WordPress/wp-includes/js/media/views.min.js
Scott Taylor d568679946 Split the media JS files into modules:
* Add a new folder in `wp-includes/js`, `media`
* Create manifest files for `views`, `models`, `grid`, and `audio-video`
* Make `browserify` an `npm` dependency
* Add Grunt tasks for `browserify` and `uglify:media` on `build` and `watch`
* Update the paths loaded for media files in `script-loader`
* All new files were created using `svn cp` from their original location

Please run `npm install`. While developing media JS, you must run `grunt watch`.

See #28510.

Built from https://develop.svn.wordpress.org/trunk@31373


git-svn-id: http://core.svn.wordpress.org/trunk@31354 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-09 00:43:50 +00:00

4 lines
113 KiB
JavaScript

!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b){var c,d=a("../models/selection.js"),e=a("./library.js");c=e.extend({defaults:_.defaults({multiple:"add",filterable:"uploaded",priority:100,syncSelection:!1},e.prototype.defaults),initialize:function(){var a=this.get("collectionType");"video"===this.get("type")&&(a="video-"+a),this.set("id",a+"-library"),this.set("toolbar",a+"-add"),this.set("menu",a),this.get("library")||this.set("library",wp.media.query({type:this.get("type")})),e.prototype.initialize.apply(this,arguments)},activate:function(){var a=this.get("library"),b=this.get("editLibrary"),c=this.frame.state(this.get("collectionType")+"-edit").get("library");b&&b!==c&&a.unobserve(b),a.validator=function(a){return!!this.mirroring.get(a.cid)&&!c.get(a.cid)&&d.prototype.validator.apply(this,arguments)},a.reset(a.mirroring.models,{silent:!0}),a.observe(c),this.set("editLibrary",c),e.prototype.activate.apply(this,arguments)}}),b.exports=c},{"../models/selection.js":20,"./library.js":10}],2:[function(a,b){var c,d=a("../models/selection.js"),e=a("./library.js"),f=a("../views/view.js"),g=a("../views/attachment/edit-library.js"),h=wp.media.view.l10n,i=jQuery;c=e.extend({defaults:{multiple:!1,sortable:!0,searchable:!1,content:"browse",describe:!0,dragInfo:!0,idealColumnWidth:170,editing:!1,priority:60,SettingsView:!1,syncSelection:!1},initialize:function(){var a=this.get("collectionType");"video"===this.get("type")&&(a="video-"+a),this.set("id",a+"-edit"),this.set("toolbar",a+"-edit"),this.get("library")||this.set("library",new d),this.get("AttachmentView")||this.set("AttachmentView",g),e.prototype.initialize.apply(this,arguments)},activate:function(){var a=this.get("library");a.props.set("type",this.get("type")),this.get("library").observe(wp.Uploader.queue),this.frame.on("content:render:browse",this.renderSettings,this),e.prototype.activate.apply(this,arguments)},deactivate:function(){this.get("library").unobserve(wp.Uploader.queue),this.frame.off("content:render:browse",this.renderSettings,this),e.prototype.deactivate.apply(this,arguments)},renderSettings:function(a){var b=this.get("library"),c=this.get("collectionType"),d=this.get("dragInfoText"),e=this.get("SettingsView"),g={};b&&a&&(b[c]=b[c]||new Backbone.Model,g[c]=new e({controller:this,model:b[c],priority:40}),a.sidebar.set(g),d&&a.toolbar.set("dragInfo",new f({el:i('<div class="instructions">'+d+"</div>")[0],priority:-40})),a.toolbar.set("reverse",{text:h.reverseOrder,priority:80,click:function(){b.reset(b.toArray().reverse())}}))}}),b.exports=c},{"../models/selection.js":20,"../views/attachment/edit-library.js":30,"../views/view.js":76,"./library.js":10}],3:[function(a,b){var c,d=a("./state.js"),e=a("../views/toolbar.js"),f=a("../views/cropper.js"),g=wp.media.view.l10n;c=d.extend({defaults:{id:"cropper",title:g.cropImage,toolbar:"crop",content:"crop",router:!1,canSkipCrop:!1},activate:function(){this.frame.on("content:create:crop",this.createCropContent,this),this.frame.on("close",this.removeCropper,this),this.set("selection",new Backbone.Collection(this.frame._selection.single))},deactivate:function(){this.frame.toolbar.mode("browse")},createCropContent:function(){this.cropperView=new f({controller:this,attachment:this.get("selection").first()}),this.cropperView.on("image-loaded",this.createCropToolbar,this),this.frame.content.set(this.cropperView)},removeCropper:function(){this.imgSelect.cancelSelection(),this.imgSelect.setOptions({remove:!0}),this.imgSelect.update(),this.cropperView.remove()},createCropToolbar:function(){var a,b;a=this.get("canSkipCrop")||!1,b={controller:this.frame,items:{insert:{style:"primary",text:g.cropImage,priority:80,requires:{library:!1,selection:!1},click:function(){var a=this,b=this.controller.state().get("selection").first();b.set({cropDetails:this.controller.state().imgSelect.getSelection()}),this.$el.text(g.cropping),this.$el.attr("disabled",!0),this.controller.state().doCrop(b).done(function(b){a.controller.trigger("cropped",b),a.controller.close()}).fail(function(){a.controller.trigger("content:error:crop")})}}}},a&&_.extend(b.items,{skip:{style:"secondary",text:g.skipCropping,priority:70,requires:{library:!1,selection:!1},click:function(){var a=this.controller.state().get("selection").first();this.controller.state().cropperView.remove(),this.controller.trigger("skippedcrop",a),this.controller.close()}}}),this.frame.toolbar.set(new e(b))},doCrop:function(a){return wp.ajax.post("custom-header-crop",{nonce:a.get("nonces").edit,id:a.get("id"),cropDetails:a.get("cropDetails")})}}),b.exports=c},{"../views/cropper.js":39,"../views/toolbar.js":68,"./state.js":15}],4:[function(a,b){var c,d=a("./state.js"),e=a("../views/toolbar.js"),f=wp.media.view.l10n;c=d.extend({defaults:{id:"edit-image",title:f.editImage,menu:!1,toolbar:"edit-image",content:"edit-image",url:""},activate:function(){this.listenTo(this.frame,"toolbar:render:edit-image",this.toolbar)},deactivate:function(){this.stopListening(this.frame)},toolbar:function(){var a=this.frame,b=a.lastState(),c=b&&b.id;a.toolbar.set(new e({controller:a,items:{back:{style:"primary",text:f.back,priority:20,click:function(){c?a.setState(c):a.close()}}}}))}}),b.exports=c},{"../views/toolbar.js":68,"./state.js":15}],5:[function(a,b){var c,d=a("./state.js"),e=wp.media.view.l10n,f=jQuery;c=d.extend({defaults:{id:"embed",title:e.insertFromUrlTitle,content:"embed",menu:"default",toolbar:"main-embed",priority:120,type:"link",url:"",metadata:{}},sensitivity:200,initialize:function(a){this.metadata=a.metadata,this.debouncedScan=_.debounce(_.bind(this.scan,this),this.sensitivity),this.props=new Backbone.Model(this.metadata||{url:""}),this.props.on("change:url",this.debouncedScan,this),this.props.on("change:url",this.refresh,this),this.on("scan",this.scanImage,this)},scan:function(){var a,b=this,c={type:"link",scanners:[]};this.props.get("url")&&this.trigger("scan",c),c.scanners.length?(a=c.scanners=f.when.apply(f,c.scanners),a.always(function(){b.get("scanners")===a&&b.set("loading",!1)})):c.scanners=null,c.loading=!!c.scanners,this.set(c)},scanImage:function(a){var b=this.frame,c=this,d=this.props.get("url"),e=new Image,g=f.Deferred();a.scanners.push(g.promise()),e.onload=function(){g.resolve(),c===b.state()&&d===c.props.get("url")&&(c.set({type:"image"}),c.props.set({width:e.width,height:e.height}))},e.onerror=g.reject,e.src=d},refresh:function(){this.frame.toolbar.get().refresh()},reset:function(){this.props.clear().set({url:""}),this.active&&this.refresh()}}),b.exports=c},{"./state.js":15}],6:[function(a,b){var c,d=a("../models/attachment.js"),e=a("./library.js"),f=wp.media.view.l10n;c=e.extend({defaults:_.defaults({id:"featured-image",title:f.setFeaturedImageTitle,multiple:!1,filterable:"uploaded",toolbar:"featured-image",priority:60,syncSelection:!0},e.prototype.defaults),initialize:function(){var a,b;this.get("library")||this.set("library",wp.media.query({type:"image"})),e.prototype.initialize.apply(this,arguments),a=this.get("library"),b=a.comparator,a.comparator=function(a,c){var d=!!this.mirroring.get(a.cid),e=!!this.mirroring.get(c.cid);return!d&&e?-1:d&&!e?1:b.apply(this,arguments)},a.observe(this.get("selection"))},activate:function(){this.updateSelection(),this.frame.on("open",this.updateSelection,this),e.prototype.activate.apply(this,arguments)},deactivate:function(){this.frame.off("open",this.updateSelection,this),e.prototype.deactivate.apply(this,arguments)},updateSelection:function(){var a,b=this.get("selection"),c=wp.media.view.settings.post.featuredImageId;""!==c&&-1!==c&&(a=d.get(c),a.fetch()),b.reset(a?[a]:[])}}),b.exports=c},{"../models/attachment.js":16,"./library.js":10}],7:[function(a,b){var c,d=a("../models/selection.js"),e=a("./library.js"),f=wp.media.view.l10n;c=e.extend({defaults:_.defaults({id:"gallery-library",title:f.addToGalleryTitle,multiple:"add",filterable:"uploaded",menu:"gallery",toolbar:"gallery-add",priority:100,syncSelection:!1},e.prototype.defaults),initialize:function(){this.get("library")||this.set("library",wp.media.query({type:"image"})),e.prototype.initialize.apply(this,arguments)},activate:function(){var a=this.get("library"),b=this.frame.state("gallery-edit").get("library");this.editLibrary&&this.editLibrary!==b&&a.unobserve(this.editLibrary),a.validator=function(a){return!!this.mirroring.get(a.cid)&&!b.get(a.cid)&&d.prototype.validator.apply(this,arguments)},a.reset(a.mirroring.models,{silent:!0}),a.observe(b),this.editLibrary=b,e.prototype.activate.apply(this,arguments)}}),b.exports=c},{"../models/selection.js":20,"./library.js":10}],8:[function(a,b){var c,d=a("../models/selection.js"),e=a("./library.js"),f=a("../views/attachment/edit-library.js"),g=a("../views/settings/gallery.js"),h=wp.media.view.l10n;c=e.extend({defaults:{id:"gallery-edit",title:h.editGalleryTitle,multiple:!1,searchable:!1,sortable:!0,display:!1,content:"browse",toolbar:"gallery-edit",describe:!0,displaySettings:!0,dragInfo:!0,idealColumnWidth:170,editing:!1,priority:60,syncSelection:!1},initialize:function(){this.get("library")||this.set("library",new d),this.get("AttachmentView")||this.set("AttachmentView",f),e.prototype.initialize.apply(this,arguments)},activate:function(){var a=this.get("library");a.props.set("type","image"),this.get("library").observe(wp.Uploader.queue),this.frame.on("content:render:browse",this.gallerySettings,this),e.prototype.activate.apply(this,arguments)},deactivate:function(){this.get("library").unobserve(wp.Uploader.queue),this.frame.off("content:render:browse",this.gallerySettings,this),e.prototype.deactivate.apply(this,arguments)},gallerySettings:function(a){if(this.get("displaySettings")){var b=this.get("library");b&&a&&(b.gallery=b.gallery||new Backbone.Model,a.sidebar.set({gallery:new g({controller:this,model:b.gallery,priority:40})}),a.toolbar.set("reverse",{text:h.reverseOrder,priority:80,click:function(){b.reset(b.toArray().reverse())}}))}}}),b.exports=c},{"../models/selection.js":20,"../views/attachment/edit-library.js":30,"../views/settings/gallery.js":64,"./library.js":10}],9:[function(a,b){var c,d=a("./state.js"),e=a("./library.js"),f=wp.media.view.l10n;c=d.extend({defaults:_.defaults({id:"image-details",title:f.imageDetailsTitle,content:"image-details",menu:!1,router:!1,toolbar:"image-details",editing:!1,priority:60},e.prototype.defaults),initialize:function(a){this.image=a.image,d.prototype.initialize.apply(this,arguments)},activate:function(){this.frame.modal.$el.addClass("image-details")}}),b.exports=c},{"./library.js":10,"./state.js":15}],10:[function(a,b){var c,d=a("../utils/selection-sync.js"),e=a("../models/selection.js"),f=a("./state.js"),g=wp.media.view.l10n;c=f.extend({defaults:{id:"library",title:g.mediaLibraryTitle,multiple:!1,content:"upload",menu:"default",router:"browse",toolbar:"select",searchable:!0,filterable:!1,sortable:!0,autoSelect:!0,describe:!1,contentUserSetting:!0,syncSelection:!0},initialize:function(){var a,b=this.get("selection");this.get("library")||this.set("library",wp.media.query()),b instanceof e||(a=b,a||(a=this.get("library").props.toJSON(),a=_.omit(a,"orderby","query")),this.set("selection",new e(null,{multiple:this.get("multiple"),props:a}))),this.resetDisplays()},activate:function(){this.syncSelection(),wp.Uploader.queue.on("add",this.uploading,this),this.get("selection").on("add remove reset",this.refreshContent,this),this.get("router")&&this.get("contentUserSetting")&&(this.frame.on("content:activate",this.saveContentMode,this),this.set("content",getUserSetting("libraryContent",this.get("content"))))},deactivate:function(){this.recordSelection(),this.frame.off("content:activate",this.saveContentMode,this),this.get("selection").off(null,null,this),wp.Uploader.queue.off(null,null,this)},reset:function(){this.get("selection").reset(),this.resetDisplays(),this.refreshContent()},resetDisplays:function(){var a=wp.media.view.settings.defaultProps;this._displays=[],this._defaultDisplaySettings={align:a.align||getUserSetting("align","none"),size:a.size||getUserSetting("imgsize","medium"),link:a.link||getUserSetting("urlbutton","file")}},display:function(a){var b=this._displays;return b[a.cid]||(b[a.cid]=new Backbone.Model(this.defaultDisplaySettings(a))),b[a.cid]},defaultDisplaySettings:function(a){var b=this._defaultDisplaySettings;return(b.canEmbed=this.canEmbed(a))&&(b.link="embed"),b},canEmbed:function(a){if(!a.get("uploading")){var b=a.get("type");if("audio"!==b&&"video"!==b)return!1}return _.contains(wp.media.view.settings.embedExts,a.get("filename").split(".").pop())},refreshContent:function(){var a=this.get("selection"),b=this.frame,c=b.router.get(),d=b.content.mode();this.active&&!a.length&&c&&!c.get(d)&&this.frame.content.render(this.get("content"))},uploading:function(a){var b=this.frame.content;"upload"===b.mode()&&this.frame.content.mode("browse"),this.get("autoSelect")&&(this.get("selection").add(a),this.frame.trigger("library:selection:add"))},saveContentMode:function(){if("browse"===this.get("router")){var a=this.frame.content.mode(),b=this.frame.router.get();b&&b.get(a)&&setUserSetting("libraryContent",a)}}}),_.extend(c.prototype,d),b.exports=c},{"../models/selection.js":20,"../utils/selection-sync.js":21,"./state.js":15}],11:[function(a,b){var c,d=a("./library.js");c=d.extend({defaults:_.defaults({filterable:"uploaded",displaySettings:!1,priority:80,syncSelection:!1},d.prototype.defaults),initialize:function(a){this.media=a.media,this.type=a.type,this.set("library",wp.media.query({type:this.type})),d.prototype.initialize.apply(this,arguments)},activate:function(){wp.media.frame.lastMime&&(this.set("library",wp.media.query({type:wp.media.frame.lastMime})),delete wp.media.frame.lastMime),d.prototype.activate.apply(this,arguments)}}),b.exports=c},{"./library.js":10}],12:[function(a,b){var c=function(a){_.extend(this,_.pick(a||{},"id","view","selector"))};c.extend=Backbone.Model.extend,_.extend(c.prototype,{mode:function(a){return a?a===this._mode?this:(this.trigger("deactivate"),this._mode=a,this.render(a),this.trigger("activate"),this):this._mode},render:function(a){if(a&&a!==this._mode)return this.mode(a);var b,c={view:null};return this.trigger("create",c),b=c.view,this.trigger("render",b),b&&this.set(b),this},get:function(){return this.view.views.first(this.selector)},set:function(a,b){return b&&(b.add=!1),this.view.views.set(this.selector,a,b)},trigger:function(a){var b,c;if(this._mode)return c=_.toArray(arguments),b=this.id+":"+a,c[0]=b+":"+this._mode,this.view.trigger.apply(this.view,c),c[0]=b,this.view.trigger.apply(this.view,c),this}}),b.exports=c},{}],13:[function(a,b){var c,d=a("./library.js"),e=wp.media.view.l10n;c=d.extend({defaults:_.defaults({id:"replace-image",title:e.replaceImageTitle,multiple:!1,filterable:"uploaded",toolbar:"replace",menu:!1,priority:60,syncSelection:!0},d.prototype.defaults),initialize:function(a){var b,c;this.image=a.image,this.get("library")||this.set("library",wp.media.query({type:"image"})),d.prototype.initialize.apply(this,arguments),b=this.get("library"),c=b.comparator,b.comparator=function(a,b){var d=!!this.mirroring.get(a.cid),e=!!this.mirroring.get(b.cid);return!d&&e?-1:d&&!e?1:c.apply(this,arguments)},b.observe(this.get("selection"))},activate:function(){this.updateSelection(),d.prototype.activate.apply(this,arguments)},updateSelection:function(){var a=this.get("selection"),b=this.image.attachment;a.reset(b?[b]:[])}}),b.exports=c},{"./library.js":10}],14:[function(a,b){var c=function(a){this.states=new Backbone.Collection(a)};c.extend=Backbone.Model.extend,_.extend(c.prototype,Backbone.Events,{state:function(a){return this.states=this.states||new Backbone.Collection,a=a||this._state,a&&!this.states.get(a)&&this.states.add({id:a}),this.states.get(a)},setState:function(a){var b=this.state();return b&&a===b.id||!this.states||!this.states.get(a)?this:(b&&(b.trigger("deactivate"),this._lastState=b.id),this._state=a,this.state().trigger("activate"),this)},lastState:function(){return this._lastState?this.state(this._lastState):void 0}}),_.each(["on","off","trigger"],function(a){c.prototype[a]=function(){return this.states=this.states||new Backbone.Collection,this.states[a].apply(this.states,arguments),this}}),b.exports=c},{}],15:[function(a,b){var c=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(a){a.$el.text(this.get("title")||"")},_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()))},_menu:function(){var a,b=this.frame.menu,c=this.get("menu");this.frame.$el.toggleClass("hide-menu",!c),c&&(b.mode(c),a=b.get(),a&&a.select&&a.select(this.id))},_updateMenu:function(){var a=this.previous("menu"),b=this.get("menu");a&&this.frame.off("menu:render:"+a,this._renderMenu,this),b&&this.frame.on("menu:render:"+b,this._renderMenu,this)},_renderMenu:function(a){var b=this.get("menuItem"),c=this.get("title"),d=this.get("priority");!b&&c&&(b={text:c},d&&(b.priority=d)),b&&a.set(this.id,b)}});_.each(["toolbar","content"],function(a){c.prototype["_"+a]=function(){var b=this.get(a);b&&this.frame[a].render(b)}}),b.exports=c},{}],16:[function(a,b){var c,d=jQuery;c=Backbone.Model.extend({sync:function(a,b,c){return _.isUndefined(this.id)?d.Deferred().rejectWith(this).promise():"read"===a?(c=c||{},c.context=this,c.data=_.extend(c.data||{},{action:"get-attachment",id:this.id}),wp.media.ajax(c)):"update"===a?this.get("nonces")&&this.get("nonces").update?(c=c||{},c.context=this,c.data=_.extend(c.data||{},{action:"save-attachment",id:this.id,nonce:this.get("nonces").update,post_id:wp.media.model.settings.post.id}),b.hasChanged()&&(c.data.changes={},_.each(b.changed,function(a,b){c.data.changes[b]=this.get(b)},this)),wp.media.ajax(c)):d.Deferred().rejectWith(this).promise():"delete"===a?(c=c||{},c.wait||(this.destroyed=!0),c.context=this,c.data=_.extend(c.data||{},{action:"delete-post",id:this.id,_wpnonce:this.get("nonces")["delete"]}),wp.media.ajax(c).done(function(){this.destroyed=!0}).fail(function(){this.destroyed=!1})):Backbone.Model.prototype.sync.apply(this,arguments)},parse:function(a){return a?(a.date=new Date(a.date),a.modified=new Date(a.modified),a):a},saveCompat:function(a,b){var c=this;return this.get("nonces")&&this.get("nonces").update?media.post("save-attachment-compat",_.defaults({id:this.id,nonce:this.get("nonces").update,post_id:wp.media.model.settings.post.id},a)).done(function(a,d,e){c.set(c.parse(a,e),b)}):d.Deferred().rejectWith(this).promise()}},{create:function(b){var c=a("./attachments.js");return c.all.push(b)},get:_.memoize(function(b,c){var d=a("./attachments.js");return d.all.push(c||{id:b})})}),b.exports=c},{"./attachments.js":17}],17:[function(a,b){var c,d=a("./attachment.js");c=Backbone.Collection.extend({model:d,initialize:function(a,b){b=b||{},this.props=new Backbone.Model,this.filters=b.filters||{},this.props.on("change",this._changeFilteredProps,this),this.props.on("change:order",this._changeOrder,this),this.props.on("change:orderby",this._changeOrderby,this),this.props.on("change:query",this._changeQuery,this),this.props.set(_.defaults(b.props||{})),b.observe&&this.observe(b.observe)},_changeOrder:function(){this.comparator&&this.sort()},_changeOrderby:function(a,b){this.comparator&&this.comparator!==c.comparator||(b&&"post__in"!==b?this.comparator=c.comparator:delete this.comparator)},_changeQuery:function(a,b){b?(this.props.on("change",this._requery,this),this._requery()):this.props.off("change",this._requery,this)},_changeFilteredProps:function(a){if(!this.props.get("query")){var b=_.chain(a.changed).map(function(b,d){var e=c.filters[d],f=a.get(d);if(e){if(f&&!this.filters[d])this.filters[d]=e;else{if(f||this.filters[d]!==e)return;delete this.filters[d]}return!0}},this).any().value();b&&(this._source||(this._source=new c(this.models)),this.reset(this._source.filter(this.validator,this)))}},validateDestroyed:!1,validator:function(a){return!this.validateDestroyed&&a.destroyed?!1:_.all(this.filters,function(b){return!!b.call(this,a)},this)},validate:function(a,b){var c=this.validator(a),d=!!this.get(a.cid);return!c&&d?this.remove(a,b):c&&!d&&this.add(a,b),this},validateAll:function(a,b){return b=b||{},_.each(a.models,function(a){this.validate(a,{silent:!0})},this),b.silent||this.trigger("reset",this,b),this},observe:function(a){return this.observers=this.observers||[],this.observers.push(a),a.on("add change remove",this._validateHandler,this),a.on("reset",this._validateAllHandler,this),this.validateAll(a),this},unobserve:function(a){return a?(a.off(null,null,this),this.observers=_.without(this.observers,a)):(_.each(this.observers,function(a){a.off(null,null,this)},this),delete this.observers),this},_validateHandler:function(a,b,c){return c=b===this.mirroring?c:{silent:c&&c.silent},this.validate(a,c)},_validateAllHandler:function(a,b){return this.validateAll(a,b)},mirror:function(a){return this.mirroring&&this.mirroring===a?this:(this.unmirror(),this.mirroring=a,this.reset([],{silent:!0}),this.observe(a),this)},unmirror:function(){this.mirroring&&(this.unobserve(this.mirroring),delete this.mirroring)},more:function(a){var b=jQuery.Deferred(),c=this.mirroring,d=this;return c&&c.more?(c.more(a).done(function(){this===d.mirroring&&b.resolveWith(this)}),b.promise()):b.resolveWith(this).promise()},hasMore:function(){return this.mirroring?this.mirroring.hasMore():!1},parse:function(a,b){return _.isArray(a)||(a=[a]),_.map(a,function(a){var c,e,f;return a instanceof Backbone.Model?(c=a.get("id"),a=a.attributes):c=a.id,e=d.get(c),f=e.parse(a,b),_.isEqual(e.attributes,f)||e.set(f),e})},_requery:function(b){var c,d;this.props.get("query")&&(d=a("./query.js"),c=this.props.toJSON(),c.cache=!0!==b,this.mirror(d.get(c)))},saveMenuOrder:function(){if("menuOrder"===this.props.get("orderby")){var a=this.chain().filter(function(a){return!_.isUndefined(a.id)}).map(function(a,b){return b+=1,a.set("menuOrder",b),[a.id,b]}).object().value();if(!_.isEmpty(a))return wp.media.post("save-attachment-order",{nonce:wp.media.model.settings.post.nonce,post_id:wp.media.model.settings.post.id,attachments:a})}}},{comparator:function(a,b,c){var d=this.props.get("orderby"),e=this.props.get("order")||"DESC",f=a.cid,g=b.cid;return a=a.get(d),b=b.get(d),("date"===d||"modified"===d)&&(a=a||new Date,b=b||new Date),c&&c.ties&&(f=g=null),"DESC"===e?wp.media.compare(a,b,f,g):wp.media.compare(b,a,g,f)},filters:{search:function(a){return this.props.get("search")?_.any(["title","filename","description","caption","name"],function(b){var c=a.get(b);return c&&-1!==c.search(this.props.get("search"))},this):!0},type:function(a){var b=this.props.get("type");return!b||-1!==b.indexOf(a.get("type"))},uploadedTo:function(a){var b=this.props.get("uploadedTo");return _.isUndefined(b)?!0:b===a.get("uploadedTo")},status:function(a){var b=this.props.get("status");return _.isUndefined(b)?!0:b===a.get("status")}}}),b.exports=c},{"./attachment.js":16,"./query.js":19}],18:[function(a,b){var c,d=a("./attachment");c=Backbone.Model.extend({initialize:function(a){this.attachment=!1,a.attachment_id&&(this.attachment=d.get(a.attachment_id),this.attachment.get("url")?(this.dfd=jQuery.Deferred(),this.dfd.resolve()):this.dfd=this.attachment.fetch(),this.bindAttachmentListeners()),this.on("change:link",this.updateLinkUrl,this),this.on("change:size",this.updateSize,this),this.setLinkTypeFromUrl(),this.setAspectRatio(),this.set("originalUrl",a.url)},bindAttachmentListeners:function(){this.listenTo(this.attachment,"sync",this.setLinkTypeFromUrl),this.listenTo(this.attachment,"sync",this.setAspectRatio),this.listenTo(this.attachment,"change",this.updateSize)},changeAttachment:function(a,b){this.stopListening(this.attachment),this.attachment=a,this.bindAttachmentListeners(),this.set("attachment_id",this.attachment.get("id")),this.set("caption",this.attachment.get("caption")),this.set("alt",this.attachment.get("alt")),this.set("size",b.get("size")),this.set("align",b.get("align")),this.set("link",b.get("link")),this.updateLinkUrl(),this.updateSize()},setLinkTypeFromUrl:function(){var a,b=this.get("linkUrl");return b?(a="custom",this.attachment?this.attachment.get("url")===b?a="file":this.attachment.get("link")===b&&(a="post"):this.get("url")===b&&(a="file"),void this.set("link",a)):void this.set("link","none")},updateLinkUrl:function(){var a,b=this.get("link");switch(b){case"file":a=this.attachment?this.attachment.get("url"):this.get("url"),this.set("linkUrl",a);break;case"post":this.set("linkUrl",this.attachment.get("link"));break;case"none":this.set("linkUrl","")}},updateSize:function(){var a;if(this.attachment){if("custom"===this.get("size"))return this.set("width",this.get("customWidth")),this.set("height",this.get("customHeight")),void this.set("url",this.get("originalUrl"));a=this.attachment.get("sizes")[this.get("size")],a&&(this.set("url",a.url),this.set("width",a.width),this.set("height",a.height))}},setAspectRatio:function(){var a;return this.attachment&&this.attachment.get("sizes")&&(a=this.attachment.get("sizes").full)?void this.set("aspectRatio",a.width/a.height):void this.set("aspectRatio",this.get("customWidth")/this.get("customHeight"))}}),b.exports=c},{"./attachment":16}],19:[function(a,b){var c,d=a("./attachments.js");c=d.extend({initialize:function(a,b){var c;b=b||{},d.prototype.initialize.apply(this,arguments),this.args=b.args,this._hasMore=!0,this.created=new Date,this.filters.order=function(a){var b=this.props.get("orderby"),c=this.props.get("order");return this.comparator?this.length?1!==this.comparator(a,this.last(),{ties:!0}):"DESC"!==c||"date"!==b&&"modified"!==b?"ASC"===c&&"menuOrder"===b?0===a.get(b):!1:a.get(b)>=this.created:!0},c=["s","order","orderby","posts_per_page","post_mime_type","post_parent"],wp.Uploader&&_(this.args).chain().keys().difference(c).isEmpty().value()&&this.observe(wp.Uploader.queue)},hasMore:function(){return this._hasMore},more:function(a){var b=this;return this._more&&"pending"===this._more.state()?this._more:this.hasMore()?(a=a||{},a.remove=!1,this._more=this.fetch(a).done(function(a){(_.isEmpty(a)||-1===this.args.posts_per_page||a.length<this.args.posts_per_page)&&(b._hasMore=!1)})):jQuery.Deferred().resolveWith(this).promise()},sync:function(a,b,c){var e,f;return"read"===a?(c=c||{},c.context=this,c.data=_.extend(c.data||{},{action:"query-attachments",post_id:wp.media.model.settings.post.id}),e=_.clone(this.args),-1!==e.posts_per_page&&(e.paged=Math.floor(this.length/e.posts_per_page)+1),c.data.query=e,wp.media.ajax(c)):(f=d.prototype.sync?d.prototype:Backbone,f.sync.apply(this,arguments))}},{defaultProps:{orderby:"date",order:"DESC"},defaultArgs:{posts_per_page:40},orderby:{allowed:["name","author","date","title","modified","uploadedTo","id","post__in","menuOrder"],valuemap:{id:"ID",uploadedTo:"parent",menuOrder:"menu_order ID"}},propmap:{search:"s",type:"post_mime_type",perPage:"posts_per_page",menuOrder:"menu_order",uploadedTo:"post_parent",status:"post_status",include:"post__in",exclude:"post__not_in"},get:function(){var a=[];return function(b,d){var e,f={},g=c.orderby,h=c.defaultProps,i=!!b.cache||_.isUndefined(b.cache);return delete b.query,delete b.cache,_.defaults(b,h),b.order=b.order.toUpperCase(),"DESC"!==b.order&&"ASC"!==b.order&&(b.order=h.order.toUpperCase()),_.contains(g.allowed,b.orderby)||(b.orderby=h.orderby),_.each(["include","exclude"],function(a){b[a]&&!_.isArray(b[a])&&(b[a]=[b[a]])}),_.each(b,function(a,b){_.isNull(a)||(f[c.propmap[b]||b]=a)}),_.defaults(f,c.defaultArgs),f.orderby=g.valuemap[b.orderby]||b.orderby,i?e=_.find(a,function(a){return _.isEqual(a.args,f)}):a=[],e||(e=new c([],_.extend(d||{},{props:b,args:f})),a.push(e)),e}}()}),b.exports=c},{"./attachments.js":17}],20:[function(a,b){var c,d=a("./attachments.js");c=d.extend({initialize:function(a,b){d.prototype.initialize.apply(this,arguments),this.multiple=b&&b.multiple,this.on("add remove reset",_.bind(this.single,this,!1))},add:function(a,b){return this.multiple||this.remove(this.models),d.prototype.add.call(this,a,b)},single:function(a){var b=this._single;return a&&(this._single=a),this._single&&!this.get(this._single.cid)&&delete this._single,this._single=this._single||this.last(),this._single!==b&&(b&&(b.trigger("selection:unsingle",b,this),this.get(b.cid)||this.trigger("selection:unsingle",b,this)),this._single&&this._single.trigger("selection:single",this._single,this)),this._single}}),b.exports=c},{"./attachments.js":17}],21:[function(a,b){var c={syncSelection:function(){var a=this.get("selection"),b=this.frame._selection;this.get("syncSelection")&&b&&a&&(a.multiple&&(a.reset([],{silent:!0}),a.validateAll(b.attachments),b.difference=_.difference(b.attachments.models,a.models)),a.single(b.single))},recordSelection:function(){var a=this.get("selection"),b=this.frame._selection;this.get("syncSelection")&&b&&a&&(a.multiple?(b.attachments.reset(a.toArray().concat(b.difference)),b.difference=[]):b.attachments.add(a.toArray()),b.single=a._single)}};b.exports=c},{}],22:[function(a){!function(b,c){var d,e=wp.media;e.isTouchDevice="ontouchend"in document,d=e.view.l10n="undefined"==typeof _wpMediaViewsL10n?{}:_wpMediaViewsL10n,e.view.settings=d.settings||{},delete d.settings,e.model.settings.post=e.view.settings.post,b.support.transition=function(){var a,b=document.documentElement.style,d={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};return a=c.find(c.keys(d),function(a){return!c.isUndefined(b[a])}),a&&{end:d[a]}}(),e.events=c.extend({},Backbone.Events),e.transition=function(a,d){var e=b.Deferred();return d=d||2e3,b.support.transition?(a instanceof b||(a=b(a)),a.first().one(b.support.transition.end,e.resolve),c.delay(e.resolve,d)):e.resolve(),e.promise()},e.controller.Region=a("./controllers/region.js"),e.controller.StateMachine=a("./controllers/state-machine.js"),e.controller.State=a("./controllers/state.js"),e.selectionSync=a("./utils/selection-sync.js"),e.controller.Library=a("./controllers/library.js"),e.controller.ImageDetails=a("./controllers/image-details.js"),e.controller.GalleryEdit=a("./controllers/gallery-edit.js"),e.controller.GalleryAdd=a("./controllers/gallery-add.js"),e.controller.CollectionEdit=a("./controllers/collection-edit.js"),e.controller.CollectionAdd=a("./controllers/collection-add.js"),e.controller.FeaturedImage=a("./controllers/featured-image.js"),e.controller.ReplaceImage=a("./controllers/replace-image.js"),e.controller.EditImage=a("./controllers/edit-image.js"),e.controller.MediaLibrary=a("./controllers/media-library.js"),e.controller.Embed=a("./controllers/embed.js"),e.controller.Cropper=a("./controllers/cropper.js"),e.View=a("./views/view.js"),e.view.Frame=a("./views/view.js"),e.view.MediaFrame=a("./views/media-frame.js"),e.view.MediaFrame.Select=a("./views/frame/select.js"),e.view.MediaFrame.Post=a("./views/frame/post.js"),e.view.MediaFrame.ImageDetails=a("./views/frame/image-details.js"),e.view.Modal=a("./views/modal.js"),e.view.FocusManager=a("./views/focus-manager.js"),e.view.UploaderWindow=a("./views/uploader/window.js"),e.view.EditorUploader=a("./views/uploader/editor.js"),e.view.UploaderInline=a("./views/uploader/inline.js"),e.view.UploaderStatus=a("./views/uploader/status.js"),e.view.UploaderStatusError=a("./views/uploader/status-error.js"),e.view.Toolbar=a("./views/toolbar.js"),e.view.Toolbar.Select=a("./views/toolbar/select.js"),e.view.Toolbar.Embed=a("./views/toolbar/embed.js"),e.view.Button=a("./views/button.js"),e.view.ButtonGroup=a("./views/button-group.js"),e.view.PriorityList=a("./views/priority-list.js"),e.view.MenuItem=a("./views/menu-item.js"),e.view.Menu=a("./views/menu.js"),e.view.RouterItem=a("./views/router-item.js"),e.view.Router=a("./views/router.js"),e.view.Sidebar=a("./views/sidebar.js"),e.view.Attachment=a("./views/attachment.js"),e.view.Attachment.Library=a("./views/attachment/library.js"),e.view.Attachment.EditLibrary=a("./views/attachment/edit-library.js"),e.view.Attachments=a("./views/attachments.js"),e.view.Search=a("./views/search.js"),e.view.AttachmentFilters=a("./views/attachment-filters.js"),e.view.DateFilter=a("./views/attachment-filters/date.js"),e.view.AttachmentFilters.Uploaded=a("./views/attachment-filters/uploaded.js"),e.view.AttachmentFilters.All=a("./views/attachment-filters/all.js"),e.view.AttachmentsBrowser=a("./views/attachments/browser.js"),e.view.Selection=a("./views/selection.js"),e.view.Attachment.Selection=a("./views/attachment/selection.js"),e.view.Attachments.Selection=a("./views/attachments/selection.js"),e.view.Attachment.EditSelection=a("./views/attachment/edit-selection.js"),e.view.Settings=a("./views/settings.js"),e.view.Settings.AttachmentDisplay=a("./views/settings/attachment-display.js"),e.view.Settings.Gallery=a("./views/settings/gallery.js"),e.view.Settings.Playlist=a("./views/settings/playlist.js"),e.view.Attachment.Details=a("./views/attachment/details.js"),e.view.AttachmentCompat=a("./views/attachment-compat.js"),e.view.Iframe=a("./views/iframe.js"),e.view.Embed=a("./views/embed.js"),e.view.Label=a("./views/label.js"),e.view.EmbedUrl=a("./views/embed/url.js"),e.view.EmbedLink=a("./views/embed/link.js"),e.view.EmbedImage=a("./views/embed/image.js"),e.view.ImageDetails=a("./views/image-details.js"),e.view.Cropper=a("./views/cropper.js"),e.view.EditImage=a("./views/edit-image.js"),e.view.Spinner=a("./views/spinner.js")
}(jQuery,_)},{"./controllers/collection-add.js":1,"./controllers/collection-edit.js":2,"./controllers/cropper.js":3,"./controllers/edit-image.js":4,"./controllers/embed.js":5,"./controllers/featured-image.js":6,"./controllers/gallery-add.js":7,"./controllers/gallery-edit.js":8,"./controllers/image-details.js":9,"./controllers/library.js":10,"./controllers/media-library.js":11,"./controllers/region.js":12,"./controllers/replace-image.js":13,"./controllers/state-machine.js":14,"./controllers/state.js":15,"./utils/selection-sync.js":21,"./views/attachment-compat.js":23,"./views/attachment-filters.js":24,"./views/attachment-filters/all.js":25,"./views/attachment-filters/date.js":26,"./views/attachment-filters/uploaded.js":27,"./views/attachment.js":28,"./views/attachment/details.js":29,"./views/attachment/edit-library.js":30,"./views/attachment/edit-selection.js":31,"./views/attachment/library.js":32,"./views/attachment/selection.js":33,"./views/attachments.js":34,"./views/attachments/browser.js":35,"./views/attachments/selection.js":36,"./views/button-group.js":37,"./views/button.js":38,"./views/cropper.js":39,"./views/edit-image.js":40,"./views/embed.js":41,"./views/embed/image.js":42,"./views/embed/link.js":43,"./views/embed/url.js":44,"./views/focus-manager.js":45,"./views/frame/image-details.js":47,"./views/frame/post.js":48,"./views/frame/select.js":49,"./views/iframe.js":50,"./views/image-details.js":51,"./views/label.js":52,"./views/media-frame.js":53,"./views/menu-item.js":54,"./views/menu.js":55,"./views/modal.js":56,"./views/priority-list.js":57,"./views/router-item.js":58,"./views/router.js":59,"./views/search.js":60,"./views/selection.js":61,"./views/settings.js":62,"./views/settings/attachment-display.js":63,"./views/settings/gallery.js":64,"./views/settings/playlist.js":65,"./views/sidebar.js":66,"./views/spinner.js":67,"./views/toolbar.js":68,"./views/toolbar/embed.js":69,"./views/toolbar/select.js":70,"./views/uploader/editor.js":71,"./views/uploader/inline.js":72,"./views/uploader/status-error.js":73,"./views/uploader/status.js":74,"./views/uploader/window.js":75,"./views/view.js":76}],23:[function(a,b){var c,d=a("./view.js");c=d.extend({tagName:"form",className:"compat-item",events:{submit:"preventDefault","change input":"save","change select":"save","change textarea":"save"},initialize:function(){this.listenTo(this.model,"change:compat",this.render)},dispose:function(){return this.$(":focus").length&&this.save(),d.prototype.dispose.apply(this,arguments)},render:function(){var a=this.model.get("compat");if(a&&a.item)return this.views.detach(),this.$el.html(a.item),this.views.render(),this},preventDefault:function(a){a.preventDefault()},save:function(a){var b={};a&&a.preventDefault(),_.each(this.$el.serializeArray(),function(a){b[a.name]=a.value}),this.controller.trigger("attachment:compat:waiting",["waiting"]),this.model.saveCompat(b).always(_.bind(this.postSave,this))},postSave:function(){this.controller.trigger("attachment:compat:ready",["ready"])}}),b.exports=c},{"./view.js":76}],24:[function(a,b){var c,d=a("./view.js"),e=jQuery;c=d.extend({tagName:"select",className:"attachment-filters",id:"media-attachment-filters",events:{change:"change"},keys:[],initialize:function(){this.createFilters(),_.extend(this.filters,this.options.filters),this.$el.html(_.chain(this.filters).map(function(a,b){return{el:e("<option></option>").val(b).html(a.text)[0],priority:a.priority||50}},this).sortBy("priority").pluck("el").value()),this.listenTo(this.model,"change",this.select),this.select()},createFilters:function(){this.filters={}},change:function(){var a=this.filters[this.el.value];a&&this.model.set(a.props)},select:function(){var a=this.model,b="all",c=a.toJSON();_.find(this.filters,function(a,d){var e=_.all(a.props,function(a,b){return a===(_.isUndefined(c[b])?null:c[b])});return e?b=d:void 0}),this.$el.val(b)}}),b.exports=c},{"./view.js":76}],25:[function(a,b){var c,d=a("../attachment-filters.js"),e=wp.media.view.l10n;c=d.extend({createFilters:function(){var a={};_.each(wp.media.view.settings.mimeTypes||{},function(b,c){a[c]={text:b,props:{status:null,type:c,uploadedTo:null,orderby:"date",order:"DESC"}}}),a.all={text:e.allMediaItems,props:{status:null,type:null,uploadedTo:null,orderby:"date",order:"DESC"},priority:10},wp.media.view.settings.post.id&&(a.uploaded={text:e.uploadedToThisPost,props:{status:null,type:null,uploadedTo:wp.media.view.settings.post.id,orderby:"menuOrder",order:"ASC"},priority:20}),a.unattached={text:e.unattached,props:{status:null,uploadedTo:0,type:null,orderby:"menuOrder",order:"ASC"},priority:50},wp.media.view.settings.mediaTrash&&this.controller.isModeActive("grid")&&(a.trash={text:e.trash,props:{uploadedTo:null,status:"trash",type:null,orderby:"date",order:"DESC"},priority:50}),this.filters=a}}),b.exports=c},{"../attachment-filters.js":24}],26:[function(a,b){var c,d=a("../attachment-filters.js"),e=wp.media.view.l10n;c=d.extend({id:"media-attachment-date-filters",createFilters:function(){var a={};_.each(wp.media.view.settings.months||{},function(b,c){a[c]={text:b.text,props:{year:b.year,monthnum:b.month}}}),a.all={text:e.allDates,props:{monthnum:!1,year:!1},priority:10},this.filters=a}}),b.exports=c},{"../attachment-filters.js":24}],27:[function(a,b){var c,d=a("../attachment-filters.js"),e=wp.media.view.l10n;c=d.extend({createFilters:function(){var a,b=this.model.get("type"),c=wp.media.view.settings.mimeTypes;c&&b&&(a=c[b]),this.filters={all:{text:a||e.allMediaItems,props:{uploadedTo:null,orderby:"date",order:"DESC"},priority:10},uploaded:{text:e.uploadedToThisPost,props:{uploadedTo:wp.media.view.settings.post.id,orderby:"menuOrder",order:"ASC"},priority:20},unattached:{text:e.unattached,props:{uploadedTo:0,orderby:"menuOrder",order:"ASC"},priority:50}}}}),b.exports=c},{"../attachment-filters.js":24}],28:[function(a,b){var c,d=a("./view.js"),e=jQuery;c=d.extend({tagName:"li",className:"attachment",template:wp.template("attachment"),attributes:function(){return{tabIndex:0,role:"checkbox","aria-label":this.model.get("title"),"aria-checked":!1,"data-id":this.model.get("id")}},events:{"click .js--select-attachment":"toggleSelectionHandler","change [data-setting]":"updateSetting","change [data-setting] input":"updateSetting","change [data-setting] select":"updateSetting","change [data-setting] textarea":"updateSetting","click .close":"removeFromLibrary","click .check":"checkClickHandler","click a":"preventDefault","keydown .close":"removeFromLibrary",keydown:"toggleSelectionHandler"},buttons:{},initialize:function(){var a=this.options.selection,b=_.defaults(this.options,{rerenderOnModelChange:!0});b.rerenderOnModelChange?this.listenTo(this.model,"change",this.render):this.listenTo(this.model,"change:percent",this.progress),this.listenTo(this.model,"change:title",this._syncTitle),this.listenTo(this.model,"change:caption",this._syncCaption),this.listenTo(this.model,"change:artist",this._syncArtist),this.listenTo(this.model,"change:album",this._syncAlbum),this.listenTo(this.model,"add",this.select),this.listenTo(this.model,"remove",this.deselect),a&&(a.on("reset",this.updateSelect,this),this.listenTo(this.model,"selection:single selection:unsingle",this.details),this.details(this.model,this.controller.state().get("selection"))),this.listenTo(this.controller,"attachment:compat:waiting attachment:compat:ready",this.updateSave)},dispose:function(){var a=this.options.selection;return this.updateAll(),a&&a.off(null,null,this),d.prototype.dispose.apply(this,arguments),this},render:function(){var a=_.defaults(this.model.toJSON(),{orientation:"landscape",uploading:!1,type:"",subtype:"",icon:"",filename:"",caption:"",title:"",dateFormatted:"",width:"",height:"",compat:!1,alt:"",description:""},this.options);return a.buttons=this.buttons,a.describe=this.controller.state().get("describe"),"image"===a.type&&(a.size=this.imageSize()),a.can={},a.nonces&&(a.can.remove=!!a.nonces["delete"],a.can.save=!!a.nonces.update),this.controller.state().get("allowLocalEdits")&&(a.allowLocalEdits=!0),a.uploading&&!a.percent&&(a.percent=0),this.views.detach(),this.$el.html(this.template(a)),this.$el.toggleClass("uploading",a.uploading),a.uploading?this.$bar=this.$(".media-progress-bar div"):delete this.$bar,this.updateSelect(),this.updateSave(),this.views.render(),this},progress:function(){this.$bar&&this.$bar.length&&this.$bar.width(this.model.get("percent")+"%")},toggleSelectionHandler:function(a){var b;if("INPUT"!==a.target.nodeName){if(37===a.keyCode||38===a.keyCode||39===a.keyCode||40===a.keyCode)return void this.controller.trigger("attachment:keydown:arrow",a);if("keydown"!==a.type||13===a.keyCode||32===a.keyCode){if(a.preventDefault(),this.controller.isModeActive("grid")){if(this.controller.isModeActive("edit"))return void this.controller.trigger("edit:attachment",this.model,a.currentTarget);this.controller.isModeActive("select")&&(b="toggle")}a.shiftKey?b="between":(a.ctrlKey||a.metaKey)&&(b="toggle"),this.toggleSelection({method:b}),this.controller.trigger("selection:toggle")}}},toggleSelection:function(a){var b,c,d,e,f=this.collection,g=this.options.selection,h=this.model,i=a&&a.method;if(g){if(b=g.single(),i=_.isUndefined(i)?g.multiple:i,"between"===i&&b&&g.multiple){if(b===h)return;return d=f.indexOf(b),e=f.indexOf(this.model),c=e>d?f.models.slice(d,e+1):f.models.slice(e,d+1),g.add(c),void g.single(h)}if("toggle"===i)return g[this.selected()?"remove":"add"](h),void g.single(h);if("add"===i)return g.add(h),void g.single(h);i||(i="add"),"add"!==i&&(i="reset"),this.selected()?g[b===h?"remove":"single"](h):(g[i](h),g.single(h))}},updateSelect:function(){this[this.selected()?"select":"deselect"]()},selected:function(){var a=this.options.selection;return a?!!a.get(this.model.cid):void 0},select:function(a,b){var c=this.options.selection,d=this.controller;!c||b&&b!==c||this.$el.hasClass("selected")||(this.$el.addClass("selected").attr("aria-checked",!0),d.isModeActive("grid")&&d.isModeActive("select")||this.$(".check").attr("tabindex","0"))},deselect:function(a,b){var c=this.options.selection;!c||b&&b!==c||this.$el.removeClass("selected").attr("aria-checked",!1).find(".check").attr("tabindex","-1")},details:function(a,b){var c,d=this.options.selection;d===b&&(c=d.single(),this.$el.toggleClass("details",c===this.model))},preventDefault:function(a){a.preventDefault()},imageSize:function(a){var b=this.model.get("sizes"),c=!1;return a=a||"medium",b&&(b[a]?c=b[a]:b.large?c=b.large:b.thumbnail?c=b.thumbnail:b.full&&(c=b.full),c)?_.clone(c):{url:this.model.get("url"),width:this.model.get("width"),height:this.model.get("height"),orientation:this.model.get("orientation")}},updateSetting:function(a){var b,c,d=e(a.target).closest("[data-setting]");d.length&&(b=d.data("setting"),c=a.target.value,this.model.get(b)!==c&&this.save(b,c))},save:function(){var a=this,b=this._save=this._save||{status:"ready"},c=this.model.save.apply(this.model,arguments),d=b.requests?e.when(c,b.requests):c;b.savedTimer&&clearTimeout(b.savedTimer),this.updateSave("waiting"),b.requests=d,d.always(function(){b.requests===d&&(a.updateSave("resolved"===d.state()?"complete":"error"),b.savedTimer=setTimeout(function(){a.updateSave("ready"),delete b.savedTimer},2e3))})},updateSave:function(a){var b=this._save=this._save||{status:"ready"};return a&&a!==b.status&&(this.$el.removeClass("save-"+b.status),b.status=a),this.$el.addClass("save-"+b.status),this},updateAll:function(){var a,b=this.$("[data-setting]"),c=this.model;a=_.chain(b).map(function(a){var b,d,f=e("input, textarea, select, [value]",a);if(f.length)return b=e(a).data("setting"),d=f.val(),c.get(b)!==d?[b,d]:void 0}).compact().object().value(),_.isEmpty(a)||c.save(a)},removeFromLibrary:function(a){("keydown"!==a.type||13===a.keyCode||32===a.keyCode)&&(a.stopPropagation(),this.collection.remove(this.model))},checkClickHandler:function(a){var b=this.options.selection;b&&(a.stopPropagation(),b.where({id:this.model.get("id")}).length?(b.remove(this.model),this.$el.focus()):b.add(this.model))}}),_.each({caption:"_syncCaption",title:"_syncTitle",artist:"_syncArtist",album:"_syncAlbum"},function(a,b){c.prototype[a]=function(a,c){var d=this.$('[data-setting="'+b+'"]');return d.length?c===d.find("input, textarea, select, [value]").val()?this:this.render():this}}),b.exports=c},{"./view.js":76}],29:[function(a,b){var c,d=a("../attachment.js"),e=wp.media.view.l10n;c=d.extend({tagName:"div",className:"attachment-details",template:wp.template("attachment-details"),attributes:function(){return{tabIndex:0,"data-id":this.model.get("id")}},events:{"change [data-setting]":"updateSetting","change [data-setting] input":"updateSetting","change [data-setting] select":"updateSetting","change [data-setting] textarea":"updateSetting","click .delete-attachment":"deleteAttachment","click .trash-attachment":"trashAttachment","click .untrash-attachment":"untrashAttachment","click .edit-attachment":"editAttachment","click .refresh-attachment":"refreshAttachment",keydown:"toggleSelectionHandler"},initialize:function(){this.options=_.defaults(this.options,{rerenderOnModelChange:!1}),this.on("ready",this.initialFocus),d.prototype.initialize.apply(this,arguments)},initialFocus:function(){wp.media.isTouchDevice||this.$(":input").eq(0).focus()},deleteAttachment:function(a){a.preventDefault(),confirm(e.warnDelete)&&(this.model.destroy(),this.controller.modal.focusManager.focus())},trashAttachment:function(a){var b=this.controller.library;a.preventDefault(),wp.media.view.settings.mediaTrash&&"edit-metadata"===this.controller.content.mode()?(this.model.set("status","trash"),this.model.save().done(function(){b._requery(!0)})):this.model.destroy()},untrashAttachment:function(a){var b=this.controller.library;a.preventDefault(),this.model.set("status","inherit"),this.model.save().done(function(){b._requery(!0)})},editAttachment:function(a){var b=this.controller.states.get("edit-image");window.imageEdit&&b?(a.preventDefault(),b.set("image",this.model),this.controller.setState("edit-image")):this.$el.addClass("needs-refresh")},refreshAttachment:function(a){this.$el.removeClass("needs-refresh"),a.preventDefault(),this.model.fetch()},toggleSelectionHandler:function(a){return"keydown"===a.type&&9===a.keyCode&&a.shiftKey&&a.target===this.$(":tabbable").get(0)?(this.controller.trigger("attachment:details:shift-tab",a),!1):37===a.keyCode||38===a.keyCode||39===a.keyCode||40===a.keyCode?void this.controller.trigger("attachment:keydown:arrow",a):void 0}}),b.exports=c},{"../attachment.js":28}],30:[function(a,b){var c,d=a("../attachment.js");c=d.extend({buttons:{close:!0}}),b.exports=c},{"../attachment.js":28}],31:[function(a,b){var c,d=a("./selection.js");c=d.extend({buttons:{close:!0}}),b.exports=c},{"./selection.js":33}],32:[function(a,b){var c,d=a("../attachment.js");c=d.extend({buttons:{check:!0}}),b.exports=c},{"../attachment.js":28}],33:[function(a,b){var c,d=a("../attachment.js");c=d.extend({className:"attachment selection",toggleSelection:function(){this.options.selection.single(this.model)}}),b.exports=c},{"../attachment.js":28}],34:[function(a,b){var c,d=a("./view.js"),e=a("./attachment.js"),f=jQuery;c=d.extend({tagName:"ul",className:"attachments",attributes:{tabIndex:-1},initialize:function(){this.el.id=_.uniqueId("__attachments-view-"),_.defaults(this.options,{refreshSensitivity:wp.media.isTouchDevice?300:200,refreshThreshold:3,AttachmentView:e,sortable:!1,resize:!0,idealColumnWidth:f(window).width()<640?135:150}),this._viewsByCid={},this.$window=f(window),this.resizeEvent="resize.media-modal-columns",this.collection.on("add",function(a){this.views.add(this.createAttachmentView(a),{at:this.collection.indexOf(a)})},this),this.collection.on("remove",function(a){var b=this._viewsByCid[a.cid];delete this._viewsByCid[a.cid],b&&b.remove()},this),this.collection.on("reset",this.render,this),this.listenTo(this.controller,"library:selection:add",this.attachmentFocus),this.scroll=_.chain(this.scroll).bind(this).throttle(this.options.refreshSensitivity).value(),this.options.scrollElement=this.options.scrollElement||this.el,f(this.options.scrollElement).on("scroll",this.scroll),this.initSortable(),_.bindAll(this,"setColumns"),this.options.resize&&(this.on("ready",this.bindEvents),this.controller.on("open",this.setColumns),_.defer(this.setColumns,this))},bindEvents:function(){this.$window.off(this.resizeEvent).on(this.resizeEvent,_.debounce(this.setColumns,50))},attachmentFocus:function(){this.$("li:first").focus()},restoreFocus:function(){this.$("li.selected:first").focus()},arrowEvent:function(a){var b=this.$el.children("li"),c=this.columns,d=b.filter(":focus").index(),e=c>=d+1?1:Math.ceil((d+1)/c);if(-1!==d){if(37===a.keyCode){if(0===d)return;b.eq(d-1).focus()}if(38===a.keyCode){if(1===e)return;b.eq(d-c).focus()}if(39===a.keyCode){if(b.length===d)return;b.eq(d+1).focus()}if(40===a.keyCode){if(Math.ceil(b.length/c)===e)return;b.eq(d+c).focus()}}},dispose:function(){this.collection.props.off(null,null,this),this.options.resize&&this.$window.off(this.resizeEvent),d.prototype.dispose.apply(this,arguments)},setColumns:function(){var a=this.columns,b=this.$el.width();b&&(this.columns=Math.min(Math.round(b/this.options.idealColumnWidth),12)||1,a&&a===this.columns||this.$el.closest(".media-frame-content").attr("data-columns",this.columns))},initSortable:function(){var a=this.collection;!wp.media.isTouchDevice&&this.options.sortable&&f.fn.sortable&&(this.$el.sortable(_.extend({disabled:!!a.comparator,tolerance:"pointer",start:function(a,b){b.item.data("sortableIndexStart",b.item.index())},update:function(b,c){var d=a.at(c.item.data("sortableIndexStart")),e=a.comparator;delete a.comparator,a.remove(d,{silent:!0}),a.add(d,{silent:!0,at:c.item.index()}),a.comparator=e,a.trigger("reset",a),a.saveMenuOrder()}},this.options.sortable)),a.props.on("change:orderby",function(){this.$el.sortable("option","disabled",!!a.comparator)},this),this.collection.props.on("change:orderby",this.refreshSortable,this),this.refreshSortable())},refreshSortable:function(){if(!wp.media.isTouchDevice&&this.options.sortable&&f.fn.sortable){var a=this.collection,b=a.props.get("orderby"),c="menuOrder"===b||!a.comparator;this.$el.sortable("option","disabled",!c)}},createAttachmentView:function(a){var b=new this.options.AttachmentView({controller:this.controller,model:a,collection:this.collection,selection:this.options.selection});return this._viewsByCid[a.cid]=b},prepare:function(){this.collection.length?this.views.set(this.collection.map(this.createAttachmentView,this)):(this.views.unset(),this.collection.more().done(this.scroll))},ready:function(){this.scroll()},scroll:function(){var a,b=this,c=this.options.scrollElement,d=c.scrollTop;c==document&&(c=document.body,d=f(document).scrollTop()),f(c).is(":visible")&&this.collection.hasMore()&&(a=this.views.parent.toolbar,c.scrollHeight-(d+c.clientHeight)<c.clientHeight/3&&a.get("spinner").show(),c.scrollHeight<d+c.clientHeight*this.options.refreshThreshold&&this.collection.more().done(function(){b.scroll(),a.get("spinner").hide()}))}}),b.exports=c},{"./attachment.js":28,"./view.js":76}],35:[function(a,b){var c,d=a("../view.js"),e=a("../attachment/library.js"),f=a("../toolbar.js"),g=a("../spinner.js"),h=a("../search.js"),i=a("../label.js"),j=a("../attachment-filters/uploaded.js"),k=a("../attachment-filters/all.js"),l=a("../attachment-filters/date.js"),m=a("../uploader/inline.js"),n=a("../attachments.js"),o=a("../sidebar.js"),p=a("../uploader/status.js"),q=a("../attachment/details.js"),r=a("../attachment-compat.js"),s=a("../settings/attachment-display.js"),t=wp.media.view.settings.mediaTrash,u=wp.media.view.l10n,v=jQuery;c=d.extend({tagName:"div",className:"attachments-browser",initialize:function(){_.defaults(this.options,{filters:!1,search:!0,date:!0,display:!1,sidebar:!0,AttachmentView:e}),this.listenTo(this.controller,"toggle:upload:attachment",_.bind(this.toggleUploader,this)),this.controller.on("edit:selection",this.editSelection),this.createToolbar(),this.options.sidebar&&this.createSidebar(),this.createUploader(),this.createAttachments(),this.updateContent(),this.options.sidebar&&"errors"!==this.options.sidebar||(this.$el.addClass("hide-sidebar"),"errors"===this.options.sidebar&&this.$el.addClass("sidebar-for-errors")),this.collection.on("add remove reset",this.updateContent,this)},editSelection:function(a){a.$(".media-button-backToLibrary").focus()},dispose:function(){return this.options.selection.off(null,null,this),d.prototype.dispose.apply(this,arguments),this},createToolbar:function(){var a,b,c;c={controller:this.controller},this.controller.isModeActive("grid")&&(c.className="media-toolbar wp-filter"),this.toolbar=new f(c),this.views.add(this.toolbar),this.toolbar.set("spinner",new g({priority:-60})),-1!==v.inArray(this.options.filters,["uploaded","all"])&&(this.toolbar.set("filtersLabel",new i({value:u.filterByType,attributes:{"for":"media-attachment-filters"},priority:-80}).render()),"uploaded"===this.options.filters?this.toolbar.set("filters",new j({controller:this.controller,model:this.collection.props,priority:-80}).render()):(b=new k({controller:this.controller,model:this.collection.props,priority:-80}),this.toolbar.set("filters",b.render()))),this.controller.isModeActive("grid")?(a=d.extend({className:"view-switch media-grid-view-switch",template:wp.template("media-library-view-switcher")}),this.toolbar.set("libraryViewSwitcher",new a({controller:this.controller,priority:-90}).render()),this.toolbar.set("dateFilterLabel",new i({value:u.filterByDate,attributes:{"for":"media-attachment-date-filters"},priority:-75}).render()),this.toolbar.set("dateFilter",new l({controller:this.controller,model:this.collection.props,priority:-75}).render()),this.toolbar.set("selectModeToggleButton",new wp.media.view.SelectModeToggleButton({text:u.bulkSelect,controller:this.controller,priority:-70}).render()),this.toolbar.set("deleteSelectedButton",new wp.media.view.DeleteSelectedButton({filters:b,style:"primary",disabled:!0,text:t?u.trashSelected:u.deleteSelected,controller:this.controller,priority:-60,click:function(){var a=[],b=[],c=this,d=this.controller.state().get("selection"),e=this.controller.state().get("library");d.length&&(t||confirm(u.warnBulkDelete))&&(!t||"trash"===d.at(0).get("status")||confirm(u.warnBulkTrash))&&(d.each(function(c){return c.get("nonces")["delete"]?void(t&&"trash"===c.get("status")?(c.set("status","inherit"),a.push(c.save()),b.push(c)):t?(c.set("status","trash"),a.push(c.save()),b.push(c)):c.destroy({wait:!0})):void b.push(c)}),a.length?(d.remove(b),v.when.apply(null,a).then(function(){e._requery(!0),c.controller.trigger("selection:action:done")})):this.controller.trigger("selection:action:done"))}}).render()),t&&this.toolbar.set("deleteSelectedPermanentlyButton",new wp.media.view.DeleteSelectedPermanentlyButton({filters:b,style:"primary",disabled:!0,text:u.deleteSelected,controller:this.controller,priority:-55,click:function(){var a=[],b=this.controller.state().get("selection");b.length&&confirm(u.warnBulkDelete)&&(b.each(function(b){return b.get("nonces")["delete"]?void b.destroy():void a.push(b)}),b.remove(a),this.controller.trigger("selection:action:done"))}}).render())):this.options.date&&(this.toolbar.set("dateFilterLabel",new i({value:u.filterByDate,attributes:{"for":"media-attachment-date-filters"},priority:-75}).render()),this.toolbar.set("dateFilter",new l({controller:this.controller,model:this.collection.props,priority:-75}).render())),this.options.search&&(this.toolbar.set("searchLabel",new i({value:u.searchMediaLabel,attributes:{"for":"media-search-input"},priority:60}).render()),this.toolbar.set("search",new h({controller:this.controller,model:this.collection.props,priority:60}).render())),this.options.dragInfo&&this.toolbar.set("dragInfo",new d({el:v('<div class="instructions">'+u.dragInfo+"</div>")[0],priority:-40})),this.options.suggestedWidth&&this.options.suggestedHeight&&this.toolbar.set("suggestedDimensions",new d({el:v('<div class="instructions">'+u.suggestedDimensions+" "+this.options.suggestedWidth+" &times; "+this.options.suggestedHeight+"</div>")[0],priority:-40}))},updateContent:function(){var a,b=this;a=this.controller.isModeActive("grid")?b.attachmentsNoResults:b.uploader,this.collection.length?(a.$el.addClass("hidden"),b.toolbar.get("spinner").hide()):(this.toolbar.get("spinner").show(),this.dfd=this.collection.more().done(function(){b.collection.length?a.$el.addClass("hidden"):a.$el.removeClass("hidden"),b.toolbar.get("spinner").hide()}))},createUploader:function(){this.uploader=new m({controller:this.controller,status:!1,message:this.controller.isModeActive("grid")?"":u.noItemsFound,canClose:this.controller.isModeActive("grid")}),this.uploader.hide(),this.views.add(this.uploader)},toggleUploader:function(){this.uploader.$el.hasClass("hidden")?this.uploader.show():this.uploader.hide()},createAttachments:function(){this.attachments=new n({controller:this.controller,collection:this.collection,selection:this.options.selection,model:this.model,sortable:this.options.sortable,scrollElement:this.options.scrollElement,idealColumnWidth:this.options.idealColumnWidth,AttachmentView:this.options.AttachmentView}),this.attachments.listenTo(this.controller,"attachment:keydown:arrow",this.attachments.arrowEvent),this.attachments.listenTo(this.controller,"attachment:details:shift-tab",this.attachments.restoreFocus),this.views.add(this.attachments),this.controller.isModeActive("grid")&&(this.attachmentsNoResults=new d({controller:this.controller,tagName:"p"}),this.attachmentsNoResults.$el.addClass("hidden no-media"),this.attachmentsNoResults.$el.html(u.noMedia),this.views.add(this.attachmentsNoResults))},createSidebar:function(){var a=this.options,b=a.selection,c=this.sidebar=new o({controller:this.controller});this.views.add(c),this.controller.uploader&&c.set("uploads",new p({controller:this.controller,priority:40})),b.on("selection:single",this.createSingle,this),b.on("selection:unsingle",this.disposeSingle,this),b.single()&&this.createSingle()},createSingle:function(){var a=this.sidebar,b=this.options.selection.single();a.set("details",new q({controller:this.controller,model:b,priority:80})),a.set("compat",new r({controller:this.controller,model:b,priority:120})),this.options.display&&a.set("display",new s({controller:this.controller,model:this.model.display(b),attachment:b,priority:160,userSettings:this.model.get("displayUserSettings")})),"insert"===this.model.id&&a.$el.addClass("visible")},disposeSingle:function(){var a=this.sidebar;a.unset("details"),a.unset("compat"),a.unset("display"),a.$el.removeClass("visible")}}),b.exports=c},{"../attachment-compat.js":23,"../attachment-filters/all.js":25,"../attachment-filters/date.js":26,"../attachment-filters/uploaded.js":27,"../attachment/details.js":29,"../attachment/library.js":32,"../attachments.js":34,"../label.js":52,"../search.js":60,"../settings/attachment-display.js":63,"../sidebar.js":66,"../spinner.js":67,"../toolbar.js":68,"../uploader/inline.js":72,"../uploader/status.js":74,"../view.js":76}],36:[function(a,b){var c,d=a("../attachments.js"),e=a("../attachment/selection.js");c=d.extend({events:{},initialize:function(){return _.defaults(this.options,{sortable:!1,resize:!1,AttachmentView:e}),d.prototype.initialize.apply(this,arguments)}}),b.exports=c},{"../attachment/selection.js":33,"../attachments.js":34}],37:[function(a,b){var c,d=a("./view.js"),e=a("./button.js"),f=jQuery;c=d.extend({tagName:"div",className:"button-group button-large media-button-group",initialize:function(){this.buttons=_.map(this.options.buttons||[],function(a){return a instanceof Backbone.View?a:new e(a).render()}),delete this.options.buttons,this.options.classes&&this.$el.addClass(this.options.classes)},render:function(){return this.$el.html(f(_.pluck(this.buttons,"el")).detach()),this}}),b.exports=c},{"./button.js":38,"./view.js":76}],38:[function(a,b){var c,d=a("./view.js");c=d.extend({tagName:"a",className:"media-button",attributes:{href:"#"},events:{click:"click"},defaults:{text:"",style:"",size:"large",disabled:!1},initialize:function(){this.model=new Backbone.Model(this.defaults),_.each(this.defaults,function(a,b){var c=this.options[b];_.isUndefined(c)||(this.model.set(b,c),delete this.options[b])},this),this.listenTo(this.model,"change",this.render)},render:function(){var a=["button",this.className],b=this.model.toJSON();return b.style&&a.push("button-"+b.style),b.size&&a.push("button-"+b.size),a=_.uniq(a.concat(this.options.classes)),this.el.className=a.join(" "),this.$el.attr("disabled",b.disabled),this.$el.text(this.model.get("text")),this},click:function(a){"#"===this.attributes.href&&a.preventDefault(),this.options.click&&!this.model.get("disabled")&&this.options.click.apply(this,arguments)}}),b.exports=c},{"./view.js":76}],39:[function(a,b){var c,d=a("./view.js"),e=a("./uploader/status-error.js"),f=a("./uploader/status.js"),g=wp.media.view.l10n,h=jQuery;c=d.extend({className:"crop-content",template:wp.template("crop-content"),initialize:function(){_.bindAll(this,"onImageLoad")},ready:function(){this.controller.frame.on("content:error:crop",this.onError,this),this.$image=this.$el.find(".crop-image"),this.$image.on("load",this.onImageLoad),h(window).on("resize.cropper",_.debounce(this.onImageLoad,250))},remove:function(){h(window).off("resize.cropper"),this.$el.remove(),this.$el.off(),d.prototype.remove.apply(this,arguments)},prepare:function(){return{title:g.cropYourImage,url:this.options.attachment.get("url")}},onImageLoad:function(){var a=this.controller.get("imgSelectOptions");"function"==typeof a&&(a=a(this.options.attachment,this.controller)),a=_.extend(a,{parent:this.$el}),this.trigger("image-loaded"),this.controller.imgSelect=this.$image.imgAreaSelect(a)},onError:function(){var a=this.options.attachment.get("filename");this.views.add(".upload-errors",new e({filename:f.prototype.filename(a),message:_wpMediaViewsL10n.cropError}),{at:0})}}),b.exports=c},{"./uploader/status-error.js":73,"./uploader/status.js":74,"./view.js":76}],40:[function(a,b){var c,d=a("./view.js");c=d.extend({className:"image-editor",template:wp.template("image-editor"),initialize:function(a){this.editor=window.imageEdit,this.controller=a.controller,d.prototype.initialize.apply(this,arguments)},prepare:function(){return this.model.toJSON()},render:function(){return d.prototype.render.apply(this,arguments),this},loadEditor:function(){var a=this.editor.open(this.model.get("id"),this.model.get("nonces").edit,this);a.done(_.bind(this.focus,this))},focus:function(){this.$(".imgedit-submit .button").eq(0).focus()},back:function(){var a=this.controller.lastState();this.controller.setState(a)},refresh:function(){this.model.fetch()},save:function(){var a=this,b=this.controller.lastState();this.model.fetch().done(function(){a.controller.setState(b)})}}),b.exports=c},{"./view.js":76}],41:[function(a,b){var c,d=a("./view.js"),e=a("./embed/image.js"),f=a("./embed/link.js"),g=a("./embed/url.js");c=d.extend({className:"media-embed",initialize:function(){this.url=new g({controller:this.controller,model:this.model.props}).render(),this.views.set([this.url]),this.refresh(),this.listenTo(this.model,"change:type",this.refresh),this.listenTo(this.model,"change:loading",this.loading)},settings:function(a){this._settings&&this._settings.remove(),this._settings=a,this.views.add(a)},refresh:function(){var a,b=this.model.get("type");if("image"===b)a=e;else{if("link"!==b)return;a=f}this.settings(new a({controller:this.controller,model:this.model.props,priority:40}))},loading:function(){this.$el.toggleClass("embed-loading",this.model.get("loading"))}}),b.exports=c},{"./embed/image.js":42,"./embed/link.js":43,"./embed/url.js":44,"./view.js":76}],42:[function(a,b){var c,d=a("../settings/attachment-display.js");c=d.extend({className:"embed-media-settings",template:wp.template("embed-image-settings"),initialize:function(){d.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"change:url",this.updateImage)
},updateImage:function(){this.$("img").attr("src",this.model.get("url"))}}),b.exports=c},{"../settings/attachment-display.js":63}],43:[function(a,b){var c,d=a("../settings.js"),e=jQuery;c=d.extend({className:"embed-link-settings",template:wp.template("embed-link-settings"),initialize:function(){this.spinner=e('<span class="spinner" />'),this.$el.append(this.spinner[0]),this.listenTo(this.model,"change:url",this.updateoEmbed)},updateoEmbed:function(){var a=this.model.get("url");this.$(".setting.title").show(),this.$(".embed-container").hide().find(".embed-preview").html(""),a&&a.length<6||(this.spinner.show(),setTimeout(_.bind(this.fetch,this),500))},fetch:function(){e("#embed-url-field").val()===this.model.get("url")&&wp.ajax.send("parse-embed",{data:{post_ID:wp.media.view.settings.post.id,shortcode:"[embed]"+this.model.get("url")+"[/embed]"}}).done(_.bind(this.renderoEmbed,this))},renderoEmbed:function(a){var b=a&&a.body||"";this.spinner.hide(),this.$(".setting.title").hide(),this.$(".embed-container").show().find(".embed-preview").html(b)}}),b.exports=c},{"../settings.js":62}],44:[function(a,b){var c,d=a("../view.js"),e=jQuery;c=d.extend({tagName:"label",className:"embed-url",events:{input:"url",keyup:"url",change:"url"},initialize:function(){var a=this;this.$input=e('<input id="embed-url-field" type="url" />').val(this.model.get("url")),this.input=this.$input[0],this.spinner=e('<span class="spinner" />')[0],this.$el.append([this.input,this.spinner]),this.listenTo(this.model,"change:url",this.render),this.model.get("url")&&_.delay(function(){a.model.trigger("change:url")},500)},render:function(){var a=this.$input;if(!a.is(":focus"))return this.input.value=this.model.get("url")||"http://",d.prototype.render.apply(this,arguments),this},ready:function(){wp.media.isTouchDevice||this.focus()},url:function(a){this.model.set("url",a.target.value)},focus:function(){var a=this.$input;a.is(":visible")&&a.focus()[0].select()}}),b.exports=c},{"../view.js":76}],45:[function(a,b){var c,d=a("./view.js");c=d.extend({events:{keydown:"constrainTabbing"},focus:function(){this.$(".media-menu-item").first().focus()},constrainTabbing:function(a){var b;if(9===a.keyCode)return b=this.$(":tabbable").not('.moxie-shim input[type="file"]'),b.last()[0]!==a.target||a.shiftKey?b.first()[0]===a.target&&a.shiftKey?(b.last().focus(),!1):void 0:(b.first().focus(),!1)}}),b.exports=c},{"./view.js":76}],46:[function(a,b){var c,d=a("../controllers/state-machine.js"),e=a("../controllers/state.js"),f=a("../controllers/region.js"),g=a("./view.js");c=g.extend({initialize:function(){_.defaults(this.options,{mode:["select"]}),this._createRegions(),this._createStates(),this._createModes()},_createRegions:function(){this.regions=this.regions?this.regions.slice():[],_.each(this.regions,function(a){this[a]=new f({view:this,id:a,selector:".media-frame-"+a})},this)},_createStates:function(){this.states=new Backbone.Collection(null,{model:e}),this.states.on("add",function(a){a.frame=this,a.trigger("ready")},this),this.options.states&&this.states.add(this.options.states)},_createModes:function(){this.activeModes=new Backbone.Collection,this.activeModes.on("add remove reset",_.bind(this.triggerModeEvents,this)),_.each(this.options.mode,function(a){this.activateMode(a)},this)},reset:function(){return this.states.invoke("trigger","reset"),this},triggerModeEvents:function(a,b,c){var d,e,f={add:"activate",remove:"deactivate"};_.each(c,function(a,b){a&&(d=b)}),_.has(f,d)&&(e=a.get("id")+":"+f[d],this.trigger(e))},activateMode:function(a){return this.isModeActive(a)?void 0:(this.activeModes.add([{id:a}]),this.$el.addClass("mode-"+a),this)},deactivateMode:function(a){return this.isModeActive(a)?(this.activeModes.remove(this.activeModes.where({id:a})),this.$el.removeClass("mode-"+a),this.trigger(a+":deactivate"),this):this},isModeActive:function(a){return Boolean(this.activeModes.where({id:a}).length)}}),_.extend(c.prototype,d.prototype),b.exports=c},{"../controllers/region.js":12,"../controllers/state-machine.js":14,"../controllers/state.js":15,"./view.js":76}],47:[function(a,b){var c,d=a("./select.js"),e=a("../toolbar.js"),f=a("../../models/post-image.js"),g=a("../../models/selection.js"),h=a("../../controllers/image-details.js"),i=a("../../controllers/replace-image.js"),j=a("../../controllers/edit-image.js"),k=a("../image-details.js"),l=a("../edit-image.js"),m=wp.media.view.l10n;c=d.extend({defaults:{id:"image",url:"",menu:"image-details",content:"image-details",toolbar:"image-details",type:"link",title:m.imageDetailsTitle,priority:120},initialize:function(a){this.image=new f(a.metadata),this.options.selection=new g(this.image.attachment,{multiple:!1}),d.prototype.initialize.apply(this,arguments)},bindHandlers:function(){d.prototype.bindHandlers.apply(this,arguments),this.on("menu:create:image-details",this.createMenu,this),this.on("content:create:image-details",this.imageDetailsContent,this),this.on("content:render:edit-image",this.editImageContent,this),this.on("toolbar:render:image-details",this.renderImageDetailsToolbar,this),this.on("toolbar:render:replace",this.renderReplaceImageToolbar,this)},createStates:function(){this.states.add([new h({image:this.image,editable:!1}),new i({id:"replace-image",library:wp.media.query({type:"image"}),image:this.image,multiple:!1,title:m.imageReplaceTitle,toolbar:"replace",priority:80,displaySettings:!0}),new j({image:this.image,selection:this.options.selection})])},imageDetailsContent:function(a){a.view=new k({controller:this,model:this.state().image,attachment:this.state().image.attachment})},editImageContent:function(){var a,b=this.state(),c=b.get("image");c&&(a=new l({model:c,controller:this}).render(),this.content.set(a),a.loadEditor())},renderImageDetailsToolbar:function(){this.toolbar.set(new e({controller:this,items:{select:{style:"primary",text:m.update,priority:80,click:function(){var a=this.controller,b=a.state();a.close(),b.trigger("update",a.image.toJSON()),a.setState(a.options.state),a.reset()}}}}))},renderReplaceImageToolbar:function(){var a=this,b=a.lastState(),c=b&&b.id;this.toolbar.set(new e({controller:this,items:{back:{text:m.back,priority:20,click:function(){c?a.setState(c):a.close()}},replace:{style:"primary",text:m.replace,priority:80,click:function(){var a=this.controller,b=a.state(),c=b.get("selection"),d=c.single();a.close(),a.image.changeAttachment(d,b.display(d)),b.trigger("replace",a.image.toJSON()),a.setState(a.options.state),a.reset()}}}}))}}),b.exports=c},{"../../controllers/edit-image.js":4,"../../controllers/image-details.js":9,"../../controllers/replace-image.js":13,"../../models/post-image.js":18,"../../models/selection.js":20,"../edit-image.js":40,"../image-details.js":51,"../toolbar.js":68,"./select.js":49}],48:[function(a,b){var c,d=a("../view.js"),e=a("./select.js"),f=a("../../controllers/library.js"),g=a("../embed.js"),h=a("../edit-image.js"),i=a("../attachment/edit-selection.js"),j=a("../toolbar.js"),k=a("../toolbar/embed.js"),l=a("../settings/playlist.js"),m=a("../attachments/browser.js"),n=a("../../models/selection.js"),o=a("../selection.js"),p=a("../../controllers/embed.js"),q=a("../../controllers/edit-image.js"),r=a("../../controllers/gallery-edit.js"),s=a("../../controllers/gallery-add.js"),t=a("../../controllers/collection-edit.js"),u=a("../../controllers/collection-add.js"),v=a("../../controllers/featured-image.js"),w=wp.media.view.l10n;c=e.extend({initialize:function(){this.counts={audio:{count:wp.media.view.settings.attachmentCounts.audio,state:"playlist"},video:{count:wp.media.view.settings.attachmentCounts.video,state:"video-playlist"}},_.defaults(this.options,{multiple:!0,editing:!1,state:"insert",metadata:{}}),e.prototype.initialize.apply(this,arguments),this.createIframeStates()},createStates:function(){var a=this.options;this.states.add([new f({id:"insert",title:w.insertMediaTitle,priority:20,toolbar:"main-insert",filterable:"all",library:wp.media.query(a.library),multiple:a.multiple?"reset":!1,editable:!0,allowLocalEdits:!0,displaySettings:!0,displayUserSettings:!0}),new f({id:"gallery",title:w.createGalleryTitle,priority:40,toolbar:"main-gallery",filterable:"uploaded",multiple:"add",editable:!1,library:wp.media.query(_.defaults({type:"image"},a.library))}),new p({metadata:a.metadata}),new q({model:a.editImage}),new r({library:a.selection,editing:a.editing,menu:"gallery"}),new s,new f({id:"playlist",title:w.createPlaylistTitle,priority:60,toolbar:"main-playlist",filterable:"uploaded",multiple:"add",editable:!1,library:wp.media.query(_.defaults({type:"audio"},a.library))}),new t({type:"audio",collectionType:"playlist",title:w.editPlaylistTitle,SettingsView:l,library:a.selection,editing:a.editing,menu:"playlist",dragInfoText:w.playlistDragInfo,dragInfo:!1}),new u({type:"audio",collectionType:"playlist",title:w.addToPlaylistTitle}),new f({id:"video-playlist",title:w.createVideoPlaylistTitle,priority:60,toolbar:"main-video-playlist",filterable:"uploaded",multiple:"add",editable:!1,library:wp.media.query(_.defaults({type:"video"},a.library))}),new t({type:"video",collectionType:"playlist",title:w.editVideoPlaylistTitle,SettingsView:l,library:a.selection,editing:a.editing,menu:"video-playlist",dragInfoText:w.videoPlaylistDragInfo,dragInfo:!1}),new u({type:"video",collectionType:"playlist",title:w.addToVideoPlaylistTitle})]),wp.media.view.settings.post.featuredImageId&&this.states.add(new v)},bindHandlers:function(){var a,b;e.prototype.bindHandlers.apply(this,arguments),this.on("activate",this.activate,this),b=_.find(this.counts,function(a){return 0===a.count}),"undefined"!=typeof b&&this.listenTo(wp.media.model.Attachments.all,"change:type",this.mediaTypeCounts),this.on("menu:create:gallery",this.createMenu,this),this.on("menu:create:playlist",this.createMenu,this),this.on("menu:create:video-playlist",this.createMenu,this),this.on("toolbar:create:main-insert",this.createToolbar,this),this.on("toolbar:create:main-gallery",this.createToolbar,this),this.on("toolbar:create:main-playlist",this.createToolbar,this),this.on("toolbar:create:main-video-playlist",this.createToolbar,this),this.on("toolbar:create:featured-image",this.featuredImageToolbar,this),this.on("toolbar:create:main-embed",this.mainEmbedToolbar,this),a={menu:{"default":"mainMenu",gallery:"galleryMenu",playlist:"playlistMenu","video-playlist":"videoPlaylistMenu"},content:{embed:"embedContent","edit-image":"editImageContent","edit-selection":"editSelectionContent"},toolbar:{"main-insert":"mainInsertToolbar","main-gallery":"mainGalleryToolbar","gallery-edit":"galleryEditToolbar","gallery-add":"galleryAddToolbar","main-playlist":"mainPlaylistToolbar","playlist-edit":"playlistEditToolbar","playlist-add":"playlistAddToolbar","main-video-playlist":"mainVideoPlaylistToolbar","video-playlist-edit":"videoPlaylistEditToolbar","video-playlist-add":"videoPlaylistAddToolbar"}},_.each(a,function(a,b){_.each(a,function(a,c){this.on(b+":render:"+c,this[a],this)},this)},this)},activate:function(){_.each(this.counts,function(a){a.count<1&&this.menuItemVisibility(a.state,"hide")},this)},mediaTypeCounts:function(a,b){"undefined"!=typeof this.counts[b]&&this.counts[b].count<1&&(this.counts[b].count++,this.menuItemVisibility(this.counts[b].state,"show"))},mainMenu:function(a){a.set({"library-separator":new d({className:"separator",priority:100})})},menuItemVisibility:function(a,b){var c=this.menu.get();"hide"===b?c.hide(a):"show"===b&&c.show(a)},galleryMenu:function(a){var b=this.lastState(),c=b&&b.id,e=this;a.set({cancel:{text:w.cancelGalleryTitle,priority:20,click:function(){c?e.setState(c):e.close(),this.controller.modal.focusManager.focus()}},separateCancel:new d({className:"separator",priority:40})})},playlistMenu:function(a){var b=this.lastState(),c=b&&b.id,e=this;a.set({cancel:{text:w.cancelPlaylistTitle,priority:20,click:function(){c?e.setState(c):e.close()}},separateCancel:new d({className:"separator",priority:40})})},videoPlaylistMenu:function(a){var b=this.lastState(),c=b&&b.id,e=this;a.set({cancel:{text:w.cancelVideoPlaylistTitle,priority:20,click:function(){c?e.setState(c):e.close()}},separateCancel:new d({className:"separator",priority:40})})},embedContent:function(){var a=new g({controller:this,model:this.state()}).render();this.content.set(a),wp.media.isTouchDevice||a.url.focus()},editSelectionContent:function(){var a,b=this.state(),c=b.get("selection");a=new m({controller:this,collection:c,selection:c,model:b,sortable:!0,search:!1,date:!1,dragInfo:!0,AttachmentView:i}).render(),a.toolbar.set("backToLibrary",{text:w.returnToLibrary,priority:-100,click:function(){this.controller.content.mode("browse")}}),this.content.set(a),this.trigger("edit:selection",this)},editImageContent:function(){var a=this.state().get("image"),b=new h({model:a,controller:this}).render();this.content.set(b),b.loadEditor()},selectionStatusToolbar:function(a){var b=this.state().get("editable");a.set("selection",new o({controller:this,collection:this.state().get("selection"),priority:-40,editable:b&&function(){this.controller.content.mode("edit-selection")}}).render())},mainInsertToolbar:function(a){var b=this;this.selectionStatusToolbar(a),a.set("insert",{style:"primary",priority:80,text:w.insertIntoPost,requires:{selection:!0},click:function(){var a=b.state(),c=a.get("selection");b.close(),a.trigger("insert",c).reset()}})},mainGalleryToolbar:function(a){var b=this;this.selectionStatusToolbar(a),a.set("gallery",{style:"primary",text:w.createNewGallery,priority:60,requires:{selection:!0},click:function(){var a=b.state().get("selection"),c=b.state("gallery-edit"),d=a.where({type:"image"});c.set("library",new n(d,{props:a.props.toJSON(),multiple:!0})),this.controller.setState("gallery-edit"),this.controller.modal.focusManager.focus()}})},mainPlaylistToolbar:function(a){var b=this;this.selectionStatusToolbar(a),a.set("playlist",{style:"primary",text:w.createNewPlaylist,priority:100,requires:{selection:!0},click:function(){var a=b.state().get("selection"),c=b.state("playlist-edit"),d=a.where({type:"audio"});c.set("library",new n(d,{props:a.props.toJSON(),multiple:!0})),this.controller.setState("playlist-edit"),this.controller.modal.focusManager.focus()}})},mainVideoPlaylistToolbar:function(a){var b=this;this.selectionStatusToolbar(a),a.set("video-playlist",{style:"primary",text:w.createNewVideoPlaylist,priority:100,requires:{selection:!0},click:function(){var a=b.state().get("selection"),c=b.state("video-playlist-edit"),d=a.where({type:"video"});c.set("library",new n(d,{props:a.props.toJSON(),multiple:!0})),this.controller.setState("video-playlist-edit"),this.controller.modal.focusManager.focus()}})},featuredImageToolbar:function(a){this.createSelectToolbar(a,{text:w.setFeaturedImage,state:this.options.state})},mainEmbedToolbar:function(a){a.view=new k({controller:this})},galleryEditToolbar:function(){var a=this.state().get("editing");this.toolbar.set(new j({controller:this,items:{insert:{style:"primary",text:a?w.updateGallery:w.insertGallery,priority:80,requires:{library:!0},click:function(){var a=this.controller,b=a.state();a.close(),b.trigger("update",b.get("library")),a.setState(a.options.state),a.reset()}}}}))},galleryAddToolbar:function(){this.toolbar.set(new j({controller:this,items:{insert:{style:"primary",text:w.addToGallery,priority:80,requires:{selection:!0},click:function(){var a=this.controller,b=a.state(),c=a.state("gallery-edit");c.get("library").add(b.get("selection").models),b.trigger("reset"),a.setState("gallery-edit")}}}}))},playlistEditToolbar:function(){var a=this.state().get("editing");this.toolbar.set(new j({controller:this,items:{insert:{style:"primary",text:a?w.updatePlaylist:w.insertPlaylist,priority:80,requires:{library:!0},click:function(){var a=this.controller,b=a.state();a.close(),b.trigger("update",b.get("library")),a.setState(a.options.state),a.reset()}}}}))},playlistAddToolbar:function(){this.toolbar.set(new j({controller:this,items:{insert:{style:"primary",text:w.addToPlaylist,priority:80,requires:{selection:!0},click:function(){var a=this.controller,b=a.state(),c=a.state("playlist-edit");c.get("library").add(b.get("selection").models),b.trigger("reset"),a.setState("playlist-edit")}}}}))},videoPlaylistEditToolbar:function(){var a=this.state().get("editing");this.toolbar.set(new j({controller:this,items:{insert:{style:"primary",text:a?w.updateVideoPlaylist:w.insertVideoPlaylist,priority:140,requires:{library:!0},click:function(){var a=this.controller,b=a.state(),c=b.get("library");c.type="video",a.close(),b.trigger("update",c),a.setState(a.options.state),a.reset()}}}}))},videoPlaylistAddToolbar:function(){this.toolbar.set(new j({controller:this,items:{insert:{style:"primary",text:w.addToVideoPlaylist,priority:140,requires:{selection:!0},click:function(){var a=this.controller,b=a.state(),c=a.state("video-playlist-edit");c.get("library").add(b.get("selection").models),b.trigger("reset"),a.setState("video-playlist-edit")}}}}))}}),b.exports=c},{"../../controllers/collection-add.js":1,"../../controllers/collection-edit.js":2,"../../controllers/edit-image.js":4,"../../controllers/embed.js":5,"../../controllers/featured-image.js":6,"../../controllers/gallery-add.js":7,"../../controllers/gallery-edit.js":8,"../../controllers/library.js":10,"../../models/selection.js":20,"../attachment/edit-selection.js":31,"../attachments/browser.js":35,"../edit-image.js":40,"../embed.js":41,"../selection.js":61,"../settings/playlist.js":65,"../toolbar.js":68,"../toolbar/embed.js":69,"../view.js":76,"./select.js":49}],49:[function(a,b){var c,d=a("../media-frame.js"),e=a("../../controllers/library.js"),f=a("../../models/attachments.js"),g=a("../../models/selection.js"),h=a("../attachments/browser.js"),i=a("../uploader/inline.js"),j=a("../toolbar/select.js"),k=wp.media.view.l10n;c=d.extend({initialize:function(){d.prototype.initialize.apply(this,arguments),_.defaults(this.options,{selection:[],library:{},multiple:!1,state:"library"}),this.createSelection(),this.createStates(),this.bindHandlers()},createSelection:function(){var a=this.options.selection;a instanceof g||(this.options.selection=new g(a,{multiple:this.options.multiple})),this._selection={attachments:new f,difference:[]}},createStates:function(){var a=this.options;this.options.states||this.states.add([new e({library:wp.media.query(a.library),multiple:a.multiple,title:a.title,priority:20})])},bindHandlers:function(){this.on("router:create:browse",this.createRouter,this),this.on("router:render:browse",this.browseRouter,this),this.on("content:create:browse",this.browseContent,this),this.on("content:render:upload",this.uploadContent,this),this.on("toolbar:create:select",this.createSelectToolbar,this)},browseRouter:function(a){a.set({upload:{text:k.uploadFilesTitle,priority:20},browse:{text:k.mediaLibraryTitle,priority:40}})},browseContent:function(a){var b=this.state();this.$el.removeClass("hide-toolbar"),a.view=new h({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(b.has("display")?"display":"displaySettings"),dragInfo:b.get("dragInfo"),idealColumnWidth:b.get("idealColumnWidth"),suggestedWidth:b.get("suggestedWidth"),suggestedHeight:b.get("suggestedHeight"),AttachmentView:b.get("AttachmentView")})},uploadContent:function(){this.$el.removeClass("hide-toolbar"),this.content.set(new i({controller:this}))},createSelectToolbar:function(a,b){b=b||this.options.button||{},b.controller=this,a.view=new j(b)}}),b.exports=c},{"../../controllers/library.js":10,"../../models/attachments.js":17,"../../models/selection.js":20,"../attachments/browser.js":35,"../media-frame.js":53,"../toolbar/select.js":70,"../uploader/inline.js":72}],50:[function(a,b){var c,d=a("./view.js");c=d.extend({className:"media-iframe",render:function(){return this.views.detach(),this.$el.html('<iframe src="'+this.controller.state().get("src")+'" />'),this.views.render(),this}}),b.exports=c},{"./view.js":76}],51:[function(a,b){var c,d=a("./settings/attachment-display.js"),e=jQuery;c=d.extend({className:"image-details",template:wp.template("image-details"),events:_.defaults(d.prototype.events,{"click .edit-attachment":"editAttachment","click .replace-attachment":"replaceAttachment","click .advanced-toggle":"onToggleAdvanced",'change [data-setting="customWidth"]':"onCustomSize",'change [data-setting="customHeight"]':"onCustomSize",'keyup [data-setting="customWidth"]':"onCustomSize",'keyup [data-setting="customHeight"]':"onCustomSize"}),initialize:function(){this.options.attachment=this.model.attachment,this.listenTo(this.model,"change:url",this.updateUrl),this.listenTo(this.model,"change:link",this.toggleLinkSettings),this.listenTo(this.model,"change:size",this.toggleCustomSize),d.prototype.initialize.apply(this,arguments)},prepare:function(){var a=!1;return this.model.attachment&&(a=this.model.attachment.toJSON()),_.defaults({model:this.model.toJSON(),attachment:a},this.options)},render:function(){var a=this,b=arguments;return this.model.attachment&&"pending"===this.model.dfd.state()?this.model.dfd.done(function(){d.prototype.render.apply(a,b),a.postRender()}).fail(function(){a.model.attachment=!1,d.prototype.render.apply(a,b),a.postRender()}):(d.prototype.render.apply(this,arguments),this.postRender()),this},postRender:function(){setTimeout(_.bind(this.resetFocus,this),10),this.toggleLinkSettings(),"show"===getUserSetting("advImgDetails")&&this.toggleAdvanced(!0),this.trigger("post-render")},resetFocus:function(){this.$(".link-to-custom").blur(),this.$(".embed-media-settings").scrollTop(0)},updateUrl:function(){this.$(".image img").attr("src",this.model.get("url")),this.$(".url").val(this.model.get("url"))},toggleLinkSettings:function(){"none"===this.model.get("link")?this.$(".link-settings").addClass("hidden"):this.$(".link-settings").removeClass("hidden")},toggleCustomSize:function(){"custom"!==this.model.get("size")?this.$(".custom-size").addClass("hidden"):this.$(".custom-size").removeClass("hidden")},onCustomSize:function(a){var b,c=e(a.target).data("setting"),d=e(a.target).val();return!/^\d+/.test(d)||parseInt(d,10)<1?void a.preventDefault():void("customWidth"===c?(b=Math.round(1/this.model.get("aspectRatio")*d),this.model.set("customHeight",b,{silent:!0}),this.$('[data-setting="customHeight"]').val(b)):(b=Math.round(this.model.get("aspectRatio")*d),this.model.set("customWidth",b,{silent:!0}),this.$('[data-setting="customWidth"]').val(b)))},onToggleAdvanced:function(a){a.preventDefault(),this.toggleAdvanced()},toggleAdvanced:function(a){var b,c=this.$el.find(".advanced-section");c.hasClass("advanced-visible")||a===!1?(c.removeClass("advanced-visible"),c.find(".advanced-settings").addClass("hidden"),b="hide"):(c.addClass("advanced-visible"),c.find(".advanced-settings").removeClass("hidden"),b="show"),setUserSetting("advImgDetails",b)},editAttachment:function(a){var b=this.controller.states.get("edit-image");window.imageEdit&&b&&(a.preventDefault(),b.set("image",this.model.attachment),this.controller.setState("edit-image"))},replaceAttachment:function(a){a.preventDefault(),this.controller.setState("replace-image")}}),b.exports=d},{"./settings/attachment-display.js":63}],52:[function(a,b){var c,d=a("./view.js");c=d.extend({tagName:"label",className:"screen-reader-text",initialize:function(){this.value=this.options.value},render:function(){return this.$el.html(this.value),this}}),b.exports=c},{"./view.js":76}],53:[function(a,b){var c,d=a("./view.js"),e=a("./frame.js"),f=a("./modal.js"),g=a("./uploader/window.js"),h=a("./menu.js"),i=a("./toolbar.js"),j=a("./router.js"),k=a("./iframe.js"),l=jQuery;c=e.extend({className:"media-frame",template:wp.template("media-frame"),regions:["menu","title","content","toolbar","router"],events:{"click div.media-frame-title h1":"toggleMenu"},initialize:function(){e.prototype.initialize.apply(this,arguments),_.defaults(this.options,{title:"",modal:!0,uploader:!0}),this.$el.addClass("wp-core-ui"),this.options.modal&&(this.modal=new f({controller:this,title:this.options.title}),this.modal.content(this)),(wp.Uploader.limitExceeded||!wp.Uploader.browser.supported)&&(this.options.uploader=!1),this.options.uploader&&(this.uploader=new g({controller:this,uploader:{dropzone:this.modal?this.modal.$el:this.$el,container:this.$el}}),this.views.set(".media-frame-uploader",this.uploader)),this.on("attach",_.bind(this.views.ready,this.views),this),this.on("title:create:default",this.createTitle,this),this.title.mode("default"),this.on("title:render",function(a){a.$el.append('<span class="dashicons dashicons-arrow-down"></span>')}),this.on("menu:create:default",this.createMenu,this)},render:function(){return!this.state()&&this.options.state&&this.setState(this.options.state),e.prototype.render.apply(this,arguments)},createTitle:function(a){a.view=new d({controller:this,tagName:"h1"})},createMenu:function(a){a.view=new h({controller:this})},toggleMenu:function(){this.$el.find(".media-menu").toggleClass("visible")},createToolbar:function(a){a.view=new i({controller:this})},createRouter:function(a){a.view=new j({controller:this})},createIframeStates:function(a){var b,c=wp.media.view.settings,d=c.tabs,e=c.tabUrl;d&&e&&(b=l("#post_ID"),b.length&&(e+="&post_id="+b.val()),_.each(d,function(b,c){this.state("iframe:"+c).set(_.defaults({tab:c,src:e+"&tab="+c,title:b,content:"iframe",menu:"default"},a))},this),this.on("content:create:iframe",this.iframeContent,this),this.on("content:deactivate:iframe",this.iframeContentCleanup,this),this.on("menu:render:default",this.iframeMenu,this),this.on("open",this.hijackThickbox,this),this.on("close",this.restoreThickbox,this))},iframeContent:function(a){this.$el.addClass("hide-toolbar"),a.view=new k({controller:this})},iframeContentCleanup:function(){this.$el.removeClass("hide-toolbar")},iframeMenu:function(a){var b={};a&&(_.each(wp.media.view.settings.tabs,function(a,c){b["iframe:"+c]={text:this.state("iframe:"+c).get("title"),priority:200}},this),a.set(b))},hijackThickbox:function(){var a=this;window.tb_remove&&!this._tb_remove&&(this._tb_remove=window.tb_remove,window.tb_remove=function(){a.close(),a.reset(),a.setState(a.options.state),a._tb_remove.call(window)})},restoreThickbox:function(){this._tb_remove&&(window.tb_remove=this._tb_remove,delete this._tb_remove)}}),_.each(["open","close","attach","detach","escape"],function(a){c.prototype[a]=function(){return this.modal&&this.modal[a].apply(this.modal,arguments),this}}),b.exports=c},{"./frame.js":46,"./iframe.js":50,"./menu.js":55,"./modal.js":56,"./router.js":59,"./toolbar.js":68,"./uploader/window.js":75,"./view.js":76}],54:[function(a,b){var c,d=a("./view.js"),e=jQuery;c=d.extend({tagName:"a",className:"media-menu-item",attributes:{href:"#"},events:{click:"_click"},_click:function(a){var b=this.options.click;a&&a.preventDefault(),b?b.call(this):this.click(),wp.media.isTouchDevice||e(".media-frame-content input").first().focus()},click:function(){var a=this.options.state;a&&(this.controller.setState(a),this.views.parent.$el.removeClass("visible"))},render:function(){var a=this.options;return a.text?this.$el.text(a.text):a.html&&this.$el.html(a.html),this}}),b.exports=c},{"./view.js":76}],55:[function(a,b){var c,d=a("./menu-item.js"),e=a("./priority-list.js");c=e.extend({tagName:"div",className:"media-menu",property:"state",ItemView:d,region:"menu",toView:function(a,b){return a=a||{},a[this.property]=a[this.property]||b,new this.ItemView(a).render()},ready:function(){e.prototype.ready.apply(this,arguments),this.visibility()},set:function(){e.prototype.set.apply(this,arguments),this.visibility()},unset:function(){e.prototype.unset.apply(this,arguments),this.visibility()},visibility:function(){var a=this.region,b=this.controller[a].get(),c=this.views.get(),d=!c||c.length<2;this===b&&this.controller.$el.toggleClass("hide-"+a,d)},select:function(a){var b=this.get(a);b&&(this.deselect(),b.$el.addClass("active"))},deselect:function(){this.$el.children().removeClass("active")},hide:function(a){var b=this.get(a);b&&b.$el.addClass("hidden")},show:function(a){var b=this.get(a);b&&b.$el.removeClass("hidden")}}),b.exports=c},{"./menu-item.js":54,"./priority-list.js":57}],56:[function(a,b){var c,d=a("./view.js"),e=a("./focus-manager.js"),f=jQuery;c=d.extend({tagName:"div",template:wp.template("media-modal"),attributes:{tabindex:0},events:{"click .media-modal-backdrop, .media-modal-close":"escapeHandler",keydown:"keydown"},initialize:function(){_.defaults(this.options,{container:document.body,title:"",propagate:!0,freeze:!0}),this.focusManager=new e({el:this.el})},prepare:function(){return{title:this.options.title}},attach:function(){return this.views.attached?this:(this.views.rendered||this.render(),this.$el.appendTo(this.options.container),this.views.attached=!0,this.views.ready(),this.propagate("attach"))},detach:function(){return this.$el.is(":visible")&&this.close(),this.$el.detach(),this.views.attached=!1,this.propagate("detach")},open:function(){var a,b=this.$el,c=this.options;return b.is(":visible")?this:(this.views.attached||this.attach(),c.freeze&&(this._freeze={scrollTop:f(window).scrollTop()}),f("body").addClass("modal-open"),b.show(),"ontouchend"in document&&(a=window.tinymce&&window.tinymce.activeEditor)&&!a.isHidden()&&a.iframeElement&&(a.iframeElement.focus(),a.iframeElement.blur(),setTimeout(function(){a.iframeElement.blur()},100)),this.$el.focus(),this.propagate("open"))},close:function(a){var b=this._freeze;return this.views.attached&&this.$el.is(":visible")?(f("body").removeClass("modal-open"),this.$el.hide().undelegate("keydown"),f("#wpbody-content").focus(),this.propagate("close"),b&&f(window).scrollTop(b.scrollTop),a&&a.escape&&this.propagate("escape"),this):this},escape:function(){return this.close({escape:!0})},escapeHandler:function(a){a.preventDefault(),this.escape()},content:function(a){return this.views.set(".media-modal-content",a),this},propagate:function(a){return this.trigger(a),this.options.propagate&&this.controller.trigger(a),this},keydown:function(a){27===a.which&&this.$el.is(":visible")&&(this.escape(),a.stopImmediatePropagation())}}),b.exports=c},{"./focus-manager.js":45,"./view.js":76}],57:[function(a,b){var c,d=a("./view.js");c=d.extend({tagName:"div",initialize:function(){this._views={},this.set(_.extend({},this._views,this.options.views),{silent:!0}),delete this.options.views,this.options.silent||this.render()},set:function(a,b,c){var d,e,f;return c=c||{},_.isObject(a)?(_.each(a,function(a,b){this.set(b,a)},this),this):(b instanceof Backbone.View||(b=this.toView(b,a,c)),b.controller=b.controller||this.controller,this.unset(a),d=b.options.priority||10,e=this.views.get()||[],_.find(e,function(a,b){return a.options.priority>d?(f=b,!0):void 0}),this._views[a]=b,this.views.add(b,{at:_.isNumber(f)?f:e.length||0}),this)},get:function(a){return this._views[a]},unset:function(a){var b=this.get(a);return b&&b.remove(),delete this._views[a],this},toView:function(a){return new d(a)}}),b.exports=c},{"./view.js":76}],58:[function(a,b){var c,d=a("./menu-item.js");c=d.extend({click:function(){var a=this.options.contentMode;a&&this.controller.content.mode(a)}}),b.exports=c},{"./menu-item.js":54}],59:[function(a,b){var c,d=a("./menu.js"),e=a("./router-item.js");c=d.extend({tagName:"div",className:"media-router",property:"contentMode",ItemView:e,region:"router",initialize:function(){this.controller.on("content:render",this.update,this),d.prototype.initialize.apply(this,arguments)},update:function(){var a=this.controller.content.mode();a&&this.select(a)}}),b.exports=c},{"./menu.js":55,"./router-item.js":58}],60:[function(a,b){var c,d=a("./view.js"),e=wp.media.view.l10n;c=d.extend({tagName:"input",className:"search",id:"media-search-input",attributes:{type:"search",placeholder:e.search},events:{input:"search",keyup:"search",change:"search",search:"search"},render:function(){return this.el.value=this.model.escape("search"),this},search:function(a){a.target.value?this.model.set("search",a.target.value):this.model.unset("search")
}}),b.exports=c},{"./view.js":76}],61:[function(a,b){var c,d=a("./view.js"),e=a("./attachments/selection.js"),f=wp.media.view.l10n;c=d.extend({tagName:"div",className:"media-selection",template:wp.template("media-selection"),events:{"click .edit-selection":"edit","click .clear-selection":"clear"},initialize:function(){_.defaults(this.options,{editable:!1,clearable:!0}),this.attachments=new e({controller:this.controller,collection:this.collection,selection:this.collection,model:new Backbone.Model}),this.views.set(".selection-view",this.attachments),this.collection.on("add remove reset",this.refresh,this),this.controller.on("content:activate",this.refresh,this)},ready:function(){this.refresh()},refresh:function(){if(this.$el.children().length){var a=this.collection,b="edit-selection"===this.controller.content.mode();this.$el.toggleClass("empty",!a.length),this.$el.toggleClass("one",1===a.length),this.$el.toggleClass("editing",b),this.$(".count").text(f.selected.replace("%d",a.length))}},edit:function(a){a.preventDefault(),this.options.editable&&this.options.editable.call(this,this.collection)},clear:function(a){a.preventDefault(),this.collection.reset(),this.controller.modal.focusManager.focus()}}),b.exports=c},{"./attachments/selection.js":36,"./view.js":76}],62:[function(a,b){var c,d=a("./view.js"),e=jQuery;c=d.extend({events:{"click button":"updateHandler","change input":"updateHandler","change select":"updateHandler","change textarea":"updateHandler"},initialize:function(){this.model=this.model||new Backbone.Model,this.listenTo(this.model,"change",this.updateChanges)},prepare:function(){return _.defaults({model:this.model.toJSON()},this.options)},render:function(){return d.prototype.render.apply(this,arguments),_(this.model.attributes).chain().keys().each(this.update,this),this},update:function(a){var b,c,d=this.model.get(a),e=this.$('[data-setting="'+a+'"]');e.length&&(e.is("select")?(c=e.find('[value="'+d+'"]'),c.length?(e.find("option").prop("selected",!1),c.prop("selected",!0)):this.model.set(a,e.find(":selected").val())):e.hasClass("button-group")?(b=e.find("button").removeClass("active"),b.filter('[value="'+d+'"]').addClass("active")):e.is('input[type="text"], textarea')?e.is(":focus")||e.val(d):e.is('input[type="checkbox"]')&&e.prop("checked",!!d&&"false"!==d))},updateHandler:function(a){var b,c=e(a.target).closest("[data-setting]"),d=a.target.value;a.preventDefault(),c.length&&(c.is('input[type="checkbox"]')&&(d=c[0].checked),this.model.set(c.data("setting"),d),(b=c.data("userSetting"))&&setUserSetting(b,d))},updateChanges:function(a){a.hasChanged()&&_(a.changed).chain().keys().each(this.update,this)}}),b.exports=c},{"./view.js":76}],63:[function(a,b){var c,d=a("../settings.js");c=d.extend({className:"attachment-display-settings",template:wp.template("attachment-display-settings"),initialize:function(){var a=this.options.attachment;_.defaults(this.options,{userSettings:!1}),d.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"change:link",this.updateLinkTo),a&&a.on("change:uploading",this.render,this)},dispose:function(){var a=this.options.attachment;a&&a.off(null,null,this),d.prototype.dispose.apply(this,arguments)},render:function(){var a=this.options.attachment;return a&&_.extend(this.options,{sizes:a.get("sizes"),type:a.get("type")}),d.prototype.render.call(this),this.updateLinkTo(),this},updateLinkTo:function(){var a=this.model.get("link"),b=this.$(".link-to-custom"),c=this.options.attachment;return"none"===a||"embed"===a||!c&&"custom"!==a?void b.addClass("hidden"):(c&&("post"===a?b.val(c.get("link")):"file"===a?b.val(c.get("url")):this.model.get("linkUrl")||b.val("http://"),b.prop("readonly","custom"!==a)),b.removeClass("hidden"),void(!wp.media.isTouchDevice&&b.is(":visible")&&b.focus()[0].select()))}}),b.exports=c},{"../settings.js":62}],64:[function(a,b){var c,d=a("../settings.js");c=d.extend({className:"collection-settings gallery-settings",template:wp.template("gallery-settings")}),b.exports=c},{"../settings.js":62}],65:[function(a,b){var c,d=a("../settings.js");c=d.extend({className:"collection-settings playlist-settings",template:wp.template("playlist-settings")}),b.exports=c},{"../settings.js":62}],66:[function(a,b){var c,d=a("./priority-list.js");c=d.extend({className:"media-sidebar"}),b.exports=c},{"./priority-list.js":57}],67:[function(a,b){var c,d=a("./view.js");c=d.extend({tagName:"span",className:"spinner",spinnerTimeout:!1,delay:400,show:function(){return this.spinnerTimeout||(this.spinnerTimeout=_.delay(function(a){a.show()},this.delay,this.$el)),this},hide:function(){return this.$el.hide(),this.spinnerTimeout=clearTimeout(this.spinnerTimeout),this}}),b.exports=c},{"./view.js":76}],68:[function(a,b){var c,d=a("./view.js"),e=a("./button.js"),f=a("./priority-list.js");c=d.extend({tagName:"div",className:"media-toolbar",initialize:function(){var a=this.controller.state(),b=this.selection=a.get("selection"),c=this.library=a.get("library");this._views={},this.primary=new f,this.secondary=new f,this.primary.$el.addClass("media-toolbar-primary search-form"),this.secondary.$el.addClass("media-toolbar-secondary"),this.views.set([this.secondary,this.primary]),this.options.items&&this.set(this.options.items,{silent:!0}),this.options.silent||this.render(),b&&b.on("add remove reset",this.refresh,this),c&&c.on("add remove reset",this.refresh,this)},dispose:function(){return this.selection&&this.selection.off(null,null,this),this.library&&this.library.off(null,null,this),d.prototype.dispose.apply(this,arguments)},ready:function(){this.refresh()},set:function(a,b,c){var d;return c=c||{},_.isObject(a)?_.each(a,function(a,b){this.set(b,a,{silent:!0})},this):(b instanceof Backbone.View||(b.classes=["media-button-"+a].concat(b.classes||[]),b=new e(b).render()),b.controller=b.controller||this.controller,this._views[a]=b,d=b.options.priority<0?"secondary":"primary",this[d].set(a,b,c)),c.silent||this.refresh(),this},get:function(a){return this._views[a]},unset:function(a,b){return delete this._views[a],this.primary.unset(a,b),this.secondary.unset(a,b),b&&b.silent||this.refresh(),this},refresh:function(){var a=this.controller.state(),b=a.get("library"),c=a.get("selection");_.each(this._views,function(a){if(a.model&&a.options&&a.options.requires){var d=a.options.requires,e=!1;e=_.some(c.models,function(a){return a.get("uploading")===!0}),d.selection&&c&&!c.length?e=!0:d.library&&b&&!b.length&&(e=!0),a.model.set("disabled",e)}})}}),b.exports=c},{"./button.js":38,"./priority-list.js":57,"./view.js":76}],69:[function(a,b){var c,d=a("./select.js"),e=wp.media.view.l10n;c=d.extend({initialize:function(){_.defaults(this.options,{text:e.insertIntoPost,requires:!1}),d.prototype.initialize.apply(this,arguments)},refresh:function(){var a=this.controller.state().props.get("url");this.get("select").model.set("disabled",!a||"http://"===a),d.prototype.refresh.apply(this,arguments)}}),b.exports=c},{"./select.js":70}],70:[function(a,b){var c,d=a("../toolbar.js"),e=wp.media.view.l10n;c=d.extend({initialize:function(){var a=this.options;_.bindAll(this,"clickSelect"),_.defaults(a,{event:"select",state:!1,reset:!0,close:!0,text:e.select,requires:{selection:!0}}),a.items=_.defaults(a.items||{},{select:{style:"primary",text:a.text,priority:80,click:this.clickSelect,requires:a.requires}}),d.prototype.initialize.apply(this,arguments)},clickSelect:function(){var a=this.options,b=this.controller;a.close&&b.close(),a.event&&b.state().trigger(a.event),a.state&&b.setState(a.state),a.reset&&b.reset()}}),b.exports=c},{"../toolbar.js":68}],71:[function(a,b){var c,d=a("../view.js"),e=wp.media.view.l10n,f=jQuery;c=d.extend({tagName:"div",className:"uploader-editor",template:wp.template("uploader-editor"),localDrag:!1,overContainer:!1,overDropzone:!1,draggingFile:null,initialize:function(){var a=this;return this.initialized=!1,window.tinyMCEPreInit&&window.tinyMCEPreInit.dragDropUpload&&this.browserSupport()?(this.$document=f(document),this.dropzones=[],this.files=[],this.$document.on("drop",".uploader-editor",_.bind(this.drop,this)),this.$document.on("dragover",".uploader-editor",_.bind(this.dropzoneDragover,this)),this.$document.on("dragleave",".uploader-editor",_.bind(this.dropzoneDragleave,this)),this.$document.on("click",".uploader-editor",_.bind(this.click,this)),this.$document.on("dragover",_.bind(this.containerDragover,this)),this.$document.on("dragleave",_.bind(this.containerDragleave,this)),this.$document.on("dragstart dragend drop",function(b){a.localDrag="dragstart"===b.type}),this.initialized=!0,this):this},browserSupport:function(){var a=!1,b=document.createElement("div");return a="draggable"in b||"ondragstart"in b&&"ondrop"in b,a=a&&!!(window.File&&window.FileList&&window.FileReader)},isDraggingFile:function(a){return null!==this.draggingFile?this.draggingFile:_.isUndefined(a.originalEvent)||_.isUndefined(a.originalEvent.dataTransfer)?!1:(this.draggingFile=_.indexOf(a.originalEvent.dataTransfer.types,"Files")>-1&&-1===_.indexOf(a.originalEvent.dataTransfer.types,"text/plain"),this.draggingFile)},refresh:function(a){var b;for(b in this.dropzones)this.dropzones[b].toggle(this.overContainer||this.overDropzone);return _.isUndefined(a)||f(a.target).closest(".uploader-editor").toggleClass("droppable",this.overDropzone),this.overContainer||this.overDropzone||(this.draggingFile=null),this},render:function(){return this.initialized?(d.prototype.render.apply(this,arguments),f(".wp-editor-wrap, #wp-fullscreen-body").each(_.bind(this.attach,this)),this):this},attach:function(a,b){var c=this.$el.clone();return this.dropzones.push(c),f(b).append(c),this},drop:function(a){var b,c=null;return this.containerDragleave(a),this.dropzoneDragleave(a),this.files=a.originalEvent.dataTransfer.files,this.files.length<1?void 0:(c=f(a.target).parents(".wp-editor-wrap"),c.length>0&&c[0].id&&(window.wpActiveEditor=c[0].id.slice(3,-5)),this.workflow?(this.workflow.state().reset(),this.addFiles.apply(this),this.workflow.open()):(this.workflow=wp.media.editor.open("content",{frame:"post",state:"insert",title:e.addMedia,multiple:!0}),b=this.workflow.uploader,b.uploader&&b.uploader.ready?this.addFiles.apply(this):this.workflow.on("uploader:ready",this.addFiles,this)),!1)},addFiles:function(){return this.files.length&&(this.workflow.uploader.uploader.uploader.addFile(_.toArray(this.files)),this.files=[]),this},containerDragover:function(a){!this.localDrag&&this.isDraggingFile(a)&&(this.overContainer=!0,this.refresh())},containerDragleave:function(){this.overContainer=!1,_.delay(_.bind(this.refresh,this),50)},dropzoneDragover:function(a){return!this.localDrag&&this.isDraggingFile(a)?(this.overDropzone=!0,this.refresh(a),!1):void 0},dropzoneDragleave:function(a){this.overDropzone=!1,_.delay(_.bind(this.refresh,this,a),50)},click:function(a){this.containerDragleave(a),this.dropzoneDragleave(a),this.localDrag=!1}}),b.exports=c},{"../view.js":76}],72:[function(a,b){var c,d=a("../view.js"),e=a("./status.js");c=d.extend({tagName:"div",className:"uploader-inline",template:wp.template("uploader-inline"),events:{"click .close":"hide"},initialize:function(){_.defaults(this.options,{message:"",status:!0,canClose:!1}),!this.options.$browser&&this.controller.uploader&&(this.options.$browser=this.controller.uploader.$browser),_.isUndefined(this.options.postId)&&(this.options.postId=wp.media.view.settings.post.id),this.options.status&&this.views.set(".upload-inline-status",new e({controller:this.controller}))},prepare:function(){var a=this.controller.state().get("suggestedWidth"),b=this.controller.state().get("suggestedHeight"),c={};return c.message=this.options.message,c.canClose=this.options.canClose,a&&b&&(c.suggestedWidth=a,c.suggestedHeight=b),c},dispose:function(){return this.disposing?d.prototype.dispose.apply(this,arguments):(this.disposing=!0,this.remove())},remove:function(){var a=d.prototype.remove.apply(this,arguments);return _.defer(_.bind(this.refresh,this)),a},refresh:function(){var a=this.controller.uploader;a&&a.refresh()},ready:function(){var a,b=this.options.$browser;if(this.controller.uploader){if(a=this.$(".browser"),a[0]===b[0])return;b.detach().text(a.text()),b[0].className=a[0].className,a.replaceWith(b.show())}return this.refresh(),this},show:function(){this.$el.removeClass("hidden")},hide:function(){this.$el.addClass("hidden")}}),b.exports=c},{"../view.js":76,"./status.js":74}],73:[function(a,b){var c,d=a("../view.js");c=d.extend({className:"upload-error",template:wp.template("uploader-status-error")}),b.exports=c},{"../view.js":76}],74:[function(a,b){var c,d=a("../view.js"),e=a("./status-error.js");c=d.extend({className:"media-uploader-status",template:wp.template("uploader-status"),events:{"click .upload-dismiss-errors":"dismiss"},initialize:function(){this.queue=wp.Uploader.queue,this.queue.on("add remove reset",this.visibility,this),this.queue.on("add remove reset change:percent",this.progress,this),this.queue.on("add remove reset change:uploading",this.info,this),this.errors=wp.Uploader.errors,this.errors.reset(),this.errors.on("add remove reset",this.visibility,this),this.errors.on("add",this.error,this)},dispose:function(){return wp.Uploader.queue.off(null,null,this),d.prototype.dispose.apply(this,arguments),this},visibility:function(){this.$el.toggleClass("uploading",!!this.queue.length),this.$el.toggleClass("errors",!!this.errors.length),this.$el.toggle(!!this.queue.length||!!this.errors.length)},ready:function(){_.each({$bar:".media-progress-bar div",$index:".upload-index",$total:".upload-total",$filename:".upload-filename"},function(a,b){this[b]=this.$(a)},this),this.visibility(),this.progress(),this.info()},progress:function(){var a=this.queue,b=this.$bar;b&&a.length&&b.width(a.reduce(function(a,b){if(!b.get("uploading"))return a+100;var c=b.get("percent");return a+(_.isNumber(c)?c:100)},0)/a.length+"%")},info:function(){var a,b=this.queue,c=0;b.length&&(a=this.queue.find(function(a,b){return c=b,a.get("uploading")}),this.$index.text(c+1),this.$total.text(b.length),this.$filename.html(a?this.filename(a.get("filename")):""))},filename:function(a){return wp.media.truncate(_.escape(a),24)},error:function(a){this.views.add(".upload-errors",new e({filename:this.filename(a.get("file").name),message:a.get("message")}),{at:0})},dismiss:function(a){var b=this.views.get(".upload-errors");a.preventDefault(),b&&_.invoke(b,"remove"),wp.Uploader.errors.reset()}}),b.exports=c},{"../view.js":76,"./status-error.js":73}],75:[function(a,b){var c,d=a("../view.js"),e=jQuery;c=d.extend({tagName:"div",className:"uploader-window",template:wp.template("uploader-window"),initialize:function(){var a;this.$browser=e('<a href="#" class="browser" />').hide().appendTo("body"),a=this.options.uploader=_.defaults(this.options.uploader||{},{dropzone:this.$el,browser:this.$browser,params:{}}),!a.dropzone||a.dropzone instanceof e||(a.dropzone=e(a.dropzone)),this.controller.on("activate",this.refresh,this),this.controller.on("detach",function(){this.$browser.remove()},this)},refresh:function(){this.uploader&&this.uploader.refresh()},ready:function(){var a,b=wp.media.view.settings.post.id;this.uploader||(b&&(this.options.uploader.params.post_id=b),this.uploader=new wp.Uploader(this.options.uploader),a=this.uploader.dropzone,a.on("dropzone:enter",_.bind(this.show,this)),a.on("dropzone:leave",_.bind(this.hide,this)),e(this.uploader).on("uploader:ready",_.bind(this._ready,this)))},_ready:function(){this.controller.trigger("uploader:ready")},show:function(){var a=this.$el.show();_.defer(function(){a.css({opacity:1})})},hide:function(){var a=this.$el.css({opacity:0});wp.media.transition(a).done(function(){"0"===a.css("opacity")&&a.hide()}),_.delay(function(){"0"===a.css("opacity")&&a.is(":visible")&&a.hide()},500)}}),b.exports=c},{"../view.js":76}],76:[function(a,b){var c=wp.Backbone.View.extend({constructor:function(a){a&&a.controller&&(this.controller=a.controller),wp.Backbone.View.apply(this,arguments)},dispose:function(){return this.undelegateEvents(),this.model&&this.model.off&&this.model.off(null,null,this),this.collection&&this.collection.off&&this.collection.off(null,null,this),this.controller&&this.controller.off&&this.controller.off(null,null,this),this},remove:function(){return this.dispose(),wp.Backbone.View.prototype.remove.apply(this,arguments)}});b.exports=c},{}]},{},[22]);