Making WordPress.org

Changeset 13057


Ignore:
Timestamp:
12/13/2023 05:11:30 PM (11 months ago)
Author:
coffee2code
Message:

Theme Directory: Remove click handler from filter tags.

Props kajalgohel, dd32, sumitsingh.
Fixes #6125.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/js
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/js/theme.js

    r12666 r13057  
    15841584            'click .filter-group [type="checkbox"]': 'addFilter',
    15851585            'click .filter-drawer .clear-filters': 'clearFilters',
    1586             'click .filtered-by': 'backToFilters'
     1586            'click .filtered-by a': 'backToFilters'
    15871587        },
    15881588
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/js/theme.min.js

    r12666 r13057  
    1 window.wp=window.wp||{},function(n){var s,o=wp.themes=wp.themes||{};o.data=_wpThemeSettings,s=o.data.l10n,_.extend(o,{model:{},view:{},routes:{},router:{},template:wp.template}),o.utils={title:function(e,t){var i=o.data.settings.title.default;"author"===t?i=o.data.settings.title.author:"tags"===t||"browse"===t?i=o.data.settings.title.tax:"search"===t?i=o.data.settings.title.search:"theme"===t?i=o.data.settings.title.theme:"404"===t||"notfound"===t?i=o.data.settings.title.notfound:("home"===t||"home"===e&&void 0===t)&&(i=o.data.settings.title.home);e=n("<div/>").html(i.replace("%s",n("<div/>").text(e).html())).text();document.title!==e&&e.length&&(document.title=e)}},o.Model=Backbone.Model.extend({initialize:function(){var e;this.set({id:this.get("slug")||this.get("id")}),this.has("sections")&&(e=this.get("sections").description,this.set({description:e})),this.set({can_configure_categorization_options:o.data.settings.currentUser?.is_admin||this.get("author")?.user_nicename===o.data.settings.currentUser?.slug})}}),o.view.Appearance=wp.Backbone.View.extend({el:"#themes .theme-browser",window:n(window),page:0,loadMore:n(".js-load-more-themes"),initialize:function(e){this.SearchView=e.SearchView||o.view.Search,this.loadMoreThemes=this.loadMoreThemes.bind(this),this.loadMore.bind("click",this.loadMoreThemes)},render:function(){this.view=new o.view.Themes({collection:this.collection,parent:this}),this.search(),this.view.render(),this.$el.find(".themes").remove(),this.$el.append(this.view.el).addClass("rendered")},searchContainer:"",search:function(){var e=new this.SearchView({collection:this.collection,parent:this});e.render(),this.searchContainer.append(n.parseHTML('<label class="screen-reader-text" for="wp-filter-search-input">'+s.search+"</label>")).append(e.el)},loadMoreThemes:function(){this.trigger("theme:loadMore")}}),o.Collection=Backbone.Collection.extend({model:o.Model,terms:"",queries:[],currentQuery:{page:1,request:{}},count:!1,loadingThemes:!1,doSearch:function(e){this.terms!==e&&(this.terms=e,0<this.terms.length&&this.search(this.terms),""===this.terms&&this.reset(o.data.themes),this.trigger("themes:update"))},search:function(t){var i,e,s,r,a;this.reset(o.data.themes,{silent:!0}),t=(t=t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")).replace(/ /g,")(?=.*"),i=new RegExp("^(?=.*"+t+").+","i"),0===(e=this.filter(function(e){return s=e.get("name").replace(/(<([^>]+)>)/gi,""),r=e.get("description").replace(/(<([^>]+)>)/gi,""),a=e.get("author").replace(/(<([^>]+)>)/gi,""),a=_.union([s,e.get("id"),r,a,e.get("tags")]),i.test(e.get("author"))&&2<t.length&&e.set("displayAuthor",!0),i.test(a)})).length?this.trigger("query:empty"):n("body").removeClass("no-results"),this.reset(e)},paginate:function(e){var t=this;return e=e||0,t=_(t.rest(o.data.settings.postsPerPage*e)),t=_(t.first(o.data.settings.postsPerPage))},query:function(t){var e,i,s,r=this.queries,a=this;if(this.currentQuery.request=t,e=_.find(r,function(e){return _.isEqual(e.request,t)}),(i=_.has(t,"page"))||(this.currentQuery.page=1),e||i){if(i)return this.apiCall(t,i).done(function(e){a.add(e.themes),a.trigger("themes:rerender"),a.trigger("query:success",e.info.results),a.loadingThemes=!1}).fail(function(){a.trigger("query:fail")});0===e.themes.length?a.trigger("query:empty"):n("body").removeClass("no-results"),_.isNumber(e.total)&&(this.count=e.total),this.reset(e.themes),e.total||(this.count=this.length),this.trigger("themes:update"),this.trigger("query:success",this.count)}else this.apiCall(t).done(function(e){e.themes&&(a.reset(e.themes),s=e.info.results,r.push({themes:e.themes,request:t,total:s})),a.trigger("themes:update"),a.trigger("query:success",s),e.themes&&0===e.themes.length&&a.trigger("query:empty")}).fail(function(){a.trigger("query:fail")})},apiCall:function(e,t){var i={type:"GET",url:o.data.settings.apiEndpoint,dataType:"json",data:_.extend({action:"query_themes",fields:{active_installs:!0,downloadlink:!0,last_updated:!0,ratings:!0,photon_screenshots:!0,tags:!0,theme_url:!0},per_page:o.data.settings.postsPerPage,locale:o.data.settings.locale},e),beforeSend:function(){n(".js-load-more-themes").hide(),t||n("body").addClass("loading-content").removeClass("no-results")}};return n.Deferred(function(t){n.ajax(i).done(function(e){t.resolveWith(this,[e])}).fail(function(){t.rejectWith(this,arguments)})}).promise()}}),o.view.Theme=wp.Backbone.View.extend({className:"theme",state:"grid",html:wp.themes.template("theme"),events:{click:"expand",keydown:"expand",touchend:"expand",keyup:"addFocus",touchmove:"preventExpand"},touchDrag:!1,render:function(){var e=this.model.toJSON();e.permalink=o.data.settings.path+o.router.baseUrl(e.slug),e.path=o.data.settings.path,this.$el.html(this.html(e)).attr({tabindex:0,"aria-describedby":e.id+"-action "+e.id+"-name"})},addFocus:function(){var e=n(":focus").hasClass("theme")?n(":focus"):n(":focus").parents(".theme");n(".theme.focus").removeClass("focus"),e.addClass("focus")},expand:function(e){if(!(!0===(e=e||window.event).metaKey|e.ctrlKey&&"click"===e.type||"keydown"===e.type&&13!==e.which&&32!==e.which))return!0===this.touchDrag?this.touchDrag=!1:void(n(e.target).is(".theme-actions a")||(o.focusedTheme=this.$el,this.trigger("theme:expand",this.model.cid),e.preventDefault()))},preventExpand:function(){this.touchDrag=!0}}),o.view.Details=wp.Backbone.View.extend({className:"theme-overlay",events:{click:"collapse","click .left":"previousTheme","click .right":"nextTheme","click .screenshot":"preview","click .theme-actions .button-secondary":"preview","keydown .theme-actions .button-secondary":"preview","touchend .theme-actions .button-secondary":"preview","click .favorite":"favorite_toggle","click #theme-patterns-grid-js .wporg-screenshot-card":"preview","click .wporg-horizontal-slider-js .wporg-screenshot-card":"thumbnailPreview","keydown .wporg-horizontal-slider-js .wporg-screenshot-card":"thumbnailPreview"},html:o.template("theme-single"),render:function(){var e=this.model.toJSON(),t=new Date;t.setUTCFullYear(e.last_updated.substring(0,4),e.last_updated.substring(5,7)-1,e.last_updated.substring(8,10)),e.last_updated=t.toLocaleDateString(s.locale,{day:"numeric",month:"long",year:"numeric"}),e.is_outdated=t.setYear(t.getYear()+1902).valueOf()<(new Date).valueOf(),e.tags=_.map(e.tags,function(e,t){e=s.tags[t]||e;return'<a href="'+o.data.settings.path+o.router.baseUrl("tags/"+t)+'">'+e+"</a>"}).join(", "),e.path=o.data.settings.path,e.active_installs<10?e.active_installs=s.active_installs_less_than_10:1e6<=e.active_installs?e.active_installs=s.active_installs_1_million:e.active_installs=e.active_installs.toLocaleString()+"+",e.show_favorites=!!o.data.settings.currentUser?.login,e.is_favorited=-1!==o.data.settings.favorites.themes.indexOf(e.slug),e.current_user=o.data.settings.currentUser?.login,this.$el.html(this.html(e)),this.navigation(),this.screenshotCheck(this.$el),this.containFocus(this.$el),this.renderDownloadsGraph(),this.renderPatterns(),this.renderStyleVariations()},favorite_toggle:function(){var e=this.$el.find(".favorite"),t=!e.hasClass("favorited"),i=this.model.get("slug");e.toggleClass("favorited"),t?o.data.settings.favorites.themes.push(i):-1<(i=o.data.settings.favorites.themes.indexOf(i))&&delete o.data.settings.favorites.themes[i];t={type:"GET",url:o.data.settings.favorites.api,dataType:"json",xhrFields:{withCredentials:!0},data:{action:t?"add-favorite":"remove-favorite",theme:this.model.get("slug"),_wpnonce:o.data.settings.favorites.nonce}};n.ajax(t).done(function(e){void 0!==e.error&&"not_logged_in"===e.error&&(o.data.settings.favorites.themes=[],o.data.settings.currentUser=!1)})},preview:function(e){var t,i,s=this,r=this.model.attributes.preview_url,a=document.activeElement;if(!0===this.touchDrag)return this.touchDrag=!1;n(e.target).hasClass("button-primary")||"keydown"===e.type&&13!==e.which&&32!==e.which||"keydown"===e.type&&13!==e.which&&n(":focus").hasClass("button")||((e=e||window.event).preventDefault(),o.focusedTheme=this.$el,(e=n(e.target).closest("a")[0])&&e.classList.contains("wporg-screenshot-card")&&(this.model.attributes.preview_url=e.href.replace("&preview","")),(i=new o.view.Preview({model:this.model})).render(),this.setNavButtonsState(),o.data.settings.isMobile?i.$el.addClass("wp-full-overlay collapsed"):i.$el.addClass("wp-full-overlay expanded"),n(".theme-install-overlay").append(i.el),this.listenTo(i,"theme:next",function(){return this.trigger("theme:next"),t=s.model,_.isUndefined(s.current)||(t=s.current),s.current=s.model.collection.at(s.model.collection.indexOf(t)+1),_.isUndefined(s.current)?(s.options.parent.parent.trigger("theme:end"),s.current=t):(i.model=s.current,i.render(),this.setNavButtonsState(),void n(".next-theme").focus())}).listenTo(i,"theme:previous",function(){this.trigger("theme:previous"),t=s.model,0!==s.model.collection.indexOf(s.current)&&(_.isUndefined(s.current)||(t=s.current),s.current=s.model.collection.at(s.model.collection.indexOf(t)-1),_.isUndefined(s.current)||(i.model=s.current,i.render(),this.setNavButtonsState(),n(".previous-theme").focus()))}),this.listenTo(i,"preview:close",function(){s.model.attributes.preview_url=r,s.current=s.model,a&&a.focus()}))},thumbnailPreview:function(e){var t,i,s,r,a;"keydown"===e.type&&13!==e.which&&32!==e.which||(e.preventDefault(),"a"!==(t=n(e.target)).prop("tagName").toLowerCase()&&(t=n(t.parent("a")[0])),i=n(".screenshot"),s="wporg-screenshot-card__active",r="wporg-thumbnail-screenshot-preview-js",a="style-variation",(e=n(".wporg-horizontal-slider-js .wporg-screenshot-card")).attr("aria-selected",!1),t.attr("aria-selected",!0),0===e.index(t)?(i.find("picture").show(),i.removeClass(a),n("."+r).remove()):(e=n('<div class="'+r+'" role="tabpanel"></div>').attr("data-link",t.attr("href")).attr("data-preview-link",t.attr("href")+"&v="+this.model.attributes.version+"-betaV2").attr("data-caption",_wpThemeSettings.l10n.pattern_caption_template.replace("%s",t.find("img").attr("alt"))).attr("data-height",i.height()+"px").attr("data-aspect-ratio",.75).attr("data-query-string","?vpw=1200&vph=900").attr("id",t.attr("aria-controls")),i.find("picture").hide(),i.addClass(a),n("."+r).remove(),i.append(e),window.__wporg_screenshot_preview_render&&window.__wporg_screenshot_preview_render(r)),n("."+s).removeClass(s),t.addClass(s),this.model.attributes.preview_url=t.attr("href"))},setNavButtonsState:function(){var e=n(".theme-install-overlay"),t=_.isUndefined(this.current)?this.model:this.current;0===this.model.collection.indexOf(t)&&e.find(".previous-theme").addClass("disabled"),_.isUndefined(this.model.collection.at(this.model.collection.indexOf(t)+1))&&e.find(".next-theme").addClass("disabled")},containFocus:function(t){var e=window.event;void 0!==e&&1!==n(e.target).closest(".theme").length||_.delay(function(){n(".theme-wrap a.button-primary:visible").focus()},500),t.on("keydown.wp-themes",function(e){9===e.which&&n(e.target).is("button.close")&&e.shiftKey&&(t.find(".theme-tags a:last-child").focus(),e.preventDefault())})},collapse:function(e){var t,i,s,r=this,a={};1!==o.data.themes.length&&(e=e||window.event,!n(e.target).is(".close")&&27!==e.keyCode||(n("body").addClass("closing-overlay"),r.unmountReactAssets(),this.$el.fadeOut(1,function(){var e;n("body").removeClass("closing-overlay"),r.closeOverlay(),t=document.body.scrollTop,(s=o.Collection.prototype.currentQuery.request.author)?(o.router.navigate(o.router.baseUrl("author/"+s)),o.utils.title(s,"author")):(s=o.Collection.prototype.currentQuery.request.search)?(o.router.navigate(o.router.baseUrl(o.router.searchPath+s)),o.utils.title(s,"search")):(i=o.view.Installer.prototype.filtersChecked())?(o.router.navigate(o.router.baseUrl("tags/"+i.join("+"))),o.utils.title(_.each(i,function(e,t){i[t]=n('label[for="filter-id-'+e+'"]').text()})[0],"tags")):(s=n(".filter-links .current"))&&(s.length||(s=n('.filter-links [data-sort="'+o.data.settings.browseDefault+'"]'),a={trigger:!0}),o.data.settings.browseDefault===s.data("sort")?(o.router.navigate(o.router.baseUrl("/"),a),o.utils.title("home")):(e=(e=s.data()||{}).sort||e.model,o.router.navigate(o.router.baseUrl(o.router.browsePath+e)),o.utils.title(s.text(),"browse"))),document.body.scrollTop=t,o.focusedTheme&&o.focusedTheme.focus()})))},renderDownloadsGraph:function(){var t=this;n.getJSON("https://api.wordpress.org/stats/themes/1.0/downloads.php?slug="+t.model.get("id")+"&limit=260&callback=?",function(e){google.charts.setOnLoadCallback(function(){var i=new google.visualization.DataTable,s=0;i.addColumn("string",_wpThemeSettings.l10n.date),i.addColumn("number",_wpThemeSettings.l10n.downloads),n.each(e,function(e,t){i.addRow(),i.setValue(s,0,new Date(e).toLocaleDateString()),i.setValue(s,1,Number(t)),s++}),new google.visualization.ColumnChart(document.getElementById("theme-download-stats-"+t.model.get("id"))).draw(i,{colors:["#253578"],legend:{position:"none"},titlePosition:"in",axisTitlesPosition:"in",chartArea:{height:280,left:35,width:"98%"},hAxis:{textStyle:{color:"black",fontSize:9}},vAxis:{format:"###,###",textPosition:"out",viewWindowMode:"explicit",viewWindow:{min:0}},bar:{groupWidth:100<i.getNumberOfRows()?"100%":null},height:350})})})},renderPatterns:function(){var e={type:"GET",url:"https://wp-themes.com/"+this.model.get("slug")+"/?rest_route=/wporg-patterns/v1/patterns"},s=this.model;function r(i,e){n.each(e,function(e,t){t=n('<div class="wporg-screenshot-preview-js"></div>').attr("data-link",t.link).attr("data-preview-link",t.preview_link+"&v="+s.get("version")+"-betaV4.0.4").attr("data-caption",_wpThemeSettings.l10n.pattern_caption_template.replace("%s",t.title));i.append(t)}),window.__wporg_screenshot_preview_render&&window.__wporg_screenshot_preview_render()}n.ajax(e).done(function(e){var t=n("#theme-patterns-grid-js"),i=n("#theme-patterns-button-js"),s=JSON.parse(e);s.length&&(n("#theme-patterns-js").show(),e=s.slice(0,9),r(t,e),9<s.length&&(i.show(),i.on("click",function(e){e.preventDefault();e=s.slice(9);r(t,e),t.find(".wporg-screenshot-card")[9].focus(),i.hide()})))})},renderStyleVariations:function(){var e={type:"GET",url:"https://wp-themes.com/"+this.model.get("slug")+"/?rest_route=/wporg-styles/v1/variations"},s=this.model;n.ajax(e).done(function(e){var i,t=n(".wporg-horizontal-slider-js"),e=JSON.parse(e);e.length&&(i=[],n.each(e,function(e,t){i.push({title:t.title,link:t.link,previewLink:t.preview_link+"&v="+s.get("version")+"-betaV1.1.2",caption:_wpThemeSettings.l10n.style_variation_caption_template.replace("%s",t.title)})}),t.attr("data-items",JSON.stringify(i)),t.attr("data-title",_wpThemeSettings.l10n.style_variations_title),window.__wporg_horizontal_slider_render&&window.__wporg_horizontal_slider_render())})},unmountReactAssets:function(){ReactDOM&&ReactDOM.unmountComponentAtNode&&(n(".wporg-horizontal-slider-js").each(function(){ReactDOM.unmountComponentAtNode(this)}),n(".wporg-screenshot-preview-js").each(function(){ReactDOM.unmountComponentAtNode(this)}),n(".wporg-thumbnail-screenshot-preview-js").each(function(){ReactDOM.unmountComponentAtNode(this)}))},navigation:function(){this.model.cid===this.model.collection.at(0).cid&&this.$el.find(".left").addClass("disabled"),this.model.cid===this.model.collection.at(this.model.collection.length-1).cid&&this.$el.find(".right").addClass("disabled")},closeOverlay:function(){n("body").removeClass("modal-open"),this.remove(),this.unbind(),this.trigger("theme:collapse")},nextTheme:function(){return this.trigger("theme:next",this.model.cid),!1},previousTheme:function(){return this.trigger("theme:previous",this.model.cid),!1},screenshotCheck:function(e){(new Image).src=e.find(".screenshot img").attr("src")}}),o.view.Preview=o.view.Details.extend({className:"wp-full-overlay expanded",el:".theme-install-overlay",events:{"click .close-full-overlay":"close","click .collapse-sidebar":"collapse","click .previous-theme":"previousTheme","click .next-theme":"nextTheme","click .wp-full-overlay-footer .devices button":"devicePreview",keyup:"keyEvent"},html:o.template("theme-preview"),render:function(){var e=this.model.toJSON();this.$el.html(this.html(e)),o.router.navigate(o.router.baseUrl(o.router.themePath+this.model.get("id"))),this.$el.fadeIn(200,function(){n("body").addClass("theme-installer-active full-overlay-active"),n(".close-full-overlay").focus()}),o.activeDevicePreview&&this.setDevicePreview(o.activeDevicePreview)},close:function(){return this.$el.fadeOut(200,function(){n("body").removeClass("theme-installer-active full-overlay-active"),o.focusedTheme&&o.focusedTheme.focus()}),this.trigger("preview:close"),this.undelegateEvents(),this.unbind(),o.router.navigate(o.router.baseUrl(o.router.themePath+this.model.get("id"))),!1},collapse:function(){return this.$el.toggleClass("collapsed"),o.data.settings.isMobile?this.$el.removeClass("expanded"):this.$el.toggleClass("expanded"),!1},devicePreview:function(e){return this.setDevicePreview(e.target.dataset.device)},setDevicePreview:function(e){var t=this.$el.find(".wp-full-overlay-footer");return t.find(".active").removeClass("active"),t.find("."+e).addClass("active"),this.$el.find(".wp-full-overlay-main iframe").removeClass(o.activeDevicePreview).addClass(e),o.activeDevicePreview=e,!1},keyEvent:function(){return 27===event.keyCode&&(this.undelegateEvents(),this.close()),39===event.keyCode&&_.once(this.nextTheme()),37===event.keyCode&&this.previousTheme(),!1}}),o.view.Themes=wp.Backbone.View.extend({className:"themes",$overlay:n("div.theme-overlay"),index:0,count:n(".wp-filter .theme-count"),initialize:function(e){var t=this;this.parent=e.parent,this.setView("grid"),this.listenTo(t.collection,"themes:update",function(){t.parent.page=0,t.render(this)}),this.listenTo(t.collection,"query:success",function(e){_.isNumber(e)?t.count.text(e.toLocaleString()):t.count.text(t.collection.length.toLocaleString())}),this.listenTo(t.collection,"query:empty",function(){n("body").addClass("no-results")}),this.listenTo(this.parent,"theme:loadMore",function(){t.renderThemes(t.parent.page)}),this.listenTo(t.collection,"themes:rerender",function(){t.renderThemes(t.parent.page)}),this.listenTo(this.parent,"theme:close",function(){t.overlay&&t.overlay.closeOverlay()}),n("body").on("keyup",function(e){t.overlay&&(39===e.keyCode&&t.overlay.nextTheme(),37===e.keyCode&&t.overlay.previousTheme(),27===e.keyCode&&t.overlay.collapse(e))})},render:function(){this.$el.empty(),1===o.data.themes.length&&(this.singleTheme=new o.view.Details({model:this.collection.models[0]}),this.singleTheme.render(),this.$el.addClass("single-theme"),this.$el.append(this.singleTheme.el)),0<this.options.collection.size()&&this.renderThemes(this.parent.page),this.count.text(this.collection.count||this.collection.length)},renderThemes:function(e){var t=this;t.instance=t.collection.paginate(e),0!==t.instance.size()?(1<=e&&n(".add-new-theme").remove(),t.instance.each(function(e){t.theme=new o.view.Theme({model:e,parent:t}),t.theme.render(),t.$el.append(t.theme.el),t.listenTo(t.theme,"theme:expand",t.expand,t)}),this.parent.page++):this.parent.trigger("theme:end")},setView:function(e){return e},expand:function(e){var t=this;this.model=t.collection.get(e),_.isUndefined(this.model)||(o.router.navigate(o.router.baseUrl(o.router.themePath+this.model.id)),o.utils.title(this.model.attributes.name,"theme"),this.setView("detail"),n("body").addClass("modal-open"),this.overlay=new o.view.Details({model:t.model}),this.overlay.render(),this.$overlay.html(this.overlay.el),this.listenTo(this.overlay,"theme:next",function(){t.next([t.model.cid]),n(".theme-header").find(".right").focus()}).listenTo(this.overlay,"theme:previous",function(){t.previous([t.model.cid]),n(".theme-header").find(".left").focus()}))},next:function(e){var e=this.collection.get(e[0]),e=this.collection.at(this.collection.indexOf(e)+1);void 0!==e&&this.theme.trigger("theme:expand",e.cid)},previous:function(e){var e=this.collection.get(e[0]),e=this.collection.at(this.collection.indexOf(e)-1);void 0!==e&&this.theme.trigger("theme:expand",e.cid)}}),o.view.Search=wp.Backbone.View.extend({tagName:"input",className:"wp-filter-search",id:"wp-filter-search-input",searching:!1,attributes:{placeholder:s.searchPlaceholder,type:"search"},events:{keyup:"search",search:"search"},initialize:function(e){this.parent=e.parent,this.listenTo(this.parent,"theme:close",function(){this.searching=!1})},search:function(e){("keyup"!==e.type||9!==e.which&&16!==e.which)&&(this.collection=this.options.parent.view.collection,"keyup"===e.type&&27===e.which&&(e.target.value=""),this.doSearch.call(this,e.target.value))},doSearch:function(e){var t={};o.view.Installer.prototype.clearFilters(jQuery.Event("click")),"author:"===(t.search=e).substring(0,7)&&(t.search="",t.author=e.slice(7)),"tag:"===e.substring(0,4)&&(t.search="",t.tag=[e.slice(4)]),n(".filter-links li > a.current").removeClass("current"),n("body").removeClass("show-filters filters-applied"),e?(o.utils.title(e,"search"),o.router.navigate(o.router.baseUrl(o.router.searchPath+e),{replace:!0})):(delete t.search,t.browse=o.data.settings.browseDefault,o.utils.title("home"),o.router.navigate(o.router.baseUrl("/"),{replace:!0})),this.runQuery(t)},runQuery:_.debounce(function(e){this.collection.query(e),this.parent.trigger("theme:close")},300)}),o.view.Installer=o.view.Appearance.extend({el:"#themes",events:{"click .filter-links li > a:not(.drawer-toggle)":"onLinkClick","click .theme-filter":"onFilter","click .drawer-toggle":"moreFilters","click .filter-drawer .apply-filters":"applyFilters",'click .filter-group [type="checkbox"]':"addFilter","click .filter-drawer .clear-filters":"clearFilters","click .filtered-by":"backToFilters"},activeClass:"current",searchContainer:n(".site-branding .search-form"),initialize:function(){o.view.Appearance.prototype.initialize.apply(this,arguments),this.sortValues=["popular","new"]},render:function(){var i=this;this.search(),this.collection=new o.Collection,this.listenTo(this,"theme:end",function(){i.collection.loadingThemes||n("body").hasClass("modal-open")||i.collection.length<o.data.settings.postsPerPage||(i.collection.loadingThemes=!0,i.collection.currentQuery.page++,_.extend(i.collection.currentQuery.request,{page:i.collection.currentQuery.page}),i.collection.query(i.collection.currentQuery.request))}),this.listenTo(this.collection,"query:success",function(e){var t;n("body").removeClass("loading-content"),n(".theme-browser").find("div.error").remove(),1<i.page&&(t=1+(i.page-1)*o.data.settings.postsPerPage,this.$el.find(".theme:nth-child("+t+")").focus()),(e=!_.isNumber(e)?i.collection.count:e)<=i.collection.length?i.loadMore.hide():i.loadMore.show()}),this.listenTo(this.collection,"query:fail",function(){n("body").removeClass("loading-content"),n(".theme-browser").find("div.error").remove(),n(".theme-browser").find("div.themes").before('<div class="error"><p>'+s.error+"</p></div>")}),this.view&&this.view.remove(),this.view=new o.view.Themes({collection:this.collection,parent:this}),this.page=0,this.$el.find(".themes").remove(),this.view.render(),this.$el.find(".theme-browser").append(this.view.el).addClass("rendered")},browse:function(e){"favorites"===e?this.collection.query({browse:e,user:o.data.settings.currentUser?.login}):this.collection.query({browse:e})},onLinkClick:function(e){const t=n(e.target);var i=t.data()||{};e.preventDefault(),i.sort||!i.tag?(n("body").removeClass("filters-applied show-filters"),t.hasClass(this.activeClass)||(e=i.sort||i.model,this.sort(e),o.data.settings.browseDefault===e?o.router.navigate(o.router.baseUrl("/")):o.router.navigate(o.router.baseUrl(o.router.browsePath+e)))):o.router.trigger("route:tag",i.tag)},sort:function(e){const t=this;var i=-1!==_.indexOf(this.sortValues,e);if(t.clearSearch(),_.each(n(".filter-group").find(":checkbox").filter(":checked"),function(e){return n(e).prop("checked",!1),t.filtersChecked()}),n(".filter-links li > a, .theme-filter").removeClass(this.activeClass),i){const s=n('.filter-links li > a[data-sort="'+e+'"]');s.addClass(this.activeClass),o.data.settings.browseDefault===e?o.utils.title("home"):o.utils.title(s.text(),"browse"),this.browse(e)}else if("favorites"===e||"commercial"===e||"community"===e){const r=n("favorites"===e?'.filter-links li > a[data-sort="'+e+'"]':'.filter-links li > a[data-model="'+e+'"]');r.addClass(this.activeClass),o.utils.title(r.text(),"browse"),this.browse(e)}else o.utils.title("404","notfound")},onFilter:function(e){var t=n(e.target),e=t.data("filter");t.hasClass(this.activeClass)||(n(".filter-links li > a, .theme-section").removeClass(this.activeClass),t.addClass(this.activeClass),e&&(e=_.union([e,this.filtersChecked()]),this.collection.query({tag:[e]})))},addFilter:function(){this.filtersChecked()},applyFilters:function(e){var t,i=[],s=this.filtersChecked(),r={tag:s},a=n(".filtered-by .tags");e&&e.preventDefault(),s&&(n("body").addClass("filters-applied"),n(".filter-links li > a.current").removeClass("current"),a.empty(),_.each(s,function(e){t=n('label[for="filter-id-'+e+'"]').text(),i.push(t),a.append('<span class="tag">'+t+"</span>"),n('.filter-links li > a[data-tag="'+e+'"]').addClass("current")}),o.router.navigate(o.router.baseUrl("tags/"+s.join("+"))),o.utils.title(i[0],"tags"),this.collection.query(r))},filtersChecked:function(){var e=n(".filter-group").find(":checkbox").filter(":checked"),t=n(".filter-drawer"),i=[];return _.each(e,function(e){i.push(n(e).prop("value"))}),0===i.length?(t.find(".apply-filters").prop("disabled",!0).find("span").text(""),t.find(".clear-filters").hide(),n("body").removeClass("filters-applied"),!1):(t.find(".apply-filters").prop("disabled",!1).find("span").text(i.length),t.find(".clear-filters").css("display","inline-block"),i)},moreFilters:function(e){return e.preventDefault(),n("body").hasClass("filters-applied")?this.backToFilters():n("body").hasClass("show-filters")&&this.filtersChecked()?this.addFilter():(this.clearSearch(),void n("body").toggleClass("show-filters"))},clearFilters:function(e){var t=n(".filter-group").find(":checkbox"),i=this;e.preventDefault(),_.each(t.filter(":checked"),function(e){return n(e).prop("checked",!1),i.filtersChecked()})},backToFilters:function(e){e&&e.preventDefault(),n("body").removeClass("filters-applied")},clearSearch:function(){n("#wp-filter-search-input").val("")}}),o.Router=Backbone.Router.extend({routes:{"browse/:sort(/page/:page)(/)":"sort","tags/:tag(/page/:page)(/)":"tag","search/:query(/page/:page)(/)":"search","author/:author(/page/:page)(/)":"author",":slug(/)":"preview","":"sort"},baseUrl:function(e){return"/"===e?e="/#":0!==e.length&&(e+="/"),e},themePath:"",browsePath:"browse/",searchPath:"search/",search:function(e){n(".wp-filter-search").val(e)},navigate:function(){Backbone.history._hasPushState&&Backbone.Router.prototype.navigate.apply(this,arguments)}}),o.History=Backbone.History.extend({getFragment:function(){return Backbone.History.prototype.getFragment.apply(this,arguments).replace(/\?.*/,"")}}),o.Run={init:function(){this.view=new o.view.Installer({section:o.data.settings.browseDefault,SearchView:o.view.Search}),Backbone.history=new o.History,this.render()},render:function(){this.view.render(),this.routes(),Backbone.history.start({root:o.data.settings.path,pushState:!0,hashChange:!1})},routes:function(){var i=this,s={};o.router=new o.Router,o.router.on("route:preview",function(e){i.view.collection.queries.push(o.data.query),s.theme=e,i.view.collection.query(s),i.view.view.expand(e)}),o.router.on("route:sort",function(e,t){t&&o.router.navigate("browse/"+e+"/",{replace:!0}),i.view.collection.queries.push(o.data.query),e=e||o.data.settings.browseDefault,i.view.sort(e),i.view.trigger("theme:close")}),o.router.on("route:search",function(e,t){t&&o.router.navigate("search/"+e+"/",{replace:!0}),i.view.collection.queries.push(o.data.query),n(".wp-filter-search").focus().trigger("keyup"),i.view.trigger("theme:close")}),o.router.on("route:tag",function(e,t){t&&o.router.navigate("tags/"+e+"/",{replace:!0}),i.view.collection.queries.push(o.data.query),_.each(e.split("+"),function(e){e=e.toLowerCase().replace(/[^a-z-]/g,""),n("#filter-id-"+e).prop("checked",!0)}),n("body").removeClass("show-filters").addClass("show-filters"),i.view.applyFilters(),i.view.trigger("theme:close")}),o.router.on("route:author",function(e,t){t&&o.router.navigate("author/"+e+"/",{replace:!0}),i.view.collection.queries.push(o.data.query),s.author=e,i.view.collection.query(s),o.utils.title(e,"author"),i.view.trigger("theme:close")})}},n(function(){o.Run.init()})}(jQuery),google.charts.load("current",{packages:["corechart"]}),function(l){const c=function(e){document.querySelector(".spinner")?.classList.remove("spinner");e=e.status+": "+e.statusText;alert(e)};document.addEventListener("submit",i=>{const a=i.target.closest("form");if(a&&["commercial","community"].includes(a.id)){i.preventDefault();const n=a.querySelector('button[type="submit"]'),o=a.querySelector(".success-msg");i=a.closest(".theme-about")?.dataset.slug;o?.classList.remove("saved");let e="";rest_name="commercial"===a.id?(e="external_support_url","supportURL"):(e="external_repository_url","repositoryURL");let s=a.querySelector('input[name="'+e+'"]'),r=a.querySelector(".button-small")?.classList.add("spinner"),t=l.restUrl+"themes/v1/theme/"+i+"/"+a.id+"/?_wpnonce="+l.restNonce;originalValue=s.dataset.originalValue??"",n.disabled=!0,fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({[rest_name]:s.value})}).then(e=>(e.ok||c(e),e)).then(e=>e.json()).then(e=>{let t;t=void 0!==e[rest_name]?(o?.classList.add("saved"),e[rest_name]):originalValue,s.value=t;const i=document.querySelector(".categorization-widget .widget-head a");i&&(i.attributes.href.value=t),n.disabled=!1,r?.classList.remove("spinner")}).catch(e=>{c(e),s.value=originalValue,n.disabled=!1})}})}((window.wp,_wpThemeSettings.rest));
     1window.wp=window.wp||{},function(n){var s,o=wp.themes=wp.themes||{};o.data=_wpThemeSettings,s=o.data.l10n,_.extend(o,{model:{},view:{},routes:{},router:{},template:wp.template}),o.utils={title:function(e,t){var i=o.data.settings.title.default,t=("author"===t?i=o.data.settings.title.author:"tags"===t||"browse"===t?i=o.data.settings.title.tax:"search"===t?i=o.data.settings.title.search:"theme"===t?i=o.data.settings.title.theme:"404"===t||"notfound"===t?i=o.data.settings.title.notfound:("home"===t||"home"===e&&void 0===t)&&(i=o.data.settings.title.home),n("<div/>").html(i.replace("%s",n("<div/>").text(e).html())).text());document.title!==t&&t.length&&(document.title=t)}},o.Model=Backbone.Model.extend({initialize:function(){var e;this.set({id:this.get("slug")||this.get("id")}),this.has("sections")&&(e=this.get("sections").description,this.set({description:e})),this.set({can_configure_categorization_options:o.data.settings.currentUser?.is_admin||this.get("author")?.user_nicename===o.data.settings.currentUser?.slug})}}),o.view.Appearance=wp.Backbone.View.extend({el:"#themes .theme-browser",window:n(window),page:0,loadMore:n(".js-load-more-themes"),initialize:function(e){this.SearchView=e.SearchView||o.view.Search,this.loadMoreThemes=this.loadMoreThemes.bind(this),this.loadMore.bind("click",this.loadMoreThemes)},render:function(){this.view=new o.view.Themes({collection:this.collection,parent:this}),this.search(),this.view.render(),this.$el.find(".themes").remove(),this.$el.append(this.view.el).addClass("rendered")},searchContainer:"",search:function(){var e=new this.SearchView({collection:this.collection,parent:this});e.render(),this.searchContainer.append(n.parseHTML('<label class="screen-reader-text" for="wp-filter-search-input">'+s.search+"</label>")).append(e.el)},loadMoreThemes:function(){this.trigger("theme:loadMore")}}),o.Collection=Backbone.Collection.extend({model:o.Model,terms:"",queries:[],currentQuery:{page:1,request:{}},count:!1,loadingThemes:!1,doSearch:function(e){this.terms!==e&&(this.terms=e,0<this.terms.length&&this.search(this.terms),""===this.terms&&this.reset(o.data.themes),this.trigger("themes:update"))},search:function(t){var i,e,s,r,a;this.reset(o.data.themes,{silent:!0}),t=(t=t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")).replace(/ /g,")(?=.*"),i=new RegExp("^(?=.*"+t+").+","i"),0===(e=this.filter(function(e){return s=e.get("name").replace(/(<([^>]+)>)/gi,""),r=e.get("description").replace(/(<([^>]+)>)/gi,""),a=e.get("author").replace(/(<([^>]+)>)/gi,""),s=_.union([s,e.get("id"),r,a,e.get("tags")]),i.test(e.get("author"))&&2<t.length&&e.set("displayAuthor",!0),i.test(s)})).length?this.trigger("query:empty"):n("body").removeClass("no-results"),this.reset(e)},paginate:function(e){var t=this;return e=e||0,t=_(t.rest(o.data.settings.postsPerPage*e)),t=_(t.first(o.data.settings.postsPerPage))},query:function(t){var e,i,s,r=this.queries,a=this;if(this.currentQuery.request=t,e=_.find(r,function(e){return _.isEqual(e.request,t)}),(i=_.has(t,"page"))||(this.currentQuery.page=1),e||i){if(i)return this.apiCall(t,i).done(function(e){a.add(e.themes),a.trigger("themes:rerender"),a.trigger("query:success",e.info.results),a.loadingThemes=!1}).fail(function(){a.trigger("query:fail")});0===e.themes.length?a.trigger("query:empty"):n("body").removeClass("no-results"),_.isNumber(e.total)&&(this.count=e.total),this.reset(e.themes),e.total||(this.count=this.length),this.trigger("themes:update"),this.trigger("query:success",this.count)}else this.apiCall(t).done(function(e){e.themes&&(a.reset(e.themes),s=e.info.results,r.push({themes:e.themes,request:t,total:s})),a.trigger("themes:update"),a.trigger("query:success",s),e.themes&&0===e.themes.length&&a.trigger("query:empty")}).fail(function(){a.trigger("query:fail")})},apiCall:function(e,t){var i={type:"GET",url:o.data.settings.apiEndpoint,dataType:"json",data:_.extend({action:"query_themes",fields:{active_installs:!0,downloadlink:!0,last_updated:!0,ratings:!0,photon_screenshots:!0,tags:!0,theme_url:!0},per_page:o.data.settings.postsPerPage,locale:o.data.settings.locale},e),beforeSend:function(){n(".js-load-more-themes").hide(),t||n("body").addClass("loading-content").removeClass("no-results")}};return n.Deferred(function(t){n.ajax(i).done(function(e){t.resolveWith(this,[e])}).fail(function(){t.rejectWith(this,arguments)})}).promise()}}),o.view.Theme=wp.Backbone.View.extend({className:"theme",state:"grid",html:wp.themes.template("theme"),events:{click:"expand",keydown:"expand",touchend:"expand",keyup:"addFocus",touchmove:"preventExpand"},touchDrag:!1,render:function(){var e=this.model.toJSON();e.permalink=o.data.settings.path+o.router.baseUrl(e.slug),e.path=o.data.settings.path,this.$el.html(this.html(e)).attr({tabindex:0,"aria-describedby":e.id+"-action "+e.id+"-name"})},addFocus:function(){var e=n(":focus").hasClass("theme")?n(":focus"):n(":focus").parents(".theme");n(".theme.focus").removeClass("focus"),e.addClass("focus")},expand:function(e){if(!(!0===(e=e||window.event).metaKey|e.ctrlKey&&"click"===e.type||"keydown"===e.type&&13!==e.which&&32!==e.which))return!0===this.touchDrag?this.touchDrag=!1:void(n(e.target).is(".theme-actions a")||(o.focusedTheme=this.$el,this.trigger("theme:expand",this.model.cid),e.preventDefault()))},preventExpand:function(){this.touchDrag=!0}}),o.view.Details=wp.Backbone.View.extend({className:"theme-overlay",events:{click:"collapse","click .left":"previousTheme","click .right":"nextTheme","click .screenshot":"preview","click .theme-actions .button-secondary":"preview","keydown .theme-actions .button-secondary":"preview","touchend .theme-actions .button-secondary":"preview","click .favorite":"favorite_toggle","click #theme-patterns-grid-js .wporg-screenshot-card":"preview","click .wporg-horizontal-slider-js .wporg-screenshot-card":"thumbnailPreview","keydown .wporg-horizontal-slider-js .wporg-screenshot-card":"thumbnailPreview"},html:o.template("theme-single"),render:function(){var e=this.model.toJSON(),t=new Date;t.setUTCFullYear(e.last_updated.substring(0,4),e.last_updated.substring(5,7)-1,e.last_updated.substring(8,10)),e.last_updated=t.toLocaleDateString(s.locale,{day:"numeric",month:"long",year:"numeric"}),e.is_outdated=t.setYear(t.getYear()+1902).valueOf()<(new Date).valueOf(),e.tags=_.map(e.tags,function(e,t){e=s.tags[t]||e;return'<a href="'+o.data.settings.path+o.router.baseUrl("tags/"+t)+'">'+e+"</a>"}).join(", "),e.path=o.data.settings.path,e.active_installs<10?e.active_installs=s.active_installs_less_than_10:1e6<=e.active_installs?e.active_installs=s.active_installs_1_million:e.active_installs=e.active_installs.toLocaleString()+"+",e.show_favorites=!!o.data.settings.currentUser?.login,e.is_favorited=-1!==o.data.settings.favorites.themes.indexOf(e.slug),e.current_user=o.data.settings.currentUser?.login,this.$el.html(this.html(e)),this.navigation(),this.screenshotCheck(this.$el),this.containFocus(this.$el),this.renderDownloadsGraph(),this.renderPatterns(),this.renderStyleVariations()},favorite_toggle:function(){var e=this.$el.find(".favorite"),t=!e.hasClass("favorited"),i=this.model.get("slug"),i=(e.toggleClass("favorited"),t?o.data.settings.favorites.themes.push(i):-1<(e=o.data.settings.favorites.themes.indexOf(i))&&delete o.data.settings.favorites.themes[e],{type:"GET",url:o.data.settings.favorites.api,dataType:"json",xhrFields:{withCredentials:!0},data:{action:t?"add-favorite":"remove-favorite",theme:this.model.get("slug"),_wpnonce:o.data.settings.favorites.nonce}});n.ajax(i).done(function(e){void 0!==e.error&&"not_logged_in"===e.error&&(o.data.settings.favorites.themes=[],o.data.settings.currentUser=!1)})},preview:function(e){var t,i,s=this,r=this.model.attributes.preview_url,a=document.activeElement;if(!0===this.touchDrag)return this.touchDrag=!1;n(e.target).hasClass("button-primary")||"keydown"===e.type&&13!==e.which&&32!==e.which||"keydown"===e.type&&13!==e.which&&n(":focus").hasClass("button")||((e=e||window.event).preventDefault(),o.focusedTheme=this.$el,(e=n(e.target).closest("a")[0])&&e.classList.contains("wporg-screenshot-card")&&(this.model.attributes.preview_url=e.href.replace("&preview","")),(i=new o.view.Preview({model:this.model})).render(),this.setNavButtonsState(),o.data.settings.isMobile?i.$el.addClass("wp-full-overlay collapsed"):i.$el.addClass("wp-full-overlay expanded"),n(".theme-install-overlay").append(i.el),this.listenTo(i,"theme:next",function(){if(this.trigger("theme:next"),t=s.model,_.isUndefined(s.current)||(t=s.current),s.current=s.model.collection.at(s.model.collection.indexOf(t)+1),_.isUndefined(s.current))return s.options.parent.parent.trigger("theme:end"),s.current=t;i.model=s.current,i.render(),this.setNavButtonsState(),n(".next-theme").focus()}).listenTo(i,"theme:previous",function(){this.trigger("theme:previous"),t=s.model,0===s.model.collection.indexOf(s.current)||(_.isUndefined(s.current)||(t=s.current),s.current=s.model.collection.at(s.model.collection.indexOf(t)-1),_.isUndefined(s.current))||(i.model=s.current,i.render(),this.setNavButtonsState(),n(".previous-theme").focus())}),this.listenTo(i,"preview:close",function(){s.model.attributes.preview_url=r,s.current=s.model,a&&a.focus()}))},thumbnailPreview:function(e){var t,i,s,r,a;"keydown"===e.type&&13!==e.which&&32!==e.which||(e.preventDefault(),"a"!==(e=n(e.target)).prop("tagName").toLowerCase()&&(e=n(e.parent("a")[0])),t=n(".screenshot"),i="wporg-screenshot-card__active",s="wporg-thumbnail-screenshot-preview-js",r="style-variation",(a=n(".wporg-horizontal-slider-js .wporg-screenshot-card")).attr("aria-selected",!1),e.attr("aria-selected",!0),0===a.index(e)?(t.find("picture").show(),t.removeClass(r),n("."+s).remove()):(a=n('<div class="'+s+'" role="tabpanel"></div>').attr("data-link",e.attr("href")).attr("data-preview-link",e.attr("href")+"&v="+this.model.attributes.version+"-betaV2").attr("data-caption",_wpThemeSettings.l10n.pattern_caption_template.replace("%s",e.find("img").attr("alt"))).attr("data-height",t.height()+"px").attr("data-aspect-ratio",.75).attr("data-query-string","?vpw=1200&vph=900").attr("id",e.attr("aria-controls")),t.find("picture").hide(),t.addClass(r),n("."+s).remove(),t.append(a),window.__wporg_screenshot_preview_render&&window.__wporg_screenshot_preview_render(s)),n("."+i).removeClass(i),e.addClass(i),this.model.attributes.preview_url=e.attr("href"))},setNavButtonsState:function(){var e=n(".theme-install-overlay"),t=_.isUndefined(this.current)?this.model:this.current;0===this.model.collection.indexOf(t)&&e.find(".previous-theme").addClass("disabled"),_.isUndefined(this.model.collection.at(this.model.collection.indexOf(t)+1))&&e.find(".next-theme").addClass("disabled")},containFocus:function(t){var e=window.event;void 0!==e&&1!==n(e.target).closest(".theme").length||_.delay(function(){n(".theme-wrap a.button-primary:visible").focus()},500),t.on("keydown.wp-themes",function(e){9===e.which&&n(e.target).is("button.close")&&e.shiftKey&&(t.find(".theme-tags a:last-child").focus(),e.preventDefault())})},collapse:function(e){var t,i,s,r=this,a={};1!==o.data.themes.length&&(e=e||window.event,n(e.target).is(".close")||27===e.keyCode)&&(n("body").addClass("closing-overlay"),r.unmountReactAssets(),this.$el.fadeOut(1,function(){var e;n("body").removeClass("closing-overlay"),r.closeOverlay(),t=document.body.scrollTop,(s=o.Collection.prototype.currentQuery.request.author)?(o.router.navigate(o.router.baseUrl("author/"+s)),o.utils.title(s,"author")):(s=o.Collection.prototype.currentQuery.request.search)?(o.router.navigate(o.router.baseUrl(o.router.searchPath+s)),o.utils.title(s,"search")):(i=o.view.Installer.prototype.filtersChecked())?(o.router.navigate(o.router.baseUrl("tags/"+i.join("+"))),o.utils.title(_.each(i,function(e,t){i[t]=n('label[for="filter-id-'+e+'"]').text()})[0],"tags")):(s=n(".filter-links .current"))&&(s.length||(s=n('.filter-links [data-sort="'+o.data.settings.browseDefault+'"]'),a={trigger:!0}),o.data.settings.browseDefault===s.data("sort")?(o.router.navigate(o.router.baseUrl("/"),a),o.utils.title("home")):(e=(e=s.data()||{}).sort||e.model,o.router.navigate(o.router.baseUrl(o.router.browsePath+e)),o.utils.title(s.text(),"browse"))),document.body.scrollTop=t,o.focusedTheme&&o.focusedTheme.focus()}))},renderDownloadsGraph:function(){var t=this;n.getJSON("https://api.wordpress.org/stats/themes/1.0/downloads.php?slug="+t.model.get("id")+"&limit=260&callback=?",function(e){google.charts.setOnLoadCallback(function(){var i=new google.visualization.DataTable,s=0;i.addColumn("string",_wpThemeSettings.l10n.date),i.addColumn("number",_wpThemeSettings.l10n.downloads),n.each(e,function(e,t){i.addRow(),i.setValue(s,0,new Date(e).toLocaleDateString()),i.setValue(s,1,Number(t)),s++}),new google.visualization.ColumnChart(document.getElementById("theme-download-stats-"+t.model.get("id"))).draw(i,{colors:["#253578"],legend:{position:"none"},titlePosition:"in",axisTitlesPosition:"in",chartArea:{height:280,left:35,width:"98%"},hAxis:{textStyle:{color:"black",fontSize:9}},vAxis:{format:"###,###",textPosition:"out",viewWindowMode:"explicit",viewWindow:{min:0}},bar:{groupWidth:100<i.getNumberOfRows()?"100%":null},height:350})})})},renderPatterns:function(){var e={type:"GET",url:"https://wp-themes.com/"+this.model.get("slug")+"/?rest_route=/wporg-patterns/v1/patterns"},s=this.model;function r(i,e){n.each(e,function(e,t){t=n('<div class="wporg-screenshot-preview-js"></div>').attr("data-link",t.link).attr("data-preview-link",t.preview_link+"&v="+s.get("version")+"-betaV4.0.4").attr("data-caption",_wpThemeSettings.l10n.pattern_caption_template.replace("%s",t.title));i.append(t)}),window.__wporg_screenshot_preview_render&&window.__wporg_screenshot_preview_render()}n.ajax(e).done(function(e){var t=n("#theme-patterns-grid-js"),i=n("#theme-patterns-button-js"),s=JSON.parse(e);s.length&&(n("#theme-patterns-js").show(),e=s.slice(0,9),r(t,e),9<s.length)&&(i.show(),i.on("click",function(e){e.preventDefault();e=s.slice(9);r(t,e),t.find(".wporg-screenshot-card")[9].focus(),i.hide()}))})},renderStyleVariations:function(){var e={type:"GET",url:"https://wp-themes.com/"+this.model.get("slug")+"/?rest_route=/wporg-styles/v1/variations"},s=this.model;n.ajax(e).done(function(e){var i,t=n(".wporg-horizontal-slider-js"),e=JSON.parse(e);e.length&&(i=[],n.each(e,function(e,t){i.push({title:t.title,link:t.link,previewLink:t.preview_link+"&v="+s.get("version")+"-betaV1.1.2",caption:_wpThemeSettings.l10n.style_variation_caption_template.replace("%s",t.title)})}),e=i,t.attr("data-items",JSON.stringify(e)),t.attr("data-title",_wpThemeSettings.l10n.style_variations_title),window.__wporg_horizontal_slider_render)&&window.__wporg_horizontal_slider_render()})},unmountReactAssets:function(){ReactDOM&&ReactDOM.unmountComponentAtNode&&(n(".wporg-horizontal-slider-js").each(function(){ReactDOM.unmountComponentAtNode(this)}),n(".wporg-screenshot-preview-js").each(function(){ReactDOM.unmountComponentAtNode(this)}),n(".wporg-thumbnail-screenshot-preview-js").each(function(){ReactDOM.unmountComponentAtNode(this)}))},navigation:function(){this.model.cid===this.model.collection.at(0).cid&&this.$el.find(".left").addClass("disabled"),this.model.cid===this.model.collection.at(this.model.collection.length-1).cid&&this.$el.find(".right").addClass("disabled")},closeOverlay:function(){n("body").removeClass("modal-open"),this.remove(),this.unbind(),this.trigger("theme:collapse")},nextTheme:function(){return this.trigger("theme:next",this.model.cid),!1},previousTheme:function(){return this.trigger("theme:previous",this.model.cid),!1},screenshotCheck:function(e){(new Image).src=e.find(".screenshot img").attr("src")}}),o.view.Preview=o.view.Details.extend({className:"wp-full-overlay expanded",el:".theme-install-overlay",events:{"click .close-full-overlay":"close","click .collapse-sidebar":"collapse","click .previous-theme":"previousTheme","click .next-theme":"nextTheme","click .wp-full-overlay-footer .devices button":"devicePreview",keyup:"keyEvent"},html:o.template("theme-preview"),render:function(){var e=this.model.toJSON();this.$el.html(this.html(e)),o.router.navigate(o.router.baseUrl(o.router.themePath+this.model.get("id"))),this.$el.fadeIn(200,function(){n("body").addClass("theme-installer-active full-overlay-active"),n(".close-full-overlay").focus()}),o.activeDevicePreview&&this.setDevicePreview(o.activeDevicePreview)},close:function(){return this.$el.fadeOut(200,function(){n("body").removeClass("theme-installer-active full-overlay-active"),o.focusedTheme&&o.focusedTheme.focus()}),this.trigger("preview:close"),this.undelegateEvents(),this.unbind(),o.router.navigate(o.router.baseUrl(o.router.themePath+this.model.get("id"))),!1},collapse:function(){return this.$el.toggleClass("collapsed"),o.data.settings.isMobile?this.$el.removeClass("expanded"):this.$el.toggleClass("expanded"),!1},devicePreview:function(e){return this.setDevicePreview(e.target.dataset.device)},setDevicePreview:function(e){var t=this.$el.find(".wp-full-overlay-footer");return t.find(".active").removeClass("active"),t.find("."+e).addClass("active"),this.$el.find(".wp-full-overlay-main iframe").removeClass(o.activeDevicePreview).addClass(e),o.activeDevicePreview=e,!1},keyEvent:function(){return 27===event.keyCode&&(this.undelegateEvents(),this.close()),39===event.keyCode&&_.once(this.nextTheme()),37===event.keyCode&&this.previousTheme(),!1}}),o.view.Themes=wp.Backbone.View.extend({className:"themes",$overlay:n("div.theme-overlay"),index:0,count:n(".wp-filter .theme-count"),initialize:function(e){var t=this;this.parent=e.parent,this.setView("grid"),this.listenTo(t.collection,"themes:update",function(){t.parent.page=0,t.render(this)}),this.listenTo(t.collection,"query:success",function(e){_.isNumber(e)?t.count.text(e.toLocaleString()):t.count.text(t.collection.length.toLocaleString())}),this.listenTo(t.collection,"query:empty",function(){n("body").addClass("no-results")}),this.listenTo(this.parent,"theme:loadMore",function(){t.renderThemes(t.parent.page)}),this.listenTo(t.collection,"themes:rerender",function(){t.renderThemes(t.parent.page)}),this.listenTo(this.parent,"theme:close",function(){t.overlay&&t.overlay.closeOverlay()}),n("body").on("keyup",function(e){t.overlay&&(39===e.keyCode&&t.overlay.nextTheme(),37===e.keyCode&&t.overlay.previousTheme(),27===e.keyCode)&&t.overlay.collapse(e)})},render:function(){this.$el.empty(),1===o.data.themes.length&&(this.singleTheme=new o.view.Details({model:this.collection.models[0]}),this.singleTheme.render(),this.$el.addClass("single-theme"),this.$el.append(this.singleTheme.el)),0<this.options.collection.size()&&this.renderThemes(this.parent.page),this.count.text(this.collection.count||this.collection.length)},renderThemes:function(e){var t=this;t.instance=t.collection.paginate(e),0===t.instance.size()?this.parent.trigger("theme:end"):(1<=e&&n(".add-new-theme").remove(),t.instance.each(function(e){t.theme=new o.view.Theme({model:e,parent:t}),t.theme.render(),t.$el.append(t.theme.el),t.listenTo(t.theme,"theme:expand",t.expand,t)}),this.parent.page++)},setView:function(e){return e},expand:function(e){var t=this;this.model=t.collection.get(e),_.isUndefined(this.model)||(o.router.navigate(o.router.baseUrl(o.router.themePath+this.model.id)),o.utils.title(this.model.attributes.name,"theme"),this.setView("detail"),n("body").addClass("modal-open"),this.overlay=new o.view.Details({model:t.model}),this.overlay.render(),this.$overlay.html(this.overlay.el),this.listenTo(this.overlay,"theme:next",function(){t.next([t.model.cid]),n(".theme-header").find(".right").focus()}).listenTo(this.overlay,"theme:previous",function(){t.previous([t.model.cid]),n(".theme-header").find(".left").focus()}))},next:function(e){e=this.collection.get(e[0]),e=this.collection.at(this.collection.indexOf(e)+1);void 0!==e&&this.theme.trigger("theme:expand",e.cid)},previous:function(e){e=this.collection.get(e[0]),e=this.collection.at(this.collection.indexOf(e)-1);void 0!==e&&this.theme.trigger("theme:expand",e.cid)}}),o.view.Search=wp.Backbone.View.extend({tagName:"input",className:"wp-filter-search",id:"wp-filter-search-input",searching:!1,attributes:{placeholder:s.searchPlaceholder,type:"search"},events:{keyup:"search",search:"search"},initialize:function(e){this.parent=e.parent,this.listenTo(this.parent,"theme:close",function(){this.searching=!1})},search:function(e){("keyup"!==e.type||9!==e.which&&16!==e.which)&&(this.collection=this.options.parent.view.collection,"keyup"===e.type&&27===e.which&&(e.target.value=""),this.doSearch.call(this,e.target.value))},doSearch:function(e){var t={};o.view.Installer.prototype.clearFilters(jQuery.Event("click")),"author:"===(t.search=e).substring(0,7)&&(t.search="",t.author=e.slice(7)),"tag:"===e.substring(0,4)&&(t.search="",t.tag=[e.slice(4)]),n(".filter-links li > a.current").removeClass("current"),n("body").removeClass("show-filters filters-applied"),e?(o.utils.title(e,"search"),o.router.navigate(o.router.baseUrl(o.router.searchPath+e),{replace:!0})):(delete t.search,t.browse=o.data.settings.browseDefault,o.utils.title("home"),o.router.navigate(o.router.baseUrl("/"),{replace:!0})),this.runQuery(t)},runQuery:_.debounce(function(e){this.collection.query(e),this.parent.trigger("theme:close")},300)}),o.view.Installer=o.view.Appearance.extend({el:"#themes",events:{"click .filter-links li > a:not(.drawer-toggle)":"onLinkClick","click .theme-filter":"onFilter","click .drawer-toggle":"moreFilters","click .filter-drawer .apply-filters":"applyFilters",'click .filter-group [type="checkbox"]':"addFilter","click .filter-drawer .clear-filters":"clearFilters","click .filtered-by a":"backToFilters"},activeClass:"current",searchContainer:n(".site-branding .search-form"),initialize:function(){o.view.Appearance.prototype.initialize.apply(this,arguments),this.sortValues=["popular","new"]},render:function(){var i=this;this.search(),this.collection=new o.Collection,this.listenTo(this,"theme:end",function(){i.collection.loadingThemes||n("body").hasClass("modal-open")||i.collection.length<o.data.settings.postsPerPage||(i.collection.loadingThemes=!0,i.collection.currentQuery.page++,_.extend(i.collection.currentQuery.request,{page:i.collection.currentQuery.page}),i.collection.query(i.collection.currentQuery.request))}),this.listenTo(this.collection,"query:success",function(e){var t;n("body").removeClass("loading-content"),n(".theme-browser").find("div.error").remove(),1<i.page&&(t=1+(i.page-1)*o.data.settings.postsPerPage,this.$el.find(".theme:nth-child("+t+")").focus()),(e=_.isNumber(e)?e:i.collection.count)<=i.collection.length?i.loadMore.hide():i.loadMore.show()}),this.listenTo(this.collection,"query:fail",function(){n("body").removeClass("loading-content"),n(".theme-browser").find("div.error").remove(),n(".theme-browser").find("div.themes").before('<div class="error"><p>'+s.error+"</p></div>")}),this.view&&this.view.remove(),this.view=new o.view.Themes({collection:this.collection,parent:this}),this.page=0,this.$el.find(".themes").remove(),this.view.render(),this.$el.find(".theme-browser").append(this.view.el).addClass("rendered")},browse:function(e){"favorites"===e?this.collection.query({browse:e,user:o.data.settings.currentUser?.login}):this.collection.query({browse:e})},onLinkClick:function(e){var t=n(e.target),i=t.data()||{};e.preventDefault(),!i.sort&&i.tag?o.router.trigger("route:tag",i.tag):(n("body").removeClass("filters-applied show-filters"),t.hasClass(this.activeClass)||(e=i.sort||i.model,this.sort(e),o.data.settings.browseDefault===e?o.router.navigate(o.router.baseUrl("/")):o.router.navigate(o.router.baseUrl(o.router.browsePath+e))))},sort:function(e){const t=this;var i=-1!==_.indexOf(this.sortValues,e);t.clearSearch(),_.each(n(".filter-group").find(":checkbox").filter(":checked"),function(e){return n(e).prop("checked",!1),t.filtersChecked()}),n(".filter-links li > a, .theme-filter").removeClass(this.activeClass),i?((i=n('.filter-links li > a[data-sort="'+e+'"]')).addClass(this.activeClass),o.data.settings.browseDefault===e?o.utils.title("home"):o.utils.title(i.text(),"browse"),this.browse(e)):"favorites"===e||"commercial"===e||"community"===e?((i=n("favorites"===e?'.filter-links li > a[data-sort="'+e+'"]':'.filter-links li > a[data-model="'+e+'"]')).addClass(this.activeClass),o.utils.title(i.text(),"browse"),this.browse(e)):o.utils.title("404","notfound")},onFilter:function(e){var e=n(e.target),t=e.data("filter");e.hasClass(this.activeClass)||(n(".filter-links li > a, .theme-section").removeClass(this.activeClass),e.addClass(this.activeClass),t&&(t=_.union([t,this.filtersChecked()]),this.collection.query({tag:[t]})))},addFilter:function(){this.filtersChecked()},applyFilters:function(e){var t,i=[],s=this.filtersChecked(),r={tag:s},a=n(".filtered-by .tags");e&&e.preventDefault(),s&&(n("body").addClass("filters-applied"),n(".filter-links li > a.current").removeClass("current"),a.empty(),_.each(s,function(e){t=n('label[for="filter-id-'+e+'"]').text(),i.push(t),a.append('<span class="tag">'+t+"</span>"),n('.filter-links li > a[data-tag="'+e+'"]').addClass("current")}),o.router.navigate(o.router.baseUrl("tags/"+s.join("+"))),o.utils.title(i[0],"tags"),this.collection.query(r))},filtersChecked:function(){var e=n(".filter-group").find(":checkbox").filter(":checked"),t=n(".filter-drawer"),i=[];return _.each(e,function(e){i.push(n(e).prop("value"))}),0===i.length?(t.find(".apply-filters").prop("disabled",!0).find("span").text(""),t.find(".clear-filters").hide(),n("body").removeClass("filters-applied"),!1):(t.find(".apply-filters").prop("disabled",!1).find("span").text(i.length),t.find(".clear-filters").css("display","inline-block"),i)},moreFilters:function(e){return e.preventDefault(),n("body").hasClass("filters-applied")?this.backToFilters():n("body").hasClass("show-filters")&&this.filtersChecked()?this.addFilter():(this.clearSearch(),void n("body").toggleClass("show-filters"))},clearFilters:function(e){var t=n(".filter-group").find(":checkbox"),i=this;e.preventDefault(),_.each(t.filter(":checked"),function(e){return n(e).prop("checked",!1),i.filtersChecked()})},backToFilters:function(e){e&&e.preventDefault(),n("body").removeClass("filters-applied")},clearSearch:function(){n("#wp-filter-search-input").val("")}}),o.Router=Backbone.Router.extend({routes:{"browse/:sort(/page/:page)(/)":"sort","tags/:tag(/page/:page)(/)":"tag","search/:query(/page/:page)(/)":"search","author/:author(/page/:page)(/)":"author",":slug(/)":"preview","":"sort"},baseUrl:function(e){return"/"===e?e="/#":0!==e.length&&(e+="/"),e},themePath:"",browsePath:"browse/",searchPath:"search/",search:function(e){n(".wp-filter-search").val(e)},navigate:function(){Backbone.history._hasPushState&&Backbone.Router.prototype.navigate.apply(this,arguments)}}),o.History=Backbone.History.extend({getFragment:function(){return Backbone.History.prototype.getFragment.apply(this,arguments).replace(/\?.*/,"")}}),o.Run={init:function(){this.view=new o.view.Installer({section:o.data.settings.browseDefault,SearchView:o.view.Search}),Backbone.history=new o.History,this.render()},render:function(){this.view.render(),this.routes(),Backbone.history.start({root:o.data.settings.path,pushState:!0,hashChange:!1})},routes:function(){var i=this,s={};o.router=new o.Router,o.router.on("route:preview",function(e){i.view.collection.queries.push(o.data.query),s.theme=e,i.view.collection.query(s),i.view.view.expand(e)}),o.router.on("route:sort",function(e,t){t&&o.router.navigate("browse/"+e+"/",{replace:!0}),i.view.collection.queries.push(o.data.query),e=e||o.data.settings.browseDefault,i.view.sort(e),i.view.trigger("theme:close")}),o.router.on("route:search",function(e,t){t&&o.router.navigate("search/"+e+"/",{replace:!0}),i.view.collection.queries.push(o.data.query),n(".wp-filter-search").focus().trigger("keyup"),i.view.trigger("theme:close")}),o.router.on("route:tag",function(e,t){t&&o.router.navigate("tags/"+e+"/",{replace:!0}),i.view.collection.queries.push(o.data.query),_.each(e.split("+"),function(e){e=e.toLowerCase().replace(/[^a-z-]/g,""),n("#filter-id-"+e).prop("checked",!0)}),n("body").removeClass("show-filters").addClass("show-filters"),i.view.applyFilters(),i.view.trigger("theme:close")}),o.router.on("route:author",function(e,t){t&&o.router.navigate("author/"+e+"/",{replace:!0}),i.view.collection.queries.push(o.data.query),s.author=e,i.view.collection.query(s),o.utils.title(e,"author"),i.view.trigger("theme:close")})}},n(function(){o.Run.init()})}(jQuery),google.charts.load("current",{packages:["corechart"]}),function(l){function c(e){document.querySelector(".spinner")?.classList.remove("spinner"),e=e.status+": "+e.statusText,alert(e)}document.addEventListener("submit",r=>{var a=r.target.closest("form");if(a&&["commercial","community"].includes(a.id)){r.preventDefault();const n=a.querySelector('button[type="submit"]'),o=a.querySelector(".success-msg");r=a.closest(".theme-about")?.dataset.slug;o?.classList.remove("saved");let e="",i=(rest_name="commercial"===a.id?(e="external_support_url","supportURL"):(e="external_repository_url","repositoryURL"),a.querySelector('input[name="'+e+'"]')),s=a.querySelector(".button-small")?.classList.add("spinner"),t=l.restUrl+"themes/v1/theme/"+r+"/"+a.id+"/?_wpnonce="+l.restNonce;originalValue=i.dataset.originalValue??"",n.disabled=!0,fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({[rest_name]:i.value})}).then(e=>(e.ok||c(e),e)).then(e=>e.json()).then(e=>{let t;t=void 0!==e[rest_name]?(o?.classList.add("saved"),e[rest_name]):originalValue,i.value=t;e=document.querySelector(".categorization-widget .widget-head a");e&&(e.attributes.href.value=t),n.disabled=!1,s?.classList.remove("spinner")}).catch(e=>{c(e),i.value=originalValue,n.disabled=!1})}})}((window.wp,_wpThemeSettings.rest));
Note: See TracChangeset for help on using the changeset viewer.