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