PageSourceSearch

https://www.tecc.com.my/catalog/view/theme/pavilion/javascript/common.js

js tecc.com.my collected 2026-10-06 13:17:37 UTC 41,993 bytes, 1,319 lines download raw bytes

1///////////////////////////////////////////
2//  OPENCART
3///////////////////////////////////////////
4
5function addToCart(product_id, quantity) {
6    quantity = typeof(quantity) != 'undefined' ? quantity : 1;
7    $.ajax({
8        url: 'index.php?route=checkout/cart/add',
9        type: 'post',
10        data: 'product_id=' + product_id + '&quantity=' + quantity,
11        dataType: 'json',
12        success: function(json) {
13            $('.success, .warning, .attention, .information, .error').remove();
14            if (json['redirect']) {
15                location = json['redirect'];
16            } else
17            if (json['error']) {
18                for (var first in json.error) break;
19                displayNotice('product', 'failure', product_id, json.error[first]);
20            } else
21            if (json['success']) {
22                $('.tb_widget_cart > .tb_nav').load('index.php?route=module/cart .tb_nav > *');
23                displayNotice('product', 'success', product_id, json['success']);
24            }
25        }
26    });
27}
28
29function addToWishList(product_id) {
30    $.ajax({
31        url: 'index.php?route=account/wishlist/add',
32        type: 'post',
33        data: 'product_id=' + product_id,
34        dataType: 'json',
35        success: function(json) {
36            $('.success, .warning, .attention, .information').remove();
37            if (!$sReg.get('/tb/is_customer_logged')) {
38                displayNotice('wishlist', 'failure', product_id, json['success']);
39                $('#wishlist_total').html(json['total']);
40            } else
41            if (json['success']) {
42                displayNotice('wishlist', 'success', product_id, json['success']);
43                $('#wishlist_total').html(json['total']);
44            }
45        }
46    });
47}
48
49function addToCompare(product_id) {
50    $.ajax({
51        url: 'index.php?route=product/compare/add',
52        type: 'post',
53        data: 'product_id=' + product_id,
54        dataType: 'json',
55        success: function(json) {
56            if (json['success']) {
57                displayNotice('compare', 'success', product_id, json['success']);
58                $('.tb_compare_total').html(json['total']);
59            }
60        }
61    });
62}
63
64/* Search */
65function moduleSearch($element) {
66    var filter_name = $element.parent().find('input[name=search]').val();
67
68    if (filter_name) {
69        location = 'index.php?route=product/search&search=' + encodeURIComponent(filter_name);
70    }
71}
72
73function changeLanguage($link) {
74    $('input[name=\'language_code\']').attr('value', $link.attr('data-language-code'));
75    $link.closest('form').submit()
76}
77
78function changeCurrency($link) {
79    $('input[name=\'currency_code\']').attr('value', $link.attr('data-currency-code'));
80    $link.closest('form').submit()
81}
82
83///////////////////////////////////////////
84//  RESIZE EVENTS
85///////////////////////////////////////////
86
87function onSizeChange(callback, namespace, unbind_namespace) {
88
89    if ($.browser.msie && $.browser.version < 9) {
90        return;
91    }
92
93    var resizeEvent = window.hasOwnProperty("onorientationchange") ? "orientationchange" : "resize";
94
95    if (typeof namespace != "undefined") {
96
97        if (typeof unbind_namespace == "undefined") {
98            unbind_namespace = false;
99        }
100
101        if (unbind_namespace) {
102            offSizeChange(namespace);
103        }
104
105        resizeEvent += "." + namespace;
106    }
107
108    $(window).on(resizeEvent, callback);
109}
110
111function offSizeChange(namespace) {
112    var resizeEvent = window.hasOwnProperty("onorientationchange") ? "orientationchange" : "resize";
113
114    resizeEvent += "." + namespace;
115
116    $(window).off(resizeEvent);
117}
118
119///////////////////////////////////////////
120//  GLOBAL VARS
121///////////////////////////////////////////
122
123var tb_user_agent = navigator.userAgent;
124var tb_is_iphone  = ~tb_user_agent.indexOf('iPhone') || ~tb_user_agent.indexOf('iPod');
125var tb_is_ipad    = ~tb_user_agent.indexOf('iPad');
126var tb_is_ios     = tb_is_iphone || tb_is_ipad;
127var tb_is_ios4    = tb_is_ios && ~tb_user_agent.indexOf(' 4_');
128
129///////////////////////////////////////////
130//  NOTIFICATIONS
131///////////////////////////////////////////
132
133function displayNotice(context, type, product_id, message) {
134
135    var stack = Number($sReg.get('/tb/msg_stack'));
136    var thumb;
137
138    if (!stack) {
139        $.noty.closeAll();
140    }
141
142    var $product = $(".tb_product.tb_id_" + product_id);
143
144    if (!$product.length) {
145        $product = $("#" + product_id);
146        thumb = $product.find(" > meta[itemprop=image]").attr("content");
147    } else {
148        thumb = $product.find(".tb_thumb img").attr("src");
149    }
150
151    var buttons_config = [{
152        type: 'tb_button tb_h_30', text: $sReg.get('/lang/text_continue'), click: function() {
153            $.noty.closeAll();
154        }
155    }];
156
157    var modal = false;
158    var w_width  = document.documentElement.clientWidth;
159    var w_height = document.documentElement.clientHeight;
160
161    if (w_width < 767 && w_height < 767) {
162        modal = true;
163    }
164
165    function ios_fixed($cont) {
166        if (tb_is_ios4) {
167            top = $(window).scrollTop();
168            $cont.css('top', top + 15);
169            $cont.parents('.noty_cont').first().prev('.noty_modal').height(1000).css('top', top);
170
171            $(document).bind('touchmove.noty', function(e) {
172                e.preventDefault();
173            }, false);
174
175            onSizeChange(function() {
176                top = $(window).scrollTop();
177                $cont.css('top', top + 15);
178                $cont.parents('.noty_cont').first().prev('.noty_modal').css('top', top);
179            }, 'noty');
180        }
181    }
182
183    var msg_tpl;
184
185    if ($product.length) {
186        msg_tpl = '\
187            <h3><i class="tb_icon fa-{{icon}}"></i>{{title}}</h3>\
188            <a class="tb_thumb" href=""><img src="{{thumb_src}}"></a>\
189            <p>{{contents}}</p>';
190    } else {
191        msg_tpl = '\
192            <h3><i class="tb_icon fa-{{icon}}"></i>{{title}}</h3>\
193            <p>{{contents}}</p>';
194    }
195
196    var showNotice = function(title) {
197        var template_vars = {
198            icon:      type == 'success' ? 'check' : 'times',
199            title:     title,
200            contents:  message,
201            thumb_src: thumb
202        };
203
204        noty({
205            text: $.tim(msg_tpl, template_vars),
206            layout: $sReg.get('/tb/msg_position'),
207            closeOnSelfClick: false,
208            modal: modal,
209            buttons: modal ? buttons_config : false,
210            closeButton: !modal,
211            timeout: modal ? false : Number($sReg.get('/tb/msg_timeout')),
212            animateOpen: {opacity: 'toggle'},
213            animateClose: {opacity: 'toggle'},
214            close_speed: stack ? 500 : 0,
215            onShow: function() {
216                ios_fixed($(this));
217            },
218            onClose: function() {
219                $(document).unbind('touchmove.noty');
220                offSizeChange('lightbox');
221            }
222        });
223    };
224
225    if (type == 'failure') {
226        showNotice($sReg.get('/lang/text_failure'));
227        return;
228    }
229
230    switch (context) {
231        case 'product':
232            buttons_config = [{
233                type: 'tb_button tb_h_30', text: $sReg.get('/lang/text_continue_shopping'), click: function() {
234                    $.noty.closeAll();
235                }
236            },{
237                type: 'tb_button tb_h_30', text: $sReg.get('/lang/text_shopping_cart'), click: function() {
238                    window.location = $sReg.get('/tb/shopping_cart_url');
239                }
240            }];
241
242            showNotice($sReg.get('/lang/text_cart_updated'));
243            break;
244        case 'wishlist':
245            buttons_config.push({
246                type: 'tb_button tb_h_30', text: $sReg.get('/lang/text_wishlist'), click: function() {
247                    window.location = $sReg.get('/tb/wishlist_url');
248                }
249            });
250            showNotice($sReg.get('/lang/text_wishlist_updated'));
251            break;
252        case 'compare':
253            buttons_config.push({
254                type: 'tb_button tb_h_30', text: $sReg.get('/lang/text_product_comparison'), click: function() {
255                    window.location = $sReg.get('/tb/compare_url');
256                }
257            });
258            showNotice($sReg.get('/lang/text_compare_updated'));
259            break;
260    }
261}
262
263///////////////////////////////////////////
264//  HEADER
265///////////////////////////////////////////
266
267function sticky_header(show_logo) {
268
269    if ((document.documentElement.clientWidth <= 767 && document.documentElement.clientHeight <= 767) || ($.browser.msie && $.browser.version <= 8)) {
270        return;
271    }
272
273    var $wrap    = $('#wrapper');
274    var $cont    = $('#main_navigation_row').length ? $('#main_navigation_row') : $('#header');
275    var $nav     = $('#main_navigation');
276    var $nav_row = $nav.parents('.tb_row').first();
277    var $nav_col = $nav.parent();
278    var height   = $cont.outerHeight(true);
279    var offset   = $cont.offset();
280    var padding  = $wrap.outerHeight() - $wrap.height();
281
282    var $temp_logo;
283    var $temp_cart;
284    var $temp_search;
285
286    $cont.removeClass('tb_sticky');
287
288    $(window).scroll(function () {
289        if ($(this).scrollTop() > height + offset.top - 50 && $(window).width() > 766) {
290            if (!$wrap.hasClass('tb_sticky')) {
291
292                $temp_logo   = show_logo ? $('#site_logo').clone().addClass('tbCloned').insertBefore($nav) : $();
293                $temp_cart   = $('.tb_widget_cart').clone(true).addClass('tbCloned').insertAfter($nav);
294                $temp_search = $('.tb_widget_site_search').clone(true).addClass('tbCloned').insertAfter($nav);
295
296                $wrap.addClass('tb_sticky');
297                $cont.addClass('tb_sticky_container');
298                $cont.parent().css('padding-top', padding + height);
299                $nav_row.addClass('tbNavContainer');
300                $nav_col.addClass('tbNavContainerCol');
301            }
302        }
303        else {
304            if (typeof $temp_logo != "undefined") {
305                $temp_logo.remove();
306                $temp_cart.remove();
307                $temp_search.remove();
308
309                $temp_logo = $temp_cart = $temp_search = undefined;
310            }
311
312            $wrap.removeClass('tb_sticky');
313            $cont.removeClass('tb_sticky_container');
314            $cont.parent().css('padding-top', '');
315            $nav_row.removeClass('tbNavContainer');
316            $nav_col.removeClass('tbNavContainerCol');
317        }
318    });
319
320}
321
322function responsive_header() {
323
324    var position = $('#header').find('.tbSystemRow').length ? 'before' : 'after';
325    var $system_row;
326
327    var change_header = function () {
328        if (document.documentElement.clientWidth < 767) {
329            if (!$('#header').hasClass('tbMobile')) {
330                var $row_markup = $('#header').find('.tbSystemRow').length ? $('<div class="tb_row tbSystemRow tbCloned"></div>') : $('<div class="tb_row tbCloned"></div>');
331
332                $system_row = $row_markup
333                  .append($('.tb_widget_currency').clone(true))
334                  .append($('.tb_widget_language').clone(true))
335                  .append($('#user_navigation li.menu_account a').clone());
336
337                if (position == 'before') {
338                    $system_row = $system_row.insertBefore('.tbLogoRow');
339                    $('#wrapper').addClass('tbSystemBefore');
340                }
341                else {
342                    $system_row = $system_row.insertAfter('.tbLogoRow');
343                    $('#wrapper').addClass('tbSystemAfter');
344                }
345
346                $('#header').addClass('tbMobile');
347            }
348        }
349        else {
350            if (typeof $system_row != "undefined") {
351                $system_row.remove();
352                $system_row = undefined;
353            }
354
355            $('#wrapper').removeClass('tbSystemBefore tbSystemAfter');
356            $('#header').removeClass('tbMobile');
357        }
358    };
359
360    change_header();
361    onSizeChange(change_header);
362}
363
364
365///////////////////////////////////////////
366//  CREATE SLIDER
367///////////////////////////////////////////
368
369function createItemSlider(container, items_count, slide_step, speed, pagination, responsive_params) {
370
371    var $slides = $(container + ' .tb_listing').children();
372    var init = false;
373    var responsive_keys = [];
374
375    for(var k in responsive_params) {
376        responsive_keys.push(Number(k));
377    }
378    responsive_keys.sort(function(a, b){return a-b});
379
380    function getRestrictions(c_width) {
381        var result = {};
382
383        if (responsive_keys.length) {
384            $.each(responsive_keys, function(key, value) {
385                result = responsive_params[value];
386                if(c_width <= value) {
387                    return false;
388                }
389            });
390        }
391
392        return result;
393    }
394
395    var SwiperObj = null;
396    var current_slides_per_view;
397
398    var buttons = function() {
399        if (SwiperObj === null) {
400            return;
401        }
402
403        if (SwiperObj.activeIndex < 1) {
404            $(container)
405                .find('.tb_prev').addClass('tb_disabled').end()
406                .find('.tb_next').removeClass('tb_disabled');
407        } else
408        if (SwiperObj.activeIndex + current_slides_per_view == items_count) {
409            $(container)
410                .find('.tb_next').addClass('tb_disabled').end()
411                .find('.tb_prev').removeClass('tb_disabled');
412        } else {
413            $(container).find('.tb_prev, .tb_next').removeClass('tb_disabled');
414        }
415    };
416
417    function max_height(container) {
418        var max_h = 0;
419        var $items = $(container).find('.swiper-slide-visible .tb_item');
420
421        $items.each(function() {
422            var h = $(this).innerHeight();
423            if (max_h == 0 || max_h < h) {
424                max_h = h;
425            }
426        });
427
428        return max_h;
429    }
430
431    function createSlider(slides_per_view, slide_step) {
432
433        $slides.wrapAll('<div class="swiper-container"><div class="swiper-wrapper"></div></div>').wrap('<div class="swiper-slide"></div>');
434        $(container)
435            .addClass('has_slider')
436            .find('.tb_listing')
437            .addClass('tb_slider')
438            .removeClass('tb_slider_load');
439
440        if (pagination) {
441            $(container)
442                .find('.tb_listing')
443                .after('<div class="tb_slider_pagination"></div>');
444        }
445
446        $(container)
447            .find('.tb_listing')
448            .after('<div class="tb_slider_controls"><a class="tb_prev" href="javascript:;" title="' + $sReg.get('/lang/text_previous') + '"></a><a class="tb_next" href="javascript:;" title="' + $sReg.get('/lang/text_next') + '"></a></div>');
449
450        SwiperObj = new Swiper(container + ' .swiper-container', {
451            slidesPerView:         slides_per_view,
452            slidesPerGroup:        slide_step,
453            speed:                 speed,
454            pagination:            pagination,
455            paginationClickable:   true,
456            paginationActiveClass: 'tb_active',
457            roundLengths:          true,
458            autoResize:            false,
459            visibilityFullFit:     true,
460            onSwiperCreated: function (swiper) {
461                buttons();
462                $(container).find('.swiper-container').addClass('tb_slider_init');
463                //$(swiper.container).css('height', max_height(swiper.container));
464            },
465            onSlideChangeEnd: function (swiper){
466                buttons();
467                //$(swiper.container).css('height', max_height(swiper.container));
468            },
469            onTouchEnd: function (swiper){
470                buttons();
471                //$(swiper.container).css('height', max_height(swiper.container));
472            }
473        });
474    }
475
476    function destroySlider() {
477        SwiperObj.destroy();
478        SwiperObj = null;
479        $(container).removeClass('has_slider')
480            .find('.swiper-slide').unwrap().unwrap().end()
481            .find('.swiper-slide .tb_item').unwrap().end()
482            .find('.tb_slider_controls, .tb_slider_pagination').remove();
483        $(container).find('.tb_listing').removeClass('tb_slider');
484
485    }
486
487    function responsive() {
488
489        var restrictions = getRestrictions($(container).width());
490        var slides_per_view = Number(restrictions.items_per_row);
491
492        if (items_count > slides_per_view && SwiperObj === null) {
493            // create
494            createSlider(slides_per_view, slide_step < slides_per_view ? slide_step : slides_per_view);
495            $(container).find('.tb_slider_pagination').addClass('tb_size_' + slides_per_view);
496            current_slides_per_view = slides_per_view;
497            buttons();
498        } else
499        if (items_count <= slides_per_view && SwiperObj !== null) {
500            // destroy
501            destroySlider();
502        } else
503        if (current_slides_per_view == slides_per_view && SwiperObj !== null) {
504            // fix size
505            SwiperObj.resizeFix();
506        } else
507        if (current_slides_per_view != slides_per_view && SwiperObj !== null) {
508            // reinit
509            SwiperObj.params.slidesPerView = slides_per_view;
510            SwiperObj.params.slidesPerGroup = slide_step < slides_per_view ? slide_step : slides_per_view;
511
512            $(container).find('.tb_slider_pagination')
513                .removeClass('tb_size_' + current_slides_per_view)
514                .addClass('tb_size_' + slides_per_view);
515
516            current_slides_per_view = slides_per_view;
517            buttons();
518            SwiperObj.resizeFix();
519        }
520
521        if ($(container).find('.tb_slider').hasClass('tb_side_nav')) {
522            tbApp.onWindowLoaded(function() {
523                var nav_height = $(container).find('.tb_slider_controls > a:first-child').height();
524
525                $(container).find('.tb_slider_controls').css('visibility', 'visible');
526                $(container).find('.tb_slider_controls > a').css('margin-top', -($(container + ' .swiper-container').height()/2 + nav_height/2));
527            });
528        }
529    }
530
531    $(container).on('click', '.tb_prev', function (e) {
532        e.preventDefault();
533        SwiperObj.swipePrev();
534        buttons();
535    });
536
537    $(container).on('click', '.tb_next', function (e) {
538        e.preventDefault();
539        SwiperObj.swipeNext();
540        buttons();
541    });
542
543    return {
544        refresh: function() {
545            if(false !== responsive_params) {
546                responsive();
547                if (false === init) {
548                    onSizeChange(function() {
549                        if ($(container).is(":visible")) {
550                            responsive();
551                            if ($(container).parent().parent().hasClass('tb_tabs_content')) {
552                                $(container).parent().css('height', '');
553                            }
554                        }
555                    });
556                    init = true;
557                }
558            } else
559            if (false === init) {
560                buttons();
561                init = true;
562            }
563        }
564    }
565}
566
567///////////////////////////////////////////
568//  ADJUST ITEM SIZE
569///////////////////////////////////////////
570
571function adjustItemSize(container, responsive_params) {
572
573    var responsive_keys = [];
574
575    for(var k in responsive_params) {
576        responsive_keys.push(Number(k));
577    }
578    responsive_keys.sort(function(a, b){return a-b});
579
580    function getRestrictions(c_width) {
581        var result = {};
582
583        if (responsive_keys.length) {
584            $.each(responsive_keys, function(key, value) {
585                result = responsive_params[value];
586                if(c_width <= value) {
587                    return false;
588                }
589            });
590        }
591
592        return result;
593    }
594
595    function responsive() {
596        var restrictions = getRestrictions($(container).width());
597
598        $(container).find('.tb_listing')
599            .removeClass('tb_size_1 tb_size_2 tb_size_3 tb_size_4 tb_size_5 tb_size_6 tb_size_7 tb_size_8')
600            .removeClass('tb_gut_0 tb_gut_10 tb_gut_20 tb_gut_30 tb_gut_40 tb_gut_50')
601            .addClass('tb_size_' + restrictions.items_per_row)
602            .addClass('tb_gut_'  + restrictions.items_spacing);
603    }
604
605    responsive();
606    onSizeChange(function() {
607        responsive();
608        if ($(container).parent().parent().hasClass('tb_tabs_content')) {
609            $(container).parent().css('height', '');
610        }
611    });
612
613}
614
615///////////////////////////////////////////
616//  ELEMENT QUERY
617///////////////////////////////////////////
618
619function element_query(element, resolutions) {
620
621    if (typeof resolutions == "undefined") {
622        resolutions = [
623            1000,
624            900,
625            800,
626            700,
627            600,
628            500,
629            400,
630            300,
631            200,
632            100,
633            0
634        ];
635    }
636
637    var max_w = resolutions[0];
638    var min_w = resolutions[resolutions.length - 1];
639
640    var width_detect = function() {
641        var outerWidth = $(element).outerWidth();
642
643        $.each(resolutions, function(i) {
644            if (i == 0) {
645                if (outerWidth > resolutions[i]) {
646                    $(element).removeClass('tb_max_w_' + max_w);
647                    $(element).removeClass('tb_min_w_' + min_w);
648                    $(element).addClass('tb_min_w_' + (resolutions[0]));
649                    max_w = 0;
650                    min_w = resolutions[i];
651
652                    return false;
653                }
654            } else {
655                if (outerWidth > resolutions[i] && outerWidth <= resolutions[i - 1]) {
656                    $(element).removeClass('tb_max_w_' + max_w);
657                    $(element).removeClass('tb_min_w_' + min_w);
658                    $(element).addClass('tb_max_w_' + resolutions[i-1]);
659                    $(element).addClass('tb_min_w_' + resolutions[i]);
660                    max_w = resolutions[i-1];
661                    min_w = resolutions[i];
662
663                    return false;
664                }
665            }
666        });
667    };
668
669    width_detect();
670
671    onSizeChange(width_detect);
672}
673
674///////////////////////////////////////////
675//  PRODUCT BEAUTIFY
676///////////////////////////////////////////
677
678function item_beautify(container) {
679
680    var original_per_row;
681    var $viewport = $(window);
682    var $tbListing = $(container).find('.tb_listing');
683
684    for (var i = 2; i <= 8; i++) {
685        if ($tbListing.hasClass('tb_size_' + i)) {
686            original_per_row = i;
687            break;
688        }
689    }
690
691    var cur_products_per_row = original_per_row;
692
693    function adjust_height(cur_products_per_row) {
694
695        var $products = $(container).find('.tb_item');
696        var $product_row;
697        var chunk = cur_products_per_row;
698
699        if ($(container).hasClass('has_slider')) {
700            chunk = $products.length;
701        }
702
703        for (var i = 0; i < $products.length; i += chunk) {
704            var max_h = 0;
705
706            $product_row = $products.slice(i , i + chunk);
707            $product_row.each(function() {
708                var h = $(this).height();
709                if (max_h == 0 || max_h < h) {
710                    max_h = h;
711                }
712            });
713            $product_row.each(function() {
714                $(this).height(max_h);
715            });
716        }
717    }
718
719    function responsive() {
720        if ($tbListing.hasClass('tb_grid_view')) {
721            $(container).find('.tb_item').css('height', '');
722
723            if ($viewport.width() <= 767) {
724              cur_products_per_row = 3;
725            }
726            if ($viewport.width() <= 480) {
727              cur_products_per_row = 2;
728            }
729            if ($viewport.width() <= 300) {
730              cur_products_per_row = 1;
731            }
732            if ($viewport.width() > 767) {
733              cur_products_per_row = original_per_row;
734            }
735
736            adjust_height(cur_products_per_row);
737        }
738    }
739
740    responsive();
741    onSizeChange(function() {
742        responsive();
743    });
744
745}
746
747///////////////////////////////////////////
748//  PRODUCT HOVER
749///////////////////////////////////////////
750
751function item_hover(container, active_elements, hover_elements, hover_style) {
752
753  // Append
754  if(hover_style == 'append') {
755    $(container + ' .tb_products.tb_grid_view:not(".tb_slider") .tb_item').each(function() {
756      var $item = $(this);
757      var $hover_content = $item.clone();
758
759      $hover_content.find(hover_elements).remove();
760      $hover_content.find('div.tb_actions:not(:has(*))').remove();
761      $hover_content.find('div.tb_item_info:not(:has(*))').remove();
762
763      $item.find(active_elements).remove();
764      $item.find('div.tb_actions:not(:has(*))').remove();
765      $item.find('div.tb_item_info:not(:has(*))').remove();
766
767      $item.hover(
768        function() {
769          $item.append('<div class="tb_item_hovered">' + $hover_content.html() + '</div>');
770        }, function() {
771          $item.find('.tb_item_hovered').remove();
772        }
773      );
774    });
775  }
776
777  // Flip && Overlay
778  if(hover_style == 'flip' || hover_style == 'overlay') {
779    $(container + ' .tb_products.tb_grid_view .tb_item').each(function() {
780      var $item = $(this);
781
782      var $active_content = $item.clone();
783      var $hover_content = $item.clone();
784
785      $active_content.find(active_elements).remove();
786      $hover_content.find(hover_elements).remove();
787
788      $item.addClass('tb_' + hover_style);
789      $item.children().remove();
790
791      $item.append('<div class="tb_item_info_active tb_front">' + $active_content.html() + '</div>');
792      $item.append('<div class="tb_item_info_hover tb_back"><div class="tb_item_info_wrap">' + $hover_content.html() + '</div></div>');
793
794      $item.find('div.tb_actions:not(:has(*))').remove();
795      $item.find('div.tb_item_info:not(:has(*))').remove();
796    });
797  }
798}
799
800///////////////////////////////////////////
801//  THUMB HOVER
802///////////////////////////////////////////
803
804function thumb_hover(container, hover_style) {
805  // Flip
806  if(hover_style == 'flip' || hover_style == 'overlay') {
807    $(container + ' .tb_products.tb_listing .tb_item').each(function() {
808      var $item = $(this);
809
810      if (!$item.find(".tb_thumb_hover").length) {
811        return true;
812      }
813
814      $item.find('.tb_thumb:first-child').addClass('tb_front');
815      $item.find('.tb_thumb_hover').addClass('tb_back');
816
817      var thumb = $item.find('.tb_thumb:first-child').outerHTML();
818
819      if (typeof thumb != "string") {
820        thumb = '';
821      }
822
823      var thumb_hover = $item.find('.tb_thumb_hover').outerHTML();
824
825      if (typeof thumb_hover != "string") {
826        thumb_hover = '';
827      }
828
829      $item.find('.tb_thumb').remove();
830      $item.prepend('<div class="tb_thumb tb_' + hover_style + '">' + thumb + thumb_hover + '</div>');
831    });
832  }
833}
834
835///////////////////////////////////////////
836//  RESPONSIVE DIALOG
837///////////////////////////////////////////
838
839function fluidDialog() {
840    var $visible = $(".ui-dialog:visible");
841
842    $visible.each(function () {
843        var $this = $(this);
844        var dialog = $this.find(".ui-dialog-content").data("ui-dialog");
845
846        if (dialog.options.fluid) {
847            var wWidth = $(window).width();
848            if (wWidth < dialog.options.maxWidth + 50) {
849                $this.css("max-width", "90%");
850            } else {
851                $this.css("max-width", dialog.options.maxWidth);
852            }
853            dialog.option("position", dialog.options.position);
854        }
855    });
856}
857
858function tbCreateDialog($selector, $parent) {
859
860    onSizeChange(fluidDialog, 'tbFluidDialog', true);
861
862    var $dialog = null;
863    var callback = function() {
864
865        if (null !== $dialog) {
866            $dialog.dialog('open');
867
868            return false;
869        }
870
871        var title = $(this).attr('alt') ? $(this).attr('alt') : $(this).text();
872
873        $dialog = $('<div></div>')
874            .appendTo('body')
875            .addClass('tb_loading')
876            .append('<i class="fa fa-circle-o-notch fa-spin"></i>')
877            .load($(this).attr('href'), function() {
878                $(this).removeClass('tb_loading').wrap('<div class="overflow_text"></div>');
879            })
880            .dialog({
881                title: title,
882                width: 600,
883                maxWidth: 600,
884                height: 'auto',
885                maxHeight: document.documentElement.clientHeight - 60,
886                modal: true,
887                fluid: true,
888                resizable: false,
889                position: {
890                    my: "top+30",
891                    at: "top",
892                    of: window
893                },
894                draggable: false,
895                open: function() {
896                    fluidDialog();
897                }
898            });
899
900        return false;
901    };
902
903    if (typeof $parent == 'undefined') {
904        $selector.bind('click', callback);
905    } else {
906        $parent.on('click', $selector, callback);
907    }
908}
909
910///////////////////////////////////////////
911//  LIGHTBOX GALLERY
912///////////////////////////////////////////
913
914function lightbox_gallery(id, gallery, index) {
915
916    $('body').append('<div id="fotorama_' + id + '"><div class="tb_gallery tb_fullscreen"><div class="fotorama"></div><a class="tb_close" href="javascript:;"></a></div></div>');
917
918    var $cont = $('#fotorama_' + id + '');
919    $cont.css('position', 'relative');
920    $cont.css('z-index', '1000');
921
922    function ios_fixed() {
923
924        if ((tb_is_iphone || tb_is_ipad) && tb_is_ios4) {
925            var w_height = document.documentElement.clientHeight;
926            var top = $(window).scrollTop();
927
928            if (tb_is_iphone && !window.navigator.standalone) {
929                w_height += 60;
930            }
931
932            $cont.find('> .tb_gallery').height(w_height);
933            $cont.find('> .tb_gallery').css('top', top);
934
935            $(document).bind('touchmove.lightbox', function(e) {
936              // This prevents native scrolling from happening.
937              e.preventDefault();
938            }, false);
939        }
940    }
941
942    ios_fixed();
943    onSizeChange(function() {
944        ios_fixed();
945        if (typeof lightbox_fotorama != 'undefined') {
946            lightbox_fotorama.resize();
947        }
948    }, 'lightbox');
949
950    var $lightbox_gallery = $cont.find('> .tb_gallery > .fotorama').fotorama({
951        data:       gallery,
952        width:      '100%',
953        height:     '100%',
954        fit:        'scaledown',
955        startindex: index,
956        shadows:    false
957    });
958
959    var lightbox_fotorama = $lightbox_gallery.data('fotorama');
960
961    function lightbox_remove() {
962        lightbox_fotorama.destroy();
963        $cont.fadeOut(function(){
964            $(this).remove();
965        });
966        $('#' + id + ' .tbGoFullscreen').removeClass('tbKeyPressed');
967        $(document).unbind('keydown.lightbox_remove');
968        $(document).unbind('touchmove.lightbox');
969        offSizeChange('lightbox');
970    }
971
972    $cont.find('.tb_close').bind('click', function() {
973        lightbox_remove();
974
975        return false;
976    });
977
978    $(document).bind("keydown.lightbox_remove", function(e) {
979        if(e.keyCode === 27) {
980            lightbox_remove();
981        }
982        if(e.keyCode === 37) {
983            lightbox_fotorama.show('<');
984        }
985        if(e.keyCode === 39) {
986            lightbox_fotorama.show('>');
987        }
988    });
989}
990
991///////////////////////////////////////////
992//  SYSTEM
993///////////////////////////////////////////
994
995function getURLVar(key) {
996    var value = [];
997    var query = String(document.location).split('?');
998    if (query[1]) {
999        var part = query[1].split('&');
1000        for (i = 0; i < part.length; i++) {
1001            var data = part[i].split('=');
1002            if (data[0] && data[1]) {
1003                value[data[0]] = data[1];
1004            }
1005        }
1006        if (value[key]) {
1007            return value[key];
1008        } else {
1009            return '';
1010        }
1011    }
1012}
1013
1014var $sReg = new function() {
1015
1016    function unlink(object) {
1017
1018        var unlinked;
1019
1020        switch (typeof object){
1021            case 'object':
1022                unlinked = {};
1023                for (var p in object) unlinked[p] = unlink(object[p]);
1024                break;
1025            case 'array':
1026                unlinked = [];
1027                for (var i = 0, l = object.length; i < l; i++) unlinked[i] = unlink(object[i]);
1028                break;
1029            default: return object;
1030        }
1031
1032        return unlinked;
1033    }
1034
1035    function mixin(mix) {
1036
1037        for (var i = 1, l = arguments.length; i < l; i++){
1038            var object = arguments[i];
1039            if (typeof object != 'object') continue;
1040            for (var key in object){
1041                var op = object[key], mp = mix[key];
1042                mix[key] = (mp && typeof op == 'object' && typeof mp == 'object') ? mixin(mp, op) : unlink(op);
1043            }
1044        }
1045
1046        return mix;
1047    }
1048
1049    function merge() {
1050
1051        var args = Array.prototype.slice.call(arguments);
1052
1053        args.unshift({});
1054
1055        return mixin.apply(null, args);
1056    }
1057
1058    return {
1059
1060        conf : {},
1061
1062        set : function(path,value){
1063
1064            var fragments = path.split('/');
1065
1066            if( fragments.shift() !== '') {
1067                return false;
1068            }
1069
1070            if(fragments.length > 0 && fragments[fragments.length - 1] == '') {
1071                fragments.pop();
1072            }
1073
1074            var obj = {};
1075            var ref = obj;
1076            var len = fragments.length;
1077
1078            if( len > 0){
1079                for(var i = 0; i < len-1; i++){
1080                    ref[fragments[i]] = {};
1081                    ref = ref[fragments[i]];
1082                }
1083                ref[fragments[len-1]] = value;
1084                this.conf = merge(this.conf,obj);
1085            } else {
1086                this.conf = value;
1087            }
1088        },
1089
1090        get : function(path){
1091
1092            var fragments = path.split('/');
1093
1094            if( fragments.shift() !== '') {
1095                return null;
1096            }
1097
1098            if(fragments.length > 0 && fragments[fragments.length -1] == '') fragments.pop();
1099
1100            var ref = this.conf;
1101            var path_exists = true;
1102            var i = 0;
1103
1104            if (ref[fragments[i]] === undefined) {
1105                return null;
1106            }
1107
1108            var len = fragments.length;
1109
1110            while(path_exists && i < len){
1111                path_exists = path_exists && (ref[fragments[i]] !== undefined);
1112                ref = ref[fragments[i]]; i++;
1113            }
1114
1115            return ref;
1116        }
1117    };
1118};
1119
1120///////////////////////////////////////////
1121//  BOOT
1122///////////////////////////////////////////
1123
1124tbApp.onScriptLoaded(function() {
1125
1126    if($sReg.get("/tb/is_touch") != 0) {
1127        $('body').addClass('is_touch');
1128    }
1129
1130    $('#search_button').bind('click', function() {
1131        moduleSearch($(this));
1132    });
1133
1134    $('#filter_keyword').bind('keydown', function(e) {
1135        if (e.keyCode == 13) {
1136            moduleSearch($(this));
1137        }
1138    });
1139
1140    $("body").on("click", ".tb_server_msg, .warning, .alert", function() {
1141        $(this).fadeOut(200, function(){
1142            $(this).remove();
1143        });
1144    });
1145
1146    $('.tb_widget_cart > .tb_nav > .heading a').one('mouseenter', function() {
1147        $('.tb_widget_cart > .tb_nav')
1148            .addClass('active')
1149            .load('index.php?route=module/cart .tb_nav > *')
1150            .on('mouseleave', function() {
1151                $(this).removeClass('active');
1152            });
1153    });
1154
1155    $('.tb_nav > ul').find('li.tb_multiple:not(.tb_item)').hoverIntent({
1156        over: function(){
1157            $(this).addClass('tb_hovered');
1158
1159            var site_width          = $('#bottom > .tb_wrap > .tb_col_1_1 > .tb_row > .tb_wrap > .tb_col_1_1').width();
1160            var site_offset         = $('#bottom > .tb_wrap > .tb_col_1_1 > .tb_row > .tb_wrap > .tb_col_1_1').offset().left;
1161            var submenu_width       = $(this).find('> .tb_submenu').width();
1162            var submenu_outer_width = $(this).find('> .tb_submenu').outerWidth();
1163            var submenu_offset      = $(this).find('> .tb_submenu').offset().left;
1164            var adjust =
1165                site_width
1166                + site_offset
1167                - submenu_width
1168                - submenu_outer_width / 4
1169                + submenu_width / 4
1170                - submenu_offset
1171                - 1;
1172
1173            if (adjust < 0 && site_offset < submenu_width) {
1174                $(this).find('> .tb_submenu').css('margin-left', Math.ceil(adjust));
1175            }
1176        }
1177        ,
1178        out: function(){
1179            $(this).removeClass('tb_hovered');
1180            $(this).find('> .tb_submenu').css('margin-left', '');
1181        },
1182        timeout: 250
1183    });
1184
1185    $('#menu > ul').find('> li').hoverIntent({
1186        over: function(){
1187            $(this).addClass('tb_hovered');
1188            if(!$(this).find('> div').is(":within-viewport-left")) {
1189                $(this).addClass('tb_out_of_view_left');
1190            }
1191            if(!$(this).find('> div').is(":within-viewport-right")) {
1192                $(this).addClass('tb_out_of_view_right');
1193            }
1194        }
1195        ,
1196        out: function(){
1197            $(this).removeClass('tb_hovered');
1198            $(this).removeClass('tb_out_of_view_left');
1199            $(this).removeClass('tb_out_of_view_right');
1200        },
1201        timeout: 250
1202    });
1203
1204    $('.tb_widget_cart > .tb_nav').hoverIntent({
1205        over: function(){
1206            $(this).addClass('tb_hovered');
1207            if(!$(this).find('> .tb_submenu').is(":within-viewport-left")) {
1208                $(this).addClass('tb_out_of_view_left');
1209            }
1210            if(!$(this).find('> .tb_submenu').is(":within-viewport-right")) {
1211                $(this).addClass('tb_out_of_view_right');
1212            }
1213        }
1214        ,
1215        out: function(){
1216            $(this).removeClass('tb_hovered');
1217            $(this).removeClass('tb_out_of_view_left');
1218            $(this).removeClass('tb_out_of_view_right');
1219        },
1220        timeout: 250
1221    });
1222
1223    responsive_header();
1224
1225    $('#header .tb_widget_currency, #main_navigation_row .tb_widget_currency').on('click', '.tb_submenu a', function(e) {
1226        changeCurrency($(this));
1227    });
1228    $('#header .tb_widget_language, #main_navigation_row .tb_widget_language').on('click', '.tb_submenu a', function(e) {
1229        changeLanguage($(this));
1230    });
1231
1232    $('#header, #main_navigation_row').on('click', '.tb_nav > ul > li.tb_multiple > a', function(e) {
1233        if (!$(this).next('.tb_submenu').is(':visible') && !$(this).parent().find('> .tb_toggle').is(':visible')) {
1234            e.preventDefault();
1235        }
1236    });
1237    $('#header, #main_navigation_row').on('click', '.tb_widget_cart > .tb_nav > .heading > a', function(e) {
1238        if (!$('.tb_widget_cart > .tb_nav > .tb_submenu').is(':visible')) {
1239            e.preventDefault();
1240        }
1241    });
1242
1243    var tb_nav_touch_event = tb_is_ios ? 'touchend' : 'click';
1244
1245    $('#header, #main_navigation_row').on(tb_nav_touch_event, 'li.tb_multiple > .tb_toggle, li.tb_multiple > a[href*="javascript"]', function() {
1246        if (!$(this).parent().find('> .tb_submenu').is(':visible')) {
1247            $(this).parent().addClass('tb_active').find('> .tb_toggle').addClass('tb_active');
1248        } else {
1249            $(this).parent().removeClass('tb_active').find('> .tb_toggle').removeClass('tb_active');
1250        }
1251    });
1252
1253    $('#main_navigation > .tb_toggle').bind('click', function() {
1254        $('#main_navigation .tb_nav, #main_navigation #menu').toggleClass('tb_active');
1255        $('.tb_widget_site_search .tb_search_wrap').removeClass('tb_active');
1256        $('.tb_widget_cart > .tb_nav').removeClass('tb_active');
1257    });
1258
1259    $('.tb_widget_site_search > .tb_toggle').bind('click', function() {
1260        $('.tb_widget_site_search .tb_search_wrap').toggleClass('tb_active');
1261        $('#main_navigation .tb_nav, #main_navigation #menu').removeClass('tb_active');
1262        $('.tb_widget_cart > .tb_nav').removeClass('tb_active');
1263    });
1264
1265    $('.tb_widget_cart > .tb_toggle').bind('click', function() {
1266        $('.tb_widget_cart > .tb_nav').toggleClass('tb_active');
1267        $('#main_navigation .tb_nav, #main_navigation #menu').removeClass('tb_active');
1268        $('.tb_widget_site_search .tb_search_wrap').removeClass('tb_active');
1269    });
1270
1271    function adjust_menu_height($items, items_per_row) {
1272
1273        var heights = [];
1274
1275        for (var i = 1; i <= $items.length; i ++) {
1276
1277            var row_index = Math.ceil(i/items_per_row) - 1;
1278            var diff = 0;
1279
1280            if (typeof heights[row_index] == "undefined") {
1281                heights[row_index] = {};
1282                heights[row_index].h = []
1283            }
1284
1285            if(i > items_per_row) {
1286                diff = heights[row_index-1]['max'] - heights[row_index-1].h[i-(items_per_row*row_index)-1];
1287                if (diff > 0 ) {
1288                    $($items[i-1]).css('margin-top', '-' + diff + 'px');
1289                }
1290            }
1291
1292            heights[row_index].h.push($($items[i-1]).height() - diff);
1293            heights[row_index].max = Math.max.apply(Math, heights[row_index].h);
1294        }
1295    }
1296
1297    $('#main_navigation .tb_megamenu').each(function() {
1298        $(this).hover(function() {
1299
1300            if ($(window).width() > 750) {
1301                $subcategories = $(this).find('> .tb_submenu > .tb_row > .tb_wrap > [class*="tb_col_"] > .tb_subcategories');
1302
1303                //$(this).find('> .tb_submenu').css('display', 'block');
1304                if(!$subcategories.hasClass('height_adjusted')) {
1305                    adjust_menu_height($subcategories.find('> .tb_item'), $subcategories.attr('data-cols'));
1306                    $subcategories.addClass('height_adjusted');
1307                }
1308            }
1309
1310        }, function() {
1311            //$(this).find('> .tb_submenu').css('display', '');
1312        });
1313    });
1314});
1315
1316$(document).ready(function() {
1317    $(tbApp).trigger("tbScriptLoadedInit");
1318    $(tbApp).trigger("tbScriptLoaded");
1319});

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.