Sticky header not able to scroll

ThemeBurn SupportForumsOpenCart ThemesBurnEngineSticky header not able to scroll

This topic has been marked as not resolved.

Sticky header not able to scroll /catalog/view/theme/BurnEngine/javascript/common.js do you know which lines I need to change

/* -----------------------------------------------------------------
   S Y S T E M
----------------------------------------------------------------- */

function getURLVar(key) {
    var value = [];
    var query = String(document.location).split('?');
    if (query[1]) {
        var part = query[1].split('&');
        for (i = 0; i < part.length; i++) {
            var data = part[i].split('=');
            if (data[0] && data[1]) {
                value[data[0]] = data[1];
            }
        }
        if (value[key]) {
            return value[key];
        } else {
            return '';
        }
    }
}

// Cart add remove functions

function addToCart(product_id, quantity) {
    var url      = window.location.href,
        $product = $('.product-id_' + product_id).parent();

    quantity = typeof(quantity) != 'undefined' ? quantity : 1;

    $.ajax({
        url: 'index.php?route=checkout/cart/add',
        type: 'post',
        data: 'product_id=' + product_id + '&quantity=' + quantity,
        dataType: 'json',
        beforeSend: function() {
            $product
                .find('.wait').remove().end()
                .removeClass('tb_product_loaded tb_add_to_cart_loaded')
                .addClass('tb_product_loading tb_add_to_cart_loading')
                .find('.tb_button_add_to_cart').append('<span class="wait"></span>');
        },
        success: function(json) {
            $('.success, .warning, .attention, .information, .error').remove();
            if (json['redirect']) {
                location = json['redirect'];
            } else
            if (json['error']) {
                for (var first in json.error) break;
                displayNotice('product', 'failure', product_id, json.error[first]);
            } else
            if (json['success']) {
                setTimeout(function () {
                    $product
                        .removeClass('tb_product_loading tb_add_to_cart_loading')
                        .find('.tb_button_add_to_cart .wait').remove().end()
                        .addClass('tb_product_loaded tb_add_to_cart_loaded');

                    setTimeout(function () {
                        $product
                            .removeClass('tb_product_loaded tb_add_to_cart_loaded')
                    }, 5000);
                }, 500);
                $.get('index.php?route=module/cart', function(result) {
                    var $items  = $(result).find('.content').clone(),
                        $title  = $(result).find('.heading').clone();

                    $('.tb_wt_header_cart_menu_system .heading').replaceWith($title);
                    $('.tb_wt_header_cart_menu_system .content').replaceWith($items);
                    tbApp.triggerResizeCallbacks();
                });
                displayNotice('product', 'success', product_id, json['success']);
            }
        }
    });
}

function removeFromCart(product_id) {
    $.get('index.php?route=module/cart&remove=' + product_id, function(result) {
        var $items  = $(result).find('.content').clone(),
            $title  = $(result).find('.heading').clone();

        $('.tb_wt_header_cart_menu_system .heading').replaceWith($title);
        $('.tb_wt_header_cart_menu_system .content').replaceWith($items);
        tbApp.triggerResizeCallbacks();
    });
}

function addToWishList(product_id) {
    var $product = $('.product-id_' + product_id).parent();

    $.ajax({
        url: 'index.php?route=account/wishlist/add',
        type: 'post',
        data: 'product_id=' + product_id,
        dataType: 'json',
        beforeSend: function() {
            $product
                .find('.wait').remove().end()
                .removeClass('tb_product_loaded tb_wishlist_loaded')
                .addClass('tb_product_loading tb_wishlist_loading')
                .find('.tb_button_wishlist').append('<span class="wait"></span>');
        },
        success: function(json) {
            $('.success, .warning, .attention, .information').remove();
            if (!tbApp['/tb/is_customer_logged']) {
                displayNotice('wishlist', 'failure', product_id, json['success']);
            } else
            if (json['success']) {
                displayNotice('wishlist', 'success', product_id, json['success']);
            }
            if (json['info']) {
                displayNotice('wishlist', 'failure', product_id, json['info']);
            }

            setTimeout(function () {
                $product
                    .removeClass('tb_product_loading tb_wishlist_loading')
                    .find('.tb_button_wishlist .wait').remove().end()
                    .addClass('tb_product_loaded tb_wishlist_loaded');

                setTimeout(function () {
                    $product
                        .removeClass('tb_product_loaded tb_wishlist_loaded')
                }, 5000);
            }, 500);

            $('.wishlist-total').html(json['total']);

            Array.prototype.forEach.call(document.querySelectorAll('a.wishlist_total, li.wishlist_total > a > .tb_text'), function(el) {
                var number = json['total'].replace(/[^0-9]/g, '');

                $(el).find('.tb_items').remove();
                $(el).append('<span class="tb_items">' + number + '</span>');
            });
        }
    });
}

function addToCompare(product_id) {
    $.ajax({
        url: 'index.php?route=product/compare/add',
        type: 'post',
        data: 'product_id=' + product_id,
        dataType: 'json',
        success: function(json) {
            if (json['success']) {
                displayNotice('compare', 'success', product_id, json['success']);
                $('#compare-total').html(json['total']);

                Array.prototype.forEach.call(document.querySelectorAll('a.tb_compare_total, li.tb_compare_total > a > .tb_text'), function(el) {
                    var number = json['total'].replace(/[^0-9]/g, '');

                    $(el).find('.tb_items').remove();
                    $(el).append('<span class="tb_items">' + number + '</span>');
                });
            }
        }
    });
}

// Search

function moduleSearch($element) {
    var filter_name = $element.parent().find('input[name=search]').val();

    if (filter_name) {
        location = $('base').attr('href') + 'index.php?route=product/search&search=' + encodeURIComponent(filter_name);
    }
}

// Currency & Language

function changeLanguage($link) {
    $('input[name=\'language_code\']').attr('value', $link.data('language-code'));

    if ($link.attr("href") == "javascript:;") {
        $link.closest('form').submit()
    }
}

function changeCurrency($link) {
    $('input[name=\'currency_code\']').attr('value', $link.data('currency-code'));
    $link.closest('form').submit()
}

// Responsive Dialog

function fluidDialog() {

    $(".ui-dialog:visible").each(function () {
        var $this = $(this);
        var dialog = $this.find(".ui-dialog-content").data("ui-dialog");

        if (dialog.options.fluid) {
            var wWidth = $(window).width();
            if (wWidth < dialog.options.maxWidth + 50) {
                $this.css("max-width", "90%");
            } else {
                $this.css("max-width", dialog.options.maxWidth);
            }
            dialog.option("position", dialog.options.position);
        }
    });
}

function createDialogInstance($element) {

    var title = $element.attr('alt') ? $element.attr('alt') : $element.text();

    return $('<div></div>')
        .appendTo('body')
        .addClass('tb_loading')
        .append('<span class="wait"></span>')
        .load($element.attr('href'), function() {
            $(this).removeClass('tb_loading').wrap('<div class="overflow_text"></div>');
        })
        .dialog({
            title: title,
            width: 600,
            maxWidth: 600,
            height: 'auto',
            maxHeight: document.documentElement.clientHeight - 60,
            modal: true,
            fluid: true,
            resizable: false,
            position: {
                my: "top+30",
                at: "top",
                of: window
            },
            draggable: false,
            open: function() {
                fluidDialog();
            }
        });
}

