@@ -6,7 +6,10 @@ angular.module('timer', [])
6
6
scope : {
7
7
interval : '=interval' ,
8
8
startTimeAttr : '=startTime' ,
9
- countdownattr : '=countdown'
9
+ countdownattr : '=countdown' ,
10
+ fullSeconds : '=fullSeconds' ,
11
+ fullMinutes : '=fullMinutes' ,
12
+ fullHours : '=fullHours'
10
13
} ,
11
14
controller : function ( $scope , $element , $attrs ) {
12
15
//angular 1.2 doesn't support attributes ending in "-start", so we're
@@ -69,7 +72,7 @@ angular.module('timer', [])
69
72
$scope . $emit ( 'timer-stopped' , { millis : $scope . millis , seconds : $scope . seconds , minutes : $scope . minutes , hours : $scope . hours , days : $scope . days } ) ;
70
73
$scope . timeoutId = null ;
71
74
} ;
72
-
75
+
73
76
$scope . end = $element [ 0 ] . end = function ( ) {
74
77
resetTimeout ( ) ;
75
78
$scope . startTime = null ;
@@ -89,9 +92,24 @@ angular.module('timer', [])
89
92
} ) ;
90
93
91
94
function calculateTimeUnits ( ) {
92
- $scope . seconds = Math . floor ( ( $scope . millis / 1000 ) % 60 ) ;
93
- $scope . minutes = Math . floor ( ( ( $scope . millis / ( 60000 ) ) % 60 ) ) ;
94
- $scope . hours = Math . floor ( ( ( $scope . millis / ( 3600000 ) ) % 24 ) ) ;
95
+ if ( $scope . fullSeconds ) {
96
+ $scope . seconds = Math . floor ( $scope . millis / 1000 ) ;
97
+ } else {
98
+ $scope . seconds = Math . floor ( ( $scope . millis / 1000 ) % 60 ) ;
99
+ }
100
+
101
+ if ( $scope . fullMinutes === true ) {
102
+ $scope . minutes = Math . floor ( $scope . millis / 60000 ) ;
103
+ } else {
104
+ $scope . minutes = Math . floor ( ( ( $scope . millis / ( 60000 ) ) % 60 ) ) ;
105
+ }
106
+
107
+ if ( $scope . fullHours === true ) {
108
+ $scope . hours = Math . floor ( $scope . millis / 3600000 ) ;
109
+ } else {
110
+ $scope . hours = Math . floor ( ( ( $scope . millis / ( 3600000 ) ) % 24 ) ) ;
111
+ }
112
+
95
113
$scope . days = Math . floor ( ( ( $scope . millis / ( 3600000 ) ) / 24 ) ) ;
96
114
}
97
115
0 commit comments