[ Index ]
 

Code source de Seagull 0.6.1

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/tinyfck/themes/advanced/ -> editor_template_src.js (source)

   1  /**

   2   * $RCSfile: editor_template_src.js,v $

   3   * $Revision: 1.96 $

   4   * $Date: 2006/04/18 13:32:52 $

   5   *

   6   * @author Moxiecode

   7   * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.

   8   */
   9  
  10  /* Import theme specific language pack */

  11  tinyMCE.importThemeLanguagePack('advanced');
  12  
  13  var TinyMCE_AdvancedTheme = {
  14      // Private theme fields

  15      _autoImportCSSClasses : true,
  16      _resizer : {},
  17      _buttons : [
  18          // Control id, button img, button title, command, user_interface, value

  19          ['bold', '{$lang_bold_img}', 'lang_bold_desc', 'Bold'],
  20          ['italic', '{$lang_italic_img}', 'lang_italic_desc', 'Italic'],
  21          ['underline', '{$lang_underline_img}', 'lang_underline_desc', 'Underline'],
  22          ['strikethrough', 'strikethrough.gif', 'lang_striketrough_desc', 'Strikethrough'],
  23          ['justifyleft', 'justifyleft.gif', 'lang_justifyleft_desc', 'JustifyLeft'],
  24          ['justifycenter', 'justifycenter.gif', 'lang_justifycenter_desc', 'JustifyCenter'],
  25          ['justifyright', 'justifyright.gif', 'lang_justifyright_desc', 'JustifyRight'],
  26          ['justifyfull', 'justifyfull.gif', 'lang_justifyfull_desc', 'JustifyFull'],
  27          ['bullist', 'bullist.gif', 'lang_bullist_desc', 'InsertUnorderedList'],
  28          ['numlist', 'numlist.gif', 'lang_numlist_desc', 'InsertOrderedList'],
  29          ['outdent', 'outdent.gif', 'lang_outdent_desc', 'Outdent'],
  30          ['indent', 'indent.gif', 'lang_indent_desc', 'Indent'],
  31          ['cut', 'cut.gif', 'lang_cut_desc', 'Cut'],
  32          ['copy', 'copy.gif', 'lang_copy_desc', 'Copy'],
  33          ['paste', 'paste.gif', 'lang_paste_desc', 'Paste'],
  34          ['undo', 'undo.gif', 'lang_undo_desc', 'Undo'],
  35          ['redo', 'redo.gif', 'lang_redo_desc', 'Redo'],
  36          ['link', 'link.gif', 'lang_link_desc', 'mceLink', true],
  37          ['unlink', 'unlink.gif', 'lang_unlink_desc', 'unlink'],
  38          ['image', 'image.gif', 'lang_image_desc', 'mceImage', true],
  39          ['cleanup', 'cleanup.gif', 'lang_cleanup_desc', 'mceCleanup'],
  40          ['help', 'help.gif', 'lang_help_desc', 'mceHelp'],
  41          ['code', 'code.gif', 'lang_theme_code_desc', 'mceCodeEditor'],
  42          ['hr', 'hr.gif', 'lang_theme_hr_desc', 'inserthorizontalrule'],
  43          ['removeformat', 'removeformat.gif', 'lang_theme_removeformat_desc', 'removeformat'],
  44          ['sub', 'sub.gif', 'lang_theme_sub_desc', 'subscript'],
  45          ['sup', 'sup.gif', 'lang_theme_sup_desc', 'superscript'],
  46          ['forecolor', 'forecolor.gif', 'lang_theme_forecolor_desc', 'mceForeColor', true],
  47          ['backcolor', 'backcolor.gif', 'lang_theme_backcolor_desc', 'mceBackColor', true],
  48          ['charmap', 'charmap.gif', 'lang_theme_charmap_desc', 'mceCharMap'],
  49          ['visualaid', 'visualaid.gif', 'lang_theme_visualaid_desc', 'mceToggleVisualAid'],
  50          ['anchor', 'anchor.gif', 'lang_theme_anchor_desc', 'mceInsertAnchor'],
  51          ['newdocument', 'newdocument.gif', 'lang_newdocument_desc', 'mceNewDocument']
  52      ],
  53  
  54      _buttonMap : 'anchor,backcolor,bold,bullist,charmap,cleanup,code,copy,cut,forecolor,help,hr,image,indent,italic,justifycenter,justifyfull,justifyleft,justifyright,link,newdocument,numlist,outdent,paste,redo,removeformat,strikethrough,sub,sup,underline,undo,unlink,visualaid,advhr,ltr,rtl,emotions,flash,fullpage,fullscreen,iespell,insertdate,inserttime,pastetext,pasteword,selectall,preview,print,save,replace,search,table,cell_props,delete_col,delete_row,col_after,col_before,row_after,row_before,merge_cells,row_props,split_cells',
  55  
  56      /**

  57       * Returns HTML code for the specificed control.

  58       */
  59      getControlHTML : function(button_name) {
  60          var i, x;
  61  
  62          // Lookup button in button list

  63          for (i=0; i<TinyMCE_AdvancedTheme._buttons.length; i++) {
  64              var but = TinyMCE_AdvancedTheme._buttons[i];
  65  
  66              if (but[0] == button_name)
  67                  return tinyMCE.getButtonHTML(but[0], but[2], '{$themeurl}/images/' + but[1], but[3], (but.length > 4 ? but[4] : false), (but.length > 5 ? but[5] : null));
  68          }
  69  
  70          // Custom controlls other than buttons

  71          switch (button_name) {
  72              case "formatselect":
  73                  var html = '<select id="{$editor_id}_formatSelect" name="{$editor_id}_formatSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FormatBlock\',false,this.options[this.selectedIndex].value);" class="mceSelectList">';
  74                  var formats = tinyMCE.getParam("theme_advanced_blockformats", "p,address,pre,h1,h2,h3,h4,h5,h6", true).split(',');
  75                  var lookup = [
  76                      ['p', '{$lang_theme_paragraph}'],
  77                      ['address', '{$lang_theme_address}'],
  78                      ['pre', '{$lang_theme_pre}'],
  79                      ['h1', '{$lang_theme_h1}'],
  80                      ['h2', '{$lang_theme_h2}'],
  81                      ['h3', '{$lang_theme_h3}'],
  82                      ['h4', '{$lang_theme_h4}'],
  83                      ['h5', '{$lang_theme_h5}'],
  84                      ['h6', '{$lang_theme_h6}'],
  85                      ['div', '{$lang_theme_div}'],
  86                      ['blockquote', '{$lang_theme_blockquote}'],
  87                      ['code', '{$lang_theme_code}'],
  88                      ['dt', '{$lang_theme_dt}'],
  89                      ['dd', '{$lang_theme_dd}'],
  90                      ['samp', '{$lang_theme_samp}']
  91                  ];
  92  
  93                  html += '<option value="">{$lang_theme_block}</option>';
  94  
  95                  // Build format select

  96                  for (var i=0; i<formats.length; i++) {
  97                      for (var x=0; x<lookup.length; x++) {
  98                          if (formats[i] == lookup[x][0])
  99                              html += '<option value="&lt;' + lookup[x][0] + '&gt;">' + lookup[x][1] + '</option>';
 100                      }
 101                  }
 102  
 103                  html += '</select>';
 104  
 105                  return html;
 106  
 107              case "styleselect":
 108                  return '<select id="{$editor_id}_styleSelect" onmousedown="tinyMCE.themes.advanced._setupCSSClasses(\'{$editor_id}\');" name="{$editor_id}_styleSelect" onfocus="tinyMCE.addSelectAccessibility(event,this,window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceSetCSSClass\',false,this.options[this.selectedIndex].value);" class="mceSelectList">{$style_select_options}</select>';
 109  
 110              case "fontselect":
 111                  var fontHTML = '<select id="{$editor_id}_fontNameSelect" name="{$editor_id}_fontNameSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FontName\',false,this.options[this.selectedIndex].value);" class="mceSelectList"><option value="">{$lang_theme_fontdefault}</option>';
 112                  var iFonts = 'Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;WingDings=wingdings';
 113                  var nFonts = 'Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sand;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats';
 114                  var fonts = tinyMCE.getParam("theme_advanced_fonts", nFonts).split(';');
 115                  for (i=0; i<fonts.length; i++) {
 116                      if (fonts[i] != '') {
 117                          var parts = fonts[i].split('=');
 118                          fontHTML += '<option value="' + parts[1] + '">' + parts[0] + '</option>';
 119                      }
 120                  }
 121  
 122                  fontHTML += '</select>';
 123                  return fontHTML;
 124  
 125              case "fontsizeselect":
 126                  return '<select id="{$editor_id}_fontSizeSelect" name="{$editor_id}_fontSizeSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FontSize\',false,this.options[this.selectedIndex].value);" class="mceSelectList">'+
 127                          '<option value="0">{$lang_theme_font_size}</option>'+
 128                          '<option value="1">1 (8 pt)</option>'+
 129                          '<option value="2">2 (10 pt)</option>'+
 130                          '<option value="3">3 (12 pt)</option>'+
 131                          '<option value="4">4 (14 pt)</option>'+
 132                          '<option value="5">5 (18 pt)</option>'+
 133                          '<option value="6">6 (24 pt)</option>'+
 134                          '<option value="7">7 (36 pt)</option>'+
 135                          '</select>';
 136  
 137              case "|":
 138              case "separator":
 139                  return '<img src="{$themeurl}/images/separator.gif" width="2" height="20" class="mceSeparatorLine" />';
 140  
 141              case "spacer":
 142                  return '<img src="{$themeurl}/images/separator.gif" width="2" height="15" border="0" class="mceSeparatorLine" style="vertical-align: middle" />';
 143  
 144              case "rowseparator":
 145                  return '<br />';
 146          }
 147  
 148          return "";
 149      },
 150  
 151      /**

 152       * Theme specific execcommand handling.

 153       */
 154      execCommand : function(editor_id, element, command, user_interface, value) {
 155          switch (command) {
 156              case "mceLink":
 157                  var inst = tinyMCE.getInstanceById(editor_id);
 158                  var doc = inst.getDoc();
 159                  var selectedText = "";
 160  
 161                  if (tinyMCE.isMSIE) {
 162                      var rng = doc.selection.createRange();
 163                      selectedText = rng.text;
 164                  } else
 165                      selectedText = inst.getSel().toString();
 166  
 167                  if (!tinyMCE.linkElement) {
 168                      if ((tinyMCE.selectedElement.nodeName.toLowerCase() != "img") && (selectedText.length <= 0))
 169                          return true;
 170                  }
 171  
 172                  var href = "", target = "", title = "", onclick = "", action = "insert", style_class = "";
 173  
 174                  if (tinyMCE.selectedElement.nodeName.toLowerCase() == "a")
 175                      tinyMCE.linkElement = tinyMCE.selectedElement;
 176  
 177                  // Is anchor not a link

 178                  if (tinyMCE.linkElement != null && tinyMCE.getAttrib(tinyMCE.linkElement, 'href') == "")
 179                      tinyMCE.linkElement = null;
 180  
 181                  if (tinyMCE.linkElement) {
 182                      href = tinyMCE.getAttrib(tinyMCE.linkElement, 'href');
 183                      target = tinyMCE.getAttrib(tinyMCE.linkElement, 'target');
 184                      title = tinyMCE.getAttrib(tinyMCE.linkElement, 'title');
 185                      onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick');
 186                      style_class = tinyMCE.getAttrib(tinyMCE.linkElement, 'class');
 187  
 188                      // Try old onclick to if copy/pasted content

 189                      if (onclick == "")
 190                          onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick');
 191  
 192                      onclick = tinyMCE.cleanupEventStr(onclick);
 193  
 194                      href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);");
 195  
 196                      // Use mce_href if defined

 197                      mceRealHref = tinyMCE.getAttrib(tinyMCE.linkElement, 'mce_href');
 198                      if (mceRealHref != "") {
 199                          href = mceRealHref;
 200  
 201                          if (tinyMCE.getParam('convert_urls'))
 202                              href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);");
 203                      }
 204  
 205                      action = "update";
 206                  }
 207  
 208                  var template = new Array();
 209  
 210                  template['file'] = 'link.htm';
 211                  template['width'] = 310;
 212                  template['height'] = 200;
 213  
 214                  // Language specific width and height addons

 215                  template['width'] += tinyMCE.getLang('lang_insert_link_delta_width', 0);
 216                  template['height'] += tinyMCE.getLang('lang_insert_link_delta_height', 0);
 217  
 218                  if (inst.settings['insertlink_callback']) {
 219                      var returnVal = eval(inst.settings['insertlink_callback'] + "(href, target, title, onclick, action, style_class);");
 220                      if (returnVal && returnVal['href'])
 221                          TinyMCE_AdvancedTheme._insertLink(returnVal['href'], returnVal['target'], returnVal['title'], returnVal['onclick'], returnVal['style_class']);
 222                  } else {
 223                      tinyMCE.openWindow(template, {href : href, target : target, title : title, onclick : onclick, action : action, className : style_class, inline : "yes"});
 224                  }
 225  
 226                  return true;
 227  
 228              case "mceImage":
 229                  var src = "", alt = "", border = "", hspace = "", vspace = "", width = "", height = "", align = "";
 230                  var title = "", onmouseover = "", onmouseout = "", action = "insert";
 231                  var img = tinyMCE.imgElement;
 232                  var inst = tinyMCE.getInstanceById(editor_id);
 233  
 234                  if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") {
 235                      img = tinyMCE.selectedElement;
 236                      tinyMCE.imgElement = img;
 237                  }
 238  
 239                  if (img) {
 240                      // Is it a internal MCE visual aid image, then skip this one.

 241                      if (tinyMCE.getAttrib(img, 'name').indexOf('mce_') == 0)
 242                          return true;
 243  
 244                      src = tinyMCE.getAttrib(img, 'src');
 245                      alt = tinyMCE.getAttrib(img, 'alt');
 246  
 247                      // Try polling out the title

 248                      if (alt == "")
 249                          alt = tinyMCE.getAttrib(img, 'title');
 250  
 251                      // Fix width/height attributes if the styles is specified

 252                      if (tinyMCE.isGecko) {
 253                          var w = img.style.width;
 254                          if (w != null && w != "")
 255                              img.setAttribute("width", w);
 256  
 257                          var h = img.style.height;
 258                          if (h != null && h != "")
 259                              img.setAttribute("height", h);
 260                      }
 261  
 262                      border = tinyMCE.getAttrib(img, 'border');
 263                      hspace = tinyMCE.getAttrib(img, 'hspace');
 264                      vspace = tinyMCE.getAttrib(img, 'vspace');
 265                      width = tinyMCE.getAttrib(img, 'width');
 266                      height = tinyMCE.getAttrib(img, 'height');
 267                      align = tinyMCE.getAttrib(img, 'align');
 268                      onmouseover = tinyMCE.getAttrib(img, 'onmouseover');
 269                      onmouseout = tinyMCE.getAttrib(img, 'onmouseout');
 270                      title = tinyMCE.getAttrib(img, 'title');
 271  
 272                      // Is realy specified?

 273                      if (tinyMCE.isMSIE) {
 274                          width = img.attributes['width'].specified ? width : "";
 275                          height = img.attributes['height'].specified ? height : "";
 276                      }
 277  
 278                      //onmouseover = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseover));

 279                      //onmouseout = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseout));

 280  
 281                      src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);");
 282  
 283                      // Use mce_src if defined

 284                      mceRealSrc = tinyMCE.getAttrib(img, 'mce_src');
 285                      if (mceRealSrc != "") {
 286                          src = mceRealSrc;
 287  
 288                          if (tinyMCE.getParam('convert_urls'))
 289                              src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);");
 290                      }
 291  
 292                      //if (onmouseover != "")

 293                      //    onmouseover = eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, img, true);");

 294  
 295                      //if (onmouseout != "")

 296                      //    onmouseout = eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, img, true);");

 297  
 298                      action = "update";
 299                  }
 300  
 301                  var template = new Array();
 302  
 303                  template['file'] = 'image.htm?src={$src}';
 304                  template['width'] = 355;
 305                  template['height'] = 265 + (tinyMCE.isMSIE ? 25 : 0);
 306  
 307                  // Language specific width and height addons

 308                  template['width'] += tinyMCE.getLang('lang_insert_image_delta_width', 0);
 309                  template['height'] += tinyMCE.getLang('lang_insert_image_delta_height', 0);
 310  
 311                  if (inst.settings['insertimage_callback']) {
 312                      var returnVal = eval(inst.settings['insertimage_callback'] + "(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout, action);");
 313                      if (returnVal && returnVal['src'])
 314                          TinyMCE_AdvancedTheme._insertImage(returnVal['src'], returnVal['alt'], returnVal['border'], returnVal['hspace'], returnVal['vspace'], returnVal['width'], returnVal['height'], returnVal['align'], returnVal['title'], returnVal['onmouseover'], returnVal['onmouseout']);
 315                  } else
 316                      tinyMCE.openWindow(template, {src : src, alt : alt, border : border, hspace : hspace, vspace : vspace, width : width, height : height, align : align, title : title, onmouseover : onmouseover, onmouseout : onmouseout, action : action, inline : "yes"});
 317  
 318                  return true;
 319  
 320              case "mceForeColor":
 321                  var template = new Array();
 322                  var elm = tinyMCE.selectedInstance.getFocusElement();
 323                  var inputColor = tinyMCE.getAttrib(elm, "color");
 324  
 325                  if (inputColor == '')
 326                      inputColor = elm.style.color;
 327  
 328                  if (!inputColor)
 329                      inputColor = "#000000";
 330  
 331                  template['file'] = 'color_picker.htm';
 332                  template['width'] = 220;
 333                  template['height'] = 190;
 334  
 335                  tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "forecolor", input_color : inputColor});
 336              return true;
 337  
 338              case "mceBackColor":
 339                  var template = new Array();
 340                  var elm = tinyMCE.selectedInstance.getFocusElement();
 341                  var inputColor = elm.style.backgroundColor;
 342  
 343                  if (!inputColor)
 344                      inputColor = "#000000";
 345  
 346                  template['file'] = 'color_picker.htm';
 347                  template['width'] = 220;
 348                  template['height'] = 190;
 349  
 350                  template['width'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_width', 0);
 351                  template['height'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_height', 0);
 352  
 353                  tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "HiliteColor", input_color : inputColor});
 354                  //mceBackColor

 355              return true;
 356  
 357              case "mceColorPicker":
 358                  if (user_interface) {
 359                      var template = new Array();
 360                      var inputColor = value['document'].getElementById(value['element_id']).value;
 361  
 362                      template['file'] = 'color_picker.htm';
 363                      template['width'] = 220;
 364                      template['height'] = 190;
 365                      template['close_previous'] = "no";
 366  
 367                      template['width'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_width', 0);
 368                      template['height'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_height', 0);
 369  
 370                      if (typeof(value['store_selection']) == "undefined")
 371                          value['store_selection'] = true;
 372  
 373                      tinyMCE.lastColorPickerValue = value;
 374                      tinyMCE.openWindow(template, {editor_id : editor_id, mce_store_selection : value['store_selection'], inline : "yes", command : "mceColorPicker", input_color : inputColor});
 375                  } else {
 376                      var savedVal = tinyMCE.lastColorPickerValue;
 377                      var elm = savedVal['document'].getElementById(savedVal['element_id']);
 378                      elm.value = value;
 379  
 380                      if (elm.onchange != null && elm.onchange != '')
 381                          eval('elm.onchange();');
 382                  }
 383              return true;
 384  
 385              case "mceCodeEditor":
 386                  var template = new Array();
 387  
 388                  template['file'] = 'source_editor.htm';
 389                  template['width'] = parseInt(tinyMCE.getParam("theme_advanced_source_editor_width", 720));
 390                  template['height'] = parseInt(tinyMCE.getParam("theme_advanced_source_editor_height", 580));
 391  
 392                  tinyMCE.openWindow(template, {editor_id : editor_id, resizable : "yes", scrollbars : "no", inline : "yes"});
 393                  return true;
 394  
 395              case "mceCharMap":
 396                  var template = new Array();
 397  
 398                  template['file'] = 'charmap.htm';
 399                  template['width'] = 550 + (tinyMCE.isOpera ? 40 : 0);
 400                  template['height'] = 250;
 401  
 402                  template['width'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_width', 0);
 403                  template['height'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_height', 0);
 404  
 405                  tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"});
 406                  return true;
 407  
 408              case "mceInsertAnchor":
 409                  var template = new Array();
 410  
 411                  template['file'] = 'anchor.htm';
 412                  template['width'] = 320;
 413                  template['height'] = 90 + (tinyMCE.isNS7 ? 30 : 0);
 414  
 415                  template['width'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_width', 0);
 416                  template['height'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_height', 0);
 417  
 418                  tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"});
 419                  return true;
 420  
 421              case "mceNewDocument":
 422                  if (confirm(tinyMCE.getLang('lang_newdocument')))
 423                      tinyMCE.execInstanceCommand(editor_id, 'mceSetContent', false, ' ');
 424  
 425                  return true;
 426          }
 427  
 428          return false;
 429      },
 430  
 431      /**

 432       * Editor instance template function.

 433       */
 434      getEditorTemplate : function(settings, editorId) {
 435  		function removeFromArray(in_array, remove_array) {
 436              var outArray = new Array();
 437              
 438              for (var i=0; i<in_array.length; i++) {
 439                  skip = false;
 440  
 441                  for (var j=0; j<remove_array.length; j++) {
 442                      if (in_array[i] == remove_array[j]) {
 443                          skip = true;
 444                      }
 445                  }
 446  
 447                  if (!skip) {
 448                      outArray[outArray.length] = in_array[i];
 449                  }
 450              }
 451  
 452              return outArray;
 453          }
 454  
 455  		function addToArray(in_array, add_array) {
 456              for (var i=0; i<add_array.length; i++) {
 457                  in_array[in_array.length] = add_array[i];
 458              }
 459  
 460              return in_array;
 461          }
 462  
 463          var template = new Array();
 464          var deltaHeight = 0;
 465          var resizing = tinyMCE.getParam("theme_advanced_resizing", false);
 466          var path = tinyMCE.getParam("theme_advanced_path", true);
 467          var statusbarHTML = '<div id="{$editor_id}_path" class="mceStatusbarPathText" style="display: ' + (path ? "block" : "none") + '">&#160;</div><div id="{$editor_id}_resize" class="mceStatusbarResize" style="display: ' + (resizing ? "block" : "none") + '" onmousedown="tinyMCE.themes.advanced._setResizing(event,\'{$editor_id}\',true);"></div><br style="clear: both" />';
 468          var layoutManager = tinyMCE.getParam("theme_advanced_layout_manager", "SimpleLayout");
 469  
 470          // Setup style select options -- MOVED UP FOR EXTERNAL TOOLBAR COMPATABILITY!

 471          var styleSelectHTML = '<option value="">{$lang_theme_style_select}</option>';
 472          if (settings['theme_advanced_styles']) {
 473              var stylesAr = settings['theme_advanced_styles'].split(';');
 474              
 475              for (var i=0; i<stylesAr.length; i++) {
 476                  var key, value;
 477  
 478                  key = stylesAr[i].split('=')[0];
 479                  value = stylesAr[i].split('=')[1];
 480  
 481                  styleSelectHTML += '<option value="' + value + '">' + key + '</option>';
 482              }
 483  
 484              TinyMCE_AdvancedTheme._autoImportCSSClasses = false;
 485          }
 486  
 487          switch(layoutManager) {
 488              case "SimpleLayout" : //the default TinyMCE Layout (for backwards compatibility)...
 489                  var toolbarHTML = "";
 490                  var toolbarLocation = tinyMCE.getParam("theme_advanced_toolbar_location", "bottom");
 491                  var toolbarAlign = tinyMCE.getParam("theme_advanced_toolbar_align", "center");
 492                  var pathLocation = tinyMCE.getParam("theme_advanced_path_location", "none"); // Compatiblity

 493                  var statusbarLocation = tinyMCE.getParam("theme_advanced_statusbar_location", pathLocation);
 494                  var defVals = {
 495                      theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,styleselect,formatselect",
 496                      theme_advanced_buttons2 : "bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image,cleanup,help,code",
 497                      theme_advanced_buttons3 : "hr,removeformat,visualaid,separator,sub,sup,separator,charmap"
 498                  };
 499  
 500                  // Add accessibility control

 501                  toolbarHTML += '<a href="#" accesskey="q" title="' + tinyMCE.getLang("lang_toolbar_focus") + '"';
 502  
 503                  if (!tinyMCE.getParam("accessibility_focus"))
 504                      toolbarHTML += ' onfocus="tinyMCE.getInstanceById(\'' + editorId + '\').getWin().focus();"';
 505  
 506                  toolbarHTML += '></a>';
 507  
 508                  // Render rows

 509                  for (var i=1; i<100; i++) {
 510                      var def = defVals["theme_advanced_buttons" + i];
 511  
 512                      var buttons = tinyMCE.getParam("theme_advanced_buttons" + i, def == null ? '' : def, true, ',');
 513                      if (buttons.length == 0)
 514                          break;
 515  
 516                      buttons = removeFromArray(buttons, tinyMCE.getParam("theme_advanced_disable", "", true, ','));
 517                      buttons = addToArray(buttons, tinyMCE.getParam("theme_advanced_buttons" + i + "_add", "", true, ','));
 518                      buttons = addToArray(tinyMCE.getParam("theme_advanced_buttons" + i + "_add_before", "", true, ','), buttons);
 519  
 520                      for (var b=0; b<buttons.length; b++)
 521                          toolbarHTML += tinyMCE.getControlHTML(buttons[b]);
 522  
 523                      if (buttons.length > 0) {
 524                          toolbarHTML += "<br />";
 525                          deltaHeight -= 23;
 526                      }
 527                  }
 528  
 529                  // Add accessibility control

 530                  toolbarHTML += '<a href="#" accesskey="z" onfocus="tinyMCE.getInstanceById(\'' + editorId + '\').getWin().focus();"></a>';
 531  
 532                  // Setup template html

 533                  template['html'] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width}px;height:{$height}px"><tbody>';
 534  
 535                  if (toolbarLocation == "top") {
 536                      template['html'] += '<tr><td class="mceToolbarTop" align="' + toolbarAlign + '" height="1" nowrap="nowrap">' + toolbarHTML + '</td></tr>';
 537                  }
 538  
 539                  if (statusbarLocation == "top") {
 540                      template['html'] += '<tr><td class="mceStatusbarTop" height="1">' + statusbarHTML + '</td></tr>';
 541                      deltaHeight -= 23;
 542                  }
 543  
 544                  template['html'] += '<tr><td align="center"><span id="{$editor_id}"></span></td></tr>';
 545  
 546                  if (toolbarLocation == "bottom") {
 547                      template['html'] += '<tr><td class="mceToolbarBottom" align="' + toolbarAlign + '" height="1">' + toolbarHTML + '</td></tr>';
 548                  }
 549  
 550                  // External toolbar changes

 551                  if (toolbarLocation == "external") {
 552                      var bod = document.body;
 553                      var elm = document.createElement ("div");
 554  
 555                      toolbarHTML = tinyMCE.replaceVar(toolbarHTML, 'style_select_options', styleSelectHTML);
 556                      toolbarHTML = tinyMCE.applyTemplate(toolbarHTML, {editor_id : editorId});
 557  
 558                      elm.className = "mceToolbarExternal";
 559                      elm.id = editorId+"_toolbar";
 560                      elm.innerHTML = '<table width="100%" border="0" align="center"><tr><td align="center">'+toolbarHTML+'</td></tr></table>';
 561                      bod.appendChild (elm);
 562                      // bod.style.marginTop = elm.offsetHeight + "px";

 563  
 564                      deltaHeight = 0;
 565                      tinyMCE.getInstanceById(editorId).toolbarElement = elm;
 566  
 567                      //template['html'] = '<div id="mceExternalToolbar" align="center" class="mceToolbarExternal"><table width="100%" border="0" align="center"><tr><td align="center">'+toolbarHTML+'</td></tr></table></div>' + template["html"];

 568                  } else {
 569                      tinyMCE.getInstanceById(editorId).toolbarElement = null;
 570                  }
 571  
 572                  if (statusbarLocation == "bottom") {
 573                      template['html'] += '<tr><td class="mceStatusbarBottom" height="1">' + statusbarHTML + '</td></tr>';
 574                      deltaHeight -= 23;
 575                  }
 576  
 577                  template['html'] += '</tbody></table>';
 578                  //"SimpleLayout"

 579              break;
 580  
 581              case "RowLayout" : //Container Layout - containers defined in "theme_advanced_containers" are rendered from top to bottom.
 582                  template['html'] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width}px;height:{$height}px"><tbody>';
 583  
 584                  var containers = tinyMCE.getParam("theme_advanced_containers", "", true, ",");
 585                  var defaultContainerCSS = tinyMCE.getParam("theme_advanced_containers_default_class", "container");
 586                  var defaultContainerAlign = tinyMCE.getParam("theme_advanced_containers_default_align", "center");
 587  
 588                  //Render Containers:

 589                  for (var i = 0; i < containers.length; i++)
 590                  {
 591                      if (containers[i] == "mceEditor") //Exceptions for mceEditor and ...
 592                          template['html'] += '<tr><td align="center" class="mceEditor_border"><span id="{$editor_id}"></span></td></tr>';
 593                      else if (containers[i] == "mceElementpath" || containers[i] == "mceStatusbar") // ... mceElementpath:
 594                      {
 595                          var pathClass = "mceStatusbar";
 596  
 597                          if (i == containers.length-1)
 598                          {
 599                              pathClass = "mceStatusbarBottom";
 600                          }
 601                          else if (i == 0)
 602                          {
 603                              pathClass = "mceStatusbar";
 604                          }
 605                          else
 606                          {
 607                              deltaHeight-=2;
 608                          }
 609  
 610                          template['html'] += '<tr><td class="' + pathClass + '" height="1">' + statusbarHTML + '</td></tr>';
 611                          deltaHeight -= 22;
 612                      } else { // Render normal Container
 613                          var curContainer = tinyMCE.getParam("theme_advanced_container_"+containers[i], "", true, ',');
 614                          var curContainerHTML = "";
 615                          var curAlign = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_align", defaultContainerAlign);
 616                          var curCSS = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_class", defaultContainerCSS);
 617  
 618                          for (var j=0; j<curContainer.length; j++) {
 619                              curContainerHTML += tinyMCE.getControlHTML(curContainer[j]);
 620                          }
 621  
 622                          if (curContainer.length > 0) {
 623                              curContainerHTML += "<br />";
 624                              deltaHeight -= 23;
 625                          }
 626  
 627                          template['html'] += '<tr><td class="' + curCSS + '" align="' + curAlign + '" height="1">' + curContainerHTML + '</td></tr>';
 628                      }
 629                  }
 630  
 631                  template['html'] += '</tbody></table>';
 632                  //RowLayout

 633              break;
 634  
 635              case "CustomLayout" : //User defined layout callback...
 636                  var customLayout = tinyMCE.getParam("theme_advanced_custom_layout","");
 637  
 638                  if (customLayout != "" && eval("typeof(" + customLayout + ")") != "undefined") {
 639                      template = eval(customLayout + "(template);");
 640                  }
 641              break;
 642          }
 643  
 644          if (resizing)
 645              template['html'] += '<span id="{$editor_id}_resize_box" class="mceResizeBox"></span>';
 646  
 647          template['html'] = tinyMCE.replaceVar(template['html'], 'style_select_options', styleSelectHTML);
 648          template['delta_width'] = 0;
 649          template['delta_height'] = deltaHeight;
 650  
 651          return template;
 652      },
 653  
 654      initInstance : function(inst) {
 655          if (tinyMCE.getParam("theme_advanced_resizing", false)) {
 656              if (tinyMCE.getParam("theme_advanced_resizing_use_cookie", true)) {
 657                  var w = TinyMCE_AdvancedTheme._getCookie("TinyMCE_" + inst.editorId + "_width");
 658                  var h = TinyMCE_AdvancedTheme._getCookie("TinyMCE_" + inst.editorId + "_height");
 659  
 660                  TinyMCE_AdvancedTheme._resizeTo(inst, w, h, tinyMCE.getParam("theme_advanced_resize_horizontal", true));
 661              }
 662          }
 663  
 664          inst.addShortcut('ctrl', 'k', 'lang_link_desc', 'mceLink');
 665      },
 666  
 667      /**

 668       * Node change handler.

 669       */
 670      handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection, setup_content) {
 671  		function selectByValue(select_elm, value, first_index) {
 672              first_index = typeof(first_index) == "undefined" ? false : true;
 673  
 674              if (select_elm) {
 675                  for (var i=0; i<select_elm.options.length; i++) {
 676                      var ov = "" + select_elm.options[i].value;
 677  
 678                      if (first_index && ov.toLowerCase().indexOf(value.toLowerCase()) == 0) {
 679                          select_elm.selectedIndex = i;
 680                          return true;
 681                      }
 682  
 683                      if (ov == value) {
 684                          select_elm.selectedIndex = i;
 685                          return true;
 686                      }
 687                  }
 688              }
 689  
 690              return false;
 691          };
 692  
 693  		function getAttrib(elm, name) {
 694              return elm.getAttribute(name) ? elm.getAttribute(name) : "";
 695          };
 696  
 697          // No node provided

 698          if (node == null)
 699              return;
 700  
 701          // Update path

 702          var pathElm = document.getElementById(editor_id + "_path");
 703          var inst = tinyMCE.getInstanceById(editor_id);
 704          var doc = inst.getDoc();
 705  
 706          if (pathElm) {
 707              // Get node path

 708              var parentNode = node;
 709              var path = new Array();
 710              
 711              while (parentNode != null) {
 712                  if (parentNode.nodeName.toUpperCase() == "BODY") {
 713                      break;
 714                  }
 715  
 716                  // Only append element nodes to path

 717                  if (parentNode.nodeType == 1 && tinyMCE.getAttrib(parentNode, "class").indexOf('mceItemHidden') == -1) {
 718                      path[path.length] = parentNode;
 719                  }
 720  
 721                  parentNode = parentNode.parentNode;
 722              }
 723  
 724              // Setup HTML

 725              var html = "";
 726              for (var i=path.length-1; i>=0; i--) {
 727                  var nodeName = path[i].nodeName.toLowerCase();
 728                  var nodeData = "";
 729  
 730                  if (nodeName == "b") {
 731                      nodeName = "strong";
 732                  }
 733  
 734                  if (nodeName == "i") {
 735                      nodeName = "em";
 736                  }
 737  
 738                  if (nodeName == "span") {
 739                      var cn = tinyMCE.getAttrib(path[i], "class");
 740                      if (cn != "" && cn.indexOf('mceItem') == -1)
 741                          nodeData += "class: " + cn + " ";
 742  
 743                      var st = tinyMCE.getAttrib(path[i], "style");
 744                      if (st != "") {
 745                          st = tinyMCE.serializeStyle(tinyMCE.parseStyle(st));
 746                          nodeData += "style: " + st + " ";
 747                      }
 748                  }
 749  
 750                  if (nodeName == "font") {
 751                      if (tinyMCE.getParam("convert_fonts_to_spans"))
 752                          nodeName = "span";
 753  
 754                      var face = tinyMCE.getAttrib(path[i], "face");
 755                      if (face != "")
 756                          nodeData += "font: " + face + " ";
 757  
 758                      var size = tinyMCE.getAttrib(path[i], "size");
 759                      if (size != "")
 760                          nodeData += "size: " + size + " ";
 761  
 762                      var color = tinyMCE.getAttrib(path[i], "color");
 763                      if (color != "")
 764                          nodeData += "color: " + color + " ";
 765                  }
 766  
 767                  if (getAttrib(path[i], 'id') != "") {
 768                      nodeData += "id: " + path[i].getAttribute('id') + " ";
 769                  }
 770  
 771                  var className = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i], "class"), false);
 772                  if (className != "" && className.indexOf('mceItem') == -1)
 773                      nodeData += "class: " + className + " ";
 774  
 775                  if (getAttrib(path[i], 'src') != "") {
 776                      var src = tinyMCE.getAttrib(path[i], "mce_src");
 777  
 778                      if (src == "")
 779                           src = tinyMCE.getAttrib(path[i], "src");
 780  
 781                      nodeData += "src: " + src + " ";
 782                  }
 783  
 784                  if (getAttrib(path[i], 'href') != "") {
 785                      var href = tinyMCE.getAttrib(path[i], "mce_href");
 786  
 787                      if (href == "")
 788                           href = tinyMCE.getAttrib(path[i], "href");
 789  
 790                      nodeData += "href: " + href + " ";
 791                  }
 792  
 793                  if (nodeName == "img" && tinyMCE.getAttrib(path[i], "class").indexOf('mceItemFlash') != -1) {
 794                      nodeName = "flash";
 795                      nodeData = "src: " + path[i].getAttribute('title');
 796                  }
 797  
 798                  if (nodeName == "a" && (anchor = tinyMCE.getAttrib(path[i], "name")) != "") {
 799                      nodeName = "a";
 800                      nodeName += "#" + anchor;
 801                      nodeData = "";
 802                  }
 803  
 804                  if (getAttrib(path[i], 'name').indexOf("mce_") != 0) {
 805                      var className = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i], "class"), false);
 806                      if (className != "" && className.indexOf('mceItem') == -1) {
 807                          nodeName += "." + className;
 808                      }
 809                  }
 810  
 811                  var cmd = 'tinyMCE.execInstanceCommand(\'' + editor_id + '\',\'mceSelectNodeDepth\',false,\'' + i + '\');';
 812                  html += '<a title="' + nodeData + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" target="_self" class="mcePathItem">' + nodeName + '</a>';
 813  
 814                  if (i > 0) {
 815                      html += " &raquo; ";
 816                  }
 817              }
 818  
 819              pathElm.innerHTML = '<a href="#" accesskey="x"></a>' + tinyMCE.getLang('lang_theme_path') + ": " + html + '&#160;';
 820          }
 821  
 822          // Reset old states

 823          tinyMCE.switchClass(editor_id + '_justifyleft', 'mceButtonNormal');
 824          tinyMCE.switchClass(editor_id + '_justifyright', 'mceButtonNormal');
 825          tinyMCE.switchClass(editor_id + '_justifycenter', 'mceButtonNormal');
 826          tinyMCE.switchClass(editor_id + '_justifyfull', 'mceButtonNormal');
 827          tinyMCE.switchClass(editor_id + '_bold', 'mceButtonNormal');
 828          tinyMCE.switchClass(editor_id + '_italic', 'mceButtonNormal');
 829          tinyMCE.switchClass(editor_id + '_underline', 'mceButtonNormal');
 830          tinyMCE.switchClass(editor_id + '_strikethrough', 'mceButtonNormal');
 831          tinyMCE.switchClass(editor_id + '_bullist', 'mceButtonNormal');
 832          tinyMCE.switchClass(editor_id + '_numlist', 'mceButtonNormal');
 833          tinyMCE.switchClass(editor_id + '_sub', 'mceButtonNormal');
 834          tinyMCE.switchClass(editor_id + '_sup', 'mceButtonNormal');
 835          tinyMCE.switchClass(editor_id + '_anchor', 'mceButtonNormal');
 836          tinyMCE.switchClass(editor_id + '_link', 'mceButtonDisabled');
 837          tinyMCE.switchClass(editor_id + '_unlink', 'mceButtonDisabled');
 838          tinyMCE.switchClass(editor_id + '_outdent', 'mceButtonDisabled');
 839          tinyMCE.switchClass(editor_id + '_image', 'mceButtonNormal');
 840          tinyMCE.switchClass(editor_id + '_hr', 'mceButtonNormal');
 841  
 842          if (node.nodeName == "A" && tinyMCE.getAttrib(node, "class").indexOf('mceItemAnchor') != -1)
 843              tinyMCE.switchClass(editor_id + '_anchor', 'mceButtonSelected');
 844  
 845          // Get link

 846          var anchorLink = tinyMCE.getParentElement(node, "a", "href");
 847  
 848          if (anchorLink || any_selection) {
 849              tinyMCE.switchClass(editor_id + '_link', anchorLink ? 'mceButtonSelected' : 'mceButtonNormal');
 850              tinyMCE.switchClass(editor_id + '_unlink', anchorLink ? 'mceButtonSelected' : 'mceButtonNormal');
 851          }
 852  
 853          // Handle visual aid

 854          tinyMCE.switchClass(editor_id + '_visualaid', visual_aid ? 'mceButtonSelected' : 'mceButtonNormal');
 855  
 856          if (undo_levels != -1) {
 857              tinyMCE.switchClass(editor_id + '_undo', 'mceButtonDisabled');
 858              tinyMCE.switchClass(editor_id + '_redo', 'mceButtonDisabled');
 859          }
 860  
 861          // Within li, blockquote

 862          if (tinyMCE.getParentElement(node, "li,blockquote"))
 863              tinyMCE.switchClass(editor_id + '_outdent', 'mceButtonNormal');
 864  
 865          // Has redo levels

 866          if (undo_index != -1 && (undo_index < undo_levels-1 && undo_levels > 0))
 867              tinyMCE.switchClass(editor_id + '_redo', 'mceButtonNormal');
 868  
 869          // Has undo levels

 870          if (undo_index != -1 && (undo_index > 0 && undo_levels > 0))
 871              tinyMCE.switchClass(editor_id + '_undo', 'mceButtonNormal');
 872  
 873          // Select class in select box

 874          var selectElm = document.getElementById(editor_id + "_styleSelect");
 875          
 876          if (selectElm) {
 877              TinyMCE_AdvancedTheme._setupCSSClasses(editor_id);
 878  
 879              classNode = node;
 880              breakOut = false;
 881              var index = 0;
 882  
 883              do {
 884                  if (classNode && classNode.className) {
 885                      for (var i=0; i<selectElm.options.length; i++) {
 886                          if (selectElm.options[i].value == classNode.className) {
 887                              index = i;
 888                              breakOut = true;
 889                              break;
 890                          }
 891                      }
 892                  }
 893              } while (!breakOut && classNode != null && (classNode = classNode.parentNode) != null);
 894  
 895              selectElm.selectedIndex = index;
 896          }
 897  
 898          // Select formatblock

 899          var selectElm = document.getElementById(editor_id + "_formatSelect");
 900          if (selectElm) {
 901              var elm = tinyMCE.getParentElement(node, "p,div,h1,h2,h3,h4,h5,h6,pre,address");
 902  
 903              if (elm)
 904                  selectByValue(selectElm, "<" + elm.nodeName.toLowerCase() + ">");
 905              else
 906                  selectByValue(selectElm, "");
 907          }
 908  
 909          // Select fontselect

 910          var selectElm = document.getElementById(editor_id + "_fontNameSelect");
 911          if (selectElm) {
 912              if (!tinyMCE.isSafari && !(tinyMCE.isMSIE && !tinyMCE.isOpera)) {
 913                  var face = inst.queryCommandValue('FontName');
 914  
 915                  face = face == null || face == "" ? "" : face;
 916  
 917                  selectByValue(selectElm, face, face != "");
 918              } else {
 919                  var elm = tinyMCE.getParentElement(node, "font", "face");
 920  
 921                  if (elm) {
 922                      var family = tinyMCE.getAttrib(elm, "face");
 923  
 924                      if (family == '')
 925                          family = '' + elm.style.fontFamily;
 926  
 927                      if (!selectByValue(selectElm, family, family != ""))
 928                          selectByValue(selectElm, "");
 929                  } else
 930                      selectByValue(selectElm, "");
 931              }
 932          }
 933  
 934          // Select fontsize

 935          var selectElm = document.getElementById(editor_id + "_fontSizeSelect");
 936          if (selectElm) {
 937              if (!tinyMCE.isSafari && !tinyMCE.isOpera) {
 938                  var size = inst.queryCommandValue('FontSize');
 939                  selectByValue(selectElm, size == null || size == "" ? "0" : size);
 940              } else {
 941                  var elm = tinyMCE.getParentElement(node, "font", "size");
 942                  if (elm) {
 943                      var size = tinyMCE.getAttrib(elm, "size");
 944  
 945                      if (size == '') {
 946                          var sizes = new Array('', '8px', '10px', '12px', '14px', '18px', '24px', '36px');
 947  
 948                          size = '' + elm.style.fontSize;
 949  
 950                          for (var i=0; i<sizes.length; i++) {
 951                              if (('' + sizes[i]) == size) {
 952                                  size = i;
 953                                  break;
 954                              }
 955                          }
 956                      }
 957  
 958                      if (!selectByValue(selectElm, size))
 959                          selectByValue(selectElm, "");
 960                  } else
 961                      selectByValue(selectElm, "0");
 962              }
 963          }
 964  
 965          // Handle align attributes

 966          alignNode = node;
 967          breakOut = false;
 968          do {
 969              if (!alignNode.getAttribute || !alignNode.getAttribute('align'))
 970                  continue;
 971  
 972              switch (alignNode.getAttribute('align').toLowerCase()) {
 973                  case "left":
 974                      tinyMCE.switchClass(editor_id + '_justifyleft', 'mceButtonSelected');
 975                      breakOut = true;
 976                  break;
 977  
 978                  case "right":
 979                      tinyMCE.switchClass(editor_id + '_justifyright', 'mceButtonSelected');
 980                      breakOut = true;
 981                  break;
 982  
 983                  case "middle":
 984                  case "center":
 985                      tinyMCE.switchClass(editor_id + '_justifycenter', 'mceButtonSelected');
 986                      breakOut = true;
 987                  break;
 988  
 989                  case "justify":
 990                      tinyMCE.switchClass(editor_id + '_justifyfull', 'mceButtonSelected');
 991                      breakOut = true;
 992                  break;
 993              }
 994          } while (!breakOut && (alignNode = alignNode.parentNode) != null);
 995  
 996          // Div justification

 997          var div = tinyMCE.getParentElement(node, "div");
 998          if (div && div.style.textAlign == "center")
 999              tinyMCE.switchClass(editor_id + '_justifycenter', 'mceButtonSelected');
