mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-27 03:27:46 +01:00
49007e52bc
Patches occasionally come in on generated files. We should be kind to new contributors and give them a hint that these files are auto-generated. This is a follow-up to [41271], which added the banner to minified CSS files. Fixes #48424. See #30666. Built from https://develop.svn.wordpress.org/trunk@46589 git-svn-id: http://core.svn.wordpress.org/trunk@46386 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2 lines
26 KiB
JavaScript
2 lines
26 KiB
JavaScript
/*! This file is auto-generated */
|
|
window.wp=window.wp||{},function(o){var l,a;function e(e,t){Backbone.history._hasPushState&&Backbone.Router.prototype.navigate.call(this,e,t)}(l=wp.themes=wp.themes||{}).data=_wpThemeSettings,a=l.data.l10n,l.isInstall=!!l.data.settings.isInstall,_.extend(l,{model:{},view:{},routes:{},router:{},template:wp.template}),l.Model=Backbone.Model.extend({initialize:function(){var e;-1!==_.indexOf(l.data.installedThemes,this.get("slug"))&&this.set({installed:!0}),this.set({id:this.get("slug")||this.get("id")}),this.has("sections")&&(e=this.get("sections").description,this.set({description:e}))}}),l.view.Appearance=wp.Backbone.View.extend({el:"#wpbody-content .wrap .theme-browser",window:o(window),page:0,initialize:function(e){_.bindAll(this,"scroller"),this.SearchView=e.SearchView?e.SearchView:l.view.Search,this.window.bind("scroll",_.throttle(this.scroller,300))},render:function(){this.view=new l.view.Themes({collection:this.collection,parent:this}),this.search(),this.$el.removeClass("search-loading"),this.view.render(),this.$el.empty().append(this.view.el).addClass("rendered")},searchContainer:o(".search-form"),search:function(){var e;1!==l.data.themes.length&&(e=new this.SearchView({collection:this.collection,parent:this}),(this.SearchView=e).render(),this.searchContainer.append(o.parseHTML('<label class="screen-reader-text" for="wp-filter-search-input">'+a.search+"</label>")).append(e.el).on("submit",function(e){e.preventDefault()}))},scroller:function(){var e,t,i=this;e=this.window.scrollTop()+i.window.height(),t=i.$el.offset().top+i.$el.outerHeight(!1)-i.window.height(),(t=Math.round(.9*t))<e&&this.trigger("theme:scroll")}}),l.Collection=Backbone.Collection.extend({model:l.Model,terms:"",doSearch:function(e){this.terms!==e&&(this.terms=e,0<this.terms.length&&this.search(this.terms),""===this.terms&&(this.reset(l.data.themes),o("body").removeClass("no-results")),this.trigger("themes:update"))},search:function(t){var i,e,s,r,a,n;this.reset(l.data.themes,{silent:!0}),t=(t=(t=t.trim()).replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")).replace(/ /g,")(?=.*"),i=new RegExp("^(?=.*"+t+").+","i"),0===(e=this.filter(function(e){return r=e.get("name").replace(/(<([^>]+)>)/gi,""),a=e.get("description").replace(/(<([^>]+)>)/gi,""),n=e.get("author").replace(/(<([^>]+)>)/gi,""),s=_.union([r,e.get("id"),a,n,e.get("tags")]),i.test(e.get("author"))&&2<t.length&&e.set("displayAuthor",!0),i.test(s)})).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(20*e)),t=_(t.first(20))},count:!1,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("query:success"),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 e=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")})},queries:[],currentQuery:{page:1,request:{}},apiCall:function(e,t){return wp.ajax.send("query-themes",{data:{request:_.extend({per_page:100},e)},beforeSend:function(){t||o("body").addClass("loading-content").removeClass("no-results")}})},loadingThemes:!1}),l.view.Theme=wp.Backbone.View.extend({className:"theme",state:"grid",html:l.template("theme"),events:{click:l.isInstall?"preview":"expand",keydown:l.isInstall?"preview":"expand",touchend:l.isInstall?"preview":"expand",keyup:"addFocus",touchmove:"preventExpand","click .theme-install":"installTheme","click .update-message":"updateTheme"},touchDrag:!1,initialize:function(){this.model.on("change",this.render,this)},render:function(){var e=this.model.toJSON();this.$el.html(this.html(e)).attr({tabindex:0,"aria-describedby":e.id+"-action "+e.id+"-name","data-slug":e.id}),this.activeTheme(),this.model.get("displayAuthor")&&this.$el.addClass("display-author")},activeTheme:function(){this.model.get("active")&&this.$el.addClass("active")},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("keydown"!==(e=e||window.event).type||13===e.which||32===e.which)return!0===this.touchDrag?this.touchDrag=!1:void(o(e.target).is(".theme-actions a")||o(e.target).is(".theme-actions a, .update-message, .button-link, .notice-dismiss")||(l.focusedTheme=this.$el,this.trigger("theme:expand",this.model.cid)))},preventExpand:function(){this.touchDrag=!0},preview:function(e){var t,i,s=this;if(e=e||window.event,!0===this.touchDrag)return this.touchDrag=!1;o(e.target).not(".install-theme-preview").parents(".theme-actions").length||"keydown"===e.type&&13!==e.which&&32!==e.which||"keydown"===e.type&&13!==e.which&&o(":focus").hasClass("button")||(e.preventDefault(),e=e||window.event,l.focusedTheme=this.$el,l.preview=i=new l.view.Preview({model:this.model}),i.render(),this.setNavButtonsState(),1===this.model.collection.length?i.$el.addClass("no-navigation"):i.$el.removeClass("no-navigation"),o("div.wrap").append(i.el),this.listenTo(i,"theme:next",function(){if(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(),o(".next-theme").focus()}).listenTo(i,"theme:previous",function(){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.current=s.model}))},setNavButtonsState:function(){var e=o(".theme-install-overlay"),t=_.isUndefined(this.current)?this.model:this.current,i=e.find(".previous-theme"),s=e.find(".next-theme");0===this.model.collection.indexOf(t)&&(i.addClass("disabled").prop("disabled",!0),s.focus()),_.isUndefined(this.model.collection.at(this.model.collection.indexOf(t)+1))&&(s.addClass("disabled").prop("disabled",!0),i.focus())},installTheme:function(e){var i=this;e.preventDefault(),wp.updates.maybeRequestFilesystemCredentials(e),o(document).on("wp-theme-install-success",function(e,t){i.model.get("id")===t.slug&&i.model.set({installed:!0})}),wp.updates.installTheme({slug:o(e.target).data("slug")})},updateTheme:function(e){var i=this;this.model.get("hasPackage")&&(e.preventDefault(),wp.updates.maybeRequestFilesystemCredentials(e),o(document).on("wp-theme-update-success",function(e,t){i.model.off("change",i.render,i),i.model.get("id")===t.slug&&i.model.set({hasUpdate:!1,version:t.newVersion}),i.model.on("change",i.render,i)}),wp.updates.updateTheme({slug:o(e.target).parents("div.theme").first().data("slug")}))}}),l.view.Details=wp.Backbone.View.extend({className:"theme-overlay",events:{click:"collapse","click .delete-theme":"deleteTheme","click .left":"previousTheme","click .right":"nextTheme","click #update-theme":"updateTheme"},html:l.template("theme-single"),render:function(){var e=this.model.toJSON();this.$el.html(this.html(e)),this.activeTheme(),this.navigation(),this.screenshotCheck(this.$el),this.containFocus(this.$el)},activeTheme:function(){this.$el.toggleClass("active",this.model.get("active"))},containFocus:function(s){_.delay(function(){o(".theme-overlay").focus()},100),s.on("keydown.wp-themes",function(e){var t=s.find(".theme-header button:not(.disabled)").first(),i=s.find(".theme-actions a:visible").last();9===e.which&&(t[0]===e.target&&e.shiftKey?(i.focus(),e.preventDefault()):i[0]!==e.target||e.shiftKey||(t.focus(),e.preventDefault()))})},collapse:function(e){var t,i=this;e=e||window.event,1!==l.data.themes.length&&(o(e.target).is(".theme-backdrop")||o(e.target).is(".close")||27===e.keyCode)&&(o("body").addClass("closing-overlay"),this.$el.fadeOut(130,function(){o("body").removeClass("closing-overlay"),i.closeOverlay(),t=document.body.scrollTop,l.router.navigate(l.router.baseUrl("")),document.body.scrollTop=t,l.focusedTheme&&l.focusedTheme.focus()}))},navigation:function(){this.model.cid===this.model.collection.at(0).cid&&this.$el.find(".left").addClass("disabled").prop("disabled",!0),this.model.cid===this.model.collection.at(this.model.collection.length-1).cid&&this.$el.find(".right").addClass("disabled").prop("disabled",!0)},closeOverlay:function(){o("body").removeClass("modal-open"),this.remove(),this.unbind(),this.trigger("theme:collapse")},updateTheme:function(e){var i=this;e.preventDefault(),wp.updates.maybeRequestFilesystemCredentials(e),o(document).on("wp-theme-update-success",function(e,t){i.model.get("id")===t.slug&&i.model.set({hasUpdate:!1,version:t.newVersion}),i.render()}),wp.updates.updateTheme({slug:o(e.target).data("slug")})},deleteTheme:function(e){var i=this,s=i.model.collection,r=l;e.preventDefault(),window.confirm(wp.themes.data.settings.confirmDelete)&&(wp.updates.maybeRequestFilesystemCredentials(e),o(document).one("wp-theme-delete-success",function(e,t){i.$el.find(".close").trigger("click"),o('[data-slug="'+t.slug+'"]').css({backgroundColor:"#faafaa"}).fadeOut(350,function(){o(this).remove(),r.data.themes=_.without(r.data.themes,_.findWhere(r.data.themes,{id:t.slug})),o(".wp-filter-search").val(""),s.doSearch(""),s.remove(i.model),s.trigger("themes:update")})}),wp.updates.deleteTheme({slug:this.model.get("id")}))},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){var t,i;t=e.find(".screenshot img"),(i=new Image).src=t.attr("src"),i.width&&i.width<=300&&e.addClass("small-screenshot")}}),l.view.Preview=l.view.Details.extend({className:"wp-full-overlay expanded",el:".theme-install-overlay",events:{"click .close-full-overlay":"close","click .collapse-sidebar":"collapse","click .devices button":"previewDevice","click .previous-theme":"previousTheme","click .next-theme":"nextTheme",keyup:"keyEvent","click .theme-install":"installTheme"},html:l.template("theme-preview"),render:function(){var e,t=this,i=this.model.toJSON(),s=o(document.body);s.attr("aria-busy","true"),this.$el.removeClass("iframe-ready").html(this.html(i)),(e=this.$el.data("current-preview-device"))&&t.tooglePreviewDeviceButtons(e),l.router.navigate(l.router.baseUrl(l.router.themePath+this.model.get("id")),{replace:!1}),this.$el.fadeIn(200,function(){s.addClass("theme-installer-active full-overlay-active")}),this.$el.find("iframe").one("load",function(){t.iframeLoaded()})},iframeLoaded:function(){this.$el.addClass("iframe-ready"),o(document.body).attr("aria-busy","false")},close:function(){return this.$el.fadeOut(200,function(){o("body").removeClass("theme-installer-active full-overlay-active"),l.focusedTheme&&l.focusedTheme.focus()}).removeClass("iframe-ready"),l.router.selectedTab?(l.router.navigate(l.router.baseUrl("?browse="+l.router.selectedTab)),l.router.selectedTab=!1):l.router.navigate(l.router.baseUrl("")),this.trigger("preview:close"),this.undelegateEvents(),this.unbind(),!1},collapse:function(e){var t=o(e.currentTarget);return"true"===t.attr("aria-expanded")?t.attr({"aria-expanded":"false","aria-label":a.expandSidebar}):t.attr({"aria-expanded":"true","aria-label":a.collapseSidebar}),this.$el.toggleClass("collapsed").toggleClass("expanded"),!1},previewDevice:function(e){var t=o(e.currentTarget).data("device");this.$el.removeClass("preview-desktop preview-tablet preview-mobile").addClass("preview-"+t).data("current-preview-device",t),this.tooglePreviewDeviceButtons(t)},tooglePreviewDeviceButtons:function(e){var t=o(".wp-full-overlay-footer .devices");t.find("button").removeClass("active").attr("aria-pressed",!1),t.find("button.preview-"+e).addClass("active").attr("aria-pressed",!0)},keyEvent:function(e){27===e.keyCode&&(this.undelegateEvents(),this.close()),39===e.keyCode&&_.once(this.nextTheme()),37===e.keyCode&&this.previousTheme()},installTheme:function(e){var t=this,i=o(e.target);e.preventDefault(),i.hasClass("disabled")||(wp.updates.maybeRequestFilesystemCredentials(e),o(document).on("wp-theme-install-success",function(){t.model.set({installed:!0})}),wp.updates.installTheme({slug:i.data("slug")}))}}),l.view.Themes=wp.Backbone.View.extend({className:"themes wp-clearfix",$overlay:o("div.theme-overlay"),index:0,count:o(".wrap .theme-count"),liveThemeCount:0,initialize:function(e){var t=this;this.parent=e.parent,this.setView("grid"),t.currentTheme(),this.listenTo(t.collection,"themes:update",function(){t.parent.page=0,t.currentTheme(),t.render(this)}),this.listenTo(t.collection,"query:success",function(e){_.isNumber(e)?(t.count.text(e),t.announceSearchResults(e)):(t.count.text(t.collection.length),t.announceSearchResults(t.collection.length))}),this.listenTo(t.collection,"query:empty",function(){o("body").addClass("no-results")}),this.listenTo(this.parent,"theme:scroll",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&&(o("#request-filesystem-credentials-dialog").is(":visible")||(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===l.data.themes.length&&(this.singleTheme=new l.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.liveThemeCount=this.collection.count?this.collection.count:this.collection.length,this.count.text(this.liveThemeCount),l.isInstall||this.announceSearchResults(this.liveThemeCount)},renderThemes:function(e){var t=this;t.instance=t.collection.paginate(e),0!==t.instance.size()?(!l.isInstall&&1<=e&&o(".add-new-theme").remove(),t.instance.each(function(e){t.theme=new l.view.Theme({model:e,parent:t}),t.theme.render(),t.$el.append(t.theme.el),t.listenTo(t.theme,"theme:expand",t.expand,t)}),!l.isInstall&&l.data.settings.canInstall&&this.$el.append('<div class="theme add-new-theme"><a href="'+l.data.settings.installURI+'"><div class="theme-screenshot"><span></span></div><h2 class="theme-name">'+a.addNew+"</h2></a></div>"),this.parent.page++):this.parent.trigger("theme:end")},currentTheme:function(){var e;(e=this.collection.findWhere({active:!0}))&&(this.collection.remove(e),this.collection.add(e,{at:0}))},setView:function(e){return e},expand:function(e){var t,i,s=this;this.model=s.collection.get(e),l.router.navigate(l.router.baseUrl(l.router.themePath+this.model.id)),this.setView("detail"),o("body").addClass("modal-open"),this.overlay=new l.view.Details({model:s.model}),this.overlay.render(),this.model.get("hasUpdate")&&(t=o('[data-slug="'+this.model.id+'"]'),i=o(this.overlay.el),t.find(".updating-message").length?(i.find(".notice-warning h3").remove(),i.find(".notice-warning").removeClass("notice-large").addClass("updating-message").find("p").text(wp.updates.l10n.updating)):t.find(".notice-error").length&&i.find(".notice-warning").remove()),this.$overlay.html(this.overlay.el),this.listenTo(this.overlay,"theme:next",function(){s.next([s.model.cid])}).listenTo(this.overlay,"theme:previous",function(){s.previous([s.model.cid])})},next:function(e){var t,i;t=this.collection.get(e[0]),void 0!==(i=this.collection.at(this.collection.indexOf(t)+1))&&(this.overlay.closeOverlay(),this.theme.trigger("theme:expand",i.cid))},previous:function(e){var t,i;t=this.collection.get(e[0]),void 0!==(i=this.collection.at(this.collection.indexOf(t)-1))&&(this.overlay.closeOverlay(),this.theme.trigger("theme:expand",i.cid))},announceSearchResults:function(e){0===e?wp.a11y.speak(a.noThemesFound):wp.a11y.speak(a.themesFound.replace("%d",e))}}),l.view.Search=wp.Backbone.View.extend({tagName:"input",className:"wp-filter-search",id:"wp-filter-search-input",searching:!1,attributes:{placeholder:a.searchPlaceholder,type:"search","aria-describedby":"live-search-desc"},events:{input:"search",keyup:"search",blur:"pushState"},initialize:function(e){this.parent=e.parent,this.listenTo(this.parent,"theme:close",function(){this.searching=!1})},search:function(e){"keyup"===e.type&&27===e.which&&(e.target.value=""),this.doSearch(e)},doSearch:function(e){var t={};this.collection.doSearch(e.target.value.replace(/\+/g," ")),this.searching&&13!==e.which?t.replace=!0:this.searching=!0,e.target.value?l.router.navigate(l.router.baseUrl(l.router.searchPath+e.target.value),t):l.router.navigate(l.router.baseUrl(""))},pushState:function(e){var t=l.router.baseUrl("");e.target.value&&(t=l.router.baseUrl(l.router.searchPath+encodeURIComponent(e.target.value))),this.searching=!1,l.router.navigate(t)}}),l.Router=Backbone.Router.extend({routes:{"themes.php?theme=:slug":"theme","themes.php?search=:query":"search","themes.php?s=:query":"search","themes.php":"themes","":"themes"},baseUrl:function(e){return"themes.php"+e},themePath:"?theme=",searchPath:"?search=",search:function(e){o(".wp-filter-search").val(e.replace(/\+/g," "))},themes:function(){o(".wp-filter-search").val("")},navigate:e}),l.Run={init:function(){this.themes=new l.Collection(l.data.themes),this.view=new l.view.Appearance({collection:this.themes}),this.render(),this.view.SearchView.doSearch=_.debounce(this.view.SearchView.doSearch,500)},render:function(){this.view.render(),this.routes(),Backbone.History.started&&Backbone.history.stop(),Backbone.history.start({root:l.data.settings.adminUrl,pushState:!0,hashChange:!1})},routes:function(){var t=this;l.router=new l.Router,l.router.on("route:theme",function(e){t.view.view.expand(e)}),l.router.on("route:themes",function(){t.themes.doSearch(""),t.view.trigger("theme:close")}),l.router.on("route:search",function(){o(".wp-filter-search").trigger("keyup")}),this.extraRoutes()},extraRoutes:function(){return!1}},l.view.InstallerSearch=l.view.Search.extend({events:{input:"search",keyup:"search"},terms:"",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(e.target.value))},doSearch:function(e){var t={};this.terms!==e&&(this.terms=e,"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").removeAttr("aria-current"),o("body").removeClass("show-filters filters-applied show-favorites-form"),o(".drawer-toggle").attr("aria-expanded","false"),this.collection.query(t),l.router.navigate(l.router.baseUrl(l.router.searchPath+encodeURIComponent(e)),{replace:!0}))}}),l.view.Installer=l.view.Appearance.extend({el:"#wpbody-content .wrap",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 .edit-filters":"backToFilters","click .favorites-form-submit":"saveUsername","keyup #wporg-username-input":"saveUsername"},render:function(){var e=this;this.search(),this.uploader(),this.collection=new l.Collection,this.listenTo(this,"theme:end",function(){e.collection.loadingThemes||(e.collection.loadingThemes=!0,e.collection.currentQuery.page++,_.extend(e.collection.currentQuery.request,{page:e.collection.currentQuery.page}),e.collection.query(e.collection.currentQuery.request))}),this.listenTo(this.collection,"query:success",function(){o("body").removeClass("loading-content"),o(".theme-browser").find("div.error").remove()}),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>'+a.error+'</p><p><button class="button try-again">'+a.tryAgain+"</button></p></div>"),o(".theme-browser .error .try-again").on("click",function(e){e.preventDefault(),o("input.wp-filter-search").trigger("input")})}),this.view&&this.view.remove(),this.view=new l.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){this.collection.query({browse:e})},onSort:function(e){var t=o(e.target),i=t.data("sort");e.preventDefault(),o("body").removeClass("filters-applied show-filters"),o(".drawer-toggle").attr("aria-expanded","false"),t.hasClass(this.activeClass)||(this.sort(i),l.router.navigate(l.router.baseUrl(l.router.browsePath+i)))},sort:function(e){this.clearSearch(),l.router.selectedTab=e,o(".filter-links li > a, .theme-filter").removeClass(this.activeClass).removeAttr("aria-current"),o('[data-sort="'+e+'"]').addClass(this.activeClass).attr("aria-current","page"),"favorites"===e?o("body").addClass("show-favorites-form"):o("body").removeClass("show-favorites-form"),this.browse(e)},onFilter:function(e){var t,i=o(e.target),s=i.data("filter");i.hasClass(this.activeClass)||(o(".filter-links li > a, .theme-section").removeClass(this.activeClass).removeAttr("aria-current"),i.addClass(this.activeClass).attr("aria-current","page"),s&&(t={tag:[s=_.union([s,this.filtersChecked()])]},this.collection.query(t)))},addFilter:function(){this.filtersChecked()},applyFilters:function(e){var t,i=this.filtersChecked(),s={tag:i},r=o(".filtered-by .tags");e&&e.preventDefault(),i?(o("body").addClass("filters-applied"),o(".filter-links li > a.current").removeClass("current").removeAttr("aria-current"),r.empty(),_.each(i,function(e){t=o('label[for="filter-id-'+e+'"]').text(),r.append('<span class="tag">'+t+"</span>")}),this.collection.query(s)):wp.a11y.speak(a.selectFeatureFilter)},saveUsername:function(e){var t=o("#wporg-username-input").val(),i=o("#wporg-username-nonce").val(),s={browse:"favorites",user:t},r=this;if(e&&e.preventDefault(),"keyup"!==e.type||13===e.which)return wp.ajax.send("save-wporg-username",{data:{_wpnonce:i,username:t},success:function(){r.collection.query(s)}})},filtersChecked:function(){var e=o(".filter-group").find(":checkbox"),t=[];return _.each(e.filter(":checked"),function(e){t.push(o(e).prop("value"))}),0===t.length?(o(".filter-drawer .apply-filters").find("span").text(""),o(".filter-drawer .clear-filters").hide(),o("body").removeClass("filters-applied"),!1):(o(".filter-drawer .apply-filters").find("span").text(t.length),o(".filter-drawer .clear-filters").css("display","inline-block"),t)},activeClass:"current",uploader:function(){var e=o(".upload-view-toggle"),t=o(document.body);e.on("click",function(){t.toggleClass("show-upload-view"),e.attr("aria-expanded",t.hasClass("show-upload-view"))})},moreFilters:function(e){var t=o("body"),i=o(".drawer-toggle");if(e.preventDefault(),t.hasClass("filters-applied"))return this.backToFilters();this.clearSearch(),l.router.navigate(l.router.baseUrl("")),t.toggleClass("show-filters"),i.attr("aria-expanded",t.hasClass("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("")}}),l.InstallerRouter=Backbone.Router.extend({routes:{"theme-install.php?theme=:slug":"preview","theme-install.php?browse=:sort":"sort","theme-install.php?search=:query":"search","theme-install.php":"sort"},baseUrl:function(e){return"theme-install.php"+e},themePath:"?theme=",browsePath:"?browse=",searchPath:"?search=",search:function(e){o(".wp-filter-search").val(e.replace(/\+/g," "))},navigate:e}),l.RunInstaller={init:function(){this.view=new l.view.Installer({section:"featured",SearchView:l.view.InstallerSearch}),this.render(),this.view.SearchView.doSearch=_.debounce(this.view.SearchView.doSearch,500)},render:function(){this.view.render(),this.routes(),Backbone.History.started&&Backbone.history.stop(),Backbone.history.start({root:l.data.settings.adminUrl,pushState:!0,hashChange:!1})},routes:function(){var t=this,i={};l.router=new l.InstallerRouter,l.router.on("route:preview",function(e){l.preview&&(l.preview.undelegateEvents(),l.preview.unbind()),t.view.view.theme&&t.view.view.theme.preview?(t.view.view.theme.model=t.view.collection.findWhere({slug:e}),t.view.view.theme.preview()):(i.theme=e,t.view.collection.query(i),t.view.collection.trigger("update"),t.view.collection.once("query:success",function(){o('div[data-slug="'+e+'"]').trigger("click")}))}),l.router.on("route:sort",function(e){e||(e="featured",l.router.navigate(l.router.baseUrl("?browse=featured"),{replace:!0})),t.view.sort(e),l.preview&&l.preview.close()}),l.router.on("route:search",function(){o(".wp-filter-search").focus().trigger("keyup")}),this.extraRoutes()},extraRoutes:function(){return!1}},o(document).ready(function(){l.isInstall?l.RunInstaller.init():l.Run.init(),o(document.body).on("click",".load-customize",function(){var e=o(this),t=document.createElement("a");t.href=e.prop("href"),t.search=o.param(_.extend(wp.customize.utils.parseQueryString(t.search.substr(1)),{return:window.location.href})),e.prop("href",t.href)}),o(".broken-themes .delete-theme").on("click",function(){return confirm(_wpThemeSettings.settings.confirmDelete)})})}(jQuery),jQuery(document).ready(function(a){window.tb_position=function(){var e=a("#TB_window"),t=a(window).width(),i=a(window).height(),s=1040<t?1040:t,r=0;a("#wpadminbar").length&&(r=parseInt(a("#wpadminbar").css("height"),10)),e.size()&&(e.width(s-50).height(i-45-r),a("#TB_iframeContent").width(s-50).height(i-75-r),e.css({"margin-left":"-"+parseInt((s-50)/2,10)+"px"}),void 0!==document.body.style.maxWidth&&e.css({top:20+r+"px","margin-top":"0"}))},a(window).resize(function(){tb_position()})}); |