var dialogCreated = false;

function tbCreateDialog($element) {

    if (!dialogCreated) {
        var el_id = 'tbFluidDialog_' + String(Math.random());
        if ($element.attr("id")) {
            el_id = $element.attr("id");
        }
        tbUtils.onSizeChange(fluidDialog, 'tbFluidDialog', true, el_id);
    }

    if (!$element.data('dialogInstance')) {
        $element.data('dialogInstance', createDialogInstance($element));
        dialogCreated = true;
    }

    $element.data('dialogInstance').dialog('open');
}

/* -----------------------------------------------------------------
   R E S I Z E   E V E N T S
----------------------------------------------------------------- */

tbApp.onScriptLoaded(function() {
    tbApp.windowWidth = tbWindowWidth;
    tbUtils.onSizeChange(function() {
        tbApp.windowWidth = window.innerWidth;
    }, false, false, 'windowWidth');
    includeSvgResource("catalog/view/theme/" + tbApp["/tb/basename"] + "/image/icons.svg", 2);
});

/* -----------------------------------------------------------------
   G L O B A L   V A R S
----------------------------------------------------------------- */

var tb_navigation_hovered = false;

/* -----------------------------------------------------------------
   N O T I F I C A T I O N S
----------------------------------------------------------------- */

var displayNotice = tbRootWindow.displayNotice !== undefined ? tbRootWindow.displayNotice : function(context, type, product_id, message) {

    var stack = Number(tbApp['/tb/msg_stack']);
    var thumb;

    if (!stack) {
        $.noty.closeAll();
    }

    var $product = $(".product-id_" + product_id).first().parent();

    if (!$product.length) {
        $product = $('.tb_wt_product_images_system');
        thumb = !$product.find('.image img').length ? $product.find('.thumbnail img').attr('src') : $product.find('.image img').attr('src');
    } else {
        thumb = $product.find(".image img").attr("src");
    }

    if (!thumb) {
        thumb = tbApp['/tb/no_image'];
    }

    var buttons_config = [{
        type: 'btn', text: tbApp._t('text_continue'), click: function() {
            $.noty.closeAll();
        }
    }];

    var modal = false;
    var w_width  = window.innerWidth;
    var w_height = window.innerHeight;

    if (w_width <= 768 && w_height <= 768) {
        modal = true;
    }

    var msg_tpl;

    if ($product.length && thumb) {
        msg_tpl = '\
            <h3>\
              <svg class="tb_icon tb_main_color_bg"><use xlink:href="{{url}}#{{icon}}" /></svg>\
              {{title}}\
            </h3>\
            <div class="noty_text_body">\
              <a class="thumbnail" href=""><img src="{{thumb_src}}"></a>\
              <p>{{contents}}</p>\
            </div>';
    } else {
        msg_tpl = '\
            <h3>\
              <svg class="tb_icon tb_main_color_bg"><use xlink:href="{{url}}#{{icon}}" /></svg>\
              {{title}}\
            </h3>\
            <p>{{contents}}</p>';
    }

    var showNotice = function(title) {
        var template_vars = {
            icon:      type == 'success' ? 'check' : 'close',
            title:     title,
            contents:  message,
            thumb_src: thumb,
            url:       window.location.href
        };

        noty({
            text: $.tim(msg_tpl, template_vars),
            layout: tbApp['/tb/msg_position'],
            closeOnSelfClick: false,
            modal: modal,
            buttons: modal ? buttons_config : false,
            closeButton: !modal,
            timeout: modal ? false : Number(tbApp['/tb/msg_timeout']),
            animateOpen: {opacity: 'toggle'},
            animateClose: {opacity: 'toggle'},
            close_speed: stack ? 500 : 0,
            onClose: function() {
                $(document).unbind('touchmove.noty');
            }
        });
    };

    if (type == 'failure') {
        showNotice(tbApp._t('text_failure'));
        return;
    }

    switch (context) {
        case 'product':
            buttons_config = [{
                type: 'btn', text: tbApp._t('text_continue_shopping'), click: function() {
                    $.noty.closeAll();
                }
            },{
                type: 'btn', text: tbApp._t('text_shopping_cart'), click: function() {
                    window.location = tbApp['/tb/url/shopping_cart'];
                }
            }];

            showNotice(tbApp._t('text_cart_updated'));
            break;
        case 'wishlist':
            buttons_config.push({
                type: 'btn', text: tbApp._t('text_wishlist'), click: function() {
                    window.location = tbApp['/tb/url/wishlist'];
                }
            });
            showNotice(tbApp._t('text_wishlist_updated'));
            break;
        case 'compare':
            buttons_config.push({
                type: 'btn', text: tbApp._t('text_product_comparison'), click: function() {
                    window.location = tbApp['/tb/url/compare'];
                }
            });
            showNotice(tbApp._t('text_compare_updated'));
            break;
    }
};

/* -----------------------------------------------------------------
   S T I C K Y   S I D E B A R
----------------------------------------------------------------- */

function stickyColumn(selectors, offset) {
    tbApp.onScriptLoaded(function() {
        selectors.split(",").forEach(function(selector) {
            var $selector = $(selector);

            $selector
                .wrapInner('<div class="col-sticky"></div>')
                .find('> .col-sticky')
                .stick_in_parent({
                    offset_top: parseInt($selector.css('paddingTop')) + Number(offset)
                });
        });
    });
}

/* -----------------------------------------------------------------
   S C R O L L   T O   T O P
----------------------------------------------------------------- */

function scroll_to_top(speed) {

    if (window.innerWidth <= 768 && window.innerHeight <= 768) {
        return;
    }

    if (speed === undefined) {
        speed = 800;
    }

    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');

    $scroll_button.bind('click', function(){
        $('html, body').animate({ scrollTop: 0 }, speed);
    });

    $(window).scroll(function () {
        if ($(this).scrollTop() > 150 && $scroll_button.css('opacity') < 100) {
            $scroll_button.css('opacity', 100);
        } else {
            $scroll_button.css('opacity', 0);
        }
    });
}

/* -----------------------------------------------------------------
   H E A D E R
----------------------------------------------------------------- */

