1(function($){ 2(function() { 3 var KKCountdown; 4 5 KKCountdown = (function() { 6 KKCountdown.prototype.version = '1.4.1'; 7 8 KKCountdown.prototype.defaults = { 9 dayText: 'day ', 10 days2Text: 'days ', 11 daysText: 'days ', 12 hourText: 'hour ', 13 hours2Text: 'hours ', 14 hoursText: 'hours ', 15 minutesText: ':', 16 secondsText: '', 17 textAfterCount: '', 18 oneDayClass: false, 19 displayDays: true, 20 displayZeroDays: true, 21 addClass: false, 22 callback: false, 23 warnSeconds: 60, 24 warnClass: false, 25 rusNumbers: false, 26 boxContenerClass: 'kkcountdown-box', 27 boxDaysClass: 'kkc-days', 28 boxHoursClass: 'kkc-hours', 29 boxMinClass: 'kkc-min', 30 boxSecClass: 'kkc-sec', 31 boxDaysTextClass: 'kkc-days-text', 32 boxHoursTextClass: 'kkc-hours-text', 33 boxMinTextClass: 'kkc-min-text', 34 boxSecTextClass: 'kkc-sec-text', 35 theme: false, 36 themeSize: 'default', 37 displayTexts: 'yes' 38 }; 39 40 function KKCountdown(el, options) { 41 var _this; 42 _this = this; 43 this.opts = $.extend({}, this.defaults, options); 44 this.$el = $(el); 45 this.countdowns = []; 46 this.prepareHTML(); 47 this.countdownInit(this.$el); 48 } 49 50 KKCountdown.prototype.prepareHTML = function() {
51 var box, boxDays, boxDaysText, boxHours, boxHoursText, boxMin, boxMinText, boxSec, boxSecText, _this; 52 _this = this; 53 box = $(document.createElement('span')).addClass(_this.opts.boxContenerClass); 54 if (_this.opts.addClass) { 55 box.addClass(_this.opts.addClass); 56 } 57 box.append( 58 '<div class="row">'+ 59 '<div class="col-md-3">'+ 60 '<div class="btn-info">'+ 61 '<span class="'+_this.opts.boxDaysClass+' kk_number"></span>'+ 62 ( _this.opts.displayTexts == 'yes' ? '<span class="kk_text '+_this.opts.boxDaysTextClass+'"></span>' : '' )+ 63 '</div>'+ 64 '</div>'+ 65 '<div class="col-md-3">'+ 66 '<div class="btn-info">'+ 67 '<span class="'+_this.opts.boxHoursClass+' kk_number"></span>'+ 68 ( _this.opts.displayTexts == 'yes' ? '<span class="kk_text '+_this.opts.boxHoursTextClass+'">'+_this.opts.hoursText+'</span>' : '' )+ 69 '</div>'+ 70 '</div>'+ 71 '<div class="col-md-3">'+ 72 '<div class="btn-info">'+ 73 '<span class="'+_this.opts.boxMinClass+' kk_number"></span>'+ 74 ( _this.opts.displayTexts == 'yes' ? '<span class="kk_text '+_this.opts.boxMinTextClass+'">'+_this.opts.minutesText+'</span>' : '' )+ 75 '</div>'+ 76 '</div>'+ 77 '<div class="col-md-3">'+ 78 '<div class="btn-info">'+ 79 '<span class="'+_this.opts.boxSecClass+' kk_number"></span>'+ 80 ( _this.opts.displayTexts == 'yes' ? '<span class="kk_text '+_this.opts.boxSecTextClass+'">'+_this.opts.secondsText+'</span>' : '' )+ 81 '</div>'+ 82 '</div>'+ 83 '</div>' 84 ); 85 86 return this.$el.append(box); 87 }; 88 89 KKCountdown.prototype.countdownInit = function(obj) { 90 var count, event, now, _this; 91 count = 0; 92 _this = this; 93 if (obj.id === void 0) { 94 obj.id = 'kk_' + Math.random(new Date().getTime()); 95 } 96 if (_this.countdowns[obj.id] || _this.countdowns[obj.id] === 0) { 97 count = _this.countdowns[obj.id]; 98 } else { 99 count = obj.data('seconds'); 100 } 101 if (count === void 0) { 102 now = new Date(); 103 now = Math.floor(now.getTime() / 1000); 104 event = obj.data('time'); 105 if (event === void 0) { 106 event = obj.attr('time'); 107 } 108 count = event - now; 109 } 110 _this.countdowns[obj.id] = count - 1; 111 if (_this.opts.warnClass && count < _this.opts.warnSeconds) { 112 obj.addClass(_this.opts.warnClass); 113 } 114 if (count <= 0) { 115 obj.html(_this.opts.textAfterCount); 116 if (_this.opts.callback) { 117 return _this.opts.callback.call(obj); 118 } 119 } else if (count <= 24 * 60 * 60) { 120 this.countdown(true, obj, count); 121 return setTimeout(function() { 122 return _this.countdownInit(obj); 123 }, 1000); 124 } else { 125 this.countdown(false, obj, count); 126 return setTimeout(function() { 127 return _this.countdownInit(obj); 128 }, 1000); 129 } 130 }; 131 132 KKCountdown.prototype.countdown = function(warning, obj, count) { 133 var days, hours, minutes, seconds, _this; 134 _this = this; 135 seconds = this.fixTime(count % 60); 136 count = Math.floor(count / 60); 137 minutes = this.fixTime(count % 60); 138 count = Math.floor(count / 60); 139 hours = this.fixTime(count % 24); 140 count = Math.floor(count / 24); 141 days = count; 142 if (_this.opts.oneDayClass && warning) { 143 obj.addClass(_this.opts.oneDayClass); 144 } 145 if (_this.opts.displayZeroDays && days >= 0) { 146 obj.find('.' + _this.opts.boxDaysClass).html(days); 147 obj.find('.' + _this.opts.boxDaysTextClass).html(this.formatText(days, 'day')); 148 } 149 obj.find('.' + _this.opts.boxHoursClass).html(hours); 150 obj.find('.' + _this.opts.boxHoursTextClass).html(this.formatText(hours, 'hour')); 151 obj.find('.' + _this.opts.boxMinClass).html(minutes); 152 return obj.find('.' + _this.opts.boxSecClass).html(seconds); 153 }; 154 155 KKCountdown.prototype.formatText = function(nr, text) { 156 var daysText, lastDigit, _this; 157 _this = this; 158 daysText = _this.opts[text + 'sText']; 159 if (_this.opts.rusNumbers) { 160 if (nr >= 5 && nr < 20) { 161 return daysText = _this.opts[text + 'sText']; 162 } else { 163 lastDigit = ("" + nr).replace(/^\d+(\d)$/, '$1') * 1; 164 if (lastDigit === 1) { 165 return daysText = _this.opts[text + 'Text']; 166 } else { 167 if (lastDigit >= 2 && lastDigit <= 4) { 168 return daysText = _this.opts[text + 's2Text']; 169 } else { 170 return daysText = _this.opts[text + 'sText']; 171 } 172 } 173 } 174 } else { 175 if (nr === 1) { 176 return daysText = _this.opts[text + 'Text']; 177 } else { 178 return daysText = _this.opts[text + 'sText']; 179 } 180 } 181 }; 182 183 KKCountdown.prototype.fixTime = function(nr) { 184 if (nr < 10) { 185 return nr = '0' + nr; 186 } else { 187 return nr = nr; 188 } 189 }; 190 191 return KKCountdown; 192 193 })(); 194 195 $.fn.extend({ 196 kkcountdown: function(option) { 197 return this.each(function() { 198 var $this, data; 199 $this = $(this); 200 data = $this.data('kkcountdown'); 201 if (!data) { 202 $this.data('kkcountdown', (data = new KKCountdown(this, option))); 203 } 204 if (typeof option === 'string') { 205 return data[option].apply(data, args); 206 } 207 }); 208 } 209 }); 210 211}).call(this); 212})(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.