⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 window.js

📁 jive论坛使得不时地好的不好的jive论坛使得不时地好的不好的
💻 JS
📖 第 1 页 / 共 4 页
字号:
if(this.useLeft)
w=this._updateWidthConstraint(w)
else
this.currentDrag.setStyle({right:(this.rightOrg-dx)+'px'});
if(this.useTop)
h=this._updateHeightConstraint(h)
else
this.currentDrag.setStyle({bottom:(this.bottomOrg-dy)+'px'});
this.setSize(w,h);
this._notify("onResize");}
else{
this.pointer=pointer;
if(this.useLeft){
var left=parseFloat(this.currentDrag.getStyle('left'))+dx;
var newLeft=this._updateLeftConstraint(left);
this.pointer[0]+=newLeft-left;
this.currentDrag.setStyle({left:newLeft+'px'});}
else
this.currentDrag.setStyle({right:parseFloat(this.currentDrag.getStyle('right'))-dx+'px'});
if(this.useTop){
var top=parseFloat(this.currentDrag.getStyle('top'))+dy;
var newTop=this._updateTopConstraint(top);
this.pointer[1]+=newTop-top;
this.currentDrag.setStyle({top:newTop+'px'});}
else
this.currentDrag.setStyle({bottom:parseFloat(this.currentDrag.getStyle('bottom'))-dy+'px'});
this._notify("onMove");}
if(this.iefix)
this._fixIEOverlapping();
this._removeStoreLocation();
Event.stop(event);},
_endDrag:function(event){
WindowUtilities.enableScreen('__invisible__');
if(this.doResize)
this._notify("onEndResize");
else
this._notify("onEndMove");
Event.stopObserving(document,"mouseup",this.eventMouseUp,false);
Event.stopObserving(document,"mousemove",this.eventMouseMove,false);
Event.stop(event);
this._hideWiredElement();
this._saveCookie()
document.body.ondrag=null;
document.body.onselectstart=null;},
_updateLeftConstraint:function(left){
if(this.constraint&&this.useLeft&&this.useTop){
var width=this.options.parent==document.body?WindowUtilities.getPageSize().windowWidth:this.options.parent.getDimensions().width;
if(left<this.constraintPad.left)
left=this.constraintPad.left;
if(left+this.width+this.widthE+this.widthW>width-this.constraintPad.right)
left=width-this.constraintPad.right-this.width-this.widthE-this.widthW;}
return left;},
_updateTopConstraint:function(top){
if(this.constraint&&this.useLeft&&this.useTop){
var height=this.options.parent==document.body?WindowUtilities.getPageSize().windowHeight:this.options.parent.getDimensions().height;
var h=this.height+this.heightN+this.heightS;
if(top<this.constraintPad.top)
top=this.constraintPad.top;
if(top+h>height-this.constraintPad.bottom)
top=height-this.constraintPad.bottom-h;}
return top;},
_updateWidthConstraint:function(w){
if(this.constraint&&this.useLeft&&this.useTop){
var width=this.options.parent==document.body?WindowUtilities.getPageSize().windowWidth:this.options.parent.getDimensions().width;
var left=parseFloat(this.element.getStyle("left"));
if(left+w+this.widthE+this.widthW>width-this.constraintPad.right)
w=width-this.constraintPad.right-left-this.widthE-this.widthW;}
return w;},
_updateHeightConstraint:function(h){
if(this.constraint&&this.useLeft&&this.useTop){
var height=this.options.parent==document.body?WindowUtilities.getPageSize().windowHeight:this.options.parent.getDimensions().height;
var top=parseFloat(this.element.getStyle("top"));
if(top+h+this.heightN+this.heightS>height-this.constraintPad.bottom)
h=height-this.constraintPad.bottom-top-this.heightN-this.heightS;}
return h;},
_createWindow:function(id){
var className=this.options.className;
var win=document.createElement("div");
win.setAttribute('id',id);
win.className="dialog";
var content;
if(this.options.url)
content="<iframe frameborder=\"0\" name=\"" + id + "_content\"  id=\"" + id + "_content\" src=\"" + this.options.url + "\"> </iframe>";
else
content="<div id=\"" + id + "_content\" class=\"" +className + "_content\"> </div>";
var closeDiv=this.options.closable?"<div class='"+className+"_close' id='"+id+"_close' onclick='Windows.close(\""+ id +"\", event)'> </div>":"";
var minDiv=this.options.minimizable?"<div class='"+className+"_minimize' id='"+id+"_minimize' onclick='Windows.minimize(\""+ id +"\", event)'> </div>":"";
var maxDiv=this.options.maximizable?"<div class='"+className+"_maximize' id='"+id+"_maximize' onclick='Windows.maximize(\""+ id +"\", event)'> </div>":"";
var seAttributes=this.options.resizable?"class='"+className+"_sizer' id='"+id+"_sizer'":"class='"+className+"_se'";
var blank="../themes/default/blank.gif";
win.innerHTML=closeDiv+minDiv+maxDiv+"\<table id='"+id +"_row1' class=\"top table_window\">\<tr>\<td class='"+className +"_nw'></td>\<td class='"+className +"_n'><div id='"+id +"_top' class='"+className +"_title title_window'>"+this.options.title +"</div></td>\<td class='"+className +"_ne'></td>\</tr>\</table>\<table id='"+id +"_row2' class=\"mid table_window\">\<tr>\<td class='"+className +"_w'></td>\<td id='"+id +"_table_content' class='"+className +"_content' valign='top'>" +content +"</td>\<td class='"+className +"_e'></td>\</tr>\</table>\<table id='"+id +"_row3' class=\"bot table_window\">\<tr>\<td class='"+className +"_sw'></td>\<td class='"+className +"_s'><div id='"+id +"_bottom' class='status_bar'><span style='float:left; width:1px; height:1px'></span></div></td>\<td " +seAttributes +"></td>\</tr>\</table>\
";
Element.hide(win);
this.options.parent.insertBefore(win,this.options.parent.firstChild);
Event.observe($(id+"_content"),"load",this.options.onload);
return win;},
changeClassName:function(newClassName){
var className=this.options.className;
var id=this.getId();
$A(["_close","_minimize","_maximize","_sizer","_content"]).each(function(value){this._toggleClassName($(id+value),className+value,newClassName+value)}.bind(this));
this._toggleClassName($(id+"_top"),className+"_title",newClassName+"_title");
$$("#"+id+" td").each(function(td){td.className=td.className.sub(className,newClassName);});
this.options.className=newClassName;},
_toggleClassName:function(element,oldClassName,newClassName){
if(element){
element.removeClassName(oldClassName);
element.addClassName(newClassName);}},
setLocation:function(top,left){
top=this._updateTopConstraint(top);
left=this._updateLeftConstraint(left);
var e=this.currentDrag||this.element;
e.setStyle({top:top+'px'});
e.setStyle({left:left+'px'});
this.useLeft=true;
this.useTop=true;},
getLocation:function(){
var location={};
if(this.useTop)
location=Object.extend(location,{top:this.element.getStyle("top")});
else
location=Object.extend(location,{bottom:this.element.getStyle("bottom")});
if(this.useLeft)
location=Object.extend(location,{left:this.element.getStyle("left")});
else
location=Object.extend(location,{right:this.element.getStyle("right")});
return location;},
getSize:function(){
return{width:this.width,height:this.height};},
setSize:function(width,height,useEffect){
width=parseFloat(width);
height=parseFloat(height);
if(!this.minimized&&width<this.options.minWidth)
width=this.options.minWidth;
if(!this.minimized&&height<this.options.minHeight)
height=this.options.minHeight;
if(this.options. maxHeight&&height>this.options. maxHeight)
height=this.options. maxHeight;
if(this.options. maxWidth&&width>this.options. maxWidth)
width=this.options. maxWidth;
if(this.useTop&&this.useLeft&&Window.hasEffectLib&&Effect.ResizeWindow&&useEffect){
new Effect.ResizeWindow(this,null,null,width,height,{duration:Window.resizeEffectDuration});}else{
this.width=width;
this.height=height;
var e=this.currentDrag?this.currentDrag:this.element;
e.setStyle({width:width+this.widthW+this.widthE+"px"})
e.setStyle({height:height+this.heightN+this.heightS+"px"})
if(!this.currentDrag||this.currentDrag==this.element){
var content=$(this.element.id+'_content');
content.setStyle({height:height+'px'});
content.setStyle({width:width+'px'});}}},
updateHeight:function(){
this.setSize(this.width,this.content.scrollHeight,true);},
updateWidth:function(){
this.setSize(this.content.scrollWidth,this.height,true);},
toFront:function(){
if(this.element.style.zIndex<Windows.maxZIndex)
this.setZIndex(Windows.maxZIndex+1);
if(this.iefix)
this._fixIEOverlapping();},
getBounds:function(insideOnly){
if(!this.width||!this.height||!this.visible)
this.computeBounds();
var w=this.width;
var h=this.height;
if(!insideOnly){
w+=this.widthW+this.widthE;
h+=this.heightN+this.heightS;}
var bounds=Object.extend(this.getLocation(),{width:w+"px",height:h+"px"});
return bounds;},
computeBounds:function(){
if(!this.width||!this.height){
var size=WindowUtilities._computeSize(this.content.innerHTML,this.content.id,this.width,this.height,0,this.options.className)
if(this.height)
this.width=size+5
else
this.height=size+5}
this.setSize(this.width,this.height);
if(this.centered)
this._center(this.centerTop,this.centerLeft);},
show:function(modal){
this.visible=true;
if(modal){
if(typeof this.overlayOpacity=="undefined"){
var that=this;
setTimeout(function(){that.show(modal)},10);
return;}
Windows.addModalWindow(this);
this.modal=true;
this.setZIndex(Windows.maxZIndex+1);
Windows.unsetOverflow(this);}
else
if(!this.element.style.zIndex)
this.setZIndex(Windows.maxZIndex+1);
if(this.oldStyle)
this.getContent().setStyle({overflow:this.oldStyle});
this.computeBounds();
this._notify("onBeforeShow");
if(this.options.showEffect!=Element.show&&this.options.showEffectOptions)
this.options.showEffect(this.element,this.options.showEffectOptions);
else
this.options.showEffect(this.element);
this._checkIEOverlapping();
WindowUtilities.focusedWindow=this
this._notify("onShow");},
showCenter:function(modal,top,left){
this.centered=true;
this.centerTop=top;
this.centerLeft=left;
this.show(modal);},
isVisible:function(){
return this.visible;},
_center:function(top,left){
var windowScroll=WindowUtilities.getWindowScroll(this.options.parent);
var pageSize=WindowUtilities.getPageSize(this.options.parent);
if(typeof top=="undefined")
top=(pageSize.windowHeight-(this.height+this.heightN+this.heightS))/2;
top+=windowScroll.top
if(typeof left=="undefined")
left=(pageSize.windowWidth-(this.width+this.widthW+this.widthE))/2;
left+=windowScroll.left
this.setLocation(top,left);
this.toFront();},
_recenter:function(event){
if(this.centered){
var pageSize=WindowUtilities.getPageSize(this.options.parent);
var windowScroll=WindowUtilities.getWindowScroll(this.options.parent);
if(this.pageSize&&this.pageSize.windowWidth==pageSize.windowWidth&&this.pageSize.windowHeight==pageSize.windowHeight&&
this.windowScroll.left==windowScroll.left&&this.windowScroll.top==windowScroll.top)
return;
this.pageSize=pageSize;
this.windowScroll=windowScroll;
if($('overlay_modal'))
$('overlay_modal').setStyle({height:(pageSize.pageHeight+'px')});
if(this.options.recenterAuto)
this._center(this.centerTop,this.centerLeft);}},
hide:function(){
this.visible=false;
if(this.modal){
Windows.removeModalWindow(this);
Windows.resetOverflow();}
this.oldStyle=this.getContent().getStyle('overflow')||"auto"
this.getContent().setStyle({overflow:"hidden"});
this.options.hideEffect(this.element,this.options.hideEffectOptions);
if(this.iefix)
this.iefix.hide();
if(!this.doNotNotifyHide)
this._notify("onHide");},
close:function(){
if(this.visible){
if(this.options.closeCallback&&!this.options.closeCallback(this))
return;
if(this.options.destroyOnClose){
var destroyFunc=this.destroy.bind(this);
if(this.options.hideEffectOptions.afterFinish){
var func=this.options.hideEffectOptions.afterFinish;
this.options.hideEffectOptions.afterFinish=function(){func();destroyFunc()}}
else
this.options.hideEffectOptions.afterFinish=function(){destroyFunc()}}
Windows.updateFocusedWindow();
this.doNotNotifyHide=true;
this.hide();
this.doNotNotifyHide=false;
this._notify("onClose");}},
minimize:function(){
if(this.resizing)
return;
var r2=$(this.getId()+"_row2");
if(!this.minimized){
this.minimized=true;
var dh=r2.getDimensions().height;
this.r2Height=dh;
var h=this.element.getHeight()-dh;
if(this.useLeft&&this.useTop&&Window.hasEffectLib&&Effect.ResizeWindow){
new Effect.ResizeWindow(this,null,null,null,this.height-dh,{duration:Window.resizeEffectDuration});}else{
this.height-=dh;
this.element.setStyle({height:h+"px"});
r2.hide();}
if(!this.useTop){
var bottom=parseFloat(this.element.getStyle('bottom'));
this.element.setStyle({bottom:(bottom+dh)+'px'});}}
else{
this.minimized=false;
var dh=this.r2Height;
this.r2Height=null;
if(this.useLeft&&this.useTop&&Window.hasEffectLib&&Effect.ResizeWindow){
new Effect.ResizeWindow(this,null,null,null,this.height+dh,{duration:Window.resizeEffectDuration});}
else{
var h=this.element.getHeight()+dh;
this.height+=dh;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -