目前共有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許可協議進行許可。