PageSourceSearch

https://www.badmintonbay.com/catalog/view/theme/BurnEngine/javascript/common.js

js badmintonbay.com collected 2026-10-04 16:08:13 UTC 66,532 bytes, 1,848 lines download raw bytes

1/* -----------------------------------------------------------------
2   S Y S T E M
3----------------------------------------------------------------- */
4
5function getURLVar(key) {
6    var value = [];
7    var query = String(document.location).split('?');
8    if (query[1]) {
9        var part = query[1].split('&');
10        for (i = 0; i < part.length; i++) {
11            var data = part[i].split('=');
12            if (data[0] && data[1]) {
13                value[data[0]] = data[1];
14            }
15        }
16        if (value[key]) {
17            return value[key];
18        } else {
19            return '';
20        }
21    }
22}
23
24// Cart add remove functions
25
26function addToCart(product_id, quantity) {
27    var url      = window.location.href,
28        $product = $('.product-id_' + product_id).parent();
29
30    $.ajax({
31        url: 'index.php?route=checkout/cart/add',
32        type: 'post',
33        data: 'product_id=' + product_id + '&quantity=' + (quantity !== undefined && Number(quantity) !== 0 ? quantity : 1),
34        dataType: 'json',
35        beforeSend: function() {
36            $product
37                .find('.wait').remove().end()
38                .removeClass('tb_product_loaded tb_add_to_cart_loaded')
39                .addClass('tb_product_loading tb_add_to_cart_loading')
40                .find('.tb_button_add_to_cart').append('<span class="wait"></span>');
41        },
42        success: function(json) {
43            $('.success, .warning, .attention, .information, .error').remove();
44            if (json['redirect']) {
45                location = json['redirect'];
46            } else
47            if (json['error']) {
48                for (var first in json.error) break;
49                displayNotice('product', 'failure', product_id, json.error[first]);
50            } else
51            if (json['success']) {
52                setTimeout(function () {
53                    $product
54                        .removeClass('tb_product_loading tb_add_to_cart_loading')
55                        .find('.tb_button_add_to_cart .wait').remove().end()
56                        .addClass('tb_product_loaded tb_add_to_cart_loaded');
57
58                    setTimeout(function () {
59                        $product
60                            .removeClass('tb_product_loaded tb_add_to_cart_loaded')
61                    }, 5000);
62                }, 500);
63                $.get('index.php?route=module/cart', function(result) {
64                    var $container = $(tbRootWindow.document).find('.tb_wt_header_cart_menu_system');
65
66                    $container.find('.heading').replaceWith($(result).find('.heading').clone());
67                    $container.find('.content').replaceWith($(result).find('.content').clone());
68
69                    tbApp.triggerResizeCallbacks();
70                });
71                displayNotice('product', 'success', product_id, json['success']);
72            }
73        }
74    });
75}
76
77function removeFromCart(product_id) {
78    $.get('index.php?route=module/cart&remove=' + product_id, function(result) {
79        var $items  = $(result).find('.content').clone(),
80            $title  = $(result).find('.heading').clone();
81
82        $('.tb_wt_header_cart_menu_system .heading').replaceWith($title);
83        $('.tb_wt_header_cart_menu_system .content').replaceWith($items);
84        tbApp.triggerResizeCallbacks();
85    });
86}
87
88function addToWishList(product_id) {
89    var $product = $('.product-id_' + product_id).parent();
90
91    $.ajax({
92        url: 'index.php?route=account/wishlist/add',
93        type: 'post',
94        data: 'product_id=' + product_id,
95        dataType: 'json',
96        beforeSend: function() {
97            $product
98                .find('.wait').remove().end()
99                .removeClass('tb_product_loaded tb_wishlist_loaded')
100                .addClass('tb_product_loading tb_wishlist_loading')
101                .find('.tb_button_wishlist').append('<span class="wait"></span>');
102        },
103        success: function(json) {
104            $('.success, .warning, .attention, .information').remove();
105            if (!tbApp['/tb/is_customer_logged']) {
106                displayNotice('wishlist', 'failure', product_id, json['success']);
107            } else
108            if (json['success']) {
109                displayNotice('wishlist', 'success', product_id, json['success']);
110            }
111            if (json['info']) {
112                displayNotice('wishlist', 'failure', product_id, json['info']);
113            }
114
115            setTimeout(function () {
116                $product
117                    .removeClass('tb_product_loading tb_wishlist_loading')
118                    .find('.tb_button_wishlist .wait').remove().end()
119                    .addClass('tb_product_loaded tb_wishlist_loaded');
120
121                setTimeout(function () {
122                    $product
123                        .removeClass('tb_product_loaded tb_wishlist_loaded')
124                }, 5000);
125            }, 500);
126
127            $(tbRootWindow.document).find('.wishlist-total').html(json['total']);
128
129            Array.prototype.forEach.call(tbRootWindow.document.querySelectorAll('a.wishlist_total, li.wishlist_total > a > .tb_text'), function(el) {
130                var number = json['total'].replace(/[^0-9]/g, '');
131
132                $(el).find('.tb_items').remove();
133                $(el).append('<span class="tb_items">' + number + '</span>');
134            });
135        }
136    });
137}
138
139function addToCompare(product_id) {
140    $.ajax({
141        url: 'index.php?route=product/compare/add',
142        type: 'post',
143        data: 'product_id=' + product_id,
144        dataType: 'json',
145        success: function(json) {
146            if (json['success']) {
147                displayNotice('compare', 'success', product_id, json['success']);
148
149                $(tbRootWindow.document).find('#compare-total').html(json['total']);
150
151                Array.prototype.forEach.call(tbRootWindow.document.querySelectorAll('a.tb_compare_total, li.tb_compare_total > a > .tb_text'), function(el) {
152                    var number = json['total'].replace(/[^0-9]/g, '');
153
154                    $(el).find('.tb_items').remove();
155                    $(el).append('<span class="tb_items">' + number + '</span>');
156                });
157            }
158        }
159    });
160}
161
162// Search
163
164function moduleSearch($element) {
165    var filter_name = $element.parent().find('input[name=search]').val();
166
167    if (filter_name) {
168        var operator = tbApp['/tb/url/search'].indexOf('?') !== -1 ? '&' : '?';
169
170        location = tbApp['/tb/url/search'] + operator + 'search=' + encodeURIComponent(filter_name);
171    }
172}
173
174// Currency & Language
175
176function changeLanguage($link) {
177    $('input[name=\'language_code\']').attr('value', $link.data('language-code'));
178
179    if ($link.attr("href") == "javascript:;") {
180        $link.closest('form').submit()
181    }
182}
183
184function changeCurrency($link) {
185    $('input[name=\'currency_code\']').attr('value', $link.data('currency-code'));
186    $link.closest('form').submit()
187}
188
189// Responsive Dialog
190
191function fluidDialog() {
192
193    $(".ui-dialog:visible").each(function () {
194        var $this = $(this);
195        var dialog = $this.find(".ui-dialog-content").data("ui-dialog");
196
197        if (dialog.options.fluid) {
198            var wWidth = $(window).width();
199            if (wWidth < dialog.options.maxWidth + 50) {
200                $this.css("max-width", "90%");
201            } else {
202                $this.css("max-width", dialog.options.maxWidth);
203            }
204            dialog.option("position", dialog.options.position);
205        }
206    });
207}
208
209function createDialogInstance($element) {
210
211    var title = $element.attr('alt') ? $element.attr('alt') : $element.text();
212
213    return $('<div></div>')
214        .appendTo('body')
215        .addClass('tb_loading')
216        .append('<span class="wait"></span>')
217        .load($element.attr('href'), function() {
218            $(this).removeClass('tb_loading').wrap('<div class="overflow_text"></div>');
219        })
220        .dialog({
221            title: title,
222            width: 600,
223            maxWidth: 600,
224            height: 'auto',
225            maxHeight: document.documentElement.clientHeight - 60,
226            modal: true,
227            fluid: true,
228            resizable: false,
229            position: {
230                my: "top+30",
231                at: "top",
232                of: window
233            },
234            draggable: false,
235            open: function() {
236                fluidDialog();
237            }
238        });
239}
240
241var dialogCreated = false;
242
243function tbCreateDialog($element) {
244
245    if (!dialogCreated) {
246        var el_id = 'tbFluidDialog_' + String(Math.random());
247        if ($element.attr("id")) {
248            el_id = $element.attr("id");
249        }
250        tbUtils.onSizeChange(fluidDialog, 'tbFluidDialog', true, el_id);
251    }
252
253    if (!$element.data('dialogInstance')) {
254        $element.data('dialogInstance', createDialogInstance($element));
255        dialogCreated = true;
256    }
257
258    $element.data('dialogInstance').dialog('open');
259}
260
261/* -----------------------------------------------------------------
262   R E S I Z E   E V E N T S
263----------------------------------------------------------------- */
264
265tbApp.onScriptLoaded(function() {
266    tbApp.windowWidth = tbWindowWidth;
267    tbApp.lang_dir    = $('html').attr('dir');
268    tbUtils.onSizeChange(function() {
269        tbApp.windowWidth = window.innerWidth;
270    }, false, false, 'windowWidth');
271    includeSvgResource("catalog/view/theme/" + tbApp["/tb/basename"] + "/image/icons.svg", 2);
272});
273
274/* -----------------------------------------------------------------
275   G L O B A L   V A R S
276----------------------------------------------------------------- */
277
278var tb_navigation_hovered = false;
279
280/* -----------------------------------------------------------------
281   N O T I F I C A T I O N S
282----------------------------------------------------------------- */
283
284var displayNotice = tbRootWindow.displayNotice !== undefined ? tbRootWindow.displayNotice : function(context, type, product_id, message) {
285
286    var stack = Number(tbApp['/tb/msg_stack']);
287    var thumb;
288
289    if (!stack) {
290        $.noty.closeAll();
291    }
292
293    var $product = $(".product-id_" + product_id).first().parent();
294
295    if (!$product.length) {
296        $product = $('.tb_wt_product_images_system');
297        thumb = !$product.find('.image img').length ? $product.find('.thumbnail img').attr('src') : $product.find('.image img').attr('src');
298    } else {
299        thumb = $product.find(".image img").attr("src");
300    }
301
302    if (!thumb) {
303        thumb = tbApp['/tb/no_image'];
304    }
305
306    var buttons_config = [{
307        type: 'btn', text: tbApp._t('text_continue'), click: function() {
308            $.noty.closeAll();
309        }
310    }];
311
312    var modal = false;
313    var w_width  = window.innerWidth;
314    var w_height = window.innerHeight;
315
316    if (w_width <= 768 && w_height <= 768) {
317        modal = true;
318    }
319
320    var msg_tpl;
321
322    if ($product.length && thumb) {
323        msg_tpl = '\
324            <h3>\
325              <svg class="tb_icon tb_main_color_bg"><use xlink:href="{{url}}#{{icon}}" /></svg>\
326              {{title}}\
327            </h3>\
328            <div class="noty_text_body">\
329              <a class="thumbnail" href=""><img src="{{thumb_src}}"></a>\
330              <p>{{contents}}</p>\
331            </div>';
332    } else {
333        msg_tpl = '\
334            <h3>\
335              <svg class="tb_icon tb_main_color_bg"><use xlink:href="{{url}}#{{icon}}" /></svg>\
336              {{title}}\
337            </h3>\
338            <p>{{contents}}</p>';
339    }
340
341    var showNotice = function(title) {
342        var template_vars = {
343            icon:      type == 'success' ? 'check' : 'close',
344            title:     title,
345            contents:  message,
346            thumb_src: thumb,
347            url:       window.location.href
348        };
349
350        noty({
351            text: $.tim(msg_tpl, template_vars),
352            layout: tbApp['/tb/msg_position'],
353            closeOnSelfClick: false,
354            modal: modal,
355            buttons: modal ? buttons_config : false,
356            closeButton: !modal,
357            timeout: modal ? false : Number(tbApp['/tb/msg_timeout']),
358            animateOpen: {opacity: 'toggle'},
359            animateClose: {opacity: 'toggle'},
360            close_speed: stack ? 500 : 0,
361            onClose: function() {
362                $(document).unbind('touchmove.noty');
363            }
364        });
365    };
366
367    if (type == 'failure') {
368        showNotice(tbApp._t('text_failure'));
369        return;
370    }
371
372    switch (context) {
373        case 'product':
374            buttons_config = [{
375                type: 'btn', text: tbApp._t('text_continue_shopping'), click: function() {
376                    $.noty.closeAll();
377                }
378            },{
379                type: 'btn', text: tbApp._t('text_shopping_cart'), click: function() {
380                    window.location = tbApp['/tb/url/shopping_cart'];
381                }
382            }];
383
384            showNotice(tbApp._t('text_cart_updated'));
385            break;
386        case 'wishlist':
387            buttons_config.push({
388                type: 'btn', text: tbApp._t('text_wishlist'), click: function() {
389                    window.location = tbApp['/tb/url/wishlist'];
390                }
391            });
392            showNotice(tbApp._t('text_wishlist_updated'));
393            break;
394        case 'compare':
395            buttons_config.push({
396                type: 'btn', text: tbApp._t('text_product_comparison'), click: function() {
397                    window.location = tbApp['/tb/url/compare'];
398                }
399            });
400            showNotice(tbApp._t('text_compare_updated'));
401            break;
402    }
403};
404
405/* -----------------------------------------------------------------
406   S T I C K Y   S I D E B A R
407----------------------------------------------------------------- */
408
409function stickyColumn(selectors, offset) {
410    tbApp.onScriptLoaded(function() {
411        selectors.split(",").forEach(function(selector) {
412            var $selector = $(selector);
413
414            $selector
415                .wrapInner('<div class="col-sticky"></div>')
416                .find('> .col-sticky')
417                .stick_in_parent({
418                    offset_top: parseInt($selector.css('paddingTop')) + Number(offset)
419                });
420        });
421    });
422}
423
424/* -----------------------------------------------------------------
425   S C R O L L   T O   T O P
426----------------------------------------------------------------- */
427
428function scroll_to_top(speed) {
429
430    if (window.innerWidth <= 768 && window.innerHeight <= 768) {
431        return;
432    }
433
434    if (speed === undefined) {
435        speed = 800;
436    }
437
438    var $scroll_button = $('<a id="tbScrollToTop" class="btn btn-default tb_no_text" href="javascript:;"><i class="fa fa-angle-up"></i></a>').appendTo('body');
439
440    $scroll_button.bind('click', function(){
441        $('html, body').animate({ scrollTop: 0 }, speed);
442    });
443
444    $(window).scroll(function () {
445        if ($(this).scrollTop() > 150 && $scroll_button.css('opacity') < 100) {
446            $scroll_button.css('opacity', 100);
447        } else {
448            $scroll_button.css('opacity', 0);
449        }
450    });
451}
452
453/* -----------------------------------------------------------------
454   H E A D E R
455----------------------------------------------------------------- */
456
457function sticky_header(style, layout, padding) {
458
459    if ($('#header').length == 0 || window.innerWidth <= 768 && window.innerHeight <= 768) {
460        return;
461    }
462
463    if (style === undefined) {
464        style = 'minimal';
465    }
466
467    if (layout === undefined) {
468        layout = 'full';
469    }
470
471    if (padding === undefined) {
472        padding = '10px 0';
473    }
474
475    var $cont    = $('#header'),
476        $wrap    = $('#wrapper'),
477        $temp;
478
479    var height      = $cont.outerHeight(true),
480        offset      = $cont.offset(),
481        //height_mod  = parseInt($cont.next().css('margin-top')) + $cont.next().offset().top - height - offset.top,
482        old_classes = $cont.attr('class'),
483        classes     = layout != 'full_fixed' ? 'tb_sticky_width_' + layout : 'tb_sticky_width_full tb_content_fixed',
484        scrolled    = false,
485        animation_timeout;
486
487    // Default style
488
489    if (style == 'default') {
490        $cont
491            .addClass(classes + ' tbSticky');
492        $('body')
493            .css('padding-top', ($cont.hasClass('tb_header_overlay') ? 0 : height));
494    }
495
496    function clone_widget($widget) {
497
498        tbApp.trigger('beforeCloneWidget', [$widget]);
499
500        var $clonedWidget = $widget.clone(true)
501            .css({'padding-left': 0, 'padding-right': 0})
502            .removeClass('display-block')
503            .addClass('display-inline-block')
504            .find("script").remove().end();
505
506        $temp.find('.col-md-12').append($clonedWidget);
507    }
508
509    tbApp.onWindowLoaded(function() {
510
511        $(window).scroll(function () {
512            if (window.pageYOffset > height + offset.top - 20 && tbApp.windowWidth > 768 && !tb_navigation_hovered) {
513
514                // minimal style
515
516                if ($wrap.find('> .tbSticky').length == 0) {
517
518                    if (style == 'minimal' && $('#sticky_header').length == 0) {
519                        $temp = $('<div id="sticky_header" class="tb_area_header ' + classes + ' tbSticky" style="padding: ' + padding + '"><div class="row tbStickyRow"><div class="col col-xs-12 col-md-12 col-valign-middle"></div></div></div>').prependTo($wrap);
520
521                        $cont.find('.tbStickyShow:not([class*="tbStickyPosition"])').each(function () {
522                            clone_widget($(this));
523                        });
524
525                        for (var i = 1; i <= 8; i++) {
526                            $cont.find('.tbStickyPosition-' + i).each(function () {
527                                clone_widget($(this));
528                            });
529                        }
530
531                        $temp.find('.tb_hovered').removeClass('tb_hovered');
532
533                        $temp.find('[id]:not(.tb_wt):not(#cart):not(#search):not(#site_logo)').each(function () {
534                            $(this).attr('id', $(this).attr('id') + '_cloned');
535                        });
536
537                        $temp.find('[data-target]').each(function () {
538                            $(this).data('target', $(this).data('target') + '_cloned');
539                        });
540
541                        dropdown_menu('#sticky_header .dropdown');
542
543                    }
544                }
545                else {
546                    $('#sticky_header').show();
547                }
548
549                // default style
550
551                if (style == 'default' && $wrap.find('> .tbStickyScrolled').length == 0) {
552                    clearTimeout(animation_timeout);
553
554                    $cont
555                        .removeClass('tbStickyRestored')
556                        .addClass('tbElementsHidden')
557                        .addClass('tbStickyScrolled')
558                        .css('padding', padding);
559                }
560                
561                scrolled = true;
562            }
563            else {
564                if (style == 'minimal') {
565                    $('#sticky_header')
566                        .hide();
567                    $cont
568                        .css('height', '')
569                        .css('padding', '');
570                    $('body')
571                        .css('padding-top', '');
572                }
573                if (style == 'default') {
574                    $cont
575                        .removeClass('tbStickyScrolled')
576                        .css('padding', '');
577                        
578                    if (scrolled) {
579                      $cont
580                        .addClass('tbStickyRestored')
581                    }
582
583                    clearTimeout(animation_timeout);
584
585                    animation_timeout = setTimeout(function() {
586                        $cont
587                            .removeClass('tbElementsHidden');
588                    }, 500);
589                }
590            }
591        });
592        $(window).trigger('scroll');
593    });
594}
595
596function responsive_header() {
597    if (!$('#header').length) {
598        return false;
599    }
600
601    var $temp;
602
603    $('#header')
604        .on('click', '.tbToggleButtons span', function () {
605            if ($(this).hasClass('tbToggleCart')) {
606                $temp = $('<div id="tb_mobile_car_menu" class="tbMobileMenu tbMobileCartMenu"><div class="row"><div class="col col-xs-12 col-sm-12 col-valign-top"></div></div></div>').appendTo('#wrapper');
607
608                $('#header').find('.tb_wt_header_cart_menu_system').each(function () {
609                    var $clonedMenu = $(this).clone(true).find("script").remove().end();
610
611                    $temp.find('.col-sm-12').append($clonedMenu);
612                    $('html').addClass('tbCartMenu');
613                    element_query('#tb_mobile_car_menu', '500,300,0', '.cart-info');
614                });
615            } else {
616                $temp = $('<div class="tbMobileMenu"><div class="row"><div class="col col-xs-12 col-sm-12 col-valign-top"></div></div></div>').appendTo('#wrapper');
617
618                $('#header').find('.tbMobileMenuShow:not([class*="tbMobilePosition"])').each(function () {
619                    var $clonedMenu = $(this).clone(true).find("script").remove().end();
620
621                    $temp.find('.col-sm-12').append($clonedMenu);
622                });
623                for (var i = 1; i <= 8; i++) {
624                    $('#header').find('.tbMobileMenuShow.tbMobilePosition-' + i).each(function () {
625                        var $clonedMenu = $(this).clone(true).find("script").remove().end();
626
627                        $temp.find('.col-sm-12').append($clonedMenu);
628                    });
629                }
630                $temp.find('[id]:not(.tb_wt):not(#cart):not(#search):not(#site_logo)').each(function () {
631                    $(this).attr('id', $(this).attr('id') + '_cloned');
632                });
633            }
634
635            setTimeout(function(){
636                $('.tbMobileMenuOverlay').addClass('tbActive');
637                $('html').addClass('tbMobile');
638                tbApp.triggerResizeCallbacks();
639            }, 10);
640        });
641
642    $('#wrapper').append('' +
643        '<div class="tbMobileMenuOverlay">' +
644        '  <svg><use xlink:href="' + window.location.href + '#close" /></svg>
644' +
645        '  <span class="tb_bg"></span>' +
646        '</div>');
647
648    $('#wrapper').on('click', '> .tbMobileMenuOverlay', function () {
649        $('html').removeClass('tbMobile');
650        $('.tbMobileMenuOverlay').removeClass('tbActive');
651        setTimeout(function() {
652            $('#wrapper').find('> .tbMobileMenu').remove();
653        }, 500);
654        tbApp.triggerResizeCallbacks();
655    });
656
657    if (window.innerWidth <= 768 && window.innerHeight > 768
658        || window.innerWidth > 768 && window.innerHeight <= 768) {
659
660        function responsive() {
661            if (window.innerWidth > 768) {
662                $('#wrapper').find('> .tbMobileMenu').remove();
663                $('html').removeClass('tbMobile');
664                $('.tbMobileMenuOverlay').removeClass('tbActive');
665            }
666        }
667
668        tbUtils.onSizeChange(responsive, false, false, false);
669    }
670}
671
672/* -----------------------------------------------------------------
673   T A B S   /   A C C O R D I O N
674----------------------------------------------------------------- */
675
676function createGroup(container, type, settings) {
677
678    var initSubwidget = function($tab, $panel) {
679
680        $panel.find("> div").each(function() {
681            var id = $(this).attr("id");
682
683            if (!$(this).data("initialized")) {
684
685                if ("function" == typeof tbApp["init" + id]) {
686                    tbApp["init" + id]();
687                }
688
689                $(this).data("initialized", true);
690            }
691
692            if ("function" == typeof tbApp["exec" + id]) {
693                tbApp["exec" + id]();
694            }
695        });
696    };
697
698    var $container = $('#' + container);
699
700    if (type == 'tabs') {
701
702        initSubwidget('tab', $($container.find('li:first-child > a').attr('data-tab')).find('> .panel-body'));
703
704        // Init tabs
705        $('#' + container).find(".tbWidgetTabs").tabs({
706            beforeLoad: function (event) {
707                event.preventDefault();
708            },
709            beforeActivate: function (event, ui) {
710                if (settings.auto_height) {
711                    return;
712                }
713
714                ui.newPanel.css('height', ui.oldPanel.height());
715                $('#' + container).css('overflow', 'hidden');
716                if (!ui.newTab.hasClass("tbActivated")) {
717                    ui.newPanel.addClass("tb_loading");
718                    ui.newPanel.prepend('<span class="wait"></span>');
719                }
720            },
721            activate: function (event, ui) {
722                initSubwidget(ui.newTab.find("a"), ui.newPanel.find('> .panel-body'));
723
724                if (settings.auto_height) {
725                    return;
726                }
727
728                if (!ui.newTab.hasClass("tbActivated")) {
729                    setTimeout(function () {
730                        ui.newTab.addClass("tbActivated");
731                        ui.newPanel.find("> .wait").remove();
732                        ui.newPanel.removeClass("tb_loading");
733                        ui.newPanel.find("> *").fadeOut(0).fadeIn(300);
734                        var old_h = ui.newPanel.height();
735                        ui.newPanel.css('height', '');
736
737                        var new_h = ui.newPanel.height();
738                        var diff = new_h - old_h;
739
740                        ui.newPanel.css('height', old_h);
741                        ui.newPanel.animate({height: '+=' + diff}, 300, function () {
742                            $('#' + container).css('overflow', '');
743                        });
744                    }, 250);
745                } else {
746                    var old_h = ui.newPanel.height();
747                    ui.newPanel.css('height', '');
748
749                    var new_h = ui.newPanel.height();
750                    var diff = new_h - old_h;
751
752                    ui.newPanel.css('height', old_h);
753                    ui.newPanel.animate({height: '+=' + diff}, 300, function () {
754                        $('#' + container).css('overflow', '');
755                    });
756                }
757            },
758            create: function (event, ui) {
759                initSubwidget(ui.tab.find("a"), ui.panel.find('> .panel-body'));
760            },
761            heightStyle: settings.auto_height ? 'auto' : 'content'
762        });
763        if (settings.fade) {
764            $('#' + container).find(".tbWidgetTabs").tabs('option', 'show', {
765                effect: 'fade',
766                duration: 300
767            });
768            $('#' + container).find(".tbWidgetTabs").tabs('option', 'hide', {
769                effect: 'fade',
770                duration: 300
771            });
772        }
773
774    } else {
775
776        initSubwidget('accordion', $($container.find('.tb_title:first-child + div > .panel-body')));
777
778        // Init accordion
779        var init_height = 50;
780
781        $container.find(".tbWidgetAccordion > .tb_accordion_content").accordion({
782            beforeActivate: function(event, ui) {
783                if (!ui.newHeader.hasClass("tbActivated")) {
784                    ui.newPanel.height(ui.oldPanel.height());
785                    ui.newPanel.addClass("tb_loading");
786                    ui.newPanel.prepend('<span class="wait"></span>');
787                }
788            },
789            activate: function(event, ui) {
790                if (!ui.newHeader.hasClass("tbActivated")) {
791                    setTimeout(function() {
792                        ui.newHeader.addClass("tbActivated");
793                        ui.newPanel.find("> .wait").remove();
794                        ui.newPanel.removeClass("tb_loading");
795                        ui.newPanel.find("> *").fadeOut(0).fadeIn(300);
796                        var old_h = ui.newPanel.height();
797                        ui.newPanel.css('height', '');
798
799                        var new_h = ui.newPanel.height();
800                        var diff  = new_h - old_h;
801
802                        ui.newPanel.css('height', old_h);
803                        if (!settings.auto_height) {
804                            ui.newPanel.animate({height: '+=' + diff});
805                        }
806                        initSubwidget(ui.newHeader, ui.newPanel.find('> .panel-body'));
807                    }, 250);
808                } else {
809                    initSubwidget(ui.newHeader, ui.newPanel.find('> .panel-body'));
810                }
811            },
812            header: 'span.tb_title',
813            heightStyle: settings.auto_height ? 'auto' : 'content',
814            collapsible: true
815        });
816        if (settings.has_icon) {
817            $('#' + container).find(".tbWidgetAccordion > .tb_accordion_content").accordion('option', 'icons', false);
818        }
819        if (settings.closed) {
820            $('#' + container).find(".tbWidgetAccordion > .tb_accordion_content").accordion('option', 'active', false);
821        }
822    }
823
824}
825
826/* -----------------------------------------------------------------
827   C A R O U S E L
828----------------------------------------------------------------- */
829
830function createItemSlider(container, items_count, slide_step, speed, pagination, responsive_params, autoplay, loop) {
831
832    if (autoplay === undefined) {
833        autoplay = 0;
834    }
835
836    if (loop === undefined) {
837        loop = false;
838    }
839
840    var $heading        = $(container).is('.has_slider:not(.no_title)') ? $(container).find('.panel-heading, .box-heading') : $(container).closest('.tb_wt_group').find('.nav-tabs'),
841        $slides         = $(container + ' .tb_listing').children(),
842        init            = false,
843        side_nav        = $(container).is('.tb_side_nav') || !$heading.length ? 1 : 0,
844        responsive_keys = [],
845        listing_style   = '';
846
847    listing_style += $(container + ' .tb_listing').is('.tb_style_bordered') ? ' tb_bordered' : '';
848    listing_style += $(container + ' .tb_listing').is('.tb_compact_view')   ? ' tb_compact'  : '';
849
850    for(var k in responsive_params) {
851        responsive_keys.push(Number(k));
852    }
853    responsive_keys.sort(function(a, b){return a-b});
854
855    function getRestrictions(c_width) {
856        var result = {};
857
858        if (responsive_keys.length) {
859            $.each(responsive_keys, function(key, value) {
860                result = responsive_params[value];
861                if(c_width <= value) {
862                    return false;
863                }
864            });
865        }
866
867        return result;
868    }
869
870    var swiperDeferred = $.Deferred();
871    var SwiperObj = null;
872    var current_slides_per_view;
873
874    var buttons = function() {
875        if (SwiperObj === null) {
876            return;
877        }
878
879        if (SwiperObj.activeIndex < 1) {
880            $(container)
881                .find('.tb_prev').addClass('tb_disabled').end()
882                .find('.tb_next').removeClass('tb_disabled');
883        } else
884        if (SwiperObj.activeIndex + current_slides_per_view == items_count) {
885            $(container)
886                .find('.tb_next').addClass('tb_disabled').end()
887                .find('.tb_prev').removeClass('tb_disabled');
888        } else {
889            $(container).find('.tb_prev, .tb_next').removeClass('tb_disabled');
890        }
891    };
892
893    function createSlider(slides_per_view, slide_step) {
894
895        $slides.wrapAll('<div class="swiper-container"><div class="swiper-wrapper"></div></div>').wrap('<div class="swiper-slide"></div>');
896        $(container)
897            .addClass('has_slider')
898            .find('.tb_listing')
899            .addClass('tb_slider')
900            .removeClass('tb_slider_load');
901
902        if (pagination) {
903            $(container)
904                .find('.tb_listing')
905                .after('<div class="tb_slider_pagination' + listing_style + '"></div>');
906        }
907
908        $(container)
909            .find('.tb_listing')
910            .after('<div class="tb_slider_controls">' +
911                   '  <a class="tb_prev" href="javascript:;" title="' + tbApp._t('text_previous') + '">' +
912                   '    <svg><use xlink:href="' + window.location.href + '#chevron_thin" /></svg>
912' +
913                   '  </a>' +
914                   '  <a class="tb_next" href="javascript:;" title="' + tbApp._t('text_next') + '">' +
915                   '    <svg><use xlink:href="' + window.location.href + '#chevron_thin" /></svg>' +
916                   '  </a>' +
917                   '</div>');
918
919        SwiperObj = new Swiper(container + ' .swiper-container', {
920            setWrapperSize:         true,
921            slidesPerView:          slides_per_view,
922            slidesPerGroup:         slide_step,
923            speed:                  speed,
924            autoplay:               autoplay,
925            loop:                   loop,
926            loopAdditionalSlides:   slides_per_view,
927            pagination:             pagination,
928            paginationClickable:    true,
929            slideActiveClass:       '',
930            slideVisibleClass:      '',
931            slideNextClass:         '',
932            slidePrevClass:         '',
933            // roundLengths:           true,
934            bulletActiveClass:      'tb_active',
935            onInit: function (swiper) {
936                buttons();
937                $(container).find('.swiper-container').addClass('tb_slider_init');
938            },
939            onSlideChangeEnd: function (swiper){
940                buttons();
941            },
942            onTouchEnd: function (swiper){
943                buttons();
944            }
945        });
946
947        $(container).on('click', '.tb_prev, .tb_next', function() {
948            $(container).addClass('tbSliderInteracted');
949        });
950
951        $(container).on('mouseover', function() {
952            if (SwiperObj) {
953                SwiperObj.stopAutoplay();
954            }
955        });
956        $(container).on('mouseout', function() {
957            if (SwiperObj && !$(this).is('.tbSliderInteracted')) {
958                SwiperObj.startAutoplay();
959            }
960        });
961
962        swiperDeferred.resolve(SwiperObj);
963    }
964
965    function destroySlider() {
966        SwiperObj.destroy();
967        SwiperObj = null;
968        $(container).removeClass('has_slider')
969            .find('.swiper-slide').unwrap().unwrap().end()
970            .find('.swiper-slide > *').unwrap().end()
971            .find('.tb_slider_controls, .tb_slider_pagination').remove();
972        $(container).find('.tb_listing').removeClass('tb_slider');
973    }
974
975    function responsive() {
976
977        var $width_container = side_nav ? $(container).find('.tb_listing') : $(container),
978            restrictions = getRestrictions($width_container.width()),
979            slides_per_view = Number(restrictions.items_per_row);
980
981        if (items_count > slides_per_view && SwiperObj === null) {
982            // create
983            createSlider(slides_per_view, slide_step < slides_per_view ? slide_step : slides_per_view);
984            $(container).find('.tb_slider_pagination').addClass('tb_size_' + slides_per_view);
985            current_slides_per_view = slides_per_view;
986            buttons();
987        } else
988        if (items_count <= slides_per_view && SwiperObj !== null) {
989            // destroy
990            destroySlider();
991        } else
992        if (current_slides_per_view != slides_per_view && SwiperObj !== null) {
993            // reinit
994            SwiperObj.params.slidesPerView = slides_per_view;
995            SwiperObj.params.slidesPerGroup = slide_step < slides_per_view ? slide_step : slides_per_view;
996
997            $(container).find('.tb_slider_pagination')
998                .removeClass('tb_size_' + current_slides_per_view)
999                .addClass('tb_size_' + slides_per_view);
1000
1001            current_slides_per_view = slides_per_view;
1002            buttons();
1003        }
1004
1005        var $nav  = $(container).find('.tb_slider_controls');
1006
1007        if (!$nav.length) {
1008            return;
1009        }
1010
1011        if (side_nav) {
1012            tbApp.onWindowLoaded(function() {
1013                var nav_height  = $nav.find('> a:first-child').height(),
1014                    mod_left    = parseInt($(container).css('padding-left')),
1015                    mod_right   = parseInt($(container).css('padding-right'));
1016
1017                $nav.find('> a').css('margin-top', -($(container + ' .swiper-container').height()/2 + nav_height/2));
1018                $nav.find('> .tb_prev').css('margin-left', mod_left);
1019                $nav.find('> .tb_next').css('margin-right', mod_right);
1020                $nav.css('visibility', 'visible');
1021            });
1022        }
1023        else {
1024            var $container = $(container).is('.has_slider:not(.no_title)') ? $(container) : $(container).closest('.tb_wt_group'),
1025                mod_x      = $('html').attr('dir') == 'ltr' ? parseInt($heading.css('padding-right'))
1026                                               + parseInt($container.css('padding-right'))
1027                                               + parseInt($heading.css('margin-right'))
1028                                               : parseInt($heading.css('padding-left'))
1029                                               + parseInt($container.css('padding-left'))
1030                                               + parseInt($heading.css('margin-left')),
1031                mod_y      = ($heading.height() - $nav.outerHeight())/2 + parseInt($heading.css('padding-top')) + parseInt($container.css('padding-top'));
1032
1033            mod_x += mod_x >= 15 ? -5 : 0;
1034
1035            $nav.css('top', mod_y);
1036            $nav.css($('html').attr('dir') == 'ltr' ? 'right' : 'left', mod_x-4);
1037        }
1038    }
1039
1040    $(container).on('click', '.tb_prev', function (e) {
1041        e.preventDefault();
1042        SwiperObj.slidePrev();
1043        buttons();
1044    });
1045
1046    $(container).on('click', '.tb_next', function (e) {
1047        e.preventDefault();
1048        SwiperObj.slideNext();
1049        buttons();
1050    });
1051
1052    return {
1053        refresh: function() {
1054            if(false !== responsive_params) {
1055                responsive();
1056                if (false === init) {
1057                    tbUtils.onSizeChange(function() {
1058                        if ($(container)[0].getBoundingClientRect().width > 0) {
1059                            responsive();
1060                            if ($(container).parent().parent().hasClass('tb_tabs_content')) {
1061                                $(container).parent().css('height', '');
1062                            }
1063                        }
1064                    }, false, false, 'createItemSlider_' + container);
1065                    init = true;
1066                }
1067            } else
1068            if (false === init) {
1069                buttons();
1070                init = true;
1071            }
1072        },
1073        swiperPromise: swiperDeferred.promise()
1074    }
1075}
1076
1077/* -----------------------------------------------------------------
1078   L I G H T B O X
1079----------------------------------------------------------------- */
1080
1081function lightbox_gallery(id, slider, index, gallery_items, gallery_options) {
1082
1083    var pswpElement  = '';
1084        pswpElement += '<div id="lightbox_gallery_' + id + '" class="pswp" tabindex="-1" role="dialog" aria-hidden="true">';
1085        pswpElement += '  <div class="pswp__bg"></div>';
1086        pswpElement += '  <div class="pswp__scroll-wrap">';
1087        pswpElement += '    <div class="pswp__container">';
1088        pswpElement += '      <div class="pswp__item"></div>';
1089        pswpElement += '      <div class="pswp__item"></div>';
1090        pswpElement += '      <div class="pswp__item"></div>';
1091        pswpElement += '    </div>';
1092        pswpElement += '    <div class="pswp__ui pswp__ui--hidden">';
1093        pswpElement += '      <div class="pswp__top-bar">';
1094        pswpElement += '        <div class="pswp__counter"></div>';
1095        pswpElement += '        <a class="pswp__button pswp__button--close" title="Close (Esc)"></a>';
1096        pswpElement += '        <a class="pswp__button pswp__button--share" title="Share"></a>';
1097        pswpElement += '        <a class="pswp__button pswp__button--fs" title="Toggle fullscreen"></a>';
1098        pswpElement += '        <a class="pswp__button pswp__button--zoom" title="Zoom in/out"></a>';
1099        pswpElement += '        <div class="pswp__preloader">';
1100        pswpElement += '          <div class="pswp__preloader__icn">';
1101        pswpElement += '            <div class="pswp__preloader__cut">';
1102        pswpElement += '              <div class="pswp__preloader__donut"></div>';
1103        pswpElement += '            </div>';
1104        pswpElement += '          </div>';
1105        pswpElement += '        </div>';
1106        pswpElement += '      </div>';
1107        pswpElement += '      <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">';
1108        pswpElement += '        <div class="pswp__share-tooltip"></div>';
1109        pswpElement += '      </div>';
1110        pswpElement += '      <a class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)"></a>';
1111        pswpElement += '      <a class="pswp__button pswp__button--arrow--right" title="Next (arrow right)"></a>';
1112        pswpElement += '      <div class="pswp__caption">';
1113        pswpElement += '        <div class="pswp__caption__center"></div>';
1114        pswpElement += '      </div>';
1115        pswpElement += '    </div>';
1116        pswpElement += '  </div>';
1117        pswpElement += '</div>';
1118
1119    if (gallery_options === undefined) {
1120        gallery_options = {
1121            showHideOpacity:       true,
1122            // showAnimationDuration: false,
1123            // hideAnimationDuration: false,
1124            shareEl:               false,
1125            getThumbBoundsFn: function(index) {
1126                var thumbnail   = slider ? $('#' + id + ' .tb_slides')[0] : $('#' + id + ' .tb_gallery a')[index],
1127                    pageYScroll = window.pageYOffset || document.documentElement.scrollTop,
1128                    rect        = thumbnail.getBoundingClientRect(),
1129                    ratio       = $(thumbnail).data('ratio'),
1130                    x_mod       = 0,
1131                    y_mod       = 0;
1132
1133                if (thumbnail.hasAttribute('data-ratio')) {
1134                    x_mod += ratio > 1 ? Math.round($(thumbnail).height() * ratio) - $(thumbnail).width()  : 0;
1135                    y_mod += ratio < 1 ? Math.round($(thumbnail).width()  / ratio) - $(thumbnail).height() : 0;
1136                }
1137
1138                return {x:rect.left - x_mod/2, y:rect.top + pageYScroll  - y_mod/2, w:rect.width + x_mod};
1139            }
1140        };
1141
1142    }
1143
1144    gallery_options.index = slider ? slider.relative.activeSlide : index;
1145
1146    var fullscreen_gallery = new PhotoSwipe (
1147        $(pswpElement).appendTo('body')[0],
1148        PhotoSwipeUI_Default,
1149        gallery_items,
1150        gallery_options
1151    );
1152
1153    if (slider) {
1154        fullscreen_gallery.listen('afterChange', function () {
1155            slider.toCenter(fullscreen_gallery.getCurrentIndex(), true);
1156        });
1157    }
1158
1159    fullscreen_gallery.listen('destroy', function() {
1160        $('#lightbox_gallery_' + id).remove();
1161    });
1162
1163    fullscreen_gallery.init();
1164
1165}
1166
1167/* -----------------------------------------------------------------
1168   C O U N T E R
1169----------------------------------------------------------------- */
1170
1171function create_countdown(container, server_date, timezone) {
1172    $(container).find('.tb_counter_time').each(function() {
1173        var finalDate = new Date($(this).data('special-price-end-date')),
1174            $counter  = $(this);
1175
1176        $counter.countdown({
1177            until:  finalDate,
1178            serverSync: function() {
1179                return new Date(server_date);
1180            },
1181            timezone: timezone,
1182            layout: '{d<}<span class="tb_counter_days">{dn}</span>{d>}'   +
1183                    '<span class="tb_counter_hours">{hn}</span>'   +
1184                    '<span class="tb_counter_minutes">{mnn}</span>' +
1185                    '<span class="tb_counter_seconds">{snn}</span>'
1186        });
1187    });
1188}
1189
1190/* -----------------------------------------------------------------
1191   P R O D U C T   H O V E R
1192----------------------------------------------------------------- */
1193
1194function item_hover(container, active_elements, hover_elements, hover_style) {
1195
1196    $(container).find('.tb_grid_view').addClass('tbHoverReady');
1197
1198    // Append
1199    if(hover_style == 'append') {
1200        $(container + ' .tb_grid_view:not(".tb_slider")').find('> div').each(function() {
1201            var $item = $(this);
1202            var $hover_content = $item.clone();
1203
1204            $hover_content.find(hover_elements).remove();
1205            $hover_content.find('div:not(:has(*)):not(.description)').remove();
1206            $hover_content.find('img')
1207                .attr('src', $hover_content.find('img').data('src'))
1208                .removeClass('lazyload')
1209                .removeAttr('data-aspectratio')
1210                .css('opacity', 100)
1211                .css('height', '');
1212
1213            $item.find(active_elements).remove();
1214            $item.find('div:not(:has(*)):not(.description)').remove();
1215
1216            $item.hover(
1217                function() {
1218                    $item.append('<div class="tb_item_hovered tb_item_info_hover">' + $hover_content.html() + '</div>');
1219                }, function() {
1220                    $item.find('.tb_item_hovered').remove();
1221                }
1222            );
1223        });
1224    }
1225
1226    // Flip && Overlay
1227    if(hover_style == 'flip' || hover_style == 'overlay') {
1228        $(container + ' .tb_grid_view').find('> div').each(function() {
1229            var $item = $(this);
1230
1231            var $active_content = $item.clone();
1232            var $hover_content = $item.clone();
1233
1234            $active_content.find(active_elements).remove();
1235            $active_content.find('div:not(:has(*)):not(.description)').remove();
1236            $active_content.find('div:not(:has(*)):not(.description)').remove();
1237
1238            $hover_content.find(hover_elements).remove();
1239            $hover_content.find('div:not(:has(*)):not(.description)').remove();
1240            $hover_content.find('div:not(:has(*)):not(.description)').remove();
1241
1242            $item.children().remove();
1243
1244            $item.append('<div class="tb_' + hover_style + '"><div class="tb_item_info_active tb_front">' + $active_content.html() + '</div><div class="tb_item_info_hover tb_back">' + $hover_content.html() + '</div></div>');
1245
1246            $item.find('div:not(:has(*)):not(.description)').remove();
1247        });
1248    }
1249}
1250
1251/* -----------------------------------------------------------------
1252   T H U M B   H O V E R
1253 ----------------------------------------------------------------- */
1254
1255function thumb_hover(container, hover_style) {
1256
1257    if(hover_style != 'flip' && hover_style != 'overlay') {
1258        return;
1259    }
1260    // Flip & overlay
1261    $(container + ' .tb_products.tb_listing').find('> div').each(function() {
1262
1263        if (!$(this).find(".image_hover").length) {
1264            return true;
1265        }
1266        $(this).find('.image_hover img').each(function() {
1267            $(this).attr('src', $(this).data('src')).css('opacity', 1);
1268        });
1269        $(this)
1270            .find('.image').addClass('tb_front').end()
1271            .find('.image_hover').addClass('tb_back').end()
1272            .find('.image, .image_hover').wrapAll('<div class="image tb_' + hover_style + '"></div>');
1273    });
1274}
1275
1276/* -----------------------------------------------------------------
1277   C O O K I E   P O L I C Y
1278----------------------------------------------------------------- */
1279
1280function cookie_policy(policy_text) {
1281
1282    if ($.cookie('agreed_with_cookie_policy')) {
1283        return;
1284    }
1285
1286    noty({
1287        text: '<h3>' + tbApp._t('text_cookie_policy_title') + '</h3><p>' + policy_text + '</p>',
1288        layout: tbApp['/tb/msg_position'],
1289        closeOnSelfClick: false,
1290        modal: false,
1291        buttons: [{
1292            type: 'btn',
1293            text: tbApp._t('text_cookie_policy_button'),
1294            click: function() {
1295                $.cookie('agreed_with_cookie_policy', '1', { expires: 30 });
1296                $.noty.closeAll();
1297            }
1298        }],
1299        closeButton: false,
1300        timeout: false,
1301        animateOpen: {opacity: 'toggle'},
1302        animateClose: {opacity: 'toggle'},
1303        close_speed: 500,
1304        onClose: function() {
1305            $(document).unbind('touchmove.noty');
1306        }
1307    });
1308}
1309
1310/* -----------------------------------------------------------------
1311   D R O P D O W N   M E N U
1312----------------------------------------------------------------- */
1313
1314function menu_position($dropdown, offset) {
1315
1316    var menu_space  = $dropdown.outerWidth() + offset.left,
1317        margin_left = menu_space > tbApp.windowWidth ? tbApp.windowWidth - menu_space - 30 : 0;
1318
1319    margin_left    += offset.left < 15 ? Math.abs(offset.left) + 15 : 0;
1320
1321    if (margin_left == 0) {
1322        return;
1323    }
1324
1325    if ($('html').is('[dir="ltr"]')) {
1326        $dropdown.css('margin-left', margin_left);
1327    } else {
1328        $dropdown.css('margin-right', -margin_left);
1329    }
1330}
1331
1332function megamenu_position($nav, $menu, $dropdown, $relativeTo, orientation) {
1333
1334    var menu_left,
1335        menu_top,
1336        menu_width,
1337        current_site_width = tbApp['/tb/maximum_width'];
1338
1339    if (tbApp.windowWidth - 60 <= tbApp['/tb/maximum_width']) {
1340        current_site_width = tbApp.windowWidth - 60;
1341    }
1342
1343    if ($menu.parent().hasClass('dropdown-menu')) {
1344        orientation = 'vertical';
1345    }
1346
1347    if ($nav.data('relative_to') == 'content' && orientation == 'horizontal' && $relativeTo.width() < current_site_width) {
1348        menu_left  = $relativeTo.offset().left;
1349        menu_left -= $menu.offset().left; // -1 removed
1350        menu_left += parseInt($relativeTo.css('padding-left'));
1351        menu_top   = 0;
1352        menu_width = $relativeTo.width();
1353    } else {
1354        menu_left    = (tbApp.windowWidth - current_site_width) / 2 - parseInt($menu.offset().left); // -1 removed
1355        menu_left  += $nav.data('relative_to') == 'content' && $relativeTo.width() < current_site_width ? parseInt($relativeTo.css('padding-left')) : 0;
1356        menu_left  += $('html').attr('dir') == 'rtl' ? -7 : 0;
1357        menu_left   = orientation == 'horizontal' ? menu_left : 0;
1358        menu_top    = 0;
1359        //menu_top   += orientation == 'vertical' ? $nav.offset().top - $menu.offset().top : 0;
1360        menu_width  = current_site_width;
1361        menu_width += $nav.data('relative_to') == 'content' && $relativeTo.width() < current_site_width ? -parseInt($relativeTo.css('padding-left')) : 0;
1362        menu_width += $nav.data('relative_to') == 'content' && $relativeTo.width() < current_site_width ? -parseInt($relativeTo.css('padding-right')) : 0;
1363        menu_width += !orientation == 'vertical' && !$menu.parent().is('.dropdown-menu') ? -$nav.width() : 0;
1364        menu_width += $menu.parent().is('.dropdown-menu') ? -$menu.parent().innerWidth() : 0;
1365    }
1366    if ($nav.data('relative_to') == 'block' && orientation == 'vertical' && $menu.hasClass('tb_megamenu')) {
1367        if ($menu.offset().top - $nav.closest('div').offset().top < $dropdown.outerHeight()) {
1368            menu_top -= $menu.offset().top - $nav.closest('div').offset().top;
1369        }
1370    }
1371
1372    $dropdown
1373        .css('margin-top', menu_top);
1374
1375    if (!$menu.is('.tb_auto_width') || $menu.data('dropdown-width') > menu_width) {
1376        $dropdown
1377            .css('margin-left', menu_left)
1378            .css('width', menu_width);
1379    }
1380
1381    if ($menu.is('.tb_tabbed_menu')) {
1382        var $link = $dropdown.find('> .tb_tabs > .nav-tabs > li.active'),
1383            tab   = '#' + $link.find('> a').data('target');
1384
1385        $dropdown.find('> .tb_tabs > .nav-tabs').css('min-width', $menu.width());
1386    }
1387}
1388
1389function dropdown_menu(selector, menu, direction, delay) {
1390
1391    if (selector === undefined) {
1392        selector = '.dropdown-menu';
1393    }
1394
1395    if (menu === undefined) {
1396        menu = '> li';
1397    }
1398
1399    if (direction === undefined) {
1400        direction = 'right';
1401    }
1402
1403    if (delay === undefined) {
1404        delay = 0;
1405    }
1406
1407    $(selector).menuAim({
1408        triggerEvent:       'hover',
1409        rowSelector:        menu,
1410        submenuDirection:   direction,
1411        tolerance:          75,
1412        activationDelay:    delay,
1413        activateCallback: function(row) {
1414
1415            var tb_sticky_parent;
1416
1417            if ($(row).parent().is('.tb_grid_view') || $(row).parent().is('.tab-content')) {
1418                return;
1419            }
1420
1421            $(row).addClass('tb_hovered');
1422
1423            if ($(row).closest('#header').length) {
1424                tb_navigation_hovered = true;
1425            }
1426            if ($(row).closest('.tbSticky').length) {
1427                tb_sticky_parent = true;
1428            }
1429
1430            var $nav         = $(row).closest('.nav'),
1431                $menu        = $(row),
1432                $dropdown    = $(row).find('.dropdown-menu').first(),
1433                $relativeTo  = $(row).closest('[class*="tb_area_"], .tbMobileMenu'),
1434                orientation  = $nav.length && $nav.hasClass('nav-horizontal') ? 'horizontal' : 'vertical';
1435
1436            if (!$dropdown.length) {
1437                return;
1438            }
1439
1440            $dropdown
1441                .css('margin-left',  '')
1442                .css('margin-right', '');
1443
1444            // Regular menu
1445
1446            var offset = $dropdown.offset();
1447
1448            if (tb_sticky_parent && $menu.parent('.nav').length && ($dropdown.outerHeight() + offset.top - $(window).scrollTop > window.innerHeight)) {
1449                $dropdown.css('max-height', (window.innerHeight - 110));
1450                $dropdown.css('overflow-y', 'auto');
1451            }
1452
1453            if (!$nav.length || !$menu.hasClass('tb_megamenu')) {
1454                menu_position($dropdown, offset);
1455
1456                return;
1457            }
1458
1459            // Megamenu
1460
1461            megamenu_position($nav, $menu, $dropdown, $relativeTo, orientation);
1462
1463        },
1464        deactivateCallback: function(row) {
1465            $(row).removeClass('tb_hovered')
1466                .find('.dropdown-menu').first().css('margin-left', '');
1467
1468            tb_navigation_hovered = false;
1469        }
1470    });
1471}
1472
1473/* -----------------------------------------------------------------
1474   T A B B E D   M E N U
1475----------------------------------------------------------------- */
1476
1477function tabbed_menu(menu) {
1478
1479    if (menu === undefined) {
1480        return false;
1481    }
1482
1483    $('#' + menu).find('.nav-tabs').each(function() {
1484        var $menu      = $('#' + menu);
1485
1486
1487        $(this).menuAim({
1488            triggerEvent:       'hover',
1489            rowSelector:        '> li',
1490            submenuDirection:   'right',
1491            tolerance:          50,
1492            activationDelay:    0,
1493            activateCallback: function(row) {
1494                var $tab       = $('#' + $(row).find('> a').data('target')),
1495                    $container = $(row).closest('.tb_tabs');
1496
1497                $container
1498                    .find('.active').removeClass('active').end()
1499                    .find('.tb_opened').removeClass('tb_opened');
1500                $(row).addClass('active');
1501                $tab.addClass('tb_opened');
1502                $menu.toggleClass('tb_first_tab_selected', $menu.find('.nav-tabs > li:first-child').is('.active'));
1503            }
1504        });
1505    });
1506}
1507
1508/* -----------------------------------------------------------------
1509   Q U I C K V I E W
1510----------------------------------------------------------------- */
1511
1512var tbShowQuickView,tbResizeQuickView;
1513
1514function tbQuickView(product_id) {
1515
1516    var $product = $('.product-id_' + product_id).parent(),
1517        $button  = $product.find('.tb_button_quickview a'),
1518        width    = document.querySelector('body').clientWidth - 40;
1519
1520    if ($button.data('dialog')) {
1521        $('#' + $button.data('dialog')).dialog('open');
1522    } else {
1523        var dialog_id = 'tbQuickviewModal-' + Math.floor(Math.random() * 100) + 1,
1524            html      = '';
1525
1526        $product
1527            .find('.tb_button_quickview .wait').remove().end()
1528            .removeClass('tb_product_loaded tb_quickview_loaded')
1529            .addClass('tb_product_loading tb_quickview_loading')
1530            .find('.tb_button_quickview').addClass('tb_disabled')
1531            .find('a').prepend('<span class="wait"></span>');
1532
1533        html += '<div id="' + dialog_id + '" class="modal-body">';
1534        html += '  <a class="close" href="javascript:void(0);"></a>';
1535        html += '  <iframe scrolling="none"></iframe>';
1536        html += '</div>';
1537
1538        $('body').append(html);
1539
1540        var $iframe = $('#' + dialog_id).find('iframe');
1541
1542        tbShowQuickView = function(height) {
1543            $iframe.height(height);
1544            $('#' + dialog_id).dialog({
1545                width: 900,
1546                maxWidth: 900,
1547                height: 'auto',
1548                modal: true,
1549                fluid: true, //new option
1550                resizable: false,
1551                dialogClass: 'modal--quickview',
1552                open: function() {
1553                    var $dialog = $(this);
1554
1555                    fluidDialog();
1556
1557                    console.log($dialog);
1558
1559                    $dialog.find('.close').bind('click', function() {
1560                        $dialog.dialog("close");
1561                    });
1562                }
1563            });
1564
1565            tbUtils.onSizeChange(fluidDialog, 'tbFluidDialog', true);
1566        };
1567        tbResizeQuickView = function(height) {
1568            $iframe.height(height);
1569        };
1570
1571        var url = $product.find('.name a, h4 a').attr('href');
1572
1573        if (!url.length) {
1574            url = 'index.php?route=product/product&tb_quickview=1&product_id=' + product_id;
1575        } else {
1576            if (url.indexOf('?') > -1) {
1577                url += '&';
1578            } else {
1579                url += '?';
1580            }
1581
1582            url += 'tb_quickview=1';
1583        }
1584
1585        $iframe
1586            .attr('src', url + '&width=' + width)
1587            .on('load', function () {
1588                $product
1589                    .removeClass('tb_product_loading tb_quickview_loading')
1590                    .find('.tb_disabled').removeClass('tb_disabled')
1591                    .find('.wait').remove();
1592            });
1593
1594        $button.data('dialog', dialog_id);
1595    }
1596}
1597
1598/* -----------------------------------------------------------------
1599   B O O T
1600----------------------------------------------------------------- */
1601
1602function bootApp() {
1603
1604    var $body = $('body');
1605
1606    /* ----------------------------------------
1607       Touch class
1608    ---------------------------------------- */
1609
1610    if (tbUtils.is_touch) {
1611        tbUtils.addClass(document.querySelector('body'), 'is_touch');
1612    } else {
1613        tbUtils.addClass(document.querySelector('body'), 'no_touch');
1614    }
1615
1616    /* ----------------------------------------
1617       System
1618     ---------------------------------------- */
1619
1620    // Form error highlight
1621
1622    $('span.error, .text-danger').each(function() {
1623        if ($(this).parent().is('.help') || $(this).parent().is('.help-block')) {
1624            return;
1625        }
1626        $(this).closest('tr, .form-group').addClass('has-error');
1627    });
1628
1629    // Close alert messages
1630
1631    $body.on('click', '.alert-dismissible, .success, .attention, .warning, .information', function() {
1632        $(this).fadeTo(200, 0, function() {
1633            $(this).slideUp(300, function() {
1634                $(this).remove();
1635            });
1636        });
1637    });
1638
1639    // Currency & Language
1640
1641    $('#currency_form').on('click', 'a[data-currency-code]', function() {
1642        changeCurrency($(this));
1643    });
1644
1645    $('#language_form').on('click', 'a[data-language-code]', function() {
1646        changeLanguage($(this));
1647    });
1648
1649    // Site search
1650
1651    $('#search_button').bind('click', function() {
1652        moduleSearch($(this));
1653    });
1654
1655    $('#filter_keyword').bind('keydown', function(e) {
1656        if (e.keyCode == 13) {
1657            var $element = $(this);
1658
1659            tbApp.once('filterKeywordEnter', function(context) {
1660                if (context.redirect) {
1661                    moduleSearch($element);
1662                }
1663            });
1664
1665            tbApp.trigger('filterKeywordEnter', [{redirect: true}]);
1666        }
1667    });
1668
1669    // Jquery UI spinner
1670
1671    $.widget("ui.spinner", $.ui.spinner, {
1672        _buttonHtml: function() {
1673            return '' +
1674                '  <div class="btn-group-vertical">' +
1675                '    <a class="ui-spinner-button ui-spinner-up btn btn-default">' +
1676                '      <span class="ui-icon ' + this.options.icons.up + '">&#9650;</span>' +
1677                '    </a>' +
1678                '    <a class="ui-spinner-button ui-spinner-down btn btn-default">' +
1679                '      <span class="ui-icon ' + this.options.icons.down + '">&#9660;</span>' +
1680                '    </a>' +
1681                '</div>';
1682        },
1683        _uiSpinnerHtml: function() {
1684            return '<span class="ui-spinner input-group"></span>';
1685        }
1686    });
1687
1688    // Modal dialog
1689
1690    $body.on('click.tb_dialog', '.colorbox, .fancybox, .agree, .tb_popup', function() {
1691        tbCreateDialog($(this));
1692
1693        return false;
1694    })
1695
1696    /* ----------------------------------------
1697       Theme
1698     ---------------------------------------- */
1699
1700    // Element queries
1701
1702    element_query('.responsive');
1703    element_query('.cart-info', '500,300,0');
1704    element_query('.tb_listing_options', '1000,650,350,0');
1705    element_query('.tb_wt_product_options_system', '1000,300,0');
1706    element_query('.tb_system_search_box', '550,0');
1707
1708    if(tbUtils.is_touch) {
1709        $body
1710            .on('click', function(e) {
1711                $('.dropdown').removeClass('tb_hovered');
1712                $('.tb_toggle').removeClass('tb_active');
1713            })
1714            .on('click', '.dropdown > a, .dropdown-toggle, .tb_wt_header_cart_menu_system .dropdown > h3', function(e) {
1715
1716                var $menu     = $(this).parent(),
1717                    $nav      = $menu.closest('.nav'),
1718                    $dropdown = $menu.find('.dropdown-menu').first();
1719
1720                if ($(this).siblings('.dropdown-menu,ul')[0].getBoundingClientRect().width < 1) {
1721                    $('.dropdown').removeClass('tb_hovered');
1722                    $(this).parents('.dropdown').addClass('tb_hovered');
1723                    $(this).parent().find('> .tb_toggle').addClass('tb_active');
1724
1725                    if (!$dropdown) {
1726                        return;
1727                    }
1728                    if (!$nav.length || !$menu.hasClass('tb_megamenu')) {
1729
1730                        $dropdown
1731                            .css('margin-left',  '')
1732                            .css('margin-right', '');
1733
1734                        var offset = $dropdown.offset();
1735
1736                        menu_position($dropdown, offset);
1737                    }
1738                    if ($menu.is('.tb_megamenu')) {
1739                        var $relativeTo = $menu.closest('[class*="tb_area_"], .tbMobileMenu'),
1740                            orientation = $nav.length && $nav.hasClass('nav-horizontal') ? 'horizontal' : 'vertical';
1741
1742                        megamenu_position($nav, $menu, $dropdown, $relativeTo, orientation);
1743                    }
1744                }
1745                else {
1746                    $(this).parent().removeClass('tb_hovered');
1747                    $(this).parent().find('> .tb_toggle').removeClass('tb_active');
1748                    if ($(this).attr('href')) {
1749                        window.location = $(this).attr('href');
1750                    }
1751                }
1752
1753                return false;
1754            })
1755            .on('click', 'li > [data-target]', function(e) {
1756                var $menu = $(this).parent(),
1757                    $nav  = $(this).closest('.nav'),
1758                    $tab  = $('#' + $(this).data('target')),
1759                    $tabs = $tab.closest('.tab-content');
1760
1761                if (!$menu.is('.active')) {
1762                    $nav.find('.active').removeClass('active');
1763                    $tabs.find('.tb_opened').removeClass('tb_opened');
1764                    $menu.addClass('active');
1765                    $tab.addClass('tb_opened');
1766                }
1767                else {
1768                    if ($(this).attr('href') && $(this).attr('href') != '#' && $(this).attr('href') != 'javascript:;') {
1769                        window.location = $(this).attr('href');
1770                    }
1771                }
1772
1773                return false;
1774            });
1775    }
1776
1777    $body
1778        .on('click', '.dropdown > .tb_toggle', function() {
1779            if ($(this).siblings('.dropdown-menu,ul')[0].getBoundingClientRect().width < 1) {
1780                $(this).parent().addClass('tb_hovered').find('> .tb_toggle').addClass('tb_active');
1781            } else {
1782                $(this).parent().removeClass('tb_hovered').find('> .tb_toggle').removeClass('tb_active');
1783            }
1784
1785            return false;
1786        })
1787        .on('click', '.tab-content > .tb_toggle', function() {
1788            if ($(this).next('.tab-pane')[0].getBoundingClientRect().width < 1) {
1789                $(this)
1790                    .addClass('tb_active')
1791                    .next('.tab-pane').addClass('active');
1792            } else {
1793                $(this)
1794                    .removeClass('tb_active')
1795                    .next('.tab-pane').removeClass('active');
1796            }
1797
1798            return false;
1799        });
1800
1801    // Dropdown menus
1802    dropdown_menu('.dropdown-menu'      , '> li', tbApp.lang_dir, 100);
1803    dropdown_menu('.tb_hidden_menu > ul', '> li', tbApp.lang_dir, 100);
1804    dropdown_menu('.nav-stacked'        , '> li', tbApp.lang_dir, 100);
1805    dropdown_menu('.nav:not(.nav-stacked):not(.nav-tabs)' , '> li', 'below', 100);
1806
1807    // Responsive header
1808    responsive_header();
1809
1810    $('#wrapper')
1811        .find('.tb_wt_cart > .nav').each(function() {
1812            var $nav = $(this),
1813                url  = window.location.href;
1814
1815    $nav.find('> .heading a').one('mouseenter', function() {
1816        $nav
1817            .addClass('active')
1818            .load('index.php?route=module/cart .nav > *')
1819            .on('mouseleave', function() {
1820                $(this).removeClass('active');
1821            });
1822        });
1823    });
1824
1825}
1826
1827window.tbBoot = function() {
1828    $(window).on('load', function(){
1829        tbApp.trigger("tbWindowLoaded");
1830        $(document.body).trigger("sticky_kit:recalc");
1831    });
1832
1833    $(document).ready(function() {
1834        tbApp.trigger("tbScriptLoadedInit");
1835
1836        bootApp();
1837
1838        tbApp.trigger("tbScriptLoaded");
1839
1840        if (tbApp['/tb/lazyload']) {
1841            lazySizes.init();
1842        }
1843    });
1844};
1845
1846if (window.tbCriticalLoaded) {
1847    window.tbBoot();
1848}

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.