/* Base.js, version 1.1a Copyright 2006-2010, Dean Edwards License: http://www.opensource.org/licenses/mit-license.php */ var Base = function() { // dummy }; Base.extend = function(_instance, _static) { // subclass "use strict"; var extend = Base.prototype.extend; // build the prototype Base._prototyping = true; var proto = new this(); extend.call(proto, _instance); proto.base = function() { // call this method from any other method to invoke that method's ancestor }; delete Base._prototyping; // create the wrapper for the constructor function //var constructor = proto.constructor.valueOf(); //-dean var constructor = proto.constructor; var klass = proto.constructor = function() { if (!Base._prototyping) { if (this._constructing || this.constructor == klass) { // instantiation this._constructing = true; constructor.apply(this, arguments); delete this._constructing; } else if (arguments[0] !== null) { // casting return (arguments[0].extend || extend).call(arguments[0], proto); } } }; // build the class interface klass.ancestor = this; klass.extend = this.extend; klass.forEach = this.forEach; klass.implement = this.implement; klass.prototype = proto; klass.toString = this.toString; klass.valueOf = function(type) { //return (type == "object") ? klass : constructor; //-dean return (type == "object") ? klass : constructor.valueOf(); }; extend.call(klass, _static); // class initialisation if (typeof klass.init == "function") klass.init(); return klass; }; Base.prototype = { extend: function(source, value) { if (arguments.length > 1) { // extending with a name/value pair var ancestor = this[source]; if (ancestor && (typeof value == "function") && // overriding a method? // the valueOf() comparison is to avoid circular references (!ancestor.valueOf || ancestor.valueOf() != value.valueOf()) && /\bbase\b/.test(value)) { // get the underlying method var method = value.valueOf(); // override value = function() { var previous = this.base || Base.prototype.base; this.base = ancestor; var returnValue = method.apply(this, arguments); this.base = previous; return returnValue; }; // point to the underlying method value.valueOf = function(type) { return (type == "object") ? value : method; }; value.toString = Base.toString; } this[source] = value; } else if (source) { // extending with an object literal var extend = Base.prototype.extend; // if this object has a customised extend method then use it if (!Base._prototyping && typeof this != "function") { extend = this.extend || extend; } var proto = {toSource: null}; // do the "toString" and other methods manually var hidden = ["constructor", "toString", "valueOf"]; // if we are prototyping then include the constructor var i = Base._prototyping ? 0 : 1; while (key = hidden[i++]) { if (source[key] != proto[key]) { extend.call(this, key, source[key]); } } // copy each of the source object's properties to this object for (var key in source) { if (!proto[key]) extend.call(this, key, source[key]); } } return this; } }; // initialise Base = Base.extend({ constructor: function() { this.extend(arguments[0]); } }, { ancestor: Object, version: "1.1", forEach: function(object, block, context) { for (var key in object) { if (this.prototype[key] === undefined) { block.call(context, object[key], key, object); } } }, implement: function() { for (var i = 0; i < arguments.length; i++) { if (typeof arguments[i] == "function") { // if it's a function, call it arguments[i](this.prototype); } else { // add the interface using the extend method this.prototype.extend(arguments[i]); } } return this; }, toString: function() { return String(this.valueOf()); } }); /*jshint smarttabs:true */ var FlipClock; /** * FlipClock.js * * @author Justin Kimbrell * @copyright 2013 - Objective HTML, LLC * @licesnse http://www.opensource.org/licenses/mit-license.php */ (function($) { "use strict"; /** * FlipFlock Helper * * @param object A jQuery object or CSS select * @param int An integer used to start the clock (no. seconds) * @param object An object of properties to override the default */ FlipClock = function(obj, digit, options) { if(digit instanceof Object && digit instanceof Date === false) { options = digit; digit = 0; } return new FlipClock.Factory(obj, digit, options); }; /** * The global FlipClock.Lang object */ FlipClock.Lang = {}; /** * The Base FlipClock class is used to extend all other FlipFlock * classes. It handles the callbacks and the basic setters/getters * * @param object An object of the default properties * @param object An object of properties to override the default */ FlipClock.Base = Base.extend({ /** * Build Date */ buildDate: '2014-12-12', /** * Version */ version: '0.7.7', /** * Sets the default options * * @param object The default options * @param object The override options */ constructor: function(_default, options) { if(typeof _default !== "object") { _default = {}; } if(typeof options !== "object") { options = {}; } this.setOptions($.extend(true, {}, _default, options)); }, /** * Delegates the callback to the defined method * * @param object The default options * @param object The override options */ callback: function(method) { if(typeof method === "function") { var args = []; for(var x = 1; x <= arguments.length; x++) { if(arguments[x]) { args.push(arguments[x]); } } method.apply(this, args); } }, /** * Log a string into the console if it exists * * @param string The name of the option * @return mixed */ log: function(str) { if(window.console && console.log) { console.log(str); } }, /** * Get an single option value. Returns false if option does not exist * * @param string The name of the option * @return mixed */ getOption: function(index) { if(this[index]) { return this[index]; } return false; }, /** * Get all options * * @return bool */ getOptions: function() { return this; }, /** * Set a single option value * * @param string The name of the option * @param mixed The value of the option */ setOption: function(index, value) { this[index] = value; }, /** * Set a multiple options by passing a JSON object * * @param object The object with the options * @param mixed The value of the option */ setOptions: function(options) { for(var key in options) { if(typeof options[key] !== "undefined") { this.setOption(key, options[key]); } } } }); }(jQuery)); /*jshint smarttabs:true */ /** * FlipClock.js * * @author Justin Kimbrell * @copyright 2013 - Objective HTML, LLC * @licesnse http://www.opensource.org/licenses/mit-license.php */ (function($) { "use strict"; /** * The FlipClock Face class is the base class in which to extend * all other FlockClock.Face classes. * * @param object The parent FlipClock.Factory object * @param object An object of properties to override the default */ FlipClock.Face = FlipClock.Base.extend({ /** * Sets whether or not the clock should start upon instantiation */ autoStart: true, /** * An array of jQuery objects used for the dividers (the colons) */ dividers: [], /** * An array of FlipClock.List objects */ factory: false, /** * An array of FlipClock.List objects */ lists: [], /** * Constructor * * @param object The parent FlipClock.Factory object * @param object An object of properties to override the default */ constructor: function(factory, options) { this.dividers = []; this.lists = []; this.base(options); this.factory = factory; }, /** * Build the clock face */ build: function() { if(this.autoStart) { this.start(); } }, /** * Creates a jQuery object used for the digit divider * * @param mixed The divider label text * @param mixed Set true to exclude the dots in the divider. * If not set, is false. */ createDivider: function(label, css, excludeDots) { if(typeof css == "boolean" || !css) { excludeDots = css; css = label; } var dots = [ '', '' ].join(''); if(excludeDots) { dots = ''; } label = this.factory.localize(label); var html = [ '', ''+(label ? label : '')+'', dots, '' ]; var $html = $(html.join('')); this.dividers.push($html); return $html; }, /** * Creates a FlipClock.List object and appends it to the DOM * * @param mixed The digit to select in the list * @param object An object to override the default properties */ createList: function(digit, options) { if(typeof digit === "object") { options = digit; digit = 0; } var obj = new FlipClock.List(this.factory, digit, options); this.lists.push(obj); return obj; }, /** * Triggers when the clock is reset */ reset: function() { this.factory.time = new FlipClock.Time( this.factory, this.factory.original ? Math.round(this.factory.original) : 0, { minimumDigits: this.factory.minimumDigits } ); this.flip(this.factory.original, false); }, /** * Append a newly created list to the clock */ appendDigitToClock: function(obj) { obj.$el.append(false); }, /** * Add a digit to the clock face */ addDigit: function(digit) { var obj = this.createList(digit, { classes: { active: this.factory.classes.active, before: this.factory.classes.before, flip: this.factory.classes.flip } }); this.appendDigitToClock(obj); }, /** * Triggers when the clock is started */ start: function() {}, /** * Triggers when the time on the clock stops */ stop: function() {}, /** * Auto increments/decrements the value of the clock face */ autoIncrement: function() { if(!this.factory.countdown) { this.increment(); } else { this.decrement(); } }, /** * Increments the value of the clock face */ increment: function() { this.factory.time.addSecond(); }, /** * Decrements the value of the clock face */ decrement: function() { if(this.factory.time.getTimeSeconds() == 0) { this.factory.stop() } else { this.factory.time.subSecond(); } }, /** * Triggers when the numbers on the clock flip */ flip: function(time, doNotAddPlayClass) { var t = this; $.each(time, function(i, digit) { var list = t.lists[i]; if(list) { if(!doNotAddPlayClass && digit != list.digit) { list.play(); } list.select(digit); } else { t.addDigit(digit); } }); } }); }(jQuery)); /*jshint smarttabs:true */ /** * FlipClock.js * * @author Justin Kimbrell * @copyright 2013 - Objective HTML, LLC * @licesnse http://www.opensource.org/licenses/mit-license.php */ (function($) { "use strict"; /** * The FlipClock Factory class is used to build the clock and manage * all the public methods. * * @param object A jQuery object or CSS selector used to fetch the wrapping DOM nodes * @param mixed This is the digit used to set the clock. If an object is passed, 0 will be used. * @param object An object of properties to override the default */ FlipClock.Factory = FlipClock.Base.extend({ /** * The clock's animation rate. * * Note, currently this property doesn't do anything. * This property is here to be used in the future to * programmaticaly set the clock's animation speed */ animationRate: 1000, /** * Auto start the clock on page load (True|False) */ autoStart: true, /** * The callback methods */ callbacks: { destroy: false, create: false, init: false, interval: false, start: false, stop: false, reset: false }, /** * The CSS classes */ classes: { active: 'flip-clock-active', before: 'flip-clock-before', divider: 'flip-clock-divider', dot: 'flip-clock-dot', label: 'flip-clock-label', flip: 'flip', play: 'play', wrapper: 'flip-clock-wrapper' }, /** * The name of the clock face class in use */ clockFace: 'HourlyCounter', /** * The name of the clock face class in use */ countdown: false, /** * The name of the default clock face class to use if the defined * clockFace variable is not a valid FlipClock.Face object */ defaultClockFace: 'HourlyCounter', /** * The default language */ defaultLanguage: 'english', /** * The jQuery object */ $el: false, /** * The FlipClock.Face object */ face: true, /** * The language object after it has been loaded */ lang: false, /** * The language being used to display labels (string) */ language: 'english', /** * The minimum digits the clock must have */ minimumDigits: 0, /** * The original starting value of the clock. Used for the reset method. */ original: false, /** * Is the clock running? (True|False) */ running: false, /** * The FlipClock.Time object */ time: false, /** * The FlipClock.Timer object */ timer: false, /** * The jQuery object (depcrecated) */ $wrapper: false, /** * Constructor * * @param object The wrapping jQuery object * @param object Number of seconds used to start the clock * @param object An object override options */ constructor: function(obj, digit, options) { if(!options) { options = {}; } this.lists = []; this.running = false; this.base(options); this.$el = $(obj).addClass(this.classes.wrapper); // Depcrated support of the $wrapper property. this.$wrapper = this.$el; this.original = (digit instanceof Date) ? digit : (digit ? Math.round(digit) : 0); this.time = new FlipClock.Time(this, this.original, { minimumDigits: this.minimumDigits, animationRate: this.animationRate }); this.timer = new FlipClock.Timer(this, options); this.loadLanguage(this.language); this.loadClockFace(this.clockFace, options); if(this.autoStart) { this.start(); } }, /** * Load the FlipClock.Face object * * @param object The name of the FlickClock.Face class * @param object An object override options */ loadClockFace: function(name, options) { var face, suffix = 'Face', hasStopped = false; name = name.ucfirst()+suffix; if(this.face.stop) { this.stop(); hasStopped = true; } this.$el.html(''); this.time.minimumDigits = this.minimumDigits; if(FlipClock[name]) { face = new FlipClock[name](this, options); } else { face = new FlipClock[this.defaultClockFace+suffix](this, options); } face.build(); this.face = face if(hasStopped) { this.start(); } return this.face; }, /** * Load the FlipClock.Lang object * * @param object The name of the language to load */ loadLanguage: function(name) { var lang; if(FlipClock.Lang[name.ucfirst()]) { lang = FlipClock.Lang[name.ucfirst()]; } else if(FlipClock.Lang[name]) { lang = FlipClock.Lang[name]; } else { lang = FlipClock.Lang[this.defaultLanguage]; } return this.lang = lang; }, /** * Localize strings into various languages * * @param string The index of the localized string * @param object Optionally pass a lang object */ localize: function(index, obj) { var lang = this.lang; if(!index) { return null; } var lindex = index.toLowerCase(); if(typeof obj == "object") { lang = obj; } if(lang && lang[lindex]) { return lang[lindex]; } return index; }, /** * Starts the clock */ start: function(callback) { var t = this; if(!t.running && (!t.countdown || t.countdown && t.time.time > 0)) { t.face.start(t.time); t.timer.start(function() { t.flip(); if(typeof callback === "function") { callback(); } }); } else { t.log('Trying to start timer when countdown already at 0'); } }, /** * Stops the clock */ stop: function(callback) { this.face.stop(); this.timer.stop(callback); for(var x in this.lists) { if (this.lists.hasOwnProperty(x)) { this.lists[x].stop(); } } }, /** * Reset the clock */ reset: function(callback) { this.timer.reset(callback); this.face.reset(); }, /** * Sets the clock time */ setTime: function(time) { this.time.time = time; this.flip(true); }, /** * Get the clock time * * @return object Returns a FlipClock.Time object */ getTime: function(time) { return this.time; }, /** * Changes the increment of time to up or down (add/sub) */ setCountdown: function(value) { var running = this.running; this.countdown = value ? true : false; if(running) { this.stop(); this.start(); } }, /** * Flip the digits on the clock * * @param array An array of digits */ flip: function(doNotAddPlayClass) { this.face.flip(false, doNotAddPlayClass); } }); }(jQuery)); /*jshint smarttabs:true */ /** * FlipClock.js * * @author Justin Kimbrell * @copyright 2013 - Objective HTML, LLC * @licesnse http://www.opensource.org/licenses/mit-license.php */ (function($) { "use strict"; /** * The FlipClock List class is used to build the list used to create * the card flip effect. This object fascilates selecting the correct * node by passing a specific digit. * * @param object A FlipClock.Factory object * @param mixed This is the digit used to set the clock. If an * object is passed, 0 will be used. * @param object An object of properties to override the default */ FlipClock.List = FlipClock.Base.extend({ /** * The digit (0-9) */ digit: 0, /** * The CSS classes */ classes: { active: 'flip-clock-active', before: 'flip-clock-before', flip: 'flip' }, /** * The parent FlipClock.Factory object */ factory: false, /** * The jQuery object */ $el: false, /** * The jQuery object (deprecated) */ $obj: false, /** * The items in the list */ items: [], /** * The last digit */ lastDigit: 0, /** * Constructor * * @param object A FlipClock.Factory object * @param int An integer use to select the correct digit * @param object An object to override the default properties */ constructor: function(factory, digit, options) { this.factory = factory; this.digit = digit; this.lastDigit = digit; this.$el = this.createList(); // Depcrated support of the $obj property. this.$obj = this.$el; if(digit > 0) { this.select(digit); } this.factory.$el.append(this.$el); }, /** * Select the digit in the list * * @param int A digit 0-9 */ select: function(digit) { if(typeof digit === "undefined") { digit = this.digit; } else { this.digit = digit; } if(this.digit != this.lastDigit) { var $delete = this.$el.find('.'+this.classes.before).removeClass(this.classes.before); this.$el.find('.'+this.classes.active).removeClass(this.classes.active) .addClass(this.classes.before); this.appendListItem(this.classes.active, this.digit); $delete.remove(); this.lastDigit = this.digit; } }, /** * Adds the play class to the DOM object */ play: function() { this.$el.addClass(this.factory.classes.play); }, /** * Removes the play class to the DOM object */ stop: function() { var t = this; setTimeout(function() { t.$el.removeClass(t.factory.classes.play); }, this.factory.timer.interval); }, /** * Creates the list item HTML and returns as a string */ createListItem: function(css, value) { return [ '