Rev 20 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 20 | Rev 13573 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* |
2 | DynAPI Distribution |
2 | DynAPI Distribution |
3 | DynLayer NS4 Specific Functions |
3 | DynLayer NS4 Specific Functions |
4 | 4 | ||
5 | The DynAPI Distribution is distributed under the terms of the GNU LGPL license. |
5 | The DynAPI Distribution is distributed under the terms of the GNU LGPL license. |
6 | |
6 | |
7 | requires: dynapi.api.DynLayerBase |
7 | requires: dynapi.api.DynLayerBase |
8 | */ |
8 | */ |
9 | 9 | ||
10 | p = DynLayer.prototype; |
10 | p = DynLayer.prototype; |
11 | p._ns4IPad = '<img src="'+dynapi.library.path+'ext/images/pixel.gif" width="0" height="0">'; // used with blackboard |
11 | p._ns4IPad = '<img src="'+dynapi.library.path+'ext/images/pixel.gif" width="0" height="0">'; // used with blackboard |
Line 54... | Line 54... | ||
54 | elm.document.close(); |
54 | elm.document.close(); |
55 | } |
55 | } |
56 | DynLayer._assignElement(this,elm); |
56 | DynLayer._assignElement(this,elm); |
57 | //if (this.updateLayout) this.updateLayout(); |
57 | //if (this.updateLayout) this.updateLayout(); |
58 | DynElement._flagCreate(this); |
58 | DynElement._flagCreate(this); |
59 | } |
59 | } |
60 | }; |
60 | }; |
61 | DynLayer._getLayerById = function(id,pElm){ |
61 | DynLayer._getLayerById = function(id,pElm){ |
62 | var i,lyrs,elm; |
62 | var i,lyrs,elm; |
63 | pElm = (pElm)? pElm:document; |
63 | pElm = (pElm)? pElm:document; |
64 | lyrs = pElm.layers; |
64 | lyrs = pElm.layers; |
Line 66... | Line 66... | ||
66 | elm=lyrs[i]; |
66 | elm=lyrs[i]; |
67 | if (elm.id==id) return elm; |
67 | if (elm.id==id) return elm; |
68 | else if (elm.layers.length){ |
68 | else if (elm.layers.length){ |
69 | elm = this._getLayerById(id,elm); |
69 | elm = this._getLayerById(id,elm); |
70 | if (elm) return elm; |
70 | if (elm) return elm; |
71 | } |
71 | } |
72 | } |
72 | } |
73 | }; |
73 | }; |
74 | DynLayer._assignElement = function(dlyr,elm) { |
74 | DynLayer._assignElement = function(dlyr,elm) { |
75 | if (!elm) { |
75 | if (!elm) { |
76 | elm = dlyr.parent.doc.layers[dlyr.id]; |
76 | elm = dlyr.parent.doc.layers[dlyr.id]; |
Line 93... | Line 93... | ||
93 | //var cw = (dlyr.w==null)? dlyr.getElmWidth() : null; |
93 | //var cw = (dlyr.w==null)? dlyr.getElmWidth() : null; |
94 | //var ch = (dlyr.h==null)? dlyr.getElmHeight() : null; |
94 | //var ch = (dlyr.h==null)? dlyr.getElmHeight() : null; |
95 | dlyr.setSize(cw,ch); |
95 | dlyr.setSize(cw,ch); |
96 | } |
96 | } |
97 | if (dlyr.bgImage!=null) dlyr.setBgImage(dlyr.bgImage); |
97 | if (dlyr.bgImage!=null) dlyr.setBgImage(dlyr.bgImage); |
98 | 98 | ||
99 | var i,ch=dlyr.children; |
99 | var i,ch=dlyr.children; |
100 | for (i=0;i<ch.length;i++) DynLayer._assignElement(ch[i],null); |
100 | for (i=0;i<ch.length;i++) DynLayer._assignElement(ch[i],null); |
101 | 101 | ||
102 | if (dlyr._hasMouseEvents) dlyr.captureMouseEvents(); |
102 | if (dlyr._hasMouseEvents) dlyr.captureMouseEvents(); |
103 | if (dlyr._hasKeyEvents) dlyr.captureKeyEvents(); |
103 | if (dlyr._hasKeyEvents) dlyr.captureKeyEvents(); |
104 | }; |
104 | }; |
Line 115... | Line 115... | ||
115 | ' left=',(this.x!=null? this.x : 0), |
115 | ' left=',(this.x!=null? this.x : 0), |
116 | ' top=',(this.y!=null? this.y : 0), |
116 | ' top=',(this.y!=null? this.y : 0), |
117 | ((this.visible)? ' visibility="inherit"':' visibility="hide"'), |
117 | ((this.visible)? ' visibility="inherit"':' visibility="hide"'), |
118 | ((this.w!=null)? ' width='+this.w:''), |
118 | ((this.w!=null)? ' width='+this.w:''), |
119 | ((this.h!=null)? ' height='+this.h:''), |
119 | ((this.h!=null)? ' height='+this.h:''), |
120 | ((this.z)? ' zindex='+this.z:''), |
120 | ((this.z)? ' zindex='+this.z:''), |
121 | ((this.bgColor!=null)? ' bgcolor="'+this.bgColor+'"':''), |
121 | ((this.bgColor!=null)? ' bgcolor="'+this.bgColor+'"':''), |
122 | ((this.bgImage!=null)? ' background="'+this.bgImage+'"':''), |
122 | ((this.bgImage!=null)? ' background="'+this.bgImage+'"':''), |
123 | clip,'>',this.getInnerHTML(),'</'+tag+'>' |
123 | clip,'>',this.getInnerHTML(),'</'+tag+'>' |
124 | ].join(''); |
124 | ].join(''); |
125 | } |
125 | } |
126 | }; |
126 | }; |
127 | p.getInnerHTML = function() { |
127 | p.getInnerHTML = function() { |
128 | var i,s = '',ch=this.children; |
128 | var i,s = '',ch=this.children; |
129 | if (this.html!=null) { |
129 | if (this.html!=null) { |
130 | if (this.w==null) s += '<nobr>'+this.html+'</nobr>'; |
130 | if (this.w==null) s += '<nobr>'+this.html+'</nobr>'; |
131 | else s+=this.html; |
131 | else s+=this.html; |
132 | } |
132 | } |
133 | if (this._blkBoardElm) s='<layer id="'+this.id+'blkboard">'+this._ns4IPad+s+'</layer>'; |
133 | if (this._blkBoardElm) s='<layer id="'+this.id+'blkboard">'+this._ns4IPad+s+'</layer>'; |
134 | if(ch.length<50) for (i=0;i<ch.length;i++) s+=ch[i].getOuterHTML(); |
134 | if(ch.length<50) for (i=0;i<ch.length;i++) s+=ch[i].getOuterHTML(); |
135 | else if(ch.length){ |
135 | else if(ch.length){ |
136 | var ar=['']; // speed improvement for layers with nested children |
136 | var ar=['']; // speed improvement for layers with nested children |
137 | for (i=0;i<ch.length;i++) ar[i]=ch[i].getOuterHTML(); |
137 | for (i=0;i<ch.length;i++) ar[i]=ch[i].getOuterHTML(); |
138 | s=s+ar.join(''); |
138 | s=s+ar.join(''); |
139 | } |
139 | } |
140 | return s; |
140 | return s; |
141 | }; |
141 | }; |
142 | p.enableBlackboard = function(){ |
142 | p.enableBlackboard = function(){ |
143 | if (!this._created) this._blkBoardElm=true; |
143 | if (!this._created) this._blkBoardElm=true; |
144 | else if(!this._blkBoardElm){ |
144 | else if(!this._blkBoardElm){ |
145 | var c,i,h='',elm = this.elm; |
145 | var c,i,h='',elm = this.elm; |
146 | if(this.html!=null) h=this.html; |
146 | if(this.html!=null) h=this.html; |
147 | var parentElement = this.parent.isClass('DynLayer')? this.parent.elm : this.parent.frame; |
147 | var parentElement = this.parent.isClass('DynLayer')? this.parent.elm : this.parent.frame; |
148 | var belm = this._blkBoardElm = new Layer(0, elm); |
148 | var belm = this._blkBoardElm = new Layer(0, elm); |
149 | this.doc = belm.document; |
149 | this.doc = belm.document; |
150 | this.doc.write(h); this.doc.close(); |
150 | this.doc.write(h); this.doc.close(); |
151 | belm.visibility = 'inherit'; |
151 | belm.visibility = 'inherit'; |
152 | for (i=0;i<this.children.length;i++){ |
152 | for (i=0;i<this.children.length;i++){ |
153 | c=this.children[i]; |
153 | c=this.children[i]; |
154 | c.css.zIndex=c.css.zIndex; // reset zindex |
154 | c.css.zIndex=c.css.zIndex; // reset zindex |
155 | } |
155 | } |
156 | } |
156 | } |
157 | }; |
157 | }; |
158 | p.setLocation = function(x,y) { |
158 | p.setLocation = function(x,y) { |
159 | var cx = (x!=null && x!=this.x); |
159 | var cx = (x!=null && x!=this.x); |
160 | var cy = (y!=null && y!=this.y); |
160 | var cy = (y!=null && y!=this.y); |
Line 163... | Line 163... | ||
163 | if (this.css!=null) { |
163 | if (this.css!=null) { |
164 | if (cx && cy) this.elm.moveTo(this.x, this.y); |
164 | if (cx && cy) this.elm.moveTo(this.x, this.y); |
165 | else if (cx) this.css.left = this.x; |
165 | else if (cx) this.css.left = this.x; |
166 | else if (cy) this.css.top = this.y; |
166 | else if (cy) this.css.top = this.y; |
167 | } |
167 | } |
168 | if(this._hasLocationEvents) this.invokeEvent('locationchange'); |
168 | if(this._hasLocationEvents) this.invokeEvent('locationchange'); |
169 | return (cx||cy); |
169 | return (cx||cy); |
170 | }; |
170 | }; |
171 | p.setPageLocation = function(x,y) { |
171 | p.setPageLocation = function(x,y) { |
172 | if (this.css) { |
172 | if (this.css) { |
173 | if (x!=null) { |
173 | if (x!=null) { |
Line 243... | Line 243... | ||
243 | // && this.captureMouseEvents && !this._hasMouseEvents) this.captureMouseEvents(); |
243 | // && this.captureMouseEvents && !this._hasMouseEvents) this.captureMouseEvents(); |
244 | }; |
244 | }; |
245 | p.getCursor = function() {return this._cursor}; |
245 | p.getCursor = function() {return this._cursor}; |
246 | p.setCursor = function(c) { |
246 | p.setCursor = function(c) { |
247 | if (!c) c = 'default'; |
247 | if (!c) c = 'default'; |
248 | if (this._cursor!=c) this._cursor = c; |
248 | if (this._cursor!=c) this._cursor = c; |
249 | // Note: not supported in ns4 |
249 | // Note: not supported in ns4 |
250 | }; |
250 | }; |
251 | p.setBgColor=function(c) { |
251 | p.setBgColor=function(c) { |
252 | this.bgColor = c; |
252 | this.bgColor = c; |
253 | if (this.css) this.elm.document.bgColor = c; |
253 | if (this.css) this.elm.document.bgColor = c; |