]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/js/media-upload.js
Wordpress 2.7.1
[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') === 0 ) {
9                         if ( ed.plugins.wpeditimage )
10                                 h = ed.plugins.wpeditimage._do_shcode(h);
11                 } else if ( h.indexOf('[gallery') === 0 ) {
12                         if ( ed.plugins.wpgallery )
13                                 h = ed.plugins.wpgallery._do_gallery(h);
14                 }
15
16                 ed.execCommand('mceInsertContent', false, h);
17
18         } else if ( typeof edInsertContent == 'function' ) {
19                 edInsertContent(edCanvas, h);
20         } else {
21                 jQuery( edCanvas ).val( jQuery( edCanvas ).val() + h );
22         }
23
24         tb_remove();
25 }
26
27 // thickbox settings
28 jQuery(function($) {
29         tb_position = function() {
30                 var tbWindow = $('#TB_window');
31                 var width = $(window).width();
32                 var H = $(window).height();
33                 var 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                         $('#TB_title').css({'background-color':'#222','color':'#cfcfcf'});
42                 };
43
44                 return $('a.thickbox').each( function() {
45                         var href = $(this).attr('href');
46                         if ( ! href ) return;
47                         href = href.replace(/&width=[0-9]+/g, '');
48                         href = href.replace(/&height=[0-9]+/g, '');
49                         $(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 ) );
50                 });
51         };
52
53         jQuery('a.thickbox').click(function(){
54                 if ( typeof tinyMCE != 'undefined' &&  tinyMCE.activeEditor ) {
55                         tinyMCE.get('content').focus();
56                         tinyMCE.activeEditor.windowManager.bookmark = tinyMCE.activeEditor.selection.getBookmark('simple');
57                 }
58         });
59
60         $(window).resize( function() { tb_position() } );
61 });
62