📄 window.js
字号:
this.element.setStyle({height:h+"px"})
r2.show();}
if(!this.useTop){
var bottom=parseFloat(this.element.getStyle('bottom'));
this.element.setStyle({bottom:(bottom-dh)+'px'});}
this.toFront();}
this._notify("onMinimize");
this._saveCookie()},
maximize:function(){
if(this.isMinimized()||this.resizing)
return;
if(Prototype.Browser.IE&&this.heightN==0)
this._getWindowBorderSize();
if(this.storedLocation!=null){
this._restoreLocation();
if(this.iefix)
this.iefix.hide();}
else{
this._storeLocation();
Windows.unsetOverflow(this);
var windowScroll=WindowUtilities.getWindowScroll(this.options.parent);
var pageSize=WindowUtilities.getPageSize(this.options.parent);
var left=windowScroll.left;
var top=windowScroll.top;
if(this.options.parent!=document.body){
windowScroll={top:0,left:0,bottom:0,right:0};
var dim=this.options.parent.getDimensions();
pageSize.windowWidth=dim.width;
pageSize.windowHeight=dim.height;
top=0;
left=0;}
if(this.constraint){
pageSize.windowWidth-=Math.max(0,this.constraintPad.left)+Math.max(0,this.constraintPad.right);
pageSize.windowHeight-=Math.max(0,this.constraintPad.top)+Math.max(0,this.constraintPad.bottom);
left+=Math.max(0,this.constraintPad.left);
top+=Math.max(0,this.constraintPad.top);}
var width=pageSize.windowWidth-this.widthW-this.widthE;
var height=pageSize.windowHeight-this.heightN-this.heightS;
if(this.useLeft&&this.useTop&&Window.hasEffectLib&&Effect.ResizeWindow){
new Effect.ResizeWindow(this,top,left,width,height,{duration:Window.resizeEffectDuration});}
else{
this.setSize(width,height);
this.element.setStyle(this.useLeft?{left:left}:{right:left});
this.element.setStyle(this.useTop?{top:top}:{bottom:top});}
this.toFront();
if(this.iefix)
this._fixIEOverlapping();}
this._notify("onMaximize");
this._saveCookie()},
isMinimized:function(){
return this.minimized;},
isMaximized:function(){
return(this.storedLocation!=null);},
setOpacity:function(opacity){
if(Element.setOpacity)
Element.setOpacity(this.element,opacity);},
setZIndex:function(zindex){
this.element.setStyle({zIndex:zindex});
Windows.updateZindex(zindex,this);},
setTitle:function(newTitle){
if(!newTitle||newTitle=="")
newTitle=" ";
Element.update(this.element.id+'_top',newTitle);},
getTitle:function(){
return $(this.element.id+'_top').innerHTML;},
setStatusBar:function(element){
var statusBar=$(this.getId()+"_bottom");
if(typeof(element)=="object"){
if(this.bottombar.firstChild)
this.bottombar.replaceChild(element,this.bottombar.firstChild);
else
this.bottombar.appendChild(element);}
else
this.bottombar.innerHTML=element;},
_checkIEOverlapping:function(){
if(!this.iefix&&(navigator.appVersion.indexOf('MSIE')>0)&&(navigator.userAgent.indexOf('Opera')<0)&&(this.element.getStyle('position')=='absolute')){
new Insertion.After(this.element.id,'<iframe id="'+this.element.id+'_iefix" '+'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" '+'src="javascript:false;" frameborder="0" scrolling="no"></iframe>');
this.iefix=$(this.element.id+'_iefix');}
if(this.iefix)
setTimeout(this._fixIEOverlapping.bind(this),50);},
_fixIEOverlapping:function(){
Position.clone(this.element,this.iefix);
this.iefix.style.zIndex=this.element.style.zIndex-1;
this.iefix.show();},
_getWindowBorderSize:function(event){
var div=this._createHiddenDiv(this.options.className+"_n")
this.heightN=Element.getDimensions(div).height;
div.parentNode.removeChild(div)
var div=this._createHiddenDiv(this.options.className+"_s")
this.heightS=Element.getDimensions(div).height;
div.parentNode.removeChild(div)
var div=this._createHiddenDiv(this.options.className+"_e")
this.widthE=Element.getDimensions(div).width;
div.parentNode.removeChild(div)
var div=this._createHiddenDiv(this.options.className+"_w")
this.widthW=Element.getDimensions(div).width;
div.parentNode.removeChild(div);
var div=document.createElement("div");
div.className="overlay_"+this.options.className;
document.body.appendChild(div);
var that=this;
setTimeout(function(){that.overlayOpacity=($(div).getStyle("opacity"));div.parentNode.removeChild(div);},10);
if(Prototype.Browser.IE){
this.heightS=$(this.getId()+"_row3").getDimensions().height;
this.heightN=$(this.getId()+"_row1").getDimensions().height;}
if(Prototype.Browser.WebKit&&Prototype.Browser.WebKitVersion<420)
this.setSize(this.width,this.height);
if(this.doMaximize)
this.maximize();
if(this.doMinimize)
this.minimize();},
_createHiddenDiv:function(className){
var objBody=document.body;
var win=document.createElement("div");
win.setAttribute('id',this.element.id+"_tmp");
win.className=className;
win.style.display='none';
win.innerHTML='';
objBody.insertBefore(win,objBody.firstChild);
return win;},
_storeLocation:function(){
if(this.storedLocation==null){
this.storedLocation={useTop:this.useTop,useLeft:this.useLeft,
top:this.element.getStyle('top'),bottom:this.element.getStyle('bottom'),
left:this.element.getStyle('left'),right:this.element.getStyle('right'),
width:this.width,height:this.height};}},
_restoreLocation:function(){
if(this.storedLocation!=null){
this.useLeft=this.storedLocation.useLeft;
this.useTop=this.storedLocation.useTop;
if(this.useLeft&&this.useTop&&Window.hasEffectLib&&Effect.ResizeWindow)
new Effect.ResizeWindow(this,this.storedLocation.top,this.storedLocation.left,this.storedLocation.width,this.storedLocation.height,{duration:Window.resizeEffectDuration});
else{
this.element.setStyle(this.useLeft?{left:this.storedLocation.left}:{right:this.storedLocation.right});
this.element.setStyle(this.useTop?{top:this.storedLocation.top}:{bottom:this.storedLocation.bottom});
this.setSize(this.storedLocation.width,this.storedLocation.height);}
Windows.resetOverflow();
this._removeStoreLocation();}},
_removeStoreLocation:function(){
this.storedLocation=null;},
_saveCookie:function(){
if(this.cookie){
var value="";
if(this.useLeft)
value+="l:"+(this.storedLocation?this.storedLocation.left:this.element.getStyle('left'))
else
value+="r:"+(this.storedLocation?this.storedLocation.right:this.element.getStyle('right'))
if(this.useTop)
value+=",t:"+(this.storedLocation?this.storedLocation.top:this.element.getStyle('top'))
else
value+=",b:"+(this.storedLocation?this.storedLocation.bottom:this.element.getStyle('bottom'))
value+=","+(this.storedLocation?this.storedLocation.width:this.width);
value+=","+(this.storedLocation?this.storedLocation.height:this.height);
value+=","+this.isMinimized();
value+=","+this.isMaximized();
WindowUtilities.setCookie(value,this.cookie)}},
_createWiredElement:function(){
if(!this.wiredElement){
if(Prototype.Browser.IE)
this._getWindowBorderSize();
var div=document.createElement("div");
div.className="wired_frame "+this.options.className+"_wired_frame";
div.style.position='absolute';
this.options.parent.insertBefore(div,this.options.parent.firstChild);
this.wiredElement=$(div);}
if(this.useLeft)
this.wiredElement.setStyle({left:this.element.getStyle('left')});
else
this.wiredElement.setStyle({right:this.element.getStyle('right')});
if(this.useTop)
this.wiredElement.setStyle({top:this.element.getStyle('top')});
else
this.wiredElement.setStyle({bottom:this.element.getStyle('bottom')});
var dim=this.element.getDimensions();
this.wiredElement.setStyle({width:dim.width+"px",height:dim.height+"px"});
this.wiredElement.setStyle({zIndex:Windows.maxZIndex+30});
return this.wiredElement;},
_hideWiredElement:function(){
if(!this.wiredElement||!this.currentDrag)
return;
if(this.currentDrag==this.element)
this.currentDrag=null;
else{
if(this.useLeft)
this.element.setStyle({left:this.currentDrag.getStyle('left')});
else
this.element.setStyle({right:this.currentDrag.getStyle('right')});
if(this.useTop)
this.element.setStyle({top:this.currentDrag.getStyle('top')});
else
this.element.setStyle({bottom:this.currentDrag.getStyle('bottom')});
this.currentDrag.hide();
this.currentDrag=null;
if(this.doResize)
this.setSize(this.width,this.height);}},
_notify:function(eventName){
if(this.options[eventName])
this.options[eventName](this);
else
Windows.notify(eventName,this);}};
var Windows={
windows:[],
modalWindows:[],
observers:[],
focusedWindow:null,
maxZIndex:0,
overlayShowEffectOptions:{duration:0.5},
overlayHideEffectOptions:{duration:0.5},
addObserver:function(observer){
this.removeObserver(observer);
this.observers.push(observer);},
removeObserver:function(observer){
this.observers=this.observers.reject(function(o){return o==observer});},
notify:function(eventName,win){
this.observers.each(function(o){if(o[eventName])o[eventName](eventName,win);});},
getWindow:function(id){
return this.windows.detect(function(d){return d.getId()==id});},
getFocusedWindow:function(){
return this.focusedWindow;},
updateFocusedWindow:function(){
this.focusedWindow=this.windows.length>=2?this.windows[this.windows.length-2]:null;},
register:function(win){
this.windows.push(win);},
addModalWindow:function(win){
if(this.modalWindows.length==0){
WindowUtilities.disableScreen(win.options.className,'overlay_modal',win.overlayOpacity,win.getId(),win.options.parent);}
else{
if(Window.keepMultiModalWindow){
$('overlay_modal').style.zIndex=Windows.maxZIndex+1;
Windows.maxZIndex+=1;
WindowUtilities._hideSelect(this.modalWindows.last().getId());}
else
this.modalWindows.last().element.hide();
WindowUtilities._showSelect(win.getId());}
this.modalWindows.push(win);},
removeModalWindow:function(win){
this.modalWindows.pop();
if(this.modalWindows.length==0)
WindowUtilities.enableScreen();
else{
if(Window.keepMultiModalWindow){
this.modalWindows.last().toFront();
WindowUtilities._showSelect(this.modalWindows.last().getId());}
else
this.modalWindows.last().element.show();}},
register:function(win){
this.windows.push(win);},
unregister:function(win){
this.windows=this.windows.reject(function(d){return d==win});},
closeAll:function(){
this.windows.each(function(w){Windows.close(w.getId())});},
closeAllModalWindows:function(){
WindowUtilities.enableScreen();
this.modalWindows.each(function(win){if(win)win.close()});},
minimize:function(id,event){
var win=this.getWindow(id)
if(win&&win.visible)
win.minimize();
Event.stop(event);},
maximize:function(id,event){
var win=this.getWindow(id)
if(win&&win.visible)
win.maximize();
Event.stop(event);},
close:function(id,event){
var win=this.getWindow(id);
if(win)
win.close();
if(event)
Event.stop(event);},
blur:function(id){
var win=this.getWindow(id);
if(!win)
return;
if(win.options.blurClassName)
win.changeClassName(win.options.blurClassName);
if(this.focusedWindow==win)
this.focusedWindow=null;
win._notify("onBlur");},
focus:function(id){
var win=this.getWindow(id);
if(!win)
return;
if(this.focusedWindow)
this.blur(this.focusedWindow.getId())
if(win.options.focusClassName)
win.changeClassName(win.options.focusClassName);
this.focusedWindow=win;
win._notify("onFocus");},
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -