/*
* lhgcore Dialog Plugin
* 2014-7-30 cpp
*/
// 初始化组件对象用于页面操作
var api = frameElement.api, W = api.opener;
// 运行代码
$.fn.runCode = function() {
var getText = function(elems) {
var ret = "", elem;
for ( var i = 0; elems[i]; i++) {
elem = elems[i];
if (elem.nodeType === 3 || elem.nodeType === 4) {
ret += elem.nodeValue;
} else if (elem.nodeType !== 8) {
ret += getText(elem.childNodes);
}
;
}
;
return ret;
};
var code = getText(this);
new Function(code).call(window);
return this;
};
//--------------------公共弹出框方法-----------------------------
// 关闭窗口
function cpp_close() {
api.close();
}
//关闭弹出框后刷新页面
function cpp_close_two() {
parent.frameContent.location.reload();
api.close();
}
//关闭弹出框后刷新页面(有frameset时使用)
function cpp_close_three() {
parent.frameContent.subcontent.location.reload();
api.close();
}
// 信息提示框(在窗口页面直接弹出)
// 参数:提示信息
function cpp_alert(msgInfo) {
$.dialog.alert(msgInfo);
}
// 信息提示框(在窗口页面直接弹出)支持确定后,刷新传入的页面地址
// 参数:提示信息
function cpp_alert_url(msgInfo,url) {
$.dialog( {
id : 'dialog004',
title : '信息提示',
icon : 'alert.gif',
content : msgInfo,
lock : true,
ok : function(){
window.location.href = url;
},
parent : api
});
}
// 信息提示框(在弹出框中直接弹出)
// 参数:提示信息
function cpp_alert_pop(msgInfo,isClose) {
W.$.dialog( {
id : 'dialog001',
title : '信息提示',
icon : 'alert.gif',
content : msgInfo,
lock : true,
ok : function(){
if(isClose){
api.close();
}
},
parent : api
});
}
//信息提示框(在弹出框中直接弹出,点击确认后刷新弹出框)
//参数:提示信息
function cpp_alert_pop_two(msgInfo) {
W.$.dialog( {
id : 'dialog001',
title : '信息提示',
icon : 'alert.gif',
content : msgInfo,
lock : true,
ok : function(){
window.location.reload();
},
parent : api
});
}
//信息提示框带刷新框架的内容页['frameContent'](在弹出框中直接弹出)
//参数:提示信息
function cpp_alert_pop_reload(msgInfo) {
W.$.dialog( {
id : 'dialog001',
title : '信息提示',
icon : 'alert.gif',
content : msgInfo,
lock : true,
ok : function(){
parent.frameContent.location.reload();
},
parent : api
});
}
//信息提示框(在弹出框中直接弹出)支持确定后,刷新传入的页面地址
//参数:提示信息
function cpp_alert_pop_url(msgInfo,url) {
W.$.dialog( {
id : 'dialog004',
title : '信息提示',
icon : 'alert.gif',
content : msgInfo,
lock : true,
ok : function(){
parent.frameContent.location.href = url;
},
parent : api
});
}
//信息提示框(在弹出框中直接弹出)支持确定后,刷新传入的页面地址--有frameset时使用
//参数:提示信息
function cpp_alert_pop_fram_url(msgInfo,url) {
W.$.dialog( {
id : 'dialog004',
title : '信息提示',
icon : 'alert.gif',
content : msgInfo,
lock : true,
ok : function(){
parent.frameContent.subcontent.location.href = url;
},
parent : api
});
}
//信息提示框(在frame中弹出,确定后重新加载整个页面)
//参数:提示信息
function cpp_alert_reload(msgInfo) {
$.dialog( {
id : 'dialog002',
title : '信息提示',
icon : 'alert.gif',
content : msgInfo,
lock : true,
ok : function(){
//刷新左侧菜单列表
parent.location.reload();
},
parent : null
});
}
//信息提示框(在frame中弹出,确定后重新加载整个页面)
//参数:提示信息
function cpp_alert_reload_two(msgInfo) {
$.dialog( {
id : 'dialog002',
title : '信息提示',
icon : 'alert.gif',
content : msgInfo,
lock : true,
ok : function(){
//刷新左侧菜单列表
parent.frameContent.location.reload();
},
parent : null
});
}
//提示确认框,调用完后恢复form的action
//参数:提示信息,表单的ID名,URL
function cpp_confirm2(conent, frmId, url) {
$.dialog.confirm(conent, function() {
var oldUrl = $("#" + frmId).attr("action");
// from方式提交
$("#" + frmId).attr("action", url);
$("#" + frmId)[0].submit();
$("#" + frmId).attr("action", oldUrl);
}, function() {
// ...不做处理
$("#" + frmId)[0].submit();;
});
}
// 提示确认框,调用完后会更改form的action
// 参数:提示信息,表单的ID名,URL
function cpp_confirm(conent, frmId, url) {
$.dialog.confirm(conent, function() {
// from方式提交
$("#" + frmId).attr("action", url);
$("#" + frmId)[0].submit();
}, function() {
// ...不做处理
});
}
//提示确认框(弹出框弹出)
//参数:提示信息,表单的ID名,URL
function cpp_confirm_pop(conent, frmId, url) {
W.$.dialog.confirm(conent, function() {
// from方式提交
$("#" + frmId).attr("action", url);
$("#" + frmId)[0].submit();
}, function() {
// ...不做处理
});
}
// 弹出框
// 参数:标题名,宽度,高度,URL,传递的值
function cpp_dialog(title, _width, _height, url, value) {
$.dialog( {
title : title,
focus : false,
content : 'url:' + url,
width : _width,
height : _height,
data : value || null,
close : function() {
}
});
}
//弹出框
//参数:关闭窗口后调用父窗口search函数
function cpp_dialog_search_parent_page(title, _width, _height, url, value) {
$.dialog( {
title : title,
focus : false,
content : 'url:' + url,
width : _width,
height : _height,
data : value || null,
close : function() {
parent.frameContent.search();
},
parent:api
});
}
/**
* 在页面上直接弹出弹出框
* @param title
* @param _width
* @param _height
* @param url
* @param fn
* @param _left
* @param _top
*/
function cpp_dialogPage(title, _width, _height, url, fn, _left, _top) {
var api = frameElement.api, W = api;
$.dialog( {
id : 'win_x0011',
title : title,
focus : false,
max : true,
content : 'url:' + url,
width : _width,
height : _height,
left : _left,
top: _top,
lock : true,
data : null,
close : function() {
// 调用子窗口方法,得到选择中菜单项值,将值传给页面函数进行显示处理
var sel_value = this.content.selValue();
if(fn != null){
fn(sel_value);
}
},
parent:api
});
}
//在页面的弹出框上直接弹出弹出框
//参数:标题名,宽度,高度,URL,函数名,左边距,上边距,
function cpp_dialog_pop_fn(title, _width, _height, url, fn, _left, _top) {
var api = frameElement.api, W = api.opener;
W.$.dialog( {
id : 'win_x0011',
title : title,
focus : false,
max : true,
content : 'url:' + url,
width : _width,
height : _height,
left : _left,
top: _top,
lock : true,
data : null,
close : function() {
// 调用子窗口方法,得到选择中菜单项值,将值传给页面函数进行显示处理
var sel_value = this.content.selValue();
if(fn != null){
fn(sel_value);
}
},
parent:api
});
}