Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
… into fix_humanize-duration-3.1.0-compatibility
  • Loading branch information
simonemazzoni committed Mar 9, 2017
2 parents 7769d00 + 8fe172e commit ca57492
Show file tree
Hide file tree
Showing 4 changed files with 296 additions and 465 deletions.
6 changes: 4 additions & 2 deletions app/js/_timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,10 @@ var timerModule = angular.module('timer', [])

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

$scope.$emit('timer-tick', {
Expand Down
27 changes: 14 additions & 13 deletions dist/angular-timer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* angular-timer - v1.3.5 - 2017-03-08 6:11 PM
* angular-timer - v1.3.5 - 2017-03-09 11:42 AM
* https://github.com/siddii/angular-timer
*
* Copyright (c) 2017 Adrian Wardell
Expand Down Expand Up @@ -341,8 +341,10 @@ var timerModule = angular.module('timer', [])

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

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

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

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

if (typeof this.timeHumanizer != 'undefined'){
time = {
'millis' : this.timeHumanizer(diffFromAlarm, { units: ["ms"] }),
'seconds' : this.timeHumanizer(diffFromAlarm, { units: ["s"] }),
'minutes' : this.timeHumanizer(diffFromAlarm, { units: ["m", "s"] }) ,
'hours' : this.timeHumanizer(diffFromAlarm, { units: ["h", "m", "s"] }) ,
'days' : this.timeHumanizer(diffFromAlarm, { units: ["d", "h", "m", "s"] }) ,
'months' : this.timeHumanizer(diffFromAlarm, { units: ["mo", "d", "h", "m", "s"] }) ,
'years' : this.timeHumanizer(diffFromAlarm, { units: ["y", "mo", "d", "h", "m", "s"] })
'millis' : this.timeHumanizer(diffFromAlarm, { units: ["milliseconds"] }),
'seconds' : this.timeHumanizer(diffFromAlarm, { units: ["seconds"] }),
'minutes' : this.timeHumanizer(diffFromAlarm, { units: ["minutes", "seconds"] }) ,
'hours' : this.timeHumanizer(diffFromAlarm, { units: ["hours", "minutes", "seconds"] }) ,
'days' : this.timeHumanizer(diffFromAlarm, { units: ["days", "hours", "minutes", "seconds"] }) ,
'months' : this.timeHumanizer(diffFromAlarm, { units: ["months", "days", "hours", "minutes", "seconds"] }) ,
'years' : this.timeHumanizer(diffFromAlarm, { units: ["years", "months", "days", "hours", "minutes", "seconds"] })
};
}
else {
Expand Down
Loading

0 comments on commit ca57492

Please sign in to comment.