function sticky_header(style, layout, padding) {

    if ($('#header').length == 0 || window.innerWidth <= 767 && window.innerHeight <= 767) {
        return;
    }

    if (style === undefined) {
        style = 'minimal';
    }

    if (layout === undefined) {
        layout = 'full';
    }

    if (padding === undefined) {
        padding = '10px 0';
    }

    var $cont    = $('#header'),
        $wrap    = $('#wrapper'),
        $temp;

    var height      = $cont.outerHeight(true),
        offset      = $cont.offset(),
        //height_mod  = parseInt($cont.next().css('margin-top')) + $cont.next().offset().top - height - offset.top,
        old_classes = $cont.attr('class'),
        classes     = layout != 'full_fixed' ? 'tb_sticky_width_' + layout : 'tb_sticky_width_full tb_content_fixed',
        scrolled    = false,
        animation_timeout;

    // Default style

    if (style == 'default') {
        $cont
            .addClass(classes + ' tbSticky');
        $('body')
            .css('padding-top', ($cont.hasClass('tb_header_overlay') ? 0 : height));
    }

    function clone_widget($widget) {

        tbApp.trigger('beforeCloneWidget', [$widget]);

        var $clonedWidget = $widget.clone(true).css({'padding-left': 0, 'padding-right': 0}).removeClass('display-block').addClass('display-inline-block').find("script").remove().end();

        $temp.find('.col-md-12').append($clonedWidget);
    }

    tbApp.onWindowLoaded(function() {

        $(window).scroll(function () {
            if (window.pageYOffset > height + offset.top - 20 && tbApp.windowWidth > 768 && !tb_navigation_hovered) {

                // minimal style

                if ($wrap.find('> .tbSticky').length == 0) {

                    if (style == 'minimal' && $('#sticky_header').length == 0) {
                        $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);

                        $cont.find('.tbStickyShow:not([class*="tbStickyPosition"])').each(function () {
                            clone_widget($(this));
                        });

                        for (var i = 1; i <= 8; i++) {
                            $cont.find('.tbStickyPosition-' + i).each(function () {
                                clone_widget($(this));
                            });
                        }

                        $temp.find('.tb_hovered').removeClass('tb_hovered');

                        $temp.find('[id]:not(.tb_wt):not(#cart):not(#search):not(#site_logo)').each(function () {
                            $(this).attr('id', $(this).attr('id') + '_cloned');
                        });

                        $temp.find('[data-target]').each(function () {
                            $(this).data('target', $(this).data('target') + '_cloned');
                        });

                        dropdown_menu('#sticky_header .dropdown');

                        $temp.find('.tb_tabbed_menu').each(function () {
                            tabbed_menu($(this).attr('id'));
                        });
                    }
                }
                else {
                    $('#sticky_header').show();
                }

                // default style

                if (style == 'default' && $wrap.find('> .tbStickyScrolled').length == 0) {
                    clearTimeout(animation_timeout);

                    $cont
                        .removeClass('tbStickyRestored')
                        .addClass('tbElementsHidden')
                        .addClass('tbStickyScrolled')
                        .css('padding', padding);
                }

                scrolled = true;
            }
            else {
                if (style == 'minimal') {
                    $('#sticky_header')
                        .hide();
                    $cont
                        .css('height', '')
                        .css('padding', '');
                    $('body')
                        .css('padding-top', '');
                }
                if (style == 'default') {
                    $cont
                        .removeClass('tbStickyScrolled')
                        .css('padding', '');

                    if (scrolled) {
                      $cont
                        .addClass('tbStickyRestored')
                    }

                    clearTimeout(animation_timeout);

                    animation_timeout = setTimeout(function() {
                        $cont
                            .removeClass('tbElementsHidden');
                    }, 500);
                }
            }
        });
        $(window).trigger('scroll');
    });
}

function responsive_header() {
    if (!$('#header').length) {
        return false;
    }

    var $temp;

    $('#header')
        .on('click', '.tbToggleButtons span', function () {
            if ($(this).hasClass('tbToggleCart')) {
                $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');

                $('#header').find('.tb_wt_header_cart_menu_system').each(function () {
                    var $clonedMenu = $(this).clone(true).find("script").remove().end();

                    $temp.find('.col-sm-12').append($clonedMenu);
                    $('html').addClass('tbCartMenu');
                    element_query('#tb_mobile_car_menu', '500,300,0', '.cart-info');
                });
            } else {
                $temp = $('<div class="tbMobileMenu"><div class="row"><div class="col col-xs-12 col-sm-12 col-valign-top"></div></div></div>').appendTo('#wrapper');

                $('#header').find('.tbMobileMenuShow:not([class*="tbMobilePosition"])').each(function () {
                    var $clonedMenu = $(this).clone(true).find("script").remove().end();

                    $temp.find('.col-sm-12').append($clonedMenu);
                });
                for (var i = 1; i <= 8; i++) {
                    $('#header').find('.tbMobileMenuShow.tbMobilePosition-' + i).each(function () {
                        var $clonedMenu = $(this).clone(true).find("script").remove().end();

                        $temp.find('.col-sm-12').append($clonedMenu);
                    });
                }
                $temp.find('[id]:not(.tb_wt):not(#cart):not(#search):not(#site_logo)').each(function () {
                    $(this).attr('id', $(this).attr('id') + '_cloned');
                });
            }

            setTimeout(function(){
                $('.tbMobileMenuOverlay').addClass('tbActive');
                $('html').addClass('tbMobile');
                tbApp.triggerResizeCallbacks();
            }, 10);
        });

    $('#wrapper').append('' +
        '<div class="tbMobileMenuOverlay">' +
        '  <svg><use xlink:href="' + window.location.href + '#close" /></svg>' +
        '  <span class="tb_bg"></span>' +
        '</div>');

    $('#wrapper').on('click', '> .tbMobileMenuOverlay', function () {
        $('html').removeClass('tbMobile');
        $('.tbMobileMenuOverlay').removeClass('tbActive');
        setTimeout(function() {
            $('#wrapper').find('> .tbMobileMenu').remove();
        }, 500);
        tbApp.triggerResizeCallbacks();
    });

    if (window.innerWidth <= 768 && window.innerHeight > 768
        || window.innerWidth > 768 && window.innerHeight <= 768) {

        function responsive() {
            if (window.innerWidth > 768) {
                $('#wrapper').find('> .tbMobileMenu').remove();
                $('html').removeClass('tbMobile');
                $('.tbMobileMenuOverlay').removeClass('tbActive');
            }
        }

        tbUtils.onSizeChange(responsive, false, false, false);
    }
}

/* -----------------------------------------------------------------
   T A B S   /   A C C O R D I O N
----------------------------------------------------------------- */

