wp/wp-admin/js/media-upload.js
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
    20  * @since 2.5.0
    20  * @since 2.5.0
    21  *
    21  *
    22  * @global
    22  * @global
    23  *
    23  *
    24  * @param {string} html The HTML to be sent to the editor.
    24  * @param {string} html The HTML to be sent to the editor.
    25  * @returns {void|boolean} Returns false when both TinyMCE and QTags instances
    25  * @return {void|boolean} Returns false when both TinyMCE and QTags instances
    26  *                         are unavailable. This means that the HTML was not
    26  *                        are unavailable. This means that the HTML was not
    27  *                         sent to the editor.
    27  *                        sent to the editor.
    28  */
    28  */
    29 window.send_to_editor = function( html ) {
    29 window.send_to_editor = function( html ) {
    30 	var editor,
    30 	var editor,
    31 		hasTinymce = typeof tinymce !== 'undefined',
    31 		hasTinymce = typeof tinymce !== 'undefined',
    32 		hasQuicktags = typeof QTags !== 'undefined';
    32 		hasQuicktags = typeof QTags !== 'undefined';
    41 		}
    41 		}
    42 	} else if ( hasTinymce ) {
    42 	} else if ( hasTinymce ) {
    43 		editor = tinymce.get( wpActiveEditor );
    43 		editor = tinymce.get( wpActiveEditor );
    44 	}
    44 	}
    45 
    45 
    46 	// If the editor is set and not hidden, insert the HTML into the content of the
    46 	// If the editor is set and not hidden,
    47 	// editor.
    47 	// insert the HTML into the content of the editor.
    48 	if ( editor && ! editor.isHidden() ) {
    48 	if ( editor && ! editor.isHidden() ) {
    49 		editor.execCommand( 'mceInsertContent', false, html );
    49 		editor.execCommand( 'mceInsertContent', false, html );
    50 	} else if ( hasQuicktags ) {
    50 	} else if ( hasQuicktags ) {
    51 		// If quick tags are available, insert the HTML into its content.
    51 		// If quick tags are available, insert the HTML into its content.
    52 		QTags.insertContent( html );
    52 		QTags.insertContent( html );
    53 	} else {
    53 	} else {
    54 		// If neither the TinyMCE editor and the quick tags are available, add the HTML
    54 		// If neither the TinyMCE editor and the quick tags are available,
    55 		// to the current active editor.
    55 		// add the HTML to the current active editor.
    56 		document.getElementById( wpActiveEditor ).value += html;
    56 		document.getElementById( wpActiveEditor ).value += html;
    57 	}
    57 	}
    58 
    58 
    59 	// If the old thickbox remove function exists, call it.
    59 	// If the old thickbox remove function exists, call it.
    60 	if ( window.tb_remove ) {
    60 	if ( window.tb_remove ) {
    69 	 *
    69 	 *
    70 	 * @since 2.6.0
    70 	 * @since 2.6.0
    71 	 *
    71 	 *
    72 	 * @global
    72 	 * @global
    73 	 *
    73 	 *
    74 	 * @returns {Object[]} Array containing jQuery objects for all the found
    74 	 * @return {Object[]} Array containing jQuery objects for all the found
    75 	 *                     ThickBox anchors.
    75 	 *                    ThickBox anchors.
    76 	 */
    76 	 */
    77 	window.tb_position = function() {
    77 	window.tb_position = function() {
    78 		var tbWindow = $('#TB_window'),
    78 		var tbWindow = $('#TB_window'),
    79 			width = $(window).width(),
    79 			width = $(window).width(),
    80 			H = $(window).height(),
    80 			H = $(window).height(),