1000  
1001          // Do special text

1002          if (!setup_content) {
1003              // , "JustifyLeft", "_justifyleft", "JustifyCenter", "justifycenter", "JustifyRight", "justifyright", "JustifyFull", "justifyfull", "InsertUnorderedList", "bullist", "InsertOrderedList", "numlist", "InsertUnorderedList", "bullist", "Outdent", "outdent", "Indent", "indent", "subscript", "sub"

1004              var ar = new Array("Bold", "_bold", "Italic", "_italic", "Strikethrough", "_strikethrough", "superscript", "_sup", "subscript", "_sub");
1005              for (var i=0; i<ar.length; i+=2) {
1006                  if (inst.queryCommandState(ar[i]))
1007                      tinyMCE.switchClass(editor_id + ar[i+1], 'mceButtonSelected');
1008              }
1009  
1010              if (inst.queryCommandState("Underline") && (node.parentNode == null || node.parentNode.nodeName != "A"))
1011                  tinyMCE.switchClass(editor_id + '_underline', 'mceButtonSelected');
1012          }
1013  
1014          // Handle elements

1015          do {
1016              switch (node.nodeName) {
1017                  case "UL":
1018                      tinyMCE.switchClass(editor_id + '_bullist', 'mceButtonSelected');
1019                  break;
1020  
1021                  case "OL":
1022                      tinyMCE.switchClass(editor_id + '_numlist', 'mceButtonSelected');
1023                  break;
1024  
1025                  case "HR":
1026                       tinyMCE.switchClass(editor_id + '_hr', 'mceButtonSelected');
1027                  break;
1028  
1029                  case "IMG":
1030                  if (getAttrib(node, 'name').indexOf('mce_') != 0) {
1031                      tinyMCE.switchClass(editor_id + '_image', 'mceButtonSelected');
1032                  }
1033                  break;
1034              }
1035          } while ((node = node.parentNode) != null);
1036      },
1037  
1038      // Private theme internal functions

