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> ' + '<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;
}
}