diolog js_easyui.dialog.js

(function ($) {

var $parent = parent.$;

//获取弹出窗口数据集合

function getDialogs() {

var dialogs = $parent("#div_index_data").data("dialogs");

dialogs = dialogs || [];

if ($.util.isEmptyObjectOrNull(dialogs))

return [];

return dialogs;

}

//获取当前弹出窗口数据

function getCurrentDialog() {

var dialogs = getDialogs();

return dialogs[dialogs.length - 1] || {};

}

//获取当前弹出窗口Id

function getCurrentDialogId() {

return getCurrentDialog().id;

}

//添加弹出窗口数据,包括弹出窗口Id和jQuery对象

function addDialog(id) {

var data = getDialogs();

data.push({ id: id, caller: window });

$parent("#div_index_data").data("dialogs", data);

}

//移除当前弹出窗口数据

function removeCurrentDialog() {

var dialogs = getDialogs();

dialogs.pop();

}

//树形操作

$.easyui.dialog = function () {

return {

//添加弹出框

addDialog: function (id) {

addDialog(id);

return getCurrentDialog();

},

//获取原调用者window对象

getCaller: function () {

return getCurrentDialog().caller;

},

//获取原调用者jQuery对象

getCaller$: function () {

return getCurrentDialog().caller.$;

},

//获取弹出窗window对象

getCurrent: function () {

var dialogId = getCurrentDialogId();

return top.frames[dialogId + "_iframe"] ? (!top.frames[dialogId + "_iframe"].contentWindow ? top.frames[dialogId + "_iframe"] : top.frames[dialogId + "_iframe"].contentWindow) : top.contentWindow;

},

//获取弹出窗jQuery对象

getCurrent$: function () {

var dialogId = getCurrentDialogId();

return top.frames[dialogId + "_iframe"] ? (!top.frames[dialogId + "_iframe"].contentWindow ? top.frames[dialogId + "_iframe"].$ : top.frames[dialogId + "_iframe"].contentWindow.$) : top.contentWindow.$;

},

//打开弹出窗口

open: function (options) {

///

///弹出模态窗,解决在Iframe中无法全屏遮罩,

/// 注意:仅支持url弹窗

///

///

/// 1. title:标题

/// 2. url:网址

/// 3. buttons:显示在窗口底部的按钮区域div的id

/// 4. icon:图标class

/// 5. width:宽度

/// 6. height:高度

/// 7. onInit:初始化事件,返回false跳出执行

///

initOptions();

if (!options.onInit(options))

return;

var dialog = createDialow();

show();

addDialog(options.id);

//初始化参数

function initOptions() {

options = $.extend({

id: $.util.newGuid(""),

title: '',

url: '',

icon: 'icon-standard-common-window',

width: 600,

height: 360,

iframe: true,

closed: false,

maximizable: true,

resizable: true,

cache: false,

modal: true,

buttons: '',

onInit: function () {

return true;

},

closeCallback: function () { }

}, options || {});

}

//创建窗口div

function createDialow() {

if (options.iframe) {

return $parent("

} else {

return $parent("

}

}

//弹出窗口

function show() {

dialog.dialog({

title: options.title,

href: options.iframe ? "" : options.url,

width: options.width,

height: options.height,

closed: options.closed,

maximizable: options.maximizable,

resizable: options.resizable,

cache: options.cache,

modal: options.modal,

iconCls: options.icon,

buttons: options.buttons,

border: false,

onLoad: function () {

},

onClose: function () {

options.closeCallback();

$parent("#" + getCurrentDialogId()).dialog('destroy');

removeCurrentDialog();

}

});

}

},

openCommon: function (url, title, width, height, callBack) {

$.easyui.dialog.open({

title: title,

url: url,

width: width,

height: height,

buttons: [{

text: '确定',

iconCls: 'icon-standard-common-ok',

handler: function () {

callBack(getCurrentDialogId());

}

}, {

text: '取消',

iconCls: 'icon-standard-common-cancel',

handler: function () {

$.easyui.dialog.close();

}

}]

});

},

//关闭弹出窗口

close: function () {

var dialogId = getCurrentDialogId();

if (!dialogId)

return;

$parent('#' + dialogId).dialog('close');

},

//打开Tab页面

openTab: function (tabid, url, name, img) {

addDialog("tabs_iframe_" + tabid);

AddTabMenu(tabid, url, name, img, true, true, true);

},

//关闭当前Tab页面

closeTab: function () {

removeCurrentDialog();

ThisCloseTab();

}

}

}();

})(jQuery);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值