[ 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/plugins/flash/ -> editor_plugin_src.js (source)

   1  /* Import plugin specific language pack */
   2  tinyMCE.importPluginLanguagePack('flash', 'en,de,sv,zh_cn,cs,fa,fr_ca,fr,pl');
   3  
   4  function TinyMCE_flash_initInstance(inst) {
   5      if (!tinyMCE.settings['flash_skip_plugin_css'])
   6          tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/flash/flash.css");
   7  }
   8  
   9  function TinyMCE_flash_getControlHTML(control_name) {
  10      switch (control_name) {
  11          case "flash":
  12              return '<img id="{$editor_id}_flash" src="{$pluginurl}/images/flash.gif" title="{$lang_insert_flash}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceFlash\');" />';
  13      }
  14  
  15      return "";
  16  }
  17  
  18  function TinyMCE_flash_parseAttributes(attribute_string) {
  19      var attributeName = "";
  20      var attributeValue = "";
  21      var withInName;
  22      var withInValue;
  23      var attributes = new Array();
  24      var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g');
  25  
  26      if (attribute_string == null || attribute_string.length < 2)
  27          return null;
  28  
  29      withInName = withInValue = false;
  30  
  31      for (var i=0; i<attribute_string.length; i++) {
  32          var chr = attribute_string.charAt(i);
  33  
  34          if ((chr == '"' || chr == "'") && !withInValue)
  35              withInValue = true;
  36          else if ((chr == '"' || chr == "'") && withInValue) {
  37              withInValue = false;
  38  
  39              var pos = attributeName.lastIndexOf(' ');
  40              if (pos != -1)
  41                  attributeName = attributeName.substring(pos+1);
  42  
  43              attributes[attributeName.toLowerCase()] = attributeValue.substring(1).toLowerCase();
  44  
  45              attributeName = "";
  46              attributeValue = "";
  47          } else if (!whiteSpaceRegExp.test(chr) && !withInName && !withInValue)
  48              withInName = true;
  49  
  50          if (chr == '=' && withInName)
  51              withInName = false;
  52  
  53          if (withInName)
  54              attributeName += chr;
  55  
  56          if (withInValue)
  57              attributeValue += chr;
  58      }
  59  
  60      return attributes;
  61  }
  62  
  63  function TinyMCE_flash_execCommand(editor_id, element, command, user_interface, value) {
  64  	function getAttrib(elm, name) {
  65          return elm.getAttribute(name) ? elm.getAttribute(name) : "";
  66      }
  67  
  68      // Handle commands
  69      switch (command) {
  70          case "mceFlash":
  71              var name = "", swffile = "", swfwidth = "", swfheight = "", action = "insert";
  72              var template = new Array();
  73              var inst = tinyMCE.getInstanceById(editor_id);
  74              var focusElm = inst.getFocusElement();
  75  
  76              template['file']   = '../../plugins/flash/flash.htm'; // Relative to theme
  77              template['width']  = 400;
  78              template['height'] = 195;
  79  
  80              // Is selection a image
  81              if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
  82                  name = getAttrib(focusElm, 'name');
  83  
  84                  if (name != 'mce_plugin_flash') // Not a Flash
  85                      return true;
  86  
  87                  // Get rest of Flash items
  88                  swffile = getAttrib(focusElm, 'alt');
  89                  swffile = eval(tinyMCE.settings['urlconverter_callback'] + "(swffile, null, true);");
  90                  swfwidth = getAttrib(focusElm, 'width');
  91                  swfheight = getAttrib(focusElm, 'height');
  92                  action = "update";
  93              }
  94  
  95              tinyMCE.openWindow(template, {editor_id : editor_id, swffile : swffile, swfwidth : swfwidth, swfheight : swfheight, action : action});
  96          return true;
  97     }
  98  
  99     // Pass to next handler in chain
 100     return false;
 101  }
 102  
 103  function TinyMCE_flash_cleanup(type, content) {
 104      switch (type) {
 105          case "insert_to_editor_dom":
 106              var imgs = content.getElementsByTagName("img");
 107              for (var i=0; i<imgs.length; i++) {
 108                  if (tinyMCE.getAttrib(imgs[i], "name") == "mce_plugin_flash") {
 109                      var src = tinyMCE.getAttrib(imgs[i], "alt");
 110  
 111                      src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], src);
 112  
 113                      imgs[i].setAttribute('alt', src);
 114                  }
 115              }
 116              break;
 117  
 118          case "get_from_editor_dom":
 119              var imgs = content.getElementsByTagName("img");
 120              for (var i=0; i<imgs.length; i++) {
 121                  if (tinyMCE.getAttrib(imgs[i], "name") == "mce_plugin_flash") {
 122                      var src = tinyMCE.getAttrib(imgs[i], "alt");
 123  
 124                      src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, null, true);");
 125  
 126                      imgs[i].setAttribute('alt', src);
 127                  }
 128              }
 129              break;
 130  
 131          case "insert_to_editor":
 132              var startPos = 0;
 133              var embedList = new Array();
 134  
 135              // Fix the embed and object elements
 136              content = content.replace(new RegExp('<[ ]*embed','gi'),'<embed');
 137              content = content.replace(new RegExp('<[ ]*/embed[ ]*>','gi'),'</embed>');
 138              content = content.replace(new RegExp('<[ ]*object','gi'),'<object');
 139              content = content.replace(new RegExp('<[ ]*/object[ ]*>','gi'),'</object>');
 140  
 141              // Parse all embed tags
 142              while ((startPos = content.indexOf('<embed', startPos+1)) != -1) {
 143                  var endPos = content.indexOf('>', startPos);
 144                  var attribs = TinyMCE_flash_parseAttributes(content.substring(startPos + 6, endPos));
 145                  embedList[embedList.length] = attribs;
 146              }
 147  
 148              // Parse all object tags and replace them with images from the embed data
 149              var index = 0;
 150              while ((startPos = content.indexOf('<object', startPos)) != -1) {
 151                  if (index >= embedList.length)
 152                      break;
 153  
 154                  var attribs = embedList[index];
 155  
 156                  // Find end of object
 157                  endPos = content.indexOf('</object>', startPos);
 158                  endPos += 9;
 159  
 160                  // Insert image
 161                  var contentAfter = content.substring(endPos);
 162                  content = content.substring(0, startPos);
 163                  content += '<img name="mce_plugin_flash" width="' + attribs["width"] + '" height="' + attribs["height"] + '"';
 164                  content += ' src="' + (tinyMCE.getParam("theme_href") + '/images/spacer.gif') + '" title="' + attribs["src"] + '"';
 165                  content += ' alt="' + attribs["src"] + '" class="mce_plugin_flash" />' + content.substring(endPos);
 166                  content += contentAfter;
 167                  index++;
 168  
 169                  startPos++;
 170              }
 171              break;
 172  
 173          case "get_from_editor":
 174              // Parse all img tags and replace them with object+embed
 175              var startPos = -1;
 176              while ((startPos = content.indexOf('<img', startPos+1)) != -1) {
 177                  var endPos = content.indexOf('/>', startPos);
 178                  var attribs = TinyMCE_flash_parseAttributes(content.substring(startPos + 4, endPos));
 179  
 180                  // Is not flash, skip it
 181                  if (attribs['name'] != "mce_plugin_flash")
 182                      continue;
 183  
 184                  endPos += 2;
 185  
 186                  var embedHTML = '';
 187  
 188                  // Insert object + embed
 189                  embedHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
 190                  embedHTML += ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"';
 191                  embedHTML += ' width="' + attribs["width"] + '" height="' + attribs["height"] + '">';
 192                  embedHTML += '<param name="movie" value="' + attribs["title"] + '" />';
 193                  embedHTML += '<param name="quality" value="high" />';
 194                  embedHTML += '<param name="menu" value="false" />';
 195                  embedHTML += '<embed src="' + attribs["title"] + '" quality="high" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + attribs["width"] + '" height="' + attribs["height"] + '"></embed></object>';
 196  
 197                  // Insert embed/object chunk
 198                  chunkBefore = content.substring(0, startPos);
 199                  chunkAfter = content.substring(endPos);
 200                  content = chunkBefore + embedHTML + chunkAfter;
 201              }
 202              break;
 203      }
 204  
 205      // Pass through to next handler in chain
 206      return content;
 207  }
 208  
 209  function TinyMCE_flash_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
 210  	function getAttrib(elm, name) {
 211          return elm.getAttribute(name) ? elm.getAttribute(name) : "";
 212      }
 213  
 214      tinyMCE.switchClassSticky(editor_id + '_flash', 'mceButtonNormal');
 215  
 216      if (node == null)
 217          return;
 218  
 219      do {
 220          if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'name').indexOf('mce_plugin_flash') == 0)
 221              tinyMCE.switchClassSticky(editor_id + '_flash', 'mceButtonSelected');
 222      } while ((node = node.parentNode));
 223  
 224      return true;
 225  }


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