root / trunk / web / dojo / dijit / _editor / plugins / FullScreen.js
History | View | Annotate | Download (6.94 KB)
1 |
/*
|
---|---|
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["dijit._editor.plugins.FullScreen"]){ |
9 |
dojo._hasResource["dijit._editor.plugins.FullScreen"]=true; |
10 |
dojo.provide("dijit._editor.plugins.FullScreen");
|
11 |
dojo.require("dojo.window");
|
12 |
dojo.require("dojo.i18n");
|
13 |
dojo.require("dijit._editor._Plugin");
|
14 |
dojo.require("dijit.form.Button");
|
15 |
dojo.requireLocalization("dijit._editor","commands",null,"ROOT,ar,ca,cs,da,de,el,es,fi,fr,he,hu,it,ja,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-tw"); |
16 |
dojo.declare("dijit._editor.plugins.FullScreen",dijit._editor._Plugin,{zIndex:500,_origState:null,_origiFrameState:null,_resizeHandle:null,isFullscreen:false,toggle:function(){ |
17 |
this.button.set("checked",!this.button.get("checked")); |
18 |
},_initButton:function(){ |
19 |
var _1=dojo.i18n.getLocalization("dijit._editor","commands"),_2=this.editor; |
20 |
this.button=new dijit.form.ToggleButton({label:_1["fullScreen"],dir:_2.dir,lang:_2.lang,showLabel:false,iconClass:this.iconClassPrefix+" "+this.iconClassPrefix+"FullScreen",tabIndex:"-1",onChange:dojo.hitch(this,"_setFullScreen")}); |
21 |
},setEditor:function(_3){ |
22 |
this.editor=_3;
|
23 |
this._initButton();
|
24 |
this.editor.addKeyHandler(dojo.keys.F11,true,true,dojo.hitch(this,function(e){ |
25 |
this.toggle();
|
26 |
dojo.stopEvent(e); |
27 |
setTimeout(dojo.hitch(this,function(){ |
28 |
this.editor.focus();
|
29 |
}),250);
|
30 |
return true; |
31 |
})); |
32 |
this.connect(this.editor.domNode,"onkeydown","_containFocus"); |
33 |
},_containFocus:function(e){ |
34 |
if(this.isFullscreen){ |
35 |
var ed=this.editor; |
36 |
if(!ed.isTabIndent&&ed._fullscreen_oldOnKeyDown&&e.keyCode===dojo.keys.TAB){
|
37 |
var f=dijit.getFocus();
|
38 |
var _4=this._getAltViewNode(); |
39 |
if(f.node==ed.iframe||(_4&&f.node===_4)){
|
40 |
setTimeout(dojo.hitch(this,function(){ |
41 |
ed.toolbar.focus(); |
42 |
}),10);
|
43 |
}else{
|
44 |
if(_4&&dojo.style(ed.iframe,"display")==="none"){ |
45 |
setTimeout(dojo.hitch(this,function(){ |
46 |
dijit.focus(_4); |
47 |
}),10);
|
48 |
}else{
|
49 |
setTimeout(dojo.hitch(this,function(){ |
50 |
ed.focus(); |
51 |
}),10);
|
52 |
} |
53 |
} |
54 |
dojo.stopEvent(e); |
55 |
}else{
|
56 |
if(ed._fullscreen_oldOnKeyDown){
|
57 |
ed._fullscreen_oldOnKeyDown(e); |
58 |
} |
59 |
} |
60 |
} |
61 |
},_resizeEditor:function(){ |
62 |
var vp=dojo.window.getBox();
|
63 |
dojo.marginBox(this.editor.domNode,{w:vp.w,h:vp.h}); |
64 |
var _5=this.editor.getHeaderHeight(); |
65 |
var _6=this.editor.getFooterHeight(); |
66 |
var _7=dojo._getPadBorderExtents(this.editor.domNode); |
67 |
var _8=dojo._getPadBorderExtents(this.editor.iframe.parentNode); |
68 |
var _9=dojo._getMarginExtents(this.editor.iframe.parentNode); |
69 |
var _a=vp.h-(_5+_7.h+_6);
|
70 |
dojo.marginBox(this.editor.iframe.parentNode,{h:_a,w:vp.w}); |
71 |
dojo.marginBox(this.editor.iframe,{h:_a-(_8.h+_9.h)}); |
72 |
},_getAltViewNode:function(){ |
73 |
},_setFullScreen:function(_b){ |
74 |
var vp=dojo.window.getBox();
|
75 |
var ed=this.editor; |
76 |
var _c=dojo.body();
|
77 |
var _d=ed.domNode.parentNode;
|
78 |
this.isFullscreen=_b;
|
79 |
if(_b){
|
80 |
while(_d&&_d!==dojo.body()){
|
81 |
dojo.addClass(_d,"dijitForceStatic");
|
82 |
_d=_d.parentNode; |
83 |
} |
84 |
this._editorResizeHolder=this.editor.resize; |
85 |
ed.resize=function(){ |
86 |
}; |
87 |
ed._fullscreen_oldOnKeyDown=ed.onKeyDown; |
88 |
ed.onKeyDown=dojo.hitch(this,this._containFocus); |
89 |
this._origState={};
|
90 |
this._origiFrameState={};
|
91 |
var _e=ed.domNode,_f=_e&&_e.style||{};
|
92 |
this._origState={width:_f.width||"",height:_f.height||"",top:dojo.style(_e,"top")||"",left:dojo.style(_e,"left")||"",position:dojo.style(_e,"position")||"static",marginBox:dojo.marginBox(ed.domNode)}; |
93 |
var _10=ed.iframe,_11=_10&&_10.style||{};
|
94 |
var bc=dojo.style(ed.iframe,"backgroundColor"); |
95 |
this._origiFrameState={backgroundColor:bc||"transparent",width:_11.width||"auto",height:_11.height||"auto",zIndex:_11.zIndex||""}; |
96 |
dojo.style(ed.domNode,{position:"absolute",top:"0px",left:"0px",zIndex:this.zIndex,width:vp.w+"px",height:vp.h+"px"}); |
97 |
dojo.style(ed.iframe,{height:"100%",width:"100%",zIndex:this.zIndex,backgroundColor:bc!=="transparent"&&bc!=="rgba(0, 0, 0, 0)"?bc:"white"}); |
98 |
dojo.style(ed.iframe.parentNode,{height:"95%",width:"100%"}); |
99 |
if(_c.style&&_c.style.overflow){
|
100 |
this._oldOverflow=dojo.style(_c,"overflow"); |
101 |
}else{
|
102 |
this._oldOverflow=""; |
103 |
} |
104 |
if(dojo.isIE&&!dojo.isQuirks){
|
105 |
if(_c.parentNode&&_c.parentNode.style&&_c.parentNode.style.overflow){
|
106 |
this._oldBodyParentOverflow=_c.parentNode.style.overflow;
|
107 |
}else{
|
108 |
try{
|
109 |
this._oldBodyParentOverflow=dojo.style(_c.parentNode,"overflow"); |
110 |
} |
111 |
catch(e){
|
112 |
this._oldBodyParentOverflow="scroll"; |
113 |
} |
114 |
} |
115 |
dojo.style(_c.parentNode,"overflow","hidden"); |
116 |
} |
117 |
dojo.style(_c,"overflow","hidden"); |
118 |
var _12=function(){ |
119 |
var vp=dojo.window.getBox();
|
120 |
if("_prevW" in this&&"_prevH" in this){ |
121 |
if(vp.w===this._prevW&&vp.h===this._prevH){ |
122 |
return;
|
123 |
} |
124 |
}else{
|
125 |
this._prevW=vp.w;
|
126 |
this._prevH=vp.h;
|
127 |
} |
128 |
if(this._resizer){ |
129 |
clearTimeout(this._resizer);
|
130 |
delete this._resizer; |
131 |
} |
132 |
this._resizer=setTimeout(dojo.hitch(this,function(){ |
133 |
delete this._resizer; |
134 |
this._resizeEditor();
|
135 |
}),10);
|
136 |
}; |
137 |
this._resizeHandle=dojo.connect(window,"onresize",this,_12); |
138 |
this._resizeHandle2=dojo.connect(ed,"resize",dojo.hitch(this,function(){ |
139 |
if(this._resizer){ |
140 |
clearTimeout(this._resizer);
|
141 |
delete this._resizer; |
142 |
} |
143 |
this._resizer=setTimeout(dojo.hitch(this,function(){ |
144 |
delete this._resizer; |
145 |
this._resizeEditor();
|
146 |
}),10);
|
147 |
})); |
148 |
this._resizeEditor();
|
149 |
var dn=this.editor.toolbar.domNode; |
150 |
setTimeout(function(){
|
151 |
dojo.window.scrollIntoView(dn); |
152 |
},250);
|
153 |
}else{
|
154 |
if(this._resizeHandle){ |
155 |
dojo.disconnect(this._resizeHandle);
|
156 |
this._resizeHandle=null; |
157 |
} |
158 |
if(this._resizeHandle2){ |
159 |
dojo.disconnect(this._resizeHandle2);
|
160 |
this._resizeHandle2=null; |
161 |
} |
162 |
if(this._rst){ |
163 |
clearTimeout(this._rst);
|
164 |
this._rst=null; |
165 |
} |
166 |
while(_d&&_d!==dojo.body()){
|
167 |
dojo.removeClass(_d,"dijitForceStatic");
|
168 |
_d=_d.parentNode; |
169 |
} |
170 |
if(this._editorResizeHolder){ |
171 |
this.editor.resize=this._editorResizeHolder; |
172 |
} |
173 |
if(!this._origState&&!this._origiFrameState){ |
174 |
return;
|
175 |
} |
176 |
if(ed._fullscreen_oldOnKeyDown){
|
177 |
ed.onKeyDown=ed._fullscreen_oldOnKeyDown; |
178 |
delete ed._fullscreen_oldOnKeyDown;
|
179 |
} |
180 |
var _13=this; |
181 |
setTimeout(function(){
|
182 |
var mb=_13._origState.marginBox;
|
183 |
var oh=_13._origState.height;
|
184 |
if(dojo.isIE&&!dojo.isQuirks){
|
185 |
_c.parentNode.style.overflow=_13._oldBodyParentOverflow; |
186 |
delete _13._oldBodyParentOverflow;
|
187 |
} |
188 |
dojo.style(_c,"overflow",_13._oldOverflow);
|
189 |
delete _13._oldOverflow;
|
190 |
dojo.style(ed.domNode,_13._origState); |
191 |
dojo.style(ed.iframe.parentNode,{height:"",width:""}); |
192 |
dojo.style(ed.iframe,_13._origiFrameState); |
193 |
delete _13._origState;
|
194 |
delete _13._origiFrameState;
|
195 |
var _14=dijit.getEnclosingWidget(ed.domNode.parentNode);
|
196 |
if(_14&&_14.resize){
|
197 |
_14.resize(); |
198 |
}else{
|
199 |
if(!oh||oh.indexOf("%")<0){ |
200 |
setTimeout(dojo.hitch(this,function(){ |
201 |
ed.resize({h:mb.h});
|
202 |
}),0);
|
203 |
} |
204 |
} |
205 |
dojo.window.scrollIntoView(_13.editor.toolbar.domNode); |
206 |
},100);
|
207 |
} |
208 |
},destroy:function(){ |
209 |
if(this._resizeHandle){ |
210 |
dojo.disconnect(this._resizeHandle);
|
211 |
this._resizeHandle=null; |
212 |
} |
213 |
if(this._resizeHandle2){ |
214 |
dojo.disconnect(this._resizeHandle2);
|
215 |
this._resizeHandle2=null; |
216 |
} |
217 |
if(this._resizer){ |
218 |
clearTimeout(this._resizer);
|
219 |
this._resizer=null; |
220 |
} |
221 |
this.inherited(arguments); |
222 |
}}); |
223 |
dojo.subscribe(dijit._scopeName+".Editor.getPlugin",null,function(o){ |
224 |
if(o.plugin){
|
225 |
return;
|
226 |
} |
227 |
var _15=o.args.name.toLowerCase();
|
228 |
if(_15==="fullscreen"){ |
229 |
o.plugin=new dijit._editor.plugins.FullScreen({zIndex:("zIndex" in o.args)?o.args.zIndex:500}); |
230 |
} |
231 |
}); |
232 |
} |