function createGroup(container, type, settings) {

    var initSubwidget = function($tab, $panel) {

        $panel.find("> div").each(function() {
            var id = $(this).attr("id");

            if (!$(this).data("initialized")) {

                if ("function" == typeof tbApp["init" + id]) {
                    tbApp["init" + id]();
                }

                $(this).data("initialized", true);
            }

            if ("function" == typeof tbApp["exec" + id]) {
                tbApp["exec" + id]();
            }
        });
    };

    var $container = $('#' + container);

    if (type == 'tabs') {

        initSubwidget('tab', $($container.find('li:first-child > a').attr('data-tab')).find('> .panel-body'));

        // Init tabs
        $('#' + container).find(".tbWidgetTabs").tabs({
            beforeLoad: function (event) {
                event.preventDefault();
            },
            beforeActivate: function (event, ui) {
                if (settings.auto_height) {
                    return;
                }

                ui.newPanel.css('height', ui.oldPanel.height());
                $('#' + container).css('overflow', 'hidden');
                if (!ui.newTab.hasClass("tbActivated")) {
                    ui.newPanel.addClass("tb_loading");
                    ui.newPanel.prepend('<span class="wait"></span>');
                }
            },
            activate: function (event, ui) {
                initSubwidget(ui.newTab.find("a"), ui.newPanel.find('> .panel-body'));

                if (settings.auto_height) {
                    return;
                }

                if (!ui.newTab.hasClass("tbActivated")) {
                    setTimeout(function () {
                        ui.newTab.addClass("tbActivated");
                        ui.newPanel.find("> .wait").remove();
                        ui.newPanel.removeClass("tb_loading");
                        ui.newPanel.find("> *").fadeOut(0).fadeIn(300);
                        var old_h = ui.newPanel.height();
                        ui.newPanel.css('height', '');

                        var new_h = ui.newPanel.height();
                        var diff = new_h - old_h;

                        ui.newPanel.css('height', old_h);
                        ui.newPanel.animate({height: '+=' + diff}, 300, function () {
                            $('#' + container).css('overflow', '');
                        });
                    }, 250);
                } else {
                    var old_h = ui.newPanel.height();
                    ui.newPanel.css('height', '');

                    var new_h = ui.newPanel.height();
                    var diff = new_h - old_h;

                    ui.newPanel.css('height', old_h);
                    ui.newPanel.animate({height: '+=' + diff}, 300, function () {
                        $('#' + container).css('overflow', '');
                    });
                }
            },
            create: function (event, ui) {
                initSubwidget(ui.tab.find("a"), ui.panel.find('> .panel-body'));
            },
            heightStyle: settings.auto_height ? 'auto' : 'content'
        });
        if (settings.fade) {
            $('#' + container).find(".tbWidgetTabs").tabs('option', 'show', {
                effect: 'fade',
                duration: 300
            });
            $('#' + container).find(".tbWidgetTabs").tabs('option', 'hide', {
                effect: 'fade',
                duration: 300
            });
        }

    } else {

        initSubwidget('accordion', $($container.find('.tb_title:first-child + div > .panel-body')));

        // Init accordion
        var init_height = 50;

        $container.find(".tbWidgetAccordion > .tb_accordion_content").accordion({
            beforeActivate: function(event, ui) {
                if (!ui.newHeader.hasClass("tbActivated")) {
                    ui.newPanel.height(ui.oldPanel.height());
                    ui.newPanel.addClass("tb_loading");
                    ui.newPanel.prepend('<span class="wait"></span>');
                }
            },
            activate: function(event, ui) {
                if (!ui.newHeader.hasClass("tbActivated")) {
                    setTimeout(function() {
                        ui.newHeader.addClass("tbActivated");
                        ui.newPanel.find("> .wait").remove();
                        ui.newPanel.removeClass("tb_loading");
                        ui.newPanel.find("> *").fadeOut(0).fadeIn(300);
                        var old_h = ui.newPanel.height();
                        ui.newPanel.css('height', '');

                        var new_h = ui.newPanel.height();
                        var diff  = new_h - old_h;

                        ui.newPanel.css('height', old_h);
                        if (!settings.auto_height) {
                            ui.newPanel.animate({height: '+=' + diff});
                        }
                        initSubwidget(ui.newHeader, ui.newPanel.find('> .panel-body'));
                    }, 250);
                } else {
                    initSubwidget(ui.newHeader, ui.newPanel.find('> .panel-body'));
                }
            },
            header: 'span.tb_title',
            heightStyle: settings.auto_height ? 'auto' : 'content',
            collapsible: true
        });
        if (settings.has_icon) {
            $('#' + container).find(".tbWidgetAccordion > .tb_accordion_content").accordion('option', 'icons', false);
        }
        if (settings.closed) {
            $('#' + container).find(".tbWidgetAccordion > .tb_accordion_content").accordion('option', 'active', false);
        }
    }

}

/* -----------------------------------------------------------------
   C A R O U S E L
----------------------------------------------------------------- */

