WordPress/wp-includes/js/media-views.min.js

1 line
54 KiB
JavaScript
Raw Normal View History

!function(r){var e,t,i,s,o=wp.media,n=o.model.Attachment,a=o.model.Attachments,l=(o.model.Query,o.view.l10n="undefined"==typeof _wpMediaViewsL10n?{}:_wpMediaViewsL10n);o.view.settings=l.settings||{},delete l.settings,o.model.settings.post=o.view.settings.post,r.support.transition=(e=document.documentElement.style,t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"},(i=_.find(_.keys(t),function(t){return!_.isUndefined(e[t])}))&&{end:t[i]}),o.transition=function(t,e){var i=r.Deferred();return e=e||2e3,r.support.transition?((t=!(t instanceof r)?r(t):t).first().one(r.support.transition.end,i.resolve),_.delay(i.resolve,e)):i.resolve(),i.promise()},o.controller.Region=function(t){_.extend(this,_.pick(t||{},"id","view","selector"))},o.controller.Region.extend=Backbone.Model.extend,_.extend(o.controller.Region.prototype,{mode:function(t){return t?(t===this._mode||(this.trigger("deactivate"),this._mode=t,this.render(t),this.trigger("activate")),this):this._mode},render:function(t){if(t&&t!==this._mode)return this.mode(t);t={view:null};return this.trigger("create",t),t=t.view,this.trigger("render",t),t&&this.set(t),this},get:function(){return this.view.views.first(this.selector)},set:function(t,e){return e&&(e.add=!1),this.view.views.set(this.selector,t,e)},trigger:function(t){if(this._mode){var e=_.toArray(arguments),i=this.id+":"+t;return e[0]=i+":"+this._mode,this.view.trigger.apply(this.view,e),e[0]=i,this.view.trigger.apply(this.view,e),this}}}),o.controller.StateMachine=function(t){this.states=new Backbone.Collection(t)},o.controller.StateMachine.extend=Backbone.Model.extend,_.extend(o.controller.StateMachine.prototype,Backbone.Events,{state:function(t){return this.states=this.states||new Backbone.Collection,(t=t||this._state)&&!this.states.get(t)&&this.states.add({id:t}),this.states.get(t)},setState:function(t){var e=this.state();return e&&t===e.id||!this.states||!this.states.get(t)||(e&&(e.trigger("deactivate"),this._lastState=e.id),this._state=t,this.state().trigger("activate")),this},lastState:function(){if(this._lastState)return this.state(this._lastState)}}),_.each(["on","off","trigger"],function(t){o.controller.StateMachine.prototype[t]=function(){return this.states=this.states||new Backbone.Collection,this.states[t].apply(this.states,arguments),this}}),o.controller.State=Backbone.Model.extend({constructor:function(){this.on("activate",this._preActivate,this),this.on("activate",this.activate,this),this.on("activate",this._postActivate,this),this.on("deactivate",this._deactivate,this),this.on("deactivate",this.deactivate,this),this.on("reset",this.reset,this),this.on("ready",this._ready,this),this.on("ready",this.ready,this),Backbone.Model.apply(this,arguments),this.on("change:menu",this._updateMenu,this)},ready:function(){},activate:function(){},deactivate:function(){},reset:function(){},_ready:function(){this._updateMenu()},_preActivate:function(){this.active=!0},_postActivate:function(){this.on("change:menu",this._menu,this),this.on("change:titleMode",this._title,this),this.on("change:content",this._content,this),this.on("change:toolbar",this._toolbar,this),this.frame.on("title:render:default",this._renderTitle,this),this._title(),this._menu(),this._toolbar(),this._content(),this._router()},_deactivate:function(){this.active=!1,this.frame.off("title:render:default",this._renderTitle,this),this.off("change:menu",this._menu,this),this.off("change:titleMode",this._title,this),this.off("change:content",this._content,this),this.off("change:toolbar",this._toolbar,this)},_title:function(){this.frame.title.render(this.get("titleMode")||"default")},_renderTitle:function(t){t.$el.text(this.get("title")||"")},_router:function(){var t=this.frame.router,e=this.get("router");this.frame.$el.toggleClass("hide-router",!e),e&&(this.frame.router.render(e),(t=t.get())&&t.select&&t.select(this.frame.content.mode()))},_menu:function(){var t=this.frame.menu,e=this.get("menu");e&&(t.mode(e),(t=t.get())&&t.select&&t.select(this.id))},_updateMenu:func