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