var tb_position;window.wp=window.wp||{},function(o){var i,a=wp.themes=wp.themes||{};a.data=_wpThemeSettings,i=a.data.l10n,a.isInstall=!!a.data.settings.isInstall,_.extend(a,{model:{},view:{},routes:{},router:{},template:wp.template}),a.Model=Backbone.Model.extend({initialize:function(){var e;-1!==_.indexOf(a.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}))}}),a.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||a.view.Search,this.window.bind("scroll",_.throttle(this.scroller,300))},render:function(){this.view=new a.view.Themes({collection:this.collection,parent:this}),this.search(),this.view.render(),this.$el.empty().append(this.view.el).addClass("rendered"),this.$el.append('
')},searchContainer:o("#wpbody h2:first"),search:function(){var e;1!==a.data.themes.length&&((e=new this.SearchView({collection:this.collection,parent:this})).render(),this.searchContainer.append(o.parseHTML('")).append(e.el))},scroller:function(){var e=this,t=this.window.scrollTop()+e.window.height(),e=e.$el.offset().top+e.$el.outerHeight(!1)-e.window.height();Math.round(.9*e)]+)>)/gi,""),r=e.get("description").replace(/(<([^>]+)>)/gi,""),n=e.get("author").replace(/(<([^>]+)>)/gi,""),n=_.union(s,e.get("id"),r,n,e.get("tags")),i.test(e.get("author"))&&2
'+i.addNew+"
"),this.parent.page++):this.parent.trigger("theme:end")},currentTheme:function(){var e=this.collection.findWhere({active:!0});e&&(this.collection.remove(e),this.collection.add(e,{at:0}))},setView:function(e){return e},expand:function(e){var t=this;this.model=t.collection.get(e),a.router.navigate(a.router.baseUrl(a.router.themePath+this.model.id)),this.setView("detail"),o("body").addClass("modal-open"),this.overlay=new a.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])}).listenTo(this.overlay,"theme:previous",function(){t.previous([t.model.cid])})},next:function(e){var e=this.collection.get(e[0]),e=this.collection.at(this.collection.indexOf(e)+1);void 0!==e&&(this.overlay.closeOverlay(),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.overlay.closeOverlay(),this.theme.trigger("theme:expand",e.cid))},announceSearchResults:function(e){0===e?wp.a11y.speak(i.noThemesFound):wp.a11y.speak(i.themesFound.replace("%d",e))}}),a.view.Search=wp.Backbone.View.extend({tagName:"input",className:"wp-filter-search",id:"wp-filter-search-input",searching:!1,attributes:{placeholder:i.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:_.debounce(function(e){var t={};this.collection.doSearch(e.target.value),this.searching&&13!==e.which?t.replace=!0:this.searching=!0,e.target.value?a.router.navigate(a.router.baseUrl(a.router.searchPath+e.target.value),t):a.router.navigate(a.router.baseUrl(""))},500),pushState:function(e){var t=a.router.baseUrl("");e.target.value&&(t=a.router.baseUrl(a.router.searchPath+e.target.value)),this.searching=!1,a.router.navigate(t)}}),a.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)},themes:function(){o(".wp-filter-search").val("")},navigate:function(){Backbone.history._hasPushState&&Backbone.Router.prototype.navigate.apply(this,arguments)}}),a.Run={init:function(){this.themes=new a.Collection(a.data.themes),this.view=new a.view.Appearance({collection:this.themes}),this.render()},render:function(){this.view.render(),this.routes(),Backbone.history.start({root:a.data.settings.adminUrl,pushState:!0,hashChange:!1})},routes:function(){var t=this;a.router=new a.Router,a.router.on("route:theme",function(e){t.view.view.expand(e)}),a.router.on("route:themes",function(){t.themes.doSearch(""),t.view.trigger("theme:close")}),a.router.on("route:search",function(){o(".wp-filter-search").trigger("keyup")}),this.extraRoutes()},extraRoutes:function(){return!1}},a.view.InstallerSearch=a.view.Search.extend({events:{input:"search",keyup:"search"},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:_.debounce(function(e){var t={};"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"),this.collection.query(t),a.router.navigate(a.router.baseUrl(a.router.searchPath+e),{replace:!0})},500)}),a.view.Installer=a.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 .filtered-by":"backToFilters"},render:function(){var e=this;this.search(),this.uploader(),this.collection=new a.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('")}),this.view&&this.view.remove(),this.view=new a.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"),t.hasClass(this.activeClass)||(this.sort(i),a.router.navigate(a.router.baseUrl(a.router.browsePath+i)))},sort:function(e){this.clearSearch(),o(".filter-links li > a, .theme-filter").removeClass(this.activeClass),o('[data-sort="'+e+'"]').addClass(this.activeClass),this.browse(e)},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={tag:[e=_.union(e,this.filtersChecked())]},this.collection.query(e)))},addFilter:function(){this.filtersChecked()},applyFilters:function(e){var t,i=this.filtersChecked(),s={tag:i},r=o(".filtered-by .tags");e&&e.preventDefault(),o("body").addClass("filters-applied"),o(".filter-links li > a.current").removeClass("current"),r.empty(),_.each(i,function(e){t=o('label[for="filter-id-'+e+'"]').text(),r.append(''+t+"")}),this.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",searchContainer:o(".wp-filter .search-form"),uploader:function(){o("a.upload").on("click",function(e){e.preventDefault(),o("body").addClass("show-upload-theme"),a.router.navigate(a.router.baseUrl("?upload"),{replace:!0})}),o("a.browse-themes").on("click",function(e){e.preventDefault(),o("body").removeClass("show-upload-theme"),a.router.navigate(a.router.baseUrl(""),{replace:!0})})},moreFilters:function(e){return e.preventDefault(),o("body").hasClass("filters-applied")?this.backToFilters():o("body").hasClass("show-filters")&&this.filtersChecked()?this.addFilter():(this.clearSearch(),a.router.navigate(a.router.baseUrl("")),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("")}}),a.InstallerRouter=Backbone.Router.extend({routes:{"theme-install.php?theme=:slug":"preview","theme-install.php?browse=:sort":"sort","theme-install.php?upload":"upload","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)},navigate:function(){Backbone.history._hasPushState&&Backbone.Router.prototype.navigate.apply(this,arguments)}}),a.RunInstaller={init:function(){this.view=new a.view.Installer({section:"featured",SearchView:a.view.InstallerSearch}),this.render()},render:function(){this.view.render(),this.routes(),Backbone.history.start({root:a.data.settings.adminUrl,pushState:!0,hashChange:!1})},routes:function(){var t=this,i={};a.router=new a.InstallerRouter,a.router.on("route:preview",function(e){i.theme=e,t.view.collection.query(i)}),a.router.on("route:sort",function(e){e=e||"featured",t.view.sort(e),t.view.trigger("theme:close")}),a.router.on("route:upload",function(){o("a.upload").trigger("click")}),a.router.on("route:search",function(){o(".wp-filter-search").focus().trigger("keyup")}),this.extraRoutes()},extraRoutes:function(){return!1}},o(document).ready(function(){(a.isInstall?a.RunInstaller:a.Run).init(),o(".broken-themes .delete-theme").on("click",function(){return confirm(_wpThemeSettings.settings.confirmDelete)})})}(jQuery),jQuery(document).ready(function(r){tb_position=function(){var e=r("#TB_window"),t=r(window).width(),i=r(window).height(),s=1040