/* NM: Shop filters script */ (function(c){c.extend(c.nmTheme,{filters_init:function(){this.$shopFilterMenu=c("#nm-shop-filter-menu");this.$shopSidebarPopupBtn=c("#nm-shop-sidebar-popup-button");this.shopSidebarLayout=c("#nm-shop-sidebar").data("sidebar-layout");this.filterPanelSliding=!1;this.filterPanelSlideSpeed=200;this.filterPanelHideWidth=551;this.shopFilterMenuFnNames={cat:"shopFiltersCategoriesToggle",filter:"shopFiltersSidebarToggle",search:"shopFiltersSearchToggle"};this.shopFiltersBind()},shopFiltersBind:function(){var a= this;a.$shopFilterMenu.find("a").bind("click",function(f){f.preventDefault();if(!a.filterPanelSliding){a.shopRemoveNotices();a.filterPanelSliding=!0;f=0;var b=c(this).parent("li"),d=b.data("panel");b.hasClass("active")||(f=a.shopFiltersHideActivePanel());b.toggleClass("active");setTimeout(function(){a[a.shopFilterMenuFnNames[d]]()},f)}});if(a.filtersEnableAjax&&a.$pageIncludes.hasClass("shop_categories"))a.$shopWrap.on("click","#nm-shop-categories a",function(b){b.preventDefault();b=c(this);var f= b.parent("li");a.searchEnabled&&a.$searchBtn.parent("li").hasClass("active")&&(a.categoryClicked=!0,a.$searchBtn.trigger("click"));c("#nm-shop-categories").children(".current-cat").removeClass("current-cat");f.addClass("current-cat");a.shopGetPage(b.attr("href"))});if(a.$shopSidebarPopupBtn.length){a.$shopSidebarPopup=c("#nm-shop-sidebar-popup");var b=null;a.$window.bind("scroll.nmShopPopupBtn resize.nmShopPopupBtn",function(){b&&clearTimeout(b);b=setTimeout(function(){a.$body.hasClass("shop-filters-popup-open")|| a.shopFiltersPopupButtonToggle()},500)});a.$shopSidebarPopupBtn.bind("click",function(){a.shopFiltersPopupShow()});c("#nm-shop-sidebar-popup-reset-button").bind("click",function(b){b.preventDefault();a.shopFiltersPopupReset()})}var e=a.isTouch?!1:!0,d=!1;a.$shopWrap.on("click","#nm-shop-sidebar .nm-widget-title",function(b){b=c(this).closest("li");if(b.hasClass("show"))e&&b.children(".nm-shop-widget-col").last().css("height",""),b.removeClass("show");else{var f=b.parent("#nm-shop-widgets-ul").children(".show"); if(e){var g=b.children(".nm-shop-widget-col").last(),h=g.children().first().outerHeight(!0)+"px",k=f.children(".nm-shop-widget-col").last();g.css("height",h);k.css("height","");d||(d=!0,a.$window.one("resize.nmShopWidget",function(){a.shopFiltersWidgetHideOpen();d=!1}))}f.removeClass("show");b.addClass("show")}});a.filtersEnableAjax&&a.$pageIncludes.hasClass("shop_filters")&&(a.$shopWrap.on("click","#nm-shop-sidebar .nm_widget a",function(b){b.preventDefault();a.shopGetPage(c(this).attr("href"))}), a.$shopWrap.on("click","#nm-shop-sidebar .widget_product_categories a",function(b){b.preventDefault();a.shopGetPage(c(this).attr("href"))}),a.$shopWrap.on("click","#nm-shop-sidebar .widget_layered_nav a",function(b){b.preventDefault();a.shopGetPage(c(this).attr("href"))}),a.$shopWrap.on("click","#nm-shop-sidebar .widget_layered_nav_filters a",function(b){b.preventDefault();a.shopGetPage(c(this).attr("href"))}),a.$shopWrap.on("click","#nm-shop-sidebar .widget_product_tag_cloud a",function(b){b.preventDefault(); a.shopGetPage(c(this).attr("href"),!1,!0)}),a.$shopWrap.on("click","#nm-shop-sidebar .widget_rating_filter a",function(b){b.preventDefault();a.shopGetPage(c(this).attr("href"))}))},shopFiltersCategoriesToggle:function(){var a=this;c("#nm-shop-categories").slideToggle(a.filterPanelSlideSpeed,function(){var b=c(this);b.toggleClass("fade-in");b.hasClass("fade-in")||b.removeClass("force-show").css("display","");a.filterPanelSliding=!1})},shopFiltersCategoriesReset:function(){c("#nm-shop-categories").removeClass("fade-in force-show").css("display", "")},shopFiltersSidebarToggle:function(){var a=this,b=c("#nm-shop-sidebar"),e=b.is(":visible");e&&b.removeClass("fade-in");b.slideToggle(a.filterPanelSlideSpeed,function(){e||b.addClass("fade-in");a.filterPanelSliding=!1})},shopFiltersWidgetHideOpen:function(){var a=c("#nm-shop-widgets-ul").children(".show");a.length&&a.find(".nm-widget-title").trigger("click")},shopFiltersSearchToggle:function(){this.searchPanelToggle();this.currentSearch=""},shopFiltersHideActivePanel:function(){var a=0,b=this.$shopFilterMenu.children(".active"); if(b.length){b.removeClass("active");var c=b.data("panel");b.is(":hidden")&&"cat"==c?this.shopFiltersCategoriesReset():(a=300,this[this.shopFilterMenuFnNames[c]]())}return a},shopFiltersPopupButtonToggle:function(){var a=this.$shopSidebarPopupBtn.hasClass("visible")?this.$shopSidebarPopupBtn.offset().top+this.$shopSidebarPopupBtn.outerHeight(!0):this.$shopSidebarPopupBtn.offset().top,b=this.$shopBrowseWrap.offset().top;a>b+190?this.shopFiltersPopupButtonShow():this.shopFiltersPopupButtonHide()},shopFiltersPopupButtonShow:function(){this.$shopSidebarPopupBtn.addClass("visible")}, shopFiltersPopupButtonHide:function(){this.$shopSidebarPopupBtn.removeClass("visible")},shopFiltersPopupShow:function(){var a=this;a.shopFiltersPopupButtonHide();a.$shopSidebarPopup.addClass("visible");a.$body.addClass("shop-filters-popup-open");a.$document.bind("mouseup.filtersPopup",function(b){a.$shopSidebarPopup.is(b.target)||0!==a.$shopSidebarPopup.has(b.target).length||a.shopFiltersPopupHide()})},shopFiltersPopupHide:function(){var a=this;a.$shopSidebarPopup.removeClass("visible");a.shopFiltersPopupButtonToggle(); a.$body.removeClass("shop-filters-popup-open");a.$document.unbind("mouseup.filtersPopup");setTimeout(function(){c("#nm-shop-search-input").val("");a.shopSearchHideNotice()},a.panelsAnimSpeed)},shopFiltersPopupReset:function(){var a=location.href.replace(location.search,"");this.shopGetPage(a);this.shopFiltersPopupHide()},shopExternalGetPage:function(a){var b=this;if(a==window.location.href)b.shopScrollToTop();else{c("#nm-shop-categories").children(".current-cat").removeClass("current-cat");var e= b.shopScrollToTop();setTimeout(function(){b.shopGetPage(a)},e)}},shopGetPage:function(a,b,e){var d=this;if(d.shopAjax)return!1;a&&(d.shopRemoveNotices(),"popup"==d.shopSidebarLayout&&d.shopFiltersPopupHide(),d.$body.width()"+a+"");nm_wp_vars.shopAjaxUpdateTitle&&(a=e.find("#nm-wp-title").text(),a.length&&(document.title=a));a=e.find("#nm-shop-categories");var d=e.find("#nm-shop-widgets-ul");e=e.find("#nm-shop-browse-wrap"); if(a.length){var f=c("#nm-shop-categories");f.hasClass("fade-in")&&a.addClass("fade-in force-show");f.replaceWith(a)}d.length&&c("#nm-shop-widgets-ul").replaceWith(d);e.length&&b.$shopBrowseWrap.replaceWith(e);b.$shopBrowseWrap=c("#nm-shop-browse-wrap");b.shopInfLoadBound||b.infload_init();a=b.shopScrollToTop();setTimeout(function(){b.shopHideLoader()},a)}});c.nmThemeExtensions.filters=c.nmTheme.filters_init})(jQuery);