Subversion Repositories wimsdev

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.         DynAPI Distribution
  3.         DynLayer IE 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.                 if(dynapi.ua.v<5){
  17.                         parentElement.insertAdjacentHTML("beforeEnd",this.getOuterHTML());
  18.                         elm = parentElement.children[parentElement.children.length-1];
  19.                 }
  20.                 else {
  21.                         // this method is more efficent for ie5+. any comment?
  22.                         elm=document.createElement('DIV');
  23.                         elm.id=this.id;
  24.                         if(this._noStyle) elm._className=this._className;
  25.                         else {
  26.                                 elm.style.position='absolute';
  27.                                 elm.style.pixelLeft=(this.x||0);
  28.                                 elm.style.pixelTop=(this.y||0);
  29.                                 elm.style.width=(this.w||'auto');
  30.                                 elm.style.height=(this.h||'auto');
  31.                                 elm.style.backgroundColor=(this.bgColor||'transparent');
  32.                                 elm.style.zIndex=(this.z||1);
  33.                                 elm.style.cursor=(this._cursor||'auto');
  34.                                 elm.style.overflow=(this._overflow!=null)? 'hidden':'';                
  35.                                 if(this.bgImage!=null) elm.style.backgroundImage='url('+this.bgImage+')';
  36.                                 if (this.bgImage==null && this.html==null) elm.style.backgroundImage='none';
  37.                                 if (this.clip) elm.style.clip='rect('+this.clip[0]+'px '+this.clip[1]+'px '+this.clip[2]+'px '+this.clip[3]+'px)';
  38.                                 else if (this.w!=null && this.h!=null) elm.style.clip='rect(0px '+this.w+'px '+this.h+'px 0px)';               
  39.                                 elm.style.visibility=(this.visible==false)? 'hidden':'inherit';
  40.                         }
  41.                         elm.innerHTML=this.getInnerHTML();
  42.                         parentElement.appendChild(elm);
  43.                 }
  44.                 DynLayer._assignElement(this,elm);
  45.                 DynElement._flagCreate(this);
  46.         }
  47. };
  48. DynLayer._assignElement = function(dlyr,elm,divs) {
  49.         if (!elm ) {
  50.                 elm = (divs)? divs[dlyr.id] : dlyr.parent.elm.all[dlyr.id];
  51.                 if (!elm) {dlyr._create();return}; // force create() for missing inline layer
  52.         }
  53.         dlyr.elm = elm;
  54.         dlyr.css = elm.style;
  55.         dlyr.doc = dlyr.parent.doc;
  56.         dlyr.elm._dynobj = dlyr;
  57.         dlyr._dyndoc = dlyr.parent._dyndoc;
  58.         if(dlyr._blkBoardElm) dlyr._blkBoardElm = (divs)? divs[dlyr.id+'_blkboard'] : dlyr.parent.elm.all[dlyr.id+'_blkboard'];
  59.  
  60.         if (dlyr.html!=null && dlyr.html!='' && (dlyr.w==null || dlyr.h==null)) {
  61.                 var cw = (dlyr.w==null)? dlyr.getContentWidth() : null;
  62.                 var ch = (dlyr.h==null)? dlyr.getContentHeight() : null;
  63.                 //var cw = (dlyr.w==null)? dlyr.getElmWidth() : null;
  64.                 //var ch = (dlyr.h==null)? dlyr.getElmHeight() : null;
  65.                 dlyr.setSize(cw,ch);
  66.         }
  67.        
  68.         var i,ch=dlyr.children;
  69.         for (i=0;i<ch.length;i++) DynLayer._assignElement(ch[i],null,divs);
  70.  
  71.         if (dlyr._textSelectable==false) elm.onselectstart = dynapi.functions.Deny;
  72.  
  73.         // prevent dragging of images
  74.         //if (elm.all.tags("img").length) elm.ondragstart = dynapi.functions.False;
  75.  
  76.         if (dlyr._hasMouseEvents) dlyr.captureMouseEvents();
  77.         if (dlyr._hasKeyEvents) dlyr.captureKeyEvents();
  78.  
  79. };
  80. p.enableBlackboard = function(){
  81.         if (!this._created) this._blkBoardElm=true;
  82.         else if(!this._blkBoardElm){
  83.                 var h='',elm = this.elm;
  84.                 if(this.html!=null) h=this.html;
  85.                 elm.insertAdjacentHTML("beforeEnd",'<div id="'+this.id+'_blkboard">'+h+'</div>');
  86.                 this._blkBoardElm = elm.children[elm.children.length-1];
  87.         }
  88. };
  89. p.setLocation=function(x,y) {
  90.         var cx = (x!=null && x!=this.x);
  91.         var cy = (y!=null && y!=this.y);
  92.         if (cx) this.x = x||0;
  93.         if (cy) this.y = y||0;
  94.         if (this.css!=null) {
  95.                 if (cx) this.css.pixelLeft = this.x;
  96.                 if (cy) this.css.pixelTop = this.y;
  97.         }
  98.         if(this._hasLocationEvents) this.invokeEvent('locationchange');
  99.         return (cx||cy);
  100. };
  101. p.setPageLocation = function(x,y) {
  102.         if (this.isChild) {
  103.                 if (dynapi.ua.v>=5) {
  104.                         if (cx) this.css.pixelLeft = this.x;
  105.                         if (cy) this.css.pixelTop = this.y;
  106.                 }
  107.                 else {
  108.                         if (cx) this.css.left = this.x+"px";
  109.                         if (cy) this.css.top = this.y+"px";
  110.                 }
  111.         }
  112.         return this.setLocation(x,y);
  113. };
  114. p.setHTML = function(html) {
  115.         if (html!=this.html) {
  116.                 this.html = html;
  117.                 if (this.css) {
  118.                         var elm = (this._blkBoardElm)? this._blkBoardElm:this.elm;
  119.                         elm.innerHTML = html;
  120.                 }
  121.         }
  122.         if(this._hasContentEvents) this.invokeEvent('contentchange');  
  123. };
  124. p.setTextSelectable=function(b) {
  125.         this._textSelectable = b;
  126.         if (this.elm) this.elm.onselectstart = b? dynapi.functions.Allow : dynapi.functions.Deny;
  127.         if (!b) this.setCursor('default');
  128.         // && this.captureMouseEvents && !this._hasMouseEvents) this.captureMouseEvents();
  129. };
  130. p.getCursor = function() {return this._cursor};
  131. p.setCursor = function(c) {
  132.         if (!c) c = 'default';
  133.         else c=(c+'').toLowerCase();
  134.         if (this._cursor!=c) {
  135.                 this._cursor = c;
  136.                 if (this.css) this.css.cursor = c;
  137.         }
  138. };
  139. p.getContentWidth=function() {
  140.         if (this.elm==null) return 0;
  141.         else {
  142.                 if (dynapi.ua.platform=="mac") return this.elm.offsetWidth;
  143.                 return parseInt(this.elm.scrollWidth);
  144.         };
  145. };
  146. p.getContentHeight=function() {
  147.         if (this.elm==null) return 0;
  148.         else {
  149.                 if (dynapi.ua.platform=="mac") return this.elm.offsetHeight;
  150.                 return parseInt(this.elm.scrollHeight);
  151.                
  152.         }
  153. };
  154.