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

View File

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