1function YcdSimpleCountdown() 2{ 3 this.countdownRun = true; 4 this.isActive = true; 5 this.seconds = 0; 6 this.id = 0; 7 this.doubeleDigits = false; 8 this.timerInterval; 9 this.countdownContainer = jQuery('.ycd-simple-container'); 10} 11 12YcdSimpleCountdown.run = function() 13{ 14 var simpleCountdown = jQuery('.ycd-simple-container'); 15 16 if (!simpleCountdown.length) { 17 return false; 18 } 19 20 simpleCountdown.each(function () { 21 var options = jQuery(this).data('options'); 22 var id = jQuery(this).data('id'); 23 var obj = new YcdSimpleCountdown(); 24 25 options['id'] = id; 26 obj.options = options; 27 obj.id = id; 28 obj.init(); 29 YcgGeneral.bind(obj); 30 }); 31}; 32 33YcdSimpleCountdown.prototype = new YcgGeneral(); 34 35YcdSimpleCountdown.prototype.init = function() 36{ 37 this.doubeleDigits = this.options['ycd-enable-simple-double-digits']; 38 39 this.render(); 40 this.livePreview(); 41}; 42 43YcdSimpleCountdown.prototype.responsive = function() { 44 var scale = function () { 45 jQuery('.ycd-simple-content-wrapper').each(function () { 46 var wrapperWidth = jQuery('.ycd-simple-mode-textUnderCountdown', this).get(0).scrollWidth; 47 var scaleDegree = jQuery(this).width()/wrapperWidth; 48 49 if(wrapperWidth > jQuery(this).width()) { 50 jQuery('.ycd-simple-container', this).css({ 51 'transform': 'scale('+ scaleDegree +', '+scaleDegree+')' 52 }); 53 } 54 else { 55 jQuery('.ycd-simple-container', this).css({ 56 'transform': 'scale('+ 1 +', '+1+')' 57 }); 58 } 59 }); 60 }; 61 62 scale(); 63 jQuery(window).resize(function () { 64 scale(); 65 }) 66}; 67 68YcdSimpleCountdown.prototype.changeDate = function() { 69 var datePicker = jQuery('#ycd-date-time-picker, #ycd-coming-soon-start'); 70 if(!datePicker.length) { 71 return false; 72 } 73 74 datePicker.change(function () { 75 jQuery(window).trigger('ycdChangeDate'); 76 }) 77}; 78 79YcdSimpleCountdown.prototype.changeTimeZone = function() { 80 var timeZone = jQuery('.js-circle-time-zone'); 81 82 if(!timeZone.length) { 83 return false; 84 } 85 86 timeZone.bind('change', function() { 87 jQuery(window).trigger('ycdChangeDate'); 88 }); 89}; 90 91YcdSimpleCountdown.prototype.changeDateDuration = function() { 92 var types = jQuery('.ycd-timer-time-settings'); 93 94 if(!types.length) { 95 return false; 96 } 97 var that = this; 98 var countdown = this.countdownContainer; 99 types.unbind('change').bind('change', function() { 100 var val = jQuery(this).val(); 101 102 if (val == '') { 103 val = 0; 104 jQuery(this).val(val); 105 } 106 var timeName = jQuery(this).attr('name'); 107 var options = countdown.data('options'); 108 options[timeName] = parseInt(val); 109 110 that.reInitSecondsByOptions(options); 111 }); 112}; 113 114YcdSimpleCountdown.prototype.changeFontFamily = function() { 115 var types = jQuery('.js-simple-font-family'); 116 117 if(!types.length) { 118 return false; 119 } 120 types.bind('change', function() { 121 var val = jQuery(this).val(); 122 var type = jQuery(this).data('field-type'); 123 124 jQuery('.ycd-simple-countdown-'+type).css({'font-family': val}); 125 }); 126}; 127 128YcdSimpleCountdown.prototype.changeFontSizes = function() { 129 var types = jQuery('.ycd-simple-font-size'); 130 131 if(!types.length) { 132 return false; 133 } 134 var that = this; 135 var countdown = this.countdownContainer; 136 types.bind('change', function() { 137 var val = jQuery(this).val(); 138 var type = jQuery(this).data('field-type'); 139 140 jQuery('.ycd-simple-countdown-'+type).css({'font-size': val}); 141 }); 142}; 143 144YcdSimpleCountdown.prototype.changeColor = function() { 145 var types = jQuery('.js-ycd-simple-time-color'); 146 147 if(!types.length) { 148 return false; 149 } 150 var that = this; 151 var countdown = this.countdownContainer; 152 types.minicolors({ 153 format: 'rgb', 154 opacity: 1, 155 change: function () { 156 var val = jQuery(this).val(); 157 var type = jQuery(this).data('time-type'); 158 jQuery('.ycd-simple-countdown-'+type).css({color: val}); 159 } 160 }); 161}; 162 163YcdSimpleCountdown.prototype.eventListener = function () 164{ 165 var that = this; 166 167 jQuery(window).bind('ycdChangeDate', function () { 168 var val = jQuery('#ycd-date-time-picker').val()+':00'; 169 var selectedTimezone = jQuery('.js-circle-time-zone option:selected').val(); 170 var seconds = that.setCounterTime(val, selectedTimezone); 171 that.seconds = seconds*1000; 172 that.countdown(); 173 }); 174}; 175 176YcdSimpleCountdown.prototype.changeDateType = function() { 177 var types = jQuery('.ycd-date-type'); 178 179 if(!types.length) { 180 return false;
181 } 182 var that = this; 183 var countdowns = this.countdownContainer; 184 types.bind('change', function() { 185 var val = jQuery(this).val(); 186 var timeName = jQuery(this).attr('name'); 187 var options = countdowns.data('options'); 188 options[timeName] = val; 189 190 that.reInitSecondsByOptions(options); 191 }); 192}; 193 194YcdSimpleCountdown.prototype.reInitSecondsByOptions = function (options) 195{ 196 var seconds = this.getSeconds(options); 197 198 this.seconds = seconds*1000; 199 this.countdown(); 200}; 201 202 203YcdSimpleCountdown.prototype.livePreview = function() 204{ 205 var adminElement = jQuery('.ycd-simple-text'); 206 if (!adminElement.length) { 207 return false; 208 } 209 210 this.eventListener(); 211 this.changeText(); 212 this.changeSwitch(); 213 this.changeDateType(); 214 this.changeDate(); 215 this.changeTimeZone(); 216 this.changeDateDuration(); 217 this.changeFontSizes(); 218 this.changeFontFamily(); 219 this.changeColor(); 220 // this.changeBorderColor(); 221 this.changeDoubeleDigits(); 222 this.changeDotes(); 223 this.changeAlign(); 224 this.changeSwithchBorder(); 225}; 226 227YcdSimpleCountdown.prototype.changeText = function() 228{ 229 var texts = jQuery('.ycd-simple-text'); 230 231 texts.bind('input', function () { 232 var unite = jQuery(this).data('time-type'); 233 jQuery('.ycd-simple-countdown-'+unite+'-label').html(jQuery(this).val()); 234 }); 235}; 236 237YcdSimpleCountdown.prototype.changeDoubeleDigits = function() 238{ 239 var texts = jQuery('#enable-double-digits'); 240 var that = this; 241 242 texts.bind('change', function () { 243 var status = jQuery(this).is(':checked'); 244 that.doubeleDigits = status; 245 }); 246}; 247 248YcdSimpleCountdown.prototype.changeAlign = function () { 249 var alignSelect = jQuery('.js-simple-timer-align'); 250 251 if (!alignSelect.length) { 252 return ; 253 } 254 255 alignSelect.bind('change', function() { 256 var selectedValue = jQuery(this).val(); 257 jQuery('.ycd-countdown-wrapper ').css({textAlign: selectedValue}); 258 }) 259} 260 261YcdSimpleCountdown.prototype.changeDotes = function () { 262 var dotesSelect = jQuery('.js-simple-timer-dotes'); 263 264 if (!dotesSelect.length) { 265 return ; 266 } 267 268 dotesSelect.bind('change', function() { 269 var selectedValue = jQuery(this).val(); 270 if (selectedValue == '') { 271 jQuery('.ycd-simple-timer-dots').hide() 272 } 273 else { 274 jQuery('.ycd-simple-timer-dots').show() 275 } 276 jQuery('.ycd-simple-timer-dots').text(selectedValue); 277 }) 278} 279 280YcdSimpleCountdown.prototype.changeSwitch = function() 281{ 282 var status = jQuery('.js-ycd-time-status'); 283 284 if (!status.length) { 285 return false; 286 } 287 288 status.bind('change', function () { 289 var currentStatus = jQuery(this).is(':checked'); 290 var type = jQuery(this).data('time-type'); 291 var wrapper = jQuery('.ycd-simple-current-unite-'+type); 292 if (currentStatus) { 293 jQuery(wrapper).prev().find('.ycd-simple-timer-dots').removeClass('ycd-hide'); 294 wrapper.removeClass('ycd-hide'); 295 } 296 else { 297 if (jQuery(wrapper).nextAll().not(".ycd-hide").length == 0) { 298 jQuery(wrapper).prev().find('.ycd-simple-timer-dots').addClass('ycd-hide'); 299 } 300 wrapper.addClass('ycd-hide'); 301 } 302 }); 303}; 304 305YcdSimpleCountdown.prototype.render = function() 306{ 307 this.addTimeToClock(); 308 this.listeners(); 309 this.countdown(); 310 this.responsive(); 311}; 312 313YcdSimpleCountdown.prototype.listeners = function () { 314 var that = this; 315 jQuery(window).bind("tabInactive", function () { 316 that.isActive = false; 317 }) 318 jQuery(window).bind("tabActive", function () { 319 that.isActive = true; 320 }) 321} 322 323YcdSimpleCountdown.prototype.countdown = function() 324{ 325 var unites = ['years', 'months', 'days', 'hours', 'minutes', 'seconds']; 326 var that = this; 327 var id = that.id; 328 var options = this.options; 329 330 var countdownWrapper = jQuery('.ycd-simple-wrapper-'+this.id); 331 var runCountdown = function() { 332 if (!that.isActive && options['ycd-countdown-stop-inactive']) { 333 return false; 334 } 335 336 // Get today's date and time 337 var now = new Date().getTime(); 338 339 // Find the distance between now and the count down date 340 var distance = that.seconds; 341 342 // If the count down is finished, write some text 343 distance = that.getFilteredDistance(); 344 345 if (distance <= 0 && that.countdownRun) { 346 clearInterval(x); 347 if(YcdArgs.isAdmin || options['ycd-countdown-expire-behavior'] == 'countToUp') { 348 return false;
349 } 350 that.endBehavior(countdownWrapper, that.options); 351 return; 352 } 353 var curDate = new Date(); 354 distance = (new Date()).getTime() + (distance) - curDate.getTime(); 355 356 // Time calculations for days, hours, minutes, and seconds 357 var unitesValues = {}; 358 unitesValues.years = Math.floor(distance / (1000 * 31557600)); 359 if (options['ycd-simple-enable-years']) { 360 distance = distance % (1000 * 31557600); 361 } 362 363 if (options['ycd-simple-enable-months']) { 364 unitesValues.months = Math.floor(distance / (2629800 * 1000)); 365 } 366 367 if (options['ycd-simple-enable-months']) { 368 unitesValues.days = Math.floor(distance % (2629800 * 1000) / (1000 * 86400) ); 369 } 370 else { 371 unitesValues.days = Math.floor(distance / (1000 * 86400) ); 372 } 373 374 unitesValues.hours = Math.floor((distance % (1000 * 86400)) / (1000 * 3600)); // Corrected hours calculation 375 unitesValues.minutes = Math.floor((distance % (1000 * 3600)) / (1000 * 60)); 376 unitesValues.seconds = Math.floor((distance % (1000 * 60)) / 1000); 377 378 for (var i in unites) { 379 var unite = unites[i]; 380 var selector = '.ycd-simple-mode-textUnderCountdown-' + id + ' .ycd-simple-countdown-' + unite + '-time'; 381 var currentUniteValue = unitesValues[unite]; 382 383 if (currentUniteValue < 10 && that.doubleDigits) { 384 currentUniteValue = "0" + currentUniteValue; 385 } 386 387 jQuery(selector).text(currentUniteValue); 388 } 389 390 if (options['ycd-countdown-expire-behavior'] == 'countToUp' && that.seconds <= 0) { 391 that.countdownRun = false; 392 } 393 394 if (!that.countdownRun) { 395 that.seconds += 1000; 396 } else { 397 that.seconds -= 1000; 398 } 399 }; 400 401 clearInterval(this.timerInterval); 402 var x = setInterval(function() { 403 runCountdown(); 404 }, 1000); 405 this.timerInterval = x; 406}; 407 408YcdSimpleCountdown.prototype.getFilteredDistance = function() { 409 if (this.seconds > 0) { 410 return this.seconds; 411 } 412 var options = this.options 413 414 if (options['ycd-countdown-expire-behavior'] == 'countToUp') { 415 this.countdownRun = false; 416 417 if (options['ycd-count-up-from-end-date']) { 418 var date = new Date( 419 moment(options['ycd-date-time-picker']) 420 .tz(options['ycd-time-zone']) 421 .format('MM/DD/YYYY H:m:s')) 422 .getTime(); 423 var now = new Date().getTime(); 424 this.seconds = now - date; 425 return this.seconds; 426 } 427 else { 428 return 0; 429 } 430 } 431 432 return 0; 433}; 434 435YcdSimpleCountdown.prototype.addBorderStyles = function() { 436 if (jQuery('#ycd-simple-enable-unite-border').is(':checked')) { 437 jQuery(".ycd-simple-current-unite-wrapper").css({ 438 width: jQuery('#ycd-simple-unite-width').val(), 439 borderWidth: jQuery('#ycd-simple-unite-border-width').val(), 440 borderRadius: jQuery('#ycd-simple-unite-border-radius').val(), 441 borderStyle: jQuery('.ycd-simple-unite-border-type').val(), 442 borderColor: jQuery("#ycd-simple-unite-border-color").val() 443 }) 444 } 445 else { 446 jQuery(".ycd-simple-current-unite-wrapper").css({ 447 border: "none" 448 }); 449 } 450 var uniteMurginTop = jQuery("#ycd-simple-unite-margin-top").val(); 451 var uniteMurginRight = jQuery("#ycd-simple-unite-margin-right").val(); 452 var uniteMurginBottom = jQuery("#ycd-simple-unite-margin-bottom").val(); 453 var uniteMurginLeft = jQuery("#ycd-simple-unite-margin-left").val(); 454 455 var unitePaddingTop = jQuery("#ycd-simple-unite-padding-top").val(); 456 var unitePaddingRight = jQuery("#ycd-simple-unite-padding-right").val(); 457 var unitePaddingBottom = jQuery("#ycd-simple-unite-padding-bottom").val(); 458 var unitePaddingLeft = jQuery("#ycd-simple-unite-padding-left").val(); 459 460 jQuery(".ycd-simple-current-unite-wrapper").css({ 461 paddingTop: unitePaddingTop, 462 paddingRight: unitePaddingRight, 463 paddingBottom: unitePaddingBottom, 464 paddingLeft: unitePaddingLeft, 465 466 marginTop: uniteMurginTop, 467 marginRight: uniteMurginRight, 468 marginBottom: uniteMurginBottom, 469 marginLeft: uniteMurginLeft, 470 }) 471 472 var numbersMurginTop = jQuery("#ycd-simple-numbers-margin-top").val(); 473 var numbersMurginRight = jQuery("#ycd-simple-numbers-margin-right").val(); 474 var numbersMurginBottom = jQuery("#ycd-simple-numbers-margin-bottom").val(); 475 var numbersMurginLeft = jQuery("#ycd-simple-numbers-margin-left").val(); 476 jQuery(".ycd-simple-countdown-number").css({ 477 marginTop: numbersMurginTop, 478 marginRight: numbersMurginRight, 479 marginBottom: numbersMurginBottom, 480 marginLeft: numbersMurginLeft, 481 }) 482 var textMurginTop = jQuery("#ycd-simple-text-margin-top").val(); 483 var textMurginRight = jQuery("#ycd-simple-text-margin-right").val(); 484 var textMurginBottom = jQuery("#ycd-simple-text-margin-bottom").val(); 485 var textMurginLeft = jQuery("#ycd-simple-text-margin-left").val(); 486 487 jQuery(".ycd-simple-countdown-label").css({ 488 marginTop: textMurginTop, 489 marginRight: textMurginRight, 490 marginBottom: textMurginBottom, 491 marginLeft: textMurginLeft, 492 }) 493} 494 495YcdSimpleCountdown.prototype.changeSwithchBorder = function() { 496 var that = this; 497 jQuery('#ycd-simple-enable-unite-border, #ycd-simple-unite-width, #ycd-simple-unite-border-width, #ycd-simple-unite-border-radius,.ycd-simple-unite-border-type').change(function() { 498 that.addBorderStyles(); 499 }) 500 jQuery('#ycd-simple-unite-border-color').minicolors({ 501 format: 'rgb', 502 opacity: 1, 503 change: function () { 504 that.addBorderStyles(); 505 } 506 }); 507 jQuery('.ycd-numbers-margin').bind('change', function() { 508 that.addBorderStyles(); 509 }) 510 jQuery('.ycd-text-margin').bind('change', function() { 511 that.addBorderStyles(); 512 }) 513 jQuery('.ycd-unite-margin').bind('change', function() { 514 that.addBorderStyles(); 515 }) 516 jQuery('.ycd-unite-padding').bind('change', function() { 517 that.addBorderStyles(); 518 }) 519} 520 521YcdSimpleCountdown.prototype.addTimeToClock = function() 522{ 523 var options = this.options;
524 var seconds = this.getSeconds(options); 525 this.seconds = seconds*1000; 526 this.id = options['id']; 527 this.options['allSeconds'] = seconds; 528 this.savedOptions = this.options; 529}; 530 531jQuery(document).ready(function() { 532 YcdSimpleCountdown.run(); 533});
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.