__DIALOG_WRAPPER__ = {};
/* IE6有个Bug,如果不给定对话框的宽度的话,在IE6下,对话框将以100%宽度显示 */
DialogManager = {
'create' :function(id){
var d = {};
if (!__DIALOG_WRAPPER__[id])
{
d = new Dialog(id);
__DIALOG_WRAPPER__[id] = d;
}
else
{
d = DialogManager.get(id);
}
return d;
},
'get' :function(id){
return __DIALOG_WRAPPER__[id];
},
'set' :function(id, val){
__DIALOG_WRAPPER__[id] = val;
},
'close' :function(id){
if (__DIALOG_WRAPPER__[id].close())
{
__DIALOG_WRAPPER__[id] = null;
}
},
'onClose' :function (){
return true;
},
/* 加载对话框样式 */
'loadStyle' :function(){
var _dialog_js_path = $('#dialog_js').attr('src');
var _path = _dialog_js_path.split('/');
var _dialog_css = _path.slice(0, _path.length - 1).join('/') + '/dialog.css';
$('#dialog_js').after(' ');
}
};
ScreenLocker = {
'style' : {
'position' : 'absolute',
'top' : '0px',
'left' : '0px',
'backgroundColor' : 'transparent',
'opacity' : 0,
'zIndex' : 999
},
'masker' : null,
'lock' : function(zIndex){
if (this.masker !== null)
{
this.masker.width($(document).width()).height($(document).height());
return true;
}
this.masker = $('
');
/* 样式 */
this.masker.css(this.style);
if (zIndex)
{
this.masker.css('zIndex', zIndex);
}
/* 整个文档的宽高 */
this.masker.width($(document).width()).height($(document).height());
$(document.body).append(this.masker);
$("#dialog_manage_screen_locker").show();
},
'unlock' : function(){
if (this.masker === null)
{
return true;
}
this.masker.remove();
this.masker = null;
}
};
Dialog = function (id){
/* 构造函数生成对话框代码,并加入到文档中 */
this.id = id;
this.init();
};
Dialog.prototype = {
/* 唯一标识 */
'id' : null,
/* 文档对象 */
'dom' : null,
'lastPos' : null,
'status' : 'complete',
'onClose' : function (){
return true;
},
'tmp' : {},
/* 初始化 */
'init' : function(){
this.dom = {'wrapper' : null, 'body':null, 'head':null, 'title':null, 'close_button':null, 'content':null};
/* 创建外层容器 */
this.dom.wrapper = $('
').get(0);
/* 创建对话框主体 */
this.dom.body = $('
').get(0);
/* 创建标题栏 */
this.dom.head = $(' ').get(0);
/* 创建标题文本 */
this.dom.title = $(' ').get(0);
/* 创建关闭按钮 */
this.dom.close_button = $('X ').get(0);
/* 创建内容区域 */
this.dom.content = $('
').get(0);
/* 组合 */
$(this.dom.head).append($(' ').append(this.dom.title)).append(this.dom.close_button);
$(this.dom.body).append(this.dom.head).append(this.dom.content);
$(this.dom.wrapper).append(this.dom.body).append('
');
/* 初始化样式 */
$(this.dom.wrapper).css({
'zIndex' : 1100,
'display' : 'none',
'position' : 'absolute'
});
$(this.dom.body).css({
'position' : 'relative'
});
$(this.dom.head).css({
'cursor' : 'move'
});
$(this.dom.content).css({
'margin' : '0px',
'padding' : '0px'
});
var self = this;
/* 初始化组件事件 */
$(this.dom.close_button).click(function(){
DialogManager.close(self.id);
});
/* 可拖放 */
// if(typeof draggable != 'undefined'){
// $(this.dom.wrapper).draggable({
// 'handle' : this.dom.head
// });
// }
/* 放入文档流 */
$(document.body).append(this.dom.wrapper);
},
/* 隐藏 */
'hide' : function(){
$(this.dom.wrapper).hide();
},
/* 显示 */
'show' : function(pos,lock){
if (pos)
{
this.setPosition(pos);
}
/* 锁定屏幕 */
if (lock == 1) ScreenLocker.lock(999);
$(this.dom.wrapper).draggable({
'handle' : this.dom.head
});
/* 显示对话框 */
$(this.dom.wrapper).show();
},
/* 关闭 */
'close' : function(lock){
if (!this.onClose())
{
return false;
}
/* 关闭对话框 */
$(this.dom.wrapper).remove();
/* 解锁屏幕 */
if (typeof lock == 'undefined'){
ScreenLocker.unlock();
}
DialogManager.set(this.id,null);
return true;
},
/* 对话框标题 */
'setTitle' : function(title){
$(this.dom.title).html(title);
},
/* 改变对话框内容 */
'setContents' : function(type, options){
contents = this.createContents(type, options);
if (typeof(contents) == 'string')
{
$(this.dom.content).html(contents);
}
else
{
$(this.dom.content).empty();
$(this.dom.content).append(contents);
}
},
/* 设置对话框样式 */
'setStyle' : function(style){
if (typeof(style) == 'object')
{
/* 否则为CSS */
$(this.dom.wrapper).css(style);
}
else
{
/* 如果是字符串,则认为是样式名 */
$(this.dom.wrapper).addClass(style);
}
},
'setWidth' : function(width){
this.setStyle({'width' : width + 'px'});
},
'setHeight' : function(height){
this.setStyle({'height' : height + 'px'});
},
/* 生成对话框内容 */
'createContents' : function(type, options){
var _html = '',
self = this,
status= 'complete';
if (!options)
{
/* 如果只有一个参数,则认为其传递的是HTML字符串 */
this.setStatus(status);
return type;
}
switch(type){
case 'ajax':
/* 通过Ajax取得HTML,显示到页面上,此过程是异步的 */
$.get(options, function(data){
self.setContents(data);
/* 使用上次定位重新定位窗口位置 */
self.setPosition(self.lastPos);
});
/* 先提示正在加载 */
_html = this.createContents('loading', {'text' : 'loading...'});
break;
case 'ajax_notice':
/* 通过Ajax取得HTML,显示到页面上,此过程是异步的 */
$.get(options, function(data) {
var json = eval('(' + data + ')');
var MsgTxt = '
' + json.Msg + '
'
self.setContents(MsgTxt);
/* 使用上次定位重新定位窗口位置 */
self.setPosition(self.lastPos);
});
/* 先提示正在加载 */
_html = this.createContents('loading', { 'text': '正在处理...' });
break;
/* 以下是内置的几种对话框类型 */
case 'loading':
_html = '';
status = 'loading';
break;
case 'message':
var type = 'notice';
if (options.type)
{
type = options.type;
}
_message_body = $('
');
_message_contents = $('' + options.text + '
');
_buttons_bar = $('
');
switch (type){
case 'notice':
case 'warning':
var button_name = '确定';
if (options.button_name)
{
button_name = options.button_name;
}
_ok_button = $(' ');
$(_ok_button).click(function(){
if (options.onclick)
{
if(!options.onclick.call())
{
return;
}
}
DialogManager.close(self.id);
});
$(_buttons_bar).append(_ok_button);
break;
case 'confirm':
var yes_button_name = "确定";
var no_button_name = "取消";
if (options.yes_button_name)
{
yes_button_name = options.yes_button_name;
}
if (options.no_button_name)
{
no_button_name = options.no_button_name;
}
_yes_button = $(' ');
_no_button = $(' ');
$(_yes_button).click(function(){
if (options.onClickYes)
{
if (options.onClickYes.call() === false)
{
return;
}
}
DialogManager.close(self.id);
});
$(_no_button).click(function(){
if (options.onClickNo)
{
if (!options.onClickNo.call())
{
return;
}
}
DialogManager.close(self.id);
});
$(_buttons_bar).append(_yes_button).append(_no_button);
break;
}
_html = $(_message_body).append(_message_contents).append(_buttons_bar);
break;
}
this.setStatus(status);
return _html;
},
/* 定位 */
'setPosition' : function(pos){
/* 上次定位 */
this.lastPos = pos;
if (typeof(pos) == 'string')
{
switch(pos){
case 'center':
var left = 0;
var top = 0;
var dialog_width = $(this.dom.wrapper).width();
var dialog_height = $(this.dom.wrapper).height();
/* left=滚动条的宽度 + (当前可视区的宽度 - 对话框的宽度 ) / 2 */
left = $(window).scrollLeft() + ($(window).width() - dialog_width) / 2;
/* top =滚动条的高度 + (当前可视区的高度 - 对话框的高度 ) / 2 */
top = $(window).scrollTop() + ($(window).height() - dialog_height) / 2;
$(this.dom.wrapper).css({left:left + 'px', top:top + 'px'});
break;
}
}
else
{
var _pos = {};
if (typeof(pos.left) != 'undefined')
{
_pos.left = pos.left;
}
if (typeof(pos.top) != 'undefined')
{
_pos.top = pos.top;
}
$(this.dom.wrapper).css(_pos);
}
},
/* 设置状态 */
'setStatus' : function(code){
this.status = code;
},
/* 获取状态 */
'getStatus' : function(){
return this.status;
},
'disableClose' : function(msg){
this.tmp['oldOnClose'] = this.onClose;
this.onClose = function(){
if(msg)alert(msg);
return false;
};
},
'enableClose' : function(){
this.onClose = this.tmp['oldOnClose'];
this.tmp['oldOnClose'] = null;
}
};
DialogManager.loadStyle();
/*common2.2.js*/
DIALOGIMGDIR = "__JS__"+'/dialog/images/dialog';
var BROWSER = {};
var USERAGENT = navigator.userAgent.toLowerCase();
browserVersion({'ie':'msie','firefox':'','chrome':'','opera':'','safari':'','mozilla':'','webkit':'','maxthon':'','qq':'qqbrowser'});
if(BROWSER.safari) {
BROWSER.firefox = true;
}
BROWSER.opera = BROWSER.opera ? opera.version() : 0;
HTMLNODE = document.getElementsByTagName('head')[0].parentNode;
if(BROWSER.ie) {
BROWSER.iemode = parseInt(typeof document.documentMode != 'undefined' ? document.documentMode : BROWSER.ie);
HTMLNODE.className = 'ie_all ie' + BROWSER.iemode;
}
var JSLOADED = [];
var JSMENU = [];
JSMENU['active'] = [];
JSMENU['timer'] = [];
JSMENU['drag'] = [];
JSMENU['layer'] = 0;
JSMENU['zIndex'] = {'win':1000,'menu':1100,'dialog':1200,'prompt':1300};
JSMENU['float'] = '';
var CURRENTSTYPE = null;
var EXTRAFUNC = [], EXTRASTR = '';
if(BROWSER.firefox && window.HTMLElement) {
HTMLElement.prototype.__defineGetter__( "innerText", function(){
var anyString = "";
var childS = this.childNodes;
for(var i=0; i ';
}
return str + '>' + this.innerHTML + '' + this.tagName.toLowerCase() + '>';
});
HTMLElement.prototype.__defineGetter__('canHaveChildren', function() {
switch(this.tagName.toLowerCase()) {
case 'area':case 'base':case 'basefont':case 'col':case 'frame':case 'hr':case 'img':case 'br':case 'input':case 'isindex':case 'link':case 'meta':case 'param':
return false;
}
return true;
});
}
function $$(id) {
return !id ? null : document.getElementById(id);
}
function _attachEvent(obj, evt, func, eventobj) {
eventobj = !eventobj ? obj : eventobj;
if(obj.addEventListener) {
obj.addEventListener(evt, func, false);
} else if(eventobj.attachEvent) {
obj.attachEvent('on' + evt, func);
}
}
function browserVersion(types) {
var other = 1;
for(i in types) {
var v = types[i] ? types[i] : i;
if(USERAGENT.indexOf(v) != -1) {
var re = new RegExp(v + '(\\/|\\s)([\\d\\.]+)', 'ig');
var matches = re.exec(USERAGENT);
var ver = matches != null ? matches[2] : 0;
other = ver !== 0 && v != 'mozilla' ? 0 : other;
}else {
var ver = 0;
}
eval('BROWSER.' + i + '= ver');
}
BROWSER.other = other;
}
function getEvent() {
if(document.all) return window.event;
func = getEvent.caller;
while(func != null) {
var arg0 = func.arguments[0];
if (arg0) {
if((arg0.constructor == Event || arg0.constructor == MouseEvent) || (typeof(arg0) == "object" && arg0.preventDefault && arg0.stopPropagation)) {
return arg0;
}
}
func=func.caller;
}
return null;
}
function isUndefined(variable) {
return typeof variable == 'undefined' ? true : false;
}
function in_array(needle, haystack) {
if(typeof needle == 'string' || typeof needle == 'number') {
for(var i in haystack) {
if(haystack[i] == needle) {
return true;
}
}
}
return false;
}
function strlen(str) {
return (BROWSER.ie && str.indexOf('\n') != -1) ? str.replace(/\r?\n/g, '_').length : str.length;
}
function Ajax(recvType, waitId) {
var aj = new Object();
aj.loading = '请稍候...';
aj.recvType = recvType ? recvType : 'XML';
aj.waitId = waitId ? $$(waitId) : null;
aj.resultHandle = null;
aj.sendString = '';
aj.targetUrl = '';
aj.setLoading = function(loading) {
if(typeof loading !== 'undefined' && loading !== null) aj.loading = loading;
};
aj.setRecvType = function(recvtype) {
aj.recvType = recvtype;
};
aj.setWaitId = function(waitid) {
aj.waitId = typeof waitid == 'object' ? waitid : $$(waitid);
};
aj.createXMLHttpRequest = function() {
var request = false;
if(window.XMLHttpRequest) {
request = new XMLHttpRequest();
if(request.overrideMimeType) {
request.overrideMimeType('text/xml');
}
} else if(window.ActiveXObject) {
var versions = ['Microsoft.XMLHTTP', 'MSXML.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.7.0', 'Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP'];
for(var i=0; i ' + aj.loading + '';
}
};
aj.processHandle = function() {
if(aj.XMLHttpRequest.readyState == 4 && aj.XMLHttpRequest.status == 200) {
if(aj.waitId) {
aj.waitId.style.display = 'none';
}
if(aj.recvType == 'HTML') {
aj.resultHandle(aj.XMLHttpRequest.responseText, aj);
} else if(aj.recvType == 'XML') {
if(!aj.XMLHttpRequest.responseXML || !aj.XMLHttpRequest.responseXML.lastChild || aj.XMLHttpRequest.responseXML.lastChild.localName == 'parsererror') {
aj.resultHandle('内部错误,无法显示此内容 ' , aj);
} else {
aj.resultHandle(aj.XMLHttpRequest.responseXML.lastChild.firstChild.nodeValue, aj);
}
}
}
};
aj.get = function(targetUrl, resultHandle) {
targetUrl = hostconvert(targetUrl);
setTimeout(function(){aj.showLoading()}, 250);
aj.targetUrl = targetUrl;
aj.XMLHttpRequest.onreadystatechange = aj.processHandle;
aj.resultHandle = resultHandle;
var attackevasive = isUndefined(attackevasive) ? 0 : attackevasive;
if(window.XMLHttpRequest) {
aj.XMLHttpRequest.open('GET', aj.targetUrl);
aj.XMLHttpRequest.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
aj.XMLHttpRequest.send(null);
} else {
aj.XMLHttpRequest.open("GET", targetUrl, true);
aj.XMLHttpRequest.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
aj.XMLHttpRequest.send();
}
};
aj.post = function(targetUrl, sendString, resultHandle) {
targetUrl = hostconvert(targetUrl);
setTimeout(function(){aj.showLoading()}, 250);
aj.targetUrl = targetUrl;
aj.sendString = sendString;
aj.XMLHttpRequest.onreadystatechange = aj.processHandle;
aj.resultHandle = resultHandle;
aj.XMLHttpRequest.open('POST', targetUrl);
aj.XMLHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
aj.XMLHttpRequest.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
aj.XMLHttpRequest.send(aj.sendString);
};
return aj;
}
function getHost(url) {
var host = "null";
if(typeof url == "undefined"|| null == url) {
url = window.location.href;
}
var regex = /^\w+\:\/\/([^\/]*).*/;
var match = url.match(regex);
if(typeof match != "undefined" && null != match) {
host = match[1];
}
return host;
}
function hostconvert(url) {
if(!url.match(/^http?:\/\//)) url = SITEURL.replace(/(\/+)$/g, '') + '/' + url;
var url_host = getHost(url);
var cur_host = getHost().toLowerCase();
if(url_host && cur_host != url_host) {
url = url.replace(url_host, cur_host);
}
return url;
}
function newfunction(func) {
var args = [];
for(var i=1; i]*?>([^\x00]*?)<\/script>/ig;
var arr = [];
while(arr = p.exec(s)) {
var p1 = /