| 1 |
// send html to the post editor |
| 2 |
function send_to_editor(h) { |
| 3 |
if ( typeof tinyMCE != 'undefined' && ( ed = tinyMCE.activeEditor ) && !ed.isHidden() ) { |
| 4 |
ed.focus(); |
| 5 |
if (tinymce.isIE) |
| 6 |
ed.selection.moveToBookmark(tinymce.EditorManager.activeEditor.windowManager.bookmark); |
| 7 |
|
| 8 |
if ( h.indexOf('[caption') != -1 ) |
| 9 |
h = ed.plugins.wpeditimage._do_shcode(h); |
| 10 |
|
| 11 |
ed.execCommand('mceInsertContent', false, h); |
| 12 |
} else |
| 13 |
edInsertContent(edCanvas, h); |
| 14 |
|
| 15 |
tb_remove(); |
| 16 |
} |
| 17 |
|
| 18 |
/** |
| 19 |
* new tb_window of media-uplader |
| 20 |
*/ |
| 21 |
jQuery(function($) { |
| 22 |
tb_position = function() { |
| 23 |
var tbWindow = $('#TB_window'); |
| 24 |
var width = $(window).width(); |
| 25 |
var H = $(window).height(); |
| 26 |
var W = ( 1720 < width ) ? 1720 : width; |
| 27 |
|
| 28 |
if ( tbWindow.size() ) { |
| 29 |
tbWindow.width( W - 50 ).height( H - 45 ); |
| 30 |
$('#TB_iframeContent').width( W - 50 ).height( H - 75 ); |
| 31 |
tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px'}); |
| 32 |
if ( typeof document.body.style.maxWidth != 'undefined' ) |
| 33 |
tbWindow.css({'top':'20px','margin-top':'0'}); |
| 34 |
$('#TB_title').css({'background-color':'#fff','color':'#cfcfcf'}); |
| 35 |
}; |
| 36 |
|
| 37 |
return $('a.thickbox').each( function() { |
| 38 |
var href = $(this).attr('href'); |
| 39 |
if ( ! href ) return; |
| 40 |
href = href.replace(/&width=[0-9]+/g, ''); |
| 41 |
href = href.replace(/&height=[0-9]+/g, ''); |
| 42 |
$(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 ) ); |
| 43 |
}); |
| 44 |
}; |
| 45 |
|
| 46 |
jQuery('a.thickbox').click(function(){ |
| 47 |
if ( typeof tinyMCE != 'undefined' && tinyMCE.activeEditor ) { |
| 48 |
tinyMCE.get('content').focus(); |
| 49 |
tinyMCE.activeEditor.windowManager.bookmark = tinyMCE.activeEditor.selection.getBookmark('simple'); |
| 50 |
} |
| 51 |
}); |
| 52 |
|
| 53 |
$(window).resize( function() { tb_position() } ); |
| 54 |
}); |