[ 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_ns4.js (source)

   1  /*
   2      DynAPI Distribution
   3      DynLayer NS4 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._ns4IPad = '<img src="'+dynapi.library.path+'gui/images/pixel.gif" width="0" height="0">'; // used with blackboard
  12  p._remove = function() {
  13      if (this.elm) {
  14          var p = this.parent;
  15          if (p && this._alias) p[this._alias]=null;
  16          if (!p.doc.recycled) p.doc.recycled=[];
  17          p.doc.recycled[p.doc.recycled.length]=this.elm;
  18          this.elm.visibility="hide";
  19          this.elm = null;
  20          if (this.releaseMouseEvents) this.releaseMouseEvents();
  21          if (this.releaseKeyEvents) this.releaseKeyEvents();
  22      }
  23      /*this.frame = null;
  24      this.bgImage = null;
  25      this.bgColor = null;
  26      this.html = null;
  27      this.z = null;
  28      this.w = null;
  29      this.h = null;
  30      this.elm = null;
  31      this.doc = null;
  32      this.css = null;*/
  33  };
  34  p._create = function() {
  35      if (this.parent && !this.elm) {
  36          DynElement._flagPreCreate(this);
  37          var parentElement = this.parent.isClass('DynLayer')? this.parent.elm : this.parent.frame;
  38          var elm = new Layer(this.w||0, parentElement);
  39          if(this._className) elm.className=this._className; // does this work in ns4?
  40          if(!this._noStyle) {
  41              if (this.w) elm.clip.width = this.w+this._fixBw;
  42              if (this.h) elm.clip.height = this.h+this._fixBh;
  43              if (this.x && this.y) elm.moveTo(this.x,this.y);
  44              else if (this.x) elm.left = this.x;
  45              else if (this.y) elm.top = this.y;
  46              if (this.bgColor!=null) elm.document.bgColor = this.bgColor;
  47              if (this.clip) {
  48                  var c = elm.clip, cl = this.clip;
  49                  c.top=cl[0], c.right=cl[1], c.bottom=cl[2], c.left=cl[3];
  50              }
  51              if (this.z) elm.zIndex = this.z;
  52              if (this.visible) elm.visibility = 'inherit';
  53          }
  54          if (this.children.length || (this.html!=null && this.html!='')) {
  55              elm.document.write(this.getInnerHTML());
  56              elm.document.close();
  57          }
  58          DynLayer._assignElement(this,elm);
  59          DynElement._flagCreate(this);
  60      }
  61  };
  62  DynLayer._getLayerById = function(id,pElm){
  63      var i,lyrs,elm;
  64      pElm = (pElm)? pElm:document;
  65      lyrs = pElm.layers;
  66      for (i=0;i<lyrs.length;i++){
  67          elm=lyrs[i];
  68          if (elm.id==id) return elm;
  69          else if (elm.layers.length){
  70              elm = this._getLayerById(id,elm);
  71              if (elm) return elm;
  72          }                
  73      }
  74  };
  75  DynLayer._assignElement = function(dlyr,elm) {
  76      if (!elm) {
  77          elm = dlyr.parent.doc.layers[dlyr.id];
  78          if (!elm) elm=DynLayer._getLayerById(dlyr.id,dlyr.parent.elm);
  79          if (!elm){
  80              if(dlyr.isInline) dlyr._create();  // force create() for missing inline layer
  81              return;
  82          }
  83      }
  84      dlyr.elm = elm;
  85      dlyr.css = elm;
  86      dlyr.doc = elm.document;
  87      if(dlyr._blkBoardElm) {
  88          dlyr._blkBoardElm = elm.document.layers[dlyr.id+'blkboard'];
  89          dlyr.doc = dlyr._blkBoardElm.document; // useful for <forms>, images, links, etc
  90      }
  91      dlyr.elm._dynobj = dlyr.doc._dynobj = dlyr;
  92      dlyr._dyndoc = dlyr.parent._dyndoc;
  93  
  94      // COMMENTED OUT TO PERMIT CSS PRIORITY
  95      // by Raphael Pereira <raphael@think-e.com.br>
  96      if (0 && dlyr.html!=null && dlyr.html!='' && (dlyr.w==null || dlyr.h==null)) {
  97          var cw = (dlyr.w==null)? dlyr.getContentWidth() : null;
  98          var ch = (dlyr.h==null)? dlyr.getContentHeight() : null;
  99          //var cw = (dlyr.w==null)? dlyr.getElmWidth() : null;
 100          //var ch = (dlyr.h==null)? dlyr.getElmHeight() : null;
 101          dlyr.setSize(cw,ch);
 102      }
 103      if (dlyr.bgImage!=null) dlyr.setBgImage(dlyr.bgImage);
 104      
 105      var i,ch=dlyr.children; 
 106      for (i=0;i<ch.length;i++) DynLayer._assignElement(ch[i],null);
 107  
 108  
 109      if (dlyr._hasKeyEvents) dlyr.captureKeyEvents();
 110      if (dlyr._hasMouseEvents) dlyr.captureMouseEvents();
 111      else {
 112          // assign ._dynobj to images and links
 113          for (var i=0;i<dlyr.doc.images.length;i++) dlyr.doc.images[i]._dynobj=dlyr; // was _dynobji
 114          for (var i=0;i<dlyr.doc.links.length;i++) dlyr.doc.links[i]._dynobj=dlyr;
 115      }
 116  };
 117  
 118  p.getOuterHTML = function() {
 119      // get box fix values
 120      var fixBw = (this._fixBw)? this._fixBw:0;
 121      var fixBh = (this._fixBh)? this._fixBh:0;
 122      var tag='layer',clip='';
 123      if (fixBw||fixBh) this._fixBoxModel = true;
 124      if(this._position=='relative') tag='ilayer';
 125      if(this._noStyle) return '\n<'+tag+' '+this._cssClass+' id="'+this.id+'">'+this.getInnerHTML()+'</'+tag+'>';
 126      else {
 127          if (this.clip) clip=' clip="'+this.clip[3]+','+this.clip[0]+','+this.clip[1]+','+this.clip[2]+'"';
 128          else clip=' clip="0,0,'+((this.w>=0)? this.w+fixBw:0)+','+((this.h>=0)? this.h+fixBh:0)+'"';
 129          return [
 130              '\n<'+tag+' ',this._cssClass,' id="'+this.id+'"',
 131              ' left=',(this.x!=null? this.x : 0),
 132              ' top=',(this.y!=null? this.y : 0),
 133              ((this.visible)? ' visibility="inherit"':' visibility="hide"'),
 134              ((this.w!=null)? ' width='+(this.w+fixBw):''),
 135              ((this.h!=null)? ' height='+(this.h+fixBw):''),
 136              ((this.z)? ' zindex='+this.z:''), 
 137              ((this.bgColor!=null)? ' bgcolor="'+this.bgColor+'"':''),
 138              ((this.bgImage!=null)? ' background="'+this.bgImage+'"':''),            
 139              clip,'>',this.getInnerHTML(),'</'+tag+'>'
 140          ].join('');
 141      }
 142  };
 143  p.getInnerHTML = function() {
 144      var i,s = '',ch=this.children;
 145      if (this.html!=null) {
 146          if (this.w==null) s += '<nobr>'+this.html+'</nobr>';
 147          else s+=this.html;
 148      }
 149      if (this._blkBoardElm) s='<layer id="'+this.id+'blkboard">'+this._ns4IPad+s+'</layer>';    
 150      if(ch.length<50) for (i=0;i<ch.length;i++) s+=ch[i].getOuterHTML(); 
 151      else if(ch.length){
 152          var ar=['']; // speed improvement for layers with nested children
 153          for (i=0;i<ch.length;i++) ar[i]=ch[i].getOuterHTML();
 154          s=s+ar.join('');    
 155      }
 156      return s;
 157  };
 158  p.enableBlackboard = function(){
 159      if (!this._created) this._blkBoardElm=true;
 160      else if(!this._blkBoardElm){
 161          var c,i,h='',elm = this.elm;
 162          if(this.html!=null) h=this.html;        
 163          var parentElement = this.parent.isClass('DynLayer')? this.parent.elm : this.parent.frame;
 164          var belm = this._blkBoardElm = new Layer(0, elm);
 165          this.doc = belm.document;
 166          this.doc.write(h); this.doc.close();
 167          belm.visibility = 'inherit';
 168          for (i=0;i<this.children.length;i++){
 169              c=this.children[i];
 170              c.css.zIndex=c.css.zIndex; // reset zindex
 171          }        
 172      }
 173  };
 174  p.setLocation = function(x,y) {
 175      var cx = (x!=null && x!=this.x);
 176      var cy = (y!=null && y!=this.y);
 177      if (cx) this.x = x||0;
 178      if (cy) this.y = y||0;
 179      if (this.css!=null) {
 180          if (cx && cy) this.elm.moveTo(this.x, this.y);
 181          else if (cx) this.css.left = this.x;
 182          else if (cy) this.css.top = this.y;
 183          // adjust parent size after being moved
 184          if((cx||cy) && this.parent._aSz) this.parent._adjustSize();            
 185      }
 186      if(this._hasLocationEvents) this.invokeEvent('locationchange');    
 187      return (cx||cy);
 188  };
 189  p.setPageLocation = function(x,y) {
 190      if (this.css) {
 191          if (x!=null) {
 192              this.css.pageX = x;
 193              this.x = this.css.left;
 194          }
 195          if (y!=null) {
 196              this.css.pageY = y;
 197              this.y = this.css.top;
 198          }
 199          return true;
 200      }
 201      else {
 202          if (this.isChild) {
 203              if (x!=null) x = x - this.parent.getPageX();
 204              if (y!=null) y = y - this.parent.getPageY();
 205          }
 206          return this.setLocation(x,y);
 207      }
 208  };
 209  p.getPageX = function() {return this.css? this.css.pageX : null};
 210  p.getPageY = function() {return this.css? this.css.pageY : null};
 211  p.setVisible = function(b) {
 212      if (b!=this.visible) {
 213          this.visible = b;
 214          if (this.css) this.css.visibility = b? "inherit" : "hide";
 215      }
 216  };
 217  p.setSize = function(w,h) {
 218      if (this._useMinSize||this._useMaxSize){
 219          if (this._minW && w<this._minW) w=this._minW;
 220          if (this._minH && h<this._minH) h=this._minH;
 221          if (this._maxW && w>this._maxW) w=this._maxW;
 222          if (this._maxH && h>this._maxH) h=this._maxH;
 223      }
 224      var cw = (w!=null && w!=this.w);
 225      var ch = (h!=null && h!=this.h);
 226      if (cw) this.w = w<0? 0 : w;
 227      if (ch) this.h = h<0? 0 : h;
 228      if (cw||ch) {
 229          if (this._hasAnchor) this.updateAnchor(); // update this anchor
 230          if (this._hasChildAnchors) this._updateAnchors(); // update child anchors
 231          if (this.css) {
 232              if (cw) this.css.clip.width = (this.w || 0)+this._fixBw;
 233              if (ch) this.css.clip.height = (this.h || 0)+this._fixBh;
 234              // adjust parent size after being sized
 235              if((cw||ch) && this.parent._aSz) this.parent._adjustSize();
 236              if (this.updateLayout) this.updateLayout();            
 237          }
 238      }
 239      if(this._hasResizeEvents) this.invokeEvent('resize');
 240      return (cw||ch);
 241  };
 242  p.setHTML=function(html) {
 243      var ch = (html!=null && html!=this.html);
 244      if (ch) {
 245          this.html = html;
 246          if (this.css) {
 247              var i, doc = this.doc;
 248              var html=(!this._blkBoardElm)? this.html:this._ns4IPad+this.html; // don't ask why! See HTMLContainer
 249              doc.open();    doc.write(html); doc.close();
 250              for (i=0;i<doc.images.length;i++) doc.images[i]._dynobj = this;
 251              for (i=0;i<doc.links.length;i++) doc.links[i]._dynobj = this;
 252              this._adjustSize();
 253          }
 254      }
 255      if(this._hasContentEvents) this.invokeEvent('contentchange');
 256  };
 257  p.setTextSelectable=function(b) {
 258      this._textSelectable = b;
 259      this.addEventListener({
 260          onmousemove : function(e) {
 261              e.preventDefault();
 262          }
 263      });
 264      // && this.captureMouseEvents && !this._hasMouseEvents) this.captureMouseEvents();
 265  };
 266  p.getCursor = function() {return this._cursor};
 267  p.setCursor = function(c) {
 268      if (!c) c = 'default';
 269      if (this._cursor!=c) this._cursor = c;    
 270      // Note: not supported in ns4
 271  };
 272  p.setBgColor=function(c) {
 273      this.bgColor = c;
 274      if (this.css) this.elm.document.bgColor = c;
 275  };
 276  p.setBgImage=function(path) {
 277      this.bgImage=path||'none';
 278      if (this.css) {
 279          //if (!path) this.setBgColor(this.getBgColor());
 280          setTimeout(this+'.elm.background.src="'+this.bgImage+'"',1);
 281      }
 282  };
 283  p.getContentWidth=function() {
 284      if (this.elm==null) return 0;
 285      else {
 286          return this.doc.width;
 287      };
 288  };
 289  p.getContentHeight=function() {
 290      if (this.elm==null) return 0;
 291      else {
 292          return this.doc.height;
 293      }
 294  };
 295  p.setClip=function(clip) {
 296      var cc=this.getClip();
 297      for (var i=0;i<clip.length;i++) if (clip[i]==null) clip[i]=cc[i];
 298      this.clip=clip;
 299      if (this.css==null) return;
 300      var c=this.css.clip;
 301      c.top=clip[0], c.right=clip[1], c.bottom=clip[2], c.left=clip[3];
 302  };
 303  p.getClip=function() {
 304      if (this.css==null || !this.css.clip) return [0,0,0,0];
 305      var c = this.css.clip;
 306      if (c) {
 307          return [c.top,c.right,c.bottom,c.left];
 308      }
 309  };
 310  


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