1039  
1040      // This function auto imports CSS classes into the class selection droplist

1041      _setupCSSClasses : function(editor_id) {
1042          var i, selectElm;
1043  
1044          if (!TinyMCE_AdvancedTheme._autoImportCSSClasses)
1045              return;
1046  
1047          selectElm = document.getElementById(editor_id + '_styleSelect');
1048  
1049          if (selectElm && selectElm.getAttribute('cssImported') != 'true') {
1050              var csses = tinyMCE.getCSSClasses(editor_id);
1051              if (csses && selectElm)    {
1052                  for (i=0; i<csses.length; i++)
1053                      selectElm.options[selectElm.options.length] = new Option(csses[i], csses[i]);
1054              }
1055  
1056              // Only do this once

1057              if (csses != null && csses.length > 0)
1058                  selectElm.setAttribute('cssImported', 'true');
1059          }
1060      },
1061  
1062      _setCookie : function(name, value, expires, path, domain, secure) {
1063          var curCookie = name + "=" + escape(value) +
1064              ((expires) ? "; expires=" + expires.toGMTString() : "") +
1065              ((path) ? "; path=" + escape(path) : "") +
1066              ((domain) ? "; domain=" + domain : "") +
1067              ((secure) ? "; secure" : "");
1068  
1069          document.cookie = curCookie;
1070      },
1071  
1072      _getCookie : function(name) {
1073          var dc = document.cookie;
1074          var prefix = name + "=";
1075          var begin = dc.indexOf("; " + prefix);
1076  
1077          if (begin == -1) {
1078              begin = dc.indexOf(prefix);
1079  
1080              if (begin != 0)
1081                  return null;
1082          } else
1083              begin += 2;
1084  
1085          var end = document.cookie.indexOf(";", begin);
1086  
1087          if (end == -1)
1088              end = dc.length;
1089  
1090          return unescape(dc.substring(begin + prefix.length, end));
1091      },
1092  
1093      _resizeTo : function(inst, w, h, set_w) {
1094          var editorContainer = document.getElementById(inst.editorId + '_parent');
1095          var tableElm = editorContainer.firstChild;
1096          var iframe = inst.iframeElement;
1097  
1098          if (w == null || w == "null") {
1099              set_w = false;
1100              w = 0;
1101          }
1102  
1103          if (h == null || h == "null")
1104              return;
1105  
1106          w = parseInt(w);
1107          h = parseInt(h);
1108  
1109          if (tinyMCE.isGecko) {
1110              w += 2;
1111              h += 2;
1112          }
1113  
1114          var dx = w - tableElm.clientWidth;
1115          var dy = h - tableElm.clientHeight;
1116  
1117          w = w < 1 ? 30 : w;
1118          h = h < 1 ? 30 : h;
1119  
1120          if (set_w)
1121              tableElm.style.width = w + "px";
1122  
1123          tableElm.style.height = h + "px";
1124  
1125          iw = iframe.clientWidth + dx;
1126          ih = iframe.clientHeight + dy;
1127  
1128          iw = iw < 1 ? 30 : iw;
1129          ih = ih < 1 ? 30 : ih;
1130  
1131          if (tinyMCE.isGecko) {
1132              iw -= 2;
1133              ih -= 2;
1134          }
1135  
1136          if (set_w)
1137              iframe.style.width = iw + "px";
1138  
1139          iframe.style.height = ih + "px";
1140  
1141          // Is it to small, make it bigger again

1142          if (set_w) {
1143              var tableBodyElm = tableElm.firstChild;
1144              var minIframeWidth = tableBodyElm.scrollWidth;
1145              if (inst.iframeElement.clientWidth < minIframeWidth) {
1146                  dx = minIframeWidth - inst.iframeElement.clientWidth;
1147  
1148                  inst.iframeElement.style.width = (iw + dx) + "px";
1149              }
1150          }
1151      },
1152  
1153      /**

1154       * Handles resizing events.

1155       */
1156      _resizeEventHandler : function(e) {
1157          var resizer = TinyMCE_AdvancedTheme._resizer;
1158  
1159          // Do nothing

1160          if (!resizer.resizing)
1161              return;
1162  
1163          e = typeof(e) == "undefined" ? window.event : e;
1164  
1165          var dx = e.screenX - resizer.downX;
1166          var dy = e.screenY - resizer.downY;
1167          var resizeBox = resizer.resizeBox;
1168          var editorId = resizer.editorId;
1169  
1170          switch (e.type) {
1171              case "mousemove":
1172                  var w, h;
1173  
1174                  w = resizer.width + dx;
1175                  h = resizer.height + dy;
1176  
1177                  w = w < 1 ? 1 : w;
1178                  h = h < 1 ? 1 : h;
1179  
1180                  if (resizer.horizontal)
1181                      resizeBox.style.width = w + "px";
1182  
1183                  resizeBox.style.height = h + "px";
1184                  break;
1185  
1186              case "mouseup":
1187                  TinyMCE_AdvancedTheme._setResizing(e, editorId, false);
1188                  TinyMCE_AdvancedTheme._resizeTo(tinyMCE.getInstanceById(editorId), resizer.width + dx, resizer.height + dy, resizer.horizontal);
1189  
1190                  // Expire in a month

1191                  if (tinyMCE.getParam("theme_advanced_resizing_use_cookie", true)) {
1192                      var expires = new Date();
1193                      expires.setTime(expires.getTime() + 3600000 * 24 * 30);
1194  
1195                      // Set the cookies

1196                      TinyMCE_AdvancedTheme._setCookie("TinyMCE_" + editorId + "_width", "" + (resizer.horizontal ? resizer.width + dx : ""), expires);
1197                      TinyMCE_AdvancedTheme._setCookie("TinyMCE_" + editorId + "_height", "" + (resizer.height + dy), expires);
1198                  }
1199                  break;
1200          }
1201      },
1202  
1203      /**

1204       * Starts/stops the editor resizing.

1205       */
1206      _setResizing : function(e, editor_id, state) {
1207          e = typeof(e) == "undefined" ? window.event : e;
1208  
1209          var resizer = TinyMCE_AdvancedTheme._resizer;
1210          var editorContainer = document.getElementById(editor_id + '_parent');
1211          var editorArea = document.getElementById(editor_id + '_parent').firstChild;
1212          var resizeBox = document.getElementById(editor_id + '_resize_box');
1213          var inst = tinyMCE.getInstanceById(editor_id);
1214  
1215          if (state) {
1216              // Place box over editor area

1217              var width = editorArea.clientWidth;
1218              var height = editorArea.clientHeight;
1219  
1220              resizeBox.style.width = width + "px";
1221              resizeBox.style.height = height + "px";
1222  
1223              resizer.iframeWidth = inst.iframeElement.clientWidth;
1224              resizer.iframeHeight = inst.iframeElement.clientHeight;
1225  
1226              // Hide editor and show resize box

1227              editorArea.style.display = "none";
1228              resizeBox.style.display = "block";
1229  
1230              // Add event handlers, only once

1231              if (!resizer.eventHandlers) {
1232                  if (tinyMCE.isMSIE)
1233                      tinyMCE.addEvent(document, "mousemove", TinyMCE_AdvancedTheme._resizeEventHandler);
1234                  else
1235                      tinyMCE.addEvent(window, "mousemove", TinyMCE_AdvancedTheme._resizeEventHandler);
1236  
1237                  tinyMCE.addEvent(document, "mouseup", TinyMCE_AdvancedTheme._resizeEventHandler);
1238  
1239                  resizer.eventHandlers = true;
1240              }
1241  
1242              resizer.resizing = true;
1243              resizer.downX = e.screenX;
1244              resizer.downY = e.screenY;
1245              resizer.width = parseInt(resizeBox.style.width);
1246              resizer.height = parseInt(resizeBox.style.height);
1247              resizer.editorId = editor_id;
1248              resizer.resizeBox = resizeBox;
1249              resizer.horizontal = tinyMCE.getParam("theme_advanced_resize_horizontal", true);
1250          } else {
1251              resizer.resizing = false;
1252              resizeBox.style.display = "none";
1253              editorArea.style.display = tinyMCE.isMSIE && !tinyMCE.isOpera ? "block" : "table";
1254              tinyMCE.execCommand('mceResetDesignMode');
1255          }
1256      },
1257  
1258      _insertImage : function(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout) {
1259          tinyMCE.execCommand('mceBeginUndoLevel');
1260  
1261          if (src == "")
1262              return;
1263  
1264          if (!tinyMCE.imgElement && tinyMCE.isSafari) {
1265              var html = "";
1266  
1267              html += '<img src="' + src + '" alt="' + alt + '"';
1268              html += ' border="' + border + '" hspace="' + hspace + '"';
1269              html += ' vspace="' + vspace + '" width="' + width + '"';
1270              html += ' height="' + height + '" align="' + align + '" title="' + title + '" onmouseover="' + onmouseover + '" onmouseout="' + onmouseout + '" />';
1271  
1272              tinyMCE.execCommand("mceInsertContent", false, html);
1273          } else {
1274              if (!tinyMCE.imgElement && tinyMCE.selectedInstance) {
1275                  if (tinyMCE.isSafari)
1276                      tinyMCE.execCommand("mceInsertContent", false, '<img src="' + tinyMCE.uniqueURL + '" />');
1277                  else
1278                      tinyMCE.selectedInstance.contentDocument.execCommand("insertimage", false, tinyMCE.uniqueURL);
1279  
1280                  tinyMCE.imgElement = tinyMCE.getElementByAttributeValue(tinyMCE.selectedInstance.contentDocument.body, "img", "src", tinyMCE.uniqueURL);
1281              }
1282          }
1283  
1284          if (tinyMCE.imgElement) {
1285              var needsRepaint = false;
1286              var msrc = src;
1287  
1288              src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, tinyMCE.imgElement);");
1289  
1290              if (tinyMCE.getParam('convert_urls'))
1291                  msrc = src;
1292  
1293              if (onmouseover && onmouseover != "")
1294                  onmouseover = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, tinyMCE.imgElement);") + "';";
1295  
1296              if (onmouseout && onmouseout != "")
1297                  onmouseout = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, tinyMCE.imgElement);") + "';";
1298  
1299              // Use alt as title if it's undefined

