vendor: 9,709 bytes, lines 1-240
1/** 2* @author ThemeDelights 3* @copyright Since 2015 ThemeDelights. All Rights Reserved. 4* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 5*/ 6/*! 7 * The Final Countdown for jQuery v2.1.0 (http://hilios.github.io/jQuery.countdown/) 8 * Copyright (c) 2015 Edson Hilios 9 * 10 * Permission is hereby granted, free of charge, to any person obtaining a copy of 11 * this software and associated documentation files (the "Software"), to deal in 12 * the Software without restriction, including without limitation the rights to 13 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 14 * the Software, and to permit persons to whom the Software is furnished to do so, 15 * subject to the following conditions: 16 * 17 * The above copyright notice and this permission notice shall be included in all 18 * copies or substantial portions of the Software. 19 * 20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 23 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 24 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 25 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 */ 27(function(factory) { 28 "use strict"; 29 if (typeof define === "function" && define.amd) { 30 define([ "jquery" ], factory); 31 } else { 32 factory(jQuery); 33 } 34})(function($) { 35 "use strict"; 36 var instances = [], matchers = [], defaultOptions = { 37 precision: 100, 38 elapse: false 39 }; 40 matchers.push(/^[0-9]*$/.source); 41 matchers.push(/([0-9]{1,2}\/){2}[0-9]{4}( [0-9]{1,2}(:[0-9]{2}){2})?/.source); 42 matchers.push(/[0-9]{4}([\/\-][0-9]{1,2}){2}( [0-9]{1,2}(:[0-9]{2}){2})?/.source); 43 matchers = new RegExp(matchers.join("|")); 44 function parseDateString(dateString) { 45 if (dateString instanceof Date) { 46 return dateString; 47 } 48 if (String(dateString).match(matchers)) { 49 if (String(dateString).match(/^[0-9]*$/)) { 50 dateString = Number(dateString); 51 } 52 if (String(dateString).match(/\-/)) { 53 dateString = String(dateString).replace(/\-/g, "/"); 54 } 55 return new Date(dateString); 56 } else { 57 throw new Error("Couldn't cast `" + dateString + "` to a date object."); 58 } 59 } 60 var DIRECTIVE_KEY_MAP = { 61 Y: "years", 62 m: "months", 63 n: "daysToMonth", 64 w: "weeks", 65 d: "daysToWeek", 66 D: "totalDays", 67 H: "hours", 68 M: "minutes", 69 S: "seconds" 70 }; 71 function escapedRegExp(str) { 72 var sanitize = str.toString().replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1"); 73 return new RegExp(sanitize); 74 } 75 function strftime(offsetObject) { 76 return function(format) { 77 var directives = format.match(/%(-|!)?[A-Z]{1}(:[^;]+;)?/gi); 78 if (directives) { 79 for (var i = 0, len = directives.length; i < len; ++i) { 80 var directive = directives[i].match(/%(-|!)?([a-zA-Z]{1})(:[^;]+;)?/), regexp = escapedRegExp(directive[0]), modifier = directive[1] || "", plural = directive[3] || "", value = null; 81 directive = directive[2]; 82 if (DIRECTIVE_KEY_MAP.hasOwnProperty(directive)) { 83 value = DIRECTIVE_KEY_MAP[directive]; 84 value = Number(offsetObject[value]); 85 } 86 if (value !== null) { 87 if (modifier === "!") { 88 value = pluralize(plural, value); 89 } 90 if (modifier === "") { 91 if (value < 10) { 92 value = "0" + value.toString(); 93 } 94 } 95 format = format.replace(regexp, value.toString()); 96 } 97 } 98 } 99 format = format.replace(/%%/, "%"); 100 return format; 101 }; 102 } 103 function pluralize(format, count) { 104 var plural = "s", singular = ""; 105 if (format) { 106 format = format.replace(/(:|;|\s)/gi, "").split(/\,/); 107 if (format.length === 1) { 108 plural = format[0]; 109 } else { 110 singular = format[0]; 111 plural = format[1]; 112 } 113 } 114 if (Math.abs(count) === 1) { 115 return singular; 116 } else { 117 return plural; 118 } 119 } 120 var Countdown = function(el, finalDate, options) { 121 this.el = el; 122 this.$el = $(el); 123 this.interval = null; 124 this.offset = {}; 125 this.options = $.extend({}, defaultOptions); 126 this.instanceNumber = instances.length; 127 instances.push(this); 128 this.$el.data("countdown-instance", this.instanceNumber); 129 if (options) { 130 if (typeof options === "function") { 131 this.$el.on("update.countdown", options); 132 this.$el.on("stoped.countdown", options); 133 this.$el.on("finish.countdown", options); 134 } else { 135 this.options = $.extend({}, defaultOptions, options); 136 } 137 } 138 this.setFinalDate(finalDate); 139 this.start(); 140 }; 141 $.extend(Countdown.prototype, { 142 start: function() { 143 if (this.interval !== null) { 144 clearInterval(this.interval); 145 } 146 var self = this; 147 this.update(); 148 this.interval = setInterval(function() { 149 self.update.call(self); 150 }, this.options.precision); 151 }, 152 stop: function() { 153 clearInterval(this.interval); 154 this.interval = null; 155 this.dispatchEvent("stoped"); 156 }, 157 toggle: function() { 158 if (this.interval) { 159 this.stop(); 160 } else { 161 this.start(); 162 } 163 }, 164 pause: function() { 165 this.stop(); 166 }, 167 resume: function() { 168 this.start(); 169 }, 170 remove: function() { 171 this.stop.call(this); 172 instances[this.instanceNumber] = null; 173 delete this.$el.data().countdownInstance; 174 }, 175 setFinalDate: function(value) { 176 this.finalDate = parseDateString(value); 177 }, 178 update: function() { 179 if (this.$el.closest("html").length === 0) { 180 this.remove(); 181 return; 182 } 183 var hasEventsAttached = $._data(this.el, "events") !== undefined, now = new Date(), newTotalSecsLeft; 184 newTotalSecsLeft = this.finalDate.getTime() - now.getTime(); 185 newTotalSecsLeft = Math.ceil(newTotalSecsLeft / 1e3); 186 newTotalSecsLeft = !this.options.elapse && newTotalSecsLeft < 0 ? 0 : Math.abs(newTotalSecsLeft); 187 if (this.totalSecsLeft === newTotalSecsLeft || !hasEventsAttached) { 188 return; 189 } else { 190 this.totalSecsLeft = newTotalSecsLeft; 191 } 192 this.elapsed = now >= this.finalDate; 193 this.offset = { 194 seconds: this.totalSecsLeft % 60, 195 minutes: Math.floor(this.totalSecsLeft / 60) % 60, 196 hours: Math.floor(this.totalSecsLeft / 60 / 60) % 24, 197 days: Math.floor(this.totalSecsLeft / 60 / 60 / 24) % 7, 198 daysToWeek: Math.floor(this.totalSecsLeft / 60 / 60 / 24) % 7, 199 daysToMonth: Math.floor(this.totalSecsLeft / 60 / 60 / 24 % 30.4368), 200 totalDays: Math.floor(this.totalSecsLeft / 60 / 60 / 24), 201 weeks: Math.floor(this.totalSecsLeft / 60 / 60 / 24 / 7), 202 months: Math.floor(this.totalSecsLeft / 60 / 60 / 24 / 30.4368), 203 years: Math.abs(this.finalDate.getFullYear() - now.getFullYear()) 204 }; 205 if (!this.options.elapse && this.totalSecsLeft === 0) { 206 this.stop(); 207 this.dispatchEvent("finish"); 208 } else { 209 this.dispatchEvent("update"); 210 } 211 }, 212 dispatchEvent: function(eventName) { 213 var event = $.Event(eventName + ".countdown"); 214 event.finalDate = this.finalDate; 215 event.elapsed = this.elapsed; 216 event.offset = $.extend({}, this.offset); 217 event.strftime = strftime(this.offset); 218 this.$el.trigger(event); 219 } 220 }); 221 $.fn.countdown = function() { 222 var argumentsArray = Array.prototype.slice.call(arguments, 0); 223 return this.each(function() { 224 var instanceNumber = $(this).data("countdown-instance"); 225 if (instanceNumber !== undefined) { 226 var instance = instances[instanceNumber], method = argumentsArray[0]; 227 if (Countdown.prototype.hasOwnProperty(method)) { 228 instance[method].apply(instance, argumentsArray.slice(1)); 229 } else if (String(method).match(/^[$A-Z_][0-9A-Z_$]*$/i) === null) { 230 instance.setFinalDate.call(instance, method); 231 instance.start(); 232 } else { 233 $.error("Method %s does not exist on jQuery.countdown".replace(/\%s/gi, method)); 234 } 235 } else { 236 new Countdown(this, argumentsArray[0], argumentsArray[1]); 237 } 238 }); 239 }; 240});
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.