Changeset 26945
- Timestamp:
- 01/14/2014 11:34:23 PM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/media-upload.js
r26876 r26945 4 4 var wpActiveEditor, send_to_editor; 5 5 6 send_to_editor = function(h) { 7 var ed, mce = typeof(tinymce) != 'undefined', qt = typeof(QTags) != 'undefined'; 6 send_to_editor = function( html ) { 7 var editor, 8 hasTinymce = typeof tinymce !== 'undefined', 9 hasQuicktags = typeof QTags !== 'undefined'; 8 10 9 11 if ( ! wpActiveEditor ) { 10 if ( mce && tinymce.activeEditor ) {11 ed = tinymce.activeEditor;12 wpActiveEditor = ed .id;13 } else if ( ! qt) {12 if ( hasTinymce && tinymce.activeEditor ) { 13 editor = tinymce.activeEditor; 14 wpActiveEditor = editor.id; 15 } else if ( ! hasQuicktags ) { 14 16 return false; 15 17 } 16 } else if ( mce ) {17 ed = tinymce.get( wpActiveEditor );18 } else if ( hasTinymce ) { 19 editor = tinymce.get( wpActiveEditor ); 18 20 } 19 21 20 if ( ed && ! ed.isHidden() ) { 21 // restore caret position on IE 22 // if ( tinymce.isIE && ed.windowManager.insertimagebookmark ) 23 // ed.selection.moveToBookmark(ed.windowManager.insertimagebookmark); 24 25 if ( h.indexOf('[caption') !== -1 ) { 26 if ( ed.wpSetImgCaption ) 27 h = ed.wpSetImgCaption(h); 28 } else if ( h.indexOf('[gallery') !== -1 ) { 29 if ( ed.plugins.wpgallery ) 30 h = ed.plugins.wpgallery._do_gallery(h); 31 } else if ( h.indexOf('[embed') === 0 ) { 32 if ( ed.plugins.wordpress ) 33 h = ed.plugins.wordpress._setEmbed(h); 34 } 35 36 ed.execCommand('mceInsertContent', false, h); 37 } else if ( qt ) { 38 QTags.insertContent(h); 22 if ( editor && ! editor.isHidden() ) { 23 editor.execCommand( 'mceInsertContent', false, html ); 24 } else if ( hasQuicktags ) { 25 QTags.insertContent( html ); 39 26 } else { 40 document.getElementById( wpActiveEditor).value += h;27 document.getElementById( wpActiveEditor ).value += html; 41 28 } 42 29 43 try{tb_remove();}catch(e){} 30 // If the old thickbox remove function exists, call it 31 if ( window.tb_remove ) { 32 try { window.tb_remove(); } catch( e ) {} 33 } 44 34 }; 45 35 … … 76 66 77 67 $(window).resize(function(){ tb_position(); }); 78 /*79 // store caret position in IE80 $(document).ready(function($){81 $('a.thickbox').click(function(){82 var ed;83 68 84 if ( typeof(tinymce) != 'undefined' && tinymce.isIE && ( ed = tinymce.get(wpActiveEditor) ) && !ed.isHidden() ) {85 ed.focus();86 ed.windowManager.insertimagebookmark = ed.selection.getBookmark();87 }88 });89 });90 */91 69 })(jQuery); -
trunk/src/wp-includes/js/media-editor.js
r26876 r26945 447 447 448 448 wp.media.editor = { 449 insert: function( h ) {450 var mce = typeof(tinymce) != 'undefined',451 qt = typeof(QTags) != 'undefined',452 wpActiveEditor = window.wpActiveEditor,453 ed;449 insert: function( html ) { 450 var editor, 451 hasTinymce = typeof tinymce !== 'undefined', 452 hasQuicktags = typeof QTags !== 'undefined', 453 wpActiveEditor = window.wpActiveEditor; 454 454 455 455 // Delegate to the global `send_to_editor` if it exists. 456 456 // This attempts to play nice with any themes/plugins that have 457 457 // overridden the insert functionality. 458 if ( window.send_to_editor ) 458 if ( window.send_to_editor ) { 459 459 return window.send_to_editor.apply( this, arguments ); 460 } 460 461 461 462 if ( ! wpActiveEditor ) { 462 if ( mce && tinymce.activeEditor ) {463 ed = tinymce.activeEditor;464 wpActiveEditor = window.wpActiveEditor = ed .id;465 } else if ( ! qt) {463 if ( hasTinymce && tinymce.activeEditor ) { 464 editor = tinymce.activeEditor; 465 wpActiveEditor = window.wpActiveEditor = editor.id; 466 } else if ( ! hasQuicktags ) { 466 467 return false; 467 468 } 468 } else if ( mce ) { 469 ed = tinymce.get( wpActiveEditor ); 470 } 471 472 if ( ed && ! ed.isHidden() ) { 473 // restore caret position on IE 474 // if ( tinymce.isIE && ed.windowManager.insertimagebookmark ) 475 // ed.selection.moveToBookmark(ed.windowManager.insertimagebookmark); 476 477 if ( h.indexOf('[caption') !== -1 ) { 478 if ( ed.wpSetImgCaption ) 479 h = ed.wpSetImgCaption(h); 480 } else if ( h.indexOf('[gallery') !== -1 ) { 481 if ( ed.plugins.wpgallery ) 482 h = ed.plugins.wpgallery._do_gallery(h); 483 } else if ( h.indexOf('[embed') === 0 ) { 484 if ( ed.plugins.wordpress ) 485 h = ed.plugins.wordpress._setEmbed(h); 486 } 487 488 ed.execCommand('mceInsertContent', false, h); 489 } else if ( qt ) { 490 QTags.insertContent(h); 469 } else if ( hasTinymce ) { 470 editor = tinymce.get( wpActiveEditor ); 471 } 472 473 if ( editor && ! editor.isHidden() ) { 474 editor.execCommand( 'mceInsertContent', false, html ); 475 } else if ( hasQuicktags ) { 476 QTags.insertContent( html ); 491 477 } else { 492 document.getElementById( wpActiveEditor).value += h;478 document.getElementById( wpActiveEditor ).value += html; 493 479 } 494 480 495 481 // If the old thickbox remove function exists, call it in case 496 482 // a theme/plugin overloaded it. 497 if ( window.tb_remove ) 483 if ( window.tb_remove ) { 498 484 try { window.tb_remove(); } catch( e ) {} 485 } 499 486 }, 500 487
Note: See TracChangeset
for help on using the changeset viewer.