目前共有2篇帖子。
[备份]目前window.js
1樓 巨大八爪鱼 2010-9-28 20:08

var window_isDragging=false;
var window_lastModalInfo_X;
var window_lastModalInfo_Y;
var window_moveModalInfo;
var window_close_image_url;
var window_opened=false;
var ojp;
if (top==self) var window_id=0;
else var window_id='[NULL]';

function createNodeW(a,b,c){
 return createNode(a+String(top.window_id),b,c);
}
function window_open(tit,url,wid,hei){
 /*
 ----------------------------------------------
   ● 窗口Div清单
 ----------------------------------------------
  1:背景层
  2:窗口阴影层
  3:窗口主框架
  4:窗口标题栏
  5:窗口内容区
  6:用于遮罩内容区的div
  7:关闭按钮
 ----------------------------------------------
 */
 top.window_id++;
 var sban=top.window_info();
 window_close_image_url=websiteaddress+"Images/System/dialogclose.gif"; //关闭按钮图片
 var bod=top.document.body;
 createNodeW('window_background','div',bod); //1
 createNodeW('window_behind','div',bod); //2
 createNodeW('window_frame','div',bod); //3
 var fra=$_DAMW('window_frame');
 var be=$_DAMW('window_behind');
 createNodeW('window_title','div',fra); //4
 createNodeW('window_content','div',fra); //5
 createNodeW('window_content_cover','div',bod); //6
 createNodeW('window_close_img','div',bod); //7
 var itl=$_DAMW('window_title');
 var cov=$_DAMW('window_content_cover');
 var wci=$_DAMW('window_close_img');
 createNodeW('window_close_image','img',wci);
 var wcide=$_DAMW('window_close_image');
 
 
 $_DAMW('window_background').className='window_background';
 fra.className='window_frame';
 itl.className='window_title';
 
 //禁止标题栏文字被选择
 itl.onselectstart=function(){return false;};
 itl.onselect=function(){document.selection.empty();};
 
 var dx=sban['ContentWidth'];
 var dy=sban['ContentHeight'];
 
 $_DAMW('window_background').style.width=dx+'px';
 $_DAMW('window_background').style.height=dy+'px';
 $_DAMW('window_content').innerHTML='<iframe id="window_iframes_for'+top.window_id+'" name="window_iframes_for'+top.window_id+'" src="'+url+'" width="100%" height="'+(hei-24)+'" frameborder="no" marginwidth="0" marginheight="0" border="0" style="background-color:#FFFFFF"></iframe>';
 ojp='window_iframes_for'+top.window_id;
 itl.innerHTML=tit;
 fra.style.width=wid+'px';
 fra.style.height=hei+'px';
 //计算窗口出现时的坐标
 var dce=top.document.documentElement,cw=sban['Width'],ch=sban['Height'];
 var x=cw/2,y=ch/2,xx=wid/2,yy=hei/2;
 x-=xx;
 y-=yy;
 if (y<0) y=0;
 if (x<0) x=0;
 
 var sl=sban['ScrollX'];
 var st=sban['ScrollY'];
 x+=sl;
 y+=st;
 
 fra.style.left=x+'px';
 fra.style.top=y+'px';
 window_lastModalInfo_X=x;
 window_lastModalInfo_Y=y;
 
 itl.onmousedown=function(event){window_move_start(event);return false;};
 window.onresize=function(){return top.window_background_repair();};
 
 cov.className='window_content_cover';
 cov.style.left=x+1+'px';
 cov.style.top=y+25+'px';
 cov.style.width=wid+'px';
 cov.style.height=hei-24+'px';
 cov.style.display='none';
 
 var xx=wid-22+x+'px',yy=y+5+'px';
 wci.className='window_close_img';
 wci.style.left=xx;
 wci.style.top=yy;
 var diu="Include/topic_alert.php?msg=";
 var diu=(url.substring(0,diu.length)!=diu);
 with (wcide){
  src=window_close_image_url;
  className='hand';
  if (diu) onclick=function(){return window_close();};
  title='关闭';
 }
 
 be.className='window_behind';
 be.style.width=wid+'px';
 be.style.height=hei+'px';
 be.style.left=x+6+'px';
 be.style.top=y+6+'px';
 
 window_opened=true;
 return true;
}
function window_move_start(event){
 //如果鼠标在标题栏上按下左键,则准备移动窗口
 if (!event) event=window.event;
 window_moveModalInfo=new Object();
 window_moveModalInfo.StartMouseX=event.pageX?event.pageX:event.screenX;
 window_moveModalInfo.StartMouseY=event.pageY?event.pageY:event.screenY;
 window_moveModalInfo.StartModalX=window_lastModalInfo_X;
 window_moveModalInfo.StartModalY=window_lastModalInfo_Y;
 window_moveModalInfo.Button=event.button;
 top.document.onmouseup=function(event){window_move_end(event);return false;};
 top.document.onmousemove=function(event){window_move(event);return false;};
 window_isDragging=true;
 var cov=$_DAMW('window_content_cover');
 cov.style.display='';
 return true;
}
function window_move(event){
 //处理窗口的移动
 if (!event) event=window.event;
 if (event.button!=window_moveModalInfo.Button||(!window_isDragging)){
  //若没有按下左键则中断
  window_move_end(event);
  return null;
 }
 var eventX=typeof(event.pageX)!='undefined'?event.pageX:event.screenX;
 var eventY=typeof(event.pageY)!='undefined'?event.pageY:event.screenY;
 var xChange=eventX-window_moveModalInfo.StartMouseX;
 var yChange=eventY-window_moveModalInfo.StartMouseY;
 xChange+=window_moveModalInfo.StartModalX;
 yChange+=window_moveModalInfo.StartModalY;
 window_changeposition(xChange,yChange);
 return true;
}
function window_move_end(event){
 //如果鼠标在文档任意位置释放了左键,则停止移动
 window_isDragging=false;
 window_moveModalInfo=null;
 top.document.onmouseup=null;
 top.document.onmousemove=null;
 var cov=$_DAMW('window_content_cover');
 cov.style.display='none';
 return true;
}
function window_changeposition(x,y){
 if (x<0) x=0;
 if (y<0) y=0;
 var lef=Number($_DAMW('window_background').style.width.replace('px','')); //背景宽度
 var rig=Number($_DAMW('window_background').style.height.replace('px','')); //背景高度
 var left=Number($_DAMW('window_frame').style.width.replace('px',''))+2;
 var righ=Number($_DAMW('window_frame').style.height.replace('px',''))+2;
 var xx=x+left; //窗口右上角点的x坐标
 var yy=y+righ; //窗口右下角点的y坐标
 if (xx+4>lef) x=lef-left-4;
 if (yy+4>rig) y=rig-righ-4;
 $_DAMW('window_frame').style.left=x+'px';
 $_DAMW('window_frame').style.top=y+'px';
 window_lastModalInfo_X=x;
 window_lastModalInfo_Y=y;
 var cov=$_DAMW('window_content_cover');
 cov.style.left=x+1+'px';
 cov.style.top=y+25+'px';
 $_DAMW('window_behind').style.left=x+6+'px';
 $_DAMW('window_behind').style.top=y+6+'px';
 $_DAMW('window_close_img').style.left=Number($_DAMW('window_frame').style.width.replace('px',''))-22+x+'px';
 $_DAMW('window_close_img').style.top=y+5+'px';
 return true;
}
function window_background_repair(){
 var sban=top.window_info();
 var dx=sban['ContentWidth'];
 var dy=sban['ContentHeight'];
 $_DAMW('window_background').style.width=dx;
 $_DAMW('window_background').style.height=dy;
 return true;
}
function window_close(num){
 if (isNaN(num) || num<1) num=1;
 if (num>window_id) num=window_id;
 var k;
 for (var i=0;i<num;i++){
  k=String(top.window_id);
  drapNode('window_background'+k+',window_content_cover'+k+',window_frame'+k+',window_close_img'+k+',window_behind'+k);
  window.onresize=null;
  window_opened=false;
  top.window_id--;
 }return true;
}

2樓 巨大八爪鱼 2010-9-28 20:11
幸好我在替换top.window.的时候多加了一个“.”,否则的话top.window_也会被替换掉!

回復帖子

  抱歉,本吧禁止發帖
內容:
用戶名: 您目前是匿名發表
 
 
©2010-2024 Arslanbar [手機版] [桌面版]
除非另有聲明,本站採用創用CC姓名標示-相同方式分享 3.0 Unported許可協議進行許可。