1 /* global tinymce, QTags */
2 // send html to the post editor
4 var wpActiveEditor, send_to_editor;
6 send_to_editor = function( html ) {
8 hasTinymce = typeof tinymce !== 'undefined',
9 hasQuicktags = typeof QTags !== 'undefined';
11 if ( ! wpActiveEditor ) {
12 if ( hasTinymce && tinymce.activeEditor ) {
13 editor = tinymce.activeEditor;
14 wpActiveEditor = editor.id;
15 } else if ( ! hasQuicktags ) {
18 } else if ( hasTinymce ) {
19 editor = tinymce.get( wpActiveEditor );
22 if ( editor && ! editor.isHidden() ) {
23 editor.execCommand( 'mceInsertContent', false, html );
24 } else if ( hasQuicktags ) {
25 QTags.insertContent( html );
27 document.getElementById( wpActiveEditor ).value += html;
30 // If the old thickbox remove function exists, call it
31 if ( window.tb_remove ) {
32 try { window.tb_remove(); } catch( e ) {}
39 tb_position = function() {
40 var tbWindow = $('#TB_window'),
41 width = $(window).width(),
42 H = $(window).height(),
43 W = ( 833 < width ) ? 833 : width,
46 if ( $('#wpadminbar').length ) {
47 adminbar_height = parseInt( $('#wpadminbar').css('height'), 10 );
50 if ( tbWindow.size() ) {
51 tbWindow.width( W - 50 ).height( H - 45 - adminbar_height );
52 $('#TB_iframeContent').width( W - 50 ).height( H - 75 - adminbar_height );
53 tbWindow.css({'margin-left': '-' + parseInt( ( ( W - 50 ) / 2 ), 10 ) + 'px'});
54 if ( typeof document.body.style.maxWidth !== 'undefined' )
55 tbWindow.css({'top': 20 + adminbar_height + 'px', 'margin-top': '0'});
58 return $('a.thickbox').each( function() {
59 var href = $(this).attr('href');
61 href = href.replace(/&width=[0-9]+/g, '');
62 href = href.replace(/&height=[0-9]+/g, '');
63 $(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 - adminbar_height ) );
67 $(window).resize(function(){ tb_position(); });