mirror of
https://github.com/WordPress/WordPress.git
synced 2024-08-20 21:02:57 +02:00
See #24716. Built from https://develop.svn.wordpress.org/trunk@28995 git-svn-id: http://core.svn.wordpress.org/trunk@28783 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
6.8 KiB
JavaScript
1 line
6.8 KiB
JavaScript
!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",toolbar:"toolbar",url:""},initialize:function(){f.controller._State.prototype.initialize.apply(this,arguments)},activate:function(){this.listenTo(this.frame,"toolbar:render:edit-image",this.toolbar)},_postActivate:function(){this._content(),this._router()},deactivate:function(){this.stopListening(this.frame)},toolbar:function(){var a=this.frame,b=a.lastState(),c=b&&b.id;a.toolbar.set(new f.view.Toolbar({controller:a,items:{back:{style:"primary",text:e.back,priority:20,click:function(){c?a.setState(c):a.close()}}}}))},_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(){b.defaults(this.options,{title:e.mediaLibraryTitle,modal:!1,selection:[],library:{},multiple:!1,state:"library",uploader:!0,mode:["grid","edit"]}),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()},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=this.options;this.options.states||this.states.add([new f.controller.Library({library:f.query(a.library),multiple:a.multiple,title:a.title,priority:20,toolbar:!1,router:!1,content:"browse",filterable:"mime-types"})])},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)},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(a){var b,c,d=this.state().get("library");b=d.indexOf(a)>0?!0:!1,c=d.indexOf(a)<d.length-1?!0:!1,new f.view.Frame.EditAttachment({hasPrevious:b,hasNext:c,model:a,gridController:this})},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.$el.attr("aria-label",this.model.attributes.title).attr("aria-checked",!1),this.model.on("change:sizes change:uploading",this.render,this),this.model.on("change:title",this._syncTitle,this),this.model.on("change:caption",this._syncCaption,this),this.model.on("change:percent",this.progress,this),this.model.on("add",this.select,this),this.model.on("remove",this.deselect,this)},render:function(){f.view.Attachment.Details.prototype.render.apply(this,arguments),f.mixin.removeAllPlayers(),a("audio, video",this.$el).each(function(a,b){var c=f.view.MediaDetails.prepareSrc(b);new MediaElementPlayer(c,f.mixin.mejsSettings)})}}),f.view.Frame.EditAttachment=f.view.Frame.extend({className:"edit-attachment-frame",template:f.template("edit-attachment-frame"),regions:["router","content"],events:{click:"collapse","click .delete-media-item":"deleteMediaItem","click .left":"previousMediaItem","click .right":"nextMediaItem"},initialize:function(){var a=this;f.view.Frame.prototype.initialize.apply(this,arguments),b.defaults(this.options,{modal:!0,state:"edit-attachment"}),this.createStates(),this.on("content:render:edit-metadata",this.editMetadataContent,this),this.on("content:render:edit-image",this.editImageContentUgh,this),"image"===this.model.get("type")&&(this.on("router:create",this.createRouter,this),this.on("router:render",this.browseRouter,this)),this.options.modal&&(this.modal=new f.view.Modal({controller:this,title:this.options.title}),this.modal.close=function(){a.modal.remove()},this.modal.content(this),this.modal.open())},createStates:function(){this.states.add([new f.controller.EditImageNoFrame({model:this.model})])},render:function(){return!this.state()&&this.options.state&&this.setState(this.options.state),f.view.Frame.prototype.render.apply(this,arguments)},editMetadataContent:function(){var a=new f.view.Attachment.Details.TwoColumn({controller:this,model:this.model});this.content.set(a)},editImageContentUgh:function(){b.defer(b.bind(this.editImageContent,this))},editImageContent:function(){var a=new f.view.EditImage({model:this.model,controller:this}).render();this.content.set(a),a.loadEditor()},createRouter:function(a){a.view=new f.view.Router({controller:this})},browseRouter:function(a){a.set({"edit-metadata":{text:"Edit Metadata",priority:20},"edit-image":{text:"Edit Image",priority:40}})},previousMediaItem:function(){this.options.hasPrevious&&(this.modal.close(),this.options.gridController.trigger("edit:attachment:previous",this.model))},nextMediaItem:function(){this.options.hasNext&&(this.modal.close(),this.options.gridController.trigger("edit:attachment:next",this.model))}}),f.view.GridFieldOptions=f.View.extend({className:"media-grid-field-options",template:f.template("media-grid-field-options"),events:{"change input":"toggleFields"},toggleFields:function(b){var c,d,e=a(b.currentTarget);d=e.data("setting"),c=a(".data-"+d,".data-fields"),e.is(":checked")?(c.show(),deleteUserSetting("hidegrid"+d)):(c.hide(),setUserSetting("hidegrid"+d,1)),a(":checked",this.$el).length?c.parent().show():c.parent().hide()}})}(jQuery,_,Backbone,wp); |