/* DynAPI Distribution DynLayer Base/Common Class The DynAPI Distribution is distributed under the terms of the GNU LGPL license. requires: dynapi.api.DynDocument */ var DynLayerBase = {}; // used by library function DynLayer(html,x,y,w,h,color,image) { this.DynElement = DynElement; this.DynElement(); if (html && typeof(html)=='object'){ // typeof more stable than constructor when creating layers from another frame var args=html; // dictionary input html=args.html; x = args.x; y = args.y; w = args.w; h = args.h; color = args.color; image = args.image; this.z = (args.zIndex||1); this._saveAnchor = args.anchor; this.visible = (args.visible==false)? false:true; this._textSelectable = (args.textSelectable==false)?false:true; if (args.id) this.setID(args.id,true); } else { this.visible = true; this.z = 1; this._saveAnchor = false; this._textSelectable = true; } this.x = x||0; this.y = y||0; this.w = w; this.h = h; this.bgColor = color; this.bgImage = image; this.html = (html!=null)? html+'':null; // convert html to string this.elm = null; this.doc = null; this.css = null; }; var p = dynapi.setPrototype('DynLayer','DynElement'); p._cssBorder = ''; p._fixBw = 0; p._fixBh = 0; p._adjustSize=function(){ var aw=this._aSzW; var ah=this._aSzH; if(this._created && (aw||ah)) { var i,c,w=0,h=0; // get furthest child for (i=0;i'+this.getInnerHTML()+''; else { var s,clip='',bgimage=' background-image:none;'; if(this.bgImage!=null) bgimage=' background-image:url('+this.bgImage+');'; if (this.clip) clip=' clip:rect('+this.clip[0]+'px '+this.clip[1]+'px '+this.clip[2]+'px '+this.clip[3]+'px);'; else if (this.w!=null && this.h!=null) clip=' clip:rect(0px '+(this.w+fixBw)+'px '+(this.h+fixBh)+'px 0px);'; // modify box fix values if (!dynapi.ua.ie && !dynapi.ua.opera) fixBw = 0; if (!dynapi.ua.ie) fixBh = 0; return [ '\n
', this.getInnerHTML(), '
' ].join(''); } }; p.getInnerHTML=function() { //! Overwritten by NS4 var s = ''; var i,ch=this.children; if (this.html!=null) s+=this.html; if (this._blkBoardElm) s=('
'+s+'
'); if(ch.length<50) for (i=0;ithis._maxW) w=this._maxW; if (this._maxH && h>this._maxH) h=this._maxH; } var cw = (w!=null && w!=this.w); var ch = (h!=null && h!=this.h); if (cw) this.w = w<0? 0 : w; if (ch) this.h = h<0? 0 : h; if (cw||ch) { if (this._hasAnchor) this.updateAnchor(); // update this anchor if (this._hasChildAnchors) this._updateAnchors(); // update child anchors if (this.css) { if (cw) this.css.width = this.w||0; if (ch) this.css.height = this.h||0; if (cw || ch) { if(this._needBoxFix) BorderManager.FixBoxModel(this,true); else this.css.clip = 'rect(0px '+(this.w||0)+'px '+(this.h||0)+'px 0px)'; // adjust parent size after being sized if(this.parent._aSz) this.parent._adjustSize(); } if (this.updateLayout) this.updateLayout(); // what's this? } } if(this._hasResizeEvents) this.invokeEvent('resize'); return (cw||ch); }; p.setMaximumSize = function(w,h){ this._maxW=w; this._maxH=h; this._useMaxSize=(w!=h!=null); w=(this.w>w)?w:this.w; h=(this.h>h)? h:this.h; this.setSize(this.w,this.h); }; p.setMinimumSize = function(w,h){ this._minW=w; this._minH=h; this._useMinSize=(w!=h!=null); this.setSize(this.w,this.h); }; p._position = 'absolute'; p._cssPosition = ' position:absolute'; p.setPosition = function(p){ if(p!='relative' && p!='fixed' && p!='absolute') p='absolute'; this._position=p; if (this.css) this.css.position=p; else this._cssPosition = ' position:'+p; }; p._overflow='hidden'; p._cssOverflow =' overflow:hidden;'; p.getOverflow = function(){return this._overflow}; p.setOverflow = function(s){ if(!s) s='default'; this._overflow=s; if(this.css) this.css.overflow=s; else this._cssOverflow=' overflow:'+s+';'; }; p.getAnchor = function(){ if(!this.parent) return this._saveAnchors; else if (this.parent._childAnchors) { return this.parent._childAnchors[this.id]; } }; p.setAnchor = function(anchor) { if (anchor == null) { delete this._saveAnchor; if (this.parent && this.parent._childAnchors && this.parent._childAnchors[this.id]) delete this.parent._childAnchors[this.id]; this._hasAnchor = false; } else if (this.parent) { if (!this.parent._childAnchors) this.parent._childAnchors = {}; var a = this.parent._childAnchors; a[this.id] = anchor; this.parent._updateAnchor(this.id); this._hasAnchor = this.parent._hasChildAnchors = true; } else this._saveAnchor = anchor; }; p.setX=function(x) {this.setLocation(x,null)}; p.setY=function(y) {this.setLocation(null,y)}; p.getX=function() {return this.x||0}; p.getY=function() {return this.y||0}; p.setPageX = function(x) {this.setPageLocation(x,null)}; p.setPageY = function(y) {this.setPageLocation(null,y)}; p.getVisible=function() {return this.visible}; p.getZIndex=function() {return this.z}; p.setZIndex=function(z) { if (typeof(z)=="object") { if (z.above) this.z = z.above.z + 1; else if (z.below) this.z = z.below.z - 1; else if (z.topmost && !this.parent) this.z = (DynLayer._z)? (DynLayer._z++):(DynLayer._z=1000); else if (z.topmost) { var topZ=10000,ch=this.parent.children; for(var i=0;itopZ) topZ=ch[i].z; this.parent._topZ = topZ+2; this.z = this.parent._topZ; } } else this.z = z; if (this.css) this.css.zIndex = this.z; }; p.getHTML = function() {return this.html}; p.setWidth=function(w) {this.setSize(w,null)}; p.setHeight=function(h) {this.setSize(null,h)}; p.getWidth=function() {return this.w||0}; p.getHeight=function() {return this.h||0}; p.getBgImage=function() {return this.bgImage}; p.getBgColor=function() {return this.bgColor}; p.setBgColor=function(c) { //! Overwritten by NS4 if (c==null) c = 'transparent'; this.bgColor = c; if (this.css) this.css.backgroundColor = c; }; p.setBgImage=function(path) { //! Overwritten by NS4 this.bgImage=path; if (this.css) this.css.backgroundImage='url('+path+')'; }; p.setClip=function(clip) { //! Overwritten by NS4 var cc=this.getClip(); for (var i=0;i-1) { c=c.split("rect(")[1].split(")")[0]; c=c.replace(/(\D+)/g,',').split(","); for (var i=0;i