flipclockjs-rails 0.4.0b → 0.5.5b

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # flipclockjs-rails
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/flipclockjs-rails.png)](http://badge.fury.io/rb/flipclockjs-rails)
4
+
3
5
  This gem packages [FlipClock.js](https://github.com/objectivehtml/FlipClock) for the Rails 3.1+ asset pipeline.
4
6
 
5
7
  FlipClock.js requires `jQuery 1.7.x+`.
@@ -8,7 +10,7 @@ FlipClock.js requires `jQuery 1.7.x+`.
8
10
 
9
11
  Add this line to your application's Gemfile:
10
12
  ```
11
- gem 'flipclockjs-rails', '~> 0.4.0b'
13
+ gem 'flipclockjs-rails', '~> 0.5.5b'
12
14
  ```
13
15
 
14
16
  And then execute:
@@ -1,5 +1,5 @@
1
1
  module Flipclockjs
2
2
  module Rails
3
- VERSION = '0.4.0b'
3
+ VERSION = '0.5.5b'
4
4
  end
5
5
  end
@@ -165,6 +165,11 @@ var FlipClock;
165
165
  */
166
166
 
167
167
  FlipClock = function(obj, digit, options) {
168
+ if(typeof digit == "object") {
169
+ options = digit;
170
+ digit = 0;
171
+ }
172
+
168
173
  return new FlipClock.Factory(obj, digit, options);
169
174
  };
170
175
 
@@ -188,13 +193,13 @@ var FlipClock;
188
193
  * Build Date
189
194
  */
190
195
 
191
- buildDate: '2013-11-07',
196
+ buildDate: '2014-06-03',
192
197
 
193
198
  /**
194
199
  * Version
195
200
  */
196
201
 
197
- version: '0.3.1',
202
+ version: '0.5.5',
198
203
 
199
204
  /**
200
205
  * Sets the default options
@@ -299,6 +304,253 @@ var FlipClock;
299
304
 
300
305
  });
301
306
 
307
+ }(jQuery));
308
+
309
+ /*jshint smarttabs:true */
310
+
311
+ /**
312
+ * FlipClock.js
313
+ *
314
+ * @author Justin Kimbrell
315
+ * @copyright 2013 - Objective HTML, LLC
316
+ * @licesnse http://www.opensource.org/licenses/mit-license.php
317
+ */
318
+
319
+ (function($) {
320
+
321
+ "use strict";
322
+
323
+ /**
324
+ * The FlipClock Face class is the base class in which to extend
325
+ * all other FlockClock.Face classes.
326
+ *
327
+ * @param object The parent FlipClock.Factory object
328
+ * @param object An object of properties to override the default
329
+ */
330
+
331
+ FlipClock.Face = FlipClock.Base.extend({
332
+
333
+ /**
334
+ * An array of jQuery objects used for the dividers (the colons)
335
+ */
336
+
337
+ dividers: [],
338
+
339
+ /**
340
+ * An array of FlipClock.List objects
341
+ */
342
+
343
+ factory: false,
344
+
345
+ /**
346
+ * An array of FlipClock.List objects
347
+ */
348
+
349
+ lists: [],
350
+
351
+ /**
352
+ * Constructor
353
+ *
354
+ * @param object The parent FlipClock.Factory object
355
+ * @param object An object of properties to override the default
356
+ */
357
+
358
+ constructor: function(factory, options) {
359
+ this.base(options);
360
+ this.factory = factory;
361
+ this.dividers = [];
362
+ },
363
+
364
+ /**
365
+ * Build the clock face
366
+ */
367
+
368
+ build: function() {},
369
+
370
+ /**
371
+ * Creates a jQuery object used for the digit divider
372
+ *
373
+ * @param mixed The divider label text
374
+ * @param mixed Set true to exclude the dots in the divider.
375
+ * If not set, is false.
376
+ */
377
+
378
+ createDivider: function(label, css, excludeDots) {
379
+
380
+ if(typeof css == "boolean" || !css) {
381
+ excludeDots = css;
382
+ css = label;
383
+ }
384
+
385
+ var dots = [
386
+ '<span class="'+this.factory.classes.dot+' top"></span>',
387
+ '<span class="'+this.factory.classes.dot+' bottom"></span>'
388
+ ].join('');
389
+
390
+ if(excludeDots) {
391
+ dots = '';
392
+ }
393
+
394
+ label = this.factory.localize(label);
395
+
396
+ var html = [
397
+ '<span class="'+this.factory.classes.divider+' '+(css ? css : '').toLowerCase()+'">',
398
+ '<span class="'+this.factory.classes.label+'">'+(label ? label : '')+'</span>',
399
+ dots,
400
+ '</span>'
401
+ ];
402
+
403
+ return $(html.join(''));
404
+ },
405
+
406
+ /**
407
+ * Creates a FlipClock.List object and appends it to the DOM
408
+ *
409
+ * @param mixed The digit to select in the list
410
+ * @param object An object to override the default properties
411
+ */
412
+
413
+ createList: function(digit, options) {
414
+ if(typeof digit === "object") {
415
+ options = digit;
416
+ digit = 0;
417
+ }
418
+
419
+ var obj = new FlipClock.List(this.factory, digit, options);
420
+
421
+ //this.factory.$wrapper.append(obj.$obj);
422
+
423
+ return obj;
424
+ },
425
+
426
+ /**
427
+ * Triggers when the clock is reset
428
+ */
429
+
430
+ reset: function() {
431
+ this.factory.time = new FlipClock.Time(
432
+ this.factor,
433
+ this.factory.original ? Math.round(this.factory.original) : 0
434
+ );
435
+ this.flip(this.factory.original, false);
436
+ },
437
+
438
+ /**
439
+ * Sets the clock time (deprecated, duplicate method)
440
+ *
441
+
442
+ setTime: function(time) {
443
+ this.flip();
444
+ },
445
+ */
446
+
447
+ /**
448
+ * Sets the clock time
449
+ */
450
+
451
+ addDigit: function(digit) {
452
+ var obj = this.createList(digit, {
453
+ classes: {
454
+ active: this.factory.classes.active,
455
+ before: this.factory.classes.before,
456
+ flip: this.factory.classes.flip
457
+ }
458
+ });
459
+
460
+ obj.$obj.insertBefore(this.factory.lists[0].$obj);
461
+
462
+ this.factory.lists.unshift(obj);
463
+ },
464
+
465
+ /**
466
+ * Triggers when the clock is started
467
+ */
468
+
469
+ start: function() {},
470
+
471
+ /**
472
+ * Triggers when the time on the clock stops
473
+ */
474
+
475
+ stop: function() {},
476
+
477
+ /**
478
+ * Increments the time with each face flip
479
+ */
480
+
481
+ increment: function() {
482
+ if (!(this.factory.time.time instanceof Date)) {
483
+ if(!this.factory.countdown) {
484
+ this.factory.time.addSecond();
485
+ }
486
+ else {
487
+ if(this.factory.time.getTimeSeconds() == 0) {
488
+ this.factory.stop()
489
+ }
490
+ else {
491
+ this.factory.time.subSecond();
492
+ }
493
+ }
494
+ }
495
+ },
496
+
497
+ /**
498
+ * Triggers when the numbers on the clock flip
499
+ */
500
+
501
+ flip: function(time, doNotAddPlayClass) {
502
+ var t = this;
503
+
504
+ this.increment();
505
+
506
+ var offset = t.factory.lists.length - time.length;
507
+
508
+ if(offset < 0) {
509
+ offset = 0;
510
+ }
511
+
512
+ $.each(time, function(i, digit) {
513
+ i += offset;
514
+
515
+ var list = t.factory.lists[i];
516
+
517
+ if(list) {
518
+ list.select(digit);
519
+
520
+ if(!doNotAddPlayClass) {
521
+ list.play();
522
+ }
523
+ }
524
+ else {
525
+ t.addDigit(digit);
526
+ }
527
+ });
528
+
529
+ for(var x = 0; x < time.length; x++) {
530
+ if(x >= offset && t.factory.lists[x].digit != time[x]) {
531
+ t.factory.lists[x].select(time[x]);
532
+ }
533
+ }
534
+ }
535
+
536
+ });
537
+
538
+ }(jQuery));
539
+
540
+ /*jshint smarttabs:true */
541
+
542
+ /**
543
+ * FlipClock.js
544
+ *
545
+ * @author Justin Kimbrell
546
+ * @copyright 2013 - Objective HTML, LLC
547
+ * @licesnse http://www.opensource.org/licenses/mit-license.php
548
+ */
549
+
550
+ (function($) {
551
+
552
+ "use strict";
553
+
302
554
  /**
303
555
  * The FlipClock Factory class is used to build the clock and manage
304
556
  * all the public methods.
@@ -378,6 +630,12 @@ var FlipClock;
378
630
 
379
631
  lang: false,
380
632
 
633
+ /**
634
+ * The original starting value of the clock. Used for the reset method.
635
+ */
636
+
637
+ original: false,
638
+
381
639
  /**
382
640
  * The FlipClock.Face object
383
641
  */
@@ -423,12 +681,21 @@ var FlipClock;
423
681
  */
424
682
 
425
683
  constructor: function(obj, digit, options) {
426
-
684
+
685
+ if(!options) {
686
+ options = {};
687
+ }
688
+
427
689
  this.lists = [];
428
690
  this.running = false;
429
691
  this.base(options);
430
692
  this.$wrapper = $(obj).addClass(this.classes.wrapper);
431
- this.time = new FlipClock.Time(this, digit ? Math.round(digit) : 0);
693
+ this.original = (digit instanceof Date) ? digit : (digit ? Math.round(digit) : 0);
694
+ this.time = new FlipClock.Time(this, this.original, {
695
+ minimumDigits: options.minimumDigits ? options.minimumDigits : 0,
696
+ animationRate: options.animationRate ? options.animationRate : 1000
697
+ });
698
+
432
699
  this.timer = new FlipClock.Timer(this, options);
433
700
 
434
701
  this.lang = this.loadLanguage(this.language);
@@ -564,7 +831,7 @@ var FlipClock;
564
831
 
565
832
  setTime: function(time) {
566
833
  this.time.time = time;
567
- this.face.setTime(time);
834
+ this.flip(true);
568
835
  },
569
836
 
570
837
  /**
@@ -597,217 +864,28 @@ var FlipClock;
597
864
  *
598
865
  * @param array An array of digits
599
866
  */
600
- flip: function() {
601
- this.face.flip();
867
+ flip: function(doNotAddPlayClass) {
868
+ this.face.flip(false, doNotAddPlayClass);
602
869
  }
603
870
 
604
871
  });
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
872
 
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;
873
+ }(jQuery));
781
874
 
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
- });
875
+ /*jshint smarttabs:true */
801
876
 
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
-
877
+ /**
878
+ * FlipClock.js
879
+ *
880
+ * @author Justin Kimbrell
881
+ * @copyright 2013 - Objective HTML, LLC
882
+ * @licesnse http://www.opensource.org/licenses/mit-license.php
883
+ */
884
+
885
+ (function($) {
886
+
887
+ "use strict";
888
+
811
889
  /**
812
890
  * The FlipClock List class is used to build the list used to create
813
891
  * the card flip effect. This object fascilates selecting the correct
@@ -863,6 +941,8 @@ var FlipClock;
863
941
  * @param object An object to override the default properties
864
942
  */
865
943
 
944
+ minimumDigits: 0,
945
+
866
946
  constructor: function(factory, digit, options) {
867
947
  this.factory = factory;
868
948
  this.digit = digit;
@@ -892,7 +972,7 @@ var FlipClock;
892
972
  var target = this.$obj.find('[data-digit="'+digit+'"]');
893
973
  var active = this.$obj.find('.'+this.classes.active).removeClass(this.classes.active);
894
974
  var before = this.$obj.find('.'+this.classes.before).removeClass(this.classes.before);
895
-
975
+
896
976
  if(!this.factory.countdown) {
897
977
  if(target.is(':first-child')) {
898
978
  this.$obj.find(':last-child').addClass(this.classes.before);
@@ -927,7 +1007,7 @@ var FlipClock;
927
1007
 
928
1008
  stop: function() {
929
1009
  var t = this;
930
-
1010
+
931
1011
  setTimeout(function() {
932
1012
  t.$obj.removeClass(t.factory.classes.play);
933
1013
  }, this.factory.timer.interval);
@@ -941,30 +1021,99 @@ var FlipClock;
941
1021
 
942
1022
  var html = $('<ul class="'+this.classes.flip+' '+(this.factory.running ? this.factory.classes.play : '')+'" />');
943
1023
 
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
-
1024
+ for(var x = 0; x < 10; x++) {
1025
+ var item = $([
1026
+ '<li data-digit="'+x+'">',
1027
+ '<a href="#">',
1028
+ '<div class="up">',
1029
+ '<div class="shadow"></div>',
1030
+ '<div class="inn">'+x+'</div>',
1031
+ '</div>',
1032
+ '<div class="down">',
1033
+ '<div class="shadow"></div>',
1034
+ '<div class="inn">'+x+'</div>',
1035
+ '</div>',
1036
+ '</a>',
1037
+ '</li>'].join(''));
1038
+
1039
+ this.items.push(item);
1040
+
1041
+ html.append(item);
1042
+ }
1043
+
1044
+ return html;
1045
+ }
1046
+ });
1047
+
1048
+
1049
+ }(jQuery));
1050
+
1051
+ /*jshint smarttabs:true */
1052
+
1053
+ /**
1054
+ * FlipClock.js
1055
+ *
1056
+ * @author Justin Kimbrell
1057
+ * @copyright 2013 - Objective HTML, LLC
1058
+ * @licesnse http://www.opensource.org/licenses/mit-license.php
1059
+ */
1060
+
1061
+ (function($) {
1062
+
1063
+ "use strict";
1064
+
1065
+ /**
1066
+ * Capitalize the first letter in a string
1067
+ *
1068
+ * @return string
1069
+ */
1070
+
1071
+ String.prototype.ucfirst = function() {
1072
+ return this.substr(0, 1).toUpperCase() + this.substr(1);
1073
+ };
1074
+
1075
+ /**
1076
+ * jQuery helper method
1077
+ *
1078
+ * @param int An integer used to start the clock (no. seconds)
1079
+ * @param object An object of properties to override the default
1080
+ */
1081
+
1082
+ $.fn.FlipClock = function(digit, options) {
1083
+ if(typeof digit == "object") {
1084
+ options = digit;
1085
+ digit = 0;
1086
+ }
1087
+ return new FlipClock($(this), digit, options);
1088
+ };
1089
+
1090
+ /**
1091
+ * jQuery helper method
1092
+ *
1093
+ * @param int An integer used to start the clock (no. seconds)
1094
+ * @param object An object of properties to override the default
1095
+ */
1096
+
1097
+ $.fn.flipClock = function(digit, options) {
1098
+ return $.fn.FlipClock(digit, options);
1099
+ };
1100
+
1101
+ }(jQuery));
1102
+
1103
+ /*jshint smarttabs:true */
1104
+
1105
+ /**
1106
+ * FlipClock.js
1107
+ *
1108
+ * @author Justin Kimbrell
1109
+ * @copyright 2013 - Objective HTML, LLC
1110
+ * @licesnse http://www.opensource.org/licenses/mit-license.php
1111
+ */
1112
+
1113
+ (function($) {
1114
+
1115
+ "use strict";
1116
+
968
1117
  /**
969
1118
  * The FlipClock Time class is used to manage all the time
970
1119
  * calculations.
@@ -977,12 +1126,6 @@ var FlipClock;
977
1126
 
978
1127
  FlipClock.Time = FlipClock.Base.extend({
979
1128
 
980
- /**
981
- * The time (in seconds)
982
- */
983
-
984
- minimumDigits: 0,
985
-
986
1129
  /**
987
1130
  * The time (in seconds)
988
1131
  */
@@ -995,6 +1138,12 @@ var FlipClock;
995
1138
 
996
1139
  factory: false,
997
1140
 
1141
+ /**
1142
+ * The minimum number of digits the clock face will have
1143
+ */
1144
+
1145
+ minimumDigits: 0,
1146
+
998
1147
  /**
999
1148
  * Constructor
1000
1149
  *
@@ -1070,16 +1219,18 @@ var FlipClock;
1070
1219
  }
1071
1220
 
1072
1221
  for(var x = 0; x < value.length; x++) {
1073
- data.push(value[x]);
1222
+ data.push(value.charAt(x));
1074
1223
  }
1075
1224
  });
1076
-
1225
+
1077
1226
  if(data.length > this.minimumDigits) {
1078
1227
  this.minimumDigits = data.length;
1079
1228
  }
1080
1229
 
1081
1230
  if(this.minimumDigits > data.length) {
1082
- data.unshift('0');
1231
+ for(var x = data.length; x < this.minimumDigits; x++) {
1232
+ data.unshift('0');
1233
+ }
1083
1234
  }
1084
1235
 
1085
1236
  return data;
@@ -1113,7 +1264,7 @@ var FlipClock;
1113
1264
  */
1114
1265
 
1115
1266
  getDays: function(mod) {
1116
- var days = this.time / 60 / 60 / 24;
1267
+ var days = this.getTimeSeconds() / 60 / 60 / 24;
1117
1268
 
1118
1269
  if(mod) {
1119
1270
  days = days % 7;
@@ -1156,7 +1307,7 @@ var FlipClock;
1156
1307
  */
1157
1308
 
1158
1309
  getHours: function(mod) {
1159
- var hours = this.time / 60 / 60;
1310
+ var hours = this.getTimeSeconds() / 60 / 60;
1160
1311
 
1161
1312
  if(mod) {
1162
1313
  hours = hours % 24;
@@ -1190,7 +1341,7 @@ var FlipClock;
1190
1341
  */
1191
1342
 
1192
1343
  getMinutes: function(mod) {
1193
- var minutes = this.time / 60;
1344
+ var minutes = this.getTimeSeconds() / 60;
1194
1345
 
1195
1346
  if(mod) {
1196
1347
  minutes = minutes % 60;
@@ -1212,6 +1363,27 @@ var FlipClock;
1212
1363
  return obj;
1213
1364
  },
1214
1365
 
1366
+ /**
1367
+ * Gets time count in seconds regardless of if targetting date or not.
1368
+ *
1369
+ * @return int Returns a floored integer
1370
+ */
1371
+
1372
+ getTimeSeconds: function(mod) {
1373
+ if (this.time instanceof Date) {
1374
+ if (this.factory.countdown) {
1375
+ if ((new Date()).getTime() > this.time.getTime()) {
1376
+ this.factory.stop();
1377
+ }
1378
+ return Math.max(this.time.getTime()/1000 - (new Date()).getTime()/1000,0);
1379
+ } else {
1380
+ return (new Date()).getTime()/1000 - this.time.getTime()/1000 ;
1381
+ }
1382
+ } else {
1383
+ return this.time;
1384
+ }
1385
+ },
1386
+
1215
1387
  /**
1216
1388
  * Gets number of seconds
1217
1389
  *
@@ -1220,7 +1392,7 @@ var FlipClock;
1220
1392
  */
1221
1393
 
1222
1394
  getSeconds: function(mod) {
1223
- var seconds = this.time;
1395
+ var seconds = this.getTimeSeconds();
1224
1396
 
1225
1397
  if(mod) {
1226
1398
  if(seconds == 60) {
@@ -1261,7 +1433,7 @@ var FlipClock;
1261
1433
  */
1262
1434
 
1263
1435
  getWeeks: function() {
1264
- var weeks = this.time / 60 / 60 / 24 / 7;
1436
+ var weeks = this.getTimeSeconds() / 60 / 60 / 24 / 7;
1265
1437
 
1266
1438
  if(mod) {
1267
1439
  weeks = weeks % 52;
@@ -1298,13 +1470,45 @@ var FlipClock;
1298
1470
 
1299
1471
  return digits;
1300
1472
  },
1473
+
1474
+ /**
1475
+ * Adds X second to the current time
1476
+ */
1477
+
1478
+ addSeconds: function(x) {
1479
+ this.time += x;
1480
+ },
1481
+
1482
+ /**
1483
+ * Adds 1 second to the current time
1484
+ */
1485
+
1486
+ addSecond: function() {
1487
+ this.addSeconds(1);
1488
+ },
1489
+
1490
+ /**
1491
+ * Substracts X seconds from the current time
1492
+ */
1493
+
1494
+ subSeconds: function(x) {
1495
+ this.time -= x;
1496
+ },
1497
+
1498
+ /**
1499
+ * Substracts 1 second from the current time
1500
+ */
1501
+
1502
+ subSecond: function() {
1503
+ this.subSeconds(1);
1504
+ },
1301
1505
 
1302
1506
  /**
1303
1507
  * Converts the object to a human readable string
1304
1508
  */
1305
1509
 
1306
1510
  toString: function() {
1307
- return this.time.toString();
1511
+ return this.getTimeSeconds().toString();
1308
1512
  }
1309
1513
 
1310
1514
  /*
@@ -1317,6 +1521,22 @@ var FlipClock;
1317
1521
  }*/
1318
1522
  });
1319
1523
 
1524
+ }(jQuery));
1525
+
1526
+ /*jshint smarttabs:true */
1527
+
1528
+ /**
1529
+ * FlipClock.js
1530
+ *
1531
+ * @author Justin Kimbrell
1532
+ * @copyright 2013 - Objective HTML, LLC
1533
+ * @licesnse http://www.opensource.org/licenses/mit-license.php
1534
+ */
1535
+
1536
+ (function($) {
1537
+
1538
+ "use strict";
1539
+
1320
1540
  /**
1321
1541
  * The FlipClock.Timer object managers the JS timers
1322
1542
  *
@@ -1357,6 +1577,12 @@ var FlipClock;
1357
1577
  */
1358
1578
 
1359
1579
  interval: 1000,
1580
+
1581
+ /**
1582
+ * The rate of the animation in milliseconds
1583
+ */
1584
+
1585
+ animationRate: 1000,
1360
1586
 
1361
1587
  /**
1362
1588
  * Constructor
@@ -1489,50 +1715,16 @@ var FlipClock;
1489
1715
 
1490
1716
  _setInterval: function(callback) {
1491
1717
  var t = this;
1492
-
1493
- t.timer = setInterval(function() {
1718
+
1719
+ t._interval(callback);
1720
+
1721
+ t.timer = setInterval(function() {
1494
1722
  t._interval(callback);
1495
1723
  }, this.interval);
1496
1724
  }
1497
1725
 
1498
1726
  });
1499
1727
 
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
1728
  }(jQuery));
1537
1729
 
1538
1730
  (function($) {
@@ -1595,9 +1787,9 @@ var FlipClock;
1595
1787
  * Flip the clock face
1596
1788
  */
1597
1789
 
1598
- flip: function(time) {
1790
+ flip: function(time, doNotAddPlayClass) {
1599
1791
  time = time ? time : this.factory.time.getMilitaryTime();
1600
- this.base(time);
1792
+ this.base(time, doNotAddPlayClass);
1601
1793
  },
1602
1794
 
1603
1795
  /**
@@ -1633,6 +1825,8 @@ var FlipClock;
1633
1825
 
1634
1826
  autoStart: false,
1635
1827
 
1828
+ minimumDigits: 2,
1829
+
1636
1830
  /**
1637
1831
  * Constructor
1638
1832
  *
@@ -1647,12 +1841,15 @@ var FlipClock;
1647
1841
 
1648
1842
  factory.increment = function() {
1649
1843
  factory.countdown = false;
1650
- factory.setTime(factory.getTime().time + 1);
1844
+ factory.setTime(factory.getTime().getTimeSeconds() + 1);
1651
1845
  };
1652
1846
 
1653
1847
  factory.decrement = function() {
1654
1848
  factory.countdown = true;
1655
- factory.setTime(factory.getTime().time - 1);
1849
+ var time = factory.getTime().getTimeSeconds();
1850
+ if(time > 0) {
1851
+ factory.setTime(time - 1);
1852
+ }
1656
1853
  };
1657
1854
 
1658
1855
  factory.setValue = function(digits) {
@@ -1665,7 +1862,13 @@ var FlipClock;
1665
1862
 
1666
1863
  this.base(factory, options);
1667
1864
  },
1668
-
1865
+
1866
+ /**
1867
+ * Increments the time with each face flip
1868
+ */
1869
+
1870
+ increment: function() {},
1871
+
1669
1872
  /**
1670
1873
  * Build the clock face
1671
1874
  */
@@ -1678,7 +1881,9 @@ var FlipClock;
1678
1881
 
1679
1882
  if(time.length > children.length) {
1680
1883
  $.each(time, function(i, digit) {
1681
- var list = t.createList(digit);
1884
+ var list = t.createList(digit, {
1885
+ minimumDigits: t.minimumDigits,
1886
+ });
1682
1887
 
1683
1888
  list.select(digit);
1684
1889
  lists.push(list);
@@ -1697,12 +1902,26 @@ var FlipClock;
1697
1902
  * Flip the clock face
1698
1903
  */
1699
1904
 
1700
- flip: function(doNotAddPlayClass) {
1701
- var time = this.factory.getTime().digitize([this.factory.getTime().time]);
1702
-
1905
+ flip: function(time, doNotAddPlayClass) {
1906
+ if(!time) {
1907
+ time = this.factory.getTime().digitize([this.factory.getTime().time]);
1908
+ }
1909
+
1703
1910
  this.base(time, doNotAddPlayClass);
1704
1911
  },
1705
1912
 
1913
+ /**
1914
+ * Reset the clock face
1915
+ */
1916
+
1917
+ reset: function() {
1918
+ this.factory.time = new FlipClock.Time(
1919
+ this.factor,
1920
+ this.factory.original ? Math.round(this.factory.original) : 0
1921
+ );
1922
+
1923
+ this.flip();
1924
+ }
1706
1925
  });
1707
1926
 
1708
1927
  }(jQuery));
@@ -1778,10 +1997,11 @@ var FlipClock;
1778
1997
  * Flip the clock face
1779
1998
  */
1780
1999
 
1781
- flip: function(doNotAddPlayClass, time) {
2000
+ flip: function(time, doNotAddPlayClass) {
1782
2001
  if(!time) {
1783
2002
  time = this.factory.time.getDayCounter(this.showSeconds);
1784
2003
  }
2004
+
1785
2005
  this.base(time, doNotAddPlayClass);
1786
2006
  },
1787
2007
 
@@ -1870,7 +2090,7 @@ var FlipClock;
1870
2090
  * Flip the clock face
1871
2091
  */
1872
2092
 
1873
- flip: function(doNotAddPlayClass, time) {
2093
+ flip: function(time, doNotAddPlayClass) {
1874
2094
  if(!time) {
1875
2095
  time = this.factory.time.getHourCounter();
1876
2096
  }
@@ -1934,8 +2154,11 @@ var FlipClock;
1934
2154
  * Flip the clock face
1935
2155
  */
1936
2156
 
1937
- flip: function(doNotAddPlayClass) {
1938
- this.base(doNotAddPlayClass, this.factory.time.getMinuteCounter());
2157
+ flip: function(time, doNotAddPlayClass) {
2158
+ if(!time) {
2159
+ time = this.factory.time.getMinuteCounter();
2160
+ }
2161
+ this.base(time, doNotAddPlayClass);
1939
2162
  },
1940
2163
 
1941
2164
  });
@@ -1994,12 +2217,12 @@ var FlipClock;
1994
2217
  * Flip the clock face
1995
2218
  */
1996
2219
 
1997
- flip: function() {
2220
+ flip: function(time, doNotAddPlayClass) {
1998
2221
  if(this.meridiumText != this._getMeridium()) {
1999
2222
  this.meridiumText = this._getMeridium();
2000
2223
  this.meridium.find('a').html(this.meridiumText);
2001
2224
  }
2002
- this.base(this.factory.time.getTime());
2225
+ this.base(this.factory.time.getTime(), doNotAddPlayClass);
2003
2226
  },
2004
2227
 
2005
2228
  /**
@@ -2038,6 +2261,60 @@ var FlipClock;
2038
2261
 
2039
2262
  });
2040
2263
 
2264
+ }(jQuery));
2265
+ (function($) {
2266
+
2267
+ /**
2268
+ * FlipClock Arabic Language Pack
2269
+ *
2270
+ * This class will be used to translate tokens into the Arabic language.
2271
+ *
2272
+ */
2273
+
2274
+ FlipClock.Lang.Arabic = {
2275
+
2276
+ 'years' : 'سنوات',
2277
+ 'months' : 'شهور',
2278
+ 'days' : 'أيام',
2279
+ 'hours' : 'ساعات',
2280
+ 'minutes' : 'دقائق',
2281
+ 'seconds' : 'ثواني'
2282
+
2283
+ };
2284
+
2285
+ /* Create various aliases for convenience */
2286
+
2287
+ FlipClock.Lang['ar'] = FlipClock.Lang.Arabic;
2288
+ FlipClock.Lang['ar-ar'] = FlipClock.Lang.Arabic;
2289
+ FlipClock.Lang['arabic'] = FlipClock.Lang.Arabic;
2290
+
2291
+ }(jQuery));
2292
+ (function($) {
2293
+
2294
+ /**
2295
+ * FlipClock Danish Language Pack
2296
+ *
2297
+ * This class will used to translate tokens into the Danish language.
2298
+ *
2299
+ */
2300
+
2301
+ FlipClock.Lang.Danish = {
2302
+
2303
+ 'years' : 'År',
2304
+ 'months' : 'Måneder',
2305
+ 'days' : 'Dage',
2306
+ 'hours' : 'Timer',
2307
+ 'minutes' : 'Minutter',
2308
+ 'seconds' : 'Sekunder'
2309
+
2310
+ };
2311
+
2312
+ /* Create various aliases for convenience */
2313
+
2314
+ FlipClock.Lang['da'] = FlipClock.Lang.Danish;
2315
+ FlipClock.Lang['da-dk'] = FlipClock.Lang.Danish;
2316
+ FlipClock.Lang['danish'] = FlipClock.Lang.Danish;
2317
+
2041
2318
  }(jQuery));
2042
2319
  (function($) {
2043
2320
 
@@ -2131,12 +2408,12 @@ var FlipClock;
2131
2408
 
2132
2409
  FlipClock.Lang.French = {
2133
2410
 
2134
- 'years' : 'ans',
2135
- 'months' : 'mois',
2136
- 'days' : 'jours',
2137
- 'hours' : 'heures',
2138
- 'minutes' : 'minutes',
2139
- 'seconds' : 'secondes'
2411
+ 'years' : 'Ans',
2412
+ 'months' : 'Mois',
2413
+ 'days' : 'Jours',
2414
+ 'hours' : 'Heures',
2415
+ 'minutes' : 'Minutes',
2416
+ 'seconds' : 'Secondes'
2140
2417
 
2141
2418
  };
2142
2419
 
@@ -2146,4 +2423,114 @@ var FlipClock;
2146
2423
  FlipClock.Lang['fr-ca'] = FlipClock.Lang.French;
2147
2424
  FlipClock.Lang['french'] = FlipClock.Lang.French;
2148
2425
 
2149
- }(jQuery));
2426
+ }(jQuery));
2427
+
2428
+ (function($) {
2429
+
2430
+ /**
2431
+ * FlipClock Italian Language Pack
2432
+ *
2433
+ * This class will used to translate tokens into the Italian language.
2434
+ *
2435
+ */
2436
+
2437
+ FlipClock.Lang.Italian = {
2438
+
2439
+ 'years' : 'Anni',
2440
+ 'months' : 'Mesi',
2441
+ 'days' : 'Giorni',
2442
+ 'hours' : 'Ore',
2443
+ 'minutes' : 'Minuti',
2444
+ 'seconds' : 'Secondi'
2445
+
2446
+ };
2447
+
2448
+ /* Create various aliases for convenience */
2449
+
2450
+ FlipClock.Lang['it'] = FlipClock.Lang.Italian;
2451
+ FlipClock.Lang['it-it'] = FlipClock.Lang.Italian;
2452
+ FlipClock.Lang['italian'] = FlipClock.Lang.Italian;
2453
+
2454
+ }(jQuery));
2455
+
2456
+ (function($) {
2457
+
2458
+ /**
2459
+ * FlipClock Dutch Language Pack
2460
+ *
2461
+ * This class will used to translate tokens into the Dutch language.
2462
+ */
2463
+
2464
+ FlipClock.Lang.Dutch = {
2465
+
2466
+ 'years' : 'Jaren',
2467
+ 'months' : 'Maanden',
2468
+ 'days' : 'Dagen',
2469
+ 'hours' : 'Uren',
2470
+ 'minutes' : 'Minuten',
2471
+ 'seconds' : 'Seconden'
2472
+
2473
+ };
2474
+
2475
+ /* Create various aliases for convenience */
2476
+
2477
+ FlipClock.Lang['nl'] = FlipClock.Lang.Dutch;
2478
+ FlipClock.Lang['nl-be'] = FlipClock.Lang.Dutch;
2479
+ FlipClock.Lang['dutch'] = FlipClock.Lang.Dutch;
2480
+
2481
+ }(jQuery));
2482
+
2483
+ (function($) {
2484
+
2485
+ /**
2486
+ * FlipClock Russian Language Pack
2487
+ *
2488
+ * This class will used to translate tokens into the Russian language.
2489
+ *
2490
+ */
2491
+
2492
+ FlipClock.Lang.Russian = {
2493
+
2494
+ 'years' : 'лет',
2495
+ 'months' : 'месяцев',
2496
+ 'days' : 'дней',
2497
+ 'hours' : 'часов',
2498
+ 'minutes' : 'минут',
2499
+ 'seconds' : 'секунд'
2500
+
2501
+ };
2502
+
2503
+ /* Create various aliases for convenience */
2504
+
2505
+ FlipClock.Lang['ru'] = FlipClock.Lang.Russian;
2506
+ FlipClock.Lang['ru-ru'] = FlipClock.Lang.Russian;
2507
+ FlipClock.Lang['russian'] = FlipClock.Lang.Russian;
2508
+
2509
+ }(jQuery));
2510
+ (function($) {
2511
+
2512
+ /**
2513
+ * FlipClock Swedish Language Pack
2514
+ *
2515
+ * This class will used to translate tokens into the Swedish language.
2516
+ *
2517
+ */
2518
+
2519
+ FlipClock.Lang.Swedish = {
2520
+
2521
+ 'years' : 'År',
2522
+ 'months' : 'Månader',
2523
+ 'days' : 'Dagar',
2524
+ 'hours' : 'Timmar',
2525
+ 'minutes' : 'Minuter',
2526
+ 'seconds' : 'Sekunder'
2527
+
2528
+ };
2529
+
2530
+ /* Create various aliases for convenience */
2531
+
2532
+ FlipClock.Lang['sv'] = FlipClock.Lang.Danish;
2533
+ FlipClock.Lang['sv-se'] = FlipClock.Lang.Danish;
2534
+ FlipClock.Lang['swedish'] = FlipClock.Lang.Danish;
2535
+
2536
+ }(jQuery));