Fixed mixed spaces and tabs. Also remove trailing comma. see #26631.

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


git-svn-id: http://core.svn.wordpress.org/trunk@27123 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2014-02-25 17:32:14 +00:00
parent 6dcd5cc69e
commit 74f2a32f52
2 changed files with 230 additions and 230 deletions

View File

@ -292,26 +292,26 @@
* containing the 'props' for the gallery. * containing the 'props' for the gallery.
*/ */
return function( shortcode ) { return function( shortcode ) {
var shortcodeString = shortcode.string(), var shortcodeString = shortcode.string(),
result = cache[ shortcodeString ], result = cache[ shortcodeString ],
attrs, args, query, others; attrs, args, query, others;
delete cache[ shortcodeString ]; delete cache[ shortcodeString ];
if ( result ) { if ( result ) {
return result; return result;
} }
// Fill the default shortcode attributes. // Fill the default shortcode attributes.
attrs = _.defaults( shortcode.attrs.named, this.defaults ); attrs = _.defaults( shortcode.attrs.named, this.defaults );
args = _.pick( attrs, 'orderby', 'order' ); args = _.pick( attrs, 'orderby', 'order' );
args.type = type; args.type = type;
args.perPage = -1; args.perPage = -1;
// Mark the `orderby` override attribute. // Mark the `orderby` override attribute.
if ( undefined !== attrs.orderby ) { if ( undefined !== attrs.orderby ) {
attrs._orderByField = attrs.orderby; attrs._orderByField = attrs.orderby;
} }
if ( 'rand' === attrs.orderby ) { if ( 'rand' === attrs.orderby ) {
@ -358,40 +358,40 @@
}; };
}, },
shortcodeAttrs : function ( prop, attachments ) { shortcodeAttrs : function ( prop, attachments ) {
var props = attachments.props.toJSON(), var props = attachments.props.toJSON(),
attrs = _.pick( props, 'orderby', 'order', 'style' ); attrs = _.pick( props, 'orderby', 'order', 'style' );
if ( attachments[ prop ] ) { if ( attachments[ prop ] ) {
_.extend( attrs, attachments[ prop ].toJSON() ); _.extend( attrs, attachments[ prop ].toJSON() );
} }
// Convert all collection shortcodes to use the `ids` property. // Convert all collection shortcodes to use the `ids` property.
// Ignore `post__in` and `post__not_in`; the attachments in // Ignore `post__in` and `post__not_in`; the attachments in
// the collection will already reflect those properties. // the collection will already reflect those properties.
attrs.ids = attachments.pluck('id'); attrs.ids = attachments.pluck('id');
// Copy the `uploadedTo` post ID. // Copy the `uploadedTo` post ID.
if ( props.uploadedTo ) { if ( props.uploadedTo ) {
attrs.id = props.uploadedTo; attrs.id = props.uploadedTo;
} }
// Check if the collection is randomly ordered. // Check if the collection is randomly ordered.
delete attrs.orderby; delete attrs.orderby;
if ( attrs._orderbyRandom ) { if ( attrs._orderbyRandom ) {
attrs.orderby = 'rand'; attrs.orderby = 'rand';
} else if ( attrs._orderByField && attrs._orderByField != 'rand' ) { } else if ( attrs._orderByField && attrs._orderByField != 'rand' ) {
attrs.orderby = attrs._orderByField; attrs.orderby = attrs._orderByField;
} }
delete attrs._orderbyRandom; delete attrs._orderbyRandom;
delete attrs._orderByField; delete attrs._orderByField;
// If the `ids` attribute is set and `orderby` attribute // If the `ids` attribute is set and `orderby` attribute
// is the default value, clear it for cleaner output. // is the default value, clear it for cleaner output.
if ( attrs.ids && 'post__in' === attrs.orderby ) { if ( attrs.ids && 'post__in' === attrs.orderby ) {
delete attrs.orderby; delete attrs.orderby;
} }
if ( -1 !== jQuery.inArray( prop, ['playlist', 'video-playlist'] ) ) { if ( -1 !== jQuery.inArray( prop, ['playlist', 'video-playlist'] ) ) {
@ -405,46 +405,46 @@
}); });
} }
// Remove default attributes from the shortcode. // Remove default attributes from the shortcode.
_.each( wp.media[prop].defaults, function( value, key ) { _.each( wp.media[prop].defaults, function( value, key ) {
if ( value === attrs[ key ] ) { if ( value === attrs[ key ] ) {
delete attrs[ key ]; delete attrs[ key ];
} }
}); });
return attrs; return attrs;
}, },
editSelection : function ( prop, shortcode ) { editSelection : function ( prop, shortcode ) {
var defaultPostId = wp.media[ prop ].defaults.id, var defaultPostId = wp.media[ prop ].defaults.id,
attachments, selection; attachments, selection;
// Ignore the rest of the match object. // Ignore the rest of the match object.
shortcode = shortcode.shortcode; shortcode = shortcode.shortcode;
if ( _.isUndefined( shortcode.get('id') ) && ! _.isUndefined( defaultPostId ) ) { if ( _.isUndefined( shortcode.get('id') ) && ! _.isUndefined( defaultPostId ) ) {
shortcode.set( 'id', defaultPostId ); shortcode.set( 'id', defaultPostId );
} }
attachments = wp.media[ prop ].attachments( shortcode ); attachments = wp.media[ prop ].attachments( shortcode );
selection = new wp.media.model.Selection( attachments.models, { selection = new wp.media.model.Selection( attachments.models, {
props: attachments.props.toJSON(), props: attachments.props.toJSON(),
multiple: true multiple: true
}); });
selection[ prop ] = attachments[ prop ]; selection[ prop ] = attachments[ prop ];
// Fetch the query's attachments, and then break ties from the // Fetch the query's attachments, and then break ties from the
// query to allow for sorting. // query to allow for sorting.
selection.more().done( function() { selection.more().done( function() {
// Break ties with the query. // Break ties with the query.
selection.props.set({ query: false }); selection.props.set({ query: false });
selection.unmirror(); selection.unmirror();
selection.props.unset('orderby'); selection.props.unset('orderby');
}); });
return selection; return selection;
}, },
/** /**
* *
@ -453,36 +453,36 @@
* @param {wp.shortcode} shortcode * @param {wp.shortcode} shortcode
* @returns {wp.shortcode} * @returns {wp.shortcode}
*/ */
cacheShortcode : function ( prop, attachments, shortcode ) { cacheShortcode : function ( prop, attachments, shortcode ) {
// Use a cloned version of the playlist. // Use a cloned version of the playlist.
var clone = new wp.media.model.Attachments( attachments.models, { var clone = new wp.media.model.Attachments( attachments.models, {
props: attachments.props.toJSON() props: attachments.props.toJSON()
}); });
clone[ prop ] = attachments[ prop ]; clone[ prop ] = attachments[ prop ];
cache[ shortcode.string() ] = clone; cache[ shortcode.string() ] = clone;
return shortcode; return shortcode;
}, },
getEditFrame : function ( args ) { getEditFrame : function ( args ) {
// Destroy the previous gallery frame. // Destroy the previous gallery frame.
if ( this.frame ) { if ( this.frame ) {
this.frame.dispose(); this.frame.dispose();
} }
// Store the current gallery frame. // Store the current gallery frame.
this.frame = wp.media( _.extend( { this.frame = wp.media( _.extend( {
frame: 'post', frame: 'post',
editing: true, editing: true,
multiple: true, multiple: true
}, args ) ).open(); }, args ) ).open();
return this.frame; return this.frame;
}, },
instance : function ( prop, args ) { instance : function ( prop, args ) {
return { return {
attachments: this.attachments( prop, args.type ), attachments: this.attachments( prop, args.type ),
/** /**
* Triggered when clicking 'Insert {label}' or 'Update {label}' * Triggered when clicking 'Insert {label}' or 'Update {label}'
* *
@ -495,14 +495,14 @@
* containing the 'props' for the gallery. * containing the 'props' for the gallery.
* @returns {wp.shortcode} * @returns {wp.shortcode}
*/ */
shortcode: function( attachments ) { shortcode: function( attachments ) {
var shortcode = new wp.shortcode({ var shortcode = new wp.shortcode({
tag: prop, tag: prop,
attrs: wp.media.collection.shortcodeAttrs( prop, attachments ), attrs: wp.media.collection.shortcodeAttrs( prop, attachments ),
type: 'single' type: 'single'
}); });
return wp.media.collection.cacheShortcode( prop, attachments, shortcode ); return wp.media.collection.cacheShortcode( prop, attachments, shortcode );
}, },
/** /**
* Triggered when double-clicking a collection shortcode placeholder * Triggered when double-clicking a collection shortcode placeholder
@ -519,44 +519,44 @@
* *
* @returns {wp.media.view.MediaFrame.Select} A media workflow. * @returns {wp.media.view.MediaFrame.Select} A media workflow.
*/ */
edit: function( content ) { edit: function( content ) {
var shortcode = wp.shortcode.next( prop, content ); var shortcode = wp.shortcode.next( prop, content );
// Bail if we didn't match the shortcode or all of the content. // Bail if we didn't match the shortcode or all of the content.
if ( ! shortcode || shortcode.content !== content ) { if ( ! shortcode || shortcode.content !== content ) {
return; return;
} }
return wp.media.collection.getEditFrame( { return wp.media.collection.getEditFrame( {
title: args.title, title: args.title,
state: prop + '-edit', state: prop + '-edit',
selection: wp.media.collection.editSelection( prop, shortcode ) selection: wp.media.collection.editSelection( prop, shortcode )
} ); } );
} }
}; };
} }
}; };
wp.media.gallery = (function() { wp.media.gallery = (function() {
var gallery = { var gallery = {
defaults : { defaults : {
itemtag: 'dl', itemtag: 'dl',
icontag: 'dt', icontag: 'dt',
captiontag: 'dd', captiontag: 'dd',
columns: '3', columns: '3',
link: 'post', link: 'post',
size: 'thumbnail', size: 'thumbnail',
order: 'ASC', order: 'ASC',
id: wp.media.view.settings.post.id, id: wp.media.view.settings.post.id,
orderby : 'menu_order ID' orderby : 'menu_order ID'
} }
}; };
return _.extend(gallery, wp.media.collection.instance( 'gallery', { return _.extend(gallery, wp.media.collection.instance( 'gallery', {
type : 'image', type : 'image',
title : wp.media.view.l10n.editGalleryTitle title : wp.media.view.l10n.editGalleryTitle
})); }));
}()); }());
wp.media.playlist = (function() { wp.media.playlist = (function() {
var playlist = { var playlist = {

View File

@ -767,102 +767,102 @@
* @param {object} args * @param {object} args
* @returns {wp.media.controller.Library} * @returns {wp.media.controller.Library}
*/ */
media.controller.CollectionEdit = function ( prop, args ) { media.controller.CollectionEdit = function ( prop, args ) {
/** /**
* @constructor * @constructor
* @augments wp.media.controller.Library * @augments wp.media.controller.Library
* @augments wp.media.controller.State * @augments wp.media.controller.State
* @augments Backbone.Model * @augments Backbone.Model
*/ */
return media.controller.Library.extend({ return media.controller.Library.extend({
defaults : _.defaults(args.defaults || {}, { defaults : _.defaults(args.defaults || {}, {
id: prop + '-edit', id: prop + '-edit',
toolbar: prop + '-edit', toolbar: prop + '-edit',
multiple: false, multiple: false,
describe: true, describe: true,
edge: 199, edge: 199,
editing: false, editing: false,
sortable: true, sortable: true,
searchable: false, searchable: false,
content: 'browse', content: 'browse',
priority: 60, priority: 60,
dragInfo: true, dragInfo: true,
// Don't sync the selection, as the Edit {Collection} library // Don't sync the selection, as the Edit {Collection} library
// *is* the selection. // *is* the selection.
syncSelection: false syncSelection: false
}), }),
initialize: function() { initialize: function() {
// If we haven't been provided a `library`, create a `Selection`. // If we haven't been provided a `library`, create a `Selection`.
if ( ! this.get('library') ) { if ( ! this.get('library') ) {
this.set( 'library', new media.model.Selection() ); this.set( 'library', new media.model.Selection() );
} }
// The single `Attachment` view to be used in the `Attachments` view. // The single `Attachment` view to be used in the `Attachments` view.
if ( ! this.get('AttachmentView') ) { if ( ! this.get('AttachmentView') ) {
this.set( 'AttachmentView', media.view.Attachment.EditLibrary ); this.set( 'AttachmentView', media.view.Attachment.EditLibrary );
} }
media.controller.Library.prototype.initialize.apply( this, arguments ); media.controller.Library.prototype.initialize.apply( this, arguments );
}, },
activate: function() { activate: function() {
var library = this.get('library'); var library = this.get('library');
// Limit the library to images only. // Limit the library to images only.
library.props.set( 'type', args.type ); library.props.set( 'type', args.type );
// Watch for uploaded attachments. // Watch for uploaded attachments.
this.get('library').observe( wp.Uploader.queue ); this.get('library').observe( wp.Uploader.queue );
this.frame.on( 'content:render:browse', this.settings, this ); this.frame.on( 'content:render:browse', this.settings, this );
media.controller.Library.prototype.activate.apply( this, arguments ); media.controller.Library.prototype.activate.apply( this, arguments );
}, },
deactivate: function() { deactivate: function() {
// Stop watching for uploaded attachments. // Stop watching for uploaded attachments.
this.get('library').unobserve( wp.Uploader.queue ); this.get('library').unobserve( wp.Uploader.queue );
this.frame.off( 'content:render:browse', this.settings, this ); this.frame.off( 'content:render:browse', this.settings, this );
media.controller.Library.prototype.deactivate.apply( this, arguments ); media.controller.Library.prototype.deactivate.apply( this, arguments );
}, },
settings: function( browser ) { settings: function( browser ) {
var library = this.get('library'), obj = {}; var library = this.get('library'), obj = {};
if ( ! library || ! browser ) { if ( ! library || ! browser ) {
return; return;
} }
library[ prop ] = library[ prop ] || new Backbone.Model(); library[ prop ] = library[ prop ] || new Backbone.Model();
obj[ prop ] = new media.view.Settings[ args.settings ]({ obj[ prop ] = new media.view.Settings[ args.settings ]({
controller: this, controller: this,
model: library[ prop ], model: library[ prop ],
priority: 40 priority: 40
}); });
browser.sidebar.set( obj ); browser.sidebar.set( obj );
if ( args.dragInfoText ) { if ( args.dragInfoText ) {
browser.toolbar.set( 'dragInfo', new media.View({ browser.toolbar.set( 'dragInfo', new media.View({
el: $( '<div class="instructions">' + args.dragInfoText + '</div>' )[0], el: $( '<div class="instructions">' + args.dragInfoText + '</div>' )[0],
priority: -40 priority: -40
}) ); }) );
} }
browser.toolbar.set( 'reverse', { browser.toolbar.set( 'reverse', {
text: l10n.reverseOrder, text: l10n.reverseOrder,
priority: 80, priority: 80,
click: function() { click: function() {
library.reset( library.toArray().reverse() ); library.reset( library.toArray().reverse() );
} }
}); });
} }
}); });
}; };
/** /**
* wp.media.controller.CollectionAdd * wp.media.controller.CollectionAdd
@ -872,56 +872,56 @@
* @param {object} args * @param {object} args
* @returns {wp.media.controller.Library} * @returns {wp.media.controller.Library}
*/ */
media.controller.CollectionAdd = function ( prop, args ) { media.controller.CollectionAdd = function ( prop, args ) {
/** /**
* @constructor * @constructor
* @augments wp.media.controller.Library * @augments wp.media.controller.Library
* @augments wp.media.controller.State * @augments wp.media.controller.State
* @augments Backbone.Model * @augments Backbone.Model
*/ */
return media.controller.Library.extend({ return media.controller.Library.extend({
defaults: _.defaults({ defaults: _.defaults({
id: prop + '-library', id: prop + '-library',
filterable: 'uploaded', filterable: 'uploaded',
multiple: 'add', multiple: 'add',
menu: prop, menu: prop,
toolbar: prop + '-add', toolbar: prop + '-add',
priority: 100, priority: 100,
syncSelection: false syncSelection: false
}, args.defaults || {}, media.controller.Library.prototype.defaults ), }, args.defaults || {}, media.controller.Library.prototype.defaults ),
initialize: function() { initialize: function() {
// If we haven't been provided a `library`, create a `Selection`. // If we haven't been provided a `library`, create a `Selection`.
if ( ! this.get('library') ) { if ( ! this.get('library') ) {
this.set( 'library', media.query({ type: args.type }) ); this.set( 'library', media.query({ type: args.type }) );
} }
media.controller.Library.prototype.initialize.apply( this, arguments ); media.controller.Library.prototype.initialize.apply( this, arguments );
}, },
activate: function() { activate: function() {
var library = this.get('library'), var library = this.get('library'),
edit = this.frame.state(prop + '-edit').get('library'); edit = this.frame.state(prop + '-edit').get('library');
if ( this.editLibrary && this.editLibrary !== edit ) { if ( this.editLibrary && this.editLibrary !== edit ) {
library.unobserve( this.editLibrary ); library.unobserve( this.editLibrary );
} }
// Accepts attachments that exist in the original library and // Accepts attachments that exist in the original library and
// that do not exist in gallery's library. // that do not exist in gallery's library.
library.validator = function( attachment ) { library.validator = function( attachment ) {
return !! this.mirroring.get( attachment.cid ) && ! edit.get( attachment.cid ) && media.model.Selection.prototype.validator.apply( this, arguments ); return !! this.mirroring.get( attachment.cid ) && ! edit.get( attachment.cid ) && media.model.Selection.prototype.validator.apply( this, arguments );
}; };
// Reset the library to ensure that all attachments are re-added // Reset the library to ensure that all attachments are re-added
// to the collection. Do so silently, as calling `observe` will // to the collection. Do so silently, as calling `observe` will
// trigger the `reset` event. // trigger the `reset` event.
library.reset( library.mirroring.models, { silent: true }); library.reset( library.mirroring.models, { silent: true });
library.observe( edit ); library.observe( edit );
this.editLibrary = edit; this.editLibrary = edit;
media.controller.Library.prototype.activate.apply( this, arguments ); media.controller.Library.prototype.activate.apply( this, arguments );
} }
}); });
}; };
// wp.media.controller.GalleryEdit // wp.media.controller.GalleryEdit
// ------------------------------- // -------------------------------
@ -1874,9 +1874,9 @@
this.on( 'menu:create:playlist', this.createMenu, this ); this.on( 'menu:create:playlist', this.createMenu, this );
this.on( 'menu:create:video-playlist', this.createMenu, this ); this.on( 'menu:create:video-playlist', this.createMenu, this );
this.on( 'toolbar:create:main-insert', this.createToolbar, this ); this.on( 'toolbar:create:main-insert', this.createToolbar, this );
this.on( 'toolbar:create:main-gallery', this.createToolbar, this ); this.on( 'toolbar:create:main-gallery', this.createToolbar, this );
this.on( 'toolbar:create:main-playlist', this.createToolbar, this ); this.on( 'toolbar:create:main-playlist', this.createToolbar, this );
this.on( 'toolbar:create:main-video-playlist', this.createToolbar, this ); this.on( 'toolbar:create:main-video-playlist', this.createToolbar, this );
this.on( 'toolbar:create:featured-image', this.featuredImageToolbar, this ); this.on( 'toolbar:create:featured-image', this.featuredImageToolbar, this );
this.on( 'toolbar:create:main-embed', this.mainEmbedToolbar, this ); this.on( 'toolbar:create:main-embed', this.mainEmbedToolbar, this );