2014-07-10 20:25:14 +02: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:e.mediaLibraryTitle,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)),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)},createRouter:function(){this.gridRouter=new f.view.Frame.Router(this),window.history&&window.history.pushState&&c.history.start({root:mediaGridSettings.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"}),a._renderTitle=function(a){var b=this.get("title")||"";a.$el.addClass("wrap"),b+='<a class="add-new-h2">Add New</a>',a.$el.html(b)},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),this.on("edit:attachment:next",this.editNextAttachment,this),this.on("edit:attachment:previous",this.editPreviousAttachment,this)},addNewClickHandler:function(){this.trigger("show:upload:attachment")},editPreviousAttachment:function(a){var b=this.state().get("library"),c=b.indexOf(a);this.trigger("edit:attachment",b.at(c-1))},editNextAttachment:function(a){var b=this.state().get("library"),c=b.indexOf(a);this.trigger("edit:attachment",b.at(c+1))},editAttachment:function(b){var c=this,d=this.state().get("library");this.editAttachmentFrame=new f.view.Frame.EditAttachments({gridRouter:this.gridRouter,library:d,model:b}),this.listenTo(this.editAttachmentFrame,"edit:attachment:next",this.editNextAttachment),this.listenTo(this.editAttachmentFrame,"edit:attachment:previous",this.editPreviousAttachment),a("body").on("keydown.media-modal",function(a){c.editAttachmentFrame.keyEvent(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")})},edit
|