PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.7
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.7
16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 All 506 releases
← All changes | modules/videopress/js/editor-view.js +31 -43 13.5.2 → 16.3-a.7 View file →
@@ -80,9 +80,9 @@
80 80 /**
81 81 * Override TextBox renderHtml to support html5 attrs.
82 82 * @link https://github.com/tinymce/tinymce/pull/2784
83 83 *
84 - * @returns {string}
84 + * @return {string}
85 85 */
86 86 tinyMCE.ui.TextBox.prototype.renderHtml = function () {
87 87 var self = this,
88 88 settings = self.settings,
@@ -129,30 +129,23 @@
129 129 return element.outerHTML;
130 130 };
131 131
132 132 tinyMCE.ui.FormItem.prototype.renderHtml = function () {
133 - _.each(
134 - vpEditorView.modal_labels,
135 - function ( value, key ) {
136 - if ( value === this.settings.items.text ) {
137 - this.classes.add( 'videopress-field-' + key );
138 - }
139 - },
140 - this
141 - );
133 + for ( const [ key, value ] of Object.entries( vpEditorView.modal_labels ) ) {
134 + if ( value === this.settings.items.text ) {
135 + this.classes.add( 'videopress-field-' + key );
136 + }
137 + }
142 138
143 139 if (
144 - _.contains(
145 - [
146 - vpEditorView.modal_labels.hd,
147 - vpEditorView.modal_labels.permalink,
148 - vpEditorView.modal_labels.autoplay,
149 - vpEditorView.modal_labels.loop,
150 - vpEditorView.modal_labels.freedom,
151 - vpEditorView.modal_labels.flashonly,
152 - ],
153 - this.settings.items.text
154 - )
140 + [
141 + vpEditorView.modal_labels.hd,
142 + vpEditorView.modal_labels.permalink,
143 + vpEditorView.modal_labels.autoplay,
144 + vpEditorView.modal_labels.loop,
145 + vpEditorView.modal_labels.freedom,
146 + vpEditorView.modal_labels.flashonly,
147 + ].includes( this.settings.items.text )
155 148 ) {
156 149 this.classes.add( 'videopress-checkbox' );
157 150 }
158 151 return oldRenderFormItem.call( this );
@@ -160,15 +153,11 @@
160 153
161 154 /**
162 155 * Populate the defaults.
163 156 */
164 - _.each(
165 - this.defaults,
166 - function ( value, key ) {
167 - named[ key ] = this.coerce( named, key );
168 - },
169 - this
170 - );
157 + for ( const [ key ] of Object.entries( this.defaults ) ) {
158 + named[ key ] = this.coerce( named, key );
159 + }
171 160
172 161 /**
173 162 * Declare the fields that will show in the popup when editing the shortcode.
174 163 */
@@ -242,9 +231,11 @@
242 231 var args = {
243 232 tag: renderer.shortcode_string,
244 233 type: 'single',
245 234 attrs: {
246 - named: _.pick( e.data, _.keys( renderer.defaults ) ),
235 + named: Object.fromEntries(
236 + Object.entries( e.data ).filter( ( [ k ] ) => k in renderer.defaults )
237 + ),
247 238 numeric: [ e.data.guid ],
248 239 },
249 240 };
250 241
@@ -251,25 +242,21 @@
251 242 if ( '0' === args.attrs.named.at ) {
252 243 args.attrs.named.at = '';
253 244 }
254 245
255 - _.each(
256 - renderer.defaults,
257 - function ( value, key ) {
258 - args.attrs.named[ key ] = this.coerce( args.attrs.named, key );
246 + for ( const [ key, value ] of Object.entries( renderer.defaults ) ) {
247 + args.attrs.named[ key ] = renderer.coerce( args.attrs.named, key );
259 248
260 - if ( value === args.attrs.named[ key ] ) {
261 - delete args.attrs.named[ key ];
262 - }
263 - },
264 - renderer
265 - );
249 + if ( value === args.attrs.named[ key ] ) {
250 + delete args.attrs.named[ key ];
251 + }
252 + }
266 253
267 254 editor.insertContent( wp.shortcode.string( args ) );
268 255 },
269 256 onopen: function ( e ) {
270 257 var prefix = 'mce-videopress-field-';
271 - _.each( [ 'w', 'at' ], function ( value ) {
258 + for ( const value of [ 'w', 'at' ] ) {
272 259 e.target.$el
273 260 .find( '.' + prefix + value + ' .mce-container-body' )
274 261 .append(
275 262 '<span class="' +
@@ -280,9 +267,9 @@
280 267 value +
281 268 '">' +
282 269 vpEditorView.modal_labels[ value + '_unit' ]
283 270 );
284 - } );
271 + }
285 272 $( 'body' ).addClass( 'modal-open' );
286 273 },
287 274 onclose: function () {
288 275 $( 'body' ).removeClass( 'modal-open' );
@@ -292,12 +279,13 @@
292 279 // Set it back to its original renderer.
293 280 tinyMCE.ui.FormItem.prototype.renderHtml = oldRenderFormItem;
294 281 },
295 282 };
296 - wp.mce.views.register( 'videopress', wp.mce.videopress_wp_view_renderer );
297 283
298 284 // Extend the videopress one to also handle `wpvideo` instances.
299 - wp.mce.wpvideo_wp_view_renderer = _.extend( {}, wp.mce.videopress_wp_view_renderer, {
285 + wp.mce.wpvideo_wp_view_renderer = Object.assign( {}, wp.mce.videopress_wp_view_renderer, {
300 286 shortcode_string: 'wpvideo',
301 287 } );
288 +
289 + wp.mce.views.register( 'videopress', wp.mce.videopress_wp_view_renderer );
302 290 wp.mce.views.register( 'wpvideo', wp.mce.wpvideo_wp_view_renderer );
303 291 } )( jQuery, wp, vpEditorView );