Changeset 42426
- Timestamp:
- 01/04/2018 02:36:13 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/media-upload.js
r36286 r42426 1 1 /* global tinymce, QTags */ 2 // send html to the post editor 2 3 /** 4 * Contains global functions for the media upload within the post edit screen. 5 * 6 * Updates the ThickBox anchor href and the ThickBox's own properties in order 7 * to set the size and position on every resize event. Also adds a function to 8 * send HTML or text to the currently active editor. 9 * 10 * @file 11 * @since 2.5.0 12 * 13 * @requires jQuery 14 */ 3 15 4 16 var wpActiveEditor, send_to_editor; 5 17 18 /** 19 * Sends the HTML passed in the parameters to TinyMCE. 20 * 21 * @since 2.5.0 22 * 23 * @global 24 * 25 * @param {string} html The HTML to be sent to the editor. 26 * @returns {void|boolean} Returns false when both TinyMCE and QTags instances 27 * are unavailable. This means that the HTML was not 28 * sent to the editor. 29 */ 6 30 send_to_editor = function( html ) { 7 31 var editor, … … 9 33 hasQuicktags = typeof QTags !== 'undefined'; 10 34 35 // If no active editor is set, try to set it. 11 36 if ( ! wpActiveEditor ) { 12 37 if ( hasTinymce && tinymce.activeEditor ) { … … 20 45 } 21 46 47 // If the editor is set and not hidden, insert the HTML into the content of the 48 // editor. 22 49 if ( editor && ! editor.isHidden() ) { 23 50 editor.execCommand( 'mceInsertContent', false, html ); 24 51 } else if ( hasQuicktags ) { 52 // If quick tags are available, insert the HTML into its content. 25 53 QTags.insertContent( html ); 26 54 } else { 55 // If neither the TinyMCE editor and the quick tags are available, add the HTML 56 // to the current active editor. 27 57 document.getElementById( wpActiveEditor ).value += html; 28 58 } 29 59 30 // If the old thickbox remove function exists, call it 60 // If the old thickbox remove function exists, call it. 31 61 if ( window.tb_remove ) { 32 62 try { window.tb_remove(); } catch( e ) {} … … 34 64 }; 35 65 36 // thickbox settings37 66 var tb_position; 38 67 (function($) { 68 /** 69 * Recalculates and applies the new ThickBox position based on the current 70 * window size. 71 * 72 * @since 2.6.0 73 * 74 * @global 75 * 76 * @returns {Object[]} Array containing jQuery objects for all the found 77 * ThickBox anchors. 78 */ 39 79 tb_position = function() { 40 80 var tbWindow = $('#TB_window'), … … 56 96 } 57 97 98 /** 99 * Recalculates the new height and width for all links with a ThickBox class. 100 * 101 * @since 2.6.0 102 */ 58 103 return $('a.thickbox').each( function() { 59 104 var href = $(this).attr('href'); … … 65 110 }; 66 111 112 // Add handler to recalculates the ThickBox position when the window is resized. 67 113 $(window).resize(function(){ tb_position(); }); 68 114
Note: See TracChangeset
for help on using the changeset viewer.