drift

WPAlchemy Multiple Editors JQuery

May 16th, 2011
584
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. jQuery(document).ready(function($) {
  2.    
  3.     //run onload
  4.     RunTinyMCE();
  5.    
  6.     //run when copy is made
  7.     $('[class*=docopy-]').click(function(){
  8.         RunTinyMCE();
  9.     });
  10.    
  11.     function RunTinyMCE(){
  12.         settings = {mode:"specific_textareas", width:"100%", theme:"advanced", skin:"wp_theme", theme_advanced_buttons1:"bold,italic,strikethrough,underline,|,bullist,numlist,blockquote,|,justifyleft,justifycenter,justifyright,|,link,unlink,|,spellchecker", theme_advanced_buttons2:"formatselect,XXXforecolor,|,pastetext,pasteword,removeformat,|,outdent,indent,|,undo,redo,|,code", theme_advanced_buttons3:"", theme_advanced_buttons4:"", language:"en", spellchecker_languages:"+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv", theme_advanced_toolbar_location:"top", theme_advanced_toolbar_align:"left", theme_advanced_statusbar_location:"bottom", theme_advanced_resizing:"1", theme_advanced_resize_horizontal:"", dialog_type:"modal", relative_urls:"", remove_script_host:"", convert_urls:"", apply_source_formatting:"", remove_linebreaks:"1", gecko_spellcheck:"1", entities:"38,amp,60,lt,62,gt", accessibility_focus:"1", tabfocus_elements:"major-publishing-actions", media_strict:"", paste_remove_styles:"1", paste_remove_spans:"1", paste_strip_class_attributes:"all", wpeditimage_disable_captions:"", plugins:"safari,inlinepopups,spellchecker,paste,wordpress,tabfocus"};
  13.        
  14.         var $ta, id, mceID;
  15.        
  16.         $('.customEditor textarea').each(function(i){
  17.        
  18.             $ta = $(this);
  19.             id = $ta.attr('id');
  20.  
  21.             //Apply TinyMCE to everyone except the one to copy
  22.             if(!$(this).parents('div.wpa_group').hasClass('tocopy')){
  23.            
  24.                 tinyMCE.execCommand('mceAddControl', false, id);
  25.             }
  26.         });
  27.        
  28.         $('.custom_upload_buttons a').each(function() {
  29.        
  30.             $(this).click(function() {
  31.                 mceID = $(this).parent().next('textarea').attr('id');
  32.                 window.send_to_editor = window.send_to_editor_clone;
  33.             });
  34.            
  35.             window.send_to_editor_clone = function(html){
  36.                 tinyMCE.execInstanceCommand(mceID, 'mceInsertContent', false, html);
  37.                 tb_remove();
  38.             }
  39.         });
  40.     };
  41. });
RAW Paste Data