You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

70 lines
1.9 KiB

  1. /* global tinymce, QTags */
  2. // send html to the post editor
  3. var wpActiveEditor, send_to_editor;
  4. send_to_editor = function( html ) {
  5. var editor,
  6. hasTinymce = typeof tinymce !== 'undefined',
  7. hasQuicktags = typeof QTags !== 'undefined';
  8. if ( ! wpActiveEditor ) {
  9. if ( hasTinymce && tinymce.activeEditor ) {
  10. editor = tinymce.activeEditor;
  11. wpActiveEditor = editor.id;
  12. } else if ( ! hasQuicktags ) {
  13. return false;
  14. }
  15. } else if ( hasTinymce ) {
  16. editor = tinymce.get( wpActiveEditor );
  17. }
  18. if ( editor && ! editor.isHidden() ) {
  19. editor.execCommand( 'mceInsertContent', false, html );
  20. } else if ( hasQuicktags ) {
  21. QTags.insertContent( html );
  22. } else {
  23. document.getElementById( wpActiveEditor ).value += html;
  24. }
  25. // If the old thickbox remove function exists, call it
  26. if ( window.tb_remove ) {
  27. try { window.tb_remove(); } catch( e ) {}
  28. }
  29. };
  30. // thickbox settings
  31. var tb_position;
  32. (function($) {
  33. tb_position = function() {
  34. var tbWindow = $('#TB_window'),
  35. width = $(window).width(),
  36. H = $(window).height(),
  37. W = ( 833 < width ) ? 833 : width,
  38. adminbar_height = 0;
  39. if ( $('#wpadminbar').length ) {
  40. adminbar_height = parseInt( $('#wpadminbar').css('height'), 10 );
  41. }
  42. if ( tbWindow.length ) {
  43. tbWindow.width( W - 50 ).height( H - 45 - adminbar_height );
  44. $('#TB_iframeContent').width( W - 50 ).height( H - 75 - adminbar_height );
  45. tbWindow.css({'margin-left': '-' + parseInt( ( ( W - 50 ) / 2 ), 10 ) + 'px'});
  46. if ( typeof document.body.style.maxWidth !== 'undefined' )
  47. tbWindow.css({'top': 20 + adminbar_height + 'px', 'margin-top': '0'});
  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. $(window).resize(function(){ tb_position(); });
  58. })(jQuery);