PageSourceSearch

https://smi.hk/catalog/view/javascript/common.js?v=1.0.1

js smi.hk collected 2026-10-02 00:36:29 UTC 30,999 bytes, 948 lines download raw bytes

1function getURLVar(key) {
2  var value = [];
3
4  var query = String(document.location).split('?');
5
6  if (query[1]) {
7    var part = query[1].split('&');
8
9    for (i = 0; i < part.length; i++) {
10      var data = part[i].split('=');
11
12      if (data[0] && data[1]) {
13        value[data[0]] = data[1];
14      }
15    }
16
17    if (value[key]) {
18      return value[key];
19    } else {
20      return '';
21    }
22  }
23}
24
25var show_load = function() {
26  layer.load(2, {shade: [0.1,'#fff'] });
27}
28
29var hide_load = function() {
30  layer.closeAll('loading');
31}
32
33var cart_ajax_load_html = function() {
34  $('.cart-wrapper').load('index.php?route=common/cart/info');
35}
36
37// ajax 默认全局设置
38$.ajaxSetup({
39  cache: false,
40  beforeSend: function() { show_load(); },
41  complete: function() { hide_load(); },
42  error: function(xhr, ajaxOptions, thrownError) {
43    console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
44  }
45});
46
47$(document).ready(function() {
48
49  var wow = new WOW({
50  });
51  wow.init();
52
53  $('.box-menu ul li').hover(function() {
54    $(this).addClass('selected');
55  }, function() {
56    $(this).removeClass('selected');
57  });
58
59
60  $('.scroll-top').on('click', function(event) {
61    event.preventDefault();
62    $('html, body').animate({ scrollTop: 0} , 'fast');
63  });
64
65  $(document).on('click', '.mobile-nav-icon, .mobile-search', function(event) {
66    $('.side-menu').fadeIn(0).children('.side-inner').addClass('active');
67  });
68
69  $(document).on('click', '.side-menu', function(e) {
70    if ( $(e.target).closest('.side-inner').length === 0 ) {
71      $('.side-menu .side-inner').removeClass('active');
72      setTimeout("$('.side-menu').fadeOut(50)", 220);
73    }
74  });
75
76  $('.side-menu li .toggle-button').click(function(event) {
77    $(this).parent().siblings().removeClass('open active').children('.dropdown-menu').slideUp();
78    $(this).parent().toggleClass('active').find('.dropdown-menu').slideToggle("fast");
79  });
80
81  // Highlight any found errors
82  $('.text-danger').each(function() {
83    var element = $(this).parent().parent();
84
85    if (element.hasClass('form-group')) {
86      element.addClass('has-error');
87    }
88  });
89
90  // Currency
91  $('#form-currency .currency-select').on('click', function(e) {
92    e.preventDefault();
93
94    $('#form-currency input[name=\'code\']').val($(this).attr('name'));
95
96    $('#form-currency').submit();
97  });
98
99  // Language
100  $('#form-language .language-select').on('click', function(e) {
101    e.preventDefault();
102
103    $('#form-language input[name=\'code\']').val($(this).attr('name'));
104
105    $('#form-language').submit();
106  });
107
108  /* Search */
109  $('.button-top-search').on('click', function() {
110    var value = $(this).parent().siblings('input').val();
111
112    var url = $(this).data('action');
113    if (value) {
114      url +=  encodeURIComponent(value);
115    }
116
117    location = url;
118  });
119
120  $('.input-top-search').on('keydown', function(e) {
121    if (e.keyCode == 13) {
122      $(this).siblings('a').children('button').trigger('click');
123    }
124  });
125
126  // Menu
127  $('#menu .dropdown-menu').each(function() {
128    var menu = $('#menu').offset();
129    var dropdown = $(this).parent().offset();
130
131    var i = (dropdown.left + $(this).outerWidth()) - (menu.left + $('#menu').outerWidth());
132
133    if (i > 0) {
134      $(this).css('margin-left', '-' + (i + 10) + 'px');
135    }
136  });
137
138  // Checkout
139  $(document).on('keydown', '#collapse-checkout-option input[name=\'email\'], #collapse-checkout-option input[name=\'password\']', function(e) {
140    if (e.keyCode == 13) {
141      $('#collapse-checkout-option #button-login').trigger('click');
142    }
143  });
144
145  // tooltips on hover
146  $('[data-toggle=\'tooltip\']').tooltip({container: 'body'});
147
148  // Makes tooltips work on ajax generated content
149  $(document).ajaxStop(function() {
150    $('[data-toggle=\'tooltip\']').tooltip({container: 'body'});
151  });
152
153  $(document).on('click', '#review .pagination a', function(e) {
154    e.preventDefault();
155    $('#review').load(this.href);
156  });
157
158  $('.more-review').on('click', function(e) {
159    $("html, body").stop().animate({ scrollTop: $('.nav-tabs').offset().top }, 400);
160    $('a[href=\'#tab-review\']').trigger('click');
161  });
162
163  slidebarInit();
164
165  $('.min-cart-backdrop, .min-cart-close').on('click', function () {
166    $('#cart').removeClass('active');
167  });
168
169  $('.product-layout .quantity-input-wrapper a').click(function(e) {
170    e.preventDefault();
171    var element = $(this).siblings('input');
172    var product_id = $(element).data('product-id');
173    var p_element = $('.list-product-' + product_id).closest('.inner');
174    if( $(this).hasClass('quantity-up')) {
175      var list_qty = parseInt($(element).val()) + 1;
176      $(element).val( list_qty );
177      cart.list_add(product_id, list_qty, 1);
178    } else {
179      var list_qty = parseInt($(element).val()) - 1;
180      var _list_qty = list_qty < 1?1:list_qty;
181      $(element).val( _list_qty  );
182      cart.list_add(product_id, list_qty, 1);
183      if( list_qty <= 0 ) {
184        $(p_element).find('.product-cart-action').addClass('d-none');
185        $(p_element).find('.btn-cart').removeClass('d-none');
186      }
187    }
188  });
189
190  $('.header-search-icon').on('click', function () {
191    $('.header-search-wrapper').fadeIn(200);
192  });
193
194  $('.wechat-a').on('click', function (e) {
195    e.stopPropagation();
196    if ( $(this).hasClass('active') ) {
197      $(this).removeClass('active');
198    }else {
199      $(this).addClass('active');
200    }
201  });
202
203
204});
205
206// Cart add remove functions
207var cart = {
208  'add': function(product_id, quantity) {
209    $.ajax({
210      url: 'index.php?route=checkout/cart/add',
211      type: 'post',
212      data: 'product_id=' + product_id + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1),
213      dataType: 'json',
214      success: function(json) {
215        $('.alert-dismissible, .text-danger').remove();
216
217        if (json['redirect']) {
218          // location = json['redirect'];
219          quickview.view(product_id);
220        }
221
222        if (json['success']) {
223          // Need to set timeout otherwise it wont update the total
224          setTimeout(function () {
225            $('#cart > button #cart-total').html(json['total']);
226            $('#cart-total-quantity').html(json['total_quantity']);
227          }, 100);
228
229          $('#cart').addClass('active');
230
231          $('#box-min-cart').children('ul').load('index.php?route=common/cart/info ul li');
232/*
233          if( $('.list-product-' + product_id).length > 0 ) {
234            var p_element = $('.list-product-' + product_id).closest('.inner');
235            $(p_element).find('.product-cart-action').removeClass('d-none');
236            $(p_element).find('.btn-cart').addClass('d-none');
237          }*/
238        }
239      }
240    });
241  },
242  'remove': function(key) {
243    $.ajax({
244      url: 'index.php?route=checkout/cart/remove',
245      type: 'post',
246      data: 'key=' + key,
247      dataType: 'json',
248      success: function(json) {
249        // Need to set timeout otherwise it wont update the total
250        setTimeout(function () {
251          $('#cart > button #cart-total').html(json['total']);
252          $('#cart-total-quantity').html(json['total_quantity']);
253        }, 100);
254
255        if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
256          location = 'index.php?route=checkout/cart';
257        } else {
258          $('#cart').addClass('active');
259
260          $('#box-min-cart').children('ul').load('index.php?route=common/cart/info ul li');
261        }
262      }
263    });
264  },
265  'list_add': function(product_id, quantity, uncheck_other) {
266    var element = $('.list-product-' + product_id).closest('.inner');
267    $.ajax({
268      url: 'index.php?route=checkout/cart/add',
269      type: 'post',
270      data: 'product_id=' + product_id + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1) + (typeof(uncheck_other) != 'undefined' ? '&uncheck_other=1':'' ),
271      dataType: 'json',
272      beforeSend: function() {
273        $(element).find('.list-add-cart-loading').fadeIn(0);
274      },
275      complete: function() {
276        $(element).find('.list-add-cart-loading').fadeOut(0);
277      },
278      success: function(json) {
279        $('.alert-dismissible, .text-danger').remove();
280
281        if (json['redirect']) {
282          // location = json['redirect'];
283          quickview.view(product_id);
284        }
285
286        if (json['success']) {
287          // Need to set timeout otherwise it wont update the total
288          setTimeout(function () {
289            $('#cart > button #cart-total').html(json['total']);
290            $('#cart-total-quantity').html(json['total_quantity']);
291          }, 100);
292
293          $('#cart').addClass('active');
294
295          $('#box-min-cart').children('ul').load('index.php?route=common/cart/info ul li', function () {
296            hide_load();
297          });
298        }
299      }
300    });
301  },
302}
303
304var voucher = {
305  'remove': function(key) {
306    $.ajax({
307      url: 'index.php?route=checkout/cart/remove',
308      type: 'post',
309      data: 'key=' + key,
310      dataType: 'json',
311      success: function(json) {
312        // Need to set timeout otherwise it wont update the total
313        setTimeout(function () {
314          $('#cart > button #cart-total').html(json['total']);
315        }, 100);
316
317        if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
318          location = 'index.php?route=checkout/cart';
319        } else {
320          $('#cart > ul').load('index.php?route=common/cart/info ul li');
321        }
322      }
323    });
324  }
325}
326
327var wishlist = {
328  'add': function(product_id) {
329    $.ajax({
330      url: 'index.php?route=account/wishlist/add',
331      type: 'post',
332      data: 'product_id=' + product_id,
333      dataType: 'json',
334      success: function(json) {
335        $('.alert-dismissible').remove();
336
337        if (json['redirect']) {
338          location = json['redirect'];
339        }
340
341        if (json['success']) {
342          showAlert('wishlist', json['success']);
343        }
344
345        $('#wishlist-total span').html(json['total']);
346        $('#wishlist-total').attr('title', json['total']);
347      }
348    });
349  }
350}
351
352var compare = {
353  'add': function(product_id) {
354    $.ajax({
355      url: 'index.php?route=product/compare/add',
356      type: 'post',
357      data: 'product_id=' + product_id,
358      dataType: 'json',
359      success: function(json) {
360        $('.alert-dismissible').remove();
361
362        if (json['success']) {
363          showAlert('compare', json['success']);
364
365          $('#compare-total').html(json['total']);
366        }
367      }
368    });
369  }
370}
371
372/* Agree to Terms */
373$(document).on('click', '.agree', function(e) {
374  e.preventDefault();
375
376  var $element = $(this);
377
378  layer.open({
379    area: ['960px', '640px'],
380    type: 2,
381    title: $element.text(),
382    content: [$element.attr('href')],
383  });
384});
385
386// Autocomplete */
387(function($) {
388  $.fn.autocomplete = function(option) {
389    return this.each(function() {
390      this.timer = null;
391      this.items = new Array();
392
393      $.extend(this, option);
394
395      $(this).attr('autocomplete', 'off');
396
397      // Focus
398      $(this).on('focus', function() {
399        this.request();
400      });
401
402      // Blur
403      $(this).on('blur', function() {
404        setTimeout(function(object) {
405          object.hide();
406        }, 200, this);
407      });
408
409      // Keydown
410      $(this).on('keydown', function(event) {
411        switch(event.keyCode) {
412          case 27: // escape
413            this.hide();
414            break;
415          default:
416            this.request();
417            break;
418        }
419      });
420
421      // Click
422      this.click = function(event) {
423        event.preventDefault();
424
425        value = $(event.target).parent().attr('data-value');
426
427        if (value && this.items[value]) {
428          this.select(this.items[value]);
429        }
430      }
431
432      // Show
433      this.show = function() {
434        var pos = $(this).position();
435
436        $(this).siblings('ul.dropdown-menu').css({
437          top: pos.top + $(this).outerHeight(),
438          left: pos.left
439        });
440
441        $(this).siblings('ul.dropdown-menu').show();
442      }
443
444      // Hide
445      this.hide = function() {
446        $(this).siblings('ul.dropdown-menu').hide();
447      }
448
449      // Request
450      this.request = function() {
451        clearTimeout(this.timer);
452
453        this.timer = setTimeout(function(object) {
454          object.source($(object).val(), $.proxy(object.response, object));
455        }, 200, this);
456      }
457
458      // Response
459      this.response = function(json) {
460        html = '';
461
462        if (json.length) {
463          for (i = 0; i < json.length; i++) {
464            this.items[json[i]['value']] = json[i];
465          }
466
467          for (i = 0; i < json.length; i++) {
468            if (!json[i]['category']) {
469              html += '<li data-value="' + json[i]['value'] + '"><a href="#">
469' + json[i]['label'] + '</a></li>';
470            }
471          }
472
473          // Get all the ones with a categories
474          var category = new Array();
475
476          for (i = 0; i < json.length; i++) {
477            if (json[i]['category']) {
478              if (!category[json[i]['category']]) {
479                category[json[i]['category']] = new Array();
480                category[json[i]['category']]['name'] = json[i]['category'];
481                category[json[i]['category']]['item'] = new Array();
482              }
483
484              category[json[i]['category']]['item'].push(json[i]);
485            }
486          }
487
488          for (i in category) {
489            html += '<li class="dropdown-header">' + category[i]['name'] + '</li>';
490
491            for (j = 0; j < category[i]['item'].length; j++) {
492              html += '<li data-value="' + category[i]['item'][j]['value'] + '"><a href="#">&nbsp;&nbsp;&nbsp;' + category[i]['item'][j]['label'] + '</a></li>';
493            }
494          }
495        }
496
497        if (html) {
498          this.show();
499        } else {
500          this.hide();
501        }
502
503        $(this).siblings('ul.dropdown-menu').html(html);
504      }
505
506      $(this).after('<ul class="dropdown-menu"></ul>');
507      $(this).siblings('ul.dropdown-menu').delegate('a', 'click', $.proxy(this.click, this));
508
509    });
510  }
511})(window.jQuery);
512
513// 商品详情加购物车
514;(function($) {
515  var ProductInfoToCart = function(element, options) {
516    var defaults = {
517      data: [],
518    };
519
520    this.element = element;
521    this.settings = $.extend({}, defaults, options);
522    this.init();
523  };
524
525  ProductInfoToCart.prototype = {
526    init: function() {
527      var self = this, settings = this.settings;
528
529      $(this.element).on('click', function(e) {
530        self.ajax(settings);
531      })
532    },
533    ajax: function(settings) {
534      if ( !settings.data.length ) return;
535      $.ajax({
536        url: 'index.php?route=checkout/cart/add',
537        type: 'post',
538        data: $(settings.data.join(',')),
539        dataType: 'json',
540        success: function(json) {
541          $('.alert-dismissible, .text-danger').remove();
542          $('.form-group').removeClass('has-error');
543
544          if (json['error']) {
545            if (json['error']['option']) {
546              for (i in json['error']['option']) {
547                var element = $('#input-option' + i.replace('_', '-'));
548
549                if (element.parent().hasClass('input-group')) {
550                  element.parent().after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
551                } else {
552                  element.parent().after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
553                }
554              }
555            }
556
557            $('.text-danger').addClass('has-error');
558          }
559
560          if (json['success']) {
561
562            if( $('#product').data('cur-page') == 'quickview' ) {
563              $('#cart', window.parent.document).addClass('active');
564              setTimeout(function () {
565                $('#cart-total-quantity', window.parent.document).html(json['total_quantity']);
566              }, 100);
567              $('#box-min-cart', window.parent.document).children('ul').load('index.php?route=common/cart/info ul li');
568            }else {
569              $('#cart').addClass('active');
570
571              setTimeout(function () {
572                $('#cart-total-quantity').html(json['total_quantity']);
573              }, 100);
574
575              $('#box-min-cart').children('ul').load('index.php?route=common/cart/info ul li');
576            }
577          }
578        },
579      });
580    },
581  }
582
583  $.fn.productInfoToCart = function (options) {
584    this.each(function(index, el) {
585      new ProductInfoToCart(this, options);
586    });
587
588    return this;
589  };
590})(jQuery);
591
592
593
594function mobilecheck() {
595  var check = false;
596  (function(a){if(/(android|ipad|playbook|silk|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|
596sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)))check = true})(navigator.userAgent||navigator.vendor||window.opera);
597  return check;
598}
599
600function slidebarInit() {
601
602  var container = document.getElementById( 'st-container' ),
603      $mcontent = $('#menu > .menu'),
604      eventtype = 'touchstart, click',
605      effect = 3;
606
607  var $mobilemenu = $('<nav id="menu-mobile" class="st-menu menu-mobile st-effect-'+effect+' hidden-md hidden-lg"><div class="menu-mobile-inner"><div class="menu-mobile-title"><div class="nav"><a class="c-tab1 mobile-menu-tab active" data-fid="menu-category" href="javascript:void(0)"></a></div><div class="button-close-menu"><i class="fa fa-times-circle-o"></i></div></div></div></nav>');
608  $(".menu-mobile-inner", $mobilemenu ).append( $mcontent.clone() );
609
610  $("#st-pusher").append( $mobilemenu );
611  $(".menu", $mobilemenu  ).removeClass("menu").addClass("menu-mobile-content");
612  $("#menu-mobile").find('.sub-menu').removeClass("sub-menu").addClass("mobile-dropdown-menu")
613  $("#menu-mobile li.dropdown").append('<span class="mobile-more"><i class="fa fa-angle-down"></i></span>');
614
615  $('#btn-mobile-menu').bind(eventtype, function (e) {
616    $('html, body').animate({ scrollTop: 0 }, 0);  //add on 20170104
617    $(container).toggleClass('st-menu-open').addClass('st-effect-'+effect);
618    $('#st-pusher').bind(eventtype, function() {
619      $(container).removeClass( "st-menu-open" );
620      $('#st-pusher').unbind( eventtype );
621    });
622    e.stopPropagation();
623    return false;
624  });
625
626  $('#menu-mobile').bind(eventtype, function (e) {
627    e.stopPropagation();
628  });
629  $('#menu-mobile .button-close-menu').on(eventtype, function () {
630    $(container).removeClass('st-menu-open');
631  });
632
633  $('#menu-mobile .menu-mobile-content li.dropdown > a, #menu-mobile .menu-mobile-content li.dropdown > .mobile-more').on('click', function () {
634    $(this).parent('li').toggleClass('mobile-sub-open').siblings('li').removeClass('mobile-sub-open');
635    return false;
636  });
637  $('#menu-mobile .menu-mobile-content li.dropdown > a').on('click', function () {
638    return false;
639  });
640
641  $('.mobile-menu-tab').bind('click', function () {
642    $(this).addClass('active').siblings('a').removeClass('active');
643    $('#menu-mobile .my-menu').hide(100);
644    $('#menu-mobile #' + $(this).data('fid')).show(100);
645  });
646}
647
648$(document).ready(function() {
649  var windowWidth = $(window).width();
650  if (windowWidth > 991) {
651    $('#st-container').removeClass("st-menu-open");
652  }
653  $(window).resize(function(){
654    var windowWidth = $(window).width();
655    if (windowWidth > 991) {
656      $('#st-container').removeClass("st-menu-open");
657    }
658  });
659
660  //首先将#back-to-top隐藏
661  $("#back-to-top").hide();
662  //当滚动条的位置处于距顶部600像素以下时,跳转链接出现,否则消失
663  $(window).scroll(function(){
664    if ($(window).scrollTop()>500){
665      $("#back-to-top").fadeIn(500);
666    }else{
667      $("#back-to-top").fadeOut(500);
668    }
669
670    if(document.body.scrollWidth > 992)  {
671      //獲取垂直滾動的距離
672      var scrollTop = $(document).scrollTop();
673      if (scrollTop >= 250) {
674        $(".box-menu > ul > li > ul").css({"transform":"translateY(-50%) scaleY(0)","-ms-transform":"translateY(-50%) scaleY(0)","-ms-transform":"-moz-translateY(-50%) scaleY(0)"});
675        $(".box-menu > ul > li > .inner-submenu").css({"transform":"translateY(-50%) scaleY(0)","-ms-transform":"translateY(-50%) scaleY(0)","-ms-transform":"-moz-translateY(-50%) scaleY(0)"});
676      }else {
677        $(".box-menu > ul > li > ul").css({"transform":"translateY(0)","-ms-transform":"translateY(0)","-moz-transform":"translateY(0)"});
678        $(".box-menu > ul > li > .inner-submenu").css({"transform":"translateY(-50%) scaleY(0)","-ms-transform":"translateY(-50%) scaleY(0)","-ms-transform":"-moz-translateY(-50%) scaleY(0)"});
679      }
680    }
681  });
682  //当点击跳转链接后,回到页面顶部位置
683  $("#back-to-top").click(function(){
684    $('body,html').animate({scrollTop:0},500);
685    return false;
686  });
687
688  $('#header-top-register-menu').hover(function() {
689    $('#header-top-register-menu').show();
690  },function(){
691    $('#header-top-register-menu').hide();
692  })
693  $('#header-top-register').click(function() {
694    $('#header-top-register-menu').show(300);
695  });
696
697  $(document).bind("click", function (e) {
698    var target = $(e.target);
699    if (target.closest("#header-top-register-menu").length == 0 && target.closest("#header-top-register").length == 0) {
700      $("#header-top-register-menu").hide();
701    }
702  });
703
704  var nav=$(".fixed-menu"); //得到菜單對象
705  var win=$(window); //得到窗口對象
706  var sc=$(document);//得到document文档对象。
707  win.scroll(function(){
708    if(sc.scrollTop()>=$('.header-top').height() + $('.page-top-banner-wrapper').height()+20){
709      nav.addClass("fixednav");
710      $(".navTmp").fadeIn();
711    }else{
712      nav.removeClass("fixednav");
713      $(".navTmp").fadeOut();
714    }
715  });
716});
717
718
719
720function refreshCaptcha(url, obj) {
721  url += Math.round(Math.random()*10000);
722  obj.attr('src', url);
723}
724
725
726var account = {
727  'loginAction' : function() {
728    $.ajax({
729      url: 'index.php?route=rst/login',
730      type: 'post',
731      data: $('#ajax-login-form').serialize(),
732      dataType: 'json',
733      beforeSend: function () {
734        $("#button-login").prop("disabled", true);
735        $("#button-login").html(
736            '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> ' + $("#button-login").data('loading-text')
737        );
738      },
739      success: function (json) {
740        $('.alert, .text-danger').remove();
741        $('.has-error').removeClass('has-error');
742        if(json['code'] == 1) {
743          if (json['redirect']) {
744            location = json['redirect'];
745          }
746        }else {
747          $("#button-login").prop("disabled", false);
748          $("#button-login").html( $("#button-login").data('default-text'));
749          if (json['warning']) {
750            $('#ajax-login-form').parent().prepend(
751                '<div class="alert alert-warning"><i class="fa fa-exclamation-circle"></i> ' + json['warning'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>'
752            );
753          }
754        }
755      },
756      error: function(xhr, ajaxOptions, thrownError) {
757        console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
758        $("#button-login").prop("disabled", false);
759        $("#button-login").html( $("#button-login").data('default-text'));
760      }
761    });
762  },
763
764  'registerAction' : function () {
765    $('.for-error').removeClass('text-danger').hide();
766    $('.form-group').removeClass('has-error');
767    $.ajax({
768      url: 'index.php?route=rst/register',
769      type: 'post',
770      data: $('#ajax-register-form').serialize(),
771      dataType: 'json',
772      beforeSend: function () {
773        $("#button-register").prop("disabled", true);
774        $("#button-register").html(
775            '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> ' + $("#button-register").data('loading-text')
776        );
777      },
778      success: function (json) {
779        $('.alert, .text-danger').remove();
780        $('.has-error').removeClass('has-error');
781        if(json['code'] == 1) {
782          if (json['redirect']) {
783            location = json['redirect'];
784          }
785        }else {
786          $("#button-register").prop("disabled", false);
787          $("#button-register").html( $("#button-register").data('default-text'));
788          $('#img-register-captcha').trigger('click');
789          for (i in json['error']) {
790            if(i == 'warning') {
791              $('#ajax-register-form').parent().prepend(
792                  '<div class="alert alert-warning"><i class="fa fa-exclamation-circle"></i> ' + json['error'][i] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>'
793              );
794            }else if (i == 'captcha') {
795              $('#input-captcha-error').html('<div class="text-danger" style="margin-top: -15px;">' + json['error'][i] + '</div>');
796              $('#input-captcha').parent().addClass('has-error');
797            } else {
798              var element = $('#input-' + i.replace('_', '-'));
799              $(element).parent().addClass('has-error');
800              $(element).after('<div class="text-danger">' + json['error'][i] + '</div>');
801            }
802          }
803
804          if( $('.alert-warning').length > 0 ) {
805            $('html, body').animate({ scrollTop: $('.alert-warning').offset().top }, 'slow');
806          }
807        }
808      },
809      error: function(xhr, ajaxOptions, thrownError) {
810        console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
811        $("#button-register").prop("disabled", false);
812        $("#button-register").html( $("#button-login").data('default-text'));
813      }
814    });
815  }
816};
817
818
819var quickview = {
820  'view'	: function (product_id) {
821    var url = 'index.php?route=product/quickview&modal=1&product_id=' + product_id;
822    layer.open({
823      area: ['860px', '560px'],
824      type: 2,
825      title: false,
826      content: [url],
827    });
828  }
829};
830
831
832var cookie_base = {
833  'setCookie' : function (cname, cvalue, exdays) {
834    var d = new Date();
835    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
836    var expires = "expires=" + d.toUTCString();
837    document.cookie = cname + "=" + cvalue + ";" + expires;
838  },
839
840  'getCookie' : function(cname) {
841    var name = cname + "=";
842    var ca = document.cookie.split(';');
843    for(var i = 0; i < ca.length; i++) {
844      var c = ca[i];
845      while (c.charAt(0) == ' ') {
846        c = c.substring(1);
847      }
848      if (c.indexOf(name) == 0) {
849        return c.substring(name.length, c.length);
850      }
851    }
852    return "";
853  },
854
855  'checkCookie' : function () {
856    return this.getCookie("cookie-policy");
857  }
858};
859
860
861var cookie_policy = {
862  'accept': function () {
863    cookie_base.setCookie("cookie-policy", "existed", 7);
864    $('.cookie-policy-wrapper').fadeOut();
865  },
866
867  'checkCookie' : function () {
868    var cookie_policy = cookie_base.getCookie("cookie-policy");
869    if (cookie_policy != "") {
870      $('.cookie-policy-wrapper').fadeOut();
871    }else {
872      $('.cookie-policy-wrapper').fadeIn();
873    }
874  }
875};
876
877
878function popupImage(obj) {
879
880  if( $(obj).data('target') == undefined || $(obj).data('target') == '' ) {
881    return false;
882  }
883  if( $(obj).data('url') == undefined || $(obj).data('url') == '' ) {
884    return false;
885  }
886
887  if( $('#'+$(obj).data('target')).length == 0 ) {
888    var html = '<div class="modal fade" id="'+ $(obj).data('target') +'">';
889    html += ' <div class="modal-dialog">';
890    html += '   <div class="modal-content">';
891    html += '   <div class="modal-header"><button type="button" class="close" data-dismiss="modal">&times;</button></div>';
892    html += '   <div class="bigPhoto modal-content-wrapper"><img class="img-fluid" src="'+ $(obj).data('url') +'"></div>';
893    html += '   </div>';
894    html += ' </div>';
895    html += '</div>';
896    $('body').append(html);
897  }
898
899  $('#'+$(obj).data('target')).modal('show');
900}
901
902
903var bookingview = {
904  'view'	: function () {
905    var url = 'index.php?route=booking/view&modal=1';
906    layer.open({
907      area: ['660px', '380px'],
908      type: 2,
909      title: false,
910      content: [url],
911    });
912  },
913
914  'search'  : function () {
915    $.ajax({
916      url: 'index.php?route=booking/search',
917      type: 'get',
918      dataType: 'json',
919      crossDomain: true,
920      data: 'keyword=' + encodeURIComponent($('#input-booking-keyword').val()),
921      beforeSend: function() {
922        $("#button-booking-search").prop("disabled", true);
923        $("#button-booking-search").html(
924            '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> ' + $("#button-booking-search").data('loading-text')
925        );
926      },
927      complete: function() {
928        $('#button-booking-search').prop("disabled", false);
929        $("#button-booking-search").html($("#button-booking-search").data('default-text'));
930      },
931      success: function(json) {
932        $('.alert, .text-danger').remove();
933
934        if (json['code'] == 0) {
935          $('#group-booking-keyword').after('<div class="text-danger">'+ json['error'] +'</div>');
936        }else {
937          if (json['success']) {
938            $('.booking-search-result-wrapper').html(json['success']);
939          }
940        }
941      },
942      error: function(xhr, ajaxOptions, thrownError) {
943        console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
944      }
945    });
946  }
947};
948

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.