[ Index ]
 

Code source de eGroupWare 1.2.106-2

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

title

Body

[fermer]

/phpgwapi/js/dynapi/api/ -> dynlayer_dom.js (source)

   1  /*
   2      DynAPI Distribution
   3      DynLayer DOM Specific Functions
   4  
   5      The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
   6      
   7      requires: dynapi.api.DynLayerBase
   8  */
   9  
  10  p = DynLayer.prototype;
  11  p._create = function() {
  12      if (this.parent && !this.elm) {
  13          DynElement._flagPreCreate(this);
  14          var elm, parentElement;
  15          parentElement = this.parent.elm;
  16          
  17          // this method seems faster for most dom browsers
  18          var r = parentElement.ownerDocument.createRange();
  19          r.setStartBefore(parentElement);
  20          var ptxt = r.createContextualFragment(this.getOuterHTML());
  21          parentElement.appendChild(ptxt);
  22          elm = parentElement.lastChild;
  23  
  24          DynLayer._assignElement(this,elm);
  25          DynElement._flagCreate(this);
  26      }
  27  };
  28  DynLayer._assignElement = function(dlyr,elm,divs) {
  29      if (!elm ) {
  30          elm = (divs)? divs[dlyr.id] : dlyr.parent.doc.getElementById(dlyr.id);
  31          if (!elm){
  32              if(dlyr.isInline) dlyr._create();  // force create() for missing inline layer
  33              return;
  34          }
  35      }
  36      dlyr.elm = elm;
  37      dlyr.css = elm.style;
  38      dlyr.doc = dlyr.parent.doc;
  39      dlyr.elm._dynobj = dlyr;
  40      dlyr._dyndoc = dlyr.parent._dyndoc;
  41      if(dlyr._blkBoardElm) dlyr._blkBoardElm = (divs)? divs[dlyr.id+'_blkboard'] : dlyr.parent.doc.getElementById(dlyr.id+'_blkboard');
  42  
  43      if (dlyr.z) dlyr.css.zIndex = dlyr.z;
  44  
  45      // COMMENTED OUT TO PERMIT CSS PRIORITY
  46      // by Raphael Pereira <raphaelpereira@users.sourceforge.net>
  47      if (0 && dlyr.html!=null && dlyr.html!='' && (dlyr.w==null || dlyr.h==null)) {
  48          var cw = (dlyr.w==null)? dlyr.getContentWidth() : null;
  49          var ch = (dlyr.h==null)? dlyr.getContentHeight() : null;
  50          //var cw = (dlyr.w==null)? dlyr.getElmWidth() : null;
  51          //var ch = (dlyr.h==null)? dlyr.getElmHeight() : null;
  52          dlyr.setSize(cw,ch);
  53      }
  54  
  55      var i,ch=dlyr.children; 
  56      for (i=0;i<ch.length;i++) DynLayer._assignElement(ch[i],null,divs);
  57  
  58      // Box Fix - for Border Manager
  59      if (dlyr._needBoxFix) BorderManager.FixBoxModel(dlyr);
  60  
  61      if (dlyr._hasKeyEvents) dlyr.captureKeyEvents();
  62      if (dlyr._hasMouseEvents) dlyr.captureMouseEvents();
  63  };
  64  p.enableBlackboard = function(){
  65      if (!this._created) this._blkBoardElm=true;
  66      else if(!this._blkBoardElm){
  67          var r,ptxt;
  68          var h='',elm = this.elm;
  69          if(this.html!=null) h=this.html;
  70          r = elm.ownerDocument.createRange();
  71          r.setStartBefore(elm);
  72          ptxt = r.createContextualFragment('<div id="'+this.id+'_blkboard">'+h+'</div>');
  73          elm.appendChild(ptxt);
  74          this._blkBoardElm = elm.lastChild;        
  75      }
  76  };
  77  p.setLocation=function(x,y) {
  78      var cx = (x!=null && x!=this.x);
  79      var cy = (y!=null && y!=this.y);
  80      if (cx) this.x = x||0;
  81      if (cy) this.y = y||0;
  82      if (this.css!=null) {
  83          if (cx) this.css.left = this.x+"px";
  84          if (cy) this.css.top = this.y+"px";
  85          // adjust parent size after being moved
  86          if((cx||cy) && this.parent._aSz) this.parent._adjustSize();
  87      }
  88      if(this._hasLocationEvents) this.invokeEvent('locationchange');
  89      return (cx||cy);
  90  };
  91  p.setPageLocation = function(x,y) {
  92      if (this.isChild) {
  93          if (x!=null) x = x - this.parent.getPageX();
  94          if (y!=null) y = y - this.parent.getPageY();
  95      }
  96      return this.setLocation(x,y);
  97  };
  98  p.setHTML = function(html) {
  99      if (html!=this.html) {
 100          this.html = html;
 101          if (this.css) {
 102              var elm = (this._blkBoardElm)? this._blkBoardElm:this.elm;
 103              elm.innerHTML = html;        
 104              var sTmp=(this.w==null)?'<NOBR>'+this.html+'</NOBR>':this.html;
 105              while (elm.hasChildNodes()) elm.removeChild(elm.firstChild);
 106              var r=elm.ownerDocument.createRange();
 107              r.selectNodeContents(elm);
 108              r.collapse(true);
 109              var df=r.createContextualFragment(sTmp);
 110              elm.appendChild(df);
 111              this._adjustSize();
 112          }
 113      }
 114      if(this._hasContentEvents) this.invokeEvent('contentchange');    
 115  };
 116  p.setTextSelectable=function(b) {
 117      this._textSelectable = b;
 118      if(!this._hasMouseEvents) this.captureMouseEvents();
 119      if (!b) this.setCursor('default');
 120  };
 121  p.getCursor = function() {return (this._cursor=='pointer')? 'hand':this._cursor};
 122  p.setCursor = function(c) {
 123      if (!c) c = 'default';
 124      else c=(c+'').toLowerCase();
 125      if (c=='hand') c='pointer';
 126      if (this._cursor!=c) {
 127          this._cursor = c;
 128          if (this.css) this.css.cursor = c;
 129      }        
 130  };
 131  p.getContentWidth=function() {
 132      if (this.elm==null) return 0;
 133      else {
 134          var p = this.parent;        
 135          var tw = this.elm.style.width;
 136          this.css.width = "auto";        
 137          var w = this.elm.offsetWidth;
 138          this.css.width = tw;
 139          return w;
 140      };
 141  };
 142  p.getContentHeight=function() {
 143      if (this.elm==null) return 0;
 144      else {
 145          var th = this.css.height;
 146          this.elm.style.height = "auto";
 147          var h = this.elm.offsetHeight;
 148          this.css.height = th;
 149          return h;
 150      }
 151  };


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