[ Index ]
 

Code source de PHP NUKE 7.9

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

title

Body

[fermer]

/includes/tiny_mce/plugins/searchreplace/ -> editor_plugin_src.js (source)

   1  /* Import theme    specific language pack */

   2  tinyMCE.importPluginLanguagePack('searchreplace', 'albanian,arabic,brazilian,catala,chinese,czech,danish,dutch,english,euskara,finnish,french,galego,german,greek,hungarian,icelandic,indonesian,italian,macedonian,norwegian,polish,portuguese,romanian,russian,slovak,slovenian,spanish,swedish,thai,turkish,ukrainian,vietnamese');
   3  
   4  function TinyMCE_searchreplace_getControlHTML(control_name)    {
   5      switch (control_name) {
   6          case "search":
   7              return '<img id="{$editor_id}_search" src="{$pluginurl}/images/search.gif" title="{$lang_searchreplace_search_desc}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceSearch\',true);" />';
   8  
   9          case "replace":
  10              return '<img id="{$editor_id}_replace" src="{$pluginurl}/images/replace.gif" title="{$lang_searchreplace_replace_desc}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceSearchReplace\',true);" />';
  11      }
  12  
  13      return "";
  14  }
  15  
  16  /**

  17   * Executes    the    search/replace commands.

  18   */
  19  function TinyMCE_searchreplace_execCommand(editor_id, element, command,    user_interface,    value) {
  20  	function defValue(key, default_value) {
  21          value[key] = typeof(value[key]) == "undefined" ? default_value : value[key];
  22      }
  23  
  24  	function replaceSel(search_str, str) {
  25          // Get current selection

  26          if (!tinyMCE.isMSIE) {
  27              var sel = instance.contentWindow.getSelection();
  28              var rng = sel.getRangeAt(0);
  29          } else {
  30              var rng = instance.contentWindow.document.selection.createRange();
  31          }
  32  
  33          // Replace current one

  34          if (!tinyMCE.isMSIE) {
  35              var doc = instance.contentWindow.document;
  36  
  37              // This way works when the replace doesn't contain the search string

  38              if (str.indexOf(search_str) == -1) {
  39                  rng.deleteContents();
  40                  rng.insertNode(rng.createContextualFragment(str));
  41                  rng.collapse(false);
  42              } else {
  43                  // Insert content ugly way! Needed to move selection to after replace item

  44                  doc.execCommand("insertimage", false, "#mce_temp_url#");
  45                  var elm = tinyMCE.getElementByAttributeValue(doc.body, "img", "src", "#mce_temp_url#");
  46                  elm.parentNode.replaceChild(doc.createTextNode(str), elm);
  47              }
  48          } else {
  49              if (rng.item)
  50                  rng.item(0).outerHTML = str;
  51              else
  52                  rng.pasteHTML(str);
  53          }
  54      }
  55  
  56      var instance = tinyMCE.getInstanceById(editor_id);
  57  
  58      if (!value)
  59          value = new Array();
  60  
  61      // Setup defualt values

  62      defValue("editor_id", editor_id);
  63      defValue("searchstring", "");
  64      defValue("replacestring", null);
  65      defValue("replacemode", "none");
  66      defValue("casesensitive", false);
  67      defValue("backwards", false);
  68      defValue("wrap", false);
  69      defValue("wholeword", false);
  70  
  71      // Handle commands

  72      switch (command) {
  73          case "mceResetSearch":
  74              tinyMCE.lastSearchRng = null;
  75              return true;
  76  
  77          case "mceSearch":
  78              if (user_interface) {
  79                  // Open search dialog

  80                  var template = new Array();
  81  
  82                  if (value['replacestring'] != null) {
  83                      template['file'] = '../../plugins/searchreplace/replace.htm'; // Relative to theme

  84                      template['width'] = 310;
  85                      template['height'] = 180;
  86                  } else {
  87                      template['file'] = '../../plugins/searchreplace/search.htm'; // Relative to theme

  88                      template['width'] = 280;
  89                      template['height'] = 180;
  90                  }
  91  
  92                  tinyMCE.openWindow(template, value);
  93              } else {
  94                  var win = tinyMCE.getInstanceById(editor_id).contentWindow;
  95                  var doc = tinyMCE.getInstanceById(editor_id).contentWindow.document;
  96  
  97                  // Handle replace current

  98                  if (value['replacemode'] == "current") {
  99                      replaceSel(value['string'], value['replacestring']);
 100  
 101                      // Search next one

 102                      value['replacemode'] = "none";
 103                      tinyMCE.execInstanceCommand(editor_id, 'mceSearch', user_interface, value, false);
 104  
 105                      return true;
 106                  }
 107  
 108                  if (tinyMCE.isMSIE) {
 109                      var rng = tinyMCE.lastSearchRng ? tinyMCE.lastSearchRng : doc.selection.createRange();
 110                      var flags = 0;
 111  
 112                      if (value['wholeword'])
 113                          flags = flags | 2;
 114  
 115                      if (value['casesensitive'])
 116                          flags = flags | 4;
 117  
 118                      // Handle replace all mode

 119                      if (value['replacemode'] == "all") {
 120                          while (rng.findText(value['string'], value['backwards'] ? -1 : 1, flags)) {
 121                              rng.scrollIntoView();
 122                              rng.select();
 123                              rng.collapse(false);
 124                              replaceSel(value['string'], value['replacestring']);
 125                          }
 126  
 127                          alert(tinyMCE.getLang('lang_searchreplace_allreplaced'));
 128                          return true;
 129                      }
 130  
 131                      if (rng.findText(value['string'], value['backwards'] ? -1 : 1, flags)) {
 132                          rng.scrollIntoView();
 133                          rng.select();
 134                          rng.collapse(value['backwards']);
 135                          tinyMCE.lastSearchRng = rng;
 136                      } else
 137                          alert(tinyMCE.getLang('lang_searchreplace_notfound'));
 138                  } else {
 139                      if (value['replacemode'] == "all") {
 140                          while (win.find(value['string'], value['casesensitive'], value['backwards'], value['wrap'], value['wholeword'], false, false))
 141                              replaceSel(value['string'], value['replacestring']);
 142  
 143                          alert(tinyMCE.getLang('lang_searchreplace_allreplaced'));
 144                          return true;
 145                      }
 146  
 147                      if (!win.find(value['string'], value['casesensitive'], value['backwards'], value['wrap'], value['wholeword'], false, false))
 148                          alert(tinyMCE.getLang('lang_searchreplace_notfound'));
 149                  }
 150              }
 151              return true;
 152  
 153          case "mceSearchReplace":
 154              value['replacestring'] = "";
 155  
 156              tinyMCE.execInstanceCommand(editor_id, 'mceSearch', user_interface, value, false);
 157              return true;
 158      }
 159  
 160      // Pass to next handler in chain

 161      return false;
 162  }
 163  
 164  function TinyMCE_searchreplace_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
 165      return true;
 166  }


Généré le : Sun Apr 1 11:11:59 2007 par Balluche grâce à PHPXref 0.7