File tree Expand file tree Collapse file tree 3 files changed +220
-217
lines changed Expand file tree Collapse file tree 3 files changed +220
-217
lines changed Original file line number Diff line number Diff line change @@ -13,8 +13,9 @@ angular.module('timer', [])
13
13
}
14
14
15
15
$scope . startTime = null ;
16
- $scope . timeoutId = null ;
16
+ $scope . timeoutId = null ;
17
17
$scope . countdown = $scope . countdownattr && parseInt ( $scope . countdownattr , 10 ) > 0 ? parseInt ( $scope . countdownattr , 10 ) : undefined ;
18
+ $scope . isRunning = false ;
18
19
19
20
$scope . $on ( 'timer-start' , function ( ) {
20
21
$scope . start ( ) ;
@@ -27,20 +28,29 @@ angular.module('timer', [])
27
28
$scope . $on ( 'timer-stop' , function ( ) {
28
29
$scope . stop ( ) ;
29
30
} ) ;
31
+
32
+ function init ( ) {
33
+ if ( $scope . timeoutId ) {
34
+ $timeout . cancel ( $scope . timeoutId ) ;
35
+ }
36
+ }
30
37
31
38
$scope . start = $element [ 0 ] . start = function ( ) {
32
39
$scope . startTime = new Date ( ) ;
40
+ init ( ) ;
33
41
tick ( ) ;
34
42
} ;
35
43
36
44
$scope . resume = $element [ 0 ] . resume = function ( ) {
45
+ init ( ) ;
37
46
$scope . startTime = new Date ( ) - ( $scope . stoppedTime - $scope . startTime ) ;
38
47
tick ( ) ;
39
48
} ;
40
49
41
50
$scope . stop = $element [ 0 ] . stop = function ( ) {
42
51
$scope . stoppedTime = new Date ( ) ;
43
52
$timeout . cancel ( $scope . timeoutId ) ;
53
+ $scope . timeoutId = null ;
44
54
} ;
45
55
46
56
$element . bind ( '$destroy' , function ( ) {
Original file line number Diff line number Diff line change 98
98
< ul class ="dropdown-menu ">
99
99
< li > < a target ="_new " href ="https://github.com/siddii/angular-timer "> View on Github</ a > </ li >
100
100
< li > < a target ="_new " href ="https://github.com/siddii/angular-timer/archive/master.zip "> Download</ a > </ li >
101
+ < li >
102
+ < a href ="index.html#contribute "> Contribute</ a > </ li >
101
103
</ ul >
102
104
</ li >
103
105
</ ul >
You can’t perform that action at this time.
0 commit comments