vue增加jQuery.open模态框方式打开新页面

7 篇文章 0 订阅

vue增加jQuery.open模态框方式打开新页面:
调用方式:
add() {
$.open("/user/add", 1024, 600, function () {

        });
    },

样式:
.ui-dialog-titlebar {
background: #11c26d !important;
}

jQuery.open = function () {//url,width,height,params,callback,fixParams
var url, width, height, params, callback, fixParams;//6
var args = arguments;
var argsLength = args.length;
for (var i = argsLength + 1; i < 7; i++) {
args[i - 1] = null;
}
url = args[0];
jQuery(args).each(function (index, arg) {
if (index == 0) return;
if (jQuery.isFunction(arg)) {
callback = arg;
} else if (typeof arg == ‘string’ || typeof arg == ‘number’) {
if (!width) width = arg;
else if (!height) height = arg;
//else params = arg ;
} else if (arg === null || arg === “”) {
//none
} else if (typeof arg == “object”) {
if (!params)
params = arg;
else
fixParams = arg;
}
});
if (!width) {
width = 1024;
}
if (!height) {
height = 600;
}

jQuery.dialogReturnValue("__init__");
params = params || {};
fixParams = fixParams || {};
var opts = {
    renderTop: true,
    width: width,
    height: height,
    fixed: false,
    isScroll: false,
    resizable: true,
    position: {
        using: function (pos) {
            $(this).css("left", pos.left);
            $(this).css("top", pos.top);
        },
    },
    buttonBar: false,
    defaultBtn: false,
    okButtonText: '保存',
    buttonText: '<a class="btn green" href="javascript:void(0)" onclick="__save()">保存</a>&nbsp;' + '<a class="btn red btn-cancel">取消</a>',
    title: params.title || params.Title || fixParams.title || '',
    url: url,
    data: params,
    onload: function () {
        var me = this;
        setTimeout(function () {
            //控件初始化
            me.frwDom.uiwidget();
            //浏览器兼容
            me.frwDom.browserFix();
        }, 5);
    }, close: function (opener) {
        var val = $.dialogReturnValue();
        if (callback) {
            return callback.call(this, val, opener);
        }
        return true;
    }
}
opts = $.extend({}, opts, params, fixParams);
var _dialog = $('<iframe frameborder="0" />').dialog(opts).attr("src", url);
$(".ui-dialog-titlebar").addClass('custom-' + localStorage.getItem('themecolor'));
return _dialog;

}

jQuery.dialogReturnValue = function (returnValue) {
if (typeof returnValue != ‘undefined’) {
if (returnValue == “init” || !returnValue) {
window.returnValue = null;
return;
}

    //window.winReturnValue = returnValue ;
    window.returnValue = returnValue;//showModelDialog

    try {
        if (window.opener.location.href != window.location.href) { //open
            //fix crossdomain
            try { window.opener.returnValue = returnValue } catch (e) { };
        }
    } catch (e) {
    }

    if (window.location.href != window.top.location.href) {//no iframe
        //dialog iframe
        $(document.body).dialogReturnValue && $(document.body).dialogReturnValue(returnValue);
    }

    //dialog iframe
    if ($(".ui-dialog-wrapper:last")[0]) {
        $(".ui-dialog-wrapper:last").find("div:first").dialogReturnValue(returnValue);
    }
} else {
    return window.returnValue;
}

}

在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值