123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725 |
- /*! artDialog v6.0.5 | https://github.com/aui/artDialog */
- !(function () {
- var __modules__ = {};
- function require (id) {
- var mod = __modules__[id];
- var exports = 'exports';
- if (typeof mod === 'object') {
- return mod;
- }
- if (!mod[exports]) {
- mod[exports] = {};
- mod[exports] = mod.call(mod[exports], require, mod[exports], mod) || mod[exports];
- }
- return mod[exports];
- }
- function define (path, fn) {
- __modules__[path] = fn;
- }
- define("jquery", function () {
- return jQuery;
- });
- /*!
- * PopupJS
- * Date: 2014-11-09
- * https://github.com/aui/popupjs
- * (c) 2009-2014 TangBin, http://www.planeArt.cn
- *
- * This is licensed under the GNU LGPL, version 2.1 or later.
- * For details, see: http://www.gnu.org/licenses/lgpl-2.1.html
- */
- define("popup", function (require) {
- var $ = require("jquery");
- var _count = 0;
- var _isIE6 = !('minWidth' in $('html')[0].style);
- var _isFixed = !_isIE6;
- function Popup () {
- this.destroyed = false;
- this.__popup = $('<div />')
- /*使用 <dialog /> 元素可能导致 z-index 永远置顶的问题(chrome)*/
- .css({
- display: 'none',
- position: 'absolute',
- /*
- left: 0,
- top: 0,
- bottom: 'auto',
- right: 'auto',
- margin: 0,
- padding: 0,
- border: '0 none',
- background: 'transparent'
- */
- outline: 0
- })
- .attr('tabindex', '-1')
- .html(this.innerHTML)
- .appendTo('body');
- this.__backdrop = this.__mask = $('<div />')
- .css({
- opacity: .7,
- background: '#000'
- });
- // 使用 HTMLElement 作为外部接口使用,而不是 jquery 对象
- // 统一的接口利于未来 Popup 移植到其他 DOM 库中
- this.node = this.__popup[0];
- this.backdrop = this.__backdrop[0];
- _count ++;
- }
- $.extend(Popup.prototype, {
-
- /**
- * 初始化完毕事件,在 show()、showModal() 执行
- * @name Popup.prototype.onshow
- * @event
- */
- /**
- * 关闭事件,在 close() 执行
- * @name Popup.prototype.onclose
- * @event
- */
- /**
- * 销毁前事件,在 remove() 前执行
- * @name Popup.prototype.onbeforeremove
- * @event
- */
- /**
- * 销毁事件,在 remove() 执行
- * @name Popup.prototype.onremove
- * @event
- */
- /**
- * 重置事件,在 reset() 执行
- * @name Popup.prototype.onreset
- * @event
- */
- /**
- * 焦点事件,在 foucs() 执行
- * @name Popup.prototype.onfocus
- * @event
- */
- /**
- * 失焦事件,在 blur() 执行
- * @name Popup.prototype.onblur
- * @event
- */
- /** 浮层 DOM 素节点[*] */
- node: null,
- /** 遮罩 DOM 节点[*] */
- backdrop: null,
- /** 是否开启固定定位[*] */
- fixed: true,
- /** 判断对话框是否删除[*] */
- destroyed: true,
- /** 判断对话框是否显示 */
- open: false,
- /** close 返回值 */
- returnValue: '',
- /** 是否自动聚焦 */
- autofocus: true,
- /** 对齐方式[*] */
- align: 'bottom left',
- /** 内部的 HTML 字符串 */
- innerHTML: '',
- /** CSS 类名 */
- className: 'ui-popup',
- /**
- * 显示浮层
- * @param {HTMLElement, Event} 指定位置(可选)
- */
- show: function (anchor) {
- if (this.destroyed) {
- return this;
- }
- var that = this;
- var popup = this.__popup;
- var backdrop = this.__backdrop;
- this.__activeElement = this.__getActive();
- this.open = true;
- this.follow = anchor || this.follow;
- // 初始化 show 方法
- if (!this.__ready) {
- popup
- .addClass(this.className)
- .attr('role', this.modal ? 'alertdialog' : 'dialog')
- .css('position', this.fixed ? 'fixed' : 'absolute');
- if (!_isIE6) {
- $(window).on('resize', $.proxy(this.reset, this));
- }
- // 模态浮层的遮罩
- if (this.modal) {
- var backdropCss = {
- position: 'fixed',
- left: 0,
- top: 0,
- width: '100%',
- height: '100%',
- overflow: 'hidden',
- userSelect: 'none',
- zIndex: this.zIndex || Popup.zIndex
- };
- popup.addClass(this.className + '-modal');
- if (!_isFixed) {
- $.extend(backdropCss, {
- position: 'absolute',
- width: $(window).width() + 'px',
- height: $(document).height() + 'px'
- });
- }
- backdrop
- .css(backdropCss)
- .attr({tabindex: '0'})
- .on('focus', $.proxy(this.focus, this));
- // 锁定 tab 的焦点操作
- this.__mask = backdrop
- .clone(true)
- .attr('style', '')
- .insertAfter(popup);
- backdrop
- .addClass(this.className + '-backdrop')
- .insertBefore(popup);
- this.__ready = true;
- }
- if (!popup.html()) {
- popup.html(this.innerHTML);
- }
- }
- popup
- .addClass(this.className + '-show')
- .show();
- backdrop.show();
- this.reset().focus();
- this.__dispatchEvent('show');
- return this;
- },
- /** 显示模态浮层。参数参见 show() */
- showModal: function () {
- this.modal = true;
- return this.show.apply(this, arguments);
- },
-
-
- /** 关闭浮层 */
- close: function (result) {
-
- if (!this.destroyed && this.open) {
-
- if (result !== undefined) {
- this.returnValue = result;
- }
-
- this.__popup.hide().removeClass(this.className + '-show');
- this.__backdrop.hide();
- this.open = false;
- this.blur();// 恢复焦点,照顾键盘操作的用户
- this.__dispatchEvent('close');
- }
-
- return this;
- },
- /** 销毁浮层 */
- remove: function () {
- if (this.destroyed) {
- return this;
- }
- this.__dispatchEvent('beforeremove');
-
- if (Popup.current === this) {
- Popup.current = null;
- }
- // 从 DOM 中移除节点
- this.__popup.remove();
- this.__backdrop.remove();
- this.__mask.remove();
- if (!_isIE6) {
- $(window).off('resize', this.reset);
- }
- this.__dispatchEvent('remove');
- for (var i in this) {
- delete this[i];
- }
- return this;
- },
- /** 重置位置 */
- reset: function () {
- var elem = this.follow;
- if (elem) {
- this.__follow(elem);
- } else {
- this.__center();
- }
- this.__dispatchEvent('reset');
- return this;
- },
- /** 让浮层获取焦点 */
- focus: function () {
- var node = this.node;
- var popup = this.__popup;
- var current = Popup.current;
- var index = this.zIndex = Popup.zIndex ++;
- if (current && current !== this) {
- current.blur(false);
- }
- // 检查焦点是否在浮层里面
- if (!$.contains(node, this.__getActive())) {
- var autofocus = popup.find('[autofocus]')[0];
- if (!this._autofocus && autofocus) {
- this._autofocus = true;
- } else {
- autofocus = node;
- }
- this.__focus(autofocus);
- }
- // 设置叠加高度
- popup.css('zIndex', index);
- //this.__backdrop.css('zIndex', index);
- Popup.current = this;
- popup.addClass(this.className + '-focus');
- this.__dispatchEvent('focus');
- return this;
- },
- /** 让浮层失去焦点。将焦点退还给之前的元素,照顾视力障碍用户 */
- blur: function () {
- var activeElement = this.__activeElement;
- var isBlur = arguments[0];
- if (isBlur !== false) {
- this.__focus(activeElement);
- }
- this._autofocus = false;
- this.__popup.removeClass(this.className + '-focus');
- this.__dispatchEvent('blur');
- return this;
- },
- /**
- * 添加事件
- * @param {String} 事件类型
- * @param {Function} 监听函数
- */
- addEventListener: function (type, callback) {
- this.__getEventListener(type).push(callback);
- return this;
- },
- /**
- * 删除事件
- * @param {String} 事件类型
- * @param {Function} 监听函数
- */
- removeEventListener: function (type, callback) {
- var listeners = this.__getEventListener(type);
- for (var i = 0; i < listeners.length; i ++) {
- if (callback === listeners[i]) {
- listeners.splice(i--, 1);
- }
- }
- return this;
- },
- // 获取事件缓存
- __getEventListener: function (type) {
- var listener = this.__listener;
- if (!listener) {
- listener = this.__listener = {};
- }
- if (!listener[type]) {
- listener[type] = [];
- }
- return listener[type];
- },
- // 派发事件
- __dispatchEvent: function (type) {
- var listeners = this.__getEventListener(type);
- if (this['on' + type]) {
- this['on' + type]();
- }
- for (var i = 0; i < listeners.length; i ++) {
- listeners[i].call(this);
- }
- },
- // 对元素安全聚焦
- __focus: function (elem) {
- // 防止 iframe 跨域无权限报错
- // 防止 IE 不可见元素报错
- try {
- // ie11 bug: iframe 页面点击会跳到顶部
- if (this.autofocus && !/^iframe$/i.test(elem.nodeName)) {
- elem.focus();
- }
- } catch (e) {}
- },
- // 获取当前焦点的元素
- __getActive: function () {
- try {// try: ie8~9, iframe #26
- var activeElement = document.activeElement;
- var contentDocument = activeElement.contentDocument;
- var elem = contentDocument && contentDocument.activeElement || activeElement;
- return elem;
- } catch (e) {}
- },
- // 居中浮层
- __center: function () {
-
- var popup = this.__popup;
- var $window = $(window);
- var $document = $(document);
- var fixed = this.fixed;
- var dl = fixed ? 0 : $document.scrollLeft();
- var dt = fixed ? 0 : $document.scrollTop();
- var ww = $window.width();
- var wh = $window.height();
- var ow = popup.width();
- var oh = popup.height();
- var left = (ww - ow) / 2 + dl;
- var top = (wh - oh) * 382 / 1000 + dt;// 黄金比例
- var style = popup[0].style;
-
- style.left = Math.max(parseInt(left), dl) + 'px';
- style.top = Math.max(parseInt(top), dt) + 'px';
- if(this.__browser.versions.ios){
- style.top = '45%';
- style.position = 'fixed';
- style.marginTop = '-'+(popup.outerHeight(true)/2)+'px';
- }
- },
-
- __browser : {
- versions:function(){
- var u = navigator.userAgent, app = navigator.appVersion;
- return { //移动终端浏览器版本信息
- trident: u.indexOf('Trident') > -1, //IE内核
- presto: u.indexOf('Presto') > -1, //opera内核
- webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
- gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
- mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
- ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
- android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或uc浏览器
- iPhone: u.indexOf('iPhone') > -1 , //是否为iPhone或者QQHD浏览器
- iPad: u.indexOf('iPad') > -1, //是否iPad
- webApp: u.indexOf('Safari') == -1 //是否web应该程序,没有头部与底部
- };
- }(),
- language:(navigator.browserLanguage || navigator.language).toLowerCase()
- },
-
- // 指定位置 @param {HTMLElement, Event} anchor
- __follow: function (anchor) {
-
- var $elem = anchor.parentNode && $(anchor);
- var popup = this.__popup;
-
- if (this.__followSkin) {
- popup.removeClass(this.__followSkin);
- }
- // 隐藏元素不可用
- if ($elem) {
- var o = $elem.offset();
- if (o.left * o.top < 0) {
- return this.__center();
- }
- }
-
- var that = this;
- var fixed = this.fixed;
- var $window = $(window);
- var $document = $(document);
- var winWidth = $window.width();
- var winHeight = $window.height();
- var docLeft = $document.scrollLeft();
- var docTop = $document.scrollTop();
- var popupWidth = popup.width();
- var popupHeight = popup.height();
- var width = $elem ? $elem.outerWidth() : 0;
- var height = $elem ? $elem.outerHeight() : 0;
- var offset = this.__offset(anchor);
- var x = offset.left;
- var y = offset.top;
- var left = fixed ? x - docLeft : x;
- var top = fixed ? y - docTop : y;
- var minLeft = fixed ? 0 : docLeft;
- var minTop = fixed ? 0 : docTop;
- var maxLeft = minLeft + winWidth - popupWidth;
- var maxTop = minTop + winHeight - popupHeight;
- var css = {};
- var align = this.align.split(' ');
- var className = this.className + '-';
- var reverse = {top: 'bottom', bottom: 'top', left: 'right', right: 'left'};
- var name = {top: 'top', bottom: 'top', left: 'left', right: 'left'};
- var temp = [{
- top: top - popupHeight,
- bottom: top + height,
- left: left - popupWidth,
- right: left + width
- }, {
- top: top,
- bottom: top - popupHeight + height,
- left: left,
- right: left - popupWidth + width
- }];
- var center = {
- left: left + width / 2 - popupWidth / 2,
- top: top + height / 2 - popupHeight / 2
- };
-
- var range = {
- left: [minLeft, maxLeft],
- top: [minTop, maxTop]
- };
- // 超出可视区域重新适应位置
- $.each(align, function (i, val) {
- // 超出右或下边界:使用左或者上边对齐
- if (temp[i][val] > range[name[val]][1]) {
- val = align[i] = reverse[val];
- }
- // 超出左或右边界:使用右或者下边对齐
- if (temp[i][val] < range[name[val]][0]) {
- align[i] = reverse[val];
- }
- });
- // 一个参数的情况
- if (!align[1]) {
- name[align[1]] = name[align[0]] === 'left' ? 'top' : 'left';
- temp[1][align[1]] = center[name[align[1]]];
- }
- //添加follow的css, 为了给css使用
- className += align.join('-') + ' '+ this.className+ '-follow';
-
- that.__followSkin = className;
- if ($elem) {
- popup.addClass(className);
- }
-
- css[name[align[0]]] = parseInt(temp[0][align[0]]);
- css[name[align[1]]] = parseInt(temp[1][align[1]]);
- popup.css(css);
- },
- // 获取元素相对于页面的位置(包括iframe内的元素)
- // 暂时不支持两层以上的 iframe 套嵌
- __offset: function (anchor) {
- var isNode = anchor.parentNode;
- var offset = isNode ? $(anchor).offset() : {
- left: anchor.pageX,
- top: anchor.pageY
- };
- anchor = isNode ? anchor : anchor.target;
- var ownerDocument = anchor.ownerDocument;
- var defaultView = ownerDocument.defaultView || ownerDocument.parentWindow;
-
- if (defaultView == window) {// IE <= 8 只能使用两个等于号
- return offset;
- }
- // {Element: Ifarme}
- var frameElement = defaultView.frameElement;
- var $ownerDocument = $(ownerDocument);
- var docLeft = $ownerDocument.scrollLeft();
- var docTop = $ownerDocument.scrollTop();
- var frameOffset = $(frameElement).offset();
- var frameLeft = frameOffset.left;
- var frameTop = frameOffset.top;
-
- return {
- left: offset.left + frameLeft - docLeft,
- top: offset.top + frameTop - docTop
- };
- }
-
- });
- /** 当前叠加高度 */
- Popup.zIndex = 1024;
- /** 顶层浮层的实例 */
- Popup.current = null;
- return Popup;
- });
- // artDialog - 默认配置
- define("dialog-config", {
- /* -----已注释的配置继承自 popup.js,仍可以再这里重新定义它----- */
- // 对齐方式
- //align: 'bottom left',
-
- // 是否固定定位
- fixed: true,
-
- // 对话框叠加高度值(重要:此值不能超过浏览器最大限制)
- zIndex: 3000,
- // 设置遮罩背景颜色
- backdropBackground: '#000',
- // 设置遮罩透明度
- backdropOpacity: 0.7,
- // 消息内容
- content: '',
-
- // 消息内容类型
- contentType: '', // load, jsonload
-
- // 自动关闭时间
- closeTime: 3000,
-
- // 标题
- title: '',
- // 对话框状态栏区域 HTML 代码
- statusbar: '',
-
- // 自定义按钮
- button: null,
-
- // 确定按钮回调函数
- ok: null,
-
- // 取消按钮回调函数
- cancel: null,
- // 确定按钮文本
- okValue: '\u786e\u5b9a',
-
- // 取消按钮文本
- cancelValue: '\u53d6\u6d88',
- cancelDisplay: true,
-
- // 内容宽度
- width: '',
-
- // 内容高度
- height: '',
-
- // 内容与边界填充距离
- padding: '',
-
- // 标题填充距离
- titlePadding:'',
-
- // 内容为块级元素
- contentBlock:false,
-
- // 对话框自定义 className
- skin: 'ax-popup',
- // 对话框最外层自定义 className
- boxSkin: 'ui-popup-full fat-title',
- // 是否支持快捷关闭(点击遮罩层自动关闭)
- quickClose: false,
- // css 文件路径,留空则不会使用 js 自动加载样式
- // 注意:css 只允许加载一个
- cssUri: '',
- // 模板(使用 table 解决 IE7 宽度自适应的 BUG)
- // js 使用 i="***" 属性识别结构,其余的均可自定义
- innerHTML:
- '<div i="dialog" class="ui-dialog">'
- + '<div class="ui-dialog-arrow-a"></div>'
- + '<div class="ui-dialog-arrow-b"></div>'
- + '<table class="ui-dialog-grid">'
- + '<tr>'
- + '<td i="header" class="ui-dialog-header">'
- + '<button i="close" class="ui-dialog-close">×</button>'
- + '<div i="title" class="ui-dialog-title"></div>'
- + '</td>'
- + '</tr>'
- + '<tr>'
- + '<td i="body" class="ui-dialog-body">'
- + '<div i="content" class="ui-dialog-content"></div>'
- + '</td>'
- + '</tr>'
- + '<tr>'
- + '<td i="footer" class="ui-dialog-footer">'
- + '<div i="statusbar" class="ui-dialog-statusbar"></div>'
- + '<div i="button" class="ui-dialog-button"></div>'
- + '</td>'
- + '</tr>'
- + '</table>'
- +'</div>'
-
- });
- /*!
- * artDialog
- * Date: 2014-11-09
- * https://github.com/aui/artDialog
- * (c) 2009-2014 TangBin, http://www.planeArt.cn
- *
- * This is licensed under the GNU LGPL, version 2.1 or later.
- * For details, see: http://www.gnu.org/licenses/lgpl-2.1.html
- */
- define("dialog", function (require) {
- var $ = require("jquery");
- var Popup = require("popup");
- var defaults = require("dialog-config");
- var css = defaults.cssUri;
- // css loader: RequireJS & SeaJS
- if (css) {
- var fn = require[require.toUrl ? 'toUrl' : 'resolve'];
- if (fn) {
- css = fn(css);
- css = '<link rel="stylesheet" href="' + css + '" />';
- if ($('base')[0]) {
- $('base').before(css);
- } else {
- $('head').append(css);
- }
- }
- }
- var _count = 0;
- var _expando = new Date() - 0; // Date.now()
- var _isIE6 = !('minWidth' in $('html')[0].style);
- var _isMobile = 'createTouch' in document && !('onmousemove' in document)
- || /(iPhone|iPad|iPod)/i.test(navigator.userAgent);
- var _isFixed = !_isIE6 && !_isMobile;
- var artDialog = function (options, ok, cancel) {
- var originalOptions = options = options || {};
-
- if (typeof options === 'string' || options.nodeType === 1) {
-
- options = {content: options, fixed: !_isMobile};
- }
-
- options = $.extend(true, {}, artDialog.defaults, options);
- options.original = originalOptions;
- var id = options.id = options.id || _expando + _count;
- var api = artDialog.get(id);
-
-
- // 如果存在同名的对话框对象,则直接返回
- if (api) {
- return api.focus();
- }
-
-
- // 目前主流移动设备对fixed支持不好,禁用此特性
- if (!_isFixed) {
- options.fixed = false;
- }
- // 快捷关闭支持:点击对话框外快速关闭对话框
- if (options.quickClose) {
- options.modal = true;
- options.backdropOpacity = .5;
- }
-
- // 按钮组
- if (!$.isArray(options.button)) {
- options.button = [];
- }
- // 取消按钮
- if (cancel !== undefined) {
- options.cancel = cancel;
- }
-
- if (options.cancel) {
- options.button.push({
- id: 'cancel',
- value: options.cancelValue,
- callback: options.cancel,
- display: options.cancelDisplay
- });
- }
-
-
- // 确定按钮
- if (ok !== undefined) {
- options.ok = ok;
- }
-
- if (options.ok) {
- options.button.push({
- id: 'ok',
- value: options.okValue,
- callback: options.ok,
- autofocus: true
- });
- }
-
- return artDialog.list[id] = new artDialog.create(options);
- };
- var popup = function () {};
- popup.prototype = Popup.prototype;
- var prototype = artDialog.prototype = new popup();
- artDialog.create = function (options) {
- var that = this;
- $.extend(this, new Popup());
- var originalOptions = options.original;
- var $popup = $(this.node).html(options.innerHTML);
- var $backdrop = $(this.backdrop);
- this.options = options;
- this._popup = $popup;
-
- $.each(options, function (name, value) {
- if (typeof that[name] === 'function') {
- that[name](value);
- } else {
- that[name] = value;
- }
- });
- // 更新 zIndex 全局配置
- if (options.zIndex) {
- Popup.zIndex = options.zIndex;
- }
- // 设置 ARIA 信息
- $popup.attr({
- 'aria-labelledby': this._$('title')
- .attr('id', 'title:' + this.id).attr('id'),
- 'aria-describedby': this._$('content')
- .attr('id', 'content:' + this.id).attr('id')
- });
- // 关闭按钮
- this._$('close')
- .css('display', this.cancel === false ? 'none' : '')
- .attr('title', this.cancelValue)
- .on('click', function (event) {
- that._trigger('cancel');
- event.preventDefault();
- });
-
- // 添加视觉参数
- if(this.contentType!=''){
- this.boxSkin='';
- if(this.skin=="bk-popup"){
- this.skin='bk-popup smallTips';
- }else{
- this.skin='smallTips';
- }
-
- }
- this._$('dialog').addClass(this.skin);
- $popup.addClass(this.boxSkin);
- this._$('body').css('padding', this.padding);
- this._$('title').css('padding', this.titlePadding);
- if(this.contentBlock){
- this._$('content').css('display', 'block');
- }
- // 点击任意空白处关闭对话框
- if (options.quickClose) {
- $backdrop
- .on(
- 'onmousedown' in document ? 'mousedown' : 'click',
- function () {
- that._trigger('cancel');
- return false;// 阻止抢夺焦点
- });
- }
- // 遮罩设置
- this.addEventListener('show', function () {
- $backdrop.css({opacity: options.backdropOpacity,background: options.backdropBackground});
- /*$backdrop.css({ 小米4 APP壳不能有动画过程
- opacity: 0,
- background: options.backdropBackground
- }).animate(
- {opacity: options.backdropOpacity}
- , 150);*/
- });
- // ESC 快捷键关闭对话框
- this._esc = function (event) {
- var target = event.target;
- var nodeName = target.nodeName;
- var rinput = /^input|textarea$/i;
- var isTop = Popup.current === that;
- var keyCode = event.keyCode;
- // 避免输入状态中 ESC 误操作关闭
- if (!isTop || rinput.test(nodeName) && target.type !== 'button') {
- return;
- }
-
- if (keyCode === 27) {
- that._trigger('cancel');
- }
- };
- $(document).on('keydown', this._esc);
- this.addEventListener('remove', function () {
- $(document).off('keydown', this._esc);
- delete artDialog.list[this.id];
- });
- _count ++;
-
- artDialog.oncreate(this);
- return this;
- };
- artDialog.create.prototype = prototype;
- $.extend(prototype, {
- /**
- * 显示对话框
- * @name artDialog.prototype.show
- * @param {HTMLElement Object, Event Object} 指定位置(可选)
- */
-
- /**
- * 显示对话框(模态)
- * @name artDialog.prototype.showModal
- * @param {HTMLElement Object, Event Object} 指定位置(可选)
- */
- /**
- * 关闭对话框
- * @name artDialog.prototype.close
- * @param {String, Number} 返回值,可被 onclose 事件收取(可选)
- */
- /**
- * 销毁对话框
- * @name artDialog.prototype.remove
- */
- /**
- * 重置对话框位置
- * @name artDialog.prototype.reset
- */
- /**
- * 让对话框聚焦(同时置顶)
- * @name artDialog.prototype.focus
- */
- /**
- * 让对话框失焦(同时置顶)
- * @name artDialog.prototype.blur
- */
- /**
- * 添加事件
- * @param {String} 事件类型
- * @param {Function} 监听函数
- * @name artDialog.prototype.addEventListener
- */
- /**
- * 删除事件
- * @param {String} 事件类型
- * @param {Function} 监听函数
- * @name artDialog.prototype.removeEventListener
- */
- /**
- * 对话框显示事件,在 show()、showModal() 执行
- * @name artDialog.prototype.onshow
- * @event
- */
- /**
- * 关闭事件,在 close() 执行
- * @name artDialog.prototype.onclose
- * @event
- */
- /**
- * 销毁前事件,在 remove() 前执行
- * @name artDialog.prototype.onbeforeremove
- * @event
- */
- /**
- * 销毁事件,在 remove() 执行
- * @name artDialog.prototype.onremove
- * @event
- */
- /**
- * 重置事件,在 reset() 执行
- * @name artDialog.prototype.onreset
- * @event
- */
- /**
- * 焦点事件,在 foucs() 执行
- * @name artDialog.prototype.onfocus
- * @event
- */
- /**
- * 失焦事件,在 blur() 执行
- * @name artDialog.prototype.onblur
- * @event
- */
-
- /**
- * 设置内容
- * @param {String, HTMLElement} 内容
- */
- content: function (html) {
-
- var $content = this._$('content');
- // HTMLElement
- if (typeof html === 'object') {
- html = $(html);
- $content.empty('').append(html.show());
- this.addEventListener('beforeremove', function () {
- $('body').append(html.hide());
- });
- // String
- } else {
- if(this.options.contentType!=''){
- switch(this.options.contentType)
- {
- case 'load':
- if(this.options.content==''){
- html='<span class="ui-dialog-loading"></span><p style="float:left;">\u52a0\u8f7d\u4e2d\uff0c\u8bf7\u7a0d\u5019...</p>';
- }else{
- html='<span class="ui-dialog-loading"></span><p style="float:left;">'+this.options.content+'</p>';
- }
- break;
- case 'jsonload':
- if(this.options.content==''){
- html='<span class="ui-dialog-loading"></span><p style="float:left;">\u6570\u636e\u8f7d\u5165\u4e2d\uff0c\u8bf7\u7a0d\u5019...</p>';
- }else{
- html='<span class="ui-dialog-loading"></span><p style="float:left;">'+this.options.content+'</p>';
- }
- break;
- case 'tipsbox':
- var th=this;
- setTimeout(function () {
- artDialog.list[th.id].close().remove();
- }, this.options.closeTime);
- break;
- }
-
- }
- $content.html(html);
- }
-
- return this.reset();
- },
-
-
- /**
- * 设置标题
- * @param {String} 标题内容
- */
- title: function (text) {
- this._$('title').html(text);
- this._$('header')[text ? 'show' : 'hide']();
- return this;
- },
- /** 设置宽度 */
- width: function (value) {
- this._$('content').css('width', value);
- return this.reset();
- },
- /** 设置高度 */
- height: function (value) {
- this._$('content').css('height', value);
- return this.reset();
- },
- /**
- * 设置按钮组
- * @param {Array, String}
- * Options: value, callback, autofocus, disabled
- */
- button: function (args) {
- args = args || [];
- var that = this;
- var html = '';
- var number = 0;
- this.callbacks = {};
-
-
- if (typeof args === 'string') {
- html = args;
- number ++;
- } else {
- $.each(args, function (i, val) {
- var id = val.id = val.id || val.value;
- var style = '';
- that.callbacks[id] = val.callback;
- if (val.display === false) {
- style = ' style="display:none"';
- } else {
- number ++;
- }
- html +=
- '<button'
- + ' type="button"'
- + ' i-id="' + id + '"'
- + style
- + (val.disabled ? ' disabled' : '')
- + (val.autofocus ? ' autofocus class="ui-dialog-autofocus"' : '')
- + '><span>'
- + val.value
- + '</span></button>';
- that._$('button')
- .on('click', '[i-id=' + id +']', function (event) {
- var $this = $(this);
- if (!$this.attr('disabled')) {// IE BUG
- that._trigger(id);
- }
-
- event.preventDefault();
- });
- });
- }
- this._$('button').html(html);
- this._$('footer')[number ? 'show' : 'hide']();
- return this;
- },
- statusbar: function (html) {
- this._$('statusbar')
- .html(html)[html ? 'show' : 'hide']();
- return this;
- },
- _$: function (i) {
- return this._popup.find('[i=' + i + ']');
- },
-
-
- // 触发按钮回调函数
- _trigger: function (id) {
- var fn = this.callbacks[id];
-
- return typeof fn !== 'function' || fn.call(this) !== false ?
- this.close().remove() : this;
- }
-
- });
- artDialog.oncreate = $.noop;
- /** 获取最顶层的对话框API */
- artDialog.getCurrent = function () {
- return Popup.current;
- };
- /**
- * 根据 ID 获取某对话框 API
- * @param {String} 对话框 ID
- * @return {Object} 对话框 API (实例)
- */
- artDialog.get = function (id) {
- return id === undefined
- ? artDialog.list
- : artDialog.list[id];
- };
- artDialog.list = {};
- /**
- * 默认配置
- */
- artDialog.defaults = defaults;
- return artDialog;
- });
- /*!
- * drag.js
- * Date: 2013-12-06
- * https://github.com/aui/artDialog
- * (c) 2009-2014 TangBin, http://www.planeArt.cn
- *
- * This is licensed under the GNU LGPL, version 2.1 or later.
- * For details, see: http://www.gnu.org/licenses/lgpl-2.1.html
- */
- define("drag", function (require) {
- var $ = require("jquery");
- var $window = $(window);
- var $document = $(document);
- var isTouch = 'createTouch' in document;
- var html = document.documentElement;
- var isIE6 = !('minWidth' in html.style);
- var isLosecapture = !isIE6 && 'onlosecapture' in html;
- var isSetCapture = 'setCapture' in html;
- var types = {
- start: isTouch ? 'touchstart' : 'mousedown',
- over: isTouch ? 'touchmove' : 'mousemove',
- end: isTouch ? 'touchend' : 'mouseup'
- };
- var getEvent = isTouch ? function (event) {
- if (!event.touches) {
- event = event.originalEvent.touches.item(0);
- }
- return event;
- } : function (event) {
- return event;
- };
- var DragEvent = function () {
- this.start = $.proxy(this.start, this);
- this.over = $.proxy(this.over, this);
- this.end = $.proxy(this.end, this);
- this.onstart = this.onover = this.onend = $.noop;
- };
- DragEvent.types = types;
- DragEvent.prototype = {
- start: function (event) {
- event = this.startFix(event);
- $document
- .on(types.over, this.over)
- .on(types.end, this.end);
-
- this.onstart(event);
- return false;
- },
- over: function (event) {
- event = this.overFix(event);
- this.onover(event);
- return false;
- },
- end: function (event) {
- event = this.endFix(event);
- $document
- .off(types.over, this.over)
- .off(types.end, this.end);
- this.onend(event);
- return false;
- },
- startFix: function (event) {
- event = getEvent(event);
- this.target = $(event.target);
- this.selectstart = function () {
- return false;
- };
- $document
- .on('selectstart', this.selectstart)
- .on('dblclick', this.end);
- if (isLosecapture) {
- this.target.on('losecapture', this.end);
- } else {
- $window.on('blur', this.end);
- }
- if (isSetCapture) {
- this.target[0].setCapture();
- }
- return event;
- },
- overFix: function (event) {
- event = getEvent(event);
- return event;
- },
- endFix: function (event) {
- event = getEvent(event);
- $document
- .off('selectstart', this.selectstart)
- .off('dblclick', this.end);
- if (isLosecapture) {
- this.target.off('losecapture', this.end);
- } else {
- $window.off('blur', this.end);
- }
- if (isSetCapture) {
- this.target[0].releaseCapture();
- }
- return event;
- }
-
- };
- /**
- * 启动拖拽
- * @param {HTMLElement} 被拖拽的元素
- * @param {Event} 触发拖拽的事件对象。可选,若无则监听 elem 的按下事件启动
- */
- DragEvent.create = function (elem, event) {
- var $elem = $(elem);
- var dragEvent = new DragEvent();
- var startType = DragEvent.types.start;
- var noop = function () {};
- var className = elem.className
- .replace(/^\s|\s.*/g, '') + '-drag-start';
- var minX;
- var minY;
- var maxX;
- var maxY;
- var api = {
- onstart: noop,
- onover: noop,
- onend: noop,
- off: function () {
- $elem.off(startType, dragEvent.start);
- }
- };
- dragEvent.onstart = function (event) {
- var isFixed = $elem.css('position') === 'fixed';
- var dl = $document.scrollLeft();
- var dt = $document.scrollTop();
- var w = $elem.width();
- var h = $elem.height();
- minX = 0;
- minY = 0;
- maxX = isFixed ? $window.width() - w + minX : $document.width() - w;
- maxY = isFixed ? $window.height() - h + minY : $document.height() - h;
- var offset = $elem.offset();
- var left = this.startLeft = isFixed ? offset.left - dl : offset.left;
- var top = this.startTop = isFixed ? offset.top - dt : offset.top;
- this.clientX = event.clientX;
- this.clientY = event.clientY;
- $elem.addClass(className);
- api.onstart.call(elem, event, left, top);
- };
-
- dragEvent.onover = function (event) {
- var left = event.clientX - this.clientX + this.startLeft;
- var top = event.clientY - this.clientY + this.startTop;
- var style = $elem[0].style;
- left = Math.max(minX, Math.min(maxX, left));
- top = Math.max(minY, Math.min(maxY, top));
- style.left = left + 'px';
- style.top = top + 'px';
-
- api.onover.call(elem, event, left, top);
- };
-
- dragEvent.onend = function (event) {
- var position = $elem.position();
- var left = position.left;
- var top = position.top;
- $elem.removeClass(className);
- api.onend.call(elem, event, left, top);
- };
- dragEvent.off = function () {
- $elem.off(startType, dragEvent.start);
- };
- if (event) {
- dragEvent.start(event);
- } else {
- $elem.on(startType, dragEvent.start);
- }
- return api;
- };
- return DragEvent;
- });
- /*!
- * artDialog-plus
- * Date: 2013-11-09
- * https://github.com/aui/artDialog
- * (c) 2009-2014 TangBin, http://www.planeArt.cn
- *
- * This is licensed under the GNU LGPL, version 2.1 or later.
- * For details, see: http://www.gnu.org/licenses/lgpl-2.1.html
- */
- define("dialog-plus", function (require) {
- var $ = require("jquery");
- var dialog = require("dialog");
- var drag = require("drag");
- dialog.oncreate = function (api) {
- var options = api.options;
- var originalOptions = options.original;
- // 页面地址
- var url = options.url;
- // 页面加载完毕的事件
- var oniframeload = options.oniframeload;
- var $iframe;
- if (url) {
- this.padding = options.padding = 0;
- $iframe = $('<iframe />');
- $iframe.attr({
- src: url,
- name: api.id,
- width: '100%',
- height: '100%',
- allowtransparency: 'yes',
- frameborder: 'no',
- scrolling: 'no'
- })
- .on('load', function () {
- var test;
-
- try {
- // 跨域测试
- test = $iframe[0].contentWindow.frameElement;
- } catch (e) {}
- if (test) {
- if (!options.width) {
- api.width($iframe.contents().width());
- }
-
- if (!options.height) {
- api.height($iframe.contents().height());
- }
- }
- if (oniframeload) {
- oniframeload.call(api);
- }
- });
- api.addEventListener('beforeremove', function () {
- // 重要!需要重置iframe地址,否则下次出现的对话框在IE6、7无法聚焦input
- // IE删除iframe后,iframe仍然会留在内存中出现上述问题,置换src是最容易解决的方法
- $iframe.attr('src', 'about:blank').remove();
- }, false);
- api.content($iframe[0]);
- api.iframeNode = $iframe[0];
- }
- // 对于子页面呼出的对话框特殊处理
- // 如果对话框配置来自 iframe
- if (!(originalOptions instanceof Object)) {
- var un = function () {
- api.close().remove();
- };
- // 找到那个 iframe
- for (var i = 0; i < frames.length; i ++) {
- try {
- if (originalOptions instanceof frames[i].Object) {
- // 让 iframe 刷新的时候也关闭对话框,
- // 防止要执行的对象被强制收回导致 IE 报错:“不能执行已释放 Script 的代码”
- $(frames[i]).one('unload', un);
- break;
- }
- } catch (e) {}
- }
- }
- // 拖拽支持
- $(api.node).on(drag.types.start, '[i=title]', function (event) {
- // 排除气泡类型的对话框
- if (!api.follow) {
- api.focus();
- drag.create(api.node, event);
- }
- });
- };
- dialog.get = function (id) {
- // 从 iframe 传入 window 对象
- if (id && id.frameElement) {
- var iframe = id.frameElement;
- var list = dialog.list;
- var api;
- for (var i in list) {
- api = list[i];
- if (api.node.getElementsByTagName('iframe')[0] === iframe) {
- return api;
- }
- }
- // 直接传入 id 的情况
- } else if (id) {
- return dialog.list[id];
- }
- };
- return dialog;
- });
- window.dialog = require("dialog-plus");
- })();
|