作者在 2009-11-19 09:39:05 发布以下内容
var ItemObj = undefined, scrollObj;
var PopupWin = function() {
this.TimeOp = "";
this.MoveSize = 0;
this.MoveSpeedMax = 40;
this.MoveSpeedMin = 5;
this.MoveSpeed = this.MoveSpeedMax;
this.MoveT = 37;
this.Pianyi = 5;
this.scrollSY = 0;
this.MoveTime = 100;
this.StartClose = 0;
this.CloseTimeRun = 3000;
this.PopObj = undefined;
this.MinButton = undefined;
this.MaxButton = undefined;
this.CloseButton = undefined;
this.MoveOp = "show"
}
PopupWin.prototype = {
init: function() {
this.create();
this.setDefault();
this.MoveSize = this.PopObj.clientHeight + this.Pianyi;
ItemObj = this;
this.TimeOp = setInterval("ItemObj.move()", this.MoveTime);
this.scrollPop()
},
move: function() {
var MoveMath = this.MoveOp == "show" ? this.ShowMoveSize(this.MoveSize) : this.MoveOp == "hide" ? this.HideMoveSize(this.MoveSize) : this.CloseMovesize();
if (MoveMath > 0) {
this.setPopTop(this.MoveStep((MoveMath - this.MoveSpeed) > 0 ? this.MoveSpeed: MoveMath))
} else {
clearInterval(this.TimeOp);
this.scrollSY = this.MoveOp == "show" ? this.PopObj.clientHeight + this.Pianyi: this.screenH - this.getPopTop();
this.MoveSpeed = this.MoveOp == "show" ? this.MoveSpeedMax: this.MoveSpeedMin;
if (this.MoveOp == "close") {
if (this.scrollSY <= 0) {
this.PopHide()
} ! this.StartClose ? (setTimeout("StartCloseRun()", this.CloseTimeRun), this.StartClose = 1, this.scrollSY = this.MoveT + this.Pianyi) : this.StartClose = 1
}
}
},
MoveStep: function(MX) {
return this.MoveOp == "show" ? this.getPopTop() - (MX) : this.getPopTop() + (MX)
},
ShowMoveSize: function(MX) {
return MX - (this.screenH() - this.getPopTop())
},
HideMoveSize: function(MX) {
return MX - (this.getPopTop() - (this.screenH() - this.PopObj.clientHeight + this.Pianyi))
},
CloseMoveSize: function() {
return this.screenH() - this.getPopTop()
},
ShowSetMove: function() {},
HidesetMove: function() {},
ClosesetMove: function() {},
PopShow: function() {
this.PopObj.style.display = "block"
},
PopHide: function() {
this.PopObj.style.display = "none"
},
setDefault: function() {
this.setPopTop(this.screenH());
this.PopShow()
},
setPopTop: function(Topsize) {
this.PopObj.style.top = Topsize + "px"
},
getPopTop: function() {
return parseInt(this.PopObj.style.top)
},
screenH: function() {
return document.documentElement.scrollTop + document.documentElement.clientHeight
},
setAbs: function() {
scrollObj.setPopTop(scrollObj.screenH() - scrollObj.scrollSY)
},
scrollPop: function() {
scrollObj = this;
if (window.attachEvent) {
window.attachEvent("onscroll", scrollObj.setAbs)
} else {
window.addEventListener("scroll", scrollObj.setAbs, false)
}
},
DomEvent: function() {},
create: function() {
this.PopObj = document.createElement("div");
this.PopObj = this.setAttr(this.PopObj, ["id", "style"], ["PopUp", "position:absolute; display:none; top:0px; right:0px; width:280px; height:300px; border:1px #000 solid;"]);
this.PopObj.innerHTML = '<a href="#" id="MinBtn" style=" position:absolute; top:12px; right:28px; width:0; overflow:hidden;background:url(images/pop_btn.gif) no-repeat;height:15px; padding-left:15px;" title="最小化">最小化</a><a href="#" style=" display:none; position:absolute; top:12px; right:28px; overflow:hidden;background:url(images/pop_btn.gif) no-repeat -15px 0;height:15px; width:0; padding-left:15px;" title="还原" id="MaxBtn">还原</a><a href="#" style=" position:absolute; top:12px; right:8px; overflow:hidden;background:url(images/pop_btn.gif) no-repeat -30px 0; width:0; height:15px; padding-left:15px;" id="CloseBtn" title="关闭">关闭</a><div class="popupc" id="PopFrm"></div>';
document.body.appendChild(this.PopObj);
this.MinButton = document.getElementById("MinBtn");
this.MaxButton = document.getElementById("MaxBtn");
this.CloseButton = document.getElementById("CloseBtn")
},
setAttr: function(Obj, Attr, Attrval) {
for (var i = 0; i < Attr.length; i++) {
if (Attr[i] != "style") {
if (Attr[i] == "class") {
Obj.setAttribute("className", Attrval[i]);
Obj.setAttribute("class", Attrval[i])
} else {
Obj.setAttribute(Attr[i], Attrval[i])
}
} else {
var oStyle = Obj.getAttribute("style");
if (oStyle == "[object]") {
oStyle.setAttribute("cssText", Attrval[i]);
Obj.setAttribute("style", oStyle)
} else {
Obj.setAttribute("style", Attrval[i])
}
}
}
return Obj
}
}
var PopupWin = function() {
this.TimeOp = "";
this.MoveSize = 0;
this.MoveSpeedMax = 40;
this.MoveSpeedMin = 5;
this.MoveSpeed = this.MoveSpeedMax;
this.MoveT = 37;
this.Pianyi = 5;
this.scrollSY = 0;
this.MoveTime = 100;
this.StartClose = 0;
this.CloseTimeRun = 3000;
this.PopObj = undefined;
this.MinButton = undefined;
this.MaxButton = undefined;
this.CloseButton = undefined;
this.MoveOp = "show"
}
PopupWin.prototype = {
init: function() {
this.create();
this.setDefault();
this.MoveSize = this.PopObj.clientHeight + this.Pianyi;
ItemObj = this;
this.TimeOp = setInterval("ItemObj.move()", this.MoveTime);
this.scrollPop()
},
move: function() {
var MoveMath = this.MoveOp == "show" ? this.ShowMoveSize(this.MoveSize) : this.MoveOp == "hide" ? this.HideMoveSize(this.MoveSize) : this.CloseMovesize();
if (MoveMath > 0) {
this.setPopTop(this.MoveStep((MoveMath - this.MoveSpeed) > 0 ? this.MoveSpeed: MoveMath))
} else {
clearInterval(this.TimeOp);
this.scrollSY = this.MoveOp == "show" ? this.PopObj.clientHeight + this.Pianyi: this.screenH - this.getPopTop();
this.MoveSpeed = this.MoveOp == "show" ? this.MoveSpeedMax: this.MoveSpeedMin;
if (this.MoveOp == "close") {
if (this.scrollSY <= 0) {
this.PopHide()
} ! this.StartClose ? (setTimeout("StartCloseRun()", this.CloseTimeRun), this.StartClose = 1, this.scrollSY = this.MoveT + this.Pianyi) : this.StartClose = 1
}
}
},
MoveStep: function(MX) {
return this.MoveOp == "show" ? this.getPopTop() - (MX) : this.getPopTop() + (MX)
},
ShowMoveSize: function(MX) {
return MX - (this.screenH() - this.getPopTop())
},
HideMoveSize: function(MX) {
return MX - (this.getPopTop() - (this.screenH() - this.PopObj.clientHeight + this.Pianyi))
},
CloseMoveSize: function() {
return this.screenH() - this.getPopTop()
},
ShowSetMove: function() {},
HidesetMove: function() {},
ClosesetMove: function() {},
PopShow: function() {
this.PopObj.style.display = "block"
},
PopHide: function() {
this.PopObj.style.display = "none"
},
setDefault: function() {
this.setPopTop(this.screenH());
this.PopShow()
},
setPopTop: function(Topsize) {
this.PopObj.style.top = Topsize + "px"
},
getPopTop: function() {
return parseInt(this.PopObj.style.top)
},
screenH: function() {
return document.documentElement.scrollTop + document.documentElement.clientHeight
},
setAbs: function() {
scrollObj.setPopTop(scrollObj.screenH() - scrollObj.scrollSY)
},
scrollPop: function() {
scrollObj = this;
if (window.attachEvent) {
window.attachEvent("onscroll", scrollObj.setAbs)
} else {
window.addEventListener("scroll", scrollObj.setAbs, false)
}
},
DomEvent: function() {},
create: function() {
this.PopObj = document.createElement("div");
this.PopObj = this.setAttr(this.PopObj, ["id", "style"], ["PopUp", "position:absolute; display:none; top:0px; right:0px; width:280px; height:300px; border:1px #000 solid;"]);
this.PopObj.innerHTML = '<a href="#" id="MinBtn" style=" position:absolute; top:12px; right:28px; width:0; overflow:hidden;background:url(images/pop_btn.gif) no-repeat;height:15px; padding-left:15px;" title="最小化">最小化</a><a href="#" style=" display:none; position:absolute; top:12px; right:28px; overflow:hidden;background:url(images/pop_btn.gif) no-repeat -15px 0;height:15px; width:0; padding-left:15px;" title="还原" id="MaxBtn">还原</a><a href="#" style=" position:absolute; top:12px; right:8px; overflow:hidden;background:url(images/pop_btn.gif) no-repeat -30px 0; width:0; height:15px; padding-left:15px;" id="CloseBtn" title="关闭">关闭</a><div class="popupc" id="PopFrm"></div>';
document.body.appendChild(this.PopObj);
this.MinButton = document.getElementById("MinBtn");
this.MaxButton = document.getElementById("MaxBtn");
this.CloseButton = document.getElementById("CloseBtn")
},
setAttr: function(Obj, Attr, Attrval) {
for (var i = 0; i < Attr.length; i++) {
if (Attr[i] != "style") {
if (Attr[i] == "class") {
Obj.setAttribute("className", Attrval[i]);
Obj.setAttribute("class", Attrval[i])
} else {
Obj.setAttribute(Attr[i], Attrval[i])
}
} else {
var oStyle = Obj.getAttribute("style");
if (oStyle == "[object]") {
oStyle.setAttribute("cssText", Attrval[i]);
Obj.setAttribute("style", oStyle)
} else {
Obj.setAttribute("style", Attrval[i])
}
}
}
return Obj
}
}