Edit File by line
/home/barbar84/public_h.../wp-admin/js
File: media-upload.js
/**
[0] Fix | Delete
* Contains global functions for the media upload within the post edit screen.
[1] Fix | Delete
*
[2] Fix | Delete
* Updates the ThickBox anchor href and the ThickBox's own properties in order
[3] Fix | Delete
* to set the size and position on every resize event. Also adds a function to
[4] Fix | Delete
* send HTML or text to the currently active editor.
[5] Fix | Delete
*
[6] Fix | Delete
* @file
[7] Fix | Delete
* @since 2.5.0
[8] Fix | Delete
* @output wp-admin/js/media-upload.js
[9] Fix | Delete
*
[10] Fix | Delete
* @requires jQuery
[11] Fix | Delete
*/
[12] Fix | Delete
[13] Fix | Delete
/* global tinymce, QTags, wpActiveEditor, tb_position */
[14] Fix | Delete
[15] Fix | Delete
/**
[16] Fix | Delete
* Sends the HTML passed in the parameters to TinyMCE.
[17] Fix | Delete
*
[18] Fix | Delete
* @since 2.5.0
[19] Fix | Delete
*
[20] Fix | Delete
* @global
[21] Fix | Delete
*
[22] Fix | Delete
* @param {string} html The HTML to be sent to the editor.
[23] Fix | Delete
* @return {void|boolean} Returns false when both TinyMCE and QTags instances
[24] Fix | Delete
* are unavailable. This means that the HTML was not
[25] Fix | Delete
* sent to the editor.
[26] Fix | Delete
*/
[27] Fix | Delete
window.send_to_editor = function( html ) {
[28] Fix | Delete
var editor,
[29] Fix | Delete
hasTinymce = typeof tinymce !== 'undefined',
[30] Fix | Delete
hasQuicktags = typeof QTags !== 'undefined';
[31] Fix | Delete
[32] Fix | Delete
// If no active editor is set, try to set it.
[33] Fix | Delete
if ( ! wpActiveEditor ) {
[34] Fix | Delete
if ( hasTinymce && tinymce.activeEditor ) {
[35] Fix | Delete
editor = tinymce.activeEditor;
[36] Fix | Delete
window.wpActiveEditor = editor.id;
[37] Fix | Delete
} else if ( ! hasQuicktags ) {
[38] Fix | Delete
return false;
[39] Fix | Delete
}
[40] Fix | Delete
} else if ( hasTinymce ) {
[41] Fix | Delete
editor = tinymce.get( wpActiveEditor );
[42] Fix | Delete
}
[43] Fix | Delete
[44] Fix | Delete
// If the editor is set and not hidden,
[45] Fix | Delete
// insert the HTML into the content of the editor.
[46] Fix | Delete
if ( editor && ! editor.isHidden() ) {
[47] Fix | Delete
editor.execCommand( 'mceInsertContent', false, html );
[48] Fix | Delete
} else if ( hasQuicktags ) {
[49] Fix | Delete
// If quick tags are available, insert the HTML into its content.
[50] Fix | Delete
QTags.insertContent( html );
[51] Fix | Delete
} else {
[52] Fix | Delete
// If neither the TinyMCE editor and the quick tags are available,
[53] Fix | Delete
// add the HTML to the current active editor.
[54] Fix | Delete
document.getElementById( wpActiveEditor ).value += html;
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
// If the old thickbox remove function exists, call it.
[58] Fix | Delete
if ( window.tb_remove ) {
[59] Fix | Delete
try { window.tb_remove(); } catch( e ) {}
[60] Fix | Delete
}
[61] Fix | Delete
};
[62] Fix | Delete
[63] Fix | Delete
(function($) {
[64] Fix | Delete
/**
[65] Fix | Delete
* Recalculates and applies the new ThickBox position based on the current
[66] Fix | Delete
* window size.
[67] Fix | Delete
*
[68] Fix | Delete
* @since 2.6.0
[69] Fix | Delete
*
[70] Fix | Delete
* @global
[71] Fix | Delete
*
[72] Fix | Delete
* @return {Object[]} Array containing jQuery objects for all the found
[73] Fix | Delete
* ThickBox anchors.
[74] Fix | Delete
*/
[75] Fix | Delete
window.tb_position = function() {
[76] Fix | Delete
var tbWindow = $('#TB_window'),
[77] Fix | Delete
width = $(window).width(),
[78] Fix | Delete
H = $(window).height(),
[79] Fix | Delete
W = ( 833 < width ) ? 833 : width,
[80] Fix | Delete
adminbar_height = 0;
[81] Fix | Delete
[82] Fix | Delete
if ( $('#wpadminbar').length ) {
[83] Fix | Delete
adminbar_height = parseInt( $('#wpadminbar').css('height'), 10 );
[84] Fix | Delete
}
[85] Fix | Delete
[86] Fix | Delete
if ( tbWindow.length ) {
[87] Fix | Delete
tbWindow.width( W - 50 ).height( H - 45 - adminbar_height );
[88] Fix | Delete
$('#TB_iframeContent').width( W - 50 ).height( H - 75 - adminbar_height );
[89] Fix | Delete
tbWindow.css({'margin-left': '-' + parseInt( ( ( W - 50 ) / 2 ), 10 ) + 'px'});
[90] Fix | Delete
if ( typeof document.body.style.maxWidth !== 'undefined' )
[91] Fix | Delete
tbWindow.css({'top': 20 + adminbar_height + 'px', 'margin-top': '0'});
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
/**
[95] Fix | Delete
* Recalculates the new height and width for all links with a ThickBox class.
[96] Fix | Delete
*
[97] Fix | Delete
* @since 2.6.0
[98] Fix | Delete
*/
[99] Fix | Delete
return $('a.thickbox').each( function() {
[100] Fix | Delete
var href = $(this).attr('href');
[101] Fix | Delete
if ( ! href ) return;
[102] Fix | Delete
href = href.replace(/&width=[0-9]+/g, '');
[103] Fix | Delete
href = href.replace(/&height=[0-9]+/g, '');
[104] Fix | Delete
$(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 - adminbar_height ) );
[105] Fix | Delete
});
[106] Fix | Delete
};
[107] Fix | Delete
[108] Fix | Delete
// Add handler to recalculates the ThickBox position when the window is resized.
[109] Fix | Delete
$(window).on( 'resize', function(){ tb_position(); });
[110] Fix | Delete
[111] Fix | Delete
})(jQuery);
[112] Fix | Delete
[113] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function