]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/js/media-upload.js
Wordpress 2.6.2
[autoinstalls/wordpress.git] / wp-admin / js / media-upload.js
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 // thickbox settings
19 jQuery(function($) {
20         tb_position = function() {
21                 var tbWindow = $('#TB_window');
22                 var width = $(window).width();
23                 var H = $(window).height();
24                 var W = ( 720 < width ) ? 720 : width;
25
26                 if ( tbWindow.size() ) {
27                         tbWindow.width( W - 50 ).height( H - 45 );
28                         $('#TB_iframeContent').width( W - 50 ).height( H - 75 );
29                         tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px'});
30                         if ( typeof document.body.style.maxWidth != 'undefined' )
31                                 tbWindow.css({'top':'20px','margin-top':'0'});
32                         $('#TB_title').css({'background-color':'#222','color':'#cfcfcf'});
33                 };
34
35                 return $('a.thickbox').each( function() {
36                         var href = $(this).attr('href');
37                         if ( ! href ) return;
38                         href = href.replace(/&width=[0-9]+/g, '');
39                         href = href.replace(/&height=[0-9]+/g, '');
40                         $(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 ) );
41                 });
42         };
43         
44         jQuery('a.thickbox').click(function(){
45                 if ( typeof tinyMCE != 'undefined' &&  tinyMCE.activeEditor ) {
46                         tinyMCE.get('content').focus();
47                         tinyMCE.activeEditor.windowManager.bookmark = tinyMCE.activeEditor.selection.getBookmark('simple');
48                 }
49         });
50
51         $(window).resize( function() { tb_position() } );
52 });
53