function createItemSlider(container, items_count, slide_step, speed, pagination, responsive_params, autoplay, loop) {

    if (autoplay === undefined) {
        autoplay = 0;
    }

    if (loop === undefined) {
        loop = false;
    }

    var $heading        = $(container).is('.has_slider:not(.no_title)') ? $(container).find('.panel-heading, .box-heading') : $(container).closest('.tb_wt_group').find('.nav-tabs'),
        $slides         = $(container + ' .tb_listing').children(),
        init            = false,
        side_nav        = $(container).is('.tb_side_nav') || !$heading.length ? 1 : 0,
        responsive_keys = [],
        listing_style;

    listing_style += $(container + ' .tb_listing').is('tb_style_bordered') ? ' tb_bordered' : '';
    listing_style += $(container + ' .tb_listing').is('tb_compact_view')   ? ' tb_compact'  : '';

    for(var k in responsive_params) {
        responsive_keys.push(Number(k));
    }
    responsive_keys.sort(function(a, b){return a-b});

    function getRestrictions(c_width) {
        var result = {};

        if (responsive_keys.length) {
            $.each(responsive_keys, function(key, value) {
                result = responsive_params[value];
                if(c_width <= value) {
                    return false;
                }
            });
        }

        return result;
    }

    var swiperDeferred = $.Deferred();
    var SwiperObj = null;
    var current_slides_per_view;

    var buttons = function() {
        if (SwiperObj === null) {
            return;
        }

        if (SwiperObj.activeIndex < 1) {
            $(container)
                .find('.tb_prev').addClass('tb_disabled').end()
                .find('.tb_next').removeClass('tb_disabled');
        } else
        if (SwiperObj.activeIndex + current_slides_per_view == items_count) {
            $(container)
                .find('.tb_next').addClass('tb_disabled').end()
                .find('.tb_prev').removeClass('tb_disabled');
        } else {
            $(container).find('.tb_prev, .tb_next').removeClass('tb_disabled');
        }
    };

    function createSlider(slides_per_view, slide_step) {

        $slides.wrapAll('<div class="swiper-container"><div class="swiper-wrapper"></div></div>').wrap('<div class="swiper-slide"></div>');
        $(container)
            .addClass('has_slider')
            .find('.tb_listing')
            .addClass('tb_slider')
            .removeClass('tb_slider_load');

        if (pagination) {
            $(container)
                .find('.tb_listing')
                .after('<div class="tb_slider_pagination' + listing_style + '"></div>');
        }

        $(container)
            .find('.tb_listing')
            .after('<div class="tb_slider_controls">' +
                   '  <a class="tb_prev" href="javascript:;" title="' + tbApp._t('text_previous') + '">' +
                   '    <svg><use xlink:href="' + window.location.href + '#chevron_thin" /></svg>' +
                   '  </a>' +
                   '  <a class="tb_next" href="javascript:;" title="' + tbApp._t('text_next') + '">' +
                   '    <svg><use xlink:href="' + window.location.href + '#chevron_thin" /></svg>' +
                   '  </a>' +
                   '</div>');

        SwiperObj = new Swiper(container + ' .swiper-container', {
            setWrapperSize:         true,
            slidesPerView:          slides_per_view,
            slidesPerGroup:         slide_step,
            speed:                  speed,
            autoplay:               autoplay,
            loop:                   loop,
            loopAdditionalSlides:   slides_per_view,
            pagination:             pagination,
            paginationClickable:    true,
            slideActiveClass:       '',
            slideVisibleClass:      '',
            slideNextClass:         '',
            slidePrevClass:         '',
            // roundLengths:           true,
            bulletActiveClass:      'tb_active',
            onInit: function (swiper) {
                buttons();
                $(container).find('.swiper-container').addClass('tb_slider_init');
            },
            onSlideChangeEnd: function (swiper){
                buttons();
            },
            onTouchEnd: function (swiper){
                buttons();
            }
        });

        $(container).on('click', '.tb_prev, .tb_next', function() {
            $(container).addClass('tbSliderInteracted');
        });

        $(container).on('mouseover', function() {
            if (SwiperObj) {
                SwiperObj.stopAutoplay();
            }
        });
        $(container).on('mouseout', function() {
            if (SwiperObj && !$(this).is('.tbSliderInteracted')) {
                SwiperObj.startAutoplay();
            }
        });

        swiperDeferred.resolve(SwiperObj);
    }

    function destroySlider() {
        SwiperObj.destroy();
        SwiperObj = null;
        $(container).removeClass('has_slider')
            .find('.swiper-slide').unwrap().unwrap().end()
            .find('.swiper-slide > *').unwrap().end()
            .find('.tb_slider_controls, .tb_slider_pagination').remove();
        $(container).find('.tb_listing').removeClass('tb_slider');
    }

    function responsive() {

        var $width_container = side_nav ? $(container).find('.tb_listing') : $(container),
            restrictions = getRestrictions($width_container.width()),
            slides_per_view = Number(restrictions.items_per_row);

        if (items_count > slides_per_view && SwiperObj === null) {
            // create
            createSlider(slides_per_view, slide_step < slides_per_view ? slide_step : slides_per_view);
            $(container).find('.tb_slider_pagination').addClass('tb_size_' + slides_per_view);
            current_slides_per_view = slides_per_view;
            buttons();
        } else
        if (items_count <= slides_per_view && SwiperObj !== null) {
            // destroy
            destroySlider();
        } else
        if (current_slides_per_view != slides_per_view && SwiperObj !== null) {
            // reinit
            SwiperObj.params.slidesPerView = slides_per_view;
            SwiperObj.params.slidesPerGroup = slide_step < slides_per_view ? slide_step : slides_per_view;

            $(container).find('.tb_slider_pagination')
                .removeClass('tb_size_' + current_slides_per_view)
                .addClass('tb_size_' + slides_per_view);

            current_slides_per_view = slides_per_view;
            buttons();
        }

        var $nav  = $(container).find('.tb_slider_controls');

        if (!$nav.length) {
            return;
        }

        if (side_nav) {
            tbApp.onWindowLoaded(function() {
                var nav_height  = $nav.find('> a:first-child').height(),
                    mod_left    = parseInt($(container).css('padding-left')),
                    mod_right   = parseInt($(container).css('padding-right'));

                $nav.find('> a').css('margin-top', -($(container + ' .swiper-container').height()/2 + nav_height/2));
                $nav.find('> .tb_prev').css('margin-left', mod_left);
                $nav.find('> .tb_next').css('margin-right', mod_right);
                $nav.css('visibility', 'visible');
            });
        }
        else {
            var $container = $(container).is('.has_slider:not(.no_title)') ? $(container) : $(container).closest('.tb_wt_group'),
                lang_dir   = $('html').first().attr('dir'),
                mod_x      = lang_dir == 'ltr' ? parseInt($heading.css('padding-right'))
                                               + parseInt($container.css('padding-right'))
                                               + parseInt($heading.css('margin-right'))
                                               : parseInt($heading.css('padding-left'))
                                               + parseInt($container.css('padding-left'))
                                               + parseInt($heading.css('margin-left')),
                mod_y      = ($heading.height() - $nav.outerHeight())/2 + parseInt($heading.css('padding-top')) + parseInt($container.css('padding-top'));

            mod_x += mod_x >= 15 ? -5 : 0;

            $nav.css('top', mod_y);
            $nav.css(lang_dir == 'ltr' ? 'right' : 'left', mod_x-4);
        }
    }

    $(container).on('click', '.tb_prev', function (e) {
        e.preventDefault();
        SwiperObj.slidePrev();
        buttons();
    });

    $(container).on('click', '.tb_next', function (e) {
        e.preventDefault();
        SwiperObj.slideNext();
        buttons();
    });

    return {
        refresh: function() {
            if(false !== responsive_params) {
                responsive();
                if (false === init) {
                    tbUtils.onSizeChange(function() {
                        if ($(container)[0].getBoundingClientRect().width > 0) {
                            responsive();
                            if ($(container).parent().parent().hasClass('tb_tabs_content')) {
                                $(container).parent().css('height', '');
                            }
                        }
                    }, false, false, 'createItemSlider_' + container);
                    init = true;
                }
            } else
            if (false === init) {
                buttons();
                init = true;
            }
        },
        swiperPromise: swiperDeferred.promise()
    }
}

/* -----------------------------------------------------------------
   L I G H T B O X
----------------------------------------------------------------- */

