equal
deleted
inserted
replaced
57 control.customHtmlWidgetPointer = control.$el.find( '.wp-pointer.custom-html-widget-pointer' ); |
57 control.customHtmlWidgetPointer = control.$el.find( '.wp-pointer.custom-html-widget-pointer' ); |
58 if ( control.customHtmlWidgetPointer.length ) { |
58 if ( control.customHtmlWidgetPointer.length ) { |
59 control.customHtmlWidgetPointer.find( '.close' ).on( 'click', function( event ) { |
59 control.customHtmlWidgetPointer.find( '.close' ).on( 'click', function( event ) { |
60 event.preventDefault(); |
60 event.preventDefault(); |
61 control.customHtmlWidgetPointer.hide(); |
61 control.customHtmlWidgetPointer.hide(); |
62 $( '#' + control.fields.text.attr( 'id' ) + '-html' ).focus(); |
62 $( '#' + control.fields.text.attr( 'id' ) + '-html' ).trigger( 'focus' ); |
63 control.dismissPointers( [ 'text_widget_custom_html' ] ); |
63 control.dismissPointers( [ 'text_widget_custom_html' ] ); |
64 }); |
64 }); |
65 control.customHtmlWidgetPointer.find( '.add-widget' ).on( 'click', function( event ) { |
65 control.customHtmlWidgetPointer.find( '.add-widget' ).on( 'click', function( event ) { |
66 event.preventDefault(); |
66 event.preventDefault(); |
67 control.customHtmlWidgetPointer.hide(); |
67 control.customHtmlWidgetPointer.hide(); |
159 if ( control.fields.text.is( ':visible' ) ) { |
159 if ( control.fields.text.is( ':visible' ) ) { |
160 if ( ! control.fields.text.is( document.activeElement ) ) { |
160 if ( ! control.fields.text.is( document.activeElement ) ) { |
161 control.fields.text.val( syncInput.val() ); |
161 control.fields.text.val( syncInput.val() ); |
162 } |
162 } |
163 } else if ( control.editor && ! control.editorFocused && syncInput.val() !== control.fields.text.val() ) { |
163 } else if ( control.editor && ! control.editorFocused && syncInput.val() !== control.fields.text.val() ) { |
164 control.editor.setContent( wp.editor.autop( syncInput.val() ) ); |
164 control.editor.setContent( wp.oldEditor.autop( syncInput.val() ) ); |
165 } |
165 } |
166 }, |
166 }, |
167 |
167 |
168 /** |
168 /** |
169 * Initialize editor. |
169 * Initialize editor. |
235 return; |
235 return; |
236 } |
236 } |
237 |
237 |
238 // The user has disabled TinyMCE. |
238 // The user has disabled TinyMCE. |
239 if ( typeof window.tinymce === 'undefined' ) { |
239 if ( typeof window.tinymce === 'undefined' ) { |
240 wp.editor.initialize( id, { |
240 wp.oldEditor.initialize( id, { |
241 quicktags: true, |
241 quicktags: true, |
242 mediaButtons: true |
242 mediaButtons: true |
243 }); |
243 }); |
244 |
244 |
245 return; |
245 return; |
246 } |
246 } |
247 |
247 |
248 // Destroy any existing editor so that it can be re-initialized after a widget-updated event. |
248 // Destroy any existing editor so that it can be re-initialized after a widget-updated event. |
249 if ( tinymce.get( id ) ) { |
249 if ( tinymce.get( id ) ) { |
250 restoreTextMode = tinymce.get( id ).isHidden(); |
250 restoreTextMode = tinymce.get( id ).isHidden(); |
251 wp.editor.remove( id ); |
251 wp.oldEditor.remove( id ); |
252 } |
252 } |
253 |
253 |
254 // Add or enable the `wpview` plugin. |
254 // Add or enable the `wpview` plugin. |
255 $( document ).one( 'wp-before-tinymce-init.text-widget-init', function( event, init ) { |
255 $( document ).one( 'wp-before-tinymce-init.text-widget-init', function( event, init ) { |
256 // If somebody has removed all plugins, they must have a good reason. |
256 // If somebody has removed all plugins, they must have a good reason. |
260 } else if ( ! /\bwpview\b/.test( init.plugins ) ) { |
260 } else if ( ! /\bwpview\b/.test( init.plugins ) ) { |
261 init.plugins += ',wpview'; |
261 init.plugins += ',wpview'; |
262 } |
262 } |
263 } ); |
263 } ); |
264 |
264 |
265 wp.editor.initialize( id, { |
265 wp.oldEditor.initialize( id, { |
266 tinymce: { |
266 tinymce: { |
267 wpautop: true |
267 wpautop: true |
268 }, |
268 }, |
269 quicktags: true, |
269 quicktags: true, |
270 mediaButtons: true |
270 mediaButtons: true |
276 * @param {jQuery} pointerElement Pointer element. |
276 * @param {jQuery} pointerElement Pointer element. |
277 * @return {void} |
277 * @return {void} |
278 */ |
278 */ |
279 showPointerElement = function( pointerElement ) { |
279 showPointerElement = function( pointerElement ) { |
280 pointerElement.show(); |
280 pointerElement.show(); |
281 pointerElement.find( '.close' ).focus(); |
281 pointerElement.find( '.close' ).trigger( 'focus' ); |
282 wp.a11y.speak( pointerElement.find( 'h3, p' ).map( function() { |
282 wp.a11y.speak( pointerElement.find( 'h3, p' ).map( function() { |
283 return $( this ).text(); |
283 return $( this ).text(); |
284 } ).get().join( '\n\n' ) ); |
284 } ).get().join( '\n\n' ) ); |
285 }; |
285 }; |
286 |
286 |
449 widgetForm = $( '.editwidget > form' ); |
449 widgetForm = $( '.editwidget > form' ); |
450 if ( 0 === widgetForm.length ) { |
450 if ( 0 === widgetForm.length ) { |
451 return; |
451 return; |
452 } |
452 } |
453 |
453 |
454 idBase = widgetForm.find( '> .widget-control-actions > .id_base' ).val(); |
454 idBase = widgetForm.find( '.id_base' ).val(); |
455 if ( -1 === component.idBases.indexOf( idBase ) ) { |
455 if ( -1 === component.idBases.indexOf( idBase ) ) { |
456 return; |
456 return; |
457 } |
457 } |
458 |
458 |
459 // Bypass using TinyMCE when widget is in legacy mode. |
459 // Bypass using TinyMCE when widget is in legacy mode. |
540 var widgetContainer = $( this ); |
540 var widgetContainer = $( this ); |
541 component.handleWidgetAdded( new jQuery.Event( 'widget-added' ), widgetContainer ); |
541 component.handleWidgetAdded( new jQuery.Event( 'widget-added' ), widgetContainer ); |
542 }); |
542 }); |
543 |
543 |
544 // Accessibility mode. |
544 // Accessibility mode. |
545 $( window ).on( 'load', function() { |
545 component.setupAccessibleMode(); |
546 component.setupAccessibleMode(); |
|
547 }); |
|
548 }); |
546 }); |
549 }; |
547 }; |
550 |
548 |
551 return component; |
549 return component; |
552 })( jQuery ); |
550 })( jQuery ); |