(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
*
module.exports = CollectionAdd;
},{}],2:[function(require,module,exports){
-/*globals wp, Backbone */
-
/**
* wp.media.controller.CollectionEdit
*
module.exports = CollectionEdit;
},{}],3:[function(require,module,exports){
-/*globals wp, _, Backbone */
-
/**
* wp.media.controller.Cropper
*
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() {
},
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
*
* @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' );
},
/**
module.exports = EditImage;
-},{}],5:[function(require,module,exports){
-/*globals wp, _, Backbone */
-
+},{}],6:[function(require,module,exports){
/**
* wp.media.controller.Embed
*
},
// The amount of time used when debouncing the scan.
- sensitivity: 200,
+ sensitivity: 400,
initialize: function(options) {
this.metadata = options.metadata;
module.exports = Embed;
-},{}],6:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],7:[function(require,module,exports){
/**
* wp.media.controller.FeaturedImage
*
module.exports = FeaturedImage;
-},{}],7:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],8:[function(require,module,exports){
/**
* wp.media.controller.GalleryAdd
*
module.exports = GalleryAdd;
-},{}],8:[function(require,module,exports){
-/*globals wp */
-
+},{}],9:[function(require,module,exports){
/**
* wp.media.controller.GalleryEdit
*
module.exports = GalleryEdit;
-},{}],9:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],10:[function(require,module,exports){
/**
* wp.media.controller.ImageDetails
*
module.exports = ImageDetails;
-},{}],10:[function(require,module,exports){
-/*globals wp, _, Backbone */
-
+},{}],11:[function(require,module,exports){
/**
* wp.media.controller.Library
*
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'
};
},
* @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).
*
module.exports = Library;
-},{}],11:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],12:[function(require,module,exports){
/**
* wp.media.controller.MediaLibrary
*
module.exports = MediaLibrary;
-},{}],12:[function(require,module,exports){
-/*globals Backbone, _ */
-
+},{}],13:[function(require,module,exports){
/**
* wp.media.controller.Region
*
module.exports = Region;
-},{}],13:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],14:[function(require,module,exports){
/**
* wp.media.controller.ReplaceImage
*
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
*
module.exports = StateMachine;
-},{}],15:[function(require,module,exports){
-/*globals _, Backbone */
-
+},{}],17:[function(require,module,exports){
/**
* wp.media.controller.State
*
module.exports = State;
-},{}],16:[function(require,module,exports){
-/*globals _ */
-
+},{}],18:[function(require,module,exports){
/**
* wp.media.selectionSync
*
module.exports = selectionSync;
-},{}],17:[function(require,module,exports){
-/*globals wp, jQuery, _, Backbone */
-
+},{}],19:[function(require,module,exports){
var media = wp.media,
$ = jQuery,
l10n;
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' );
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
*
module.exports = AttachmentCompat;
-},{}],19:[function(require,module,exports){
-/*globals _, jQuery */
-
+},{}],21:[function(require,module,exports){
/**
* wp.media.view.AttachmentFilters
*
module.exports = AttachmentFilters;
-},{}],20:[function(require,module,exports){
-/*globals wp */
-
+},{}],22:[function(require,module,exports){
/**
* wp.media.view.AttachmentFilters.All
*
module.exports = All;
-},{}],21:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],23:[function(require,module,exports){
/**
* A filter dropdown for month/dates.
*
module.exports = DateFilter;
-},{}],22:[function(require,module,exports){
-/*globals wp */
-
+},{}],24:[function(require,module,exports){
/**
* wp.media.view.AttachmentFilters.Uploaded
*
module.exports = Uploaded;
-},{}],23:[function(require,module,exports){
-/*globals wp, _, jQuery */
-
+},{}],25:[function(require,module,exports){
/**
* wp.media.view.Attachment
*
'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'
},
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;
}
details = selection.single();
this.$el.toggleClass( 'details', details === this.model );
},
- /**
- * @param {Object} event
- */
- preventDefault: function( event ) {
- event.preventDefault();
- },
/**
* @param {string} size
* @returns {Object}
module.exports = Attachment;
-},{}],24:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],26:[function(require,module,exports){
/**
* wp.media.view.Attachment.Details
*
'click .trash-attachment': 'trashAttachment',
'click .untrash-attachment': 'untrashAttachment',
'click .edit-attachment': 'editAttachment',
- 'click .refresh-attachment': 'refreshAttachment',
'keydown': 'toggleSelectionHandler'
},
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();
}
},
/**
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.
module.exports = Details;
-},{}],25:[function(require,module,exports){
-/*globals wp */
-
+},{}],27:[function(require,module,exports){
/**
* wp.media.view.Attachment.EditLibrary
*
module.exports = EditLibrary;
-},{}],26:[function(require,module,exports){
-/*globals wp */
-
+},{}],28:[function(require,module,exports){
/**
* wp.media.view.Attachments.EditSelection
*
module.exports = EditSelection;
-},{}],27:[function(require,module,exports){
-/*globals wp */
-
+},{}],29:[function(require,module,exports){
/**
* wp.media.view.Attachment.Library
*
module.exports = Library;
-},{}],28:[function(require,module,exports){
-/*globals wp */
-
+},{}],30:[function(require,module,exports){
/**
* wp.media.view.Attachment.Selection
*
module.exports = Selection;
-},{}],29:[function(require,module,exports){
-/*globals wp, _, jQuery */
-
+},{}],31:[function(require,module,exports){
/**
* wp.media.view.Attachments
*
initSortable: function() {
var collection = this.collection;
- if ( wp.media.isTouchDevice || ! this.options.sortable || ! $.fn.sortable ) {
+ if ( ! this.options.sortable || ! $.fn.sortable ) {
return;
}
},
refreshSortable: function() {
- if ( wp.media.isTouchDevice || ! this.options.sortable || ! $.fn.sortable ) {
+ if ( ! this.options.sortable || ! $.fn.sortable ) {
return;
}
module.exports = Attachments;
-},{}],30:[function(require,module,exports){
-/*globals wp, _, jQuery */
-
+},{}],32:[function(require,module,exports){
/**
* wp.media.view.AttachmentsBrowser
*
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();
+ this.createUploader();
+ this.createAttachments();
if ( this.options.sidebar ) {
this.createSidebar();
}
- this.createUploader();
- this.createAttachments();
this.updateContent();
if ( ! this.options.sidebar || 'errors' === this.options.sidebar ) {
});
// 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 );
module.exports = AttachmentsBrowser;
-},{}],31:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],33:[function(require,module,exports){
/**
* wp.media.view.Attachments.Selection
*
module.exports = Selection;
-},{}],32:[function(require,module,exports){
-/*globals _, Backbone */
-
+},{}],34:[function(require,module,exports){
/**
* wp.media.view.ButtonGroup
*
module.exports = ButtonGroup;
-},{}],33:[function(require,module,exports){
-/*globals _, Backbone */
-
+},{}],35:[function(require,module,exports){
/**
* wp.media.view.Button
*
* @augments Backbone.View
*/
var Button = wp.media.View.extend({
- tagName: 'a',
+ tagName: 'button',
className: 'media-button',
- attributes: { href: '#' },
+ attributes: { type: 'button' },
events: {
'click': 'click'
module.exports = Button;
-},{}],34:[function(require,module,exports){
-/*globals wp, _, jQuery */
-
+},{}],36:[function(require,module,exports){
/**
* wp.media.view.Cropper
*
module.exports = Cropper;
-},{}],35:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],37:[function(require,module,exports){
/**
* wp.media.view.EditImage
*
module.exports = EditImage;
-},{}],36:[function(require,module,exports){
+},{}],38:[function(require,module,exports){
/**
* wp.media.view.Embed
*
module.exports = Embed;
-},{}],37:[function(require,module,exports){
-/*globals wp */
-
+},{}],39:[function(require,module,exports){
/**
* wp.media.view.EmbedImage
*
module.exports = EmbedImage;
-},{}],38:[function(require,module,exports){
-/*globals wp, _, jQuery */
-
+},{}],40:[function(require,module,exports){
/**
* wp.media.view.EmbedLink
*
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 );
},
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 );
module.exports = EmbedLink;
-},{}],39:[function(require,module,exports){
-/*globals wp, _, jQuery */
-
+},{}],41:[function(require,module,exports){
/**
* wp.media.view.EmbedUrl
*
module.exports = EmbedUrl;
-},{}],40:[function(require,module,exports){
+},{}],42:[function(require,module,exports){
/**
* wp.media.view.FocusManager
*
module.exports = FocusManager;
-},{}],41:[function(require,module,exports){
-/*globals _, Backbone */
-
+},{}],43:[function(require,module,exports){
/**
* wp.media.view.Frame
*
module.exports = Frame;
-},{}],42:[function(require,module,exports){
-/*globals wp */
-
+},{}],44:[function(require,module,exports){
/**
* wp.media.view.MediaFrame.ImageDetails
*
module.exports = ImageDetails;
-},{}],43:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],45:[function(require,module,exports){
/**
* wp.media.view.MediaFrame.Post
*
module.exports = Post;
-},{}],44:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],46:[function(require,module,exports){
/**
* wp.media.view.MediaFrame.Select
*
module.exports = Select;
-},{}],45:[function(require,module,exports){
+},{}],47:[function(require,module,exports){
/**
* wp.media.view.Iframe
*
module.exports = Iframe;
-},{}],46:[function(require,module,exports){
-/*globals wp, _, jQuery */
-
+},{}],48:[function(require,module,exports){
/**
* wp.media.view.ImageDetails
*
module.exports = ImageDetails;
-},{}],47:[function(require,module,exports){
+},{}],49:[function(require,module,exports){
/**
* wp.media.view.Label
*
module.exports = Label;
-},{}],48:[function(require,module,exports){
-/*globals wp, _, jQuery */
-
+},{}],50:[function(require,module,exports){
/**
* wp.media.view.MediaFrame
*
module.exports = MediaFrame;
-},{}],49:[function(require,module,exports){
-/*globals jQuery */
-
+},{}],51:[function(require,module,exports){
/**
* wp.media.view.MenuItem
*
module.exports = MenuItem;
-},{}],50:[function(require,module,exports){
+},{}],52:[function(require,module,exports){
/**
* wp.media.view.Menu
*
module.exports = Menu;
-},{}],51:[function(require,module,exports){
-/*globals wp, _, jQuery */
-
+},{}],53:[function(require,module,exports){
/**
* wp.media.view.Modal
*
'keydown': 'keydown'
},
+ clickedOpenerEl: null,
+
initialize: function() {
_.defaults( this.options, {
container: document.body,
return this;
}
+ this.clickedOpenerEl = document.activeElement;
+
if ( ! this.views.attached ) {
this.attach();
}
// Hide modal and remove restricted media modal tab focus once it's closed
this.$el.hide().undelegate( 'keydown' );
- // Put focus back in useful location once modal is closed
- $('#wpbody-content').focus();
+ // Put focus back in useful location once modal is closed.
+ if ( null !== this.clickedOpenerEl ) {
+ this.clickedOpenerEl.focus();
+ } else {
+ $( '#wpbody-content' ).focus();
+ }
this.propagate('close');
module.exports = Modal;
-},{}],52:[function(require,module,exports){
-/*globals _, Backbone */
-
+},{}],54:[function(require,module,exports){
/**
* wp.media.view.PriorityList
*
module.exports = PriorityList;
-},{}],53:[function(require,module,exports){
+},{}],55:[function(require,module,exports){
/**
* wp.media.view.RouterItem
*
module.exports = RouterItem;
-},{}],54:[function(require,module,exports){
-/*globals wp */
-
+},{}],56:[function(require,module,exports){
/**
* wp.media.view.Router
*
module.exports = Router;
-},{}],55:[function(require,module,exports){
-/*globals wp */
-
+},{}],57:[function(require,module,exports){
/**
* wp.media.view.Search
*
attributes: {
type: 'search',
- placeholder: l10n.search
+ placeholder: l10n.searchMediaPlaceholder
},
events: {
module.exports = Search;
-},{}],56:[function(require,module,exports){
-/*globals wp, _, Backbone */
-
+},{}],58:[function(require,module,exports){
/**
* wp.media.view.Selection
*
module.exports = Selection;
-},{}],57:[function(require,module,exports){
-/*globals _, Backbone */
-
+},{}],59:[function(require,module,exports){
/**
* wp.media.view.Settings
*
module.exports = Settings;
-},{}],58:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],60:[function(require,module,exports){
/**
* wp.media.view.Settings.AttachmentDisplay
*
module.exports = AttachmentDisplay;
-},{}],59:[function(require,module,exports){
-/*globals wp */
-
+},{}],61:[function(require,module,exports){
/**
* wp.media.view.Settings.Gallery
*
module.exports = Gallery;
-},{}],60:[function(require,module,exports){
-/*globals wp */
-
+},{}],62:[function(require,module,exports){
/**
* wp.media.view.Settings.Playlist
*
module.exports = Playlist;
-},{}],61:[function(require,module,exports){
+},{}],63:[function(require,module,exports){
/**
* wp.media.view.Sidebar
*
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
*
module.exports = Spinner;
-},{}],63:[function(require,module,exports){
-/*globals _, Backbone */
-
+},{}],67:[function(require,module,exports){
/**
* wp.media.view.Toolbar
*
module.exports = Toolbar;
-},{}],64:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],68:[function(require,module,exports){
/**
* wp.media.view.Toolbar.Embed
*
module.exports = Embed;
-},{}],65:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],69:[function(require,module,exports){
/**
* wp.media.view.Toolbar.Select
*
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
*
this.$document.on( 'dragstart dragend drop', _.bind( function( event ) {
this.localDrag = event.type === 'dragstart';
+
+ if ( event.type === 'drop' ) {
+ this.containerDragleave();
+ }
}, this ) );
this.initialized = true;
}
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;
},
* @param {jQuery.Event} event The 'drop' event.
*/
drop: function( event ) {
- var $wrap = null, uploadView;
+ var $wrap, uploadView;
this.containerDragleave( event );
this.dropzoneDragleave( event );
}
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 {
module.exports = EditorUploader;
-},{}],67:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],71:[function(require,module,exports){
/**
* wp.media.view.UploaderInline
*
module.exports = UploaderInline;
-},{}],68:[function(require,module,exports){
-/*globals wp */
-
+},{}],72:[function(require,module,exports){
/**
* wp.media.view.UploaderStatusError
*
module.exports = UploaderStatusError;
-},{}],69:[function(require,module,exports){
-/*globals wp, _ */
-
+},{}],73:[function(require,module,exports){
/**
* wp.media.view.UploaderStatus
*
* @returns {string}
*/
filename: function( filename ) {
- return wp.media.truncate( _.escape( filename ), 24 );
+ return _.escape( filename );
},
/**
* @param {Backbone.Model} error
module.exports = UploaderStatus;
-},{}],70:[function(require,module,exports){
-/*globals wp, _, jQuery */
-
+},{}],74:[function(require,module,exports){
/**
* wp.media.view.UploaderWindow
*
module.exports = UploaderWindow;
-},{}],71:[function(require,module,exports){
-/*globals wp */
-
+},{}],75:[function(require,module,exports){
/**
* wp.media.View
*
module.exports = View;
-},{}]},{},[17]);
+},{}]},{},[19]);