123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245 |
- /**
- * jQuery ligerUI 1.1.9
- *
- * http://ligerui.com
- *
- * Author daomi 2012 [ gd_star@163.com ]
- *
- * 修改bug 加了一个g.iframe,放置对话框被其他的控件挡住。
- *
- */
- (function ($)
- {
- var l = $.ligerui;
- //全局事件
- $(".l-dialog-btn").live('mouseover', function ()
- {
- $(this).addClass("l-dialog-btn-over");
- }).live('mouseout', function ()
- {
- $(this).removeClass("l-dialog-btn-over");
- });
- $(".l-dialog-tc .l-dialog-close").live('mouseover', function ()
- {
- $(this).addClass("l-dialog-close-over");
- }).live('mouseout', function ()
- {
- $(this).removeClass("l-dialog-close-over");
- });
- $.ligerDialog = function ()
- {
- return l.run.call(null, "ligerDialog", arguments, { isStatic: true });
- };
- //dialog 图片文件夹的路径 预加载
- $.ligerui.DialogImagePath = "../../lib/ligerUI/skins/Aqua/images/win/";
-
- function prevImage(paths)
- {
- for (var i in paths)
- {
- $('<img />').attr('src', l.DialogImagePath + paths[i]);
- }
- }
- //prevImage(['dialog.gif', 'dialog-winbtns.gif', 'dialog-bc.gif', 'dialog-tc.gif']);
- $.ligerDefaults.DialogString = {
- titleMessage: $lang.tip.msg, //提示文本标题
- ok: $lang.button.ok,
- yes: $lang.button.yes,
- no: $lang.button.no,
- cancel: $lang.button.cancel,
- waittingMessage: $lang.tip.waiting
- };
-
- $.ligerDefaults.Dialog = {
- cls: null, //给dialog附加css class
- id: null, //给dialog附加id
- buttons: null, //按钮集合
- isDrag: true, //是否拖动
- width: 280, //宽度
- height: null, //高度,默认自适应
- content: '', //内容
- target: null, //目标对象,指定它将以appendTo()的方式载入
- url: null, //目标页url,默认以iframe的方式载入
- load: false, //是否以load()的方式加载目标页的内容
- onLoaded: null,
- type: 'none', //类型 warn、success、error、question
- left: null, //位置left
- top: null, //位置top
- modal: true, //是否模态对话框
- name: null, //创建iframe时 作为iframe的name和id
- isResize: false, // 是否调整大小
- allowClose: true, //允许关闭
- opener: null,
- timeParmName: null, //是否给URL后面加上值为new Date().getTime()的参数,如果需要指定一个参数名即可
- closeWhenEnter: null, //回车时是否关闭dialog
- isHidden: false, //关闭对话框时是否只是隐藏,还是销毁对话框
- show: true, //初始化时是否马上显示
- title: $.ligerDefaults.DialogString.titleMessage, //头部
- showMax: false, //是否显示最大化按钮
- showToggle: false, //是否显示收缩窗口按钮
- showMin: false, //是否显示最小化按钮
- slide: $.browser.msie ? false : true, //是否以动画的形式显示
- fixedType: null, //在固定的位置显示, 可以设置的值有n, e, s, w, ne, se, sw, nw
- showType: null //显示类型,可以设置为slide(固定显示时有效)
- };
- $.ligerMethos.Dialog = $.ligerMethos.Dialog || {};
- l.controls.Dialog = function (options)
- {
- l.controls.Dialog.base.constructor.call(this, null, options);
- };
- l.controls.Dialog.ligerExtend(l.core.Win, {
- __getType: function ()
- {
- return 'Dialog';
- },
- __idPrev: function ()
- {
- return 'Dialog';
- },
- _extendMethods: function ()
- {
- return $.ligerMethos.Dialog;
- },
- _render: function ()
- {
-
- var g = this, p = this.options;
- g.set(p, true);
-
- var dialog = $('<div class="l-dialog"><table class="l-dialog-table" cellpadding="0" cellspacing="0" border="0"><tbody><tr><td class="l-dialog-tl"></td><td class="l-dialog-tc"><div class="l-dialog-tc-inner"><div class="l-dialog-icon"></div><div class="l-dialog-title"></div><div class="l-dialog-winbtns"><div class="l-dialog-winbtn l-dialog-close"></div></div></div></td><td class="l-dialog-tr"></td></tr><tr><td class="l-dialog-cl"></td><td class="l-dialog-cc"><div class="l-dialog-body"><div class="l-dialog-image"></div> <div class="l-dialog-content"></div><div class="l-dialog-buttons"><div class="l-dialog-buttons-inner"></div></td><td class="l-dialog-cr"></td></tr><tr><td class="l-dialog-bl"></td><td class="l-dialog-bc"></td><td class="l-dialog-br"></td></tr></tbody></table></div>');
- $('body').append(dialog);
- var frameObj=$(".l-dialog-frame");
- if(frameObj.length==0){
- frameObj=$('<iframe frameborder="0" class="l-dialog-frame"></iframe>');
- dialog.after(frameObj);
- }
- g.iframe=frameObj;
-
-
- g.dialog = dialog;
- g.element = dialog[0];
- g.dialog.body = $(".l-dialog-body:first", g.dialog);
- g.dialog.header = $(".l-dialog-tc-inner:first", g.dialog);
- g.dialog.winbtns = $(".l-dialog-winbtns:first", g.dialog.header);
- g.dialog.buttons = $(".l-dialog-buttons:first", g.dialog);
- g.dialog.content = $(".l-dialog-content:first", g.dialog);
- g.set(p, false);
-
-
- if (p.allowClose == false) $(".l-dialog-close", g.dialog).remove();
- if (p.target || p.url || p.type == "none")
- {
- p.type = null;
- g.dialog.addClass("l-dialog-win");
- }
- if (p.cls) g.dialog.addClass(p.cls);
- if (p.id) g.dialog.attr("id", p.id);
- //设置锁定屏幕、拖动支持 和设置图片
- g.mask();
- if (p.isDrag)
- g._applyDrag();
- if (p.isResize)
- g._applyResize();
- if (p.type)
- g._setImage();
- else
- {
- $(".l-dialog-image", g.dialog).remove();
- g.dialog.content.addClass("l-dialog-content-noimage");
- }
- if (!p.show)
- {
- g.unmask();
- g.dialog.hide();
- }
- //设置主体内容
- if (p.target)
- {
- p.target.dialog = g;
- g.dialog.content.prepend(p.target);
- $(p.target).show();
- }
- else if (p.url)
- {
- if (p.timeParmName)
- {
- p.url += p.url.indexOf('?') == -1 ? "?" : "&";
- p.url += p.timeParmName + "=" + new Date().getTime();
- }
- if (p.load)
- {
- g.dialog.body.load(p.url, function ()
- {
- g._saveStatus();
- g.trigger('loaded');
- });
- }
- else
- {
- g.jiframe = $("<iframe frameborder='0'></iframe>");
- var framename = p.name ? p.name : "ligerwindow" + new Date().getTime();
- g.jiframe.attr("name", framename);
- g.jiframe.attr("id", framename);
- g.dialog.content.prepend(g.jiframe);
- g.dialog.content.addClass("l-dialog-content-nopadding");
- setTimeout(function ()
- {
- /* g.jiframe.attr("src", p.url);TODO
- g.frame = window.frames[g.jiframe.attr("name")];*/
-
- if (g.dialog.body.find(".l-dialog-loading:first").length == 0)
- g.dialog.body.append("<div class='l-dialog-loading' style='display:block;'></div>");
- var iframeloading = $(".l-dialog-loading:first", g.dialog.body);
- g.jiframe[0].dialog = g;//增加窗口对dialog对象的引用
- /*
- //可以在子窗口这样使用:
- var dialog = frameElement.dialog;
- var dialogData = dialog.get('data');//获取data参数
- dialog.set('title','新标题'); //设置标题
- dialog.close();//关闭dialog
- */
- g.jiframe.attr("src", p.url).bind('load.dialog', function ()
- {
- iframeloading.hide();
- g.trigger('loaded');
- });
- g.frame = window.frames[g.jiframe.attr("name")];
- }, 0);
- }
- }
- if (p.opener) g.dialog.opener = p.opener;
- //设置按钮
- if (p.buttons)
- {
- $(p.buttons).each(function (i, item)
- {
- var btn = $('<div class="l-dialog-btn"><div class="l-dialog-btn-l"></div><div class="l-dialog-btn-r"></div><div class="l-dialog-btn-inner"></div></div>');
- $(".l-dialog-btn-inner", btn).html(item.text);
- $(".l-dialog-buttons-inner", g.dialog.buttons).prepend(btn);
- item.width && btn.width(item.width);
- item.onclick && btn.click(function () { item.onclick(item, g, i) });
- });
- } else
- {
- g.dialog.buttons.remove();
- }
- $(".l-dialog-buttons-inner", g.dialog.buttons).append("<div class='l-clear'></div>");
- $(".l-dialog-title", g.dialog)
- .bind("selectstart", function () { return false; });
- g.dialog.click(function ()
- {
- l.win.setFront(g);
- });
- //设置事件
- $(".l-dialog-tc .l-dialog-close", g.dialog).click(function ()
- {
- if (p.isHidden)
- g.hide();
- else
- g.close();
- });
- if (!p.fixedType)
- {
- //位置初始化
- var left = 0;
- var top = 0;
- var width = p.width || g.dialog.width();
- if (p.slide == true) p.slide = 'fast';
- if (p.left != null) left = p.left;
- else p.left = left = 0.5 * ($(window).width() - width);
- if (p.top != null) top = p.top;
- else p.top = top = 0.5 * ($(window).height() - g.dialog.height()) + $(window).scrollTop() - 10;
- if (left < 0) p.left = left = 0;
- if (top < 0) p.top = top = 0;
- g.dialog.css({ left: left, top: top });
-
- g.iframe.css({ left: left, top: top,width:g.dialog.width(),height:g.dialog.height() });
- }
- g.show();
- $('body').bind('keydown.dialog', function (e)
- {
- var key = e.which;
- if (key == 13)
- {
- g.enter();
- }
- else if (key == 27)
- {
- g.esc();
- }
- });
- g._updateBtnsWidth();
- g._saveStatus();
- g._onReisze();
- },
- _borderX: 12,
- _borderY: 32,
- doMax: function (slide)
- {
- var g = this, p = this.options;
- var width = $(window).width(), height = $(window).height(), left = 0, top = 0;
- if (l.win.taskbar)
- {
- height -= l.win.taskbar.outerHeight();
- if (l.win.top) top += l.win.taskbar.outerHeight();
- }
- if (slide)
- {
- g.dialog.body.animate({ width: width - g._borderX }, p.slide);
- g.dialog.animate({ left: left, top: top }, p.slide);
- g.dialog.content.animate({ height: height - g._borderY - g.dialog.buttons.outerHeight() }, p.slide, function ()
- {
- g._onReisze();
- });
- }
- else
- {
- g.set({ width: width, height: height, left: left, top: top });
- g._onReisze();
- }
- },
- //最大化
- max: function ()
- {
- var g = this, p = this.options;
- if (g.winmax)
- {
- g.winmax.addClass("l-dialog-recover");
- g.doMax(p.slide);
- if (g.wintoggle)
- {
- if (g.wintoggle.hasClass("l-dialog-extend"))
- g.wintoggle.addClass("l-dialog-toggle-disabled l-dialog-extend-disabled");
- else
- g.wintoggle.addClass("l-dialog-toggle-disabled l-dialog-collapse-disabled");
- }
- if (g.resizable) g.resizable.set({ disabled: true });
- if (g.draggable) g.draggable.set({ disabled: true });
- g.maximum = true;
- $(window).bind('resize.dialogmax', function ()
- {
- g.doMax(false);
- });
- }
- },
- //恢复
- recover: function ()
- {
- var g = this, p = this.options;
- if (g.winmax)
- {
- g.winmax.removeClass("l-dialog-recover");
- if (p.slide)
- {
- g.dialog.body.animate({ width: g._width - g._borderX }, p.slide);
- g.dialog.animate({ left: g._left, top: g._top }, p.slide);
- g.dialog.content.animate({ height: g._height - g._borderY - g.dialog.buttons.outerHeight() }, p.slide, function ()
- {
- g._onReisze();
- });
- }
- else
- {
- g.set({ width: g._width, height: g._height, left: g._left, top: g._top });
- g._onReisze();
- }
- if (g.wintoggle)
- {
- g.wintoggle.removeClass("l-dialog-toggle-disabled l-dialog-extend-disabled l-dialog-collapse-disabled");
- }
- $(window).unbind('resize.dialogmax');
- }
- if (this.resizable) this.resizable.set({ disabled: false });
- if (g.draggable) g.draggable.set({ disabled: false });
- g.maximum = false;
- },
- //最小化
- min: function ()
- {
- var g = this, p = this.options;
- var task = l.win.getTask(this);
- if (p.slide)
- {
- g.dialog.body.animate({ width: 1 }, p.slide);
- task.y = task.offset().top + task.height();
- task.x = task.offset().left + task.width() / 2;
- g.dialog.animate({ left: task.x, top: task.y }, p.slide, function ()
- {
- g.dialog.hide();
- });
- }
- else
- {
- g.dialog.hide();
- }
- g.unmask();
- g.minimize = true;
- g.actived = false;
- },
- active: function ()
- {
- var g = this, p = this.options;
- if (g.minimize)
- {
- var width = g._width, height = g._height, left = g._left, top = g._top;
- if (g.maximum)
- {
- width = $(window).width();
- height = $(window).height();
- left = top = 0;
- if (l.win.taskbar)
- {
- height -= l.win.taskbar.outerHeight();
- if (l.win.top) top += l.win.taskbar.outerHeight();
- }
- }
- if (p.slide)
- {
- g.dialog.body.animate({ width: width - g._borderX }, p.slide);
- g.dialog.animate({ left: left, top: top }, p.slide);
- }
- else
- {
- g.set({ width: width, height: height, left: left, top: top });
- }
- }
- g.actived = true;
- g.minimize = false;
- l.win.setFront(g);
- g.show();
- },
- //展开 收缩
- toggle: function ()
- {
- var g = this, p = this.options;
- if (!g.wintoggle) return;
- if (g.wintoggle.hasClass("l-dialog-extend"))
- g.extend();
- else
- g.collapse();
- },
- //收缩
- collapse: function ()
- {
- var g = this, p = this.options;
- if (!g.wintoggle) return;
- if (p.slide)
- g.dialog.content.animate({ height: 1 }, p.slide);
- else
- g.dialog.content.height(1);
- if (this.resizable) this.resizable.set({ disabled: true });
- },
- //展开
- extend: function ()
- {
- var g = this, p = this.options;
- if (!g.wintoggle) return;
- var contentHeight = g._height - g._borderY - g.dialog.buttons.outerHeight();
- if (p.slide)
- g.dialog.content.animate({ height: contentHeight }, p.slide);
- else
- g.dialog.content.height(contentHeight);
- if (this.resizable) this.resizable.set({ disabled: false });
- },
- _updateBtnsWidth: function ()
- {
- var g = this;
- var btnscount = $(">div", g.dialog.winbtns).length;
- g.dialog.winbtns.width(22 * btnscount);
- },
- _setLeft: function (value)
- {
- if (!this.dialog) return;
- if (value != null)
- this.dialog.css({ left: value });
- },
- _setTop: function (value)
- {
- if (!this.dialog) return;
- if (value != null)
- this.dialog.css({ top: value });
- },
- _setWidth: function (value)
- {
- if (!this.dialog) return;
- if (value >= this._borderX)
- {
- this.dialog.body.width(value - this._borderX);
- }
- },
- _setHeight: function (value)
- {
- var g = this, p = this.options;
- if (!this.dialog) return;
- if (value >= this._borderY)
- {
- var height = value - this._borderY - g.dialog.buttons.outerHeight();
- g.dialog.content.height(height);
- }
- },
- _setShowMax: function (value)
- {
- var g = this, p = this.options;
- if (value)
- {
- if (!g.winmax)
- {
- g.winmax = $('<div class="l-dialog-winbtn l-dialog-max"></div>').appendTo(g.dialog.winbtns)
- .hover(function ()
- {
- if ($(this).hasClass("l-dialog-recover"))
- $(this).addClass("l-dialog-recover-over");
- else
- $(this).addClass("l-dialog-max-over");
- }, function ()
- {
- $(this).removeClass("l-dialog-max-over l-dialog-recover-over");
- }).click(function ()
- {
- if ($(this).hasClass("l-dialog-recover"))
- g.recover();
- else
- g.max();
- });
- }
- }
- else if (g.winmax)
- {
- g.winmax.remove();
- g.winmax = null;
- }
- g._updateBtnsWidth();
- },
- _setShowMin: function (value)
- {
- var g = this, p = this.options;
- if (value)
- {
- if (!g.winmin)
- {
- g.winmin = $('<div class="l-dialog-winbtn l-dialog-min"></div>').appendTo(g.dialog.winbtns)
- .hover(function ()
- {
- $(this).addClass("l-dialog-min-over");
- }, function ()
- {
- $(this).removeClass("l-dialog-min-over");
- }).click(function ()
- {
- g.min();
- });
- l.win.addTask(g);
- }
- }
- else if (g.winmin)
- {
- g.winmin.remove();
- g.winmin = null;
- }
- g._updateBtnsWidth();
- },
- _setShowToggle: function (value)
- {
- var g = this, p = this.options;
- if (value)
- {
- if (!g.wintoggle)
- {
- g.wintoggle = $('<div class="l-dialog-winbtn l-dialog-collapse"></div>').appendTo(g.dialog.winbtns)
- .hover(function ()
- {
- if ($(this).hasClass("l-dialog-toggle-disabled")) return;
- if ($(this).hasClass("l-dialog-extend"))
- $(this).addClass("l-dialog-extend-over");
- else
- $(this).addClass("l-dialog-collapse-over");
- }, function ()
- {
- $(this).removeClass("l-dialog-extend-over l-dialog-collapse-over");
- }).click(function ()
- {
- if ($(this).hasClass("l-dialog-toggle-disabled")) return;
- if (g.wintoggle.hasClass("l-dialog-extend"))
- {
- if (g.trigger('extend') == false) return;
- g.wintoggle.removeClass("l-dialog-extend");
- g.extend();
- g.trigger('extended');
- }
- else
- {
- if (g.trigger('collapse') == false) return;
- g.wintoggle.addClass("l-dialog-extend");
- g.collapse();
- g.trigger('collapseed')
- }
- });
- }
- }
- else if (g.wintoggle)
- {
- g.wintoggle.remove();
- g.wintoggle = null;
- }
- },
- //按下回车
- enter: function ()
- {
- var g = this, p = this.options;
- var isClose;
- if (p.closeWhenEnter != undefined)
- {
- isClose = p.closeWhenEnter;
- }
- else if (p.type == "warn" || p.type == "error" || p.type == "success" || p.type == "question")
- {
- isClose = true;
- }
- if (isClose)
- {
- g.close();
- }
- },
- esc: function ()
- {
- },
- _removeDialog: function ()
- {
- var g = this, p = this.options;
- if (p.showType && p.fixedType)
- {
- g.dialog.animate({ bottom: -1 * p.height }, function ()
- {
- g.dialog.remove();
- });
- } else
- {
- g.dialog.remove();
- }
- },
- close: function ()
- {
- var g = this, p = this.options;
- l.win.removeTask(this);
- g.unmask();
- g._removeDialog();
- $('body').unbind('keydown.dialog');
- g.iframe.hide();
- },
- _getVisible: function ()
- {
- return this.dialog.is(":visible");
- },
- _setUrl: function (url)
- {
- var g = this, p = this.options;
- p.url = url;
- if (p.load)
- {
- g.dialog.body.html("").load(p.url, function ()
- {
- g.trigger('loaded');
- });
- }
- else if (g.jiframe)
- {
- g.jiframe.attr("src", p.url);
- }
- },
- _setContent: function (content)
- {
- this.dialog.content.html(content);
- },
- _setTitle: function (value)
- {
- var g = this; var p = this.options;
- if (value)
- {
- $(".l-dialog-title", g.dialog).html(value);
- }
- },
- _hideDialog: function ()
- {
- var g = this, p = this.options;
- if (p.showType && p.fixedType)
- {
- g.dialog.animate({ bottom: -1 * p.height }, function ()
- {
- g.dialog.hide();
- });
- } else
- {
- g.dialog.hide();
- }
- },
- hidden: function ()
- {
- var g = this;
- l.win.removeTask(g);
- g.dialog.hide();
- g.unmask();
- g.iframe.hide();
- },
- show: function ()
- {
- var g = this, p = this.options;
- g.mask();
- if (p.fixedType)
- {
- if (p.showType)
- {
- g.dialog.css({ bottom: -1 * p.height }).addClass("l-dialog-fixed");
- g.dialog.show().animate({ bottom: 0 });
- }
- else
- {
- g.dialog.show().css({ bottom: 0 });
- }
- }
- else
- {
- g.dialog.show();
- }
- //前端显示
- $.ligerui.win.setFront.ligerDefer($.ligerui.win, 100, [g]);
- g.iframe.show();
- },
- setUrl: function (url)
- {
- this._setUrl(url);
- },
- _saveStatus: function ()
- {
- var g = this;
- g._width = g.dialog.body.width();
- g._height = g.dialog.body.height();
- var top = 0;
- var left = 0;
- if (!isNaN(parseInt(g.dialog.css('top'))))
- top = parseInt(g.dialog.css('top'));
- if (!isNaN(parseInt(g.dialog.css('left'))))
- left = parseInt(g.dialog.css('left'));
- g._top = top;
- g._left = left;
- },
- _applyDrag: function ()
- {
- var g = this, p = this.options;
- if ($.fn.ligerDrag)
- g.draggable = g.dialog.ligerDrag({ handler: '.l-dialog-title', animate: false,
- onStartDrag: function ()
- {
- l.win.setFront(g);
- },
- onStopDrag: function ()
- {
- if (p.target)
- {
- var triggers1 = l.find($.ligerui.controls.DateEditor);
- var triggers2 = l.find($.ligerui.controls.ComboBox);
- //更新所有下拉选择框的位置
- $($.merge(triggers1, triggers2)).each(function ()
- {
- if (this.updateSelectBoxPosition)
- this.updateSelectBoxPosition();
- });
- }
- g._saveStatus();
- g.iframe.css({ left: g.dialog.css("left"), top: g.dialog.css("top")});
- }
- });
- },
- _onReisze: function ()
- {
- var g = this, p = this.options;
- if (p.target)
- {
- var manager = $(p.target).liger();
- if (!manager) manager = $(p.target).find(":first").liger();
- if (!manager) return;
- var contentHeight = g.dialog.content.height();
- var contentWidth = g.dialog.content.width();
- manager.trigger('resize', [{ width: contentWidth, height: contentHeight}]);
- }
- },
- _applyResize: function ()
- {
- var g = this, p = this.options;
- if ($.fn.ligerResizable)
- {
- g.resizable = g.dialog.ligerResizable({
- onStopResize: function (current, e)
- {
- var top = 0;
- var left = 0;
- if (!isNaN(parseInt(g.dialog.css('top'))))
- top = parseInt(g.dialog.css('top'));
- if (!isNaN(parseInt(g.dialog.css('left'))))
- left = parseInt(g.dialog.css('left'));
- if (current.diffLeft)
- {
- g.set({ left: left + current.diffLeft });
- }
- if (current.diffTop)
- {
- g.set({ top: top + current.diffTop });
- }
- if (current.newWidth)
- {
- g.set({ width: current.newWidth });
- g.dialog.body.css({ width: current.newWidth - g._borderX });
- }
- if (current.newHeight)
- {
- g.set({ height: current.newHeight });
- }
- g.iframe.css({ left: left + current.diffLeft, top: top + current.diffTop,width:current.newWidth,height:current.newHeight+8});
- g._onReisze();
- g._saveStatus();
- return false;
- }, animate: false
- });
- }
- },
- _setImage: function ()
- {
- var g = this, p = this.options;
- if (p.type)
- {
- if (p.type == 'success' || p.type == 'donne' || p.type == 'ok')
- {
- $(".l-dialog-image", g.dialog).addClass("l-dialog-image-donne").show();
- g.dialog.content.css({ paddingLeft: 64, paddingBottom: 30 });
- }
- else if (p.type == 'error')
- {
- $(".l-dialog-image", g.dialog).addClass("l-dialog-image-error").show();
- g.dialog.content.css({ paddingLeft: 64, paddingBottom: 30 });
- g.dialog.buttons.css({paddingTop:2,paddingBottom:2});
- }
- else if (p.type == 'warn')
- {
- $(".l-dialog-image", g.dialog).addClass("l-dialog-image-warn").show();
- g.dialog.content.css({ paddingLeft: 64, paddingBottom: 30 });
- g.dialog.buttons.css({paddingTop:2,paddingBottom:2});
- }
- else if (p.type == 'question')
- {
- $(".l-dialog-image", g.dialog).addClass("l-dialog-image-question").show();
- g.dialog.content.css({ paddingLeft: 64, paddingBottom: 40 });
- }else if (p.type == 'confirm')
- {
- $(".l-dialog-image", g.dialog).addClass("l-dialog-image-question").show();
- g.dialog.content.css({ paddingLeft: 64, paddingBottom: 30 });
- g.dialog.buttons.css({paddingTop:2,paddingBottom:2});
- }
- }
- }
- });
- l.controls.Dialog.prototype.hide = l.controls.Dialog.prototype.hidden;
- $.ligerDialog.open = function (p)
- {
- return $.ligerDialog(p);
- };
- $.ligerDialog.close = function ()
- {
- var dialogs = l.find(l.controls.Dialog.prototype.__getType());
- for (var i in dialogs)
- {
- var d = dialogs[i];
- d.destroy.ligerDefer(d, 5);
- }
- l.win.unmask();
- };
- $.ligerDialog.show = function (p)
- {
- var dialogs = l.find(l.controls.Dialog.prototype.__getType());
- if (dialogs.length)
- {
- for (var i in dialogs)
- {
- dialogs[i].show();
- return;
- }
- }
- return $.ligerDialog(p);
- };
- $.ligerDialog.hide = function ()
- {
- var dialogs = l.find(l.controls.Dialog.prototype.__getType());
- for (var i in dialogs)
- {
- var d = dialogs[i];
- d.hide();
- }
- };
- $.ligerDialog.tip = function (options)
- {
- options = $.extend({
- showType: 'slide',
- width: 240,
- modal: false,
- height: 100
- }, options || {});
- $.extend(options, {
- fixedType: 'se',
- type: 'none',
- isDrag: false,
- isResize: false,
- showMax: false,
- showToggle: false,
- showMin: false
- });
- return $.ligerDialog.open(options);
- };
- $.ligerDialog.alert = function (content, title, type, callback,width,height)
- {
- content = content || "";
- if (typeof (title) == "function")
- {
- callback = title;
- type = null;
- }
- else if (typeof (type) == "function")
- {
- callback = type;
- }
- var btnclick = function (item, Dialog, index)
- {
- Dialog.close();
- if (callback)
- callback(item, Dialog, index);
- };
- p = {
- content: content,
- buttons: [{ text: $.ligerDefaults.DialogString.ok, onclick: btnclick}]
- };
- if(width){
- p.width=width;
- }
- if(height){
- p.height=height;
- }
- if (typeof (title) == "string" && title != "") p.title = title;
- if (typeof (type) == "string" && type != "") p.type = type;
- $.extend(p, {
- showMax: false,
- showToggle: false,
- showMin: false
- });
- try {
-
- document.activeElement.blur();
- } catch (e) {
- // TODO: handle exception
- }
- return $.ligerDialog(p);
- };
- $.ligerDialog.confirm = function (content, title, callback)
- {
- if (typeof (title) == "function")
- {
- callback = title;
- type = null;
- }
- var btnclick = function (item, Dialog)
- {
- Dialog.close();
- if (callback)
- {
- callback(item.type == 'ok');
- }
- };
- p = {
- type: 'question',
- content: content,
- buttons: [{ text: $.ligerDefaults.DialogString.yes, onclick: btnclick, type: 'ok' }, { text: $.ligerDefaults.DialogString.no, onclick: btnclick, type: 'no'}]
- };
- if (typeof (title) == "string" && title != "") p.title = title;
- $.extend(p, {
- showMax: false,
- showToggle: false,
- showMin: false
- });
- return $.ligerDialog(p);
- };
- $.ligerDialog.confirmEx = function (content, title, callback,DialogStringExt, width, height)
- {
- if (typeof (title) == "function")
- {
- callback = title;
- type = null;
- }
- var btnclick = function (item, Dialog)
- {
- Dialog.close();
- if (callback)
- {
- callback(item.type == 'ok');
- }
- };
- if(DialogStringExt){//国际化
- $.ligerDefaults.DialogString=DialogStringExt;
- }
- p = {
- type: 'confirm',
- content: content,
- buttons: [{ text: $.ligerDefaults.DialogString.yes, onclick: btnclick, type: 'ok' }, { text: $.ligerDefaults.DialogString.no, onclick: btnclick, type: 'no'}]
- };
- if(width){
- p.width=width;
- }
- if(height){
- p.height=height;
- }
- if (typeof (title) == "string" && title != "") p.title = title;
- $.extend(p, {
- allowClose: false, //不允许关闭
- showMax: false,
- showToggle: false,
- showMin: false
- });
- return $.ligerDialog(p);
- };
- $.ligerDialog.warning = function (content, title, callback)
- {
- if (typeof (title) == "function")
- {
- callback = title;
- type = null;
- }
- var btnclick = function (item, Dialog)
- {
- Dialog.close();
- if (callback)
- {
- callback(item.type);
- }
- };
- p = {
- type: 'question',
- content: content,
- buttons: [{ text: $.ligerDefaults.DialogString.yes, onclick: btnclick, type: 'yes' }, { text: $.ligerDefaults.DialogString.no, onclick: btnclick, type: 'no' }, { text: $.ligerDefaults.DialogString.cancel, onclick: btnclick, type: 'cancel'}]
- };
- if (typeof (title) == "string" && title != "") p.title = title;
- $.extend(p, {
- showMax: false,
- showToggle: false,
- showMin: false
- });
- return $.ligerDialog(p);
- };
- $.ligerDialog.waitting = function (title)
- {
- title = title || $.ligerDefaults.Dialog.waittingMessage;
- return $.ligerDialog.open({ cls: 'l-dialog-waittingdialog', type: 'none', content: '<div style="padding:4px">' + title + '</div>', allowClose: false });
- };
- $.ligerDialog.closeWaitting = function ()
- {
- var dialogs = l.find(l.controls.Dialog);
- for (var i in dialogs)
- {
- var d = dialogs[i];
- if(d && d.iframe){
- d.iframe.remove();
- }
- // $(".l-window-mask").remove();
-
-
- if (d.dialog.hasClass("l-dialog-waittingdialog"))
- d.close();
- }
- };
- $.ligerDialog.success = function (content, title, onBtnClick)
- {
- return $.ligerDialog.alert(content, title, 'success', onBtnClick);
- };
- $.ligerDialog.error = function (content, title, onBtnClick)
- {
- return $.ligerDialog.alert(content, title, 'error', onBtnClick);
- };
-
- $.ligerDialog.err = function (title,msg,detail, onBtnClick){
-
- var divTemplate="<div class='div_error' ><div class='div_error_msg'>{0}</div>" +
- "<div style='text-align:left; padding-bottom:10px; padding-left:10px;'></div>" +
- "<textarea class='div_error_detail'>{1}</textarea>" +
- "</div>";
- var content=String.format(divTemplate,msg,detail);
-
- //这里要把它提到首页,获取到outerWindow最外层的window
- var outerWindow =window.top;
-
- var obj= outerWindow.$.ligerDialog.alert(content, title, 'error', onBtnClick,420,220);
-
- return obj;
- };
-
- //成功提示窗口。
- $.ligerDialog.successExt = function (title,msg,detail,onBtnClick)
- {
- var divTemplate="<div class='div_error'><div class='div_success_msg'>{0}</div><div class='div_success_detail'>{1}</div></div>";
- var content= String.format(divTemplate,msg,detail);
- var obj= $.ligerDialog.alert(content, title, 'success', onBtnClick,380,160);
- return obj;
- };
-
- //提示窗口(导入导出专用)
- $.ligerDialog.tipDialog = function (title,msg,detail,type,onBtnClick)
- {
- var divTemplate="<div class='div_error'><div class='div_toggle'>{0}</div><div class='div_tipdialog_detail'>{1}</div></div>";
- var content= String.format(divTemplate,msg,detail);
- var obj= $.ligerDialog.open({
- width: 380,
- type:type?'warn':type,
- title:title,
- content: content,
- buttons: [{ text: $.ligerDefaults.DialogString.ok, onclick: function(item, Dialog){
- if(onBtnClick){
- onBtnClick.call(this);
- }
- else{
- Dialog.close();
- }
- } }]
- });
-
- $(".div_toggle").click(function(){
- var visible= $(".div_tipdialog_detail").css("display");
- if(visible=="none"){
- $(".div_tipdialog_detail").css("display","block");
- $(".div_toggle").addClass("div_toggle_down");
- }
- else{
- $(".div_tipdialog_detail").css("display","none");
- $(".div_toggle").removeClass("div_toggle_down");
- }
- });
-
- return obj;
- };
-
- $.ligerDialog.warn = function (content, title, onBtnClick)
- {
- return $.ligerDialog.alert(content, title, 'warn', onBtnClick);
- };
- $.ligerDialog.question = function (content, title)
- {
- return $.ligerDialog.alert(content, title, 'question');
- };
- $.ligerDialog.prompt = function (title, value, multi, callback)
- {
- var target = $('<input type="text" class="l-dialog-inputtext"/>');
- if (typeof (multi) == "function")
- {
- callback = multi;
- }
- if (typeof (value) == "function")
- {
- callback = value;
- }
- else if (typeof (value) == "boolean")
- {
- multi = value;
- }
- if (typeof (multi) == "boolean" && multi)
- {
- target = $('<textarea class="l-dialog-textarea"></textarea>');
- }
- if (typeof (value) == "string" || typeof (value) == "int")
- {
- target.val(value);
- }
- var btnclick = function (item, Dialog, index)
- {
- Dialog.close();
- if (callback)
- {
- callback(item.type == 'yes', target.val());
- }
- }
- p = {
- title: title,
- target: target,
- width: 320,
- buttons: [{ text: $.ligerDefaults.DialogString.ok, onclick: btnclick, type: 'yes' }, { text: $.ligerDefaults.DialogString.cancel, onclick: btnclick, type: 'cancel'}]
- };
- return $.ligerDialog(p);
- };
- //扩展没有关闭按钮
- $.ligerDialog.alertExt = function (content, title, type, callback,DialogStringExt, width, height)
- {
- content = content || "";
- if (typeof (title) == "function")
- {
- callback = title;
- type = null;
- }
- else if (typeof (type) == "function")
- {
- callback = type;
- }
- var btnclick = function (item, Dialog, index)
- {
- Dialog.close();
- if (callback)
- callback(item, Dialog, index);
- };
- if(DialogStringExt){//国际化
- $.ligerDefaults.DialogString=DialogStringExt;
- }
- p = {
- content: content,
- buttons: [{ text: $.ligerDefaults.DialogString.ok, onclick: btnclick}]
- };
- if(width){
- p.width=width;
- }
- if(height){
- p.height=height;
- }
- if (typeof (title) == "string" && title != "") p.title = title;
- if (typeof (type) == "string" && type != "") p.type = type;
- $.extend(p, {
- allowClose: false, //不允许关闭
- showMax: false,
- showToggle: false,
- showMin: false
- });
- return $.ligerDialog(p);
- };
- })(jQuery);
|