[ Index ]
 

Code source de Joomla 1.0.13

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/mambots/editors/tinymce/jscripts/tiny_mce/plugins/preview/ -> editor_plugin_src.js (source)

   1  /**
   2   * $Id: editor_plugin_src.js 126 2006-10-22 16:19:55Z spocke $
   3   *
   4   * @author Moxiecode
   5   * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
   6   */
   7  
   8  /* Import plugin specific language pack */
   9  tinyMCE.importPluginLanguagePack('preview');
  10  
  11  var TinyMCE_PreviewPlugin = {
  12      getInfo : function() {
  13          return {
  14              longname : 'Preview',
  15              author : 'Moxiecode Systems AB',
  16              authorurl : 'http://tinymce.moxiecode.com',
  17              infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_preview.html',
  18              version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
  19          };
  20      },
  21  
  22      /**
  23       * Returns the HTML contents of the preview control.
  24       */
  25      getControlHTML : function(cn) {
  26          switch (cn) {
  27              case "preview":
  28                  return tinyMCE.getButtonHTML(cn, 'lang_preview_desc', '{$pluginurl}/images/preview.gif', 'mcePreview');
  29          }
  30  
  31          return "";
  32      },
  33  
  34      /**
  35       * Executes the mcePreview command.
  36       */
  37      execCommand : function(editor_id, element, command, user_interface, value) {
  38          // Handle commands
  39          switch (command) {
  40              case "mcePreview":
  41                  var previewPage = tinyMCE.getParam("plugin_preview_pageurl", null);
  42                  var previewWidth = tinyMCE.getParam("plugin_preview_width", "550");
  43                  var previewHeight = tinyMCE.getParam("plugin_preview_height", "600");
  44  
  45                  // Use a custom preview page
  46                  if (previewPage) {
  47                      var template = new Array();
  48  
  49                      template['file'] = previewPage;
  50                      template['width'] = previewWidth;
  51                      template['height'] = previewHeight;
  52  
  53                      tinyMCE.openWindow(template, {editor_id : editor_id, resizable : "yes", scrollbars : "yes", inline : "yes", content : tinyMCE.getContent(), content_css : tinyMCE.getParam("content_css")});
  54                  } else {
  55                      var win = window.open("", "mcePreview", "menubar=no,toolbar=no,scrollbars=yes,resizable=yes,left=20,top=20,width=" + previewWidth + ",height="  + previewHeight);
  56                      var html = "", i;
  57                      var c = tinyMCE.getContent();
  58                      var pos = c.indexOf('<body'), pos2, css = tinyMCE.getParam("content_css").split(',');
  59  
  60                      if (pos != -1) {
  61                          pos = c.indexOf('>', pos);
  62                          pos2 = c.lastIndexOf('</body>');
  63                          c = c.substring(pos + 1, pos2);
  64                      }
  65  
  66                      html += tinyMCE.getParam('doctype');
  67                      html += '<html xmlns="http://www.w3.org/1999/xhtml">';
  68                      html += '<head>';
  69                      html += '<title>' + tinyMCE.getLang('lang_preview_desc') + '</title>';
  70                      html += '<base href="' + tinyMCE.settings['base_href'] + '" />';
  71                      html += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
  72  
  73                      for (i=0; i<css.length; i++)
  74                          html += '<link href="' + css[i] + '" rel="stylesheet" type="text/css" />';
  75  
  76                      html += '<script type="text/javascript">';
  77                      html += 'window.opener.TinyMCE_PreviewPlugin._setDoc(document);';
  78                      html += 'window.opener.TinyMCE_PreviewPlugin._setWin(window);';
  79                      html += 'writeFlash = window.opener.TinyMCE_PreviewPlugin._writeFlash;';
  80                      html += 'writeShockWave = window.opener.TinyMCE_PreviewPlugin._writeShockWave;';
  81                      html += 'writeQuickTime = window.opener.TinyMCE_PreviewPlugin._writeQuickTime;';
  82                      html += 'writeRealMedia = window.opener.TinyMCE_PreviewPlugin._writeRealMedia;';
  83                      html += 'writeWindowsMedia = window.opener.TinyMCE_PreviewPlugin._writeWindowsMedia;';
  84                      html += 'writeEmbed = window.opener.TinyMCE_PreviewPlugin._writeEmbed;';
  85                      html += '</script>';
  86                      html += '</head>';
  87                      html += '<body dir="' + tinyMCE.getParam("directionality") + '" onload="window.opener.TinyMCE_PreviewPlugin._onLoad();">';
  88                      html += c;
  89                      html += '</body>';
  90                      html += '</html>';
  91  
  92                      win.document.write(html);
  93                      win.document.close();
  94                  }
  95  
  96                  return true;
  97          }
  98  
  99          return false;
 100      },
 101  
 102      _setDoc : function(d) {
 103          TinyMCE_PreviewPlugin._doc = d;
 104          d._embeds = new Array();
 105      },
 106  
 107      _setWin : function(d) {
 108          TinyMCE_PreviewPlugin._win = d;
 109      },
 110  
 111      _onLoad : function() {
 112          var nl, i, el = new Array(), d = TinyMCE_PreviewPlugin._doc, sv, ne;
 113  
 114          nl = d.getElementsByTagName("script");
 115          for (i=0; i<nl.length; i++) {
 116              sv = tinyMCE.isMSIE ? nl[i].innerHTML : nl[i].firstChild.nodeValue;
 117  
 118              if (new RegExp('write(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)\\(.*', 'g').test(sv))
 119                  el[el.length] = nl[i];
 120          }
 121  
 122          for (i=0; i<el.length; i++) {
 123              ne = d.createElement("div");
 124              ne.innerHTML = d._embeds[i];
 125              el[i].parentNode.insertBefore(ne.firstChild, el[i]);
 126          }
 127      },
 128  
 129      _writeFlash : function(p) {
 130          p.src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], p.src);
 131          TinyMCE_PreviewPlugin._writeEmbed(
 132              'D27CDB6E-AE6D-11cf-96B8-444553540000',
 133              'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
 134              'application/x-shockwave-flash',
 135              p
 136          );
 137      },
 138  
 139      _writeShockWave : function(p) {
 140          p.src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], p.src);
 141          TinyMCE_PreviewPlugin._writeEmbed(
 142              '166B1BCA-3F9C-11CF-8075-444553540000',
 143              'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0',
 144              'application/x-director',
 145              p
 146          );
 147      },
 148  
 149      _writeQuickTime : function(p) {
 150          p.src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], p.src);
 151          TinyMCE_PreviewPlugin._writeEmbed(
 152              '02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
 153              'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0',
 154              'video/quicktime',
 155              p
 156          );
 157      },
 158  
 159      _writeRealMedia : function(p) {
 160          p.src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], p.src);
 161          TinyMCE_PreviewPlugin._writeEmbed(
 162              'CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA',
 163              'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
 164              'audio/x-pn-realaudio-plugin',
 165              p
 166          );
 167      },
 168  
 169      _writeWindowsMedia : function(p) {
 170          p.src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], p.src);
 171          p.url = p.src;
 172          TinyMCE_PreviewPlugin._writeEmbed(
 173              '6BF52A52-394A-11D3-B153-00C04F79FAA6',
 174              'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701',
 175              'application/x-mplayer2',
 176              p
 177          );
 178      },
 179  
 180      _writeEmbed : function(cls, cb, mt, p) {
 181          var h = '', n, d = TinyMCE_PreviewPlugin._doc, ne, c;
 182  
 183          h += '<object classid="clsid:' + cls + '" codebase="' + cb + '"';
 184          h += typeof(p.id) != "undefined" ? 'id="' + p.id + '"' : '';
 185          h += typeof(p.name) != "undefined" ? 'name="' + p.name + '"' : '';
 186          h += typeof(p.width) != "undefined" ? 'width="' + p.width + '"' : '';
 187          h += typeof(p.height) != "undefined" ? 'height="' + p.height + '"' : '';
 188          h += typeof(p.align) != "undefined" ? 'align="' + p.align + '"' : '';
 189          h += '>';
 190  
 191          for (n in p)
 192              h += '<param name="' + n + '" value="' + p[n] + '">';
 193  
 194          h += '<embed type="' + mt + '"';
 195  
 196          for (n in p)
 197              h += n + '="' + p[n] + '" ';
 198  
 199          h += '></embed></object>';
 200  
 201          d._embeds[d._embeds.length] = h;
 202      }
 203  };
 204  
 205  tinyMCE.addPlugin("preview", TinyMCE_PreviewPlugin);


Généré le : Wed Nov 21 14:43:32 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics