This repository was archived by the owner on Apr 4, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +23
-10
lines changed Expand file tree Collapse file tree 2 files changed +23
-10
lines changed Original file line number Diff line number Diff line change 1
- ( function ( ) {
1
+ ( function ( root , factory ) {
2
+ if ( typeof define === 'function' && define . amd ) {
3
+ // AMD.
4
+ define ( [ 'moment' ] , factory ) ;
5
+ } else if ( typeof module === 'object' && module . exports ) {
6
+ // CommonJS-like
7
+ module . exports = factory ( require ( 'moment' ) ) ;
8
+ } else {
9
+ // Browser globals (root is window)
10
+ factory ( root . moment ) ;
11
+ }
12
+ } ( this , function ( moment ) {
2
13
3
14
function Timer ( duration , attributes , callback ) {
4
15
this . timerDuration = duration ;
8
19
this . stopped = false ; // If stop() is called this variable will be used to finish the paused duration once it's started again.
9
20
this . timer ;
10
21
this . startTick ;
11
- this . endTick ;
22
+ this . endTick ;
12
23
13
24
if ( attributes . start ) {
14
25
if ( attributes . wait > 0 ) {
52
63
return self . callback ( ) ;
53
64
} , this . timerDuration ) ;
54
65
}
55
-
66
+
56
67
this . updateStartEndTickFromDuration ( self . timerDuration ) ;
57
68
this . started = true ;
58
69
102
113
this . start ( ) ;
103
114
return true ;
104
115
}
105
-
116
+
106
117
return false ;
107
118
}
108
119
125
136
Timer . prototype . isStopped = function ( ) {
126
137
return this . stopped ;
127
138
}
128
-
139
+
129
140
// define internal moment reference
130
141
var moment ;
131
142
132
143
if ( typeof require === "function" ) {
133
- try { moment = require ( 'moment' ) ; }
144
+ try { moment = require ( 'moment' ) ; }
134
145
catch ( e ) { }
135
- }
146
+ }
136
147
137
148
if ( ! moment && this . moment ) {
138
149
moment = this . moment ;
157
168
} else {
158
169
throw new Error ( "First argument must be of type function or object." ) ;
159
170
}
160
-
161
- return new Timer ( this . asMilliseconds ( ) , attributes , callback ) ;
171
+
172
+ return ( function ( ) {
173
+ return new Timer ( this . asMilliseconds ( ) , attributes , callback ) ;
174
+ } . bind ( this ) ) ( ) ;
162
175
} ;
163
176
164
- } ) ( this ) ;
177
+ } ) ) ;
You can’t perform that action at this time.
0 commit comments