Created
September 24, 2013 10:23
-
-
Save drfill/6682899 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function($) { | |
| /** | |
| * Daily Counter Clock Face | |
| * | |
| * This class will generate a daily counter for FlipClock.js. A | |
| * daily counter will track days, hours, minutes, and seconds. If | |
| * the number of available digits is exceeded in the count, a new | |
| * digit will be created. | |
| * | |
| * @param object The parent FlipClock.Factory object | |
| * @param object An object of properties to override the default | |
| */ | |
| FlipClock.DailyCounterFace = FlipClock.Face.extend({ | |
| /** | |
| * Constructor | |
| * | |
| * @param object The parent FlipClock.Factory object | |
| * @param object An object of properties to override the default | |
| */ | |
| constructor: function(factory, options) { | |
| this.base(factory, options); | |
| }, | |
| /** | |
| * Build the clock face | |
| */ | |
| build: function(excludeHours, time) { | |
| var t = this; | |
| var children = this.factory.$wrapper.find('ul'); | |
| var lists = []; | |
| time = time ? time : this.factory.time.getDayCounter(); | |
| if(time.length > children.length) { | |
| $.each(time, function(i, digit) { | |
| lists.push(t.createList(digit)); | |
| }); | |
| } | |
| this.factory.lists = lists; | |
| $(this.createDivider('секунды')).insertBefore(this.factory.lists[this.factory.lists.length - 2].$obj); | |
| $(this.createDivider('минуты')).insertBefore(this.factory.lists[this.factory.lists.length - 4].$obj); | |
| $(this.createDivider('часы', true)).insertBefore(this.factory.lists[this.factory.lists.length - 6].$obj); | |
| $(this.createDivider('дни', true)).insertBefore(this.factory.lists[0].$obj); | |
| this._clearExcessDigits(); | |
| if(this.autoStart) { | |
| this.start(); | |
| } | |
| }, | |
| /** | |
| * Flip the clock face | |
| */ | |
| flip: function(doNotAddPlayClass, time) { | |
| if(!time) { | |
| time = this.factory.time.getDayCounter(); | |
| } | |
| this.base(time, doNotAddPlayClass); | |
| }, | |
| /** | |
| * Clear the excess digits from the tens columns for sec/min | |
| */ | |
| _clearExcessDigits: function() { | |
| var tenSeconds = this.factory.lists[this.factory.lists.length - 2]; | |
| var tenMinutes = this.factory.lists[this.factory.lists.length - 4]; | |
| for(var x = 6; x < 10; x++) { | |
| tenSeconds.$obj.find('li:last-child').remove(); | |
| tenMinutes.$obj.find('li:last-child').remove(); | |
| } | |
| } | |
| }); | |
| }(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment