Widgets: Further refine WP JS coding style in media widgets code.

Props afercia.
See #32417.

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


git-svn-id: http://core.svn.wordpress.org/trunk@40678 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2017-05-22 22:05:42 +00:00
parent e083a1aff7
commit 6e935e7f20
5 changed files with 32 additions and 32 deletions

View File

@ -19,18 +19,18 @@
*/
createStates: function createStates() {
this.states.add([
new wp.media.controller.AudioDetails( {
new wp.media.controller.AudioDetails({
media: this.media
} ),
}),
new wp.media.controller.MediaLibrary( {
new wp.media.controller.MediaLibrary({
type: 'audio',
id: 'add-audio-source',
title: wp.media.view.l10n.audioAddSourceTitle,
toolbar: 'add-audio-source',
media: this.media,
menu: false
} )
})
]);
}
});
@ -43,7 +43,7 @@
* @class AudioWidgetModel
* @constructor
*/
AudioWidgetModel = component.MediaWidgetModel.extend( {} );
AudioWidgetModel = component.MediaWidgetModel.extend({});
/**
* Audio widget control.
@ -53,7 +53,7 @@
* @class AudioWidgetModel
* @constructor
*/
AudioWidgetControl = component.MediaWidgetControl.extend( {
AudioWidgetControl = component.MediaWidgetControl.extend({
/**
* Show display settings.
@ -92,13 +92,13 @@
previewContainer = control.$el.find( '.media-widget-preview' );
previewTemplate = wp.template( 'wp-media-widget-audio-preview' );
previewContainer.html( previewTemplate( {
previewContainer.html( previewTemplate({
model: {
attachment_id: control.model.get( 'attachment_id' ),
src: attachmentUrl
},
error: control.model.get( 'error' )
} ) );
}));
wp.mediaelement.initialize();
},
@ -117,7 +117,7 @@
frame: 'audio',
state: 'audio-details',
metadata: metadata
} );
});
wp.media.frame = mediaFrame;
mediaFrame.$el.addClass( 'media-widget' );
@ -141,7 +141,7 @@
mediaFrame.open();
}
} );
});
// Exports.
component.controlConstructors.media_audio = AudioWidgetControl;

View File

@ -23,23 +23,23 @@
media: this.media
}),
new wp.media.controller.MediaLibrary( {
new wp.media.controller.MediaLibrary({
type: 'video',
id: 'add-video-source',
title: wp.media.view.l10n.videoAddSourceTitle,
toolbar: 'add-video-source',
media: this.media,
menu: false
} ),
}),
new wp.media.controller.MediaLibrary( {
new wp.media.controller.MediaLibrary({
type: 'text',
id: 'add-track',
title: wp.media.view.l10n.videoAddTrackTitle,
toolbar: 'add-track',
media: this.media,
menu: 'video-details'
} )
})
]);
}
});
@ -52,7 +52,7 @@
* @class VideoWidgetModel
* @constructor
*/
VideoWidgetModel = component.MediaWidgetModel.extend( {} );
VideoWidgetModel = component.MediaWidgetModel.extend({});
/**
* Video widget control.
@ -62,7 +62,7 @@
* @class VideoWidgetControl
* @constructor
*/
VideoWidgetControl = component.MediaWidgetControl.extend( {
VideoWidgetControl = component.MediaWidgetControl.extend({
/**
* Show display settings.
@ -181,7 +181,7 @@
previewContainer = control.$el.find( '.media-widget-preview' );
previewTemplate = wp.template( 'wp-media-widget-video-preview' );
previewContainer.html( previewTemplate( {
previewContainer.html( previewTemplate({
model: {
attachment_id: control.model.get( 'attachment_id' ),
src: attachmentUrl,
@ -189,7 +189,7 @@
},
is_hosted_embed: isHostedEmbed,
error: error
} ) );
}));
wp.mediaelement.initialize();
},
@ -232,7 +232,7 @@
mediaFrame.open();
}
} );
});
// Exports.
component.controlConstructors.media_video = VideoWidgetControl;

View File

@ -134,7 +134,7 @@ wp.mediaWidgets = ( function( $ ) {
noticeContainer.empty();
noticeContainer.append( $( '<p>', {
html: notice
} ) );
}));
noticeContainer.slideDown( 'fast' );
}
},
@ -217,7 +217,7 @@ wp.mediaWidgets = ( function( $ ) {
*
* @returns {void}
*/
renderFail: function renderFail( ) {
renderFail: function renderFail() {
var embedLinkView = this; // eslint-disable-line consistent-this
$( '#embed-url-field' ).addClass( 'invalid' );
embedLinkView.setErrorNotice( embedLinkView.controller.options.invalidEmbedTypeError || 'ERROR' );
@ -230,7 +230,7 @@ wp.mediaWidgets = ( function( $ ) {
controller: this.controller,
model: this.model.props,
priority: 40
}) );
}));
}
});
@ -258,7 +258,7 @@ wp.mediaWidgets = ( function( $ ) {
mime = specificMimes.join( ',' );
}
this.states.add( [
this.states.add([
// Main states.
new component.PersistentDisplaySettingsLibrary({
@ -287,7 +287,7 @@ wp.mediaWidgets = ( function( $ ) {
type: 'image' === this.options.mimeType ? 'image' : 'link',
invalidEmbedTypeError: this.options.invalidEmbedTypeError
})
] );
]);
},
/**
@ -643,7 +643,7 @@ wp.mediaWidgets = ( function( $ ) {
var control = this, selection, mediaFrame, defaultSync, mediaFrameProps;
if ( control.isSelected() && 0 !== control.model.get( 'attachment_id' ) ) {
selection = new wp.media.model.Selection( [ control.selectedAttachment ] );
selection = new wp.media.model.Selection([ control.selectedAttachment ]);
} else {
selection = null;
}
@ -745,7 +745,7 @@ wp.mediaWidgets = ( function( $ ) {
{ attachment_id: 0 }, // Because some media frames use `attachment_id` not `id`.
control.model.getEmbedResetProps()
);
} else {
} else {
throw new Error( 'Unexpected state: ' + state.get( 'id' ) );
}
@ -760,7 +760,7 @@ wp.mediaWidgets = ( function( $ ) {
if ( ext in control.model.schema && modelProps.url !== modelProps[ ext ] ) {
modelProps[ ext ] = '';
}
} );
});
return modelProps;
},

View File

@ -125,7 +125,7 @@ wp.textWidgets = ( function( $ ) {
}
// Destroy any existing editor so that it can be re-initialized after a widget-updated event.
if ( tinymce.get( id ) ) {
if ( tinymce.get( id ) ) {
restoreTextMode = tinymce.get( id ).isHidden();
wp.editor.remove( id );
}
@ -135,7 +135,7 @@ wp.textWidgets = ( function( $ ) {
wpautop: true
},
quicktags: true
} );
});
editor = window.tinymce.get( id );
if ( ! editor ) {
@ -190,12 +190,12 @@ wp.textWidgets = ( function( $ ) {
};
editor.on( 'focus', function() {
control.editorFocused = true;
} );
});
editor.on( 'NodeChange', _.debounce( triggerChangeIfDirty, changeDebounceDelay ) );
editor.on( 'blur', function() {
control.editorFocused = false;
triggerChangeIfDirty();
} );
});
control.editor = editor;
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.8-beta2-40820';
$wp_version = '4.8-beta2-40821';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.