1300              if (typeof(title) == "undefined")
1301                  title = alt;
1302  
1303              if (width != tinyMCE.imgElement.getAttribute("width") || height != tinyMCE.imgElement.getAttribute("height") || align != tinyMCE.imgElement.getAttribute("align"))
1304                  needsRepaint = true;
1305  
1306              tinyMCE.setAttrib(tinyMCE.imgElement, 'src', src);
1307              tinyMCE.setAttrib(tinyMCE.imgElement, 'mce_src', msrc);
1308              tinyMCE.setAttrib(tinyMCE.imgElement, 'alt', alt);
1309              tinyMCE.setAttrib(tinyMCE.imgElement, 'title', title);
1310              tinyMCE.setAttrib(tinyMCE.imgElement, 'align', align);
1311              tinyMCE.setAttrib(tinyMCE.imgElement, 'border', border, true);
1312              tinyMCE.setAttrib(tinyMCE.imgElement, 'hspace', hspace, true);
1313              tinyMCE.setAttrib(tinyMCE.imgElement, 'vspace', vspace, true);
1314              tinyMCE.setAttrib(tinyMCE.imgElement, 'width', width, true);
1315              tinyMCE.setAttrib(tinyMCE.imgElement, 'height', height, true);
1316              tinyMCE.setAttrib(tinyMCE.imgElement, 'onmouseover', onmouseover);
1317              tinyMCE.setAttrib(tinyMCE.imgElement, 'onmouseout', onmouseout);
1318  
1319              // Fix for bug #989846 - Image resize bug

