flipclockjs-rails 0.4.0b
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +22 -0
- data/README.md +54 -0
- data/lib/flipclockjs-rails.rb +8 -0
- data/lib/flipclockjs-rails/version.rb +5 -0
- data/vendor/assets/javascripts/flipclock.js +2149 -0
- data/vendor/assets/javascripts/flipclock.min.js +2 -0
- data/vendor/assets/stylesheets/flipclock.css +427 -0
- metadata +101 -0
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Trevor Strieber
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# flipclockjs-rails
|
2
|
+
|
3
|
+
This gem packages [FlipClock.js](https://github.com/objectivehtml/FlipClock) for the Rails 3.1+ asset pipeline.
|
4
|
+
|
5
|
+
FlipClock.js requires `jQuery 1.7.x+`.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
```
|
11
|
+
gem 'flipclockjs-rails', '~> 0.4.0b'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install flipclockjs-rails
|
22
|
+
```
|
23
|
+
|
24
|
+
Add the following to your JavaScript manifest file (`application.js`):
|
25
|
+
|
26
|
+
```js
|
27
|
+
//= require flipclock.min
|
28
|
+
```
|
29
|
+
|
30
|
+
Add the following to your stylesheet file:
|
31
|
+
|
32
|
+
If you are using SCSS, modify your `application.css.scss`:
|
33
|
+
|
34
|
+
```scss
|
35
|
+
@import 'flipclock';
|
36
|
+
```
|
37
|
+
|
38
|
+
If you're using plain CSS, modify your `application.css`:
|
39
|
+
|
40
|
+
```css
|
41
|
+
*= require flipclock
|
42
|
+
```
|
43
|
+
|
44
|
+
## Usage
|
45
|
+
|
46
|
+
Check out the documentation at: http://flipclockjs.com/
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
1. Fork it ( http://github.com/TrevorS/flipclockjs-rails/fork )
|
51
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
52
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
53
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
54
|
+
5. Create new Pull Request
|
@@ -0,0 +1,2149 @@
|
|
1
|
+
/*
|
2
|
+
Base.js, version 1.1a
|
3
|
+
Copyright 2006-2010, Dean Edwards
|
4
|
+
License: http://www.opensource.org/licenses/mit-license.php
|
5
|
+
*/
|
6
|
+
|
7
|
+
var Base = function() {
|
8
|
+
// dummy
|
9
|
+
};
|
10
|
+
|
11
|
+
Base.extend = function(_instance, _static) { // subclass
|
12
|
+
|
13
|
+
"use strict";
|
14
|
+
|
15
|
+
var extend = Base.prototype.extend;
|
16
|
+
|
17
|
+
// build the prototype
|
18
|
+
Base._prototyping = true;
|
19
|
+
var proto = new this();
|
20
|
+
extend.call(proto, _instance);
|
21
|
+
proto.base = function() {
|
22
|
+
// call this method from any other method to invoke that method's ancestor
|
23
|
+
};
|
24
|
+
delete Base._prototyping;
|
25
|
+
|
26
|
+
// create the wrapper for the constructor function
|
27
|
+
//var constructor = proto.constructor.valueOf(); //-dean
|
28
|
+
var constructor = proto.constructor;
|
29
|
+
var klass = proto.constructor = function() {
|
30
|
+
if (!Base._prototyping) {
|
31
|
+
if (this._constructing || this.constructor == klass) { // instantiation
|
32
|
+
this._constructing = true;
|
33
|
+
constructor.apply(this, arguments);
|
34
|
+
delete this._constructing;
|
35
|
+
} else if (arguments[0] !== null) { // casting
|
36
|
+
return (arguments[0].extend || extend).call(arguments[0], proto);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
};
|
40
|
+
|
41
|
+
// build the class interface
|
42
|
+
klass.ancestor = this;
|
43
|
+
klass.extend = this.extend;
|
44
|
+
klass.forEach = this.forEach;
|
45
|
+
klass.implement = this.implement;
|
46
|
+
klass.prototype = proto;
|
47
|
+
klass.toString = this.toString;
|
48
|
+
klass.valueOf = function(type) {
|
49
|
+
//return (type == "object") ? klass : constructor; //-dean
|
50
|
+
return (type == "object") ? klass : constructor.valueOf();
|
51
|
+
};
|
52
|
+
extend.call(klass, _static);
|
53
|
+
// class initialisation
|
54
|
+
if (typeof klass.init == "function") klass.init();
|
55
|
+
return klass;
|
56
|
+
};
|
57
|
+
|
58
|
+
Base.prototype = {
|
59
|
+
extend: function(source, value) {
|
60
|
+
if (arguments.length > 1) { // extending with a name/value pair
|
61
|
+
var ancestor = this[source];
|
62
|
+
if (ancestor && (typeof value == "function") && // overriding a method?
|
63
|
+
// the valueOf() comparison is to avoid circular references
|
64
|
+
(!ancestor.valueOf || ancestor.valueOf() != value.valueOf()) &&
|
65
|
+
/\bbase\b/.test(value)) {
|
66
|
+
// get the underlying method
|
67
|
+
var method = value.valueOf();
|
68
|
+
// override
|
69
|
+
value = function() {
|
70
|
+
var previous = this.base || Base.prototype.base;
|
71
|
+
this.base = ancestor;
|
72
|
+
var returnValue = method.apply(this, arguments);
|
73
|
+
this.base = previous;
|
74
|
+
return returnValue;
|
75
|
+
};
|
76
|
+
// point to the underlying method
|
77
|
+
value.valueOf = function(type) {
|
78
|
+
return (type == "object") ? value : method;
|
79
|
+
};
|
80
|
+
value.toString = Base.toString;
|
81
|
+
}
|
82
|
+
this[source] = value;
|
83
|
+
} else if (source) { // extending with an object literal
|
84
|
+
var extend = Base.prototype.extend;
|
85
|
+
// if this object has a customised extend method then use it
|
86
|
+
if (!Base._prototyping && typeof this != "function") {
|
87
|
+
extend = this.extend || extend;
|
88
|
+
}
|
89
|
+
var proto = {toSource: null};
|
90
|
+
// do the "toString" and other methods manually
|
91
|
+
var hidden = ["constructor", "toString", "valueOf"];
|
92
|
+
// if we are prototyping then include the constructor
|
93
|
+
var i = Base._prototyping ? 0 : 1;
|
94
|
+
while (key = hidden[i++]) {
|
95
|
+
if (source[key] != proto[key]) {
|
96
|
+
extend.call(this, key, source[key]);
|
97
|
+
|
98
|
+
}
|
99
|
+
}
|
100
|
+
// copy each of the source object's properties to this object
|
101
|
+
for (var key in source) {
|
102
|
+
if (!proto[key]) extend.call(this, key, source[key]);
|
103
|
+
}
|
104
|
+
}
|
105
|
+
return this;
|
106
|
+
}
|
107
|
+
};
|
108
|
+
|
109
|
+
// initialise
|
110
|
+
Base = Base.extend({
|
111
|
+
constructor: function() {
|
112
|
+
this.extend(arguments[0]);
|
113
|
+
}
|
114
|
+
}, {
|
115
|
+
ancestor: Object,
|
116
|
+
version: "1.1",
|
117
|
+
|
118
|
+
forEach: function(object, block, context) {
|
119
|
+
for (var key in object) {
|
120
|
+
if (this.prototype[key] === undefined) {
|
121
|
+
block.call(context, object[key], key, object);
|
122
|
+
}
|
123
|
+
}
|
124
|
+
},
|
125
|
+
|
126
|
+
implement: function() {
|
127
|
+
for (var i = 0; i < arguments.length; i++) {
|
128
|
+
if (typeof arguments[i] == "function") {
|
129
|
+
// if it's a function, call it
|
130
|
+
arguments[i](this.prototype);
|
131
|
+
} else {
|
132
|
+
// add the interface using the extend method
|
133
|
+
this.prototype.extend(arguments[i]);
|
134
|
+
}
|
135
|
+
}
|
136
|
+
return this;
|
137
|
+
},
|
138
|
+
|
139
|
+
toString: function() {
|
140
|
+
return String(this.valueOf());
|
141
|
+
}
|
142
|
+
});
|
143
|
+
/*jshint smarttabs:true */
|
144
|
+
|
145
|
+
var FlipClock;
|
146
|
+
|
147
|
+
/**
|
148
|
+
* FlipClock.js
|
149
|
+
*
|
150
|
+
* @author Justin Kimbrell
|
151
|
+
* @copyright 2013 - Objective HTML, LLC
|
152
|
+
* @licesnse http://www.opensource.org/licenses/mit-license.php
|
153
|
+
*/
|
154
|
+
|
155
|
+
(function($) {
|
156
|
+
|
157
|
+
"use strict";
|
158
|
+
|
159
|
+
/**
|
160
|
+
* FlipFlock Helper
|
161
|
+
*
|
162
|
+
* @param object A jQuery object or CSS select
|
163
|
+
* @param int An integer used to start the clock (no. seconds)
|
164
|
+
* @param object An object of properties to override the default
|
165
|
+
*/
|
166
|
+
|
167
|
+
FlipClock = function(obj, digit, options) {
|
168
|
+
return new FlipClock.Factory(obj, digit, options);
|
169
|
+
};
|
170
|
+
|
171
|
+
/**
|
172
|
+
* The global FlipClock.Lang object
|
173
|
+
*/
|
174
|
+
|
175
|
+
FlipClock.Lang = {};
|
176
|
+
|
177
|
+
/**
|
178
|
+
* The Base FlipClock class is used to extend all other FlipFlock
|
179
|
+
* classes. It handles the callbacks and the basic setters/getters
|
180
|
+
*
|
181
|
+
* @param object An object of the default properties
|
182
|
+
* @param object An object of properties to override the default
|
183
|
+
*/
|
184
|
+
|
185
|
+
FlipClock.Base = Base.extend({
|
186
|
+
|
187
|
+
/**
|
188
|
+
* Build Date
|
189
|
+
*/
|
190
|
+
|
191
|
+
buildDate: '2013-11-07',
|
192
|
+
|
193
|
+
/**
|
194
|
+
* Version
|
195
|
+
*/
|
196
|
+
|
197
|
+
version: '0.3.1',
|
198
|
+
|
199
|
+
/**
|
200
|
+
* Sets the default options
|
201
|
+
*
|
202
|
+
* @param object The default options
|
203
|
+
* @param object The override options
|
204
|
+
*/
|
205
|
+
|
206
|
+
constructor: function(_default, options) {
|
207
|
+
if(typeof _default !== "object") {
|
208
|
+
_default = {};
|
209
|
+
}
|
210
|
+
if(typeof options !== "object") {
|
211
|
+
options = {};
|
212
|
+
}
|
213
|
+
this.setOptions($.extend(true, {}, _default, options));
|
214
|
+
},
|
215
|
+
|
216
|
+
/**
|
217
|
+
* Delegates the callback to the defined method
|
218
|
+
*
|
219
|
+
* @param object The default options
|
220
|
+
* @param object The override options
|
221
|
+
*/
|
222
|
+
|
223
|
+
callback: function(method) {
|
224
|
+
if(typeof method === "function") {
|
225
|
+
var args = [];
|
226
|
+
|
227
|
+
for(var x = 1; x <= arguments.length; x++) {
|
228
|
+
if(arguments[x]) {
|
229
|
+
args.push(arguments[x]);
|
230
|
+
}
|
231
|
+
}
|
232
|
+
|
233
|
+
method.apply(this, args);
|
234
|
+
}
|
235
|
+
},
|
236
|
+
|
237
|
+
/**
|
238
|
+
* Log a string into the console if it exists
|
239
|
+
*
|
240
|
+
* @param string The name of the option
|
241
|
+
* @return mixed
|
242
|
+
*/
|
243
|
+
|
244
|
+
log: function(str) {
|
245
|
+
if(window.console && console.log) {
|
246
|
+
console.log(str);
|
247
|
+
}
|
248
|
+
},
|
249
|
+
|
250
|
+
/**
|
251
|
+
* Get an single option value. Returns false if option does not exist
|
252
|
+
*
|
253
|
+
* @param string The name of the option
|
254
|
+
* @return mixed
|
255
|
+
*/
|
256
|
+
|
257
|
+
getOption: function(index) {
|
258
|
+
if(this[index]) {
|
259
|
+
return this[index];
|
260
|
+
}
|
261
|
+
return false;
|
262
|
+
},
|
263
|
+
|
264
|
+
/**
|
265
|
+
* Get all options
|
266
|
+
*
|
267
|
+
* @return bool
|
268
|
+
*/
|
269
|
+
|
270
|
+
getOptions: function() {
|
271
|
+
return this;
|
272
|
+
},
|
273
|
+
|
274
|
+
/**
|
275
|
+
* Set a single option value
|
276
|
+
*
|
277
|
+
* @param string The name of the option
|
278
|
+
* @param mixed The value of the option
|
279
|
+
*/
|
280
|
+
|
281
|
+
setOption: function(index, value) {
|
282
|
+
this[index] = value;
|
283
|
+
},
|
284
|
+
|
285
|
+
/**
|
286
|
+
* Set a multiple options by passing a JSON object
|
287
|
+
*
|
288
|
+
* @param object The object with the options
|
289
|
+
* @param mixed The value of the option
|
290
|
+
*/
|
291
|
+
|
292
|
+
setOptions: function(options) {
|
293
|
+
for(var key in options) {
|
294
|
+
if(typeof options[key] !== "undefined") {
|
295
|
+
this.setOption(key, options[key]);
|
296
|
+
}
|
297
|
+
}
|
298
|
+
}
|
299
|
+
|
300
|
+
});
|
301
|
+
|
302
|
+
/**
|
303
|
+
* The FlipClock Factory class is used to build the clock and manage
|
304
|
+
* all the public methods.
|
305
|
+
*
|
306
|
+
* @param object A jQuery object or CSS selector used to fetch
|
307
|
+
the wrapping DOM nodes
|
308
|
+
* @param mixed This is the digit used to set the clock. If an
|
309
|
+
object is passed, 0 will be used.
|
310
|
+
* @param object An object of properties to override the default
|
311
|
+
*/
|
312
|
+
|
313
|
+
FlipClock.Factory = FlipClock.Base.extend({
|
314
|
+
|
315
|
+
/**
|
316
|
+
* Auto start the clock on page load (True|False)
|
317
|
+
*/
|
318
|
+
|
319
|
+
autoStart: true,
|
320
|
+
|
321
|
+
/**
|
322
|
+
* The callback methods
|
323
|
+
*/
|
324
|
+
|
325
|
+
callbacks: {
|
326
|
+
destroy: false,
|
327
|
+
create: false,
|
328
|
+
init: false,
|
329
|
+
interval: false,
|
330
|
+
start: false,
|
331
|
+
stop: false,
|
332
|
+
reset: false
|
333
|
+
},
|
334
|
+
|
335
|
+
/**
|
336
|
+
* The CSS classes
|
337
|
+
*/
|
338
|
+
|
339
|
+
classes: {
|
340
|
+
active: 'flip-clock-active',
|
341
|
+
before: 'flip-clock-before',
|
342
|
+
divider: 'flip-clock-divider',
|
343
|
+
dot: 'flip-clock-dot',
|
344
|
+
label: 'flip-clock-label',
|
345
|
+
flip: 'flip',
|
346
|
+
play: 'play',
|
347
|
+
wrapper: 'flip-clock-wrapper'
|
348
|
+
},
|
349
|
+
|
350
|
+
/**
|
351
|
+
* The name of the clock face class in use
|
352
|
+
*/
|
353
|
+
|
354
|
+
clockFace: 'HourlyCounter',
|
355
|
+
|
356
|
+
/**
|
357
|
+
* The name of the default clock face class to use if the defined
|
358
|
+
* clockFace variable is not a valid FlipClock.Face object
|
359
|
+
*/
|
360
|
+
|
361
|
+
defaultClockFace: 'HourlyCounter',
|
362
|
+
|
363
|
+
/**
|
364
|
+
* The default language
|
365
|
+
*/
|
366
|
+
|
367
|
+
defaultLanguage: 'english',
|
368
|
+
|
369
|
+
/**
|
370
|
+
* The language being used to display labels (string)
|
371
|
+
*/
|
372
|
+
|
373
|
+
language: 'english',
|
374
|
+
|
375
|
+
/**
|
376
|
+
* The language object after it has been loaded
|
377
|
+
*/
|
378
|
+
|
379
|
+
lang: false,
|
380
|
+
|
381
|
+
/**
|
382
|
+
* The FlipClock.Face object
|
383
|
+
*/
|
384
|
+
|
385
|
+
face: true,
|
386
|
+
|
387
|
+
/**
|
388
|
+
* Is the clock running? (True|False)
|
389
|
+
*/
|
390
|
+
|
391
|
+
running: false,
|
392
|
+
|
393
|
+
/**
|
394
|
+
* The FlipClock.Time object
|
395
|
+
*/
|
396
|
+
|
397
|
+
time: false,
|
398
|
+
|
399
|
+
/**
|
400
|
+
* The FlipClock.Timer object
|
401
|
+
*/
|
402
|
+
|
403
|
+
timer: false,
|
404
|
+
|
405
|
+
/**
|
406
|
+
* An array of FlipClock.List objects
|
407
|
+
*/
|
408
|
+
|
409
|
+
lists: [],
|
410
|
+
|
411
|
+
/**
|
412
|
+
* The wrapping jQuery object
|
413
|
+
*/
|
414
|
+
|
415
|
+
$wrapper: false,
|
416
|
+
|
417
|
+
/**
|
418
|
+
* Constructor
|
419
|
+
*
|
420
|
+
* @param object The wrapping jQuery object
|
421
|
+
* @param object Number of seconds used to start the clock
|
422
|
+
* @param object An object override options
|
423
|
+
*/
|
424
|
+
|
425
|
+
constructor: function(obj, digit, options) {
|
426
|
+
|
427
|
+
this.lists = [];
|
428
|
+
this.running = false;
|
429
|
+
this.base(options);
|
430
|
+
this.$wrapper = $(obj).addClass(this.classes.wrapper);
|
431
|
+
this.time = new FlipClock.Time(this, digit ? Math.round(digit) : 0);
|
432
|
+
this.timer = new FlipClock.Timer(this, options);
|
433
|
+
|
434
|
+
this.lang = this.loadLanguage(this.language);
|
435
|
+
this.face = this.loadClockFace(this.clockFace, options);
|
436
|
+
|
437
|
+
if(this.autoStart) {
|
438
|
+
this.start();
|
439
|
+
}
|
440
|
+
},
|
441
|
+
|
442
|
+
/**
|
443
|
+
* Load the FlipClock.Face object
|
444
|
+
*
|
445
|
+
* @param object The name of the FlickClock.Face class
|
446
|
+
* @param object An object override options
|
447
|
+
*/
|
448
|
+
|
449
|
+
loadClockFace: function(name, options) {
|
450
|
+
var face, suffix = 'Face';
|
451
|
+
|
452
|
+
name = name.ucfirst()+suffix;
|
453
|
+
|
454
|
+
if(FlipClock[name]) {
|
455
|
+
face = new FlipClock[name](this, options);
|
456
|
+
}
|
457
|
+
else {
|
458
|
+
face = new FlipClock[this.defaultClockFace+suffix](this, options);
|
459
|
+
}
|
460
|
+
|
461
|
+
face.build();
|
462
|
+
|
463
|
+
return face;
|
464
|
+
},
|
465
|
+
|
466
|
+
|
467
|
+
/**
|
468
|
+
* Load the FlipClock.Lang object
|
469
|
+
*
|
470
|
+
* @param object The name of the language to load
|
471
|
+
*/
|
472
|
+
|
473
|
+
loadLanguage: function(name) {
|
474
|
+
var lang;
|
475
|
+
|
476
|
+
if(FlipClock.Lang[name.ucfirst()]) {
|
477
|
+
lang = FlipClock.Lang[name.ucfirst()];
|
478
|
+
}
|
479
|
+
else if(FlipClock.Lang[name]) {
|
480
|
+
lang = FlipClock.Lang[name];
|
481
|
+
}
|
482
|
+
else {
|
483
|
+
lang = FlipClock.Lang[this.defaultLanguage];
|
484
|
+
}
|
485
|
+
|
486
|
+
return lang;
|
487
|
+
},
|
488
|
+
|
489
|
+
/**
|
490
|
+
* Localize strings into various languages
|
491
|
+
*
|
492
|
+
* @param string The index of the localized string
|
493
|
+
* @param object Optionally pass a lang object
|
494
|
+
*/
|
495
|
+
|
496
|
+
localize: function(index, obj) {
|
497
|
+
var lang = this.lang;
|
498
|
+
|
499
|
+
if(!index) {
|
500
|
+
return null;
|
501
|
+
}
|
502
|
+
|
503
|
+
var lindex = index.toLowerCase();
|
504
|
+
|
505
|
+
if(typeof obj == "object") {
|
506
|
+
lang = obj;
|
507
|
+
}
|
508
|
+
|
509
|
+
if(lang && lang[lindex]) {
|
510
|
+
return lang[lindex];
|
511
|
+
}
|
512
|
+
|
513
|
+
return index;
|
514
|
+
},
|
515
|
+
|
516
|
+
|
517
|
+
/**
|
518
|
+
* Starts the clock
|
519
|
+
*/
|
520
|
+
|
521
|
+
start: function(callback) {
|
522
|
+
var t = this;
|
523
|
+
|
524
|
+
if(!t.running && (!t.countdown || t.countdown && t.time.time > 0)) {
|
525
|
+
t.face.start(t.time);
|
526
|
+
t.timer.start(function() {
|
527
|
+
t.flip();
|
528
|
+
|
529
|
+
if(typeof callback === "function") {
|
530
|
+
callback();
|
531
|
+
}
|
532
|
+
});
|
533
|
+
}
|
534
|
+
else {
|
535
|
+
t.log('Trying to start timer when countdown already at 0');
|
536
|
+
}
|
537
|
+
},
|
538
|
+
|
539
|
+
/**
|
540
|
+
* Stops the clock
|
541
|
+
*/
|
542
|
+
|
543
|
+
stop: function(callback) {
|
544
|
+
this.face.stop();
|
545
|
+
this.timer.stop(callback);
|
546
|
+
|
547
|
+
for(var x in this.lists) {
|
548
|
+
this.lists[x].stop();
|
549
|
+
}
|
550
|
+
},
|
551
|
+
|
552
|
+
/**
|
553
|
+
* Reset the clock
|
554
|
+
*/
|
555
|
+
|
556
|
+
reset: function(callback) {
|
557
|
+
this.timer.reset(callback);
|
558
|
+
this.face.reset();
|
559
|
+
},
|
560
|
+
|
561
|
+
/**
|
562
|
+
* Sets the clock time
|
563
|
+
*/
|
564
|
+
|
565
|
+
setTime: function(time) {
|
566
|
+
this.time.time = time;
|
567
|
+
this.face.setTime(time);
|
568
|
+
},
|
569
|
+
|
570
|
+
/**
|
571
|
+
* Get the clock time
|
572
|
+
*
|
573
|
+
* @return object Returns a FlipClock.Time object
|
574
|
+
*/
|
575
|
+
|
576
|
+
getTime: function(time) {
|
577
|
+
return this.time;
|
578
|
+
},
|
579
|
+
|
580
|
+
/**
|
581
|
+
* Changes the increment of time to up or down (add/sub)
|
582
|
+
*/
|
583
|
+
|
584
|
+
setCountdown: function(value) {
|
585
|
+
var running = this.running;
|
586
|
+
|
587
|
+
this.countdown = value ? true : false;
|
588
|
+
|
589
|
+
if(running) {
|
590
|
+
this.stop();
|
591
|
+
this.start();
|
592
|
+
}
|
593
|
+
},
|
594
|
+
|
595
|
+
/**
|
596
|
+
* Flip the digits on the clock
|
597
|
+
*
|
598
|
+
* @param array An array of digits
|
599
|
+
*/
|
600
|
+
flip: function() {
|
601
|
+
this.face.flip();
|
602
|
+
}
|
603
|
+
|
604
|
+
});
|
605
|
+
|
606
|
+
/**
|
607
|
+
* The FlipClock Face class is the base class in which to extend
|
608
|
+
* all other FlockClock.Face classes.
|
609
|
+
*
|
610
|
+
* @param object The parent FlipClock.Factory object
|
611
|
+
* @param object An object of properties to override the default
|
612
|
+
*/
|
613
|
+
|
614
|
+
FlipClock.Face = FlipClock.Base.extend({
|
615
|
+
|
616
|
+
/**
|
617
|
+
* An array of jQuery objects used for the dividers (the colons)
|
618
|
+
*/
|
619
|
+
|
620
|
+
dividers: [],
|
621
|
+
|
622
|
+
/**
|
623
|
+
* An array of FlipClock.List objects
|
624
|
+
*/
|
625
|
+
|
626
|
+
factory: false,
|
627
|
+
|
628
|
+
/**
|
629
|
+
* An array of FlipClock.List objects
|
630
|
+
*/
|
631
|
+
|
632
|
+
lists: [],
|
633
|
+
|
634
|
+
/**
|
635
|
+
* Constructor
|
636
|
+
*
|
637
|
+
* @param object The parent FlipClock.Factory object
|
638
|
+
* @param object An object of properties to override the default
|
639
|
+
*/
|
640
|
+
|
641
|
+
constructor: function(factory, options) {
|
642
|
+
this.base(options);
|
643
|
+
this.factory = factory;
|
644
|
+
this.dividers = [];
|
645
|
+
},
|
646
|
+
|
647
|
+
/**
|
648
|
+
* Build the clock face
|
649
|
+
*/
|
650
|
+
|
651
|
+
build: function() {},
|
652
|
+
|
653
|
+
/**
|
654
|
+
* Creates a jQuery object used for the digit divider
|
655
|
+
*
|
656
|
+
* @param mixed The divider label text
|
657
|
+
* @param mixed Set true to exclude the dots in the divider.
|
658
|
+
* If not set, is false.
|
659
|
+
*/
|
660
|
+
|
661
|
+
createDivider: function(label, css, excludeDots) {
|
662
|
+
|
663
|
+
if(typeof css == "boolean" || !css) {
|
664
|
+
excludeDots = css;
|
665
|
+
css = label;
|
666
|
+
}
|
667
|
+
|
668
|
+
var dots = [
|
669
|
+
'<span class="'+this.factory.classes.dot+' top"></span>',
|
670
|
+
'<span class="'+this.factory.classes.dot+' bottom"></span>'
|
671
|
+
].join('');
|
672
|
+
|
673
|
+
if(excludeDots) {
|
674
|
+
dots = '';
|
675
|
+
}
|
676
|
+
|
677
|
+
label = this.factory.localize(label);
|
678
|
+
|
679
|
+
var html = [
|
680
|
+
'<span class="'+this.factory.classes.divider+' '+(css ? css : '').toLowerCase()+'">',
|
681
|
+
'<span class="'+this.factory.classes.label+'">'+(label ? label : '')+'</span>',
|
682
|
+
dots,
|
683
|
+
'</span>'
|
684
|
+
];
|
685
|
+
|
686
|
+
return $(html.join(''));
|
687
|
+
},
|
688
|
+
|
689
|
+
/**
|
690
|
+
* Creates a FlipClock.List object and appends it to the DOM
|
691
|
+
*
|
692
|
+
* @param mixed The digit to select in the list
|
693
|
+
* @param object An object to override the default properties
|
694
|
+
*/
|
695
|
+
|
696
|
+
createList: function(digit, options) {
|
697
|
+
if(typeof digit === "object") {
|
698
|
+
options = digit;
|
699
|
+
digit = 0;
|
700
|
+
}
|
701
|
+
|
702
|
+
var obj = new FlipClock.List(this.factory, digit, options);
|
703
|
+
|
704
|
+
//this.factory.$wrapper.append(obj.$obj);
|
705
|
+
|
706
|
+
return obj;
|
707
|
+
},
|
708
|
+
|
709
|
+
/**
|
710
|
+
* Triggers when the clock is reset
|
711
|
+
*/
|
712
|
+
|
713
|
+
reset: function() {},
|
714
|
+
|
715
|
+
/**
|
716
|
+
* Sets the clock time
|
717
|
+
*/
|
718
|
+
|
719
|
+
setTime: function(time) {
|
720
|
+
this.flip(time);
|
721
|
+
},
|
722
|
+
|
723
|
+
/**
|
724
|
+
* Sets the clock time
|
725
|
+
*/
|
726
|
+
|
727
|
+
addDigit: function(digit) {
|
728
|
+
var obj = this.createList(digit, {
|
729
|
+
classes: {
|
730
|
+
active: this.factory.classes.active,
|
731
|
+
before: this.factory.classes.before,
|
732
|
+
flip: this.factory.classes.flip
|
733
|
+
}
|
734
|
+
});
|
735
|
+
|
736
|
+
obj.$obj.insertBefore(this.factory.lists[0].$obj);
|
737
|
+
|
738
|
+
this.factory.lists.unshift(obj);
|
739
|
+
},
|
740
|
+
|
741
|
+
/**
|
742
|
+
* Triggers when the clock is started
|
743
|
+
*/
|
744
|
+
|
745
|
+
start: function() {},
|
746
|
+
|
747
|
+
/**
|
748
|
+
* Triggers when the time on the clock stops
|
749
|
+
*/
|
750
|
+
|
751
|
+
stop: function() {},
|
752
|
+
|
753
|
+
/**
|
754
|
+
* Triggers when the numbers on the clock flip
|
755
|
+
*/
|
756
|
+
|
757
|
+
flip: function(time, doNotAddPlayClass) {
|
758
|
+
var t = this;
|
759
|
+
|
760
|
+
if(!doNotAddPlayClass) {
|
761
|
+
if(!t.factory.countdown) {
|
762
|
+
t.factory.time.time++;
|
763
|
+
}
|
764
|
+
else {
|
765
|
+
if(t.factory.time.time <= 0) {
|
766
|
+
t.factory.stop();
|
767
|
+
}
|
768
|
+
|
769
|
+
t.factory.time.time--;
|
770
|
+
}
|
771
|
+
}
|
772
|
+
|
773
|
+
var offset = t.factory.lists.length - time.length;
|
774
|
+
|
775
|
+
if(offset < 0) {
|
776
|
+
offset = 0;
|
777
|
+
}
|
778
|
+
|
779
|
+
var totalNew = 0;
|
780
|
+
var reFlip = false;
|
781
|
+
|
782
|
+
$.each(time, function(i, digit) {
|
783
|
+
i += offset;
|
784
|
+
|
785
|
+
var list = t.factory.lists[i];
|
786
|
+
|
787
|
+
if(list) {
|
788
|
+
var currentDigit = list.digit;
|
789
|
+
|
790
|
+
list.select(digit);
|
791
|
+
|
792
|
+
if(digit != currentDigit && !doNotAddPlayClass) {
|
793
|
+
list.play();
|
794
|
+
}
|
795
|
+
}
|
796
|
+
else {
|
797
|
+
t.addDigit(digit);
|
798
|
+
reFlip = true;
|
799
|
+
}
|
800
|
+
});
|
801
|
+
|
802
|
+
for(var x = 0; x < time.length; x++) {
|
803
|
+
if(x >= offset && t.factory.lists[x].digit != time[x]) {
|
804
|
+
t.factory.lists[x].select(time[x]);
|
805
|
+
}
|
806
|
+
}
|
807
|
+
}
|
808
|
+
|
809
|
+
});
|
810
|
+
|
811
|
+
/**
|
812
|
+
* The FlipClock List class is used to build the list used to create
|
813
|
+
* the card flip effect. This object fascilates selecting the correct
|
814
|
+
* node by passing a specific digit.
|
815
|
+
*
|
816
|
+
* @param object A FlipClock.Factory object
|
817
|
+
* @param mixed This is the digit used to set the clock. If an
|
818
|
+
* object is passed, 0 will be used.
|
819
|
+
* @param object An object of properties to override the default
|
820
|
+
*/
|
821
|
+
|
822
|
+
FlipClock.List = FlipClock.Base.extend({
|
823
|
+
|
824
|
+
/**
|
825
|
+
* The digit (0-9)
|
826
|
+
*/
|
827
|
+
|
828
|
+
digit: 0,
|
829
|
+
|
830
|
+
/**
|
831
|
+
* The CSS classes
|
832
|
+
*/
|
833
|
+
|
834
|
+
classes: {
|
835
|
+
active: 'flip-clock-active',
|
836
|
+
before: 'flip-clock-before',
|
837
|
+
flip: 'flip'
|
838
|
+
},
|
839
|
+
|
840
|
+
/**
|
841
|
+
* The parent FlipClock.Factory object
|
842
|
+
*/
|
843
|
+
|
844
|
+
factory: false,
|
845
|
+
|
846
|
+
/**
|
847
|
+
* The wrapping jQuery object
|
848
|
+
*/
|
849
|
+
|
850
|
+
$obj: false,
|
851
|
+
|
852
|
+
/**
|
853
|
+
* The items in the list
|
854
|
+
*/
|
855
|
+
|
856
|
+
items: [],
|
857
|
+
|
858
|
+
/**
|
859
|
+
* Constructor
|
860
|
+
*
|
861
|
+
* @param object A FlipClock.Factory object
|
862
|
+
* @param int An integer use to select the correct digit
|
863
|
+
* @param object An object to override the default properties
|
864
|
+
*/
|
865
|
+
|
866
|
+
constructor: function(factory, digit, options) {
|
867
|
+
this.factory = factory;
|
868
|
+
this.digit = digit;
|
869
|
+
this.$obj = this.createList();
|
870
|
+
|
871
|
+
if(digit > 0) {
|
872
|
+
this.select(digit);
|
873
|
+
}
|
874
|
+
|
875
|
+
this.factory.$wrapper.append(this.$obj);
|
876
|
+
},
|
877
|
+
|
878
|
+
/**
|
879
|
+
* Select the digit in the list
|
880
|
+
*
|
881
|
+
* @param int A digit 0-9
|
882
|
+
*/
|
883
|
+
|
884
|
+
select: function(digit) {
|
885
|
+
if(typeof digit === "undefined") {
|
886
|
+
digit = this.digit;
|
887
|
+
}
|
888
|
+
else {
|
889
|
+
this.digit = digit;
|
890
|
+
}
|
891
|
+
|
892
|
+
var target = this.$obj.find('[data-digit="'+digit+'"]');
|
893
|
+
var active = this.$obj.find('.'+this.classes.active).removeClass(this.classes.active);
|
894
|
+
var before = this.$obj.find('.'+this.classes.before).removeClass(this.classes.before);
|
895
|
+
|
896
|
+
if(!this.factory.countdown) {
|
897
|
+
if(target.is(':first-child')) {
|
898
|
+
this.$obj.find(':last-child').addClass(this.classes.before);
|
899
|
+
}
|
900
|
+
else {
|
901
|
+
target.prev().addClass(this.classes.before);
|
902
|
+
}
|
903
|
+
}
|
904
|
+
else {
|
905
|
+
if(target.is(':last-child')) {
|
906
|
+
this.$obj.find(':first-child').addClass(this.classes.before);
|
907
|
+
}
|
908
|
+
else {
|
909
|
+
target.next().addClass(this.classes.before);
|
910
|
+
}
|
911
|
+
}
|
912
|
+
|
913
|
+
target.addClass(this.classes.active);
|
914
|
+
},
|
915
|
+
|
916
|
+
/**
|
917
|
+
* Adds the play class to the DOM object
|
918
|
+
*/
|
919
|
+
|
920
|
+
play: function() {
|
921
|
+
this.$obj.addClass(this.factory.classes.play);
|
922
|
+
},
|
923
|
+
|
924
|
+
/**
|
925
|
+
* Removes the play class to the DOM object
|
926
|
+
*/
|
927
|
+
|
928
|
+
stop: function() {
|
929
|
+
var t = this;
|
930
|
+
|
931
|
+
setTimeout(function() {
|
932
|
+
t.$obj.removeClass(t.factory.classes.play);
|
933
|
+
}, this.factory.timer.interval);
|
934
|
+
},
|
935
|
+
|
936
|
+
/**
|
937
|
+
* Create the list of digits and appends it to the DOM object
|
938
|
+
*/
|
939
|
+
|
940
|
+
createList: function() {
|
941
|
+
|
942
|
+
var html = $('<ul class="'+this.classes.flip+' '+(this.factory.running ? this.factory.classes.play : '')+'" />');
|
943
|
+
|
944
|
+
for(var x = 0; x < 10; x++) {
|
945
|
+
var item = $([
|
946
|
+
'<li data-digit="'+x+'">',
|
947
|
+
'<a href="#">',
|
948
|
+
'<div class="up">',
|
949
|
+
'<div class="shadow"></div>',
|
950
|
+
'<div class="inn">'+x+'</div>',
|
951
|
+
'</div>',
|
952
|
+
'<div class="down">',
|
953
|
+
'<div class="shadow"></div>',
|
954
|
+
'<div class="inn">'+x+'</div>',
|
955
|
+
'</div>',
|
956
|
+
'</a>',
|
957
|
+
'</li>'].join(''));
|
958
|
+
|
959
|
+
this.items.push(item);
|
960
|
+
|
961
|
+
html.append(item);
|
962
|
+
}
|
963
|
+
|
964
|
+
return html;
|
965
|
+
}
|
966
|
+
});
|
967
|
+
|
968
|
+
/**
|
969
|
+
* The FlipClock Time class is used to manage all the time
|
970
|
+
* calculations.
|
971
|
+
*
|
972
|
+
* @param object A FlipClock.Factory object
|
973
|
+
* @param mixed This is the digit used to set the clock. If an
|
974
|
+
* object is passed, 0 will be used.
|
975
|
+
* @param object An object of properties to override the default
|
976
|
+
*/
|
977
|
+
|
978
|
+
FlipClock.Time = FlipClock.Base.extend({
|
979
|
+
|
980
|
+
/**
|
981
|
+
* The time (in seconds)
|
982
|
+
*/
|
983
|
+
|
984
|
+
minimumDigits: 0,
|
985
|
+
|
986
|
+
/**
|
987
|
+
* The time (in seconds)
|
988
|
+
*/
|
989
|
+
|
990
|
+
time: 0,
|
991
|
+
|
992
|
+
/**
|
993
|
+
* The parent FlipClock.Factory object
|
994
|
+
*/
|
995
|
+
|
996
|
+
factory: false,
|
997
|
+
|
998
|
+
/**
|
999
|
+
* Constructor
|
1000
|
+
*
|
1001
|
+
* @param object A FlipClock.Factory object
|
1002
|
+
* @param int An integer use to select the correct digit
|
1003
|
+
* @param object An object to override the default properties
|
1004
|
+
*/
|
1005
|
+
|
1006
|
+
constructor: function(factory, time, options) {
|
1007
|
+
this.base(options);
|
1008
|
+
this.factory = factory;
|
1009
|
+
|
1010
|
+
if(time) {
|
1011
|
+
this.time = time;
|
1012
|
+
}
|
1013
|
+
},
|
1014
|
+
|
1015
|
+
/**
|
1016
|
+
* Convert a string or integer to an array of digits
|
1017
|
+
*
|
1018
|
+
* @param mixed String or Integer of digits
|
1019
|
+
* @return array An array of digits
|
1020
|
+
*/
|
1021
|
+
|
1022
|
+
convertDigitsToArray: function(str) {
|
1023
|
+
var data = [];
|
1024
|
+
|
1025
|
+
str = str.toString();
|
1026
|
+
|
1027
|
+
for(var x = 0;x < str.length; x++) {
|
1028
|
+
if(str[x].match(/^\d*$/g)) {
|
1029
|
+
data.push(str[x]);
|
1030
|
+
}
|
1031
|
+
}
|
1032
|
+
|
1033
|
+
return data;
|
1034
|
+
},
|
1035
|
+
|
1036
|
+
/**
|
1037
|
+
* Get a specific digit from the time integer
|
1038
|
+
*
|
1039
|
+
* @param int The specific digit to select from the time
|
1040
|
+
* @return mixed Returns FALSE if no digit is found, otherwise
|
1041
|
+
* the method returns the defined digit
|
1042
|
+
*/
|
1043
|
+
|
1044
|
+
digit: function(i) {
|
1045
|
+
var timeStr = this.toString();
|
1046
|
+
var length = timeStr.length;
|
1047
|
+
|
1048
|
+
if(timeStr[length - i]) {
|
1049
|
+
return timeStr[length - i];
|
1050
|
+
}
|
1051
|
+
|
1052
|
+
return false;
|
1053
|
+
},
|
1054
|
+
|
1055
|
+
/**
|
1056
|
+
* Formats any array of digits into a valid array of digits
|
1057
|
+
*
|
1058
|
+
* @param mixed An array of digits
|
1059
|
+
* @return array An array of digits
|
1060
|
+
*/
|
1061
|
+
|
1062
|
+
digitize: function(obj) {
|
1063
|
+
var data = [];
|
1064
|
+
|
1065
|
+
$.each(obj, function(i, value) {
|
1066
|
+
value = value.toString();
|
1067
|
+
|
1068
|
+
if(value.length == 1) {
|
1069
|
+
value = '0'+value;
|
1070
|
+
}
|
1071
|
+
|
1072
|
+
for(var x = 0; x < value.length; x++) {
|
1073
|
+
data.push(value[x]);
|
1074
|
+
}
|
1075
|
+
});
|
1076
|
+
|
1077
|
+
if(data.length > this.minimumDigits) {
|
1078
|
+
this.minimumDigits = data.length;
|
1079
|
+
}
|
1080
|
+
|
1081
|
+
if(this.minimumDigits > data.length) {
|
1082
|
+
data.unshift('0');
|
1083
|
+
}
|
1084
|
+
|
1085
|
+
return data;
|
1086
|
+
},
|
1087
|
+
|
1088
|
+
/**
|
1089
|
+
* Gets a daily breakdown
|
1090
|
+
*
|
1091
|
+
* @return object Returns a digitized object
|
1092
|
+
*/
|
1093
|
+
|
1094
|
+
getDayCounter: function(includeSeconds) {
|
1095
|
+
var digits = [
|
1096
|
+
this.getDays(),
|
1097
|
+
this.getHours(true),
|
1098
|
+
this.getMinutes(true)
|
1099
|
+
];
|
1100
|
+
|
1101
|
+
if(includeSeconds) {
|
1102
|
+
digits.push(this.getSeconds(true));
|
1103
|
+
}
|
1104
|
+
|
1105
|
+
return this.digitize(digits);
|
1106
|
+
},
|
1107
|
+
|
1108
|
+
/**
|
1109
|
+
* Gets number of days
|
1110
|
+
*
|
1111
|
+
* @param bool Should perform a modulus? If not sent, then no.
|
1112
|
+
* @return int Retuns a floored integer
|
1113
|
+
*/
|
1114
|
+
|
1115
|
+
getDays: function(mod) {
|
1116
|
+
var days = this.time / 60 / 60 / 24;
|
1117
|
+
|
1118
|
+
if(mod) {
|
1119
|
+
days = days % 7;
|
1120
|
+
}
|
1121
|
+
|
1122
|
+
return Math.floor(days);
|
1123
|
+
},
|
1124
|
+
|
1125
|
+
/**
|
1126
|
+
* Gets an hourly breakdown
|
1127
|
+
*
|
1128
|
+
* @return object Returns a digitized object
|
1129
|
+
*/
|
1130
|
+
|
1131
|
+
getHourCounter: function() {
|
1132
|
+
var obj = this.digitize([
|
1133
|
+
this.getHours(),
|
1134
|
+
this.getMinutes(true),
|
1135
|
+
this.getSeconds(true)
|
1136
|
+
]);
|
1137
|
+
|
1138
|
+
return obj;
|
1139
|
+
},
|
1140
|
+
|
1141
|
+
/**
|
1142
|
+
* Gets an hourly breakdown
|
1143
|
+
*
|
1144
|
+
* @return object Returns a digitized object
|
1145
|
+
*/
|
1146
|
+
|
1147
|
+
getHourly: function() {
|
1148
|
+
return this.getHourCounter();
|
1149
|
+
},
|
1150
|
+
|
1151
|
+
/**
|
1152
|
+
* Gets number of hours
|
1153
|
+
*
|
1154
|
+
* @param bool Should perform a modulus? If not sent, then no.
|
1155
|
+
* @return int Retuns a floored integer
|
1156
|
+
*/
|
1157
|
+
|
1158
|
+
getHours: function(mod) {
|
1159
|
+
var hours = this.time / 60 / 60;
|
1160
|
+
|
1161
|
+
if(mod) {
|
1162
|
+
hours = hours % 24;
|
1163
|
+
}
|
1164
|
+
|
1165
|
+
return Math.floor(hours);
|
1166
|
+
},
|
1167
|
+
|
1168
|
+
/**
|
1169
|
+
* Gets the twenty-four hour time
|
1170
|
+
*
|
1171
|
+
* @return object returns a digitized object
|
1172
|
+
*/
|
1173
|
+
|
1174
|
+
getMilitaryTime: function() {
|
1175
|
+
var date = new Date();
|
1176
|
+
var obj = this.digitize([
|
1177
|
+
date.getHours(),
|
1178
|
+
date.getMinutes(),
|
1179
|
+
date.getSeconds()
|
1180
|
+
]);
|
1181
|
+
|
1182
|
+
return obj;
|
1183
|
+
},
|
1184
|
+
|
1185
|
+
/**
|
1186
|
+
* Gets number of minutes
|
1187
|
+
*
|
1188
|
+
* @param bool Should perform a modulus? If not sent, then no.
|
1189
|
+
* @return int Retuns a floored integer
|
1190
|
+
*/
|
1191
|
+
|
1192
|
+
getMinutes: function(mod) {
|
1193
|
+
var minutes = this.time / 60;
|
1194
|
+
|
1195
|
+
if(mod) {
|
1196
|
+
minutes = minutes % 60;
|
1197
|
+
}
|
1198
|
+
|
1199
|
+
return Math.floor(minutes);
|
1200
|
+
},
|
1201
|
+
|
1202
|
+
/**
|
1203
|
+
* Gets a minute breakdown
|
1204
|
+
*/
|
1205
|
+
|
1206
|
+
getMinuteCounter: function() {
|
1207
|
+
var obj = this.digitize([
|
1208
|
+
this.getMinutes(),
|
1209
|
+
this.getSeconds(true)
|
1210
|
+
]);
|
1211
|
+
|
1212
|
+
return obj;
|
1213
|
+
},
|
1214
|
+
|
1215
|
+
/**
|
1216
|
+
* Gets number of seconds
|
1217
|
+
*
|
1218
|
+
* @param bool Should perform a modulus? If not sent, then no.
|
1219
|
+
* @return int Retuns a ceiled integer
|
1220
|
+
*/
|
1221
|
+
|
1222
|
+
getSeconds: function(mod) {
|
1223
|
+
var seconds = this.time;
|
1224
|
+
|
1225
|
+
if(mod) {
|
1226
|
+
if(seconds == 60) {
|
1227
|
+
seconds = 0;
|
1228
|
+
}
|
1229
|
+
else {
|
1230
|
+
seconds = seconds % 60;
|
1231
|
+
}
|
1232
|
+
}
|
1233
|
+
|
1234
|
+
return Math.ceil(seconds);
|
1235
|
+
},
|
1236
|
+
|
1237
|
+
/**
|
1238
|
+
* Gets the current twelve hour time
|
1239
|
+
*
|
1240
|
+
* @return object Returns a digitized object
|
1241
|
+
*/
|
1242
|
+
|
1243
|
+
getTime: function() {
|
1244
|
+
var date = new Date();
|
1245
|
+
var hours = date.getHours();
|
1246
|
+
var merid = hours > 12 ? 'PM' : 'AM';
|
1247
|
+
var obj = this.digitize([
|
1248
|
+
hours > 12 ? hours - 12 : (hours === 0 ? 12 : hours),
|
1249
|
+
date.getMinutes(),
|
1250
|
+
date.getSeconds()
|
1251
|
+
]);
|
1252
|
+
|
1253
|
+
return obj;
|
1254
|
+
},
|
1255
|
+
|
1256
|
+
/**
|
1257
|
+
* Gets number of weeks
|
1258
|
+
*
|
1259
|
+
* @param bool Should perform a modulus? If not sent, then no.
|
1260
|
+
* @return int Retuns a floored integer
|
1261
|
+
*/
|
1262
|
+
|
1263
|
+
getWeeks: function() {
|
1264
|
+
var weeks = this.time / 60 / 60 / 24 / 7;
|
1265
|
+
|
1266
|
+
if(mod) {
|
1267
|
+
weeks = weeks % 52;
|
1268
|
+
}
|
1269
|
+
|
1270
|
+
return Math.floor(weeks);
|
1271
|
+
},
|
1272
|
+
|
1273
|
+
/**
|
1274
|
+
* Removes a specific number of leading zeros from the array.
|
1275
|
+
* This method prevents you from removing too many digits, even
|
1276
|
+
* if you try.
|
1277
|
+
*
|
1278
|
+
* @param int Total number of digits to remove
|
1279
|
+
* @return array An array of digits
|
1280
|
+
*/
|
1281
|
+
|
1282
|
+
removeLeadingZeros: function(totalDigits, digits) {
|
1283
|
+
var total = 0;
|
1284
|
+
var newArray = [];
|
1285
|
+
|
1286
|
+
$.each(digits, function(i, digit) {
|
1287
|
+
if(i < totalDigits) {
|
1288
|
+
total += parseInt(digits[i], 10);
|
1289
|
+
}
|
1290
|
+
else {
|
1291
|
+
newArray.push(digits[i]);
|
1292
|
+
}
|
1293
|
+
});
|
1294
|
+
|
1295
|
+
if(total === 0) {
|
1296
|
+
return newArray;
|
1297
|
+
}
|
1298
|
+
|
1299
|
+
return digits;
|
1300
|
+
},
|
1301
|
+
|
1302
|
+
/**
|
1303
|
+
* Converts the object to a human readable string
|
1304
|
+
*/
|
1305
|
+
|
1306
|
+
toString: function() {
|
1307
|
+
return this.time.toString();
|
1308
|
+
}
|
1309
|
+
|
1310
|
+
/*
|
1311
|
+
getYears: function() {
|
1312
|
+
return Math.floor(this.time / 60 / 60 / 24 / 7 / 52);
|
1313
|
+
},
|
1314
|
+
|
1315
|
+
getDecades: function() {
|
1316
|
+
return Math.floor(this.getWeeks() / 10);
|
1317
|
+
}*/
|
1318
|
+
});
|
1319
|
+
|
1320
|
+
/**
|
1321
|
+
* The FlipClock.Timer object managers the JS timers
|
1322
|
+
*
|
1323
|
+
* @param object The parent FlipClock.Factory object
|
1324
|
+
* @param object Override the default options
|
1325
|
+
*/
|
1326
|
+
|
1327
|
+
FlipClock.Timer = FlipClock.Base.extend({
|
1328
|
+
|
1329
|
+
/**
|
1330
|
+
* Callbacks
|
1331
|
+
*/
|
1332
|
+
|
1333
|
+
callbacks: {
|
1334
|
+
destroy: false,
|
1335
|
+
create: false,
|
1336
|
+
init: false,
|
1337
|
+
interval: false,
|
1338
|
+
start: false,
|
1339
|
+
stop: false,
|
1340
|
+
reset: false
|
1341
|
+
},
|
1342
|
+
|
1343
|
+
/**
|
1344
|
+
* FlipClock timer count (how many intervals have passed)
|
1345
|
+
*/
|
1346
|
+
|
1347
|
+
count: 0,
|
1348
|
+
|
1349
|
+
/**
|
1350
|
+
* The parent FlipClock.Factory object
|
1351
|
+
*/
|
1352
|
+
|
1353
|
+
factory: false,
|
1354
|
+
|
1355
|
+
/**
|
1356
|
+
* Timer interval (1 second by default)
|
1357
|
+
*/
|
1358
|
+
|
1359
|
+
interval: 1000,
|
1360
|
+
|
1361
|
+
/**
|
1362
|
+
* Constructor
|
1363
|
+
*
|
1364
|
+
* @return void
|
1365
|
+
*/
|
1366
|
+
|
1367
|
+
constructor: function(factory, options) {
|
1368
|
+
this.base(options);
|
1369
|
+
this.factory = factory;
|
1370
|
+
this.callback(this.callbacks.init);
|
1371
|
+
this.callback(this.callbacks.create);
|
1372
|
+
},
|
1373
|
+
|
1374
|
+
/**
|
1375
|
+
* This method gets the elapsed the time as an interger
|
1376
|
+
*
|
1377
|
+
* @return void
|
1378
|
+
*/
|
1379
|
+
|
1380
|
+
getElapsed: function() {
|
1381
|
+
return this.count * this.interval;
|
1382
|
+
},
|
1383
|
+
|
1384
|
+
/**
|
1385
|
+
* This method gets the elapsed the time as a Date object
|
1386
|
+
*
|
1387
|
+
* @return void
|
1388
|
+
*/
|
1389
|
+
|
1390
|
+
getElapsedTime: function() {
|
1391
|
+
return new Date(this.time + this.getElapsed());
|
1392
|
+
},
|
1393
|
+
|
1394
|
+
/**
|
1395
|
+
* This method is resets the timer
|
1396
|
+
*
|
1397
|
+
* @param callback This method resets the timer back to 0
|
1398
|
+
* @return void
|
1399
|
+
*/
|
1400
|
+
|
1401
|
+
reset: function(callback) {
|
1402
|
+
clearInterval(this.timer);
|
1403
|
+
this.count = 0;
|
1404
|
+
this._setInterval(callback);
|
1405
|
+
this.callback(this.callbacks.reset);
|
1406
|
+
},
|
1407
|
+
|
1408
|
+
/**
|
1409
|
+
* This method is starts the timer
|
1410
|
+
*
|
1411
|
+
* @param callback A function that is called once the timer is destroyed
|
1412
|
+
* @return void
|
1413
|
+
*/
|
1414
|
+
|
1415
|
+
start: function(callback) {
|
1416
|
+
this.factory.running = true;
|
1417
|
+
this._createTimer(callback);
|
1418
|
+
this.callback(this.callbacks.start);
|
1419
|
+
},
|
1420
|
+
|
1421
|
+
/**
|
1422
|
+
* This method is stops the timer
|
1423
|
+
*
|
1424
|
+
* @param callback A function that is called once the timer is destroyed
|
1425
|
+
* @return void
|
1426
|
+
*/
|
1427
|
+
|
1428
|
+
stop: function(callback) {
|
1429
|
+
this.factory.running = false;
|
1430
|
+
this._clearInterval(callback);
|
1431
|
+
this.callback(this.callbacks.stop);
|
1432
|
+
this.callback(callback);
|
1433
|
+
},
|
1434
|
+
|
1435
|
+
/**
|
1436
|
+
* Clear the timer interval
|
1437
|
+
*
|
1438
|
+
* @return void
|
1439
|
+
*/
|
1440
|
+
|
1441
|
+
_clearInterval: function() {
|
1442
|
+
clearInterval(this.timer);
|
1443
|
+
},
|
1444
|
+
|
1445
|
+
/**
|
1446
|
+
* Create the timer object
|
1447
|
+
*
|
1448
|
+
* @param callback A function that is called once the timer is created
|
1449
|
+
* @return void
|
1450
|
+
*/
|
1451
|
+
|
1452
|
+
_createTimer: function(callback) {
|
1453
|
+
this._setInterval(callback);
|
1454
|
+
},
|
1455
|
+
|
1456
|
+
/**
|
1457
|
+
* Destroy the timer object
|
1458
|
+
*
|
1459
|
+
* @param callback A function that is called once the timer is destroyed
|
1460
|
+
* @return void
|
1461
|
+
*/
|
1462
|
+
|
1463
|
+
_destroyTimer: function(callback) {
|
1464
|
+
this._clearInterval();
|
1465
|
+
this.timer = false;
|
1466
|
+
this.callback(callback);
|
1467
|
+
this.callback(this.callbacks.destroy);
|
1468
|
+
},
|
1469
|
+
|
1470
|
+
/**
|
1471
|
+
* This method is called each time the timer interval is ran
|
1472
|
+
*
|
1473
|
+
* @param callback A function that is called once the timer is destroyed
|
1474
|
+
* @return void
|
1475
|
+
*/
|
1476
|
+
|
1477
|
+
_interval: function(callback) {
|
1478
|
+
this.callback(this.callbacks.interval);
|
1479
|
+
this.callback(callback);
|
1480
|
+
this.count++;
|
1481
|
+
},
|
1482
|
+
|
1483
|
+
/**
|
1484
|
+
* This sets the timer interval
|
1485
|
+
*
|
1486
|
+
* @param callback A function that is called once the timer is destroyed
|
1487
|
+
* @return void
|
1488
|
+
*/
|
1489
|
+
|
1490
|
+
_setInterval: function(callback) {
|
1491
|
+
var t = this;
|
1492
|
+
|
1493
|
+
t.timer = setInterval(function() {
|
1494
|
+
t._interval(callback);
|
1495
|
+
}, this.interval);
|
1496
|
+
}
|
1497
|
+
|
1498
|
+
});
|
1499
|
+
|
1500
|
+
/**
|
1501
|
+
* Capitalize the first letter in a string
|
1502
|
+
*
|
1503
|
+
* @return string
|
1504
|
+
*/
|
1505
|
+
|
1506
|
+
String.prototype.ucfirst = function() {
|
1507
|
+
return this.substr(0, 1).toUpperCase() + this.substr(1);
|
1508
|
+
};
|
1509
|
+
|
1510
|
+
/**
|
1511
|
+
* jQuery helper method
|
1512
|
+
*
|
1513
|
+
* @param int An integer used to start the clock (no. seconds)
|
1514
|
+
* @param object An object of properties to override the default
|
1515
|
+
*/
|
1516
|
+
|
1517
|
+
$.fn.FlipClock = function(digit, options) {
|
1518
|
+
if(typeof digit == "object") {
|
1519
|
+
options = digit;
|
1520
|
+
digit = 0;
|
1521
|
+
}
|
1522
|
+
return new FlipClock($(this), digit, options);
|
1523
|
+
};
|
1524
|
+
|
1525
|
+
/**
|
1526
|
+
* jQuery helper method
|
1527
|
+
*
|
1528
|
+
* @param int An integer used to start the clock (no. seconds)
|
1529
|
+
* @param object An object of properties to override the default
|
1530
|
+
*/
|
1531
|
+
|
1532
|
+
$.fn.flipClock = function(digit, options) {
|
1533
|
+
return $.fn.FlipClock(digit, options);
|
1534
|
+
};
|
1535
|
+
|
1536
|
+
}(jQuery));
|
1537
|
+
|
1538
|
+
(function($) {
|
1539
|
+
|
1540
|
+
/**
|
1541
|
+
* Twenty-Four Hour Clock Face
|
1542
|
+
*
|
1543
|
+
* This class will generate a twenty-four our clock for FlipClock.js
|
1544
|
+
*
|
1545
|
+
* @param object The parent FlipClock.Factory object
|
1546
|
+
* @param object An object of properties to override the default
|
1547
|
+
*/
|
1548
|
+
|
1549
|
+
FlipClock.TwentyFourHourClockFace = FlipClock.Face.extend({
|
1550
|
+
|
1551
|
+
/**
|
1552
|
+
* Constructor
|
1553
|
+
*
|
1554
|
+
* @param object The parent FlipClock.Factory object
|
1555
|
+
* @param object An object of properties to override the default
|
1556
|
+
*/
|
1557
|
+
|
1558
|
+
constructor: function(factory, options) {
|
1559
|
+
factory.countdown = false;
|
1560
|
+
this.base(factory, options);
|
1561
|
+
},
|
1562
|
+
|
1563
|
+
/**
|
1564
|
+
* Build the clock face
|
1565
|
+
*
|
1566
|
+
* @param object Pass the time that should be used to display on the clock.
|
1567
|
+
*/
|
1568
|
+
|
1569
|
+
build: function(time) {
|
1570
|
+
var t = this;
|
1571
|
+
var children = this.factory.$wrapper.find('ul');
|
1572
|
+
|
1573
|
+
time = time ? time : (this.factory.time.time || this.factory.time.getMilitaryTime());
|
1574
|
+
|
1575
|
+
if(time.length > children.length) {
|
1576
|
+
$.each(time, function(i, digit) {
|
1577
|
+
t.factory.lists.push(t.createList(digit));
|
1578
|
+
});
|
1579
|
+
}
|
1580
|
+
|
1581
|
+
this.dividers.push(this.createDivider());
|
1582
|
+
this.dividers.push(this.createDivider());
|
1583
|
+
|
1584
|
+
$(this.dividers[0]).insertBefore(this.factory.lists[this.factory.lists.length - 2].$obj);
|
1585
|
+
$(this.dividers[1]).insertBefore(this.factory.lists[this.factory.lists.length - 4].$obj);
|
1586
|
+
|
1587
|
+
this._clearExcessDigits();
|
1588
|
+
|
1589
|
+
if(this.autoStart) {
|
1590
|
+
this.start();
|
1591
|
+
}
|
1592
|
+
},
|
1593
|
+
|
1594
|
+
/**
|
1595
|
+
* Flip the clock face
|
1596
|
+
*/
|
1597
|
+
|
1598
|
+
flip: function(time) {
|
1599
|
+
time = time ? time : this.factory.time.getMilitaryTime();
|
1600
|
+
this.base(time);
|
1601
|
+
},
|
1602
|
+
|
1603
|
+
/**
|
1604
|
+
* Clear the excess digits from the tens columns for sec/min
|
1605
|
+
*/
|
1606
|
+
|
1607
|
+
_clearExcessDigits: function() {
|
1608
|
+
var tenSeconds = this.factory.lists[this.factory.lists.length - 2];
|
1609
|
+
var tenMinutes = this.factory.lists[this.factory.lists.length - 4];
|
1610
|
+
|
1611
|
+
for(var x = 6; x < 10; x++) {
|
1612
|
+
tenSeconds.$obj.find('li:last-child').remove();
|
1613
|
+
tenMinutes.$obj.find('li:last-child').remove();
|
1614
|
+
}
|
1615
|
+
}
|
1616
|
+
|
1617
|
+
});
|
1618
|
+
|
1619
|
+
}(jQuery));
|
1620
|
+
(function($) {
|
1621
|
+
|
1622
|
+
/**
|
1623
|
+
* Counter Clock Face
|
1624
|
+
*
|
1625
|
+
* This class will generate a generice flip counter. The timer has been
|
1626
|
+
* disabled. clock.increment() and clock.decrement() have been added.
|
1627
|
+
*
|
1628
|
+
* @param object The parent FlipClock.Factory object
|
1629
|
+
* @param object An object of properties to override the default
|
1630
|
+
*/
|
1631
|
+
|
1632
|
+
FlipClock.CounterFace = FlipClock.Face.extend({
|
1633
|
+
|
1634
|
+
autoStart: false,
|
1635
|
+
|
1636
|
+
/**
|
1637
|
+
* Constructor
|
1638
|
+
*
|
1639
|
+
* @param object The parent FlipClock.Factory object
|
1640
|
+
* @param object An object of properties to override the default
|
1641
|
+
*/
|
1642
|
+
|
1643
|
+
constructor: function(factory, options) {
|
1644
|
+
factory.timer.interval = 0;
|
1645
|
+
factory.autoStart = false;
|
1646
|
+
factory.running = true;
|
1647
|
+
|
1648
|
+
factory.increment = function() {
|
1649
|
+
factory.countdown = false;
|
1650
|
+
factory.setTime(factory.getTime().time + 1);
|
1651
|
+
};
|
1652
|
+
|
1653
|
+
factory.decrement = function() {
|
1654
|
+
factory.countdown = true;
|
1655
|
+
factory.setTime(factory.getTime().time - 1);
|
1656
|
+
};
|
1657
|
+
|
1658
|
+
factory.setValue = function(digits) {
|
1659
|
+
factory.setTime(digits);
|
1660
|
+
};
|
1661
|
+
|
1662
|
+
factory.setCounter = function(digits) {
|
1663
|
+
factory.setTime(digits);
|
1664
|
+
};
|
1665
|
+
|
1666
|
+
this.base(factory, options);
|
1667
|
+
},
|
1668
|
+
|
1669
|
+
/**
|
1670
|
+
* Build the clock face
|
1671
|
+
*/
|
1672
|
+
|
1673
|
+
build: function() {
|
1674
|
+
var t = this;
|
1675
|
+
var children = this.factory.$wrapper.find('ul');
|
1676
|
+
var lists = [];
|
1677
|
+
var time = this.factory.getTime().digitize([this.factory.getTime().time]);
|
1678
|
+
|
1679
|
+
if(time.length > children.length) {
|
1680
|
+
$.each(time, function(i, digit) {
|
1681
|
+
var list = t.createList(digit);
|
1682
|
+
|
1683
|
+
list.select(digit);
|
1684
|
+
lists.push(list);
|
1685
|
+
});
|
1686
|
+
|
1687
|
+
}
|
1688
|
+
|
1689
|
+
$.each(lists, function(i, list) {
|
1690
|
+
list.play();
|
1691
|
+
});
|
1692
|
+
|
1693
|
+
this.factory.lists = lists;
|
1694
|
+
},
|
1695
|
+
|
1696
|
+
/**
|
1697
|
+
* Flip the clock face
|
1698
|
+
*/
|
1699
|
+
|
1700
|
+
flip: function(doNotAddPlayClass) {
|
1701
|
+
var time = this.factory.getTime().digitize([this.factory.getTime().time]);
|
1702
|
+
|
1703
|
+
this.base(time, doNotAddPlayClass);
|
1704
|
+
},
|
1705
|
+
|
1706
|
+
});
|
1707
|
+
|
1708
|
+
}(jQuery));
|
1709
|
+
(function($) {
|
1710
|
+
|
1711
|
+
/**
|
1712
|
+
* Daily Counter Clock Face
|
1713
|
+
*
|
1714
|
+
* This class will generate a daily counter for FlipClock.js. A
|
1715
|
+
* daily counter will track days, hours, minutes, and seconds. If
|
1716
|
+
* the number of available digits is exceeded in the count, a new
|
1717
|
+
* digit will be created.
|
1718
|
+
*
|
1719
|
+
* @param object The parent FlipClock.Factory object
|
1720
|
+
* @param object An object of properties to override the default
|
1721
|
+
*/
|
1722
|
+
|
1723
|
+
FlipClock.DailyCounterFace = FlipClock.Face.extend({
|
1724
|
+
|
1725
|
+
showSeconds: true,
|
1726
|
+
|
1727
|
+
/**
|
1728
|
+
* Constructor
|
1729
|
+
*
|
1730
|
+
* @param object The parent FlipClock.Factory object
|
1731
|
+
* @param object An object of properties to override the default
|
1732
|
+
*/
|
1733
|
+
|
1734
|
+
constructor: function(factory, options) {
|
1735
|
+
this.base(factory, options);
|
1736
|
+
},
|
1737
|
+
|
1738
|
+
/**
|
1739
|
+
* Build the clock face
|
1740
|
+
*/
|
1741
|
+
|
1742
|
+
build: function(excludeHours, time) {
|
1743
|
+
var t = this;
|
1744
|
+
var children = this.factory.$wrapper.find('ul');
|
1745
|
+
var lists = [];
|
1746
|
+
var offset = 0;
|
1747
|
+
|
1748
|
+
time = time ? time : this.factory.time.getDayCounter(this.showSeconds);
|
1749
|
+
|
1750
|
+
if(time.length > children.length) {
|
1751
|
+
$.each(time, function(i, digit) {
|
1752
|
+
lists.push(t.createList(digit));
|
1753
|
+
});
|
1754
|
+
}
|
1755
|
+
|
1756
|
+
this.factory.lists = lists;
|
1757
|
+
|
1758
|
+
if(this.showSeconds) {
|
1759
|
+
$(this.createDivider('Seconds')).insertBefore(this.factory.lists[this.factory.lists.length - 2].$obj);
|
1760
|
+
}
|
1761
|
+
else
|
1762
|
+
{
|
1763
|
+
offset = 2;
|
1764
|
+
}
|
1765
|
+
|
1766
|
+
$(this.createDivider('Minutes')).insertBefore(this.factory.lists[this.factory.lists.length - 4 + offset].$obj);
|
1767
|
+
$(this.createDivider('Hours')).insertBefore(this.factory.lists[this.factory.lists.length - 6 + offset].$obj);
|
1768
|
+
$(this.createDivider('Days', true)).insertBefore(this.factory.lists[0].$obj);
|
1769
|
+
|
1770
|
+
this._clearExcessDigits();
|
1771
|
+
|
1772
|
+
if(this.autoStart) {
|
1773
|
+
this.start();
|
1774
|
+
}
|
1775
|
+
},
|
1776
|
+
|
1777
|
+
/**
|
1778
|
+
* Flip the clock face
|
1779
|
+
*/
|
1780
|
+
|
1781
|
+
flip: function(doNotAddPlayClass, time) {
|
1782
|
+
if(!time) {
|
1783
|
+
time = this.factory.time.getDayCounter(this.showSeconds);
|
1784
|
+
}
|
1785
|
+
this.base(time, doNotAddPlayClass);
|
1786
|
+
},
|
1787
|
+
|
1788
|
+
/**
|
1789
|
+
* Clear the excess digits from the tens columns for sec/min
|
1790
|
+
*/
|
1791
|
+
|
1792
|
+
_clearExcessDigits: function() {
|
1793
|
+
var tenSeconds = this.factory.lists[this.factory.lists.length - 2];
|
1794
|
+
var tenMinutes = this.factory.lists[this.factory.lists.length - 4];
|
1795
|
+
|
1796
|
+
for(var x = 6; x < 10; x++) {
|
1797
|
+
tenSeconds.$obj.find('li:last-child').remove();
|
1798
|
+
tenMinutes.$obj.find('li:last-child').remove();
|
1799
|
+
}
|
1800
|
+
}
|
1801
|
+
|
1802
|
+
});
|
1803
|
+
|
1804
|
+
}(jQuery));
|
1805
|
+
(function($) {
|
1806
|
+
|
1807
|
+
/**
|
1808
|
+
* Hourly Counter Clock Face
|
1809
|
+
*
|
1810
|
+
* This class will generate an hourly counter for FlipClock.js. An
|
1811
|
+
* hour counter will track hours, minutes, and seconds. If number of
|
1812
|
+
* available digits is exceeded in the count, a new digit will be
|
1813
|
+
* created.
|
1814
|
+
*
|
1815
|
+
* @param object The parent FlipClock.Factory object
|
1816
|
+
* @param object An object of properties to override the default
|
1817
|
+
*/
|
1818
|
+
|
1819
|
+
FlipClock.HourlyCounterFace = FlipClock.Face.extend({
|
1820
|
+
|
1821
|
+
clearExcessDigits: true,
|
1822
|
+
|
1823
|
+
/**
|
1824
|
+
* Constructor
|
1825
|
+
*
|
1826
|
+
* @param object The parent FlipClock.Factory object
|
1827
|
+
* @param object An object of properties to override the default
|
1828
|
+
*/
|
1829
|
+
|
1830
|
+
constructor: function(factory, options) {
|
1831
|
+
this.base(factory, options);
|
1832
|
+
},
|
1833
|
+
|
1834
|
+
/**
|
1835
|
+
* Build the clock face
|
1836
|
+
*/
|
1837
|
+
|
1838
|
+
build: function(excludeHours, time) {
|
1839
|
+
var t = this;
|
1840
|
+
var children = this.factory.$wrapper.find('ul');
|
1841
|
+
var lists = [];
|
1842
|
+
|
1843
|
+
time = time ? time : this.factory.time.getHourCounter();
|
1844
|
+
|
1845
|
+
if(time.length > children.length) {
|
1846
|
+
$.each(time, function(i, digit) {
|
1847
|
+
lists.push(t.createList(digit));
|
1848
|
+
});
|
1849
|
+
}
|
1850
|
+
|
1851
|
+
this.factory.lists = lists;
|
1852
|
+
|
1853
|
+
$(this.createDivider('Seconds')).insertBefore(this.factory.lists[this.factory.lists.length - 2].$obj);
|
1854
|
+
$(this.createDivider('Minutes')).insertBefore(this.factory.lists[this.factory.lists.length - 4].$obj);
|
1855
|
+
|
1856
|
+
if(!excludeHours) {
|
1857
|
+
$(this.createDivider('Hours', true)).insertBefore(this.factory.lists[0].$obj);
|
1858
|
+
}
|
1859
|
+
|
1860
|
+
if(this.clearExcessDigits) {
|
1861
|
+
this._clearExcessDigits();
|
1862
|
+
}
|
1863
|
+
|
1864
|
+
if(this.autoStart) {
|
1865
|
+
this.start();
|
1866
|
+
}
|
1867
|
+
},
|
1868
|
+
|
1869
|
+
/**
|
1870
|
+
* Flip the clock face
|
1871
|
+
*/
|
1872
|
+
|
1873
|
+
flip: function(doNotAddPlayClass, time) {
|
1874
|
+
if(!time) {
|
1875
|
+
time = this.factory.time.getHourCounter();
|
1876
|
+
}
|
1877
|
+
this.base(time, doNotAddPlayClass);
|
1878
|
+
},
|
1879
|
+
|
1880
|
+
/**
|
1881
|
+
* Clear the excess digits from the tens columns for sec/min
|
1882
|
+
*/
|
1883
|
+
|
1884
|
+
_clearExcessDigits: function() {
|
1885
|
+
var tenSeconds = this.factory.lists[this.factory.lists.length - 2];
|
1886
|
+
var tenMinutes = this.factory.lists[this.factory.lists.length - 4];
|
1887
|
+
|
1888
|
+
for(var x = 6; x < 10; x++) {
|
1889
|
+
tenSeconds.$obj.find('li:last-child').remove();
|
1890
|
+
tenMinutes.$obj.find('li:last-child').remove();
|
1891
|
+
}
|
1892
|
+
}
|
1893
|
+
|
1894
|
+
});
|
1895
|
+
|
1896
|
+
}(jQuery));
|
1897
|
+
(function($) {
|
1898
|
+
|
1899
|
+
/**
|
1900
|
+
* Minute Counter Clock Face
|
1901
|
+
*
|
1902
|
+
* This class will generate a minute counter for FlipClock.js. A
|
1903
|
+
* minute counter will track minutes and seconds. If an hour is
|
1904
|
+
* reached, the counter will reset back to 0. (4 digits max)
|
1905
|
+
*
|
1906
|
+
* @param object The parent FlipClock.Factory object
|
1907
|
+
* @param object An object of properties to override the default
|
1908
|
+
*/
|
1909
|
+
|
1910
|
+
FlipClock.MinuteCounterFace = FlipClock.HourlyCounterFace.extend({
|
1911
|
+
|
1912
|
+
clearExcessDigits: false,
|
1913
|
+
|
1914
|
+
/**
|
1915
|
+
* Constructor
|
1916
|
+
*
|
1917
|
+
* @param object The parent FlipClock.Factory object
|
1918
|
+
* @param object An object of properties to override the default
|
1919
|
+
*/
|
1920
|
+
|
1921
|
+
constructor: function(factory, options) {
|
1922
|
+
this.base(factory, options);
|
1923
|
+
},
|
1924
|
+
|
1925
|
+
/**
|
1926
|
+
* Build the clock face
|
1927
|
+
*/
|
1928
|
+
|
1929
|
+
build: function() {
|
1930
|
+
this.base(true, this.factory.time.getMinuteCounter());
|
1931
|
+
},
|
1932
|
+
|
1933
|
+
/**
|
1934
|
+
* Flip the clock face
|
1935
|
+
*/
|
1936
|
+
|
1937
|
+
flip: function(doNotAddPlayClass) {
|
1938
|
+
this.base(doNotAddPlayClass, this.factory.time.getMinuteCounter());
|
1939
|
+
},
|
1940
|
+
|
1941
|
+
});
|
1942
|
+
|
1943
|
+
}(jQuery));
|
1944
|
+
(function($) {
|
1945
|
+
|
1946
|
+
/**
|
1947
|
+
* Twelve Hour Clock Face
|
1948
|
+
*
|
1949
|
+
* This class will generate a twelve hour clock for FlipClock.js
|
1950
|
+
*
|
1951
|
+
* @param object The parent FlipClock.Factory object
|
1952
|
+
* @param object An object of properties to override the default
|
1953
|
+
*/
|
1954
|
+
|
1955
|
+
FlipClock.TwelveHourClockFace = FlipClock.TwentyFourHourClockFace.extend({
|
1956
|
+
|
1957
|
+
/**
|
1958
|
+
* The meridium jQuery DOM object
|
1959
|
+
*/
|
1960
|
+
|
1961
|
+
meridium: false,
|
1962
|
+
|
1963
|
+
/**
|
1964
|
+
* The meridium text as string for easy access
|
1965
|
+
*/
|
1966
|
+
|
1967
|
+
meridiumText: 'AM',
|
1968
|
+
|
1969
|
+
/**
|
1970
|
+
* Build the clock face
|
1971
|
+
*
|
1972
|
+
* @param object Pass the time that should be used to display on the clock.
|
1973
|
+
*/
|
1974
|
+
|
1975
|
+
build: function(time) {
|
1976
|
+
var t = this;
|
1977
|
+
|
1978
|
+
time = time ? time : (this.factory.time.time ? this.factory.time.time : this.factory.time.getTime());
|
1979
|
+
|
1980
|
+
this.base(time);
|
1981
|
+
this.meridiumText = this._isPM() ? 'PM' : 'AM';
|
1982
|
+
this.meridium = $([
|
1983
|
+
'<ul class="flip-clock-meridium">',
|
1984
|
+
'<li>',
|
1985
|
+
'<a href="#">'+this.meridiumText+'</a>',
|
1986
|
+
'</li>',
|
1987
|
+
'</ul>'
|
1988
|
+
].join(''));
|
1989
|
+
|
1990
|
+
this.meridium.insertAfter(this.factory.lists[this.factory.lists.length-1].$obj);
|
1991
|
+
},
|
1992
|
+
|
1993
|
+
/**
|
1994
|
+
* Flip the clock face
|
1995
|
+
*/
|
1996
|
+
|
1997
|
+
flip: function() {
|
1998
|
+
if(this.meridiumText != this._getMeridium()) {
|
1999
|
+
this.meridiumText = this._getMeridium();
|
2000
|
+
this.meridium.find('a').html(this.meridiumText);
|
2001
|
+
}
|
2002
|
+
this.base(this.factory.time.getTime());
|
2003
|
+
},
|
2004
|
+
|
2005
|
+
/**
|
2006
|
+
* Get the current meridium
|
2007
|
+
*
|
2008
|
+
* @return string Returns the meridium (AM|PM)
|
2009
|
+
*/
|
2010
|
+
|
2011
|
+
_getMeridium: function() {
|
2012
|
+
return new Date().getHours() >= 12 ? 'PM' : 'AM';
|
2013
|
+
},
|
2014
|
+
|
2015
|
+
/**
|
2016
|
+
* Is it currently in the post-medirium?
|
2017
|
+
*
|
2018
|
+
* @return bool Returns true or false
|
2019
|
+
*/
|
2020
|
+
|
2021
|
+
_isPM: function() {
|
2022
|
+
return this._getMeridium() == 'PM' ? true : false;
|
2023
|
+
},
|
2024
|
+
|
2025
|
+
/**
|
2026
|
+
* Clear the excess digits from the tens columns for sec/min
|
2027
|
+
*/
|
2028
|
+
|
2029
|
+
_clearExcessDigits: function() {
|
2030
|
+
var tenSeconds = this.factory.lists[this.factory.lists.length - 2];
|
2031
|
+
var tenMinutes = this.factory.lists[this.factory.lists.length - 4];
|
2032
|
+
|
2033
|
+
for(var x = 6; x < 10; x++) {
|
2034
|
+
tenSeconds.$obj.find('li:last-child').remove();
|
2035
|
+
tenMinutes.$obj.find('li:last-child').remove();
|
2036
|
+
}
|
2037
|
+
}
|
2038
|
+
|
2039
|
+
});
|
2040
|
+
|
2041
|
+
}(jQuery));
|
2042
|
+
(function($) {
|
2043
|
+
|
2044
|
+
/**
|
2045
|
+
* FlipClock German Language Pack
|
2046
|
+
*
|
2047
|
+
* This class will used to translate tokens into the German language.
|
2048
|
+
*
|
2049
|
+
*/
|
2050
|
+
|
2051
|
+
FlipClock.Lang.German = {
|
2052
|
+
|
2053
|
+
'years' : 'Jahre',
|
2054
|
+
'months' : 'Monate',
|
2055
|
+
'days' : 'Tage',
|
2056
|
+
'hours' : 'Stunden',
|
2057
|
+
'minutes' : 'Minuten',
|
2058
|
+
'seconds' : 'Sekunden'
|
2059
|
+
|
2060
|
+
};
|
2061
|
+
|
2062
|
+
/* Create various aliases for convenience */
|
2063
|
+
|
2064
|
+
FlipClock.Lang['de'] = FlipClock.Lang.German;
|
2065
|
+
FlipClock.Lang['de-de'] = FlipClock.Lang.German;
|
2066
|
+
FlipClock.Lang['german'] = FlipClock.Lang.German;
|
2067
|
+
|
2068
|
+
}(jQuery));
|
2069
|
+
(function($) {
|
2070
|
+
|
2071
|
+
/**
|
2072
|
+
* FlipClock English Language Pack
|
2073
|
+
*
|
2074
|
+
* This class will used to translate tokens into the English language.
|
2075
|
+
*
|
2076
|
+
*/
|
2077
|
+
|
2078
|
+
FlipClock.Lang.English = {
|
2079
|
+
|
2080
|
+
'years' : 'Years',
|
2081
|
+
'months' : 'Months',
|
2082
|
+
'days' : 'Days',
|
2083
|
+
'hours' : 'Hours',
|
2084
|
+
'minutes' : 'Minutes',
|
2085
|
+
'seconds' : 'Seconds'
|
2086
|
+
|
2087
|
+
};
|
2088
|
+
|
2089
|
+
/* Create various aliases for convenience */
|
2090
|
+
|
2091
|
+
FlipClock.Lang['en'] = FlipClock.Lang.English;
|
2092
|
+
FlipClock.Lang['en-us'] = FlipClock.Lang.English;
|
2093
|
+
FlipClock.Lang['english'] = FlipClock.Lang.English;
|
2094
|
+
|
2095
|
+
}(jQuery));
|
2096
|
+
(function($) {
|
2097
|
+
|
2098
|
+
/**
|
2099
|
+
* FlipClock Spanish Language Pack
|
2100
|
+
*
|
2101
|
+
* This class will used to translate tokens into the Spanish language.
|
2102
|
+
*
|
2103
|
+
*/
|
2104
|
+
|
2105
|
+
FlipClock.Lang.Spanish = {
|
2106
|
+
|
2107
|
+
'years' : 'Años',
|
2108
|
+
'months' : 'Meses',
|
2109
|
+
'days' : 'DÍas',
|
2110
|
+
'hours' : 'Horas',
|
2111
|
+
'minutes' : 'Minutos',
|
2112
|
+
'seconds' : 'Segundo'
|
2113
|
+
|
2114
|
+
};
|
2115
|
+
|
2116
|
+
/* Create various aliases for convenience */
|
2117
|
+
|
2118
|
+
FlipClock.Lang['es'] = FlipClock.Lang.Spanish;
|
2119
|
+
FlipClock.Lang['es-es'] = FlipClock.Lang.Spanish;
|
2120
|
+
FlipClock.Lang['spanish'] = FlipClock.Lang.Spanish;
|
2121
|
+
|
2122
|
+
}(jQuery));
|
2123
|
+
(function($) {
|
2124
|
+
|
2125
|
+
/**
|
2126
|
+
* FlipClock Canadian French Language Pack
|
2127
|
+
*
|
2128
|
+
* This class will used to translate tokens into the Canadian French language.
|
2129
|
+
*
|
2130
|
+
*/
|
2131
|
+
|
2132
|
+
FlipClock.Lang.French = {
|
2133
|
+
|
2134
|
+
'years' : 'ans',
|
2135
|
+
'months' : 'mois',
|
2136
|
+
'days' : 'jours',
|
2137
|
+
'hours' : 'heures',
|
2138
|
+
'minutes' : 'minutes',
|
2139
|
+
'seconds' : 'secondes'
|
2140
|
+
|
2141
|
+
};
|
2142
|
+
|
2143
|
+
/* Create various aliases for convenience */
|
2144
|
+
|
2145
|
+
FlipClock.Lang['fr'] = FlipClock.Lang.French;
|
2146
|
+
FlipClock.Lang['fr-ca'] = FlipClock.Lang.French;
|
2147
|
+
FlipClock.Lang['french'] = FlipClock.Lang.French;
|
2148
|
+
|
2149
|
+
}(jQuery));
|