|
1
|
|
-window.jetpackModules=window.jetpackModules||{},window.jetpackModules.models=function(t,e,r,a){"use strict";var s={};return s.Modules=a.Model.extend({visibles:{},filter_and_sort:function(){var t,a=e(".subsubsub .current"),s=this.get("raw"),i=e(".button-group.filter-active .active"),o=e(".button-group.sort .active"),n=e("#srch-term-search-input").val().toLowerCase();return a.closest("li").hasClass("all")||(s=r.filter(s,(function(t){return r.contains(t.module_tags,a.data("title"))}))),i.data("filter-by")&&(s=r.filter(s,(function(t){return t[i.data("filter-by")]===i.data("filter-value")}))),n.length&&(s=r.filter(s,(function(t){return-1!==(t.name+" "+t.description+" "+t.long_description+" "+t.search_terms+" "+t.module_tags).toLowerCase().indexOf(n)}))),o.data("sort-by")&&(s=r.sortBy(s,o.data("sort-by")),"reverse"===o.data("sort-order")&&s.reverse()),t=r.groupBy(s,"available"),r.has(t,"false")&&(s=[].concat(t[!0],t[!1])),this.set("items",s),this},initialize:function(){var t=this.get("items");this.set("raw",t)}}),s}(window,jQuery,_,Backbone); |
|
1
|
+window.jetpackModules=window.jetpackModules||{},window.jetpackModules.models=function(t,e,r){"use strict";var a={};return a.Modules=r.Model.extend({visibles:{},apply_filters:function(t){t=t||{};var r=e(".subsubsub .current a"),a=e(".purpose-filter .current a"),i=Object.values(this.get("raw")),o=e(".button-group.availability-filter .active"),l=e("#srch-term-search-input").val().toLowerCase();return"hide-unavailable"===o.data("availability")&&(i=i.filter(t=>t.available)),t.ignoreTag||r.closest("li").hasClass("all")||(i=i.filter(t=>t.module_tags.includes(r.data("title")))),t.ignorePurpose||!a.length||a.closest("li").hasClass("all")||(i=i.filter(t=>t.product_group===a.data("group"))),e(".button-group.module-filter .active").each(function(){var t=e(this).data("filter-by"),r=e(this).data("filter-value");t&&(i=i.filter(e=>e[t]===r))}),l.length&&(i=i.filter(function(t){return-1!==(t.name+" "+t.description+" "+t.long_description+" "+t.search_terms+" "+t.module_tags).toLowerCase().indexOf(l)})),i},tag_counts:function(){var t=this.apply_filters({ignoreTag:!0}),e={__all__:t.length};return t.forEach(function(t){(t.module_tags||[]).forEach(function(t){e[t]=(e[t]||0)+1})}),e},purpose_counts:function(){var t=this.apply_filters({ignorePurpose:!0}),e={__all__:t.length};return t.forEach(function(t){t.product_group&&(e[t.product_group]=(e[t.product_group]||0)+1)}),e},filter_and_sort:function(){var t=this.apply_filters();t.sort((t,e)=>t.name.localeCompare(e.name));var e={growth:0,performance:1,security:2,other:3};return t.sort(function(t,r){var a=void 0!==e[t.product_group]?e[t.product_group]:99,i=void 0!==e[r.product_group]?e[r.product_group]:99;return a!==i?a-i:(r.available?1:0)-(t.available?1:0)}),this.set("items",t),this},initialize:function(){var t=this.get("items");this.set("raw",t)}}),a}(window,jQuery,Backbone); |