Changeset 12137
- Timestamp:
- 10/20/2022 06:58:41 AM (2 years ago)
- 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
r12134 r12137 556 556 557 557 // Currently this feature is in beta 558 if ( window.location.href.includes( 'beta=style_variations' ) ) { 559 this.renderStyleVariations(); 560 } 558 this.renderStyleVariations(); 561 559 }, 562 560 -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/js/theme.min.js
r12134 r12137 1 window.wp=window.wp||{},function(o){var s,n=wp.themes=wp.themes||{};n.data=_wpThemeSettings,s=n.data.l10n,_.extend(n,{model:{},view:{},routes:{},router:{},template:wp.template}),n.utils={title:function(e,t){var i=n.data.settings.title.default;"author"===t?i=n.data.settings.title.author:"tags"===t||"browse"===t?i=n.data.settings.title.tax:"search"===t?i=n.data.settings.title.search:"theme"===t?i=n.data.settings.title.theme:"404"===t||"notfound"===t?i=n.data.settings.title.notfound:("home"===t||"home"===e&&void 0===t)&&(i=n.data.settings.title.home);e=o("<div/>").html(i.replace("%s",o("<div/>").text(e).html())).text();document.title!==e&&e.length&&(document.title=e)}},n.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}))}}),n.view.Appearance=wp.Backbone.View.extend({el:"#themes .theme-browser",window:o(window),page:0,loadMore:o(".js-load-more-themes"),initialize:function(e){this.SearchView=e.SearchView||n.view.Search,this.loadMoreThemes=this.loadMoreThemes.bind(this),this.loadMore.bind("click",this.loadMoreThemes)},render:function(){this.view=new n.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(o.parseHTML('<label class="screen-reader-text" for="wp-filter-search-input">'+s.search+"</label>")).append(e.el)},loadMoreThemes:function(){this.trigger("theme:loadMore")}}),n.Collection=Backbone.Collection.extend({model:n.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(n.data.themes),this.trigger("themes:update"))},search:function(t){var i,e,s,r,a;this.reset(n.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"):o("body").removeClass("no-results"),this.reset(e)},paginate:function(e){var t=this;return e=e||0,t=_(t.rest(n.data.settings.postsPerPage*e)),t=_(t.first(n.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"):o("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,s=n.data.settings.apiEndpoint,e=_.extend({per_page:n.data.settings.postsPerPage,locale:n.data.settings.locale,fields:{description:!0,sections:!1,tested:!0,requires:!0,downloaded:!1,downloadlink:!0,last_updated:!0,homepage:!0,theme_url:!0,parent:!0,tags:!0,rating:!0,ratings:!0,num_ratings:!0,extended_author:!0,photon_screenshots:!0,active_installs:!0,requires_php:!0}},e);return"api.wordpress.org"===new URL(s).hostname&&(e={action:"query_themes",request:e}),i={type:"GET",url:s,jsonp:"callback",dataType:"jsonp",data:e,beforeSend:function(){t||o("body").addClass("loading-content").removeClass("no-results")}},o.Deferred(function(t){o.ajax(i).done(function(e){t.resolveWith(this,[e])}).fail(function(){t.rejectWith(this,arguments)})}).promise()}}),n.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=n.data.settings.path+n.router.baseUrl(e.slug),e.path=n.data.settings.path,this.$el.html(this.html(e)).attr({tabindex:0,"aria-describedby":e.id+"-action "+e.id+"-name"})},addFocus:function(){var e=o(":focus").hasClass("theme")?o(":focus"):o(":focus").parents(".theme");o(".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(o(e.target).is(".theme-actions a")||(n.focusedTheme=this.$el,this.trigger("theme:expand",this.model.cid),e.preventDefault()))},preventExpand:function(){this.touchDrag=!0}}),n.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":"favourite_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:n.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="'+n.data.settings.path+n.router.baseUrl("tags/"+t)+'">'+e+"</a>"}).join(", "),e.path=n.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=!!n.data.settings.favorites.user,e.is_favorited=-1!==n.data.settings.favorites.themes.indexOf(e.slug),e.current_user=n.data.settings.favorites.user,this.$el.html(this.html(e)),this.navigation(),this.screenshotCheck(this.$el),this.containFocus(this.$el),this.renderDownloadsGraph(),this.renderPatterns(), window.location.href.includes("beta=style_variations")&&this.renderStyleVariations()},favourite_toggle:function(){var e=this.$el.find(".favorite"),t=!e.hasClass("favorited"),i=this.model.get("slug");e.toggleClass("favorited"),t?n.data.settings.favorites.themes.push(i):-1<(i=n.data.settings.favorites.themes.indexOf(i))&&delete n.data.settings.favorites.themes[i];t={type:"GET",url:n.data.settings.favorites.api,jsonp:"callback",dataType:"jsonp",data:{action:t?"add-favorite":"remove-favorite",theme:this.model.get("slug"),_wpnonce:n.data.settings.favorites.nonce}};o.ajax(t).done(function(e){void 0!==e.error&&"not_logged_in"===e.error&&(n.data.settings.favorites.themes=[],n.data.settings.favorites.user="")})},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;o(e.target).hasClass("button-primary")||"keydown"===e.type&&13!==e.which&&32!==e.which||"keydown"===e.type&&13!==e.which&&o(":focus").hasClass("button")||((e=e||window.event).preventDefault(),n.focusedTheme=this.$el,(e=o(e.target).closest("a")[0])&&e.classList.contains("wporg-screenshot-card")&&(this.model.attributes.preview_url=e.href.replace("&preview","")),(i=new n.view.Preview({model:this.model})).render(),this.setNavButtonsState(),n.data.settings.isMobile?i.$el.addClass("wp-full-overlay collapsed"):i.$el.addClass("wp-full-overlay expanded"),o(".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 o(".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(),o(".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=o(e.target)).prop("tagName").toLowerCase()&&(t=o(t.parent("a")[0])),i=o(".screenshot"),s="wporg-screenshot-card__active",r="wporg-thumbnail-screenshot-preview-js",a="style-variation",(e=o(".wporg-horizontal-slider-js .wporg-screenshot-card")).attr("aria-selected",!1),o(t).attr("aria-selected",!0),0===e.index(t)?(i.find("picture").show(),i.removeClass(a),o("."+r).remove()):(e=o('<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),o("."+r).remove(),i.append(e),window.__wporg_screenshot_preview_render&&window.__wporg_screenshot_preview_render(r)),o("."+s).removeClass(s),t.addClass(s),this.model.attributes.preview_url=t.attr("href"))},setNavButtonsState:function(){var e=o(".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!==o(e.target).closest(".theme").length||_.delay(function(){o(".theme-wrap a.button-primary:visible").focus()},500),t.on("keydown.wp-themes",function(e){9===e.which&&o(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!==n.data.themes.length&&(e=e||window.event,!o(e.target).is(".close")&&27!==e.keyCode||(o("body").addClass("closing-overlay"),r.unmountReactAssets(),this.$el.fadeOut(1,function(){o("body").removeClass("closing-overlay"),r.closeOverlay(),t=document.body.scrollTop,(s=n.Collection.prototype.currentQuery.request.author)?(n.router.navigate(n.router.baseUrl("author/"+s)),n.utils.title(s,"author")):(s=n.Collection.prototype.currentQuery.request.search)?(n.router.navigate(n.router.baseUrl(n.router.searchPath+s)),n.utils.title(s,"search")):(i=n.view.Installer.prototype.filtersChecked())?(n.router.navigate(n.router.baseUrl("tags/"+i.join("+"))),n.utils.title(_.each(i,function(e,t){i[t]=o('label[for="filter-id-'+e+'"]').text()})[0],"tags")):(s=o(".filter-links .current"))&&(s.length||(s=o('.filter-links [data-sort="'+n.data.settings.browseDefault+'"]'),a={trigger:!0}),n.data.settings.browseDefault===s.data("sort")?(n.router.navigate(n.router.baseUrl("/"),a),n.utils.title("home")):(n.router.navigate(n.router.baseUrl(n.router.browsePath+s.data("sort")),a),n.utils.title(s.text(),"browse"))),document.body.scrollTop=t,n.focusedTheme&&n.focusedTheme.focus()})))},renderDownloadsGraph:function(){var t=this;o.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),o.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){o.each(e,function(e,t){t=o('<div class="wporg-screenshot-preview-js"></div>').attr("data-link",t.link).attr("data-preview-link",t.preview_link+"&v="+s.get("version")+"-betaV2").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()}o.ajax(e).done(function(e){var t=o("#theme-patterns-grid-js"),i=o("#theme-patterns-button-js"),s=JSON.parse(e);s.length&&(o("#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;o.ajax(e).done(function(e){var i,t=o(".wporg-horizontal-slider-js"),e=JSON.parse(e);e.length&&(i=[],o.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&&(o(".wporg-horizontal-slider-js").each(function(){ReactDOM.unmountComponentAtNode(this)}),o(".wporg-screenshot-preview-js").each(function(){ReactDOM.unmountComponentAtNode(this)}),o(".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(){o("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")}}),n.view.Preview=n.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:n.template("theme-preview"),render:function(){var e=this.model.toJSON();this.$el.html(this.html(e)),n.router.navigate(n.router.baseUrl(n.router.themePath+this.model.get("id"))),this.$el.fadeIn(200,function(){o("body").addClass("theme-installer-active full-overlay-active"),o(".close-full-overlay").focus()}),n.activeDevicePreview&&this.setDevicePreview(n.activeDevicePreview)},close:function(){return this.$el.fadeOut(200,function(){o("body").removeClass("theme-installer-active full-overlay-active"),n.focusedTheme&&n.focusedTheme.focus()}),this.trigger("preview:close"),this.undelegateEvents(),this.unbind(),n.router.navigate(n.router.baseUrl(n.router.themePath+this.model.get("id"))),!1},collapse:function(){return this.$el.toggleClass("collapsed"),n.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(n.activeDevicePreview).addClass(e),n.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}}),n.view.Themes=wp.Backbone.View.extend({className:"themes",$overlay:o("div.theme-overlay"),index:0,count:o(".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(){o("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()}),o("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===n.data.themes.length&&(this.singleTheme=new n.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&&o(".add-new-theme").remove(),t.instance.each(function(e){t.theme=new n.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)||(n.router.navigate(n.router.baseUrl(n.router.themePath+this.model.id)),n.utils.title(this.model.attributes.name,"theme"),this.setView("detail"),o("body").addClass("modal-open"),this.overlay=new n.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]),o(".theme-header").find(".right").focus()}).listenTo(this.overlay,"theme:previous",function(){t.previous([t.model.cid]),o(".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)}}),n.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=""),_.debounce(_.bind(this.doSearch,this),300)(e.target.value))},doSearch:_.debounce(function(e){var t={};n.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)]),o(".filter-links li > a.current").removeClass("current"),o("body").removeClass("show-filters filters-applied"),e?(n.utils.title(e,"search"),n.router.navigate(n.router.baseUrl(n.router.searchPath+e),{replace:!0})):(delete t.search,t.browse=n.data.settings.browseDefault,n.utils.title("home"),n.router.navigate(n.router.baseUrl("/"),{replace:!0})),this.collection.query(t)},300)}),n.view.Installer=n.view.Appearance.extend({el:"#themes",events:{"click .filter-links li > a":"onSort","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:o(".wp-filter .search-form"),initialize:function(){n.view.Appearance.prototype.initialize.apply(this,arguments),this.sortValues=o(".filter-links li > a").map(function(){return o(this).data("sort")}).get()},render:function(){var i=this;this.search(),this.collection=new n.Collection,this.listenTo(this,"theme:end",function(){i.collection.loadingThemes||o("body").hasClass("modal-open")||i.collection.length<n.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;o("body").removeClass("loading-content"),o(".theme-browser").find("div.error").remove(),1<i.page&&(t=1+(i.page-1)*n.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(){o("body").removeClass("loading-content"),o(".theme-browser").find("div.error").remove(),o(".theme-browser").find("div.themes").before('<div class="error"><p>'+s.error+"</p></div>")}),this.view&&this.view.remove(),this.view=new n.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:n.data.settings.favorites.user}):this.collection.query({browse:e})},onSort:function(e){var t=o(e.target),i=t.data("sort");e.preventDefault(),i||!t.data("tag")?(o("body").removeClass("filters-applied show-filters"),t.hasClass(this.activeClass)||(this.sort(i),n.data.settings.browseDefault===i?n.router.navigate(n.router.baseUrl("/")):n.router.navigate(n.router.baseUrl(n.router.browsePath+i)))):n.router.trigger("route:tag",t.data("tag"))},sort:function(e){var t=this,i=!1;-1!==_.indexOf(this.sortValues,e)&&(i=o('.filter-links [data-sort="'+e+'"]')),t.clearSearch(),_.each(o(".filter-group").find(":checkbox").filter(":checked"),function(e){return o(e).prop("checked",!1),t.filtersChecked()}),o(".filter-links li > a, .theme-filter").removeClass(this.activeClass),i&&i.length?(i.addClass(this.activeClass),n.data.settings.browseDefault===e?n.utils.title("home"):n.utils.title(i.text(),"browse"),this.browse(e)):n.utils.title("404","notfound")},onFilter:function(e){var t=o(e.target),e=t.data("filter");t.hasClass(this.activeClass)||(o(".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=o(".filtered-by .tags");e&&e.preventDefault(),s&&(o("body").addClass("filters-applied"),o(".filter-links li > a.current").removeClass("current"),a.empty(),_.each(s,function(e){t=o('label[for="filter-id-'+e+'"]').text(),i.push(t),a.append('<span class="tag">'+t+"</span>"),o('.filter-links li > a[data-tag="'+e+'"]').addClass("current")}),n.router.navigate(n.router.baseUrl("tags/"+s.join("+"))),n.utils.title(i[0],"tags"),this.collection.query(r))},filtersChecked:function(){var e=o(".filter-group").find(":checkbox").filter(":checked"),t=o(".filter-drawer"),i=[];return _.each(e,function(e){i.push(o(e).prop("value"))}),0===i.length?(t.find(".apply-filters").prop("disabled",!0).find("span").text(""),t.find(".clear-filters").hide(),o("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(),o("body").hasClass("filters-applied")?this.backToFilters():o("body").hasClass("show-filters")&&this.filtersChecked()?this.addFilter():(this.clearSearch(),void o("body").toggleClass("show-filters"))},clearFilters:function(e){var t=o(".filter-group").find(":checkbox"),i=this;e.preventDefault(),_.each(t.filter(":checked"),function(e){return o(e).prop("checked",!1),i.filtersChecked()})},backToFilters:function(e){e&&e.preventDefault(),o("body").removeClass("filters-applied")},clearSearch:function(){o("#wp-filter-search-input").val("")}}),n.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){o(".wp-filter-search").val(e)},navigate:function(){Backbone.history._hasPushState&&Backbone.Router.prototype.navigate.apply(this,arguments)}}),n.History=Backbone.History.extend({getFragment:function(){return Backbone.History.prototype.getFragment.apply(this,arguments).replace(/\?.*/,"")}}),n.Run={init:function(){this.view=new n.view.Installer({section:n.data.settings.browseDefault,SearchView:n.view.Search}),Backbone.history=new n.History,this.render()},render:function(){this.view.render(),this.routes(),Backbone.history.start({root:n.data.settings.path,pushState:!0,hashChange:!1})},routes:function(){var i=this,s={};n.router=new n.Router,n.router.on("route:preview",function(e){i.view.collection.queries.push(n.data.query),s.theme=e,i.view.collection.query(s),i.view.view.expand(e)}),n.router.on("route:sort",function(e,t){t&&n.router.navigate("browse/"+e+"/",{replace:!0}),i.view.collection.queries.push(n.data.query),e=e||n.data.settings.browseDefault,i.view.sort(e),i.view.trigger("theme:close")}),n.router.on("route:search",function(e,t){t&&n.router.navigate("search/"+e+"/",{replace:!0}),i.view.collection.queries.push(n.data.query),o(".wp-filter-search").focus().trigger("keyup"),i.view.trigger("theme:close")}),n.router.on("route:tag",function(e,t){t&&n.router.navigate("tags/"+e+"/",{replace:!0}),i.view.collection.queries.push(n.data.query),_.each(e.split("+"),function(e){e=e.toLowerCase().replace(/[^a-z-]/g,""),o("#filter-id-"+e).prop("checked",!0)}),o("body").removeClass("show-filters").addClass("show-filters"),i.view.applyFilters(),i.view.trigger("theme:close")}),n.router.on("route:author",function(e,t){t&&n.router.navigate("author/"+e+"/",{replace:!0}),i.view.collection.queries.push(n.data.query),s.author=e,i.view.collection.query(s),n.utils.title(e,"author"),i.view.trigger("theme:close")})}},o(function(){n.Run.init()})}(jQuery),google.charts.load("current",{packages:["corechart"]});1 window.wp=window.wp||{},function(o){var s,n=wp.themes=wp.themes||{};n.data=_wpThemeSettings,s=n.data.l10n,_.extend(n,{model:{},view:{},routes:{},router:{},template:wp.template}),n.utils={title:function(e,t){var i=n.data.settings.title.default;"author"===t?i=n.data.settings.title.author:"tags"===t||"browse"===t?i=n.data.settings.title.tax:"search"===t?i=n.data.settings.title.search:"theme"===t?i=n.data.settings.title.theme:"404"===t||"notfound"===t?i=n.data.settings.title.notfound:("home"===t||"home"===e&&void 0===t)&&(i=n.data.settings.title.home);e=o("<div/>").html(i.replace("%s",o("<div/>").text(e).html())).text();document.title!==e&&e.length&&(document.title=e)}},n.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}))}}),n.view.Appearance=wp.Backbone.View.extend({el:"#themes .theme-browser",window:o(window),page:0,loadMore:o(".js-load-more-themes"),initialize:function(e){this.SearchView=e.SearchView||n.view.Search,this.loadMoreThemes=this.loadMoreThemes.bind(this),this.loadMore.bind("click",this.loadMoreThemes)},render:function(){this.view=new n.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(o.parseHTML('<label class="screen-reader-text" for="wp-filter-search-input">'+s.search+"</label>")).append(e.el)},loadMoreThemes:function(){this.trigger("theme:loadMore")}}),n.Collection=Backbone.Collection.extend({model:n.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(n.data.themes),this.trigger("themes:update"))},search:function(t){var i,e,s,r,a;this.reset(n.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"):o("body").removeClass("no-results"),this.reset(e)},paginate:function(e){var t=this;return e=e||0,t=_(t.rest(n.data.settings.postsPerPage*e)),t=_(t.first(n.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"):o("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,s=n.data.settings.apiEndpoint,e=_.extend({per_page:n.data.settings.postsPerPage,locale:n.data.settings.locale,fields:{description:!0,sections:!1,tested:!0,requires:!0,downloaded:!1,downloadlink:!0,last_updated:!0,homepage:!0,theme_url:!0,parent:!0,tags:!0,rating:!0,ratings:!0,num_ratings:!0,extended_author:!0,photon_screenshots:!0,active_installs:!0,requires_php:!0}},e);return"api.wordpress.org"===new URL(s).hostname&&(e={action:"query_themes",request:e}),i={type:"GET",url:s,jsonp:"callback",dataType:"jsonp",data:e,beforeSend:function(){t||o("body").addClass("loading-content").removeClass("no-results")}},o.Deferred(function(t){o.ajax(i).done(function(e){t.resolveWith(this,[e])}).fail(function(){t.rejectWith(this,arguments)})}).promise()}}),n.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=n.data.settings.path+n.router.baseUrl(e.slug),e.path=n.data.settings.path,this.$el.html(this.html(e)).attr({tabindex:0,"aria-describedby":e.id+"-action "+e.id+"-name"})},addFocus:function(){var e=o(":focus").hasClass("theme")?o(":focus"):o(":focus").parents(".theme");o(".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(o(e.target).is(".theme-actions a")||(n.focusedTheme=this.$el,this.trigger("theme:expand",this.model.cid),e.preventDefault()))},preventExpand:function(){this.touchDrag=!0}}),n.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":"favourite_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:n.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="'+n.data.settings.path+n.router.baseUrl("tags/"+t)+'">'+e+"</a>"}).join(", "),e.path=n.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=!!n.data.settings.favorites.user,e.is_favorited=-1!==n.data.settings.favorites.themes.indexOf(e.slug),e.current_user=n.data.settings.favorites.user,this.$el.html(this.html(e)),this.navigation(),this.screenshotCheck(this.$el),this.containFocus(this.$el),this.renderDownloadsGraph(),this.renderPatterns(),this.renderStyleVariations()},favourite_toggle:function(){var e=this.$el.find(".favorite"),t=!e.hasClass("favorited"),i=this.model.get("slug");e.toggleClass("favorited"),t?n.data.settings.favorites.themes.push(i):-1<(i=n.data.settings.favorites.themes.indexOf(i))&&delete n.data.settings.favorites.themes[i];t={type:"GET",url:n.data.settings.favorites.api,jsonp:"callback",dataType:"jsonp",data:{action:t?"add-favorite":"remove-favorite",theme:this.model.get("slug"),_wpnonce:n.data.settings.favorites.nonce}};o.ajax(t).done(function(e){void 0!==e.error&&"not_logged_in"===e.error&&(n.data.settings.favorites.themes=[],n.data.settings.favorites.user="")})},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;o(e.target).hasClass("button-primary")||"keydown"===e.type&&13!==e.which&&32!==e.which||"keydown"===e.type&&13!==e.which&&o(":focus").hasClass("button")||((e=e||window.event).preventDefault(),n.focusedTheme=this.$el,(e=o(e.target).closest("a")[0])&&e.classList.contains("wporg-screenshot-card")&&(this.model.attributes.preview_url=e.href.replace("&preview","")),(i=new n.view.Preview({model:this.model})).render(),this.setNavButtonsState(),n.data.settings.isMobile?i.$el.addClass("wp-full-overlay collapsed"):i.$el.addClass("wp-full-overlay expanded"),o(".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 o(".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(),o(".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=o(e.target)).prop("tagName").toLowerCase()&&(t=o(t.parent("a")[0])),i=o(".screenshot"),s="wporg-screenshot-card__active",r="wporg-thumbnail-screenshot-preview-js",a="style-variation",(e=o(".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),o("."+r).remove()):(e=o('<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),o("."+r).remove(),i.append(e),window.__wporg_screenshot_preview_render&&window.__wporg_screenshot_preview_render(r)),o("."+s).removeClass(s),t.addClass(s),this.model.attributes.preview_url=t.attr("href"))},setNavButtonsState:function(){var e=o(".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!==o(e.target).closest(".theme").length||_.delay(function(){o(".theme-wrap a.button-primary:visible").focus()},500),t.on("keydown.wp-themes",function(e){9===e.which&&o(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!==n.data.themes.length&&(e=e||window.event,!o(e.target).is(".close")&&27!==e.keyCode||(o("body").addClass("closing-overlay"),r.unmountReactAssets(),this.$el.fadeOut(1,function(){o("body").removeClass("closing-overlay"),r.closeOverlay(),t=document.body.scrollTop,(s=n.Collection.prototype.currentQuery.request.author)?(n.router.navigate(n.router.baseUrl("author/"+s)),n.utils.title(s,"author")):(s=n.Collection.prototype.currentQuery.request.search)?(n.router.navigate(n.router.baseUrl(n.router.searchPath+s)),n.utils.title(s,"search")):(i=n.view.Installer.prototype.filtersChecked())?(n.router.navigate(n.router.baseUrl("tags/"+i.join("+"))),n.utils.title(_.each(i,function(e,t){i[t]=o('label[for="filter-id-'+e+'"]').text()})[0],"tags")):(s=o(".filter-links .current"))&&(s.length||(s=o('.filter-links [data-sort="'+n.data.settings.browseDefault+'"]'),a={trigger:!0}),n.data.settings.browseDefault===s.data("sort")?(n.router.navigate(n.router.baseUrl("/"),a),n.utils.title("home")):(n.router.navigate(n.router.baseUrl(n.router.browsePath+s.data("sort")),a),n.utils.title(s.text(),"browse"))),document.body.scrollTop=t,n.focusedTheme&&n.focusedTheme.focus()})))},renderDownloadsGraph:function(){var t=this;o.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),o.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){o.each(e,function(e,t){t=o('<div class="wporg-screenshot-preview-js"></div>').attr("data-link",t.link).attr("data-preview-link",t.preview_link+"&v="+s.get("version")+"-betaV2").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()}o.ajax(e).done(function(e){var t=o("#theme-patterns-grid-js"),i=o("#theme-patterns-button-js"),s=JSON.parse(e);s.length&&(o("#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;o.ajax(e).done(function(e){var i,t=o(".wporg-horizontal-slider-js"),e=JSON.parse(e);e.length&&(i=[],o.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&&(o(".wporg-horizontal-slider-js").each(function(){ReactDOM.unmountComponentAtNode(this)}),o(".wporg-screenshot-preview-js").each(function(){ReactDOM.unmountComponentAtNode(this)}),o(".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(){o("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")}}),n.view.Preview=n.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:n.template("theme-preview"),render:function(){var e=this.model.toJSON();this.$el.html(this.html(e)),n.router.navigate(n.router.baseUrl(n.router.themePath+this.model.get("id"))),this.$el.fadeIn(200,function(){o("body").addClass("theme-installer-active full-overlay-active"),o(".close-full-overlay").focus()}),n.activeDevicePreview&&this.setDevicePreview(n.activeDevicePreview)},close:function(){return this.$el.fadeOut(200,function(){o("body").removeClass("theme-installer-active full-overlay-active"),n.focusedTheme&&n.focusedTheme.focus()}),this.trigger("preview:close"),this.undelegateEvents(),this.unbind(),n.router.navigate(n.router.baseUrl(n.router.themePath+this.model.get("id"))),!1},collapse:function(){return this.$el.toggleClass("collapsed"),n.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(n.activeDevicePreview).addClass(e),n.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}}),n.view.Themes=wp.Backbone.View.extend({className:"themes",$overlay:o("div.theme-overlay"),index:0,count:o(".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(){o("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()}),o("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===n.data.themes.length&&(this.singleTheme=new n.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&&o(".add-new-theme").remove(),t.instance.each(function(e){t.theme=new n.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)||(n.router.navigate(n.router.baseUrl(n.router.themePath+this.model.id)),n.utils.title(this.model.attributes.name,"theme"),this.setView("detail"),o("body").addClass("modal-open"),this.overlay=new n.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]),o(".theme-header").find(".right").focus()}).listenTo(this.overlay,"theme:previous",function(){t.previous([t.model.cid]),o(".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)}}),n.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=""),_.debounce(_.bind(this.doSearch,this),300)(e.target.value))},doSearch:_.debounce(function(e){var t={};n.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)]),o(".filter-links li > a.current").removeClass("current"),o("body").removeClass("show-filters filters-applied"),e?(n.utils.title(e,"search"),n.router.navigate(n.router.baseUrl(n.router.searchPath+e),{replace:!0})):(delete t.search,t.browse=n.data.settings.browseDefault,n.utils.title("home"),n.router.navigate(n.router.baseUrl("/"),{replace:!0})),this.collection.query(t)},300)}),n.view.Installer=n.view.Appearance.extend({el:"#themes",events:{"click .filter-links li > a":"onSort","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:o(".wp-filter .search-form"),initialize:function(){n.view.Appearance.prototype.initialize.apply(this,arguments),this.sortValues=o(".filter-links li > a").map(function(){return o(this).data("sort")}).get()},render:function(){var i=this;this.search(),this.collection=new n.Collection,this.listenTo(this,"theme:end",function(){i.collection.loadingThemes||o("body").hasClass("modal-open")||i.collection.length<n.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;o("body").removeClass("loading-content"),o(".theme-browser").find("div.error").remove(),1<i.page&&(t=1+(i.page-1)*n.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(){o("body").removeClass("loading-content"),o(".theme-browser").find("div.error").remove(),o(".theme-browser").find("div.themes").before('<div class="error"><p>'+s.error+"</p></div>")}),this.view&&this.view.remove(),this.view=new n.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:n.data.settings.favorites.user}):this.collection.query({browse:e})},onSort:function(e){var t=o(e.target),i=t.data("sort");e.preventDefault(),i||!t.data("tag")?(o("body").removeClass("filters-applied show-filters"),t.hasClass(this.activeClass)||(this.sort(i),n.data.settings.browseDefault===i?n.router.navigate(n.router.baseUrl("/")):n.router.navigate(n.router.baseUrl(n.router.browsePath+i)))):n.router.trigger("route:tag",t.data("tag"))},sort:function(e){var t=this,i=!1;-1!==_.indexOf(this.sortValues,e)&&(i=o('.filter-links [data-sort="'+e+'"]')),t.clearSearch(),_.each(o(".filter-group").find(":checkbox").filter(":checked"),function(e){return o(e).prop("checked",!1),t.filtersChecked()}),o(".filter-links li > a, .theme-filter").removeClass(this.activeClass),i&&i.length?(i.addClass(this.activeClass),n.data.settings.browseDefault===e?n.utils.title("home"):n.utils.title(i.text(),"browse"),this.browse(e)):n.utils.title("404","notfound")},onFilter:function(e){var t=o(e.target),e=t.data("filter");t.hasClass(this.activeClass)||(o(".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=o(".filtered-by .tags");e&&e.preventDefault(),s&&(o("body").addClass("filters-applied"),o(".filter-links li > a.current").removeClass("current"),a.empty(),_.each(s,function(e){t=o('label[for="filter-id-'+e+'"]').text(),i.push(t),a.append('<span class="tag">'+t+"</span>"),o('.filter-links li > a[data-tag="'+e+'"]').addClass("current")}),n.router.navigate(n.router.baseUrl("tags/"+s.join("+"))),n.utils.title(i[0],"tags"),this.collection.query(r))},filtersChecked:function(){var e=o(".filter-group").find(":checkbox").filter(":checked"),t=o(".filter-drawer"),i=[];return _.each(e,function(e){i.push(o(e).prop("value"))}),0===i.length?(t.find(".apply-filters").prop("disabled",!0).find("span").text(""),t.find(".clear-filters").hide(),o("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(),o("body").hasClass("filters-applied")?this.backToFilters():o("body").hasClass("show-filters")&&this.filtersChecked()?this.addFilter():(this.clearSearch(),void o("body").toggleClass("show-filters"))},clearFilters:function(e){var t=o(".filter-group").find(":checkbox"),i=this;e.preventDefault(),_.each(t.filter(":checked"),function(e){return o(e).prop("checked",!1),i.filtersChecked()})},backToFilters:function(e){e&&e.preventDefault(),o("body").removeClass("filters-applied")},clearSearch:function(){o("#wp-filter-search-input").val("")}}),n.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){o(".wp-filter-search").val(e)},navigate:function(){Backbone.history._hasPushState&&Backbone.Router.prototype.navigate.apply(this,arguments)}}),n.History=Backbone.History.extend({getFragment:function(){return Backbone.History.prototype.getFragment.apply(this,arguments).replace(/\?.*/,"")}}),n.Run={init:function(){this.view=new n.view.Installer({section:n.data.settings.browseDefault,SearchView:n.view.Search}),Backbone.history=new n.History,this.render()},render:function(){this.view.render(),this.routes(),Backbone.history.start({root:n.data.settings.path,pushState:!0,hashChange:!1})},routes:function(){var i=this,s={};n.router=new n.Router,n.router.on("route:preview",function(e){i.view.collection.queries.push(n.data.query),s.theme=e,i.view.collection.query(s),i.view.view.expand(e)}),n.router.on("route:sort",function(e,t){t&&n.router.navigate("browse/"+e+"/",{replace:!0}),i.view.collection.queries.push(n.data.query),e=e||n.data.settings.browseDefault,i.view.sort(e),i.view.trigger("theme:close")}),n.router.on("route:search",function(e,t){t&&n.router.navigate("search/"+e+"/",{replace:!0}),i.view.collection.queries.push(n.data.query),o(".wp-filter-search").focus().trigger("keyup"),i.view.trigger("theme:close")}),n.router.on("route:tag",function(e,t){t&&n.router.navigate("tags/"+e+"/",{replace:!0}),i.view.collection.queries.push(n.data.query),_.each(e.split("+"),function(e){e=e.toLowerCase().replace(/[^a-z-]/g,""),o("#filter-id-"+e).prop("checked",!0)}),o("body").removeClass("show-filters").addClass("show-filters"),i.view.applyFilters(),i.view.trigger("theme:close")}),n.router.on("route:author",function(e,t){t&&n.router.navigate("author/"+e+"/",{replace:!0}),i.view.collection.queries.push(n.data.query),s.author=e,i.view.collection.query(s),n.utils.title(e,"author"),i.view.trigger("theme:close")})}},o(function(){n.Run.init()})}(jQuery),google.charts.load("current",{packages:["corechart"]});
Note: See TracChangeset
for help on using the changeset viewer.