From c1661ecbb3fbd48f2529c156f3d80b59e7a5b57a Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 22 May 2017 22:04:03 +0000 Subject: [PATCH] Widgets: Further refine WP JS coding style in media widgets code. Props afercia. See #32417. git-svn-id: https://develop.svn.wordpress.org/trunk@40821 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/widgets/media-audio-widget.js | 20 +++++++++---------- src/wp-admin/js/widgets/media-video-widget.js | 18 ++++++++--------- src/wp-admin/js/widgets/media-widgets.js | 16 +++++++-------- src/wp-admin/js/widgets/text-widgets.js | 8 ++++---- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/wp-admin/js/widgets/media-audio-widget.js b/src/wp-admin/js/widgets/media-audio-widget.js index 68ca64513f..1f98ef70cf 100644 --- a/src/wp-admin/js/widgets/media-audio-widget.js +++ b/src/wp-admin/js/widgets/media-audio-widget.js @@ -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; diff --git a/src/wp-admin/js/widgets/media-video-widget.js b/src/wp-admin/js/widgets/media-video-widget.js index 686336bf63..07b203fde4 100644 --- a/src/wp-admin/js/widgets/media-video-widget.js +++ b/src/wp-admin/js/widgets/media-video-widget.js @@ -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; diff --git a/src/wp-admin/js/widgets/media-widgets.js b/src/wp-admin/js/widgets/media-widgets.js index cdda5db222..584852a1dd 100644 --- a/src/wp-admin/js/widgets/media-widgets.js +++ b/src/wp-admin/js/widgets/media-widgets.js @@ -134,7 +134,7 @@ wp.mediaWidgets = ( function( $ ) { noticeContainer.empty(); noticeContainer.append( $( '

', { 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; }, diff --git a/src/wp-admin/js/widgets/text-widgets.js b/src/wp-admin/js/widgets/text-widgets.js index 2d3a5b812c..2108b65548 100644 --- a/src/wp-admin/js/widgets/text-widgets.js +++ b/src/wp-admin/js/widgets/text-widgets.js @@ -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; }