MegaFilter.prototype.beforeRequest = function() {
    var self = this;
};
MegaFilter.prototype.beforeRender = function( htmlResponse, htmlContent, json ) {
    var self = this;
};
MegaFilter.prototype.afterRender = function( htmlResponse, htmlContent, json ) {
    var self = this;
    $('#list-view').click(function() {
        $('#content .product-grid > .clearfix').remove();
        $('#content .product-grid, #content .product-price').attr('class', 'product-layout product-list col-xs-12');
        localStorage.setItem('display', 'list');
    });
    $('#grid-view').click(function() {
        cols = $('#column-right, #column-left').length;
        menu = $('.breadcrumb.col-md-offset-4.col-lg-offset-3').length;
        if (cols == 2) {
            $('.product-grid, .product-list, .product-price').attr('class', 'product-layout product-grid col-lg-6 col-md-6 col-sm-12 col-xs-12');
        } else if (cols == 1 || menu == 1) {
            $('.product-grid, .product-list, .product-price').attr('class', 'product-layout product-grid col-lg-4 col-md-6 col-sm-6 col-xs-12');
        } else {
            $('.product-grid, .product-list, .product-price').attr('class', 'product-layout product-grid col-lg-3 col-md-3 col-sm-6 col-xs-12');
        }
    
        if($(window).width() > 767) {
            autoheight();
        }
    
        localStorage.setItem('display', 'grid');
    });
       $('#price-view').click(function() {
        $('#content .row > .product-list, #content .row > .product-grid').attr('class', 'product-layout product-price col-xs-12');
        $('.product-price .caption').each(function() {
            $(this).wrap('<div></div>');
        });
        localStorage.setItem('display', 'compact');
    });
    if (localStorage.getItem('display') == 'list') {
        $('#list-view').trigger('click');
    } else if (localStorage.getItem('display') == 'compact')  {
        $('#price-view').trigger('click');
    } else {
        $('#grid-view').trigger('click');
    }
if($(window).width() > 768) {
        $('[data-toggle=\'tooltip\']').tooltip({container: 'body', trigger:'hover'});
        $(document).ajaxStop(function() {
            $('[data-toggle=\'tooltip\']').tooltip({container: 'body', trigger:'hover'});
        });
    }
};