mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-09 04:11:10 +01:00
1 line
7.2 KiB
JavaScript
1 line
7.2 KiB
JavaScript
|
window.wp=window.wp||{},function(a){var b=wp.themes=wp.themes||{};b.data=_wpThemeSettings,_.extend(b,{model:{},view:{},routes:{},router:{},template:wp.template}),b.model=Backbone.Model.extend({}),b.view.Appearance=wp.Backbone.View.extend({el:b.data.settings.container,window:a(window),page:0,events:{"click .themes-bulk-edit":"editMode","click .theme .delete-theme":"deleteTheme"},initialize:function(){var a=this;this.window.bind("scroll.themes",function(){this.throttle=!0}),setInterval(function(){this.throttle&&(this.throttle=!1,a.scroller())},300)},render:function(){this.view=new b.view.Themes({collection:this.collection,parent:this}),this.view.render(),this.$el.append(this.view.el),this.search()},search:function(){var a,c=this;a=new b.view.Search({collection:c.collection}),a.render(),c.$el.find("> h2").after(a.el)},scroller:function(){var a,b,c=this;a=this.window.scrollTop()+c.window.height(),b=c.$el.offset().top+c.$el.outerHeight(!1)-c.window.height(),b=Math.round(.9*b),a>b&&this.trigger("theme:scroll")},editMode:function(){a("body").toggleClass("edit-mode"),this.$el.find(".themes-bulk-edit").toggleClass("mp6-text-highlight")},deleteTheme:function(){return confirm(b.data.settings.confirmDelete)}}),b.Collection=Backbone.Collection.extend({model:b.model,terms:"",doSearch:function(a){this.terms=a,this.terms.length>0&&this.search(this.terms),""===this.terms&&this.reset(b.data.themes),this.trigger("update")},search:function(a){var c,d,e,f=this;f.reset(b.data.themes),a=a.replace(" ",")(?=.*"),c=new RegExp("^(?=.*"+a+").+","i"),d=f.filter(function(a){return e=_.union(a.get("name"),a.get("author"),a.get("tags")),c.test(a.get("author"))&&a.set("displayAuthor",!0),c.test(e)}),f.reset(d)},paginate:function(a){var b=this;return a=a||0,b=_(b.rest(15*a)),b=_(b.first(15))}}),b.view.Theme=wp.Backbone.View.extend({className:"theme",state:"grid",html:b.template("theme"),events:{click:"expand"},render:function(){var a=this.model.toJSON();this.$el.html(this.html(a)),this.activeTheme(),this.model.get("displayAuthor")&&this.$el.addClass("display-author")},activeTheme:function(){this.model.get("active")&&(this.$el.addClass("active"),this.$el.find(".theme-name").addClass("mp6-primary"),a("#theme-overlay").addClass("active"))},expand:function(b){var c=this;b=b||window.event,a(b.target).is(".theme-actions a, .delete-theme")||this.trigger("theme:expand",c.model.cid)}}),b.view.Details=wp.Backbone.View.extend({id:"theme-overlay",events:{click:"collapse","click .delete-theme":"deleteTheme","click .left":"previousTheme","click .right":"nextTheme"},html:b.template("theme-single"),render:function(){var a=this.model.toJSON();this.$el.html(this.html(a)),this.activeTheme(),this.navigation()},activeTheme:function(){this.model.get("active")?this.$el.addClass("active"):a("#theme-overlay").removeClass("active")},collapse:function(c){var d,e=this;c=c||window.event,(a(c.target).is(".theme-backdrop")||a(c.target).is("div.back")||27===c.keyCode)&&(a("body").addClass("closing-overlay"),this.$el.fadeOut(130,function(){a("body").removeClass("theme-overlay closing-overlay"),e.closeOverlay(),d=document.body.scrollTop,b.router.navigate(""),document.body.scrollTop=d}))},navigation:function(){var b=this;a("body").on("keyup",function(a){39===a.keyCode&&b.trigger("theme:next",b.model.cid),37===a.keyCode&&b.trigger("theme:previous",b.model.cid),27===a.keyCode&&b.collapse()})},closeOverlay:function(){this.remove(),this.unbind(),this.trigger("theme:collapse")},screenshotGallery:function(){var b,c,d=a("#theme-screenshots");d.find("div.first").next().addClass("selected"),d.on("click","div.thumb",function(){b=a(this),c=a(this).find("img").clone(),b.siblings(".first").html(c),b.siblings(".selected").removeClass("selected"),b.addClass("selected")})},deleteTheme:function(){return confirm(b.data.settings.confirmDelete)},nextTheme:function(){var a=this;a.trigger("theme:next",a.model.cid)},previousTheme:function(){var a=this;a.trigger("theme:previous",a.model.cid)}}),b.view.Themes=wp.Backbone.View.extend({id:"themes",index:0,count:a("#theme-count"),initialize:function(a){var b=this;t
|