jQuery(document).ready(function(){
varrightwin=jQuery("#right");
varwindowobj=jQuery(window);
varcwinWidth=rightwin.width();
varcwinHeight=rightwin.height();
varbrowserWidth=windowobj.width();
varbrowserHeight=windowobj.height();
varscrollLeft=windowobj.scrollLeft();
varscrollTop=windowobj.scrollTop();
rightwin.mywin({left:"right",top:"bottom"},
function(){
rightwin.hide(1000);
},{left:browserWidth-cwinWidth-5,top:browserHeight}
).fadeOut(30000).dequeue();
});
/*name:mywin插件
*参数position:窗口显示的最终位置{left:XX,top:XX}
*参数hidefunc:关闭时调用的函数
*参数initPos:窗口初位置{left:XX,top:XX}
*/
jQuery.fn.mywin=function(position,hidefunc,initPos){
if(position&&positioninstanceofObject){
varpositionleft=position.left;
varpositiontop=position.top;
varleft;
vartop;
varwindowobj=$(window);
varcurrentwin=this;
varcwinWidth=this.outerWidth(true);
varcwinHeight=this.outerHeight(true);
varbrowserWidth;//浏览器宽度
varbrowserHeight;//浏览器高度
varscrollLeft;//
varscrollTop;//
//计算浏览器可视区域位置
functiongetWinDin(){
browserWidth=windowobj.width();
browserHeight=windowobj.height();
scrollLeft=windowobj.scrollLeft();
scrollTop=windowobj.scrollTop();
}
//计算浏览器的左边距
functioncallLeft(positionleft,browserWidth,scrollLeft,cwinWidth){
if(positionleft&&typeofpositionleft=="string"){
if(positionleft=="center"){
left=(browserWidth-cwinWidth)/2;
}
elseif(positionleft=="left"){
left=0;
}
elseif(positionleft=="right"){
left=browserWidth-cwinWidth;
}
}
elseif(positionleft&&typeofpositionleft=="number"){
top=positionleft;
}else{
left=(browserWidth-cwinWidth)/2;
}
}
//计算浏览器的上边距
functioncallTop(positiontop,browserHeight,scrollTop,cwinHeight){
if(positiontop&&typeofpositiontop=="string"){
if(positiontop=="center"){
top=(browserHeight-cwinHeight)/2;
}
elseif(positiontop=="top"){
top=0
}
elseif(positiontop=="bottom"){
top=browserHeight-cwinHeight;
}
}
elseif(positiontop&&typeofpositiontop=="number"){
top=positiontop;
}else{
top=(browserHeight-cwinHeight)/2;
}
}
//移动窗口的位置
functionmovewin(){
callLeft(currentwin.data("positionleft"),browserWidth,scrollLeft,cwinWidth);
callTop(currentwin.data("positiontop"),browserHeight,scrollTop,cwinHeight);
currentwin.animate({
left:left-5,
top:top
},2000);
}
//拖动窗口滚动条后重新调整窗口的相对位置
varscrolltimeout;
$(window).scroll(function(){
if(!currentwin.is(":visible")){
return;
}
clearTimeout(scrolltimeout);
scrolltimeout=setTimeout(function
昵称:11 |
来自:121.28.92.* |
|
2016/12/19 10:53:10
|
去去去
|
|
|
|
昵称:匿名 |
来自:202.104.66.* |
|
2013/1/7 17:54:05
|
33
|
|
|
|
|