function lightbox_gallery(id, slider, index, gallery_items, gallery_options) {

    var pswpElement  = '';
        pswpElement += '<div id="lightbox_gallery_' + id + '" class="pswp" tabindex="-1" role="dialog" aria-hidden="true">';
        pswpElement += '  <div class="pswp__bg"></div>';
        pswpElement += '  <div class="pswp__scroll-wrap">';
        pswpElement += '    <div class="pswp__container">';
        pswpElement += '      <div class="pswp__item"></div>';
        pswpElement += '      <div class="pswp__item"></div>';
        pswpElement += '      <div class="pswp__item"></div>';
        pswpElement += '    </div>';
        pswpElement += '    <div class="pswp__ui pswp__ui--hidden">';
        pswpElement += '      <div class="pswp__top-bar">';
        pswpElement += '        <div class="pswp__counter"></div>';
        pswpElement += '        <a class="pswp__button pswp__button--close" title="Close (Esc)"></a>';
        pswpElement += '        <a class="pswp__button pswp__button--share" title="Share"></a>';
        pswpElement += '        <a class="pswp__button pswp__button--fs" title="Toggle fullscreen"></a>';
        pswpElement += '        <a class="pswp__button pswp__button--zoom" title="Zoom in/out"></a>';
        pswpElement += '        <div class="pswp__preloader">';
        pswpElement += '          <div class="pswp__preloader__icn">';
        pswpElement += '            <div class="pswp__preloader__cut">';
        pswpElement += '              <div class="pswp__preloader__donut"></div>';
        pswpElement += '            </div>';
        pswpElement += '          </div>';
        pswpElement += '        </div>';
        pswpElement += '      </div>';
        pswpElement += '      <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">';
        pswpElement += '        <div class="pswp__share-tooltip"></div>';
        pswpElement += '      </div>';
        pswpElement += '      <a class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)"></a>';
        pswpElement += '      <a class="pswp__button pswp__button--arrow--right" title="Next (arrow right)"></a>';
        pswpElement += '      <div class="pswp__caption">';
        pswpElement += '        <div class="pswp__caption__center"></div>';
        pswpElement += '      </div>';
        pswpElement += '    </div>';
        pswpElement += '  </div>';
        pswpElement += '</div>';

    if (gallery_options === undefined) {
        gallery_options = {
            showHideOpacity:       true,
            // showAnimationDuration: false,
            // hideAnimationDuration: false,
            shareEl:               false,
            getThumbBoundsFn: function(index) {
                var thumbnail   = slider ? $('#' + id + ' .tb_slides')[0] : $('#' + id + ' .tb_gallery a')[index],
                    pageYScroll = window.pageYOffset || document.documentElement.scrollTop,
                    rect        = thumbnail.getBoundingClientRect(),
                    ratio       = $(thumbnail).data('ratio'),
                    x_mod       = 0,
                    y_mod       = 0;

                if (thumbnail.hasAttribute('data-ratio')) {
                    x_mod += ratio > 1 ? Math.round($(thumbnail).height() * ratio) - $(thumbnail).width()  : 0;
                    y_mod += ratio < 1 ? Math.round($(thumbnail).width()  / ratio) - $(thumbnail).height() : 0;
                }

                return {x:rect.left - x_mod/2, y:rect.top + pageYScroll  - y_mod/2, w:rect.width + x_mod};
            }
        };

    }

    gallery_options.index = slider ? slider.relative.activeSlide : index;

    var fullscreen_gallery = new PhotoSwipe (
        $(pswpElement).appendTo('body')[0],
        PhotoSwipeUI_Default,
        gallery_items,
        gallery_options
    );

    if (slider) {
        fullscreen_gallery.listen('afterChange', function () {
            slider.toCenter(fullscreen_gallery.getCurrentIndex(), true);
        });
    }

    fullscreen_gallery.listen('destroy', function() {
        $('#lightbox_gallery_' + id).remove();
    });

    fullscreen_gallery.init();

}

/* -----------------------------------------------------------------
   C O U N T E R
----------------------------------------------------------------- */

function create_countdown(container, server_date, timezone) {
    $(container).find('.tb_counter_time').each(function() {
        var finalDate = new Date($(this).data('special-price-end-date')),
            $counter  = $(this);

        $counter.countdown({
            until:  finalDate,
            serverSync: function() {
                return new Date(server_date);
            },
            timezone: timezone,
            layout: '{d<}<span class="tb_counter_days">{dn}</span>{d>}'   +
                    '<span class="tb_counter_hours">{hn}</span>'   +
                    '<span class="tb_counter_minutes">{mnn}</span>' +
                    '<span class="tb_counter_seconds">{snn}</span>'
        });
    });
}

/* -----------------------------------------------------------------
   P R O D U C T   H O V E R
----------------------------------------------------------------- */

function item_hover(container, active_elements, hover_elements, hover_style) {

    $(container).find('.tb_grid_view').addClass('tbHoverReady');

    // Append
    if(hover_style == 'append') {
        $(container + ' .tb_grid_view:not(".tb_slider")').find('> div').each(function() {
            var $item = $(this);
            var $hover_content = $item.clone();

            $hover_content.find(hover_elements).remove();
            $hover_content.find('div:not(:has(*)):not(.description)').remove();
            $hover_content.find('img')
                .attr('src', $hover_content.find('img').data('src'))
                .removeClass('lazyload')
                .removeAttr('data-aspectratio')
                .css('opacity', 100)
                .css('height', '');

            $item.find(active_elements).remove();
            $item.find('div:not(:has(*)):not(.description)').remove();

            $item.hover(
                function() {
                    $item.append('<div class="tb_item_hovered">' + $hover_content.html() + '</div>');
                }, function() {
                    $item.find('.tb_item_hovered').remove();
                }
            );
        });
    }

    // Flip && Overlay
    if(hover_style == 'flip' || hover_style == 'overlay') {
        $(container + ' .tb_grid_view').find('> div').each(function() {
            var $item = $(this);

            var $active_content = $item.clone();
            var $hover_content = $item.clone();

            $active_content.find(active_elements).remove();
            $active_content.find('div:not(:has(*)):not(.description)').remove();
            $active_content.find('div:not(:has(*)):not(.description)').remove();

            $hover_content.find(hover_elements).remove();
            $hover_content.find('div:not(:has(*)):not(.description)').remove();
            $hover_content.find('div:not(:has(*)):not(.description)').remove();

            $item.children().remove();

            $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>');

            $item.find('div:not(:has(*)):not(.description)').remove();
        });
    }
}

/* -----------------------------------------------------------------
   T H U M B   H O V E R
 ----------------------------------------------------------------- */

function thumb_hover(container, hover_style) {

    if(hover_style != 'flip' && hover_style != 'overlay') {
        return;
    }
    // Flip & overlay
    $(container + ' .tb_products.tb_listing').find('> div').each(function() {

        if (!$(this).find(".image_hover").length) {
            return true;
        }
        $(this).find('.image_hover img').each(function() {
            $(this).attr('src', $(this).data('src')).css('opacity', 1);
        });
        $(this)
            .find('.image').addClass('tb_front').end()
            .find('.image_hover').addClass('tb_back').end()
            .find('.image, .image_hover').wrapAll('<div class="image tb_' + hover_style + '"></div>');
    });
}

/* -----------------------------------------------------------------
   C O O K I E   P O L I C Y
----------------------------------------------------------------- */

function cookie_policy(policy_text) {

    if ($.cookie('agreed_with_cookie_policy')) {
        return;
    }

    noty({
        text: '<h3>' + tbApp._t('text_cookie_policy_title') + '</h3><p>' + policy_text + '</p>',
        layout: tbApp['/tb/msg_position'],
        closeOnSelfClick: false,
        modal: false,
        buttons: [{
            type: 'btn',
            text: tbApp._t('text_cookie_policy_button'),
            click: function() {
                $.cookie('agreed_with_cookie_policy', '1');
                $.noty.closeAll();
            }
        }],
        closeButton: false,
        timeout: false,
        animateOpen: {opacity: 'toggle'},
        animateClose: {opacity: 'toggle'},
        close_speed: 500,
        onClose: function() {
            $(document).unbind('touchmove.noty');
        }
    });
}

/* -----------------------------------------------------------------
   D R O P D O W N   M E N U
----------------------------------------------------------------- */

