- openDialog: function (options) {
- if (!options){
- return;
- }
- if (!options.url){
- return;
- }
- var defaultOptions = {
- type: 0,
- targetWindow: '',
- title: "",
- url: "",
- width: "",
- height: "",
- iconCls: '',
- showHeader: true,
- cls: '',
- borderStyle: '',
- allowResize: false,
- allowDrag: true,
- showCloseButton: true,
- showMaxButton: false,
- showModal: true,
- loadOnRefresh: false,
- onload: null, //弹出页面加载完成
- ondestroy: null //弹出页面关闭前
- };
- options = $.extend('', defaultOptions, options);
- if(options.type == 0) { //弹出自定义大小窗口
- options.width = options.width || 500;
- options.height = options.height || 400;
- } else if (options.type == 1 || options.type == 2){ //1弹出ifram窗口, //2弹出顶级全屏窗口
- options.showHeader= false;
- options.cls = 'showMaxCenter';
- options.borderStyle= 'border:0';
- options.allowDrag= false;
- options.allowResize= false;
- if(options.type == 1){
- options.targetWindow= window;
- }
- }
- if(options.url.indexOf("http") == -1) {
- options.url = ROOTPATH + options.url;
- }
- console.log(options.url);
- var win = mini.open({
- targetWindow: options.targetWindow, //页面对象。默认是顶级页面。
- url: options.url, //页面地址
- showHeader: options.showHeader, //显示头部
- title: options.title, //标题
- cls: options.cls, //样式
- borderStyle: options.borderStyle, //边框
- iconCls: options.iconCls, //标题图标
- width: options.width, //宽度
- height: options.height, //高度
- allowResize: options.allowResize, //允许尺寸调节
- allowDrag: options.allowDrag, //允许拖拽位置
- showCloseButton: options.showCloseButton, //显示关闭按钮
- showMaxButton: options.showMaxButton, //显示最大化按钮
- showModal: options.showModal, //显示遮罩
- loadOnRefresh: options.loadOnRefresh, //true每次刷新都激发onload事件
- onload: typeof options.onload === "function" ? options.onload : function() {
- var iframe = this.getIFrameEl();
- if(typeof iframe.contentWindow.setData == "function" && options.data){
- iframe.contentWindow.setData(options.data);
- }
- },
- ondestroy: typeof options.ondestroy === "function" ? options.ondestroy : function(action) {
- if(action == "ok" && typeof options.onOkClick === "function"){
- options.onOkClick()
- }
- if(action == "cancle" && typeof options.onCancleclick === "function"){
- options.onCancleclick()
- }
- if(action == "close" && typeof options.onCloseclick === "function"){
- options.onCloseclick()
- }
- }
- });
- if(options.type == 1 || options.type == 2) {
- win.max();
- }
- },
复制代码 上面是我封装的,看上去不怎么简洁,然后调用这个方法的时候窗口好像加载的慢了,该如何修改一下
|