2014-07-13 12:16:15 -04:00
|
|
|
!function(a,b,c,d){var e,f=d.media;f.view.l10n?e=f.view.l10n:(e=f.view.l10n="undefined"==typeof _wpMediaViewsL10n?{}:_wpMediaViewsL10n,delete e.settings),f.controller.EditImageNoFrame=f.controller.State.extend({defaults:{id:"edit-attachment",title:e.editImage,menu:!1,router:"edit-metadata",content:"edit-metadata",url:""},_ready:function(){},_postActivate:function(){this._content(),this._router()},_router:function(){var a,b=this.frame.router,c=this.get("router");this.frame.$el.toggleClass("hide-router",!c),c&&(this.frame.router.render(c),a=b.get(),a&&a.select&&a.select(this.frame.content.mode()))},_content:function(){var a=this.get("content");a&&this.frame.content.render(a)}}),f.view.MediaFrame.Manage=f.view.MediaFrame.extend({initialize:function(){var c=this;b.defaults(this.options,{title:"",modal:!1,selection:[],library:{},multiple:"add",state:"library",uploader:!0,mode:["grid","edit"]}),a(document).on("click",".add-new-h2",b.bind(this.addNewClickHandler,this)),a(document).on("screen:options:open",b.bind(this.screenOptionsOpen,this)),a(document).on("screen:options:close",b.bind(this.screenOptionsClose,this)),this.$el.addClass("wp-core-ui media-grid-view"),(d.Uploader.limitExceeded||!d.Uploader.browser.supported)&&(this.options.uploader=!1),this.options.uploader&&(this.uploader=new f.view.UploaderWindow({controller:this,uploader:{dropzone:a("body"),container:a("body")}}).render(),this.uploader.ready(),a("body").append(this.uploader.el),this.options.uploader=!1),f.view.MediaFrame.prototype.initialize.apply(this,arguments),this.$el.appendTo(this.options.container),this.createSelection(),this.createStates(),this.bindHandlers(),this.render(),a("#media-search-input").on("input",b.debounce(function(b){var d=a(b.currentTarget).val(),e="";d&&(e+="?search="+d),c.gridRouter.navigate(c.gridRouter.baseUrl(e))},1e3)),b.delay(b.bind(this.createRouter,this),1e3)},screenOptionsOpen:function(){this.$el.addClass("media-grid-view-options")},screenOptionsClose:function(){this.$el.removeClass("media-grid-view-options")},createRouter:function(){this.gridRouter=new f.view.MediaFrame.Manage.Router,window.history&&window.history.pushState&&c.history.start({root:_wpMediaGridSettings.adminUrl,pushState:!0})},createSelection:function(){var a=this.options.selection;a instanceof f.model.Selection||(this.options.selection=new f.model.Selection(a,{multiple:this.options.multiple})),this._selection={attachments:new f.model.Attachments,difference:[]}},createStates:function(){var a,b=this.options;this.options.states||(a=new f.controller.Library({library:f.query(b.library),multiple:b.multiple,title:b.title,priority:20,toolbar:!1,router:!1,content:"browse",filterable:"mime-types"}),this.states.add([a]))},bindHandlers:function(){this.on("content:create:browse",this.browseContent,this),this.on("content:render:edit-image",this.editImageContent,this),this.on("edit:attachment",this.editAttachment,this)},addNewClickHandler:function(a){a.preventDefault(),this.trigger("toggle:upload:attachment")},editAttachment:function(a){d.media({frame:"edit-attachments",gridRouter:this.gridRouter,library:this.state().get("library"),model:a})},browseContent:function(a){var b=this.state();a.view=new f.view.AttachmentsBrowser({controller:this,collection:b.get("library"),selection:b.get("selection"),model:b,sortable:b.get("sortable"),search:b.get("searchable"),filters:b.get("filterable"),display:b.get("displaySettings"),dragInfo:b.get("dragInfo"),bulkEdit:!0,sidebar:!1,suggestedWidth:b.get("suggestedWidth"),suggestedHeight:b.get("suggestedHeight"),AttachmentView:b.get("AttachmentView")})},editImageContent:function(){var a=this.state().get("image"),b=new f.view.EditImage({model:a,controller:this}).render();this.content.set(b),b.loadEditor()}}),f.view.Attachment.Details.TwoColumn=f.view.Attachment.Details.extend({template:d.template("attachment-details-two-column"),initialize:function(){this.model&&(this.$el.attr("aria-label",this.model.get("title")).attr("aria-checked",!1),this.model.on("change:title",this._syncTitle,this),this.model.on("change:caption",this._syncCaption,this),this.m
|