]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/js/media-upload.dev.js
Wordpress 3.2.1
[autoinstalls/wordpress.git] / wp-admin / js / media-upload.dev.js
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                 // restore caret position on IE
7                 if ( tinymce.isIE && ed.windowManager.insertimagebookmark )
8                         ed.selection.moveToBookmark(ed.windowManager.insertimagebookmark);
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                 } else if ( h.indexOf('[embed') === 0 ) {
17                         if ( ed.plugins.wordpress )
18                                 h = ed.plugins.wordpress._setEmbed(h);
19                 }
20
21                 ed.execCommand('mceInsertContent', false, h);
22
23         } else if ( typeof edInsertContent == 'function' ) {
24                 edInsertContent(edCanvas, h);
25         } else {
26                 jQuery( edCanvas ).val( jQuery( edCanvas ).val() + h );
27         }
28
29         tb_remove();
30 }
31
32 // thickbox settings
33 var tb_position;
34 (function($) {
35         tb_position = function() {
36                 var tbWindow = $('#TB_window'), width = $(window).width(), H = $(window).height(), W = ( 720 < width ) ? 720 : width, adminbar_height = 0;
37
38                 if ( $('body.admin-bar').length )
39                         adminbar_height = 28;
40
41                 if ( tbWindow.size() ) {
42                         tbWindow.width( W - 50 ).height( H - 45 - adminbar_height );
43                         $('#TB_iframeContent').width( W - 50 ).height( H - 75 - adminbar_height );
44                         tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px'});
45                         if ( typeof document.body.style.maxWidth != 'undefined' )
46                                 tbWindow.css({'top': 20 + adminbar_height + 'px','margin-top':'0'});
47                 };
48
49                 return $('a.thickbox').each( function() {
50                         var href = $(this).attr('href');
51                         if ( ! href ) return;
52                         href = href.replace(/&width=[0-9]+/g, '');
53                         href = href.replace(/&height=[0-9]+/g, '');
54                         $(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 - adminbar_height ) );
55                 });
56         };
57
58         $(window).resize(function(){ tb_position(); });
59
60         // store caret position in IE
61         $(document).ready(function($){
62                 $('a.thickbox').click(function(){
63                         var ed;
64
65                         if ( typeof tinyMCE != 'undefined' && tinymce.isIE && ( ed = tinyMCE.activeEditor ) && !ed.isHidden() ) {
66                                 ed.focus();
67                                 ed.windowManager.insertimagebookmark = ed.selection.getBookmark();
68                         }
69                 });
70         });
71
72 })(jQuery);