]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/media-views.js
Wordpress 4.5.3
[autoinstalls/wordpress.git] / wp-includes / js / media-views.js
index 605459f4a9b9a0053d8461cdd17cc4c92bbe4b7c..60f9b9361fd684819375dccd33aa345e65fee45a 100644 (file)
@@ -1,6 +1,4 @@
 (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<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
-/*globals wp, _ */
-
 /**
  * wp.media.controller.CollectionAdd
  *
@@ -102,8 +100,6 @@ CollectionAdd = Library.extend({
 module.exports = CollectionAdd;
 
 },{}],2:[function(require,module,exports){
-/*globals wp, Backbone */
-
 /**
  * wp.media.controller.CollectionEdit
  *
@@ -266,8 +262,6 @@ CollectionEdit = Library.extend({
 module.exports = CollectionEdit;
 
 },{}],3:[function(require,module,exports){
-/*globals wp, _, Backbone */
-
 /**
  * wp.media.controller.Cropper
  *
@@ -288,8 +282,10 @@ Cropper = wp.media.controller.State.extend({
                toolbar:     'crop',
                content:     'crop',
                router:      false,
+               canSkipCrop: false,
 
-               canSkipCrop: false
+               // Default doCrop Ajax arguments to allow the Customizer (for example) to inject state.
+               doCropArgs: {}
        },
 
        activate: function() {
@@ -373,19 +369,64 @@ Cropper = wp.media.controller.State.extend({
        },
 
        doCrop: function( attachment ) {
-               return wp.ajax.post( 'custom-header-crop', {
-                       nonce: attachment.get('nonces').edit,
-                       id: attachment.get('id'),
-                       cropDetails: attachment.get('cropDetails')
-               } );
+               return wp.ajax.post( 'custom-header-crop', _.extend(
+                       {},
+                       this.defaults.doCropArgs,
+                       {
+                               nonce: attachment.get( 'nonces' ).edit,
+                               id: attachment.get( 'id' ),
+                               cropDetails: attachment.get( 'cropDetails' )
+                       }
+               ) );
        }
 });
 
 module.exports = Cropper;
 
 },{}],4:[function(require,module,exports){
-/*globals wp */
+/**
+ * wp.media.controller.CustomizeImageCropper
+ *
+ * A state for cropping an image.
+ *
+ * @class
+ * @augments wp.media.controller.Cropper
+ * @augments wp.media.controller.State
+ * @augments Backbone.Model
+ */
+var Controller = wp.media.controller,
+       CustomizeImageCropper;
+
+CustomizeImageCropper = Controller.Cropper.extend({
+       doCrop: function( attachment ) {
+               var cropDetails = attachment.get( 'cropDetails' ),
+                       control = this.get( 'control' ),
+                       ratio = cropDetails.width / cropDetails.height;
+
+               // Use crop measurements when flexible in both directions.
+               if ( control.params.flex_width && control.params.flex_height ) {
+                       cropDetails.dst_width  = cropDetails.width;
+                       cropDetails.dst_height = cropDetails.height;
+
+               // Constrain flexible side based on image ratio and size of the fixed side.
+               } else {
+                       cropDetails.dst_width  = control.params.flex_width  ? control.params.height * ratio : control.params.width;
+                       cropDetails.dst_height = control.params.flex_height ? control.params.width  / ratio : control.params.height;
+               }
+
+               return wp.ajax.post( 'crop-image', {
+                       wp_customize: 'on',
+                       nonce: attachment.get( 'nonces' ).edit,
+                       id: attachment.get( 'id' ),
+                       context: control.id,
+                       cropDetails: cropDetails
+               } );
+       }
+});
+
+module.exports = CustomizeImageCropper;
 
+},{}],5:[function(require,module,exports){
 /**
  * wp.media.controller.EditImage
  *
@@ -421,14 +462,14 @@ EditImage = wp.media.controller.State.extend({
         * @since 3.9.0
         */
        activate: function() {
-               this.listenTo( this.frame, 'toolbar:render:edit-image', this.toolbar );
+               this.frame.on( 'toolbar:render:edit-image', _.bind( this.toolbar, this ) );
        },
 
        /**
         * @since 3.9.0
         */
        deactivate: function() {
-               this.stopListening( this.frame );
+               this.frame.off( 'toolbar:render:edit-image' );
        },
 
        /**
@@ -461,9 +502,7 @@ EditImage = wp.media.controller.State.extend({
 
 module.exports = EditImage;
 
-},{}],5:[function(require,module,exports){
-/*globals wp, _, Backbone */
-
+},{}],6:[function(require,module,exports){
 /**
  * wp.media.controller.Embed
  *
@@ -503,7 +542,7 @@ Embed = wp.media.controller.State.extend({
        },
 
        // The amount of time used when debouncing the scan.
-       sensitivity: 200,
+       sensitivity: 400,
 
        initialize: function(options) {
                this.metadata = options.metadata;
@@ -599,9 +638,7 @@ Embed = wp.media.controller.State.extend({
 
 module.exports = Embed;
 
-},{}],6:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],7:[function(require,module,exports){
 /**
  * wp.media.controller.FeaturedImage
  *
@@ -723,9 +760,7 @@ FeaturedImage = Library.extend({
 
 module.exports = FeaturedImage;
 
-},{}],7:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],8:[function(require,module,exports){
 /**
  * wp.media.controller.GalleryAdd
  *
@@ -816,9 +851,7 @@ GalleryAdd = Library.extend({
 
 module.exports = GalleryAdd;
 
-},{}],8:[function(require,module,exports){
-/*globals wp */
-
+},{}],9:[function(require,module,exports){
 /**
  * wp.media.controller.GalleryEdit
  *
@@ -960,9 +993,7 @@ GalleryEdit = Library.extend({
 
 module.exports = GalleryEdit;
 
-},{}],9:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],10:[function(require,module,exports){
 /**
  * wp.media.controller.ImageDetails
  *
@@ -1024,9 +1055,7 @@ ImageDetails = State.extend({
 
 module.exports = ImageDetails;
 
-},{}],10:[function(require,module,exports){
-/*globals wp, _, Backbone */
-
+},{}],11:[function(require,module,exports){
 /**
  * wp.media.controller.Library
  *
@@ -1168,9 +1197,9 @@ Library = wp.media.controller.State.extend({
                var defaultProps = wp.media.view.settings.defaultProps;
                this._displays = [];
                this._defaultDisplaySettings = {
-                       align: defaultProps.align || getUserSetting( 'align', 'none' ),
-                       size:  defaultProps.size  || getUserSetting( 'imgsize', 'medium' ),
-                       link:  defaultProps.link  || getUserSetting( 'urlbutton', 'file' )
+                       align: getUserSetting( 'align', defaultProps.align ) || 'none',
+                       size:  getUserSetting( 'imgsize', defaultProps.size ) || 'medium',
+                       link:  getUserSetting( 'urlbutton', defaultProps.link ) || 'none'
                };
        },
 
@@ -1200,13 +1229,34 @@ Library = wp.media.controller.State.extend({
         * @returns {Object}
         */
        defaultDisplaySettings: function( attachment ) {
-               var settings = this._defaultDisplaySettings;
+               var settings = _.clone( this._defaultDisplaySettings );
+
                if ( settings.canEmbed = this.canEmbed( attachment ) ) {
                        settings.link = 'embed';
+               } else if ( ! this.isImageAttachment( attachment ) && settings.link === 'none' ) {
+                       settings.link = 'file';
                }
+
                return settings;
        },
 
+       /**
+        * Whether an attachment is image.
+        *
+        * @since 4.4.1
+        *
+        * @param {wp.media.model.Attachment} attachment
+        * @returns {Boolean}
+        */
+       isImageAttachment: function( attachment ) {
+               // If uploading, we know the filename but not the mime type.
+               if ( attachment.get('uploading') ) {
+                       return /\.(jpe?g|png|gif)$/i.test( attachment.get('filename') );
+               }
+
+               return attachment.get('type') === 'image';
+       },
+
        /**
         * Whether an attachment can be embedded (audio or video).
         *
@@ -1298,9 +1348,7 @@ _.extend( Library.prototype, wp.media.selectionSync );
 
 module.exports = Library;
 
-},{}],11:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],12:[function(require,module,exports){
 /**
  * wp.media.controller.MediaLibrary
  *
@@ -1350,9 +1398,7 @@ MediaLibrary = Library.extend({
 
 module.exports = MediaLibrary;
 
-},{}],12:[function(require,module,exports){
-/*globals Backbone, _ */
-
+},{}],13:[function(require,module,exports){
 /**
  * wp.media.controller.Region
  *
@@ -1531,9 +1577,7 @@ _.extend( Region.prototype, {
 
 module.exports = Region;
 
-},{}],13:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],14:[function(require,module,exports){
 /**
  * wp.media.controller.ReplaceImage
  *
@@ -1641,9 +1685,56 @@ ReplaceImage = Library.extend({
 
 module.exports = ReplaceImage;
 
-},{}],14:[function(require,module,exports){
-/*globals _, Backbone */
+},{}],15:[function(require,module,exports){
+/**
+ * wp.media.controller.SiteIconCropper
+ *
+ * A state for cropping a Site Icon.
+ *
+ * @class
+ * @augments wp.media.controller.Cropper
+ * @augments wp.media.controller.State
+ * @augments Backbone.Model
+ */
+var Controller = wp.media.controller,
+       SiteIconCropper;
+
+SiteIconCropper = Controller.Cropper.extend({
+       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));
+       },
+
+       createCropContent: function() {
+               this.cropperView = new wp.media.view.SiteIconCropper({
+                       controller: this,
+                       attachment: this.get('selection').first()
+               });
+               this.cropperView.on('image-loaded', this.createCropToolbar, this);
+               this.frame.content.set(this.cropperView);
+
+       },
 
+       doCrop: function( attachment ) {
+               var cropDetails = attachment.get( 'cropDetails' ),
+                       control = this.get( 'control' );
+
+               cropDetails.dst_width  = control.params.width;
+               cropDetails.dst_height = control.params.height;
+
+               return wp.ajax.post( 'crop-image', {
+                       nonce: attachment.get( 'nonces' ).edit,
+                       id: attachment.get( 'id' ),
+                       context: 'site-icon',
+                       cropDetails: cropDetails
+               } );
+       }
+});
+
+module.exports = SiteIconCropper;
+
+},{}],16:[function(require,module,exports){
 /**
  * wp.media.controller.StateMachine
  *
@@ -1767,9 +1858,7 @@ _.each([ 'on', 'off', 'trigger' ], function( method ) {
 
 module.exports = StateMachine;
 
-},{}],15:[function(require,module,exports){
-/*globals _, Backbone */
-
+},{}],17:[function(require,module,exports){
 /**
  * wp.media.controller.State
  *
@@ -2010,9 +2099,7 @@ _.each(['toolbar','content'], function( region ) {
 
 module.exports = State;
 
-},{}],16:[function(require,module,exports){
-/*globals _ */
-
+},{}],18:[function(require,module,exports){
 /**
  * wp.media.selectionSync
  *
@@ -2078,9 +2165,7 @@ var selectionSync = {
 
 module.exports = selectionSync;
 
-},{}],17:[function(require,module,exports){
-/*globals wp, jQuery, _, Backbone */
-
+},{}],19:[function(require,module,exports){
 var media = wp.media,
        $ = jQuery,
        l10n;
@@ -2171,6 +2256,8 @@ media.controller.EditImage = require( './controllers/edit-image.js' );
 media.controller.MediaLibrary = require( './controllers/media-library.js' );
 media.controller.Embed = require( './controllers/embed.js' );
 media.controller.Cropper = require( './controllers/cropper.js' );
+media.controller.CustomizeImageCropper = require( './controllers/customize-image-cropper.js' );
+media.controller.SiteIconCropper = require( './controllers/site-icon-cropper.js' );
 
 media.View = require( './views/view.js' );
 media.view.Frame = require( './views/frame.js' );
@@ -2224,12 +2311,12 @@ media.view.EmbedLink = require( './views/embed/link.js' );
 media.view.EmbedImage = require( './views/embed/image.js' );
 media.view.ImageDetails = require( './views/image-details.js' );
 media.view.Cropper = require( './views/cropper.js' );
+media.view.SiteIconCropper = require( './views/site-icon-cropper.js' );
+media.view.SiteIconPreview = require( './views/site-icon-preview.js' );
 media.view.EditImage = require( './views/edit-image.js' );
 media.view.Spinner = require( './views/spinner.js' );
 
-},{"./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":16,"./views/attachment-compat.js":18,"./views/attachment-filters.js":19,"./views/attachment-filters/all.js":20,"./views/attachment-filters/date.js":21,"./views/attachment-filters/uploaded.js":22,"./views/attachment.js":23,"./views/attachment/details.js":24,"./views/attachment/edit-library.js":25,"./views/attachment/edit-selection.js":26,"./views/attachment/library.js":27,"./views/attachment/selection.js":28,"./views/attachments.js":29,"./views/attachments/browser.js":30,"./views/attachments/selection.js":31,"./views/button-group.js":32,"./views/button.js":33,"./views/cropper.js":34,"./views/edit-image.js":35,"./views/embed.js":36,"./views/embed/image.js":37,"./views/embed/link.js":38,"./views/embed/url.js":39,"./views/focus-manager.js":40,"./views/frame.js":41,"./views/frame/image-details.js":42,"./views/frame/post.js":43,"./views/frame/select.js":44,"./views/iframe.js":45,"./views/image-details.js":46,"./views/label.js":47,"./views/media-frame.js":48,"./views/menu-item.js":49,"./views/menu.js":50,"./views/modal.js":51,"./views/priority-list.js":52,"./views/router-item.js":53,"./views/router.js":54,"./views/search.js":55,"./views/selection.js":56,"./views/settings.js":57,"./views/settings/attachment-display.js":58,"./views/settings/gallery.js":59,"./views/settings/playlist.js":60,"./views/sidebar.js":61,"./views/spinner.js":62,"./views/toolbar.js":63,"./views/toolbar/embed.js":64,"./views/toolbar/select.js":65,"./views/uploader/editor.js":66,"./views/uploader/inline.js":67,"./views/uploader/status-error.js":68,"./views/uploader/status.js":69,"./views/uploader/window.js":70,"./views/view.js":71}],18:[function(require,module,exports){
-/*globals _ */
-
+},{"./controllers/collection-add.js":1,"./controllers/collection-edit.js":2,"./controllers/cropper.js":3,"./controllers/customize-image-cropper.js":4,"./controllers/edit-image.js":5,"./controllers/embed.js":6,"./controllers/featured-image.js":7,"./controllers/gallery-add.js":8,"./controllers/gallery-edit.js":9,"./controllers/image-details.js":10,"./controllers/library.js":11,"./controllers/media-library.js":12,"./controllers/region.js":13,"./controllers/replace-image.js":14,"./controllers/site-icon-cropper.js":15,"./controllers/state-machine.js":16,"./controllers/state.js":17,"./utils/selection-sync.js":18,"./views/attachment-compat.js":20,"./views/attachment-filters.js":21,"./views/attachment-filters/all.js":22,"./views/attachment-filters/date.js":23,"./views/attachment-filters/uploaded.js":24,"./views/attachment.js":25,"./views/attachment/details.js":26,"./views/attachment/edit-library.js":27,"./views/attachment/edit-selection.js":28,"./views/attachment/library.js":29,"./views/attachment/selection.js":30,"./views/attachments.js":31,"./views/attachments/browser.js":32,"./views/attachments/selection.js":33,"./views/button-group.js":34,"./views/button.js":35,"./views/cropper.js":36,"./views/edit-image.js":37,"./views/embed.js":38,"./views/embed/image.js":39,"./views/embed/link.js":40,"./views/embed/url.js":41,"./views/focus-manager.js":42,"./views/frame.js":43,"./views/frame/image-details.js":44,"./views/frame/post.js":45,"./views/frame/select.js":46,"./views/iframe.js":47,"./views/image-details.js":48,"./views/label.js":49,"./views/media-frame.js":50,"./views/menu-item.js":51,"./views/menu.js":52,"./views/modal.js":53,"./views/priority-list.js":54,"./views/router-item.js":55,"./views/router.js":56,"./views/search.js":57,"./views/selection.js":58,"./views/settings.js":59,"./views/settings/attachment-display.js":60,"./views/settings/gallery.js":61,"./views/settings/playlist.js":62,"./views/sidebar.js":63,"./views/site-icon-cropper.js":64,"./views/site-icon-preview.js":65,"./views/spinner.js":66,"./views/toolbar.js":67,"./views/toolbar/embed.js":68,"./views/toolbar/select.js":69,"./views/uploader/editor.js":70,"./views/uploader/inline.js":71,"./views/uploader/status-error.js":72,"./views/uploader/status.js":73,"./views/uploader/window.js":74,"./views/view.js":75}],20:[function(require,module,exports){
 /**
  * wp.media.view.AttachmentCompat
  *
@@ -2314,9 +2401,7 @@ AttachmentCompat = View.extend({
 
 module.exports = AttachmentCompat;
 
-},{}],19:[function(require,module,exports){
-/*globals _, jQuery */
-
+},{}],21:[function(require,module,exports){
 /**
  * wp.media.view.AttachmentFilters
  *
@@ -2393,9 +2478,7 @@ AttachmentFilters = wp.media.View.extend({
 
 module.exports = AttachmentFilters;
 
-},{}],20:[function(require,module,exports){
-/*globals wp */
-
+},{}],22:[function(require,module,exports){
 /**
  * wp.media.view.AttachmentFilters.All
  *
@@ -2485,9 +2568,7 @@ All = wp.media.view.AttachmentFilters.extend({
 
 module.exports = All;
 
-},{}],21:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],23:[function(require,module,exports){
 /**
  * A filter dropdown for month/dates.
  *
@@ -2528,9 +2609,7 @@ DateFilter = wp.media.view.AttachmentFilters.extend({
 
 module.exports = DateFilter;
 
-},{}],22:[function(require,module,exports){
-/*globals wp */
-
+},{}],24:[function(require,module,exports){
 /**
  * wp.media.view.AttachmentFilters.Uploaded
  *
@@ -2589,9 +2668,7 @@ Uploaded = wp.media.view.AttachmentFilters.extend({
 
 module.exports = Uploaded;
 
-},{}],23:[function(require,module,exports){
-/*globals wp, _, jQuery */
-
+},{}],25:[function(require,module,exports){
 /**
  * wp.media.view.Attachment
  *
@@ -2625,10 +2702,8 @@ Attachment = View.extend({
                'change [data-setting] input':    'updateSetting',
                'change [data-setting] select':   'updateSetting',
                'change [data-setting] textarea': 'updateSetting',
-               'click .close':                   'removeFromLibrary',
+               'click .attachment-close':        'removeFromLibrary',
                'click .check':                   'checkClickHandler',
-               'click a':                        'preventDefault',
-               'keydown .close':                 'removeFromLibrary',
                'keydown':                        'toggleSelectionHandler'
        },
 
@@ -2756,8 +2831,8 @@ Attachment = View.extend({
        toggleSelectionHandler: function( event ) {
                var method;
 
-               // Don't do anything inside inputs.
-               if ( 'INPUT' === event.target.nodeName ) {
+               // Don't do anything inside inputs and on the attachment check and remove buttons.
+               if ( 'INPUT' === event.target.nodeName || 'BUTTON' === event.target.nodeName ) {
                        return;
                }
 
@@ -2942,12 +3017,6 @@ Attachment = View.extend({
                details = selection.single();
                this.$el.toggleClass( 'details', details === this.model );
        },
-       /**
-        * @param {Object} event
-        */
-       preventDefault: function( event ) {
-               event.preventDefault();
-       },
        /**
         * @param {string} size
         * @returns {Object}
@@ -3145,9 +3214,7 @@ _.each({
 
 module.exports = Attachment;
 
-},{}],24:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],26:[function(require,module,exports){
 /**
  * wp.media.view.Attachment.Details
  *
@@ -3182,7 +3249,6 @@ Details = Attachment.extend({
                'click .trash-attachment':        'trashAttachment',
                'click .untrash-attachment':      'untrashAttachment',
                'click .edit-attachment':         'editAttachment',
-               'click .refresh-attachment':      'refreshAttachment',
                'keydown':                        'toggleSelectionHandler'
        },
 
@@ -3198,7 +3264,14 @@ Details = Attachment.extend({
 
        initialFocus: function() {
                if ( ! wp.media.isTouchDevice ) {
-                       this.$( ':input' ).eq( 0 ).focus();
+                       /*
+                       Previously focused the first ':input' (the readonly URL text field).
+                       Since the first ':input' is now a button (delete/trash): when pressing
+                       spacebar on an attachment, Firefox fires deleteAttachment/trashAttachment
+                       as soon as focus is moved. Explicitly target the first text field for now.
+                       @todo change initial focus logic, also for accessibility.
+                       */
+                       this.$( 'input[type="text"]' ).eq( 0 ).focus();
                }
        },
        /**
@@ -3258,14 +3331,6 @@ Details = Attachment.extend({
                        this.$el.addClass('needs-refresh');
                }
        },
-       /**
-        * @param {Object} event
-        */
-       refreshAttachment: function( event ) {
-               this.$el.removeClass('needs-refresh');
-               event.preventDefault();
-               this.model.fetch();
-       },
        /**
         * When reverse tabbing(shift+tab) out of the right details panel, deliver
         * the focus to the item in the list that was being edited.
@@ -3287,9 +3352,7 @@ Details = Attachment.extend({
 
 module.exports = Details;
 
-},{}],25:[function(require,module,exports){
-/*globals wp */
-
+},{}],27:[function(require,module,exports){
 /**
  * wp.media.view.Attachment.EditLibrary
  *
@@ -3307,9 +3370,7 @@ var EditLibrary = wp.media.view.Attachment.extend({
 
 module.exports = EditLibrary;
 
-},{}],26:[function(require,module,exports){
-/*globals wp */
-
+},{}],28:[function(require,module,exports){
 /**
  * wp.media.view.Attachments.EditSelection
  *
@@ -3328,9 +3389,7 @@ var EditSelection = wp.media.view.Attachment.Selection.extend({
 
 module.exports = EditSelection;
 
-},{}],27:[function(require,module,exports){
-/*globals wp */
-
+},{}],29:[function(require,module,exports){
 /**
  * wp.media.view.Attachment.Library
  *
@@ -3348,9 +3407,7 @@ var Library = wp.media.view.Attachment.extend({
 
 module.exports = Library;
 
-},{}],28:[function(require,module,exports){
-/*globals wp */
-
+},{}],30:[function(require,module,exports){
 /**
  * wp.media.view.Attachment.Selection
  *
@@ -3372,9 +3429,7 @@ var Selection = wp.media.view.Attachment.extend({
 
 module.exports = Selection;
 
-},{}],29:[function(require,module,exports){
-/*globals wp, _, jQuery */
-
+},{}],31:[function(require,module,exports){
 /**
  * wp.media.view.Attachments
  *
@@ -3673,9 +3728,7 @@ Attachments = View.extend({
 
 module.exports = Attachments;
 
-},{}],30:[function(require,module,exports){
-/*globals wp, _, jQuery */
-
+},{}],32:[function(require,module,exports){
 /**
  * wp.media.view.AttachmentsBrowser
  *
@@ -3716,7 +3769,7 @@ AttachmentsBrowser = View.extend({
                        AttachmentView: wp.media.view.Attachment.Library
                });
 
-               this.listenTo( this.controller, 'toggle:upload:attachment', _.bind( this.toggleUploader, this ) );
+               this.controller.on( 'toggle:upload:attachment', this.toggleUploader, this );
                this.controller.on( 'edit:selection', this.editSelection );
                this.createToolbar();
                if ( this.options.sidebar ) {
@@ -4032,8 +4085,8 @@ AttachmentsBrowser = View.extend({
                });
 
                // Add keydown listener to the instance of the Attachments view
-               this.attachments.listenTo( this.controller, 'attachment:keydown:arrow',     this.attachments.arrowEvent );
-               this.attachments.listenTo( this.controller, 'attachment:details:shift-tab', this.attachments.restoreFocus );
+               this.controller.on( 'attachment:keydown:arrow',     _.bind( this.attachments.arrowEvent, this.attachments ) );
+               this.controller.on( 'attachment:details:shift-tab', _.bind( this.attachments.restoreFocus, this.attachments ) );
 
                this.views.add( this.attachments );
 
@@ -4119,9 +4172,7 @@ AttachmentsBrowser = View.extend({
 
 module.exports = AttachmentsBrowser;
 
-},{}],31:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],33:[function(require,module,exports){
 /**
  * wp.media.view.Attachments.Selection
  *
@@ -4151,9 +4202,7 @@ Selection = Attachments.extend({
 
 module.exports = Selection;
 
-},{}],32:[function(require,module,exports){
-/*globals _, Backbone */
-
+},{}],34:[function(require,module,exports){
 /**
  * wp.media.view.ButtonGroup
  *
@@ -4199,9 +4248,7 @@ ButtonGroup = wp.media.View.extend({
 
 module.exports = ButtonGroup;
 
-},{}],33:[function(require,module,exports){
-/*globals _, Backbone */
-
+},{}],35:[function(require,module,exports){
 /**
  * wp.media.view.Button
  *
@@ -4211,9 +4258,9 @@ module.exports = ButtonGroup;
  * @augments Backbone.View
  */
 var Button = wp.media.View.extend({
-       tagName:    'a',
+       tagName:    'button',
        className:  'media-button',
-       attributes: { href: '#' },
+       attributes: { type: 'button' },
 
        events: {
                'click': 'click'
@@ -4287,9 +4334,7 @@ var Button = wp.media.View.extend({
 
 module.exports = Button;
 
-},{}],34:[function(require,module,exports){
-/*globals wp, _, jQuery */
-
+},{}],36:[function(require,module,exports){
 /**
  * wp.media.view.Cropper
  *
@@ -4356,9 +4401,7 @@ Cropper = View.extend({
 
 module.exports = Cropper;
 
-},{}],35:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],37:[function(require,module,exports){
 /**
  * wp.media.view.EditImage
  *
@@ -4414,7 +4457,7 @@ EditImage = View.extend({
 
 module.exports = EditImage;
 
-},{}],36:[function(require,module,exports){
+},{}],38:[function(require,module,exports){
 /**
  * wp.media.view.Embed
  *
@@ -4478,9 +4521,7 @@ var Embed = wp.media.View.extend({
 
 module.exports = Embed;
 
-},{}],37:[function(require,module,exports){
-/*globals wp */
-
+},{}],39:[function(require,module,exports){
 /**
  * wp.media.view.EmbedImage
  *
@@ -4513,9 +4554,7 @@ EmbedImage = AttachmentDisplay.extend({
 
 module.exports = EmbedImage;
 
-},{}],38:[function(require,module,exports){
-/*globals wp, _, jQuery */
-
+},{}],40:[function(require,module,exports){
 /**
  * wp.media.view.EmbedLink
  *
@@ -4533,8 +4572,6 @@ EmbedLink = wp.media.view.Settings.extend({
        template:  wp.template('embed-link-settings'),
 
        initialize: function() {
-               this.spinner = $('<span class="spinner" />');
-               this.$el.append( this.spinner[0] );
                this.listenTo( this.model, 'change:url', this.updateoEmbed );
        },
 
@@ -4545,36 +4582,56 @@ EmbedLink = wp.media.view.Settings.extend({
                this.$('.embed-container').hide().find('.embed-preview').empty();
                this.$( '.setting' ).hide();
 
-               // only proceed with embed if the field contains more than 6 characters
-               if ( url && url.length < 6 ) {
+               // only proceed with embed if the field contains more than 11 characters
+               // Example: http://a.io is 11 chars
+               if ( url && ( url.length < 11 || ! url.match(/^http(s)?:\/\//) ) ) {
                        return;
                }
 
                this.fetch();
-       }, 600 ),
+       }, wp.media.controller.Embed.sensitivity ),
 
        fetch: function() {
+               var embed;
+
                // check if they haven't typed in 500 ms
                if ( $('#embed-url-field').val() !== this.model.get('url') ) {
                        return;
                }
 
-               wp.ajax.send( 'parse-embed', {
-                       data : {
+               if ( this.dfd && 'pending' === this.dfd.state() ) {
+                       this.dfd.abort();
+               }
+
+               embed = new wp.shortcode({
+                       tag: 'embed',
+                       attrs: _.pick( this.model.attributes, [ 'width', 'height', 'src' ] ),
+                       content: this.model.get('url')
+               });
+
+               this.dfd = $.ajax({
+                       type:    'POST',
+                       url:     wp.ajax.settings.url,
+                       context: this,
+                       data:    {
+                               action: 'parse-embed',
                                post_ID: wp.media.view.settings.post.id,
-                               shortcode: '[embed]' + this.model.get('url') + '[/embed]'
+                               shortcode: embed.string()
                        }
-               } )
-                       .done( _.bind( this.renderoEmbed, this ) )
-                       .fail( _.bind( this.renderFail, this ) );
+               })
+                       .done( this.renderoEmbed )
+                       .fail( this.renderFail );
        },
 
-       renderFail: function () {
+       renderFail: function ( response, status ) {
+               if ( 'abort' === status ) {
+                       return;
+               }
                this.$( '.link-text' ).show();
        },
 
        renderoEmbed: function( response ) {
-               var html = ( response && response.body ) || '';
+               var html = ( response && response.data && response.data.body ) || '';
 
                if ( html ) {
                        this.$('.embed-container').show().find('.embed-preview').html( html );
@@ -4586,9 +4643,7 @@ EmbedLink = wp.media.view.Settings.extend({
 
 module.exports = EmbedLink;
 
-},{}],39:[function(require,module,exports){
-/*globals wp, _, jQuery */
-
+},{}],41:[function(require,module,exports){
 /**
  * wp.media.view.EmbedUrl
  *
@@ -4667,7 +4722,7 @@ EmbedUrl = View.extend({
 
 module.exports = EmbedUrl;
 
-},{}],40:[function(require,module,exports){
+},{}],42:[function(require,module,exports){
 /**
  * wp.media.view.FocusManager
  *
@@ -4713,9 +4768,7 @@ var FocusManager = wp.media.View.extend({
 
 module.exports = FocusManager;
 
-},{}],41:[function(require,module,exports){
-/*globals _, Backbone */
-
+},{}],43:[function(require,module,exports){
 /**
  * wp.media.view.Frame
  *
@@ -4881,9 +4934,7 @@ _.extend( Frame.prototype, wp.media.controller.StateMachine.prototype );
 
 module.exports = Frame;
 
-},{}],42:[function(require,module,exports){
-/*globals wp */
-
+},{}],44:[function(require,module,exports){
 /**
  * wp.media.view.MediaFrame.ImageDetails
  *
@@ -5060,9 +5111,7 @@ ImageDetails = Select.extend({
 
 module.exports = ImageDetails;
 
-},{}],43:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],45:[function(require,module,exports){
 /**
  * wp.media.view.MediaFrame.Post
  *
@@ -5797,9 +5846,7 @@ Post = Select.extend({
 
 module.exports = Post;
 
-},{}],44:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],46:[function(require,module,exports){
 /**
  * wp.media.view.MediaFrame.Select
  *
@@ -5970,7 +6017,7 @@ Select = MediaFrame.extend({
 
 module.exports = Select;
 
-},{}],45:[function(require,module,exports){
+},{}],47:[function(require,module,exports){
 /**
  * wp.media.view.Iframe
  *
@@ -5994,9 +6041,7 @@ var Iframe = wp.media.View.extend({
 
 module.exports = Iframe;
 
-},{}],46:[function(require,module,exports){
-/*globals wp, _, jQuery */
-
+},{}],48:[function(require,module,exports){
 /**
  * wp.media.view.ImageDetails
  *
@@ -6164,7 +6209,7 @@ ImageDetails = AttachmentDisplay.extend({
 
 module.exports = ImageDetails;
 
-},{}],47:[function(require,module,exports){
+},{}],49:[function(require,module,exports){
 /**
  * wp.media.view.Label
  *
@@ -6190,9 +6235,7 @@ var Label = wp.media.View.extend({
 
 module.exports = Label;
 
-},{}],48:[function(require,module,exports){
-/*globals wp, _, jQuery */
-
+},{}],50:[function(require,module,exports){
 /**
  * wp.media.view.MediaFrame
  *
@@ -6439,9 +6482,7 @@ _.each(['open','close','attach','detach','escape'], function( method ) {
 
 module.exports = MediaFrame;
 
-},{}],49:[function(require,module,exports){
-/*globals jQuery */
-
+},{}],51:[function(require,module,exports){
 /**
  * wp.media.view.MenuItem
  *
@@ -6513,7 +6554,7 @@ MenuItem = wp.media.View.extend({
 
 module.exports = MenuItem;
 
-},{}],50:[function(require,module,exports){
+},{}],52:[function(require,module,exports){
 /**
  * wp.media.view.Menu
  *
@@ -6630,9 +6671,7 @@ Menu = PriorityList.extend({
 
 module.exports = Menu;
 
-},{}],51:[function(require,module,exports){
-/*globals wp, _, jQuery */
-
+},{}],53:[function(require,module,exports){
 /**
  * wp.media.view.Modal
  *
@@ -6845,9 +6884,7 @@ Modal = wp.media.View.extend({
 
 module.exports = Modal;
 
-},{}],52:[function(require,module,exports){
-/*globals _, Backbone */
-
+},{}],54:[function(require,module,exports){
 /**
  * wp.media.view.PriorityList
  *
@@ -6944,7 +6981,7 @@ var PriorityList = wp.media.View.extend({
 
 module.exports = PriorityList;
 
-},{}],53:[function(require,module,exports){
+},{}],55:[function(require,module,exports){
 /**
  * wp.media.view.RouterItem
  *
@@ -6968,9 +7005,7 @@ var RouterItem = wp.media.view.MenuItem.extend({
 
 module.exports = RouterItem;
 
-},{}],54:[function(require,module,exports){
-/*globals wp */
-
+},{}],56:[function(require,module,exports){
 /**
  * wp.media.view.Router
  *
@@ -7007,9 +7042,7 @@ Router = Menu.extend({
 
 module.exports = Router;
 
-},{}],55:[function(require,module,exports){
-/*globals wp */
-
+},{}],57:[function(require,module,exports){
 /**
  * wp.media.view.Search
  *
@@ -7057,9 +7090,7 @@ Search = wp.media.View.extend({
 
 module.exports = Search;
 
-},{}],56:[function(require,module,exports){
-/*globals wp, _, Backbone */
-
+},{}],58:[function(require,module,exports){
 /**
  * wp.media.view.Selection
  *
@@ -7142,9 +7173,7 @@ Selection = wp.media.View.extend({
 
 module.exports = Selection;
 
-},{}],57:[function(require,module,exports){
-/*globals _, Backbone */
-
+},{}],59:[function(require,module,exports){
 /**
  * wp.media.view.Settings
  *
@@ -7265,9 +7294,7 @@ Settings = View.extend({
 
 module.exports = Settings;
 
-},{}],58:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],60:[function(require,module,exports){
 /**
  * wp.media.view.Settings.AttachmentDisplay
  *
@@ -7361,9 +7388,7 @@ AttachmentDisplay = Settings.extend({
 
 module.exports = AttachmentDisplay;
 
-},{}],59:[function(require,module,exports){
-/*globals wp */
-
+},{}],61:[function(require,module,exports){
 /**
  * wp.media.view.Settings.Gallery
  *
@@ -7380,9 +7405,7 @@ var Gallery = wp.media.view.Settings.extend({
 
 module.exports = Gallery;
 
-},{}],60:[function(require,module,exports){
-/*globals wp */
-
+},{}],62:[function(require,module,exports){
 /**
  * wp.media.view.Settings.Playlist
  *
@@ -7399,7 +7422,7 @@ var Playlist = wp.media.view.Settings.extend({
 
 module.exports = Playlist;
 
-},{}],61:[function(require,module,exports){
+},{}],63:[function(require,module,exports){
 /**
  * wp.media.view.Sidebar
  *
@@ -7415,9 +7438,106 @@ var Sidebar = wp.media.view.PriorityList.extend({
 
 module.exports = Sidebar;
 
-},{}],62:[function(require,module,exports){
-/*globals _ */
+},{}],64:[function(require,module,exports){
+/**
+ * wp.media.view.SiteIconCropper
+ *
+ * Uses the imgAreaSelect plugin to allow a user to crop a Site Icon.
+ *
+ * Takes imgAreaSelect options from
+ * wp.customize.SiteIconControl.calculateImageSelectOptions.
+ *
+ * @class
+ * @augments wp.media.view.Cropper
+ * @augments wp.media.View
+ * @augments wp.Backbone.View
+ * @augments Backbone.View
+ */
+var View = wp.media.view,
+       SiteIconCropper;
+
+SiteIconCropper = View.Cropper.extend({
+       className: 'crop-content site-icon',
+
+       ready: function () {
+               View.Cropper.prototype.ready.apply( this, arguments );
+
+               this.$( '.crop-image' ).on( 'load', _.bind( this.addSidebar, this ) );
+       },
+
+       addSidebar: function() {
+               this.sidebar = new wp.media.view.Sidebar({
+                       controller: this.controller
+               });
+
+               this.sidebar.set( 'preview', new wp.media.view.SiteIconPreview({
+                       controller: this.controller,
+                       attachment: this.options.attachment
+               }) );
+
+               this.controller.cropperView.views.add( this.sidebar );
+       }
+});
+
+module.exports = SiteIconCropper;
+
+},{}],65:[function(require,module,exports){
+/**
+ * wp.media.view.SiteIconPreview
+ *
+ * Shows a preview of the Site Icon as a favicon and app icon while cropping.
+ *
+ * @class
+ * @augments wp.media.View
+ * @augments wp.Backbone.View
+ * @augments Backbone.View
+ */
+var View = wp.media.View,
+       $ = jQuery,
+       SiteIconPreview;
+
+SiteIconPreview = View.extend({
+       className: 'site-icon-preview',
+       template: wp.template( 'site-icon-preview' ),
+
+       ready: function() {
+               this.controller.imgSelect.setOptions({
+                       onInit: this.updatePreview,
+                       onSelectChange: this.updatePreview
+               });
+       },
 
+       prepare: function() {
+               return {
+                       url: this.options.attachment.get( 'url' )
+               };
+       },
+
+       updatePreview: function( img, coords ) {
+               var rx = 64 / coords.width,
+                       ry = 64 / coords.height,
+                       preview_rx = 16 / coords.width,
+                       preview_ry = 16 / coords.height;
+
+               $( '#preview-app-icon' ).css({
+                       width: Math.round(rx * this.imageWidth ) + 'px',
+                       height: Math.round(ry * this.imageHeight ) + 'px',
+                       marginLeft: '-' + Math.round(rx * coords.x1) + 'px',
+                       marginTop: '-' + Math.round(ry * coords.y1) + 'px'
+               });
+
+               $( '#preview-favicon' ).css({
+                       width: Math.round( preview_rx * this.imageWidth ) + 'px',
+                       height: Math.round( preview_ry * this.imageHeight ) + 'px',
+                       marginLeft: '-' + Math.round( preview_rx * coords.x1 ) + 'px',
+                       marginTop: '-' + Math.floor( preview_ry* coords.y1 ) + 'px'
+               });
+       }
+});
+
+module.exports = SiteIconPreview;
+
+},{}],66:[function(require,module,exports){
 /**
  * wp.media.view.Spinner
  *
@@ -7452,9 +7572,7 @@ var Spinner = wp.media.View.extend({
 
 module.exports = Spinner;
 
-},{}],63:[function(require,module,exports){
-/*globals _, Backbone */
-
+},{}],67:[function(require,module,exports){
 /**
  * wp.media.view.Toolbar
  *
@@ -7614,9 +7732,7 @@ Toolbar = View.extend({
 
 module.exports = Toolbar;
 
-},{}],64:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],68:[function(require,module,exports){
 /**
  * wp.media.view.Toolbar.Embed
  *
@@ -7653,9 +7769,7 @@ Embed = Select.extend({
 
 module.exports = Embed;
 
-},{}],65:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],69:[function(require,module,exports){
 /**
  * wp.media.view.Toolbar.Select
  *
@@ -7725,12 +7839,10 @@ Select = Toolbar.extend({
 
 module.exports = Select;
 
-},{}],66:[function(require,module,exports){
-/*globals wp, _, jQuery */
-
+},{}],70:[function(require,module,exports){
 /**
- * Creates a dropzone on WP editor instances (elements with .wp-editor-wrap
- * or #wp-fullscreen-body) and relays drag'n'dropped files to a media workflow.
+ * Creates a dropzone on WP editor instances (elements with .wp-editor-wrap)
+ * and relays drag'n'dropped files to a media workflow.
  *
  * wp.media.view.EditorUploader
  *
@@ -7779,6 +7891,10 @@ EditorUploader = View.extend({
 
                this.$document.on( 'dragstart dragend drop', _.bind( function( event ) {
                        this.localDrag = event.type === 'dragstart';
+
+                       if ( event.type === 'drop' ) {
+                               this.containerDragleave();
+                       }
                }, this ) );
 
                this.initialized = true;
@@ -7837,7 +7953,7 @@ EditorUploader = View.extend({
                }
 
                View.prototype.render.apply( this, arguments );
-               $( '.wp-editor-wrap, #wp-fullscreen-body' ).each( _.bind( this.attach, this ) );
+               $( '.wp-editor-wrap' ).each( _.bind( this.attach, this ) );
                return this;
        },
 
@@ -7856,7 +7972,7 @@ EditorUploader = View.extend({
         * @param  {jQuery.Event} event The 'drop' event.
         */
        drop: function( event ) {
-               var $wrap = null, uploadView;
+               var $wrap, uploadView;
 
                this.containerDragleave( event );
                this.dropzoneDragleave( event );
@@ -7873,13 +7989,15 @@ EditorUploader = View.extend({
                }
 
                if ( ! this.workflow ) {
-                       this.workflow = wp.media.editor.open( 'content', {
+                       this.workflow = wp.media.editor.open( window.wpActiveEditor, {
                                frame:    'post',
                                state:    'insert',
                                title:    l10n.addMedia,
                                multiple: true
                        });
+
                        uploadView = this.workflow.uploader;
+
                        if ( uploadView.uploader && uploadView.uploader.ready ) {
                                this.addFiles.apply( this );
                        } else {
@@ -7946,9 +8064,7 @@ EditorUploader = View.extend({
 
 module.exports = EditorUploader;
 
-},{}],67:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],71:[function(require,module,exports){
 /**
  * wp.media.view.UploaderInline
  *
@@ -8079,9 +8195,7 @@ UploaderInline = View.extend({
 
 module.exports = UploaderInline;
 
-},{}],68:[function(require,module,exports){
-/*globals wp */
-
+},{}],72:[function(require,module,exports){
 /**
  * wp.media.view.UploaderStatusError
  *
@@ -8097,9 +8211,7 @@ var UploaderStatusError = wp.media.View.extend({
 
 module.exports = UploaderStatusError;
 
-},{}],69:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],73:[function(require,module,exports){
 /**
  * wp.media.view.UploaderStatus
  *
@@ -8206,7 +8318,7 @@ UploaderStatus = View.extend({
         * @returns {string}
         */
        filename: function( filename ) {
-               return wp.media.truncate( _.escape( filename ), 24 );
+               return _.escape( filename );
        },
        /**
         * @param {Backbone.Model} error
@@ -8237,9 +8349,7 @@ UploaderStatus = View.extend({
 
 module.exports = UploaderStatus;
 
-},{}],70:[function(require,module,exports){
-/*globals wp, _, jQuery */
-
+},{}],74:[function(require,module,exports){
 /**
  * wp.media.view.UploaderWindow
  *
@@ -8350,9 +8460,7 @@ UploaderWindow = wp.media.View.extend({
 
 module.exports = UploaderWindow;
 
-},{}],71:[function(require,module,exports){
-/*globals wp */
-
+},{}],75:[function(require,module,exports){
 /**
  * wp.media.View
  *
@@ -8418,4 +8526,4 @@ var View = wp.Backbone.View.extend({
 
 module.exports = View;
 
-},{}]},{},[17]);
+},{}]},{},[19]);