Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trigger $digest loop when use finishCallback #273

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions app/js/_timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var timerModule = angular.module('timer', [])
monthsS: '=?',
yearsS: '=?'
},
controller: ['$scope', '$element', '$attrs', '$timeout', 'I18nService', '$interpolate', 'progressBarService', function ($scope, $element, $attrs, $timeout, I18nService, $interpolate, progressBarService) {
controller: ['$scope', '$element', '$attrs', '$timeout', 'I18nService', '$interpolate', 'progressBarService', '$rootScope', function ($scope, $element, $attrs, $timeout, I18nService, $interpolate, progressBarService, $rootScope) {

// Checking for trim function since IE8 doesn't have it
// If not a function, create tirm with RegEx to mimic native trim
Expand Down Expand Up @@ -298,7 +298,11 @@ var timerModule = angular.module('timer', [])
$scope.millis = 0;
calculateTimeUnits();
if($scope.finishCallback) {
$scope.$eval($scope.finishCallback);
if ($rootScope.$$phase) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to avoid this undocumented API usage?

Copy link
Author

@hjzheng hjzheng Aug 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, As far as I know It is a only way to detect whether the $digest loop is running.

$scope.$evalAsync($scope.finishCallback);
} else {
$scope.$apply($scope.finishCallback);
}
}
return;
}
Expand All @@ -318,7 +322,11 @@ var timerModule = angular.module('timer', [])
else if ($scope.countdown <= 0) {
$scope.stop();
if($scope.finishCallback) {
$scope.$eval($scope.finishCallback);
if ($rootScope.$$phase) {
$scope.$evalAsync($scope.finishCallback);
} else {
$scope.$apply($scope.finishCallback);
}
}
}

Expand Down
30 changes: 30 additions & 0 deletions bower_components/moment/.bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "moment",
"version": "2.9.0",
"main": "moment.js",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests",
"tasks",
"component.json",
"composer.json",
"CONTRIBUTING.md",
"ender.js",
"Gruntfile.js",
"package.js",
"package.json"
],
"homepage": "https://github.com/moment/moment",
"_release": "2.9.0",
"_resolution": {
"type": "version",
"tag": "2.9.0",
"commit": "8b35bc74c0e88c1a8c58ccb90117a9edc9f6a479"
},
"_source": "https://github.com/moment/moment.git",
"_target": "~2.9.0",
"_originalSource": "moment"
}
423 changes: 423 additions & 0 deletions bower_components/moment/CHANGELOG.md

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions bower_components/moment/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright (c) 2011-2014 Tim Wood, Iskren Chernev, Moment.js contributors

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
28 changes: 28 additions & 0 deletions bower_components/moment/Moment.js.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Moment.js</id>
<version>2.8.4</version>
<authors>Tim Wood</authors>
<owners>Cory Deppen, Iskren Chernev</owners>
<description>A lightweight javascript date library for parsing, manipulating, and formatting dates.</description>
<releaseNotes>
- Add LTS localised format that includes seconds
- Added formatToken 'x' for unix offset in milliseconds #1938
- Support 24:00:00.000 to mean next day, at midnight.
- Accept 'date' key when creating moment with object
- Use native toISOString when we can
- Some bugfixes and language improvements
</releaseNotes>
<projectUrl>http://momentjs.com/</projectUrl>
<iconUrl>http://pbs.twimg.com/profile_images/482670411402858496/Xrtdc94q_normal.png</iconUrl>
<licenseUrl>https://raw.github.com/timrwood/moment/master/LICENSE</licenseUrl>
<tags>JavaScript date time browser node.js</tags>
</metadata>
<files>
<file src="moment.js" target="Content\Scripts" />
<file src="min/moment.min.js" target="Content\Scripts" />
<file src="min/moment-with-locales.js" target="Content\Scripts" />
<file src="min/moment-with-locales.min.js" target="Content\Scripts" />
</files>
</package>
39 changes: 39 additions & 0 deletions bower_components/moment/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[![NPM version][npm-version-image]][npm-url] [![NPM downloads][npm-downloads-image]][npm-url] [![MIT License][license-image]][license-url] [![Build Status][travis-image]][travis-url]

A lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates.

## [Documentation](http://momentjs.com/docs/)

## Upgrading to 2.0.0

There are a number of small backwards incompatible changes with version 2.0.0. [See the full descriptions here](https://gist.github.com/timrwood/e72f2eef320ed9e37c51#backwards-incompatible-changes)

* Changed language ordinal method to return the number + ordinal instead of just the ordinal.

* Changed two digit year parsing cutoff to match strptime.

* Removed `moment#sod` and `moment#eod` in favor of `moment#startOf` and `moment#endOf`.

* Removed `moment.humanizeDuration()` in favor of `moment.duration().humanize()`.

* Removed the lang data objects from the top level namespace.

* Duplicate `Date` passed to `moment()` instead of referencing it.

## [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md)

## [Contributing](https://github.com/moment/moment/blob/develop/CONTRIBUTING.md)

## License

Moment.js is freely distributable under the terms of the [MIT license](https://github.com/moment/moment/blob/develop/LICENSE).

[license-image]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat
[license-url]: LICENSE

[npm-url]: https://npmjs.org/package/moment
[npm-version-image]: http://img.shields.io/npm/v/moment.svg?style=flat
[npm-downloads-image]: http://img.shields.io/npm/dm/moment.svg?style=flat

[travis-url]: http://travis-ci.org/moment/moment
[travis-image]: http://img.shields.io/travis/moment/moment/develop.svg?style=flat
10 changes: 10 additions & 0 deletions bower_components/moment/benchmarks/clone.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var Benchmark = require('benchmark'),
moment = require("./../moment.js"),
base = moment('2013-05-25');

module.exports = {
name: 'clone',
onComplete: function(){console.log('done');},
fn: function(){base.clone();},
async: true
};
20 changes: 20 additions & 0 deletions bower_components/moment/bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "moment",
"version": "2.9.0",
"main": "moment.js",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests",
"tasks",
"component.json",
"composer.json",
"CONTRIBUTING.md",
"ender.js",
"Gruntfile.js",
"package.js",
"package.json"
]
}
71 changes: 71 additions & 0 deletions bower_components/moment/locale/af.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// moment.js locale configuration
// locale : afrikaans (af)
// author : Werner Mollentze : https://github.com/wernerm

