Skip to content

Commit ca57492

Browse files
committed
Merge branch 'master' of https://github.com/simonemazzoni/angular-timer into fix_humanize-duration-3.1.0-compatibility
2 parents 7769d00 + 8fe172e commit ca57492

File tree

4 files changed

+296
-465
lines changed

4 files changed

+296
-465
lines changed

app/js/_timer.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,10 @@ var timerModule = angular.module('timer', [])
334334

335335
//We are not using $timeout for a reason. Please read here - https://github.com/siddii/angular-timer/pull/5
336336
$scope.timeoutId = setTimeout(function () {
337-
tick();
338-
$scope.$digest();
337+
tick();
338+
// since you choose not to use $timeout, at least preserve angular cycle two way data binding
339+
// by calling $scope.$apply() instead of $scope.$digest()
340+
$scope.$apply();
339341
}, $scope.interval - adjustment);
340342

341343
$scope.$emit('timer-tick', {

dist/angular-timer.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* angular-timer - v1.3.5 - 2017-03-08 6:11 PM
2+
* angular-timer - v1.3.5 - 2017-03-09 11:42 AM
33
* https://github.com/siddii/angular-timer
44
*
55
* Copyright (c) 2017 Adrian Wardell
@@ -341,8 +341,10 @@ var timerModule = angular.module('timer', [])
341341

342342
//We are not using $timeout for a reason. Please read here - https://github.com/siddii/angular-timer/pull/5
343343
$scope.timeoutId = setTimeout(function () {
344-
tick();
345-
$scope.$digest();
344+
tick();
345+
// since you choose not to use $timeout, at least preserve angular cycle two way data binding
346+
// by calling $scope.$apply() instead of $scope.$digest()
347+
$scope.$apply();
346348
}, $scope.interval - adjustment);
347349

348350
$scope.$emit('timer-tick', {
@@ -452,9 +454,8 @@ app.factory('I18nService', function() {
452454
this.language = this.fallback;
453455
}
454456

455-
// It should be handle by the user's application itself, and not inside the directive
456-
// moment init
457-
// moment.locale(this.language);
457+
//moment init
458+
moment.locale(this.language); // @TODO maybe to remove, it should be handle by the user's application itself, and not inside the directive
458459

459460
//human duration init, using it because momentjs does not allow accurate time (
460461
// momentJS: a few moment ago, human duration : 4 seconds ago
@@ -476,13 +477,13 @@ app.factory('I18nService', function() {
476477

477478
if (typeof this.timeHumanizer != 'undefined'){
478479
time = {
479-
'millis' : this.timeHumanizer(diffFromAlarm, { units: ["ms"] }),
480-
'seconds' : this.timeHumanizer(diffFromAlarm, { units: ["s"] }),
481-
'minutes' : this.timeHumanizer(diffFromAlarm, { units: ["m", "s"] }) ,
482-
'hours' : this.timeHumanizer(diffFromAlarm, { units: ["h", "m", "s"] }) ,
483-
'days' : this.timeHumanizer(diffFromAlarm, { units: ["d", "h", "m", "s"] }) ,
484-
'months' : this.timeHumanizer(diffFromAlarm, { units: ["mo", "d", "h", "m", "s"] }) ,
485-
'years' : this.timeHumanizer(diffFromAlarm, { units: ["y", "mo", "d", "h", "m", "s"] })
480+
'millis' : this.timeHumanizer(diffFromAlarm, { units: ["milliseconds"] }),
481+
'seconds' : this.timeHumanizer(diffFromAlarm, { units: ["seconds"] }),
482+
'minutes' : this.timeHumanizer(diffFromAlarm, { units: ["minutes", "seconds"] }) ,
483+
'hours' : this.timeHumanizer(diffFromAlarm, { units: ["hours", "minutes", "seconds"] }) ,
484+
'days' : this.timeHumanizer(diffFromAlarm, { units: ["days", "hours", "minutes", "seconds"] }) ,
485+
'months' : this.timeHumanizer(diffFromAlarm, { units: ["months", "days", "hours", "minutes", "seconds"] }) ,
486+
'years' : this.timeHumanizer(diffFromAlarm, { units: ["years", "months", "days", "hours", "minutes", "seconds"] })
486487
};
487488
}
488489
else {

0 commit comments

Comments
 (0)