mirror of
https://github.com/Mayccoll/Gogh.git
synced 2023-08-10 21:12:46 +03:00
1 line
2.8 KiB
JavaScript
1 line
2.8 KiB
JavaScript
jQuery(document).ready(function(t){function e(e){var i=t([t(".cd-filter-trigger"),t(".cd-filter"),t(".cd-tab-filter"),t(".cd-gallery")]);i.each(function(){t(this).toggleClass("filter-is-visible",e)})}function i(){var e=t(".cd-main-content").offset().top,i=t(window).scrollTop();i>=e?t(".cd-main-content").addClass("is-fixed"):t(".cd-main-content").removeClass("is-fixed")}t(".cd-filter-trigger").on("click",function(){e(!0)}),t(".cd-filter .cd-close").on("click",function(){e(!1)});var n=t(".cd-tab-filter .placeholder a"),a="Select",c=n.text();t(".cd-tab-filter li").on("click",function(e){var i=t(e.target).data("type");t(e.target).is(n)?(n.text(a==n.text()?c:a),t(".cd-tab-filter").toggleClass("is-open")):n.data("type")==i?(n.text(t(e.target).text()),t(".cd-tab-filter").removeClass("is-open")):(t(".cd-tab-filter").removeClass("is-open"),n.text(t(e.target).text()).data("type",i),c=t(e.target).text(),t(".cd-tab-filter .selected").removeClass("selected"),t(e.target).addClass("selected"))}),t(".cd-filter-block h4").on("click",function(){t(this).toggleClass("closed").siblings(".cd-filter-content").slideToggle(300)}),t(window).on("scroll",function(){window.requestAnimationFrame?window.requestAnimationFrame(i):i()}),buttonFilter.init(),t(".cd-gallery ul").mixItUp({controls:{enable:!1},callbacks:{onMixStart:function(){t(".cd-fail-message").fadeOut(200)},onMixFail:function(){t(".cd-fail-message").fadeIn(200)}}});var r,l=t(),o=function(){var t=0;return function(e,i){clearTimeout(t),t=setTimeout(e,i)}}();t(".cd-filter-content input[type='search']").keyup(function(){o(function(){r=t(".cd-filter-content input[type='search']").val().toLowerCase(),r.length>0?(t(".mix").each(function(){var e=t(this);l=e.attr("class").toLowerCase().match(r)?l.add(this):l.not(this)}),t(".cd-gallery ul").mixItUp("filter",l)):t(".cd-gallery ul").mixItUp("filter","all")},200)})});var buttonFilter={$filters:null,groups:[],outputArray:[],outputString:"",init:function(){var t=this;t.$filters=$(".cd-main-content"),t.$container=$(".cd-gallery ul"),t.$filters.find(".cd-filters").each(function(){var e=$(this);t.groups.push({$inputs:e.find(".filter"),active:"",tracker:!1})}),t.bindHandlers()},bindHandlers:function(){var t=this;t.$filters.on("click","a",function(){t.parseFilters()}),t.$filters.on("change",function(){t.parseFilters()})},parseFilters:function(){for(var t,e=this,i=0;t=e.groups[i];i++)t.active=[],t.$inputs.each(function(){var e=$(this);e.is('input[type="radio"]')||e.is('input[type="checkbox"]')?e.is(":checked")&&t.active.push(e.attr("data-filter")):e.is("select")?t.active.push(e.val()):e.find(".selected").length>0&&t.active.push(e.attr("data-filter"))});e.concatenate()},concatenate:function(){var t=this;t.outputString="";for(var e,i=0;e=t.groups[i];i++)t.outputString+=e.active;!t.outputString.length&&(t.outputString="all"),t.$container.mixItUp("isLoaded")&&t.$container.mixItUp("filter",t.outputString)}}; |