From b191013198607369d22070761a63c9a15e34ca7f Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Mon, 9 Feb 2015 16:01:29 +0000 Subject: [PATCH] Media JS files: * In media manifests, ditch IIFEs and global injection, these get dynamically scoped via Browserify * Remove the `debug` option from `browserify:media` * Add `jshint:media` to `jshint:corejs` * Add a trailing newline to all new module files Props iseulde. See #28510. Built from https://develop.svn.wordpress.org/trunk@31385 git-svn-id: http://core.svn.wordpress.org/trunk@31366 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/js/media/audio-video.js | 566 ++++++++---------- wp-includes/js/media/audio-video.manifest.js | 413 +++++++------ wp-includes/js/media/audio-video.min.js | 4 +- .../js/media/controllers/audio-details.js | 4 +- .../js/media/controllers/collection-add.js | 4 +- .../js/media/controllers/collection-edit.js | 4 +- wp-includes/js/media/controllers/cropper.js | 6 +- .../controllers/edit-attachment-metadata.js | 4 +- .../js/media/controllers/edit-image.js | 4 +- wp-includes/js/media/controllers/embed.js | 4 +- .../js/media/controllers/featured-image.js | 4 +- .../js/media/controllers/gallery-add.js | 10 +- .../js/media/controllers/gallery-edit.js | 11 +- .../js/media/controllers/image-details.js | 4 +- wp-includes/js/media/controllers/library.js | 8 +- .../js/media/controllers/media-library.js | 4 +- wp-includes/js/media/controllers/region.js | 4 +- .../js/media/controllers/replace-image.js | 4 +- .../js/media/controllers/state-machine.js | 4 +- wp-includes/js/media/controllers/state.js | 4 +- .../js/media/controllers/video-details.js | 4 +- wp-includes/js/media/grid.js | 177 +++--- wp-includes/js/media/grid.manifest.js | 24 +- wp-includes/js/media/grid.min.js | 4 +- wp-includes/js/media/models.js | 448 +++++++------- wp-includes/js/media/models.manifest.js | 429 +++++++------ wp-includes/js/media/models.min.js | 2 +- wp-includes/js/media/models/attachment.js | 6 +- wp-includes/js/media/models/attachments.js | 7 +- wp-includes/js/media/models/post-image.js | 4 +- wp-includes/js/media/models/post-media.js | 4 +- wp-includes/js/media/models/query.js | 4 +- wp-includes/js/media/models/selection.js | 4 +- wp-includes/js/media/routers/manage.js | 4 +- wp-includes/js/media/utils/selection-sync.js | 4 +- wp-includes/js/media/views.js | 483 +++++++-------- wp-includes/js/media/views.manifest.js | 259 ++++---- wp-includes/js/media/views.min.js | 6 +- .../js/media/views/attachment-compat.js | 4 +- .../js/media/views/attachment-filters.js | 4 +- .../js/media/views/attachment-filters/all.js | 4 +- .../js/media/views/attachment-filters/date.js | 4 +- .../views/attachment-filters/uploaded.js | 4 +- wp-includes/js/media/views/attachment.js | 4 +- .../views/attachment/details-two-column.js | 6 +- .../js/media/views/attachment/details.js | 6 +- .../js/media/views/attachment/edit-library.js | 2 +- .../media/views/attachment/edit-selection.js | 2 +- .../js/media/views/attachment/library.js | 2 +- .../js/media/views/attachment/selection.js | 2 +- wp-includes/js/media/views/attachments.js | 6 +- .../js/media/views/attachments/browser.js | 10 +- .../js/media/views/attachments/selection.js | 4 +- wp-includes/js/media/views/audio-details.js | 4 +- wp-includes/js/media/views/button-group.js | 4 +- wp-includes/js/media/views/button.js | 4 +- .../button/delete-selected-permanently.js | 2 +- .../js/media/views/button/delete-selected.js | 4 +- .../media/views/button/select-mode-toggle.js | 4 +- wp-includes/js/media/views/cropper.js | 6 +- .../js/media/views/edit-image-details.js | 2 +- wp-includes/js/media/views/edit-image.js | 4 +- wp-includes/js/media/views/embed.js | 2 +- wp-includes/js/media/views/embed/image.js | 4 +- wp-includes/js/media/views/embed/link.js | 4 +- wp-includes/js/media/views/embed/url.js | 4 +- wp-includes/js/media/views/focus-manager.js | 2 +- wp-includes/js/media/views/frame.js | 4 +- .../js/media/views/frame/audio-details.js | 4 +- .../js/media/views/frame/edit-attachments.js | 4 +- .../js/media/views/frame/image-details.js | 4 +- wp-includes/js/media/views/frame/manage.js | 6 +- .../js/media/views/frame/media-details.js | 4 +- wp-includes/js/media/views/frame/post.js | 4 +- wp-includes/js/media/views/frame/select.js | 4 +- .../js/media/views/frame/video-details.js | 4 +- wp-includes/js/media/views/iframe.js | 2 +- wp-includes/js/media/views/image-details.js | 8 +- wp-includes/js/media/views/label.js | 2 +- wp-includes/js/media/views/media-details.js | 8 +- wp-includes/js/media/views/media-frame.js | 4 +- wp-includes/js/media/views/menu-item.js | 4 +- wp-includes/js/media/views/menu.js | 2 +- wp-includes/js/media/views/modal.js | 4 +- wp-includes/js/media/views/priority-list.js | 4 +- wp-includes/js/media/views/router-item.js | 2 +- wp-includes/js/media/views/router.js | 2 +- wp-includes/js/media/views/search.js | 4 +- wp-includes/js/media/views/selection.js | 4 +- wp-includes/js/media/views/settings.js | 6 +- .../views/settings/attachment-display.js | 4 +- .../js/media/views/settings/gallery.js | 4 +- .../js/media/views/settings/playlist.js | 4 +- wp-includes/js/media/views/sidebar.js | 2 +- wp-includes/js/media/views/spinner.js | 4 +- wp-includes/js/media/views/toolbar.js | 4 +- wp-includes/js/media/views/toolbar/embed.js | 4 +- wp-includes/js/media/views/toolbar/select.js | 4 +- wp-includes/js/media/views/uploader/editor.js | 4 +- wp-includes/js/media/views/uploader/inline.js | 4 +- .../js/media/views/uploader/status-error.js | 4 +- wp-includes/js/media/views/uploader/status.js | 4 +- wp-includes/js/media/views/uploader/window.js | 4 +- wp-includes/js/media/views/video-details.js | 4 +- wp-includes/js/media/views/view.js | 4 +- wp-includes/version.php | 2 +- 106 files changed, 1462 insertions(+), 1749 deletions(-) diff --git a/wp-includes/js/media/audio-video.js b/wp-includes/js/media/audio-video.js index ca4ef75f91..2e0b287db5 100644 --- a/wp-includes/js/media/audio-video.js +++ b/wp-includes/js/media/audio-video.js @@ -1,231 +1,221 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o").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":51}],13:[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":12}],14:[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":12}],15:[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":12}],16:[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":51}],17:[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":16}],18:[function(a,b){var c,d=a("../attachment.js");c=d.extend({buttons:{check:!0}}),b.exports=c},{"../attachment.js":16}],19:[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)'+u.dragInfo+"")[0],priority:-40})),this.options.suggestedWidth&&this.options.suggestedHeight&&this.toolbar.set("suggestedDimensions",new d({el:v('
'+u.suggestedDimensions+" "+this.options.suggestedWidth+" × "+this.options.suggestedHeight+"
")[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":11,"../attachment-filters/all.js":13,"../attachment-filters/date.js":14,"../attachment-filters/uploaded.js":15,"../attachment/details.js":17,"../attachment/library.js":18,"../attachments.js":19,"../label.js":30,"../search.js":39,"../settings/attachment-display.js":41,"../sidebar.js":42,"../spinner.js":43,"../toolbar.js":44,"../uploader/inline.js":46,"../uploader/status.js":48,"../view.js":51}],21:[function(a,b){var c,d=a("./media-details");c=d.extend({className:"audio-details",template:wp.template("audio-details"),setMedia:function(){var a=this.$(".wp-audio-shortcode");return a.find("source").length?(a.is(":hidden")&&a.show(),this.media=d.prepareSrc(a.get(0))):(a.hide(),this.media=!1),this}}),b.exports=c},{"./media-details":31}],22:[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":51}],23:[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":51}],24:[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":5,"../controllers/state-machine.js":6,"../controllers/state.js":7,"./view.js":51}],25:[function(a,b){var c,d=a("./media-details"),e=a("../../controllers/media-library.js"),f=a("../audio-details.js"),g=a("../../controllers/audio-details.js"),h=wp.media.view.l10n;c=d.extend({defaults:{id:"audio",url:"",menu:"audio-details",content:"audio-details",toolbar:"audio-details",type:"link",title:h.audioDetailsTitle,priority:120},initialize:function(a){a.DetailsView=f,a.cancelText=h.audioDetailsCancel,a.addText=h.audioAddSourceTitle,d.prototype.initialize.call(this,a)},bindHandlers:function(){d.prototype.bindHandlers.apply(this,arguments),this.on("toolbar:render:replace-audio",this.renderReplaceToolbar,this),this.on("toolbar:render:add-audio-source",this.renderAddSourceToolbar,this)},createStates:function(){this.states.add([new g({media:this.media}),new e({type:"audio",id:"replace-audio",title:h.audioReplaceTitle,toolbar:"replace-audio",media:this.media,menu:"audio-details"}),new e({type:"audio",id:"add-audio-source",title:h.audioAddSourceTitle,toolbar:"add-audio-source",media:this.media,menu:!1})])}}),b.exports=c},{"../../controllers/audio-details.js":2,"../../controllers/media-library.js":4,"../audio-details.js":21,"./media-details":26}],26:[function(a,b){var c,d=a("../view.js"),e=a("../toolbar.js"),f=a("./select.js"),g=wp.media.view.l10n;c=f.extend({defaults:{id:"media",url:"",menu:"media-details",content:"media-details",toolbar:"media-details",type:"link",priority:120},initialize:function(a){this.DetailsView=a.DetailsView,this.cancelText=a.cancelText,this.addText=a.addText,this.media=new wp.media.model.PostMedia(a.metadata),this.options.selection=new wp.media.model.Selection(this.media.attachment,{multiple:!1}),f.prototype.initialize.apply(this,arguments)},bindHandlers:function(){var a=this.defaults.menu;f.prototype.bindHandlers.apply(this,arguments),this.on("menu:create:"+a,this.createMenu,this),this.on("content:render:"+a,this.renderDetailsContent,this),this.on("menu:render:"+a,this.renderMenu,this),this.on("toolbar:render:"+a,this.renderDetailsToolbar,this)},renderDetailsContent:function(){var a=new this.DetailsView({controller:this,model:this.state().media,attachment:this.state().media.attachment}).render();this.content.set(a)},renderMenu:function(a){var b=this.lastState(),c=b&&b.id,e=this;a.set({cancel:{text:this.cancelText,priority:20,click:function(){c?e.setState(c):e.close()}},separateCancel:new d({className:"separator",priority:40})})},setPrimaryButton:function(a,b){this.toolbar.set(new e({controller:this,items:{button:{style:"primary",text:a,priority:80,click:function(){var a=this.controller;b.call(this,a,a.state()),a.setState(a.options.state),a.reset()}}}}))},renderDetailsToolbar:function(){this.setPrimaryButton(g.update,function(a,b){a.close(),b.trigger("update",a.media.toJSON())})},renderReplaceToolbar:function(){this.setPrimaryButton(g.replace,function(a,b){var c=b.get("selection").single();a.media.changeAttachment(c),b.trigger("replace",a.media.toJSON())})},renderAddSourceToolbar:function(){this.setPrimaryButton(this.addText,function(a,b){var c=b.get("selection").single();a.media.setSource(c),b.trigger("add-source",a.media.toJSON())})}}),b.exports=c},{"../toolbar.js":44,"../view.js":51,"./select.js":27}],27:[function(a,b){var c,d=a("../media-frame.js"),e=a("../../controllers/library.js"),f=a("../attachments/browser.js"),g=a("../uploader/inline.js"),h=a("../toolbar/select.js"),i=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 wp.media.model.Selection||(this.options.selection=new wp.media.model.Selection(a,{multiple:this.options.multiple})),this._selection={attachments:new wp.media.model.Attachments,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:i.uploadFilesTitle,priority:20},browse:{text:i.mediaLibraryTitle,priority:40}})},browseContent:function(a){var b=this.state();this.$el.removeClass("hide-toolbar"),a.view=new f({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 g({controller:this}))},createSelectToolbar:function(a,b){b=b||this.options.button||{},b.controller=this,a.view=new h(b)}}),b.exports=c},{"../../controllers/library.js":3,"../attachments/browser.js":20,"../media-frame.js":32,"../toolbar/select.js":45,"../uploader/inline.js":46}],28:[function(a,b){var c,d=a("./media-details"),e=a("../../controllers/media-library.js"),f=a("../video-details.js"),g=a("../../controllers/video-details.js"),h=wp.media.view.l10n;c=d.extend({defaults:{id:"video",url:"",menu:"video-details",content:"video-details",toolbar:"video-details",type:"link",title:h.videoDetailsTitle,priority:120},initialize:function(a){a.DetailsView=f,a.cancelText=h.videoDetailsCancel,a.addText=h.videoAddSourceTitle,d.prototype.initialize.call(this,a)},bindHandlers:function(){d.prototype.bindHandlers.apply(this,arguments),this.on("toolbar:render:replace-video",this.renderReplaceToolbar,this),this.on("toolbar:render:add-video-source",this.renderAddSourceToolbar,this),this.on("toolbar:render:select-poster-image",this.renderSelectPosterImageToolbar,this),this.on("toolbar:render:add-track",this.renderAddTrackToolbar,this)},createStates:function(){this.states.add([new g({media:this.media}),new e({type:"video",id:"replace-video",title:h.videoReplaceTitle,toolbar:"replace-video",media:this.media,menu:"video-details"}),new e({type:"video",id:"add-video-source",title:h.videoAddSourceTitle,toolbar:"add-video-source",media:this.media,menu:!1}),new e({type:"image",id:"select-poster-image",title:h.videoSelectPosterImageTitle,toolbar:"select-poster-image",media:this.media,menu:"video-details"}),new e({type:"text",id:"add-track",title:h.videoAddTrackTitle,toolbar:"add-track",media:this.media,menu:"video-details"})])},renderSelectPosterImageToolbar:function(){this.setPrimaryButton(h.videoSelectPosterImageTitle,function(a,b){var c=[],d=b.get("selection").single();a.media.set("poster",d.get("url")),b.trigger("set-poster-image",a.media.toJSON()),_.each(wp.media.view.settings.embedExts,function(b){a.media.get(b)&&c.push(a.media.get(b))}),wp.ajax.send("set-attachment-thumbnail",{data:{urls:c,thumbnail_id:d.get("id")}})})},renderAddTrackToolbar:function(){this.setPrimaryButton(h.videoAddTrackTitle,function(a,b){var c=b.get("selection").single(),d=a.media.get("content");-1===d.indexOf(c.get("url"))&&(d+=[''].join(""),a.media.set("content",d)),b.trigger("add-track",a.media.toJSON())})}}),b.exports=c},{"../../controllers/media-library.js":4,"../../controllers/video-details.js":8,"../video-details.js":50,"./media-details":26}],29:[function(a,b){var c,d=a("./view.js");c=d.extend({className:"media-iframe",render:function(){return this.views.detach(),this.$el.html('