[ Index ]

WordPress Cross Reference

title

Body

[close]

/wp-admin/js/ -> media-upload.js (source)

   1  /* global tinymce, QTags, tb_remove */
   2  // send html to the post editor
   3  
   4  var wpActiveEditor, send_to_editor;
   5  
   6  send_to_editor = function(h) {
   7      var ed, mce = typeof(tinymce) != 'undefined', qt = typeof(QTags) != 'undefined';
   8  
   9      if ( !wpActiveEditor ) {
  10          if ( mce && tinymce.activeEditor ) {
  11              ed = tinymce.activeEditor;
  12              wpActiveEditor = ed.id;
  13          } else if ( !qt ) {
  14              return false;
  15          }
  16      } else if ( mce ) {
  17          if ( tinymce.activeEditor && (tinymce.activeEditor.id == 'mce_fullscreen' || tinymce.activeEditor.id == 'wp_mce_fullscreen') )
  18              ed = tinymce.activeEditor;
  19          else
  20              ed = tinymce.get(wpActiveEditor);
  21      }
  22  
  23      if ( ed && !ed.isHidden() ) {
  24          // restore caret position on IE
  25          if ( tinymce.isIE && ed.windowManager.insertimagebookmark )
  26              ed.selection.moveToBookmark(ed.windowManager.insertimagebookmark);
  27  
  28          if ( h.indexOf('[caption') !== -1 ) {
  29              if ( ed.wpSetImgCaption )
  30                  h = ed.wpSetImgCaption(h);
  31          } else if ( h.indexOf('[gallery') !== -1 ) {
  32              if ( ed.plugins.wpgallery )
  33                  h = ed.plugins.wpgallery._do_gallery(h);
  34          } else if ( h.indexOf('[embed') === 0 ) {
  35              if ( ed.plugins.wordpress )
  36                  h = ed.plugins.wordpress._setEmbed(h);
  37          }
  38  
  39          ed.execCommand('mceInsertContent', false, h);
  40      } else if ( qt ) {
  41          QTags.insertContent(h);
  42      } else {
  43          document.getElementById(wpActiveEditor).value += h;
  44      }
  45  
  46      try{tb_remove();}catch(e){}
  47  };
  48  
  49  // thickbox settings
  50  var tb_position;
  51  (function($) {
  52      tb_position = function() {
  53          var tbWindow = $('#TB_window'),
  54              width = $(window).width(),
  55              H = $(window).height(),
  56              W = ( 720 < width ) ? 720 : width,
  57              adminbar_height = 0;
  58  
  59          if ( $('body.admin-bar').length ) {
  60              adminbar_height = parseInt( jQuery('#wpadminbar').css('height'), 10 );
  61          }
  62  
  63          if ( tbWindow.size() ) {
  64              tbWindow.width( W - 50 ).height( H - 45 - adminbar_height );
  65              $('#TB_iframeContent').width( W - 50 ).height( H - 75 - adminbar_height );
  66              tbWindow.css({'margin-left': '-' + parseInt( ( ( W - 50 ) / 2 ), 10 ) + 'px'});
  67              if ( typeof document.body.style.maxWidth !== 'undefined' )
  68                  tbWindow.css({'top': 20 + adminbar_height + 'px', 'margin-top': '0'});
  69          }
  70  
  71          return $('a.thickbox').each( function() {
  72              var href = $(this).attr('href');
  73              if ( ! href ) return;
  74              href = href.replace(/&width=[0-9]+/g, '');
  75              href = href.replace(/&height=[0-9]+/g, '');
  76              $(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 - adminbar_height ) );
  77          });
  78      };
  79  
  80      $(window).resize(function(){ tb_position(); });
  81  
  82      // store caret position in IE
  83      $(document).ready(function($){
  84          $('a.thickbox').click(function(){
  85              var ed;
  86  
  87              if ( typeof(tinymce) != 'undefined' && tinymce.isIE && ( ed = tinymce.get(wpActiveEditor) ) && !ed.isHidden() ) {
  88                  ed.focus();
  89                  ed.windowManager.insertimagebookmark = ed.selection.getBookmark();
  90              }
  91          });
  92      });
  93  
  94  })(jQuery);


Generated: Tue Mar 25 01:41:18 2014 WordPress honlapkészítés: online1.hu