[ Index ]
 

Code source de eGroupWare 1.2.106-2

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

title

Body

[fermer]

/phpgwapi/js/tinymce/jscripts/tiny_mce/themes/advanced/ -> editor_template_src.js (source)

   1  /* Import theme specific language pack */
   2  tinyMCE.importThemeLanguagePack('advanced');
   3  
   4  // Variable declarations
   5  var TinyMCE_advanced_autoImportCSSClasses = true;
   6  var TinyMCE_advanced_foreColor = "#000000";
   7  var TinyMCE_advanced_anchorName = "";
   8  var TinyMCE_advanced_buttons = [
   9          // Control id, button img, button title, command, user_interface, value
  10          ['bold', '{$lang_bold_img}', '{$lang_bold_desc}', 'Bold'],
  11          ['italic', '{$lang_italic_img}', '{$lang_italic_desc}', 'Italic'],
  12          ['underline', '{$lang_underline_img}', '{$lang_underline_desc}', 'Underline'],
  13          ['strikethrough', 'strikethrough.gif', '{$lang_striketrough_desc}', 'Strikethrough'],
  14          ['justifyleft', 'left.gif', '{$lang_justifyleft_desc}', 'JustifyLeft'],
  15          ['justifycenter', 'center.gif', '{$lang_justifycenter_desc}', 'JustifyCenter'],
  16          ['justifyright', 'right.gif', '{$lang_justifyright_desc}', 'JustifyRight'],
  17          ['justifyfull', 'full.gif', '{$lang_justifyfull_desc}', 'JustifyFull'],
  18          ['bullist', 'bullist.gif', '{$lang_bullist_desc}', 'InsertUnorderedList'],
  19          ['numlist', 'numlist.gif', '{$lang_numlist_desc}', 'InsertOrderedList'],
  20          ['outdent', 'outdent.gif', '{$lang_outdent_desc}', 'Outdent'],
  21          ['indent', 'indent.gif', '{$lang_indent_desc}', 'Indent'],
  22          ['cut', 'cut.gif', '{$lang_cut_desc}', 'Cut'],
  23          ['copy', 'copy.gif', '{$lang_copy_desc}', 'Copy'],
  24          ['paste', 'paste.gif', '{$lang_paste_desc}', 'Paste'],
  25          ['undo', 'undo.gif', '{$lang_undo_desc}', 'Undo'],
  26          ['redo', 'redo.gif', '{$lang_redo_desc}', 'Redo'],
  27          ['link', 'link.gif', '{$lang_link_desc}', 'mceLink', true],
  28          ['unlink', 'unlink.gif', '{$lang_unlink_desc}', 'unlink'],
  29          ['image', 'image.gif', '{$lang_image_desc}', 'mceImage', true],
  30          ['cleanup', 'cleanup.gif', '{$lang_cleanup_desc}', 'mceCleanup'],
  31          ['help', 'help.gif', '{$lang_help_desc}', 'mceHelp'],
  32          ['code', 'code.gif', '{$lang_theme_code_desc}', 'mceCodeEditor'],
  33          ['hr', 'hr.gif', '{$lang_theme_hr_desc}', 'inserthorizontalrule'],
  34          ['removeformat', 'removeformat.gif', '{$lang_theme_removeformat_desc}', 'removeformat'],
  35          ['sub', 'sub.gif', '{$lang_theme_sub_desc}', 'subscript'],
  36          ['sup', 'sup.gif', '{$lang_theme_sup_desc}', 'superscript'],
  37          ['forecolor', 'forecolor.gif', '{$lang_theme_forecolor_desc}', 'mceForeColor', true],
  38          ['backcolor', 'backcolor.gif', '{$lang_theme_backcolor_desc}', 'mceBackColor', true],
  39          ['charmap', 'charmap.gif', '{$lang_theme_charmap_desc}', 'mceCharMap'],
  40          ['visualaid', 'visualaid.gif', '{$lang_theme_visualaid_desc}', 'mceToggleVisualAid'],
  41          ['anchor', 'anchor.gif', '{$lang_theme_anchor_desc}', 'mceInsertAnchor'],
  42          ['newdocument', 'newdocument.gif', '{$lang_newdocument_desc}', 'mceSetContent', false, '']
  43      ];
  44  
  45  
  46  /**
  47   * Returns HTML code for the specificed control.
  48   */
  49  function TinyMCE_advanced_getControlHTML(button_name) {
  50      var buttonTileMap = new Array('anchor.gif','backcolor.gif','bullist.gif','center.gif','charmap.gif','cleanup.gif','code.gif','copy.gif','custom_1.gif','cut.gif','forecolor.gif','full.gif','help.gif','hr.gif','image.gif','indent.gif','left.gif','link.gif','numlist.gif','outdent.gif','paste.gif','redo.gif','removeformat.gif','right.gif','strikethrough.gif','sub.gif','sup.gif','undo.gif','unlink.gif','visualaid.gif');
  51  
  52      // Lookup button in button list
  53      for (var i=0; i<TinyMCE_advanced_buttons.length; i++) {
  54          var but = TinyMCE_advanced_buttons[i];
  55          if (but[0] == button_name) {
  56              var safariPatch = '" onclick="';
  57  
  58              if (tinyMCE.isSafari)
  59                  safariPatch = "";
  60  
  61              // Check for it in tilemap
  62              if (tinyMCE.settings['button_tile_map']) {
  63                  for (var x=0; !tinyMCE.isMSIE && x<buttonTileMap.length; x++) {
  64                      if (buttonTileMap[x] == but[1])
  65                          return '<img id="{$editor_id}_' + but[0] + '" src="{$themeurl}/images/spacer.gif" style="background-image:url({$themeurl}/images/buttons.gif); background-position: ' + (0-(x*20)) + 'px 0px" title="' + but[2] + '" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');' + safariPatch + 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + but[3] + '\', ' + (but.length > 4 ? but[4] : false) + (but.length > 5 ? ', \'' + but[5] + '\'' : '') + ')">';
  66                  }
  67              }
  68  
  69              // Old style
  70              return '<img id="{$editor_id}_' + but[0] + '" src="{$themeurl}/images/' + but[1] + '" title="' + but[2] + '" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');' + safariPatch + 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + but[3] + '\', ' + (but.length > 4 ? but[4] : false) + (but.length > 5 ? ', \'' + but[5] + '\'' : '') + ')">';
  71          }
  72      }
  73  
  74      // Custom controlls other than buttons
  75      switch (button_name) {
  76          case "formatselect":
  77              var html = '<select id="{$editor_id}_formatSelect" name="{$editor_id}_formatSelect" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FormatBlock\',false,this.options[this.selectedIndex].value);" class="mceSelectList">';
  78              var formats = tinyMCE.getParam("theme_advanced_blockformats", "p,address,pre,h1,h2,h3,h4,h5,h6", true).split(',');
  79              var lookup = [
  80                  ['p', '{$lang_theme_paragraph}'],
  81                  ['address', '{$lang_theme_address}'],
  82                  ['pre', '{$lang_theme_pre}'],
  83                  ['h1', '{$lang_theme_h1}'],
  84                  ['h2', '{$lang_theme_h2}'],
  85                  ['h3', '{$lang_theme_h3}'],
  86                  ['h4', '{$lang_theme_h4}'],
  87                  ['h5', '{$lang_theme_h5}'],
  88                  ['h6', '{$lang_theme_h6}']
  89              ];
  90  
  91              // Build format select
  92              for (var i=0; i<formats.length; i++) {
  93                  for (var x=0; x<lookup.length; x++) {
  94                      if (formats[i] == lookup[x][0])
  95                          html += '<option value="<' + lookup[x][0] + '>">' + lookup[x][1] + '</option>';
  96                  }
  97              }
  98  
  99              html += '</select>';
 100  
 101              return html;
 102  
 103  
 104          case "styleselect":
 105              return '<select id="{$editor_id}_styleSelect" onmousedown="TinyMCE_advanced_setupCSSClasses(\'{$editor_id}\');" name="{$editor_id}_styleSelect" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceSetCSSClass\',false,this.options[this.selectedIndex].value);" class="mceSelectList">{$style_select_options}</select>';
 106  
 107          case "fontselect":
 108              return '<select id="{$editor_id}_fontNameSelect" name="{$editor_id}_fontNameSelect" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FontName\',false,this.options[this.selectedIndex].value);" class="mceSelectList">\
 109                      <option value="">{$lang_theme_fontdefault}</option>\
 110                      <option value="arial,helvetica,sans-serif">Arial</option>\
 111                      <option value="times new roman,times,serif">Times New Roman</option>\
 112                      <option value="verdana,arial,helvetica,sans-serif">Verdana</option>\
 113                      <option value="courier new,courier,monospace">Courier</option>\
 114                      <option value="georgia,times new roman,times,serif">Georgia</option>\
 115                      <option value="tahoma,arial,helvetica,sans-serif">Tahoma</option>\
 116                      </select>';
 117  
 118          case "fontsizeselect":
 119              return '<select id="{$editor_id}_fontSizeSelect" name="{$editor_id}_fontSizeSelect" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FontSize\',false,this.options[this.selectedIndex].value);" class="mceSelectList">\
 120                      <option value="0">-- {$lang_theme_font_size} --</option>\
 121                      <option value="1">1 (8 pt)</option>\
 122                      <option value="2">2 (10 pt)</option>\
 123                      <option value="3">3 (12 pt)</option>\
 124                      <option value="4">4 (14 pt)</option>\
 125                      <option value="5">5 (18 pt)</option>\
 126                      <option value="6">6 (24 pt)</option>\
 127                      <option value="7">7 (36 pt)</option>\
 128                      </select>';
 129  
 130          case "|":
 131          case "separator":
 132              return '<img src="{$themeurl}/images/spacer.gif" width="1" height="15" class="mceSeparatorLine">';
 133  
 134          case "spacer":
 135              return '<img src="{$themeurl}/images/spacer.gif" width="1" height="15" border="0" class="mceSeparatorLine" style="vertical-align: middle" />';
 136  
 137          case "rowseparator":
 138              return '<br />';
 139      }
 140  
 141      return "";
 142  }
 143  
 144  /**
 145   * Theme specific exec command handeling.
 146   */
 147  function TinyMCE_advanced_execCommand(editor_id, element, command, user_interface, value) {
 148      switch (command) {
 149          case "mceForeColor":
 150              var template = new Array();
 151              var inputColor = TinyMCE_advanced_foreColor;
 152  
 153              if (!inputColor)
 154                  inputColor = "#000000";
 155  
 156              template['file'] = 'color_picker.htm';
 157              template['width'] = 210;
 158              template['height'] = 200;
 159  
 160              tinyMCE.openWindow(template, {editor_id : editor_id, command : "forecolor", input_color : inputColor});
 161              return true;
 162  
 163          case "mceBackColor":
 164              var template = new Array();
 165              var inputColor = TinyMCE_advanced_foreColor;
 166  
 167              if (!inputColor)
 168                  inputColor = "#000000";
 169  
 170              template['file'] = 'color_picker.htm';
 171              template['width'] = 210;
 172              template['height'] = 200;
 173  
 174              tinyMCE.openWindow(template, {editor_id : editor_id, command : "HiliteColor", input_color : inputColor});
 175              return true;
 176  
 177          case "mceCodeEditor":
 178              var template = new Array();
 179  
 180              template['file'] = 'source_editor.htm';
 181              template['width'] = tinyMCE.getParam("theme_advanced_source_editor_width", 500);
 182              template['height'] = tinyMCE.getParam("theme_advanced_source_editor_height", 400);
 183  
 184              tinyMCE.openWindow(template, {editor_id : editor_id, resizable : "yes", scrollbars : "no"});
 185              return true;
 186  
 187          case "mceCharMap":
 188              var template = new Array();
 189  
 190              template['file'] = 'charmap.htm';
 191              template['width'] = 550;
 192              template['height'] = 280;
 193  
 194              tinyMCE.openWindow(template, {editor_id : editor_id});
 195              return true;
 196  
 197          case "mceInsertAnchor":
 198              var template = new Array();
 199  
 200              template['file'] = 'anchor.htm';
 201              template['width'] = 320;
 202              template['height'] = 130;
 203  
 204              tinyMCE.openWindow(template, {editor_id : editor_id, name : TinyMCE_advanced_anchorName, action : (TinyMCE_advanced_anchorName == "" ? "insert" : "update")});
 205              return true;
 206      }
 207  
 208      // Default behavior
 209      return false;
 210  }
 211  
 212  /**
 213   * Editor instance template function.
 214   */
 215  function TinyMCE_advanced_getEditorTemplate(settings) {
 216  	function removeFromArray(in_array, remove_array) {
 217          var outArray = new Array();
 218          for (var i=0; i<in_array.length; i++) {
 219              skip = false;
 220  
 221              for (var j=0; j<remove_array.length; j++) {
 222                  if (in_array[i] == remove_array[j])
 223                      skip = true;
 224              }
 225  
 226              if (!skip)
 227                  outArray[outArray.length] = in_array[i];
 228          }
 229  
 230          return outArray;
 231      }
 232  
 233  	function addToArray(in_array, add_array) {
 234          for (var i=0; i<add_array.length; i++)
 235              in_array[in_array.length] = add_array[i];
 236  
 237          return in_array;
 238      }
 239  
 240      var template = new Array();
 241      var deltaHeight = 0;
 242  
 243      //###########################################################################################################
 244      // <Layout Manager Modification by SlyD, 14.1.2005>
 245      //###########################################################################################################
 246  
 247        var pathHTML = '{$lang_theme_path}: <span id="{$editor_id}_path">&nbsp;</span>';
 248      var layoutManager = tinyMCE.getParam("theme_advanced_layout_manager", "SimpleLayout");
 249  
 250      switch(layoutManager) {
 251          case "SimpleLayout" : //the default TinyMCE Layout (for backwards compatibility)...
 252                  var toolbarHTML = "";
 253                  var toolbarLocation = tinyMCE.getParam("theme_advanced_toolbar_location", "bottom");
 254                  var toolbarAlign = tinyMCE.getParam("theme_advanced_toolbar_align", "center");
 255                  var pathLocation = tinyMCE.getParam("theme_advanced_path_location", "none");
 256  
 257                  // Render row 1
 258                  var buttonNamesRow1 = tinyMCE.getParam("theme_advanced_buttons1", "bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,styleselect,formatselect", true, ',');
 259                  buttonNamesRow1 = removeFromArray(buttonNamesRow1, tinyMCE.getParam("theme_advanced_disable", "", true, ','));
 260                  buttonNamesRow1 = addToArray(buttonNamesRow1, tinyMCE.getParam("theme_advanced_buttons1_add", "", true, ','));
 261                  buttonNamesRow1 = addToArray(tinyMCE.getParam("theme_advanced_buttons1_add_before", "", true, ','), buttonNamesRow1);
 262                  for (var i=0; i<buttonNamesRow1.length; i++)
 263                      toolbarHTML += tinyMCE.getControlHTML(buttonNamesRow1[i]);
 264  
 265                  if (buttonNamesRow1.length > 0) {
 266                      toolbarHTML += "<br />";
 267                      deltaHeight -= 23;
 268                  }
 269  
 270                  // Render row 2
 271                  var buttonNamesRow2 = tinyMCE.getParam("theme_advanced_buttons2", "bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image,cleanup,help,code", true, ',');
 272                  buttonNamesRow2 = removeFromArray(buttonNamesRow2, tinyMCE.getParam("theme_advanced_disable", "", true, ','));
 273                  buttonNamesRow2 = addToArray(buttonNamesRow2, tinyMCE.getParam("theme_advanced_buttons2_add", "", true, ','));
 274                  buttonNamesRow2 = addToArray(tinyMCE.getParam("theme_advanced_buttons2_add_before", "", true, ','), buttonNamesRow2);
 275                  for (var i=0; i<buttonNamesRow2.length; i++)
 276                      toolbarHTML += tinyMCE.getControlHTML(buttonNamesRow2[i]);
 277  
 278                  if (buttonNamesRow2.length > 0) {
 279                      toolbarHTML += "<br />";
 280                      deltaHeight -= 23;
 281                  }
 282  
 283                  // Render row 3
 284                  var buttonNamesRow3 = tinyMCE.getParam("theme_advanced_buttons3", "hr,removeformat,visualaid,separator,sub,sup,separator,charmap", true, ',');
 285                  buttonNamesRow3 = removeFromArray(buttonNamesRow3, tinyMCE.getParam("theme_advanced_disable", "", true, ','));
 286                  buttonNamesRow3 = addToArray(buttonNamesRow3, tinyMCE.getParam("theme_advanced_buttons3_add", "", true, ','));
 287                  buttonNamesRow3 = addToArray(tinyMCE.getParam("theme_advanced_buttons3_add_before", "", true, ','), buttonNamesRow3);
 288                  for (var i=0; i<buttonNamesRow3.length; i++)
 289                      toolbarHTML += tinyMCE.getControlHTML(buttonNamesRow3[i]);
 290  
 291                  if (buttonNamesRow3.length > 0)
 292                      deltaHeight -= 20;
 293  
 294                  // Setup template html
 295                  template['html'] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}"><tbody>';
 296  
 297                  if (toolbarLocation == "top")
 298                      template['html'] += '<tr><td class="mceToolbarTop" align="' + toolbarAlign + '" height="1" nowrap="nowrap">' + toolbarHTML + '</td></tr>';
 299  
 300                  if (pathLocation == "top") {
 301                      template['html'] += '<tr><td class="mcePathTop" height="1">' + pathHTML + '</td></tr>';
 302                      deltaHeight -= 23;
 303                  }
 304  
 305              /*  template['html'] += '<tr><td align="center">\
 306                      <iframe id="{$editor_id}" class="mceEditorArea" border="1" frameborder="0" src="{$default_document}" marginwidth="0" marginheight="0" leftmargin="0" topmargin="0" style="width:{$area_width};height:{$area_height}" width="{$area_width}" height="{$area_height}"></iframe>\
 307                      </td></tr>';*/
 308                  template['html'] += '<tr><td align="center">\
 309                      <span id="{$editor_id}"></span>\
 310                      </td></tr>';
 311  
 312                  if (toolbarLocation == "bottom")
 313                      template['html'] += '<tr><td class="mceToolbarBottom" align="' + toolbarAlign + '" height="1">' + toolbarHTML + '</td></tr>';
 314  
 315                  if (pathLocation == "bottom") {
 316                      template['html'] += '<tr><td class="mcePathBottom" height="1">' + pathHTML + '</td></tr>';
 317                      deltaHeight -= 23;
 318                  }
 319  
 320                  template['html'] += '</table>';
 321          break;
 322  
 323          case "RowLayout" : //Container Layout - containers defined in "theme_advanced_containers" are rendered from top to bottom.
 324              template['html'] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}"><tbody>';
 325  
 326              var containers = tinyMCE.getParam("theme_advanced_containers", "", true, ",");
 327              var defaultContainerCSS = tinyMCE.getParam("theme_advanced_containers_default_class", "container");
 328              var defaultContainerAlign = tinyMCE.getParam("theme_advanced_containers_default_align", "center");
 329  
 330              //Render Containers:
 331              for(var i = 0; i < containers.length; i++)
 332              {
 333                  if(containers[i] == "mceEditor") //Exceptions for mceEditor and ...
 334                  {
 335                      template['html'] += '<tr><td align="center" class="mceEditor_border">\
 336                          <span id="{$editor_id}"></span>\
 337                          </td></tr>';
 338                  }
 339                  else if(containers[i] == "mceElementpath") // ... mceElementpath:
 340                  {
 341                      var pathClass = "mcePath";
 342  
 343                      if (i == containers.length-1)
 344                          pathClass = "mcePathBottom";
 345                      else if (i == 0)
 346                          pathClass = "mcePathTop";
 347                      else
 348                          deltaHeight-=2;
 349  
 350                      template['html'] += '<tr><td class="' + pathClass + '" height="1">' + pathHTML + '</td></tr>';
 351                      deltaHeight -= 22;
 352                  }
 353                  else //Render normal Container:
 354                  {
 355                      var curContainer = tinyMCE.getParam("theme_advanced_container_"+containers[i], "", true, ',');
 356                      var curContainerHTML = "";
 357                      var curAlign = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_align", defaultContainerAlign);
 358                      var curCSS = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_class", defaultContainerCSS);
 359  
 360                      for (var j=0; j<curContainer.length; j++)
 361                          curContainerHTML += tinyMCE.getControlHTML(curContainer[j]);
 362  
 363                      if (curContainer.length > 0) {
 364                          curContainerHTML += "<br />";
 365                          deltaHeight -= 23;
 366                      }
 367  
 368                      template['html'] += '<tr><td class="' + curCSS + '" align="' + curAlign + '" height="1">' + curContainerHTML + '</td></tr>';
 369                  }
 370              }
 371  
 372              template['html'] += '</tbody></table>';
 373          break;
 374          case "BorderLayout" : //will be like java.awt.BorderLayout of SUN Java...
 375              // Not implemented yet... 
 376          break;
 377          case "CustomLayout" : //User defined layout callback...
 378                  var customLayout = tinyMCE.getParam("theme_advanced_custom_layout","");
 379                  if (customLayout != "" && eval("typeof(" + customLayout + ")") != "undefined")
 380                  template = eval(customLayout + "(template);");
 381          break;
 382          default:
 383              alert('UNDEFINED LAYOUT MANAGER! PLEASE CHECK YOUR TINYMCE CONFIG!');
 384          break;
 385      }
 386  
 387      //###########################################################################################################
 388      // </Modification by SlyD, 14.1.2005>
 389      //###########################################################################################################
 390  
 391      // Setup style select options
 392      var styleSelectHTML = '<option value="">-- {$lang_theme_style_select} --</option>';
 393      if (settings['theme_advanced_styles']) {
 394          var stylesAr = settings['theme_advanced_styles'].split(';');
 395          for (var i=0; i<stylesAr.length; i++) {
 396              var key, value;
 397  
 398              key = stylesAr[i].split('=')[0];
 399              value = stylesAr[i].split('=')[1];
 400  
 401              styleSelectHTML += '<option value="' + value + '">' + key + '</option>';
 402          }
 403  
 404          TinyMCE_advanced_autoImportCSSClasses = false;
 405      }
 406  
 407      template['html'] = tinyMCE.replaceVar(template['html'], 'style_select_options', styleSelectHTML);
 408      template['delta_width'] = 0;
 409      template['delta_height'] = deltaHeight;
 410  
 411      return template;
 412  }
 413  
 414  /**
 415   * Insert link template function.
 416   */
 417  function TinyMCE_advanced_getInsertLinkTemplate() {
 418      var template = new Array();
 419  
 420      template['file'] = 'link.htm';
 421      template['width'] = 300;
 422      template['height'] = 150;
 423  
 424      // Language specific width and height addons
 425      template['width'] += tinyMCE.getLang('lang_insert_link_delta_width', 0);
 426      template['height'] += tinyMCE.getLang('lang_insert_link_delta_height', 0);
 427  
 428      return template;
 429  }
 430  
 431  /**
 432   * Insert image template function.
 433   */
 434  function TinyMCE_advanced_getInsertImageTemplate() {
 435      var template = new Array();
 436  
 437      template['file'] = 'image.htm?src={$src}';
 438      template['width'] = 340;
 439      template['height'] = 280;
 440  
 441      // Language specific width and height addons
 442      template['width'] += tinyMCE.getLang('lang_insert_image_delta_width', 0);
 443      template['height'] += tinyMCE.getLang('lang_insert_image_delta_height', 0);
 444  
 445      return template;
 446  }
 447  
 448  /**
 449   * Node change handler.
 450   */
 451  function TinyMCE_advanced_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
 452  	function selectByValue(select_elm, value) {
 453          if (select_elm) {
 454              for (var i=0; i<select_elm.options.length; i++) {
 455                  if (select_elm.options[i].value == value) {
 456                      select_elm.selectedIndex = i;
 457                      return true;
 458                  }
 459              }
 460          }
 461  
 462          return false;
 463      }
 464  
 465      // No node provided
 466      if (node == null)
 467          return;
 468  
 469      // Update path
 470      var pathElm = document.getElementById(editor_id + "_path");
 471      if (pathElm) {
 472          // Get node path
 473          var parentNode = node;
 474          var path = new Array();
 475          while (parentNode) {
 476              if (parentNode.nodeName.toLowerCase() == "body")
 477                  break;
 478  
 479              // Only append element nodes to path
 480              if (parentNode.nodeType == 1)
 481                  path[path.length] = parentNode;
 482  
 483              parentNode = parentNode.parentNode;
 484          }
 485  
 486          // Setup HTML
 487          var html = "";
 488          for (var i=path.length-1; i>=0; i--) {
 489              var nodeName = path[i].nodeName.toLowerCase();
 490              var nodeData = "";
 491              var className = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i], 'class'), false);
 492  
 493              if (nodeName == "b")
 494                  nodeName = "strong";
 495  
 496              if (nodeName == "i")
 497                  nodeName = "em";
 498  
 499              if (tinyMCE.getAttrib(path[i], 'id') != "")
 500                  nodeData += "id: " + path[i].getAttribute('id') + " ";
 501  
 502              if (className != "")
 503                  nodeData += "class: " + className + " ";
 504  
 505              if (tinyMCE.getAttrib(path[i], 'src') != "")
 506                  nodeData += "src: " + path[i].getAttribute('src') + " ";
 507  
 508              if (tinyMCE.getAttrib(path[i], 'href') != "")
 509                  nodeData += "href: " + path[i].getAttribute('href') + " ";
 510  
 511              if (nodeName == "img" && tinyMCE.getAttrib(path[i], 'name') == "mce_plugin_flash") {
 512                  nodeName = "flash";
 513                  nodeData = "";
 514              }
 515  
 516              if (tinyMCE.getAttrib(path[i], 'name').indexOf("mce_") != 0) {
 517                  if (className != "")
 518                      nodeName += "." + className;
 519              }
 520  
 521              if (tinyMCE.isMSIE || tinyMCE.isSafari)
 522                  html += '<a title="' + nodeData + '" href="javascript:void(0);" onmousedown="tinyMCE.execInstanceCommand(\'' + editor_id + '\',\'mceSelectNodeDepth\',false,\'' + i + '\');return false;" class="mcePathItem">' + nodeName + '</a>';
 523              else
 524                  html += '<a title="' + nodeData + '" href="javascript:tinyMCE.execInstanceCommand(\'' + editor_id + '\',\'mceSelectNodeDepth\',false,\'' + i + '\');" class="mcePathItem">' + nodeName + '</a>';
 525  
 526              if (i > 0)
 527                  html += " &raquo; ";
 528          }
 529  
 530          pathElm.innerHTML = html + "&nbsp;";
 531      }
 532  
 533      // Get element color
 534      var colorElm = tinyMCE.getParentElement(node, "font", "color");
 535      if (colorElm)
 536          TinyMCE_advanced_foreColor = "" + colorElm.color.toUpperCase();
 537  
 538      // Reset old states
 539      tinyMCE.switchClassSticky(editor_id + '_justifyleft', 'mceButtonNormal');
 540      tinyMCE.switchClassSticky(editor_id + '_justifyright', 'mceButtonNormal');
 541      tinyMCE.switchClassSticky(editor_id + '_justifycenter', 'mceButtonNormal');
 542      tinyMCE.switchClassSticky(editor_id + '_justifyfull', 'mceButtonNormal');
 543      tinyMCE.switchClassSticky(editor_id + '_bold', 'mceButtonNormal');
 544      tinyMCE.switchClassSticky(editor_id + '_italic', 'mceButtonNormal');
 545      tinyMCE.switchClassSticky(editor_id + '_underline', 'mceButtonNormal');
 546      tinyMCE.switchClassSticky(editor_id + '_strikethrough', 'mceButtonNormal');
 547      tinyMCE.switchClassSticky(editor_id + '_bullist', 'mceButtonNormal');
 548      tinyMCE.switchClassSticky(editor_id + '_numlist', 'mceButtonNormal');
 549      tinyMCE.switchClassSticky(editor_id + '_sub', 'mceButtonNormal');
 550      tinyMCE.switchClassSticky(editor_id + '_sup', 'mceButtonNormal');
 551      tinyMCE.switchClassSticky(editor_id + '_anchor', 'mceButtonNormal');
 552      tinyMCE.switchClassSticky(editor_id + '_link', 'mceButtonDisabled', true);
 553      tinyMCE.switchClassSticky(editor_id + '_unlink', 'mceButtonDisabled', true);
 554      tinyMCE.switchClassSticky(editor_id + '_outdent', 'mceButtonDisabled', true);
 555      tinyMCE.switchClassSticky(editor_id + '_image', 'mceButtonNormal');
 556      tinyMCE.switchClassSticky(editor_id + '_hr', 'mceButtonNormal');
 557  
 558      // Get anchor name
 559      var anchorName = tinyMCE.getParentElement(node, "a", "name");
 560      TinyMCE_advanced_anchorName = "";
 561      if (anchorName) {
 562          TinyMCE_advanced_anchorName = anchorName.getAttribute("name");
 563          tinyMCE.switchClassSticky(editor_id + '_anchor', 'mceButtonSelected');
 564      }
 565  
 566      // Get link
 567      var anchorLink = tinyMCE.getParentElement(node, "a", "href");
 568      if (anchorLink || any_selection) {
 569          tinyMCE.switchClassSticky(editor_id + '_link', anchorLink ? 'mceButtonSelected' : 'mceButtonNormal', false);
 570          tinyMCE.switchClassSticky(editor_id + '_unlink', anchorLink ? 'mceButtonSelected' : 'mceButtonNormal', false);
 571      }
 572  
 573      // Handle visual aid
 574      tinyMCE.switchClassSticky(editor_id + '_visualaid', visual_aid ? 'mceButtonSelected' : 'mceButtonNormal', false);
 575  
 576      if (undo_levels != -1) {
 577          tinyMCE.switchClassSticky(editor_id + '_undo', 'mceButtonDisabled', true);
 578          tinyMCE.switchClassSticky(editor_id + '_redo', 'mceButtonDisabled', true);
 579      }
 580  
 581      // Within li, blockquote
 582      if (tinyMCE.getParentElement(node, "li,blockquote"))
 583          tinyMCE.switchClassSticky(editor_id + '_outdent', 'mceButtonNormal', false);
 584  
 585      // Has redo levels
 586      if (undo_index != -1 && (undo_index < undo_levels-1 && undo_levels > 0))
 587          tinyMCE.switchClassSticky(editor_id + '_redo', 'mceButtonNormal', false);
 588  
 589      // Has undo levels
 590      if (undo_index != -1 && (undo_index > 0 && undo_levels > 0))
 591          tinyMCE.switchClassSticky(editor_id + '_undo', 'mceButtonNormal', false);
 592  
 593      // Select class in select box
 594      var selectElm = document.getElementById(editor_id + "_styleSelect");
 595      if (selectElm) {
 596          TinyMCE_advanced_setupCSSClasses(editor_id);
 597  
 598          classNode = node;
 599          breakOut = false;
 600          var index = 0;
 601  
 602          do {
 603              if (classNode && classNode.className) {
 604                  for (var i=0; i<selectElm.options.length; i++) {
 605                      if (selectElm.options[i].value == classNode.className) {
 606                          index = i;
 607                          breakOut = true;
 608                          break;
 609                      }
 610                  }
 611              }
 612          } while (!breakOut && classNode != null && (classNode = classNode.parentNode));
 613  
 614          selectElm.selectedIndex = index;
 615      }
 616  
 617      // Select formatblock
 618      var selectElm = document.getElementById(editor_id + "_formatSelect");
 619      if (selectElm) {
 620          var elm = tinyMCE.getParentElement(node, "p,div,h1,h2,h3,h4,h5,h6,pre,address");
 621          if (elm) {
 622              selectByValue(selectElm, "<" + elm.nodeName.toLowerCase() + ">");
 623          } else
 624              selectByValue(selectElm, "<p>");
 625      }
 626  
 627      // Select fontselect
 628      var selectElm = document.getElementById(editor_id + "_fontNameSelect");
 629      if (selectElm) {
 630          var elm = tinyMCE.getParentElement(node, "font", "face");
 631          if (elm)
 632              selectByValue(selectElm, elm.getAttribute("face"));
 633          else
 634              selectByValue(selectElm, "");
 635      }
 636  
 637      // Select fontsize
 638      var selectElm = document.getElementById(editor_id + "_fontSizeSelect");
 639      if (selectElm) {
 640          var elm = tinyMCE.getParentElement(node, "font", "size");
 641          if (elm && tinyMCE.getAttrib(elm, "size") != "")
 642              selectByValue(selectElm, elm.getAttribute("size"));
 643          else
 644              selectByValue(selectElm, "0");
 645      }
 646  
 647      // Handle align attributes
 648      alignNode = node;
 649      breakOut = false;
 650      do {
 651          if (!alignNode.getAttribute || !alignNode.getAttribute('align'))
 652              continue;
 653  
 654          switch (alignNode.getAttribute('align').toLowerCase()) {
 655              case "left":
 656                  tinyMCE.switchClassSticky(editor_id + '_justifyleft', 'mceButtonSelected');
 657                  breakOut = true;
 658              break;
 659  
 660              case "right":
 661                  tinyMCE.switchClassSticky(editor_id + '_justifyright', 'mceButtonSelected');
 662                  breakOut = true;
 663              break;
 664  
 665              case "middle":
 666              case "center":
 667                  tinyMCE.switchClassSticky(editor_id + '_justifycenter', 'mceButtonSelected');
 668                  breakOut = true;
 669              break;
 670  
 671              case "justify":
 672                  tinyMCE.switchClassSticky(editor_id + '_justifyfull', 'mceButtonSelected');
 673                  breakOut = true;
 674              break;
 675          }
 676      } while (!breakOut && (alignNode = alignNode.parentNode));
 677  
 678      // Do special text
 679      if (tinyMCE.isGecko && node.nodeType == 3) {
 680          var inst = tinyMCE.getInstanceById(editor_id);
 681          var doc = inst.getDoc();
 682  
 683          if (doc.queryCommandState("Bold"))
 684              tinyMCE.switchClassSticky(editor_id + '_bold', 'mceButtonSelected');
 685  
 686          if (doc.queryCommandState("Italic"))
 687              tinyMCE.switchClassSticky(editor_id + '_italic', 'mceButtonSelected');
 688  
 689          if (doc.queryCommandState("Underline") && (node.parentNode == null || node.parentNode.nodeName != "A"))
 690              tinyMCE.switchClassSticky(editor_id + '_underline', 'mceButtonSelected');
 691  
 692          if (doc.queryCommandState("Strikethrough"))
 693              tinyMCE.switchClassSticky(editor_id + '_strikethrough', 'mceButtonSelected');
 694      }
 695  
 696      // Handle elements
 697      do {
 698          switch (node.nodeName.toLowerCase()) {
 699              case "b":
 700              case "strong":
 701                  tinyMCE.switchClassSticky(editor_id + '_bold', 'mceButtonSelected');
 702              break;
 703  
 704              case "i":
 705              case "em":
 706                  tinyMCE.switchClassSticky(editor_id + '_italic', 'mceButtonSelected');
 707              break;
 708  
 709              case "u":
 710                  tinyMCE.switchClassSticky(editor_id + '_underline', 'mceButtonSelected');
 711              break;
 712  
 713              case "strike":
 714                  tinyMCE.switchClassSticky(editor_id + '_strikethrough', 'mceButtonSelected');
 715              break;
 716  
 717              case "ul":
 718                  tinyMCE.switchClassSticky(editor_id + '_bullist', 'mceButtonSelected');
 719              break;
 720  
 721              case "ol":
 722                  tinyMCE.switchClassSticky(editor_id + '_numlist', 'mceButtonSelected');
 723              break;
 724  
 725              case "sub":
 726                  tinyMCE.switchClassSticky(editor_id + '_sub', 'mceButtonSelected');
 727              break;
 728  
 729              case "sup":
 730                  tinyMCE.switchClassSticky(editor_id + '_sup', 'mceButtonSelected');
 731              break;
 732  
 733              case "hr":
 734                  tinyMCE.switchClassSticky(editor_id + '_hr', 'mceButtonSelected');
 735              break;
 736  
 737              case "img":
 738                  if (tinyMCE.getAttrib(node, 'name').indexOf('mce_') != 0)
 739                      tinyMCE.switchClassSticky(editor_id + '_image', 'mceButtonSelected');
 740              break;
 741          }
 742      } while ((node = node.parentNode));
 743  }
 744  
 745  // This function auto imports CSS classes into the class selection droplist
 746  function TinyMCE_advanced_setupCSSClasses(editor_id) {
 747      if (!TinyMCE_advanced_autoImportCSSClasses)
 748          return;
 749  
 750      var selectElm = document.getElementById(editor_id + '_styleSelect');
 751  
 752      if (selectElm && selectElm.getAttribute('cssImported') != 'true') {
 753          var csses = tinyMCE.getCSSClasses(editor_id);
 754          if (csses && selectElm) {
 755              for (var i=0; i<csses.length; i++)
 756                  selectElm.options[selectElm.length] = new Option(csses[i], csses[i]);
 757          }
 758  
 759          // Only do this once
 760          if (csses != null && csses.length > 0)
 761              selectElm.setAttribute('cssImported', 'true');
 762      }
 763  }


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7