Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / layout / FloatingPane.js

History | View | Annotate | Download (7.82 KB)

1 9 andrej.cim
/*
2
        Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3
        Available via Academic Free License >= 2.1 OR the modified BSD license.
4
        see: http://dojotoolkit.org/license for details
5
*/
6
7
8
if(!dojo._hasResource["dojox.layout.FloatingPane"]){
9
dojo._hasResource["dojox.layout.FloatingPane"]=true;
10
dojo.provide("dojox.layout.FloatingPane");
11
dojo.experimental("dojox.layout.FloatingPane");
12
dojo.require("dojo.window");
13
dojo.require("dijit._Templated");
14
dojo.require("dijit._Widget");
15
dojo.require("dojo.dnd.Moveable");
16
dojo.require("dojox.layout.ContentPane");
17
dojo.require("dojox.layout.ResizeHandle");
18
dojo.declare("dojox.layout.FloatingPane",[dojox.layout.ContentPane,dijit._Templated],{closable:true,dockable:true,resizable:false,maxable:false,resizeAxis:"xy",title:"",dockTo:"",duration:400,contentClass:"dojoxFloatingPaneContent",_showAnim:null,_hideAnim:null,_dockNode:null,_restoreState:{},_allFPs:[],_startZ:100,templateString:dojo.cache("dojox.layout","resources/FloatingPane.html","<div class=\"dojoxFloatingPane\" id=\"${id}\">\n\t<div tabindex=\"0\" waiRole=\"button\" class=\"dojoxFloatingPaneTitle\" dojoAttachPoint=\"focusNode\">\n\t\t<span dojoAttachPoint=\"closeNode\" dojoAttachEvent=\"onclick: close\" class=\"dojoxFloatingCloseIcon\"></span>\n\t\t<span dojoAttachPoint=\"maxNode\" dojoAttachEvent=\"onclick: maximize\" class=\"dojoxFloatingMaximizeIcon\">&thinsp;</span>\n\t\t<span dojoAttachPoint=\"restoreNode\" dojoAttachEvent=\"onclick: _restore\" class=\"dojoxFloatingRestoreIcon\">&thinsp;</span>\t\n\t\t<span dojoAttachPoint=\"dockNode\" dojoAttachEvent=\"onclick: minimize\" class=\"dojoxFloatingMinimizeIcon\">&thinsp;</span>\n\t\t<span dojoAttachPoint=\"titleNode\" class=\"dijitInline dijitTitleNode\"></span>\n\t</div>\n\t<div dojoAttachPoint=\"canvas\" class=\"dojoxFloatingPaneCanvas\">\n\t\t<div dojoAttachPoint=\"containerNode\" waiRole=\"region\" tabindex=\"-1\" class=\"${contentClass}\">\n\t\t</div>\n\t\t<span dojoAttachPoint=\"resizeHandle\" class=\"dojoxFloatingResizeHandle\"></span>\n\t</div>\n</div>\n"),attributeMap:dojo.delegate(dijit._Widget.prototype.attributeMap,{title:{type:"innerHTML",node:"titleNode"}}),postCreate:function(){
19
this.inherited(arguments);
20
new dojo.dnd.Moveable(this.domNode,{handle:this.focusNode});
21
if(!this.dockable){
22
this.dockNode.style.display="none";
23
}
24
if(!this.closable){
25
this.closeNode.style.display="none";
26
}
27
if(!this.maxable){
28
this.maxNode.style.display="none";
29
this.restoreNode.style.display="none";
30
}
31
if(!this.resizable){
32
this.resizeHandle.style.display="none";
33
}else{
34
this.domNode.style.width=dojo.marginBox(this.domNode).w+"px";
35
}
36
this._allFPs.push(this);
37
this.domNode.style.position="absolute";
38
this.bgIframe=new dijit.BackgroundIframe(this.domNode);
39
this._naturalState=dojo.coords(this.domNode);
40
},startup:function(){
41
if(this._started){
42
return;
43
}
44
this.inherited(arguments);
45
if(this.resizable){
46
if(dojo.isIE){
47
this.canvas.style.overflow="auto";
48
}else{
49
this.containerNode.style.overflow="auto";
50
}
51
this._resizeHandle=new dojox.layout.ResizeHandle({targetId:this.id,resizeAxis:this.resizeAxis},this.resizeHandle);
52
}
53
if(this.dockable){
54
var _1=this.dockTo;
55
if(this.dockTo){
56
this.dockTo=dijit.byId(this.dockTo);
57
}else{
58
this.dockTo=dijit.byId("dojoxGlobalFloatingDock");
59
}
60
if(!this.dockTo){
61
var _2,_3;
62
if(_1){
63
_2=_1;
64
_3=dojo.byId(_1);
65
}else{
66
_3=dojo.create("div",null,dojo.body());
67
dojo.addClass(_3,"dojoxFloatingDockDefault");
68
_2="dojoxGlobalFloatingDock";
69
}
70
this.dockTo=new dojox.layout.Dock({id:_2,autoPosition:"south"},_3);
71
this.dockTo.startup();
72
}
73
if((this.domNode.style.display=="none")||(this.domNode.style.visibility=="hidden")){
74
this.minimize();
75
}
76
}
77
this.connect(this.focusNode,"onmousedown","bringToTop");
78
this.connect(this.domNode,"onmousedown","bringToTop");
79
this.resize(dojo.coords(this.domNode));
80
this._started=true;
81
},setTitle:function(_4){
82
dojo.deprecated("pane.setTitle","Use pane.attr('title', someTitle)","2.0");
83
this.set("title",_4);
84
},close:function(){
85
if(!this.closable){
86
return;
87
}
88
dojo.unsubscribe(this._listener);
89
this.hide(dojo.hitch(this,function(){
90
this.destroyRecursive();
91
}));
92
},hide:function(_5){
93
dojo.fadeOut({node:this.domNode,duration:this.duration,onEnd:dojo.hitch(this,function(){
94
this.domNode.style.display="none";
95
this.domNode.style.visibility="hidden";
96
if(this.dockTo&&this.dockable){
97
this.dockTo._positionDock(null);
98
}
99
if(_5){
100
_5();
101
}
102
})}).play();
103
},show:function(_6){
104
var _7=dojo.fadeIn({node:this.domNode,duration:this.duration,beforeBegin:dojo.hitch(this,function(){
105
this.domNode.style.display="";
106
this.domNode.style.visibility="visible";
107
if(this.dockTo&&this.dockable){
108
this.dockTo._positionDock(null);
109
}
110
if(typeof _6=="function"){
111
_6();
112
}
113
this._isDocked=false;
114
if(this._dockNode){
115
this._dockNode.destroy();
116
this._dockNode=null;
117
}
118
})}).play();
119
this.resize(dojo.coords(this.domNode));
120
},minimize:function(){
121
if(!this._isDocked){
122
this.hide(dojo.hitch(this,"_dock"));
123
}
124
},maximize:function(){
125
if(this._maximized){
126
return;
127
}
128
this._naturalState=dojo.position(this.domNode);
129
if(this._isDocked){
130
this.show();
131
setTimeout(dojo.hitch(this,"maximize"),this.duration);
132
}
133
dojo.addClass(this.focusNode,"floatingPaneMaximized");
134
this.resize(dojo.window.getBox());
135
this._maximized=true;
136
},_restore:function(){
137
if(this._maximized){
138
this.resize(this._naturalState);
139
dojo.removeClass(this.focusNode,"floatingPaneMaximized");
140
this._maximized=false;
141
}
142
},_dock:function(){
143
if(!this._isDocked&&this.dockable){
144
this._dockNode=this.dockTo.addNode(this);
145
this._isDocked=true;
146
}
147
},resize:function(_8){
148
_8=_8||this._naturalState;
149
this._currentState=_8;
150
var _9=this.domNode.style;
151
if("t" in _8){
152
_9.top=_8.t+"px";
153
}
154
if("l" in _8){
155
_9.left=_8.l+"px";
156
}
157
_9.width=_8.w+"px";
158
_9.height=_8.h+"px";
159
var _a={l:0,t:0,w:_8.w,h:(_8.h-this.focusNode.offsetHeight)};
160
dojo.marginBox(this.canvas,_a);
161
this._checkIfSingleChild();
162
if(this._singleChild&&this._singleChild.resize){
163
this._singleChild.resize(_a);
164
}
165
},bringToTop:function(){
166
var _b=dojo.filter(this._allFPs,function(i){
167
return i!==this;
168
},this);
169
_b.sort(function(a,b){
170
return a.domNode.style.zIndex-b.domNode.style.zIndex;
171
});
172
_b.push(this);
173
dojo.forEach(_b,function(w,x){
174
w.domNode.style.zIndex=this._startZ+(x*2);
175
dojo.removeClass(w.domNode,"dojoxFloatingPaneFg");
176
},this);
177
dojo.addClass(this.domNode,"dojoxFloatingPaneFg");
178
},destroy:function(){
179
this._allFPs.splice(dojo.indexOf(this._allFPs,this),1);
180
if(this._resizeHandle){
181
this._resizeHandle.destroy();
182
}
183
this.inherited(arguments);
184
}});
185
dojo.declare("dojox.layout.Dock",[dijit._Widget,dijit._Templated],{templateString:"<div class=\"dojoxDock\"><ul dojoAttachPoint=\"containerNode\" class=\"dojoxDockList\"></ul></div>",_docked:[],_inPositioning:false,autoPosition:false,addNode:function(_c){
186
var _d=dojo.create("li",null,this.containerNode),_e=new dojox.layout._DockNode({title:_c.title,paneRef:_c},_d);
187
_e.startup();
188
return _e;
189
},startup:function(){
190
if(this.id=="dojoxGlobalFloatingDock"||this.isFixedDock){
191
this.connect(window,"onresize","_positionDock");
192
this.connect(window,"onscroll","_positionDock");
193
if(dojo.isIE){
194
this.connect(this.domNode,"onresize","_positionDock");
195
}
196
}
197
this._positionDock(null);
198
this.inherited(arguments);
199
},_positionDock:function(e){
200
if(!this._inPositioning){
201
if(this.autoPosition=="south"){
202
setTimeout(dojo.hitch(this,function(){
203
this._inPositiononing=true;
204
var _f=dojo.window.getBox();
205
var s=this.domNode.style;
206
s.left=_f.l+"px";
207
s.width=(_f.w-2)+"px";
208
s.top=(_f.h+_f.t)-this.domNode.offsetHeight+"px";
209
this._inPositioning=false;
210
}),125);
211
}
212
}
213
}});
214
dojo.declare("dojox.layout._DockNode",[dijit._Widget,dijit._Templated],{title:"",paneRef:null,templateString:"<li dojoAttachEvent=\"onclick: restore\" class=\"dojoxDockNode\">"+"<span dojoAttachPoint=\"restoreNode\" class=\"dojoxDockRestoreButton\" dojoAttachEvent=\"onclick: restore\"></span>"+"<span class=\"dojoxDockTitleNode\" dojoAttachPoint=\"titleNode\">${title}</span>"+"</li>",restore:function(){
215
this.paneRef.show();
216
this.paneRef.bringToTop();
217
if(!this.paneRef.isLoaded){
218
this.paneRef.refresh();
219
}
220
this.destroy();
221
}});
222
}