Subversion Repositories wimsdev

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
20 reyssat 1
/*
2
        DynAPI Distribution
3
        DynLayer Opera 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
// Warning: Avoid using document.all collection as it has been reported 
11
// that on some platforms when opera is set to an identity other than IE 
12
// the all[] collection is not available 
13
 
14
p = DynLayer.prototype;
15
p._create = function() {
16
        if (this.parent && !this.elm) {
17
                DynElement._flagPreCreate(this);
18
                var elm, parentElement;
19
                parentElement = this.parent.elm;
20
 
21
                // this method is more efficient for opera7+
22
                parentElement.insertAdjacentHTML("beforeEnd",this.getOuterHTML());
23
                elm = parentElement.children[parentElement.children.length-1];
24
 
25
                DynLayer._assignElement(this,elm);
26
                DynElement._flagCreate(this);
27
        }
28
};
29
DynLayer._assignElement = function(dlyr,elm,divs) {
30
        if (!elm ) {
31
                elm = (divs)? divs[dlyr.id] : dlyr.parent.doc.getElementById(dlyr.id);
32
                if (!elm) {dlyr._create();return}; // force create() for missing inline layer
33
        }
34
        dlyr.elm = elm;
35
        dlyr.css = elm.style;
36
        dlyr.doc = dlyr.parent.doc;
37
        dlyr.elm._dynobj = dlyr;
38
        dlyr._dyndoc = dlyr.parent._dyndoc;
39
        if(dlyr._blkBoardElm) dlyr._blkBoardElm = (divs)? divs[dlyr.id+'_blkboard'] : dlyr.parent.doc.getElementById(dlyr.id+'_blkboard');
40
 
41
        if (dlyr.html!=null && dlyr.html!='' && (dlyr.w==null || dlyr.h==null)) {
42
                var cw = (dlyr.w==null)? dlyr.getContentWidth() : null;
43
                var ch = (dlyr.h==null)? dlyr.getContentHeight() : null;
44
                //var cw = (dlyr.w==null)? dlyr.getElmWidth() : null;
45
                //var ch = (dlyr.h==null)? dlyr.getElmHeight() : null;
46
                dlyr.setSize(cw,ch);
47
        }
48
 
49
        var i,ch=dlyr.children;
50
        for (i=0;i<ch.length;i++) DynLayer._assignElement(ch[i],null,divs);
51
 
52
        if (this._textSelectable==false) elm.onselectstart = dynapi.functions.Disallow;
53
 
54
        if (dlyr._hasMouseEvents) dlyr.captureMouseEvents();
55
        if (dlyr._hasKeyEvents) dlyr.captureKeyEvents();
56
};
57
p.enableBlackboard = function(){
58
        if (!this._created) this._blkBoardElm=true;
59
        else if(!this._blkBoardElm){
60
                var h='',elm = this.elm;
61
                if(this.html!=null) h=this.html;
62
                elm.insertAdjacentHTML("beforeEnd",'<div id="'+this.id+'_blkboard">'+h+'</div>');
63
                this._blkBoardElm = elm.children[elm.children.length-1];
64
        }
65
};
66
p.setLocation=function(x,y) {
67
        var cx = (x!=null && x!=this.x);
68
        var cy = (y!=null && y!=this.y);
69
        if (cx) this.x = x||0;
70
        if (cy) this.y = y||0;
71
        if (this.css!=null) {
72
                if (cx) this.css.pixelLeft = this.x;
73
                if (cy) this.css.pixelTop = this.y;
74
        }
75
        if(this._hasLocationEvents) this.invokeEvent('locationchange');        
76
        return (cx||cy);
77
};
78
p.setPageLocation = function(x,y) {
79
        if (this.isChild) {
80
                if (dynapi.ua.v>=5) {
81
                        if (cx) this.css.pixelLeft = this.x;
82
                        if (cy) this.css.pixelTop = this.y;
83
                }
84
                else {
85
                        if (cx) this.css.left = this.x+"px";
86
                        if (cy) this.css.top = this.y+"px";
87
                }
88
        }
89
        return this.setLocation(x,y);
90
};
91
p.setHTML = function(html) {
92
        if (html!=this.html) {
93
                this.html = html;
94
                if (this.css) {
95
                        var elm = (this._blkBoardElm)? this._blkBoardElm:this.elm;
96
                        elm.innerHTML = html;
97
                }
98
        }
99
        if(this._hasContentEvents) this.invokeEvent('contentchange');
100
};
101
p.setTextSelectable=function(b) {
102
        this._textSelectable = b;
103
        if (this.elm) this.elm.onselectstart = b? dynapi.functions.Allow : dynapi.functions.Deny;
104
        if (!b) this.setCursor('default');
105
        // && this.captureMouseEvents && !this._hasMouseEvents) this.captureMouseEvents();
106
};
107
p.getCursor = function() {return this._cursor};
108
p.setCursor = function(c) {
109
        if (!c) c = 'default';
110
        else c=(c+'').toLowerCase();
111
        if (this._cursor!=c) {
112
                this._cursor = c;
113
                if (this.css) this.css.cursor = c;
114
        }              
115
};
116
p.getContentWidth=function() {
117
        if (this.elm==null) return 0;
118
        else {
119
                if (dynapi.ua.platform=="mac") return this.elm.offsetWidth;
120
                return parseInt(this.elm.scrollWidth);
121
        };
122
};
123
p.getContentHeight=function() {
124
        if (this.elm==null) return 0;
125
        else {
126
                if (dynapi.ua.platform=="mac") return this.elm.offsetHeight;
127
                return parseInt(this.elm.scrollHeight);
128
        }
129
};