1/** 2 * SITE.Helper 3 * 4 * @author CLHOM 5 * @website http://www.kiiiick.com 6 * @copyright Copyright (C) KiiiiCK Co., All Rights Reserved. 7 */ 8 9"use strict"; 10 11var SITE = SITE || {}; 12 13;(function(SITE) { 14 15 /** 16 * SITE.Helper 17 * @author CLHOM 18 **/ 19 20 SITE.Helper = function() { 21 22 //-- set construct in object --// 23 function __construct() 24 { 25 26 } 27 28 //-- set public func --// 29 this.alert = function() { 30 $('#modal-msg').modal({show: true}).find('.modal-body').html(msg); 31 }; 32 33 this.is_mobile = function() { 34 if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) return true; 35 return false; 36 }; 37 38 this.scroll_to_top = function() { 39 $('html, body').animate({scrollTop: 0}); 40 }; 41 42 this.money_format = function(_n, _c, _p) { 43 var c = _c == undefined ? SETTINGS.bcscale_set : _c, 44 p = _p == undefined ? '' : _p, 45 n = Number(_n), 46 r = n.toFixed(c).replace(/(\d)(?=(\d{3})+(\.|$))/g, '$1,'); 47 48 return p + r; 49 }; 50 51 this.money_to_number = function(_n) { 52 if (typeof _n != 'string') return _n; 53 return Number(_n.replace(/[^0-9.-]+/g, '')); 54 }; 55 56 this.local_time = function(datetime, format) { 57 return moment(datetime + ' +0000', 'YYYY-MM-DD HH:mm:ss Z').format(format != undefined ? format : 'YYYY-MM-DD HH:mm:ss'); 58 }; 59 60 this.serializeArrayToObject = function(arr) { 61 var _arr = []; 62 for (var k in arr) { 63 var v = arr[k]; 64 _arr[v['name']] = v['value']; 65 } 66 67 return _arr; 68 }; 69 70 this.progress = { 71 open: function(msg) { 72 var $modal = $('#modal-progress').modal({show: true, backdrop: 'static', keyboard: false}); 73 $modal.find('.progress-bar').addClass('active'); 74 if (msg != undefined) $modal.find('.msg').html(msg); 75 }, 76 close: function() { 77 var $modal = $('#modal-progress').modal('hide'); 78 $modal.find('.progress-bar').removeClass('active'); 79 $modal.find('.msg').html(''); 80 } 81 }; 82 83 this.getUrlParameter = function(sParam) { 84 var sPageURL = decodeURIComponent(window.location.search.substring(1)), 85 sURLVariables = sPageURL.split('&'), 86 sParameterName, 87 i; 88 89 for (i = 0; i < sURLVariables.length; i++) { 90 sParameterName = sURLVariables[i].split('='); 91 92 if (sParameterName[0] === sParam) { 93 return sParameterName[1] === undefined ? true : sParameterName[1]; 94 } 95 } 96 }; 97 98 this.xhrErrorHandle = function(jqXHR, exception) { 99 var msg = ''; 100 if (jqXHR.status === 0) { 101 msg = 'Not connect.\n Verify Network.'; 102 } else if (jqXHR.status == 404) { 103 msg = 'Requested page not found. [404]'; 104 } else if (jqXHR.status == 500) { 105 msg = 'Internal Server Error [500].'; 106 } else if (exception === 'parsererror') { 107 msg = 'Requested JSON parse failed.'; 108 } else if (exception === 'timeout') { 109 msg = 'Time out error.'; 110 } else if (exception === 'abort') { 111 msg = 'Ajax request aborted.'; 112 } else { 113 msg = 'Uncaught Error.\n' + jqXHR.responseText; 114 } 115 this.progress.close(); 116 setTimeout(function() { 117 this.alert(msg + ' Please try to refresh your browser, thanks!'); 118 }, 800); 119 }; 120 121 122 var _this = this; 123 124 __construct(); 125 }; 126 127})(SITE); 128/* 129 * SITE.Message 130 * 131 * @author CLHOM 132 * @website http://www.kiiiick.com 133 * @include jquery.confirm-2.3.1 plugin 134 * @copyright Copyright (C) KICKcreative Co., All Rights Reserved. 135 * 136 */ 137 138"use strict"; 139 140var SITE = SITE || {}; 141 142;(function(SITE) { 143 144 /** 145 * SITE.Message 146 * @param 147 * 148 **/ 149 150 SITE.Message = function(configs) { 151 //-- set public value --// 152 153 //-- set private value --// 154 var _configs = { 155 // alert or dialog 156 type: 'dialog', 157 dialogConfig: {}, 158 langCode: $.cookie('lang_code') ? $.cookie('lang_code') : 'en', 159 langs: { 160 'en': { 161 'ok': 'OK', 162 'close': 'CLOSE', 163 'yes': 'YES', 164 'no': 'NO' 165 }, 166 'tw': { 167 'ok': '確èª', 168 'close': 'éé', 169 'yes': 'æ¯', 170 'no': 'å¦' 171 } 172 }, 173 setLang: function(str) { 174 if (this.langs[this.langCode] == undefined || this.langs[this.langCode][str] == undefined) 175 { 176 if (this.langs['en'] != undefined && this.langs['en'][str] != undefined) return this.langs['en'][str]; 177 178 return str.toUpperCase(); 179 } 180 181 return this.langs[this.langCode][str]; 182 } 183 }; 184 185 _configs = $.extend(_configs, configs); 186 187 var $box = null; 188 189 var _helper = { 190 isset: function(v) { 191 return v != undefined; 192 } 193 }; 194 195 //-- set construct in object --// 196 function __construct() 197 { 198 $(function() { 199 if (has_message() === true) { 200 var msg = '', 201 type = $box.attr('class'); 202 203 switch (_configs.type) { 204 case 'alert': 205 msg = $box.text(); 206 break; 207 208 case 'dialog': 209 msg = $box.html(); 210 break; 211 } 212 213 switch (type) { 214 case 'notice-box': 215 case 'success-box': 216 case 'error-box': 217 default: 218 _this.alert(msg, _configs.setLang('ok')); 219 break; 220 } 221 } 222 }); 223 } 224 225 //-- set private function --// 226 function has_message() 227 { 228 $box = $('.success-box, .notice-box, .error-box'); 229 return $box.length > 0 ? true : false;
230 } 231 232 //-- set public function --// 233 this.alert = function(msg, btnText, configs) 234 { 235 switch (_configs.type) { 236 case 'alert': 237 alert(msg); 238 239 break; 240 241 case 'dialog': 242 if (_helper.isset(configs)) _configs.dialogConfig = $.extend(_configs.dialogConfig, configs); 243 244 var buildModal = function() { 245 $.confirm($.extend({ 246 title: '', 247 text: msg, 248 confirmButton: btnText, 249 confirmButtonClass:'', 250 cancelButton: '', 251 cancelButtonClass: 'd-none' 252 }, _configs.dialogConfig)); 253 }; 254 255 if ($('.confirmation-modal').length > 0) 256 { 257 $('.confirmation-modal').on('hidden.bs.modal', function() { 258 buildModal(); 259 }); 260 } 261 else 262 { 263 buildModal(); 264 } 265 266 break; 267 } 268 }; 269 270 this.confirm = function(msg, callback, configs) 271 { 272 switch (_configs.type) { 273 case 'alert': 274 if (confirm(msg)) { 275 if (_helper.isset(callback.ok)) callback.ok(); 276 } else { 277 if (_helper.isset(callback.cancel)) callback.cancel(); 278 } 279 280 break; 281 282 case 'dialog': 283 if (_helper.isset(callback.ok)) _configs.dialogConfig = $.extend(_configs.dialogConfig, {confirm: callback.ok}); 284 if (_helper.isset(callback.cancel)) _configs.dialogConfig = $.extend(_configs.dialogConfig, {cancel: callback.cancel}); 285 if (_helper.isset(configs)) _configs.dialogConfig = $.extend(_configs.dialogConfig, configs); 286 287 var buildModal = function() { 288 $.confirm($.extend({ 289 title: '', 290 text: msg, 291 confirmButton: _configs.setLang('yes'), 292 confirmButtonClass:'', 293 cancelButton: _configs.setLang('no'), 294 cancelButtonClass:'', 295 }, _configs.dialogConfig)); 296 }; 297 298 if ($('.confirmation-modal').length > 0) 299 { 300 $('.confirmation-modal').on('hidden.bs.modal', function() { 301 buildModal(); 302 }); 303 } 304 else 305 { 306 buildModal(); 307 } 308 309 break; 310 } 311 }; 312 313 314 var _this = this; 315 316 __construct(); 317 }; 318 319})(SITE); 320/** 321 * SITE.Readmore 322 * 323 * @author CLHOM 324 * @website http://www.kiiiick.com 325 * @copyright Copyright (C) KiiiiCK Co., All Rights Reserved. 326 */ 327 328"use strict"; 329 330var SITE = SITE || {}; 331 332;(function(SITE) { 333 334 SITE.Readmore = function(configs) { 335 336 //-- set public value --// 337 this.is_last = false; 338 339 //-- set private value --// 340 var _configs = { 341 // selectors 342 ajax_url: '', 343 con: '', 344 handle: '.js-load-more', 345 handle_txt: '.js-txt-con', 346 347 // css class 348 goods_hide_class: '-hide', 349 350 // static value 351 limit: 6, 352 page: 1, 353 infinite_scroll: true, 354 355 // message 356 loading_page_msg: 'Loading...', 357 last_page_msg: 'This is last page.' 358 }; 359 360 _configs = $.extend(_configs, configs); 361 362 var _helper = { 363 alert: function(msg) { 364 if (SITE.Message && _msg != undefined) { 365 _msg.alert(msg, this.$t('message.button_close')); 366 } else { 367 alert(msg); 368 } 369 }, 370 371 getScrollEnd: function($scrollTarget, $stickyTo, offsetTop) { 372 return Math.ceil( Math.abs( ( $stickyTo.height() + offsetTop ) - $scrollTarget.height() ) ); 373 } 374 }; 375 376 var $win = $(window), 377 $con = $(_configs.con), 378 $handle = $(_configs.handle), 379 $handle_txt = $(_configs.handle_txt), 380 default_txt = $handle_txt.text(), 381 page = Number(_configs.page == '' ? 1 : _configs.page) + 1, 382 f_data = {}, 383 is_scrolling = false, 384 base_url = window.location.href.replace(/(\/\d?\?)/, ''), 385 base_uri = base_url.replace(window.location.protocol+'//'+document.domain, ''); 386 387 //-- set construct --// 388 function __construct() { 389 $handle.bind('click.readmore', _click_event); 390 391 if (_configs.infinite_scroll) { 392 $win.bind('scroll.readmore', _scroll_event); 393 } 394 } 395 396 //-- set private function --// 397 function _get_n_data() { 398 if (_this.is_last) return; 399 400 _this.prepare_data(); 401 402 $handle_txt.text(_configs.loading_page_msg); 403 404 $.get(_configs.ajax_url, f_data).done(function(json){ 405 if (json.status == 'success') { 406 var $item = $(json.item_html); 407 408 $item.addClass(_configs.goods_hide_class); 409 410 if (SITE.Readmore.prototype.append_callback == undefined) { 411 $con.append($item); 412 } else { 413 SITE.Readmore.prototype.append_callback($item); 414 } 415 416 setTimeout(function() { 417 $item.removeClass(_configs.goods_hide_class); 418 }, 10); 419 420 // save current page to url 421 var new_url = base_url.replace(/([\?|\&]p=)[\d]/, function(match, a) {return a + f_data.page;}); 422 if (new_url == base_url) new_url += base_url.lastIndexOf('?') > -1 ? '&p=' + f_data.page : '?p=' + f_data.page; 423 window.history.pushState(null, null, new_url); 424 425 page++; 426 427 if (json.total > f_data.limit * f_data.page) { 428 $handle_txt.text(default_txt); 429 } else { 430 _this.last(); 431 } 432 } else if (json.status == 'error') { 433 if (json.error == 'Product is empty!') { 434 _this.last(); 435 return; 436 } 437 438 _helper.alert(json.error); 439 } else { 440 _helper.alert('Requested JSON parse failed.'); 441 } 442 }).error(function(jqXHR, exception) { 443 var msg = ''; 444 if (jqXHR.status === 0) { 445 msg = 'Not connect.\n Verify Network.'; 446 } else if (jqXHR.status == 404) { 447 msg = 'Requested page not found. [404]'; 448 } else if (jqXHR.status == 500) { 449 // msg = 'Internal Server Error [500].'; 450 msg = 'Your connection with the server was idle for too long and timed out. Please refresh this page and try again.'; 451 } else if (exception === 'parsererror') { 452 msg = 'Requested JSON parse failed.'; 453 } else if (exception === 'timeout') { 454 msg = 'Time out error.'; 455 } else if (exception === 'abort') { 456 msg = 'Ajax request aborted.'; 457 } else { 458 msg = 'Uncaught Error.\n' + jqXHR.responseText; 459 } 460 _helper.alert(msg); 461 }); 462 } 463 464 function _click_event(e) { 465 e.preventDefault(); 466 _get_n_data(); 467 } 468 469 function _scroll_event() { 470 if (is_scrolling) return; 471 472 var scroll = $win.scrollTop(), 473 scrollDist = _helper.getScrollEnd($win, $con, $con.offset().top); 474 475 if (scroll > scrollDist && !is_scrolling) { 476 _get_n_data(); 477 is_scrolling = true; 478 479 setTimeout(function() { 480 is_scrolling = false;
481 }, 1000); 482 } 483 } 484 485 //-- set public function --// 486 this.renew = function() { 487 // clear page url 488 var new_url = base_url.replace(/(\/\d?\?)/, ''); 489 window.history.pushState(null, null, new_url); 490 page = Number(_configs.page == '' ? 1 : _configs.page) + 1; 491 is_scrolling = false; 492 $handle.removeClass(_configs.goods_hide_class); 493 $handle_txt.text(default_txt); 494 $win.bind('scroll.readmore', _scroll_event); 495 _this.is_last = false; 496 }; 497 498 this.last = function() { 499 $handle.addClass(_configs.goods_hide_class); 500 $handle_txt.text(_configs.last_page_msg); 501 $win.unbind('scroll.readmore', _scroll_event); 502 _this.is_last = true; 503 }; 504 505 this.prepare_data = function() { 506 f_data = { 507 limit: _configs.limit, 508 page: page 509 }; 510 511 if (SITE.Readmore.prototype.merge_data != undefined) { 512 f_data = SITE.Readmore.prototype.merge_data(f_data); 513 } 514 }; 515 516 var _this = this; 517 518 __construct(); 519 520 }; 521 522})(SITE); 523/** 524 * SITE.Form 525 * 526 * @author CLHOM 527 * @website http://www.kiiiick.com 528 * @copyright Copyright (C) KiiiiCK Co., All Rights Reserved. 529 */ 530 531"use strict"; 532 533var SITE = SITE || {}; 534 535;(function(SITE) { 536 537 /** 538 * SITE.Form 539 * @param _form_selector form element selector 540 * 541 **/ 542 543 SITE.Form = function(_con_seletor, _configs) { 544 //-- set private value --// 545 this.$con = null; 546 547 //-- set construct in object --// 548 function __construct() 549 { 550 $(function() { 551 if (_con_seletor != undefined) _this.$con = $(_con_seletor); 552 _this.set_form_validation(_this.$con ? _this.$con : null, _configs); 553 _this.set_country_select(); 554 _this.set_confirm_button(); 555 }); 556 } 557 558 //-- set public func --// 559 this.set_form_validation = function(_valid_selector, _extend_configs) { 560 var _valid_selector = _valid_selector || '.js-form-validation'; 561 var _extend_configs = _extend_configs || { highlight: function(element, errorClass, validClass) { 562 $(element).parents('.js-validGroup').addClass(errorClass).removeClass(validClass); 563 }, unhighlight: function(element, errorClass, validClass) { 564 $(element).parents('.-error').removeClass(errorClass).addClass(validClass); 565 } }; 566 567 $(_valid_selector).validate($.extend({ 568 errorClass: '-error' 569 }, _extend_configs)); 570 }; 571 572 this.set_country_select = function(_country_selector) { 573 var _country_selector = _country_selector || '.js-country-select'; 574 var countryData = $.fn.intlTelInput.getCountryData(); 575 576 $(_country_selector).each(function() { 577 var $this = $(this), 578 data = $this.data(), 579 selected = data.selected || null, 580 supported = data.supported || null, 581 format = data.format || 'name:name'; 582 583 if ($this.hasClass('-country-select-created')) $this.html($this.find('option').eq(0)); 584 585 supported = supported ? supported.split(',') : null; 586 587 for (var k in countryData) { 588 var v = countryData[k]; 589 if (supported && $.inArray(v.iso2, supported) == -1) continue; 590 var $option = $('<option>'), 591 name = v.name, 592 code = v.iso2; 593 594 if (selected != null) { 595 switch (format) { 596 case 'code:name': 597 $option.val(code); 598 $option.text(name); 599 if (selected && selected == code) $option.prop('selected', true); 600 break; 601 602 case 'name:name': 603 default: 604 $option.val(name); 605 $option.text(name); 606 if (selected && selected == name) $option.prop('selected', true); 607 break; 608 } 609 } 610 611 $this.append($option); 612 } 613 614 $this.addClass('-country-select-created'); 615 }); 616 }; 617 618 this.set_confirm_button = function() { 619 // Confirmation 620 $('a.confirm').on('click', function(e){ 621 e.preventDefault(); 622 623 var href = $(this).attr('href'), 624 removemsg = $(this).attr('title'); 625 626 if (confirm(removemsg || pyro.lang.dialog_message)) 627 { 628 $(this).trigger('click-confirmed'); 629 630 if ($.data(this, 'stop-click')){ 631 $.data(this, 'stop-click', false); 632 return; 633 } 634 window.location.replace(href); 635 } 636 }); 637 638 //use a confirm dialog on "delete many" buttons 639 $(':submit.confirm').on('click', function(e, confirmation){ 640 641 if (confirmation) 642 { 643 return true; 644 } 645 646 var removemsg = $(this).attr('title'); 647 648 if (confirm(removemsg || pyro.lang.dialog_message)) 649 { 650 $(this).trigger('click-confirmed'); 651 652 if ($(this).data('stop-click')){ 653 $(this).data('stop-click', false); 654 return; 655 } 656 657 return true; 658 } else { 659 return false;
660 } 661 }); 662 }; 663 664 665 var _this = this; 666 667 __construct(); 668 }; 669 670})(SITE); 671/** 672 * SITE.Information 673 * 674 * @author CLHOM 675 * @website http://www.kiiiick.com 676 * @copyright Copyright (C) KiiiiCK Co., All Rights Reserved. 677 */ 678 679"use strict"; 680 681var SITE = SITE || {}; 682 683;(function(SITE) { 684 685 /** 686 * SITE.Information 687 **/ 688 689 SITE.Information = function(_con_seletor) { 690 function __construct() 691 { 692 _global.headroomNav(); 693 694 // Global message js code. 695 if ($('#js-global-msg').length > 0) { 696 var has_global_msg = true; 697 var set_global_msg = function() { 698 // var global_msg_h = $('#js-global-msg').height() - 1, 699 700 var global_msg_h = $('#js-global-msg').height() - 1, 701 header_h = $('#js-header').height(), 702 filter_h = $('#js-filter').height() / 2; 703 704 if (!has_global_msg) { 705 var headerHeight = $('#js-header').height(); 706 $('#js-headroomNav').height(headerHeight + 1); 707 } 708 }; 709 710 $('#js-global-msg-close').bind('click', function(e) { 711 $('#js-global-msg').removeClass('is-active'); 712 has_global_msg = false; 713 set_global_msg(); 714 }); 715 716 $(window).bind('resize.global-msg', function() { 717 setTimeout(set_global_msg, 300); 718 }); 719 720 if ($('#js-global-msg img').length > 0) { 721 $('#js-global-msg img').imgpreload(function() { 722 set_global_msg(); 723 }); 724 } else { 725 set_global_msg(); 726 } 727 } 728 } 729 730 731 var _this = this; 732 733 __construct(); 734 }; 735 736})(SITE);
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.