1320              if (width && width != "")
1321                  tinyMCE.imgElement.style.pixelWidth = width;
1322  
1323              if (height && height != "")
1324                  tinyMCE.imgElement.style.pixelHeight = height;
1325  
1326              if (needsRepaint)
1327                  tinyMCE.selectedInstance.repaint();
1328          }
1329  
1330          tinyMCE.execCommand('mceEndUndoLevel');
1331      },
1332  
1333      _insertLink : function(href, target, title, onclick, style_class) {
1334          tinyMCE.execCommand('mceBeginUndoLevel');
1335  
1336          if (tinyMCE.selectedInstance && tinyMCE.selectedElement && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") {
1337              var doc = tinyMCE.selectedInstance.getDoc();
1338              var linkElement = tinyMCE.getParentElement(tinyMCE.selectedElement, "a");
1339              var newLink = false;
1340  
1341              if (!linkElement) {
1342                  linkElement = doc.createElement("a");
1343                  newLink = true;
1344              }
1345  
1346              var mhref = href;
1347              var thref = eval(tinyMCE.settings['urlconverter_callback'] + "(href, linkElement);");
1348              mhref = tinyMCE.getParam('convert_urls') ? href : mhref;
1349  
1350              tinyMCE.setAttrib(linkElement, 'href', thref);
1351              tinyMCE.setAttrib(linkElement, 'mce_href', mhref);
1352              tinyMCE.setAttrib(linkElement, 'target', target);
1353              tinyMCE.setAttrib(linkElement, 'title', title);
1354              tinyMCE.setAttrib(linkElement, 'onclick', onclick);
1355              tinyMCE.setAttrib(linkElement, 'class', style_class);
1356  
1357              if (newLink) {
1358                  linkElement.appendChild(tinyMCE.selectedElement.cloneNode(true));
1359                  tinyMCE.selectedElement.parentNode.replaceChild(linkElement, tinyMCE.selectedElement);
1360              }
1361  
1362              return;
1363          }
1364  
1365          if (!tinyMCE.linkElement && tinyMCE.selectedInstance) {
1366              if (tinyMCE.isSafari) {
1367                  tinyMCE.execCommand("mceInsertContent", false, '<a href="' + tinyMCE.uniqueURL + '">' + tinyMCE.selectedInstance.selection.getSelectedHTML() + '</a>');
1368              } else
1369                  tinyMCE.selectedInstance.contentDocument.execCommand("createlink", false, tinyMCE.uniqueURL);
1370  
1371              tinyMCE.linkElement = tinyMCE.getElementByAttributeValue(tinyMCE.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL);
1372  
1373              var elementArray = tinyMCE.getElementsByAttributeValue(tinyMCE.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL);
1374  
1375              for (var i=0; i<elementArray.length; i++) {
1376                  var mhref = href;
1377                  var thref = eval(tinyMCE.settings['urlconverter_callback'] + "(href, elementArray[i]);");
1378                  mhref = tinyMCE.getParam('convert_urls') ? href : mhref;
1379  
1380                  tinyMCE.setAttrib(elementArray[i], 'href', thref);
1381                  tinyMCE.setAttrib(elementArray[i], 'mce_href', mhref);
1382                  tinyMCE.setAttrib(elementArray[i], 'target', target);
1383                  tinyMCE.setAttrib(elementArray[i], 'title', title);
1384                  tinyMCE.setAttrib(elementArray[i], 'onclick', onclick);
1385                  tinyMCE.setAttrib(elementArray[i], 'class', style_class);
1386              }
1387  
1388              tinyMCE.linkElement = elementArray[0];
1389          }
1390  
1391          if (tinyMCE.linkElement) {
1392              var mhref = href;
1393              href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement);");
1394              mhref = tinyMCE.getParam('convert_urls') ? href : mhref;
1395  
1396              tinyMCE.setAttrib(tinyMCE.linkElement, 'href', href);
1397              tinyMCE.setAttrib(tinyMCE.linkElement, 'mce_href', mhref);
1398              tinyMCE.setAttrib(tinyMCE.linkElement, 'target', target);
1399              tinyMCE.setAttrib(tinyMCE.linkElement, 'title', title);
1400              tinyMCE.setAttrib(tinyMCE.linkElement, 'onclick', onclick);
1401              tinyMCE.setAttrib(tinyMCE.linkElement, 'class', style_class);
1402          }
1403  
1404          tinyMCE.execCommand('mceEndUndoLevel');
1405      }
1406  };
1407  
1408  tinyMCE.addTheme("advanced", TinyMCE_AdvancedTheme);
1409  
1410  // Add default buttons maps for advanced theme and all internal plugins

1411  tinyMCE.addButtonMap(TinyMCE_AdvancedTheme._buttonMap);


Généré le : Fri Mar 30 01:27:52 2007 par Balluche grâce à PHPXref 0.7