?? ofileupload.lib.js
字號:
?/*
By Hangring
#2008.03.24#
---
use list:
> global.lib.js
> node.lib.js
> events.lib.js
> node.lib.js
> css.lib.js
---
自定義的文件上傳控件
*/
function oFileUpload () {
this.container = null;
this.fileUpload = null;
this.mouseMove = null;
this.mouseOver = null;
this.getOffset = null;
this.reset = null;
// 上傳框是否關(guān)閉
this.Closed = true;
}
oFileUpload.prototype.Init = function () {
};
oFileUpload.prototype.Create = function () {
var self = this;
var c = this.container;
var leaf = false;
if (c) leaf = true;
else c = this.container = oNode.CreateNode('div');
c.style.overflow = 'hidden';
var fu = this.fileUpload = oNode.CreateInput('file');
fu.type = 'file';
oNode.AddNode(fu, c);
fu.style.position = 'relative';
fu.style.visibility = 'hidden';
CSS.SetAlpha(fu, 0);
var W, H, w, h;
var oX, oY, ox, oy;
var _ox, _oy;
var reset = this.Reset = function () {
oX = oY = ox = oy = _ox = _oy = 0;
W = 0, H = 0;
fu.style.left = '0';
fu.style.top = '0';
this.getOffset();
};
var getOffset = this.getOffset = function () {
oX || (oX = Global.GetOffsetLeft(c));
oY || (oY = Global.GetOffsetTop(c));
ox || (ox = Global.GetOffsetLeft(fu));
oy || (oy = Global.GetOffsetTop(fu));
_ox || (_ox = ox - oX);
_oy || (_oy = oy - oY);
W || (W = c.offsetWidth);
H || (H = c.offsetHeight);
w || (w = fu.offsetWidth);
h || (h = fu.offsetHeight);
}
var mouseMove = this.mouseMove = function (e) {
var e_x = e.clientX + Global.GetScrollLeft();
var e_y = e.clientY + Global.GetScrollTop();
getOffset();
if (e_x < oX || e_x > oX + W || e_y < oY || e_y > oY + H) {
//fu.style.display = 'none';
return;
}
fu.style.display = '';
var x = e_x - ox;
var y = e_y - oy;
fu.style.top = y - (h / 2) + 'px';
fu.style.left = x - (w - 30) + 'px';
};
var mouseOver = this.mouseOver = function () {
fu.style.visibility = 'visible';
if (oX != Global.GetOffsetLeft(c) || oY != Global.GetOffsetTop(c)) {
oX = Global.GetOffsetLeft(c);
oY = Global.GetOffsetTop(c);
ox = oX + _ox;
oy = oY + _oy;
}
};
var mouseOut = this.mouseOut = function (e) {
fu.style.visibility = 'hidden';
var obj = $EO(e);
var p = false;
while (obj) {
if (obj == c) p = true;
obj = obj.parentNode;
}
p || self.Reset();
};
Events.AttachEvent(c, 'mousemove', mouseMove);
Events.AttachEvent(c, 'mouseover', mouseOver);
Events.AttachEvent(c, 'mouseout', mouseOut);
leaf && getOffset();
var mouseClick = this.mouseClick = function (e) {
self.Closed = false;
self.Click(e);
};
Events.AttachEvent(fu, 'click', mouseClick);
return c;
};
oFileUpload.prototype.Click = function (e) {};
oFileUpload.prototype.RemoveEvent = function () {
Events.RemoveEvent(this.container, 'mousemove', this.mouseMove);
Events.RemoveEvent(this.container, 'mouseover', this.mouseOver);
Events.RemoveEvent(this.container, 'mouseout', this.mouseOut);
Events.RemoveEvent(this.fileUpload, 'click', this.mouseClick);
};
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -