[ Index ]
 

Code source de Horde 3.1.3

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

title

Body

[fermer]

/services/editor/htmlarea/plugins/AnselImage/ -> ansel-image.js (source)

   1  // Ansel Image Plugin for HTMLArea-3.0
   2  // Plugin that allows the insertion of images from the
   3  // Horde framework module Ansel into a text
   4  //
   5  // Module reuses HTMLArea code
   6  //
   7  // Implementation: Roel Gloudemans <roel@gloudemans.info>
   8  //
   9  // (c) 2004.
  10  // Distributed under the same terms as HTMLArea itself.
  11  // This notice MUST stay intact for use (see license.txt).
  12  //
  13  // $Id: ansel-image.js,v 1.1 2004/09/08 16:06:13 lancer Exp $
  14  
  15  
  16  function AnselImage(editor)
  17  {
  18      this.editor = editor;
  19      var i18n = AnselImage.I18N;
  20  };
  21  
  22  
  23  AnselImage._pluginInfo = {
  24      name          : "AnselImage",
  25      version       : "1.0",
  26      developer     : "Roel Gloudemans",
  27      developer_url : "http://www.gloudemans.info/",
  28          sponsor       : "Horde Project",
  29          sponsor_url   : "http://www.horde.org/",
  30      license       : "htmlArea"
  31  };
  32  
  33  
  34  // Called when the user clicks on "InsertImage" button.  If an image is already
  35  // there, it will just modify it's properties.
  36  // This function overrides the native HTMLArea function
  37  HTMLArea.prototype._insertImage = function(image) {
  38      var editor = this;    // for nested functions
  39      var outparam = null;
  40  
  41      if (typeof image == "undefined") {
  42          image = this.getParentElement();
  43          if (image && !/^img$/i.test(image.tagName))
  44              image = null;
  45      }
  46      if (image) outparam = {
  47          f_base   : editor.config.baseURL,
  48          f_url    : HTMLArea.is_ie ? editor.stripBaseURL(image.src) : image.getAttribute("src"),
  49          f_alt    : image.alt,
  50          f_border : image.border,
  51          f_align  : image.align,
  52          f_vert   : image.vspace,
  53          f_horiz  : image.hspace
  54      };
  55  
  56      var manager = _editor_url + 'plugins/AnselImage/insert_image.php';
  57  
  58      Dialog(manager, function(param) {
  59  //    this._popupDialog(manager, function(param) {
  60          if (!param) {    // user must have pressed Cancel
  61              return false;
  62          }
  63          var img = image;
  64          if (!img) {
  65              var sel = editor._getSelection();
  66              var range = editor._createRange(sel);
  67              editor._doc.execCommand("insertimage", false, param.f_url);
  68              if (HTMLArea.is_ie) {
  69                  img = range.parentElement();
  70                  // wonder if this works...
  71                  if (img.tagName.toLowerCase() != "img") {
  72                      img = img.previousSibling;
  73                  }
  74              } else {
  75                  img = range.startContainer.previousSibling;
  76              }
  77          } else {
  78              img.src = param.f_url;
  79          }
  80  
  81          for (var field in param) {
  82              var value = param[field];
  83              switch (field) {
  84                  case "f_alt"    : img.alt     = value; break;
  85                  case "f_border" : img.border = parseInt(value || "0"); break;
  86                  case "f_align"  : img.align     = value; break;
  87                  case "f_vert"   : img.vspace = parseInt(value || "0"); break;
  88                  case "f_horiz"  : img.hspace = parseInt(value || "0"); break;
  89              }
  90          }
  91      }, outparam);
  92  };


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