2条回答 默认 最新
- qq_30471551 2016-08-24 13:10关注
if (!Array.prototype.push) {
';
Array.prototype.push = function() {
var startLength = this.length;
for (var j = 0; j < arguments.length; j++) {
this[startLength + j] = arguments[j];
}
return this.length;
}
};
function G() {
var elements = new Array();
for (var i = 0; i < arguments.length; i++) {
var element = arguments[i];
if (typeof element == 'string') element = document.getElementById(element);
if (arguments.length == 1) return element;
elements.push(element)
};
return elements
};
function getValue(str) {
var nResult = 0;
switch (str) {
case "scrollTop":
if (typeof(window.pageYOffset) != 'undefined') {
nResult = window.pageYOffset;
} else if (typeof(document.compatMode) != 'undefined' && document.compatMode != 'BackCompat') {
nResult = document.documentElement.scrollTop;
} else if (typeof(document.body) != 'undefined') {
nResult = document.body.scrollTop;
}
break;
case "clientWidth":
if (typeof(document.compatMode) != 'undefined' && document.compatMode != 'BackCompat') {
nResult = document.documentElement.clientWidth;
} else if (typeof(document.body) != 'undefined') {
nResult = document.body.clientWidth;
}
break;
case "clientHeight":
if (typeof(document.compatMode) != 'undefined' && document.compatMode != 'BackCompat') {
nResult = document.documentElement.clientHeight;
} else if (typeof(document.body) != 'undefined') {
nResult = document.body.clientHeight;
}
break;
case "scrollWidth":
if (typeof(document.compatMode) != 'undefined' && document.compatMode != 'BackCompat') {
nResult = document.documentElement.scrollWidth;
} else if (typeof(document.body) != 'undefined') {
nResult = document.body.scrollWidth;
}
break;
case "scrollHeight":
if (typeof(document.compatMode) != 'undefined' && document.compatMode != 'BackCompat') {
nResult = document.documentElement.scrollHeight;
} else if (typeof(document.body) != 'undefined') {
nResult = document.body.scrollHeight;
}
break;
default:
break;
}
return nResult;
};
Function.prototype.bind = function(object) {
var __method = this;
return function() {
__method.apply(object, arguments)
}
};
Function.prototype.bindAsEventListener = function(object) {
var __method = this;
return function(event) {
__method.call(object, event || window.event)
}
};
Object.extend = function(destination, source) {
for (property in source) {
destination[property] = source[property]
};
return destination
};
if (!window.Event) {
var Event = new Object();
};
Object.extend(Event, {
observers: false,
element: function(event) {
return event.target || event.srcElement;
},
isLeftClick: function(event) {
return (((event.which) && (event.which == 1)) || ((event.button) && (event.button == 1)));
},
pointerX: function(event) {
return event.pageX || (event.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft));
},
pointerY: function(event) {
return event.pageY || (event.clientY + (document.documentElement.scrollTop || document.body.scrollTop));
},
stop: function(event) {
if (event.preventDefault) {
event.preventDefault();
event.stopPropagation();
} else {
event.returnValue = false;
event.cancelBubble = true;
};
},
findElement: function(event, tagName) {
var element = Event.element(event);
while (element.parentNode && (!element.tagName || (element.tagName.toUpperCase() != tagName.toUpperCase()))) element = element.parentNode;
return element;
},
_observeAndCache: function(element, name, observer, useCapture) {
if (!this.observers) this.observers = [];
if (element.addEventListener) {
this.observers.push([element, name, observer, useCapture]);
element.addEventListener(name, observer, useCapture);
} else if (element.attachEvent) {
this.observers.push([element, name, observer, useCapture]);
element.attachEvent('on' + name, observer);
};
},
unloadCache: function() {
if (!Event.observers) return;
for (var j = 0; j < Event.observers.length; j++) {
Event.stopObserving.apply(this, Event.observers[j]);
Event.observers[j][0] = null;
};
Event.observers = false;
},
observe: function(element, name, observer, useCapture) {
var element = G(element);
useCapture = useCapture || false;
if (name == 'keypress' && (navigator.appVersion.match(/Konqueror|Safari|KHTML/) || element.attachEvent)) name = 'keydown';
this._observeAndCache(element, name, observer, useCapture);
},
stopObserving: function(element, name, observer, useCapture) {
var element = G(element);
useCapture = useCapture || false;
if (name == 'keypress' && (navigator.appVersion.match(/Konqueror|Safari|KHTML/) || element.detachEvent)) name = 'keydown';
if (element.removeEventListener) {
element.removeEventListener(name, observer, useCapture);
} else if (element.detachEvent) {
element.detachEvent('on' + name, observer);
};
}
});
Event.observe(window, 'unload', Event.unloadCache, false);
var Class = function() {
var _class = function() {
this.initialize.apply(this, arguments);
};
for (j = 0; j < arguments.length; j++) {
superClass = arguments[j];
for (member in superClass.prototype) {
_class.prototype[member] = superClass.prototype[member];
};
};
_class.child = function() {
return new Class(this);
};
_class.extend = function(f) {
for (property in f) {
_class.prototype[property] = f[property];
};
};
return _class;
};
function space(flag) {
if (flag == "begin") {
var ele = document.getElementById("ft");
if (typeof(ele) != "undefined" && ele != null) ele.id = "ft_popup";
ele = document.getElementById("usrbar");
if (typeof(ele) != "undefined" && ele != null) ele.id = "usrbar_popup";
} else if (flag == "end") {
var ele = document.getElementById("ft_popup");
if (typeof(ele) != "undefined" && ele != null) ele.id = "ft";
ele = document.getElementById("usrbar_popup");
if (typeof(ele) != "undefined" && ele != null) ele.id = "usrbar";
};
};
var Popup = new Class();
Popup.prototype = {
iframeIdName: 'ifr_popup',
initialize: function(config) {
this.config = Object.extend({
contentType: 1,
isHaveTitle: true,
scrollType: 'no',
isBackgroundCanClick: false,
isSupportDraging: true,
isShowShadow: true,
isReloadOnClose: true,
width: 400,
height: 300
},
config || {});
this.info = {
shadowWidth: 4,
title: "",
contentUrl: "",
contentHtml: "",
callBack: null,
parameter: null,
confirmCon: "",
alertCon: "",
someHiddenTag: "select,object,embed",
someHiddenEle: "",
overlay: 0,
coverOpacity: 40
};
this.color = {
cColor: "#000000",
bColor: "#FFFFFF",
tColor: "#709CD2",
wColor: "#FFFFFF"
};
this.dropClass = null;
this.someToHidden = [];
if (!this.config.isHaveTitle) {
this.config.isSupportDraging = false;
}
this.iniBuild();
},
setContent: function(arrt, val) {
if (val != '') {
switch (arrt) {
case 'width':
this.config.width = val;
break;
case 'height':
this.config.height = val;
break;
case 'title':
this.info.title = val;
break;
case 'contentUrl':
this.info.contentUrl = val;
break;
case 'contentHtml':
this.info.contentHtml = val;
break;
case 'callBack':
this.info.callBack = val;
break;
case 'parameter':
this.info.parameter = val;
break;
case 'confirmCon':
this.info.confirmCon = val;
break;
case 'alertCon':
this.info.alertCon = val;
break;
case 'someHiddenTag':
this.info.someHiddenTag = val;
break;
case 'someHiddenEle':
this.info.someHiddenEle = val;
break;
case 'overlay':
this.info.overlay = val;
};
};
},
iniBuild: function() {
G('dialogCase') ? G('dialogCase').parentNode.removeChild(G('dialogCase')) : function() {};
var oDiv = document.createElement('span');
oDiv.id = 'dialogCase';
document.body.appendChild(oDiv);
},
build: function() {
var baseZIndex = 10001 + this.info.overlay * 10;
var showZIndex = baseZIndex + 2;
this.iframeIdName = 'ifr_popup' + this.info.overlay;
var path = "decorators/js/popup/dialogclose.gif";
var close = '';
var cB = 'filter: alpha(opacity=' + this.info.coverOpacity + ');opacity:' + this.info.coverOpacity / 100 + ';';
var cover = '
var mainBox = '' + '';';
if (this.config.isHaveTitle) {
mainBox += ' '' + ' ' + this.info.title + ' ' + '' + close + '
} else {
mainBox += ' '' + close + '
};
mainBox += '
if (!this.config.isBackgroundCanClick) {
G('dialogCase').innerHTML = cover + mainBox;
this.setBackgroundSize();
window.onresize = this.setBackgroundSize;
} else {
G('dialogCase').innerHTML = mainBox;
}
Event.observe(G('dialogBoxClose'), "click", this.reset.bindAsEventListener(this), false);
if (this.config.isSupportDraging) {
dropClass = new Dragdrop(this.config.width, this.config.height, this.info.shadowWidth, this.config.isSupportDraging, this.config.contentType);
G("dialogBoxTitle").style.cursor = "move"
};
this.lastBuild()
},
setBackgroundSize: function() {
var getValueWidth;
var getMaxValueWidth = [getValue("clientWidth"), getValue("scrollWidth")];
getValueWidth = eval("Math.max(" + getMaxValueWidth.toString() + ")");
G('dialogBoxBG').style.width = getValueWidth;
var getValueHeight;
var getMaxValueHeight = [getValue("clientHeight"), getValue("scrollHeight")];
getValueHeight = eval("Math.max(" + getMaxValueHeight.toString() + ")");
G('dialogBoxBG').style.height = getValueHeight;
},
lastBuild: function() {
var confirm = '' + this.info.confirmCon + '
var alert = '' + this.info.alertCon + '
var baseZIndex = 10001 + this.info.overlay * 10;
var coverIfZIndex = baseZIndex + 4;
if (this.config.contentType == 1) {
var openIframe = "";
var coverIframe = "";
G("dialogBody").innerHTML = openIframe + coverIframe;
} else if (this.config.contentType == 2) {
G("dialogBody").innerHTML = this.info.contentHtml;
} else if (this.config.contentType == 3) {
G("dialogBody").innerHTML = confirm;
Event.observe(G('dialogOk'), "click", this.forCallback.bindAsEventListener(this), false);
Event.observe(G('dialogCancel'), "click", this.close.bindAsEventListener(this), false);
} else if (this.config.contentType == 4) {
G("dialogBody").innerHTML = alert;
Event.observe(G('dialogYES'), "click", this.close.bindAsEventListener(this), false);
};
},
reBuild: function() {
G('dialogBody').height = G('dialogBody').clientHeight;
this.lastBuild()
},
show: function() {
this.hiddenSome();
this.middle();
if (this.config.isShowShadow) this.shadow()
},
forCallback: function() {
return this.info.callBack(this.info.parameter)
},
shadow: function() {
var oShadow = G('dialogBoxShadow');
var oDialog = G('dialogBox');
oShadow['style']['position'] = "absolute";
oShadow['style']['background'] = "#000";
oShadow['style']['display'] = "";
oShadow['style']['opacity'] = "0.2";
oShadow['style']['filter'] = "alpha(opacity=20)";
oShadow['style']['top'] = oDialog.offsetTop + this.info.shadowWidth + "px";
oShadow['style']['left'] = oDialog.offsetLeft + this.info.shadowWidth + "px";
oShadow['style']['width'] = oDialog.offsetWidth + "px";
oShadow['style']['height'] = oDialog.offsetHeight + "px";
},
middle: function() {
if (!this.config.isBackgroundCanClick) G('dialogBoxBG').style.display = '';
var oDialog = G('dialogBox');
oDialog['style']['position'] = "absolute";
oDialog['style']['display'] = '';
var sClientWidth = getValue("clientWidth");
var sClientHeight = getValue("clientHeight");
var sScrollTop = getValue("scrollTop");
var sleft = (sClientWidth / 2) - (oDialog.offsetWidth / 2);
var iTop = (sClientHeight / 2 + sScrollTop) - (oDialog.offsetHeight / 2);
var sTop = iTop > 0 ? iTop: (sClientHeight / 2 + sScrollTop) - (oDialog.offsetHeight / 2);
if (sTop < 1) sTop = "20";
if (sleft < 1) sleft = "20";
oDialog['style']['left'] = sleft + "px";
oDialog['style']['top'] = sTop + "px";
},
reset: function() {
if (this.config.isReloadOnClose) {
top.location.reload();
};
this.close();
},
close: function() {
G('dialogBox').style.display = 'none';
if (!this.config.isBackgroundCanClick) G('dialogBoxBG').style.display = 'none';
if (this.config.isShowShadow) G('dialogBoxShadow').style.display = 'none';
G('dialogBody').innerHTML = '';
this.showSome();
},
hiddenSome: function() {
var tag = this.info.someHiddenTag.split(",");
if (tag.length == 1 && tag[0] == "") {
tag.length = 0;
}
for (var j = 0; j < tag.length; j++) {
this.hiddenTag(tag[j]);
};
var ids = this.info.someHiddenEle.split(",");
if (ids.length == 1 && ids[0] == "") ids.length = 0;
for (var j = 0; j < ids.length; j++) {
this.hiddenEle(ids[j]);
};
space("begin");
},
hiddenTag: function(tagName) {
var ele = document.getElementsByTagName(tagName);
if (ele != null) {
for (var j = 0; j < ele.length; j++) {
if (ele[j].style.display != "none" && ele[j].style.visibility != 'hidden') {
ele[j].style.visibility = 'hidden';
this.someToHidden.push(ele[j]);
};
};
};
},
hiddenEle: function(id) {
var ele = document.getElementById(id);
if (typeof(ele) != "undefined" && ele != null) {
ele.style.visibility = 'hidden';
this.someToHidden.push(ele);
}
},
showSome: function() {
for (var j = 0; j < this.someToHidden.length; j++) {
this.someToHidden[j].style.visibility = 'visible';
};
space("end");
}
};
var Dragdrop = new Class();
Dragdrop.prototype = {
initialize: function(width, height, shadowWidth, showShadow, contentType) {
this.dragData = null;
this.dragDataIn = null;
this.backData = null;
this.width = width;
this.height = height;
this.shadowWidth = shadowWidth;
this.showShadow = showShadow;
this.contentType = contentType;
this.IsDraging = false;
this.oObj = G('dialogBox');
Event.observe(G('dialogBoxTitle'), "mousedown", this.moveStart.bindAsEventListener(this), false);
},
moveStart: function(event) {
this.IsDraging = true;
if (this.contentType == 1) {
G("iframeBG").style.display = "";
G("iframeBG").style.width = this.width;
G("iframeBG").style.height = this.height;
};
Event.observe(document, "mousemove", this.mousemove.bindAsEventListener(this), false);
Event.observe(document, "mouseup", this.mouseup.bindAsEventListener(this), false);
Event.observe(document, "selectstart", this.returnFalse, false);
this.dragData = {
x: Event.pointerX(event),
y: Event.pointerY(event)
};
this.backData = {
x: parseInt(this.oObj.style.left),
y: parseInt(this.oObj.style.top)
};
},
mousemove: function(event) {
if (!this.IsDraging) return;
var iLeft = Event.pointerX(event) - this.dragData["x"] + parseInt(this.oObj.style.left);
var iTop = Event.pointerY(event) - this.dragData["y"] + parseInt(this.oObj.style.top);
if (this.dragData["y"] < parseInt(this.oObj.style.top)) iTop = iTop - 12;
else if (this.dragData["y"] > parseInt(this.oObj.style.top) + 25) iTop = iTop + 12;
this.oObj.style.left = iLeft + "px";
this.oObj.style.top = iTop + "px";;
if (this.showShadow) {
G('dialogBoxShadow').style.left = iLeft + this.shadowWidth + "px";
G('dialogBoxShadow').style.top = iTop + this.shadowWidth + "px";
};
this.dragData = {
x: Event.pointerX(event),
y: Event.pointerY(event)
};
document.body.style.cursor = "move";
},
mouseup: function(event) {
if (!this.IsDraging) return;
if (this.contentType == 1) G("iframeBG").style.display = "none";
document.onmousemove = null;
document.onmouseup = null;
var mousX = Event.pointerX(event) - (document.documentElement.scrollLeft || document.body.scrollLeft);
var mousY = Event.pointerY(event) - (document.documentElement.scrollTop || document.body.scrollTop);
var oObjBottom;
var oObjRight;
if (this.showShadow) {
oObjBottom = parseInt(this.oObj.style.top) + this.height + this.shadowWidth;
oObjRight = parseInt(this.oObj.style.left) + this.width + this.shadowWidth;
} else {
oObjBottom = parseInt(this.oObj.style.top) + this.height;
oObjRight = parseInt(this.oObj.style.left) + this.width;
};
if (mousX < 1 || mousY < 1 || mousX > document.body.clientWidth || mousY > document.body.clientHeight || parseInt(this.oObj.style.left) < 0 || parseInt(this.oObj.style.top) < 0 || oObjRight > document.body.clientWidth || oObjBottom > document.body.clientHeight) {
this.oObj.style.left = this.backData["x"];
this.oObj.style.top = this.backData["y"];
if (this.showShadow) {
G('dialogBoxShadow').style.left = this.backData.x + this.shadowWidth;
G('dialogBoxShadow').style.top = this.backData.y + this.shadowWidth;
};
};
this.IsDraging = false;
document.body.style.cursor = "";
Event.stopObserving(document, "selectstart", this.returnFalse, false);
},
returnFalse: function() {
return false;
}
};
function openshow(url, title, w, h, stype) {
g_pop = new Popup({
contentType: stype,
isReloadOnClose: false,
width: w,
height: h
});
g_pop.setContent("title", title);
g_pop.setContent("contentUrl", url);
g_pop.build();
g_pop.show();
}
function g_close_pop_re() {
g_pop.close();
location.reload();
}
function Comment(url, w, h) {
g_pop = new Popup({
contentType: 1,
isReloadOnClose: false,
width: w,
height: h
});
g_pop.setContent("title", "登陆");
g_pop.setContent("scrollType", "no");
g_pop.setContent("contentUrl", url);
g_pop.build();
g_pop.show();
}
function g_close_pop() {
g_pop.close();
g_pop = null;
}
function ShowAlert(title, content, w, h) {
var pop = new Popup({
contentType: 4,
isReloadOnClose: false,
width: w,
height: h
});
pop.setContent("title", title);
pop.setContent("alertCon", content);
pop.build();
pop.show();
}
function Wclose() {
g_pop.close();
g_pop = null;
}解决 无用评论 打赏 举报
悬赏问题
- ¥15 如何在scanpy上做差异基因和通路富集?
- ¥20 关于#硬件工程#的问题,请各位专家解答!
- ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
- ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
- ¥30 截图中的mathematics程序转换成matlab
- ¥15 动力学代码报错,维度不匹配
- ¥15 Power query添加列问题
- ¥50 Kubernetes&Fission&Eleasticsearch
- ¥15 報錯:Person is not mapped,如何解決?
- ¥15 c++头文件不能识别CDialog