function dropdown_menu(selector) {

    if (selector === undefined) {
        selector = '.dropdown';
    }

    Array.prototype.forEach.call(document.querySelectorAll(selector), function(el) {
        hoverintent(el,
            function(){
                var tb_sticky_parent;

                if ($(this).parent().is('.tb_grid_view') || $(this).parent().is('.tab-content')) {
                    return;
                }

                $(this).addClass('tb_hovered');

                if ($(this).closest('#header').length) {
                    tb_navigation_hovered = true;
                }
                if ($(this).closest('.tbSticky').length) {
                    tb_sticky_parent = true;
                }

                var $nav         = $(this).closest('.nav'),
                    $menu        = $(this),
                    $dropdown    = $(this).find('.dropdown-menu').first(),
                    offset       = $dropdown.offset(),
                    $relativeTo  = $(this).closest('[class*="tb_area_"], .tbMobileMenu'),
                    orientation  = $nav.length && $nav.hasClass('nav-horizontal') ? 'horizontal' : 'vertical';

                if (tb_sticky_parent && $menu.parent('.nav').length && ($dropdown.outerHeight() + offset.top - $(window).scrollTop > window.innerHeight)) {
                    $dropdown.css('max-height', (window.innerHeight - 110));
                    $dropdown.css('overflow-y', 'auto');
                }

                // Regular menu

                if (!$dropdown.length) {
                    return;
                }

                if (!$nav.length || !$menu.hasClass('tb_megamenu')) {
                    var menu_space  = $dropdown.outerWidth() + offset.left,
                        margin_left = menu_space > tbApp.windowWidth ? tbApp.windowWidth - menu_space - 30 : 0;

                    margin_left    += offset.left < 15 ? Math.abs(offset.left) + 15 : 0;

                    if (margin_left == 0) {
                        return;
                    }

                    if ($('html').is('[dir="ltr"]')) {
                        $dropdown.css('margin-left', margin_left);
                    } else {
                        $dropdown.css('margin-right', -margin_left);
                    }
                }

                if (!$nav.length || !$menu.hasClass('tb_megamenu')) {
                    return;
                }

                // Megamenu

                var menu_left,
                    menu_top,
                    menu_width,
                    current_site_width = tbApp['/tb/maximum_width'];

                if (tbApp.windowWidth - 60 <= tbApp['/tb/maximum_width']) {
                    current_site_width = tbApp.windowWidth - 60;
                }

                if ($menu.parent().hasClass('dropdown-menu')) {
                    orientation = 'vertical';
                }

                if ($nav.data('relative_to') == 'content' && orientation == 'horizontal' && $relativeTo.width() < current_site_width) {
                    menu_left  = $relativeTo.offset().left;
                    menu_left -= $menu.offset().left; // -1 removed
                    menu_left += parseInt($relativeTo.css('padding-left'));
                    menu_top   = 0;
                    menu_width = $relativeTo.width();
                } else {
                    menu_left    = (tbApp.windowWidth - current_site_width) / 2 - parseInt($menu.offset().left); // -1 removed
                    menu_left  += $nav.data('relative_to') == 'content' && $relativeTo.width() < current_site_width ? parseInt($relativeTo.css('padding-left')) : 0;
                    menu_left  += $('html').attr('dir') == 'rtl' ? -7 : 0;
                    menu_left   = orientation == 'horizontal' ? menu_left : 0;
                    menu_top    = 0;
                    //menu_top   += orientation == 'vertical' ? $nav.offset().top - $menu.offset().top : 0;
                    menu_width  = current_site_width;
                    menu_width += $nav.data('relative_to') == 'content' && $relativeTo.width() < current_site_width ? -parseInt($relativeTo.css('padding-left')) : 0;
                    menu_width += $nav.data('relative_to') == 'content' && $relativeTo.width() < current_site_width ? -parseInt($relativeTo.css('padding-right')) : 0;
                    menu_width += !orientation == 'vertical' && !$menu.parent().is('.dropdown-menu') ? -$nav.width() : 0;
                    menu_width += $menu.parent().is('.dropdown-menu') ? -$menu.parent().innerWidth() : 0;
                }
                if ($nav.data('relative_to') == 'block' && orientation == 'vertical' && $menu.hasClass('tb_megamenu')) {
                    if ($menu.offset().top - $nav.closest('div').offset().top < $dropdown.outerHeight()) {
                        menu_top -= $menu.offset().top - $nav.closest('div').offset().top;
                    }
                }

                $dropdown
                    .css('margin-top', menu_top);

                if (!$menu.is('.tb_auto_width') || $menu.data('dropdown-width') > menu_width) {
                    $dropdown
                        .css('margin-left', menu_left)
                        .css('width', menu_width);
                }

                if ($menu.find('.tb_grid_view')) {
                    adjustItemSize('#' + $menu.attr('id') + ' .tb_subcategories', $menu.data('responsive'));
                }

                if ($menu.is('.tb_tabbed_menu')) {
                    var $link = $dropdown.find('> .tb_tabs > .nav-tabs > li.active'),
                        tab   = '#' + $link.find('> a').data('target');

                    $dropdown.find('> .tb_tabs > .nav-tabs').css('min-width', $menu.width());

                    if ($(tab + ' .tb_grid_view').length) {
                        adjustItemSize(tab + ' .tb_subcategories', $link.data('responsive'));
                    }
                }
            },
            function(){
                $(this).removeClass('tb_hovered')
                    .find('.dropdown-menu').first().css('margin-left', '');

                tb_navigation_hovered = false;
            }
        ).options({
            timeout: 300
        });
    });
}

/* -----------------------------------------------------------------
   T A B B E D   M E N U
----------------------------------------------------------------- */

function tabbed_menu(menu) {
    var $nav  = $(menu).closest('.nav');

    // Dropdown hover
    Array.prototype.forEach.call(document.getElementById(menu).querySelectorAll('.nav-tabs > li > a'), function(el) {
        hoverintent(el,
            function(){
                var $menu = $('#' + menu),
                    $link = $(el).parent(),
                    tab   = '#' + $(el).data('target');

                $menu.find('.tab-content > *').removeClass('tb_opened');
                $menu.find('.nav-tabs > *').removeClass('active');
                $(this).parent().addClass('active');
                $(tab).addClass('tb_opened');
                $menu.toggleClass('tb_first_tab_selected', $menu.find('.nav-tabs > li:first-child').is('.active'));
                if ($(tab + ' .tb_grid_view').length) {
                    adjustItemSize(tab + ' .tb_subcategories', $link.data('responsive'));
                }
            },
            function(){
            }
        ).options({
            timeout: 300
        });
    });
}

/* -----------------------------------------------------------------
   Q U I C K V I E W
----------------------------------------------------------------- */

var tbShowQuickView,tbResizeQuickView;

function tbQuickView(product_id) {

    var $product = $('.product-id_' + product_id).parent(),
        $button  = $product.find('.tb_button_quickview a');

    if ($button.data('dialog')) {
        $('#' + $button.data('dialog')).modal('show');
    } else {

        var dialog_id = 'tbQuickviewModal-' + Math.floor(Math.random() * 100) + 1,
            html      = '';

        $product
            .find('.tb_button_quickview .wait').remove().end()
            .removeClass('tb_product_loaded tb_quickview_loaded')
            .addClass('tb_product_loading tb_quickview_loading')
            .find('.tb_button_quickview').addClass('tb_disabled')
            .find('a').prepend('<span class="wait"></span>');

        html += '<div id="' + dialog_id + '" class="modal modal--quickview fade">';
        html += '  <div class="modal-dialog">';
        html += '    <div class="modal-content">';
        html += '      <div class="modal-body">';
        html += '        <a href="javascript:;" class="close" data-dismiss="modal"></a>';
        html += '        <iframe scrolling="none"></iframe>';
        html += '      </div>';
        html += '    </div>';
        html += '  </div>';
        html += '</div>';

        $('body').append(html);

        var $iframe = $('#' + dialog_id).find('iframe');

        tbShowQuickView = function(height) {
            $iframe.height(height);
            $('#' + dialog_id).modal('show');
        };
        tbResizeQuickView = function(height) {
            $iframe.height(height);
        };

        $iframe
            .attr('src', 'index.php?route=product/product&tb_quickview=1&product_id=' + product_id)
            .on('load', function () {
                $product
                    .removeClass('tb_product_loading tb_quickview_loading')
                    .find('.tb_disabled').removeClass('tb_disabled')
                    .find('.wait').remove();
            });

        $button.data('dialog', dialog_id);
    }
}

/* -----------------------------------------------------------------
   B O O T
----------------------------------------------------------------- */

function bootApp() {

    var $body = $('body');

    /* ----------------------------------------
       Touch class
    ---------------------------------------- */

    if (tbUtils.is_touch) {
        tbUtils.addClass(document.querySelector('body'), 'is_touch');
    } else {
        tbUtils.addClass(document.querySelector('body'), 'no_touch');
    }

    /* ----------------------------------------
       System
     ---------------------------------------- */

    // Form error highlight

    $('span.error, .text-danger').each(function() {
        if ($(this).parent().is('.help') || $(this).parent().is('.help-block')) {
            return;
        }
        $(this).closest('tr, .form-group').addClass('has-error');
    });

    // Close alert messages

    $body.on('click', '.alert, .success, .attention, .warning, .information', function() {
        $(this).fadeTo(200, 0, function() {
            $(this).slideUp(300, function() {
                $(this).remove();
            });
        });
    });

    // Currency & Language

    $('#currency_form').on('click', 'a[data-currency-code]', function() {
        changeCurrency($(this));
    });

    $('#language_form').on('click', 'a[data-language-code]', function() {
        changeLanguage($(this));
    });

    // Site search

    $('#search_button').bind('click', function() {
        moduleSearch($(this));
    });

    $('#filter_keyword').bind('keydown', function(e) {
        if (e.keyCode == 13) {
            var $element = $(this);

            tbApp.once('filterKeywordEnter', function(context) {
                if (context.redirect) {
                    moduleSearch($element);
                }
            });

            tbApp.trigger('filterKeywordEnter', [{redirect: true}]);
        }
    });

    // Jquery UI spinner

    $.widget("ui.spinner", $.ui.spinner, {
        _buttonHtml: function() {
            return '' +
                '  <div class="btn-group-vertical">' +
                '    <a class="ui-spinner-button ui-spinner-up btn btn-default">' +
                '      <span class="ui-icon ' + this.options.icons.up + '">▲</span>' +
                '    </a>' +
                '    <a class="ui-spinner-button ui-spinner-down btn btn-default">' +
                '      <span class="ui-icon ' + this.options.icons.down + '">▼</span>' +
                '    </a>' +
                '</div>';
        },
        _uiSpinnerHtml: function() {
            return '<span class="ui-spinner input-group"></span>';
        }
    });

    // Modal dialog

    $body.on('click.tb_dialog', '.colorbox, .fancybox, .agree, .tb_popup', function() {
        tbCreateDialog($(this));

        return false;
    })

    /* ----------------------------------------
       Theme
     ---------------------------------------- */

    // Element queries

    element_query('.responsive');
    element_query('.cart-info', '500,300,0');
    element_query('.tb_listing_options', '1000,650,350,0');
    element_query('.tb_wt_product_options_system', '1000,300,0');
    element_query('.tb_system_search_box', '550,0');

    if(tbUtils.is_touch) {
        $body
            .on('click', function(e) {
                $('.dropdown').removeClass('tb_hovered');
                $('.tb_toggle').removeClass('tb_active');
            })
            .on('click', '.dropdown > a', function(e) {
                if ($(this).siblings('.dropdown-menu,ul')[0].getBoundingClientRect().width < 1) {
                    $('.dropdown').removeClass('tb_hovered');
                    $(this).parents('.dropdown').addClass('tb_hovered');
                    $(this).parent().find('> .tb_toggle').addClass('tb_active');
                }
                else {
                    $(this).parent().removeClass('tb_hovered');
                    $(this).parent().find('> .tb_toggle').removeClass('tb_active');
                    window.location = $(this).attr('href');
                }

                return false;
            });
    }

    $body
        .on(tbUtils.is_touch ? 'touchstart MSPointerDown' : 'click', '.dropdown > .tb_toggle', function() {
            if ($(this).siblings('.dropdown-menu,ul')[0].getBoundingClientRect().width < 1) {
                $(this).parent().addClass('tb_hovered').find('> .tb_toggle').addClass('tb_active');
            } else {
                $(this).parent().removeClass('tb_hovered').find('> .tb_toggle').removeClass('tb_active');
            }
            if ($(this).parent().find('.tb_grid_view')) {
                adjustItemSize('#' + $(this).parent().attr('id') + ' .tb_subcategories', $(this).parent().data('responsive'));
            }

            return false;
        });

    // Dropdown menus
    dropdown_menu();

    // Responsive header
    responsive_header();

    $('#wrapper')
        .find('.tb_wt_cart > .nav').each(function() {
            var $nav = $(this),
                url  = window.location.href;

    $nav.find('> .heading a').one('mouseenter', function() {
        $nav
            .addClass('active')
            .load('index.php?route=module/cart .nav > *')
            .on('mouseleave', function() {
                $(this).removeClass('active');
            });
        });
    });

}

window.tbBoot = function() {
    $(window).on('load', function(){
        tbApp.trigger("tbWindowLoaded");
        $(document.body).trigger("sticky_kit:recalc");
    });

    $(document).ready(function() {
        tbApp.trigger("tbScriptLoadedInit");

        bootApp();

        tbApp.trigger("tbScriptLoaded");
    });
};

if (window.tbCriticalLoaded) {
    window.tbBoot();
}
March 13, 2019 at 3:14 pm #67478

Hi,

We will need the website url, admin and ftp access, so we can check.

You can use hidepost to share private information with the support staff.

BR,
ThemeBurn team

March 18, 2019 at 11:36 am #67532
April 3, 2019 at 5:24 pm #67661

? any luck on this thanks

June 28, 2019 at 3:21 pm #67858
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.