(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
module.exports = factory(require('../moment')); // Node
} else {
factory((typeof global !== 'undefined' ? global : this).moment); // node or other global
}
}(function (moment) {
return moment.defineLocale('af', {
months : 'Januarie_Februarie_Maart_April_Mei_Junie_Julie_Augustus_September_Oktober_November_Desember'.split('_'),
monthsShort : 'Jan_Feb_Mar_Apr_Mei_Jun_Jul_Aug_Sep_Okt_Nov_Des'.split('_'),
weekdays : 'Sondag_Maandag_Dinsdag_Woensdag_Donderdag_Vrydag_Saterdag'.split('_'),
weekdaysShort : 'Son_Maa_Din_Woe_Don_Vry_Sat'.split('_'),
weekdaysMin : 'So_Ma_Di_Wo_Do_Vr_Sa'.split('_'),
meridiemParse: /vm|nm/i,
isPM : function (input) {
return /^nm$/i.test(input);
},
meridiem : function (hours, minutes, isLower) {
if (hours < 12) {
return isLower ? 'vm' : 'VM';
} else {
return isLower ? 'nm' : 'NM';
}
},
longDateFormat : {
LT : 'HH:mm',
LTS : 'LT:ss',
L : 'DD/MM/YYYY',
LL : 'D MMMM YYYY',
LLL : 'D MMMM YYYY LT',
LLLL : 'dddd, D MMMM YYYY LT'
},
calendar : {
sameDay : '[Vandag om] LT',
nextDay : '[Môre om] LT',
nextWeek : 'dddd [om] LT',
lastDay : '[Gister om] LT',
lastWeek : '[Laas] dddd [om] LT',
sameElse : 'L'
},
relativeTime : {
future : 'oor %s',
past : '%s gelede',
s : '\'n paar sekondes',
m : '\'n minuut',
mm : '%d minute',
h : '\'n uur',
hh : '%d ure',
d : '\'n dag',
dd : '%d dae',
M : '\'n maand',
MM : '%d maande',
y : '\'n jaar',
yy : '%d jaar'
},
ordinalParse: /\d{1,2}(ste|de)/,
ordinal : function (number) {
return number + ((number === 1 || number === 8 || number >= 20) ? 'ste' : 'de'); // Thanks to Joris Röling : https://github.com/jjupiter
},
week : {
dow : 1, // Maandag is die eerste dag van die week.
doy : 4 // Die week wat die 4de Januarie bevat is die eerste week van die jaar.
}
});
}));
57 changes: 57 additions & 0 deletions bower_components/moment/locale/ar-ma.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// moment.js locale configuration
// locale : Moroccan Arabic (ar-ma)
// author : ElFadili Yassine : https://github.com/ElFadiliY
// author : Abdel Said : https://github.com/abdelsaid

(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
module.exports = factory(require('../moment')); // Node
} else {
factory((typeof global !== 'undefined' ? global : this).moment); // node or other global
}
}(function (moment) {
return moment.defineLocale('ar-ma', {
months : 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'),
monthsShort : 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'),
weekdays : 'الأحد_الإتنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
weekdaysShort : 'احد_اتنين_ثلاثاء_اربعاء_خميس_جمعة_سبت'.split('_'),
weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
longDateFormat : {
LT : 'HH:mm',
LTS : 'LT:ss',
L : 'DD/MM/YYYY',
LL : 'D MMMM YYYY',
LLL : 'D MMMM YYYY LT',
LLLL : 'dddd D MMMM YYYY LT'
},
calendar : {
sameDay: '[اليوم على الساعة] LT',
nextDay: '[غدا على الساعة] LT',
nextWeek: 'dddd [على الساعة] LT',
lastDay: '[أمس على الساعة] LT',
lastWeek: 'dddd [على الساعة] LT',
sameElse: 'L'
},
relativeTime : {
future : 'في %s',
past : 'منذ %s',
s : 'ثوان',
m : 'دقيقة',
mm : '%d دقائق',
h : 'ساعة',
hh : '%d ساعات',
d : 'يوم',
dd : '%d أيام',
M : 'شهر',
MM : '%d أشهر',
y : 'سنة',
yy : '%d سنوات'
},
week : {
dow : 6, // Saturday is the first day of the week.
doy : 12 // The week that contains Jan 1st is the first week of the year.
}
});
}));
Loading