artDialog.js 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155
  1. /*!
  2. * artDialog 4.1.7
  3. * Date: 2013-03-03 08:04
  4. * http://code.google.com/p/artdialog/
  5. * (c) 2009-2012 TangBin, http://www.planeArt.cn
  6. *
  7. * This is licensed under the GNU LGPL, version 2.1 or later.
  8. * For details, see: http://creativecommons.org/licenses/LGPL/2.1/
  9. */
  10. ;(function (window, undefined) {
  11. //if (window.jQuery) return jQuery;
  12. var $ = window.art = function (selector, context) {
  13. return new $.fn.init(selector, context);
  14. },
  15. readyBound = false,
  16. readyList = [],
  17. DOMContentLoaded,
  18. isOpacity = 'opacity' in document.documentElement.style,
  19. quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,
  20. rclass = /[\n\t]/g,
  21. ralpha = /alpha\([^)]*\)/i,
  22. ropacity = /opacity=([^)]*)/,
  23. rfxnum = /^([+-]=)?([\d+-.]+)(.*)$/;
  24. if (window.$ === undefined) window.$ = $;
  25. $.fn = $.prototype = {
  26. constructor: $,
  27. /**
  28. * DOM 就绪
  29. * @param {Function} 回调函数
  30. */
  31. ready: function (callback) {
  32. $.bindReady();
  33. if ($.isReady) {
  34. callback.call(document, $);
  35. } else if (readyList) {
  36. readyList.push(callback);
  37. };
  38. return this;
  39. },
  40. /**
  41. * 判断样式类是否存在
  42. * @param {String} 名称
  43. * @return {Boolean}
  44. */
  45. hasClass: function (name) {
  46. var className = ' ' + name + ' ';
  47. if ((' ' + this[0].className + ' ').replace(rclass, ' ')
  48. .indexOf(className) > -1) return true;
  49. return false;
  50. },
  51. /**
  52. * 添加样式类
  53. * @param {String} 名称
  54. */
  55. addClass: function (name) {
  56. if (!this.hasClass(name)) this[0].className += ' ' + name;
  57. return this;
  58. },
  59. /**
  60. * 移除样式类
  61. * @param {String} 名称
  62. */
  63. removeClass: function (name) {
  64. var elem = this[0];
  65. if (!name) {
  66. elem.className = '';
  67. } else
  68. if (this.hasClass(name)) {
  69. elem.className = elem.className.replace(name, ' ');
  70. };
  71. return this;
  72. },
  73. /**
  74. * 读写样式<br />
  75. * css(name) 访问第一个匹配元素的样式属性<br />
  76. * css(properties) 把一个"名/值对"对象设置为所有匹配元素的样式属性<br />
  77. * css(name, value) 在所有匹配的元素中,设置一个样式属性的值<br />
  78. */
  79. css: function (name, value) {
  80. var i, elem = this[0], obj = arguments[0];
  81. if (typeof name === 'string') {
  82. if (value === undefined) {
  83. return $.css(elem, name);
  84. } else {
  85. name === 'opacity' ?
  86. $.opacity.set(elem, value) :
  87. elem.style[name] = value;
  88. };
  89. } else {
  90. for (i in obj) {
  91. i === 'opacity' ?
  92. $.opacity.set(elem, obj[i]) :
  93. elem.style[i] = obj[i];
  94. };
  95. };
  96. return this;
  97. },
  98. /** 显示元素 */
  99. show: function () {
  100. return this.css('display', 'block');
  101. },
  102. /** 隐藏元素 */
  103. hide: function () {
  104. return this.css('display', 'none');
  105. },
  106. /**
  107. * 获取相对文档的坐标
  108. * @return {Object} 返回left、top的数值
  109. */
  110. offset: function () {
  111. var elem = this[0],
  112. box = elem.getBoundingClientRect(),
  113. doc = elem.ownerDocument,
  114. body = doc.body,
  115. docElem = doc.documentElement,
  116. clientTop = docElem.clientTop || body.clientTop || 0,
  117. clientLeft = docElem.clientLeft || body.clientLeft || 0,
  118. top = box.top + (self.pageYOffset || docElem.scrollTop) - clientTop,
  119. left = box.left + (self.pageXOffset || docElem.scrollLeft) - clientLeft;
  120. return {
  121. left: left,
  122. top: top
  123. };
  124. },
  125. /**
  126. * 读写HTML - (不支持文本框)
  127. * @param {String} 内容
  128. */
  129. html: function (content) {
  130. var elem = this[0];
  131. if (content === undefined) return elem.innerHTML;
  132. $.cleanData(elem.getElementsByTagName('*'));
  133. elem.innerHTML = content;
  134. return this;
  135. },
  136. /**
  137. * 移除节点
  138. */
  139. remove: function () {
  140. var elem = this[0];
  141. $.cleanData(elem.getElementsByTagName('*'));
  142. $.cleanData([elem]);
  143. elem.parentNode.removeChild(elem);
  144. return this;
  145. },
  146. /**
  147. * 事件绑定
  148. * @param {String} 类型
  149. * @param {Function} 要绑定的函数
  150. */
  151. bind: function (type, callback) {
  152. $.event.add(this[0], type, callback);
  153. return this;
  154. },
  155. /**
  156. * 移除事件
  157. * @param {String} 类型
  158. * @param {Function} 要卸载的函数
  159. */
  160. unbind: function(type, callback) {
  161. $.event.remove(this[0], type, callback);
  162. return this;
  163. }
  164. };
  165. $.fn.init = function (selector, context) {
  166. var match, elem;
  167. context = context || document;
  168. if (!selector) return this;
  169. if (selector.nodeType) {
  170. this[0] = selector;
  171. return this;
  172. };
  173. if (selector === 'body' && context.body) {
  174. this[0] = context.body;
  175. return this;
  176. };
  177. if (selector === 'head' || selector === 'html') {
  178. this[0] = context.getElementsByTagName(selector)[0];
  179. return this;
  180. };
  181. if (typeof selector === 'string') {
  182. match = quickExpr.exec(selector);
  183. if (match && match[2]) {
  184. elem = context.getElementById(match[2]);
  185. if (elem && elem.parentNode) this[0] = elem;
  186. return this;
  187. };
  188. };
  189. if (typeof selector === 'function') return $(document).ready(selector);
  190. this[0] = selector;
  191. return this;
  192. };
  193. $.fn.init.prototype = $.fn;
  194. /** 空函数 */
  195. $.noop = function () {};
  196. /** 检测window */
  197. $.isWindow = function (obj) {
  198. return obj && typeof obj === 'object' && 'setInterval' in obj;
  199. };
  200. /** 数组判定 */
  201. $.isArray = function (obj) {
  202. return Object.prototype.toString.call(obj) === '[object Array]';
  203. };
  204. /**
  205. * 搜索子元素
  206. * 注意:只支持nodeName或.className的形式,并且只返回第一个元素
  207. * @param {String}
  208. */
  209. $.fn.find = function (expr) {
  210. var value, elem = this[0],
  211. className = expr.split('.')[1];
  212. if (className) {
  213. if (document.getElementsByClassName) {
  214. value = elem.getElementsByClassName(className);
  215. } else {
  216. value = getElementsByClassName(className, elem);
  217. };
  218. } else {
  219. value = elem.getElementsByTagName(expr);
  220. };
  221. return $(value[0]);
  222. };
  223. function getElementsByClassName (className, node, tag) {
  224. node = node || document;
  225. tag = tag || '*';
  226. var i = 0,
  227. j = 0,
  228. classElements = [],
  229. els = node.getElementsByTagName(tag),
  230. elsLen = els.length,
  231. pattern = new RegExp("(^|\\s)" + className + "(\\s|$)");
  232. for (; i < elsLen; i ++) {
  233. if (pattern.test(els[i].className)) {
  234. classElements[j] = els[i];
  235. j ++;
  236. };
  237. };
  238. return classElements;
  239. };
  240. /**
  241. * 遍历
  242. * @param {Object}
  243. * @param {Function}
  244. */
  245. $.each = function (obj, callback) {
  246. var name, i = 0,
  247. length = obj.length,
  248. isObj = length === undefined;
  249. if (isObj) {
  250. for (name in obj) {
  251. if (callback.call(obj[name], name, obj[name]) === false) break;
  252. };
  253. } else {
  254. for (var value = obj[0];
  255. i < length && callback.call(value, i, value) !== false;
  256. value = obj[++i]) {};
  257. };
  258. return obj;
  259. };
  260. /**
  261. * 读写缓存
  262. * @param {HTMLElement} 元素
  263. * @param {String} 缓存名称
  264. * @param {Any} 数据
  265. * @return {Any} 如果无参数data则返回缓存数据
  266. */
  267. $.data = function (elem, name, data) {
  268. var cache = $.cache,
  269. id = uuid(elem);
  270. if (name === undefined) return cache[id];
  271. if (!cache[id]) cache[id] = {};
  272. if (data !== undefined) cache[id][name] = data;
  273. return cache[id][name];
  274. };
  275. /**
  276. * 删除缓存
  277. * @param {HTMLElement} 元素
  278. * @param {String} 缓存名称
  279. */
  280. $.removeData = function (elem, name) {
  281. var empty = true,
  282. expando = $.expando,
  283. cache = $.cache,
  284. id = uuid(elem),
  285. thisCache = id && cache[id];
  286. if (!thisCache) return;
  287. if (name) {
  288. delete thisCache[name];
  289. for (var n in thisCache) empty = false;
  290. if (empty) delete $.cache[id];
  291. } else {
  292. delete cache[id];
  293. if (elem.removeAttribute) {
  294. elem.removeAttribute(expando);
  295. } else {
  296. elem[expando] = null;
  297. };
  298. };
  299. };
  300. $.uuid = 0;
  301. $.cache = {};
  302. $.expando = '@cache' + + new Date
  303. // 标记元素唯一身份
  304. function uuid (elem) {
  305. var expando = $.expando,
  306. id = elem === window ? 0 : elem[expando];
  307. if (id === undefined) elem[expando] = id = ++ $.uuid;
  308. return id;
  309. };
  310. /**
  311. * 事件机制
  312. * @namespace
  313. * @requires [$.data, $.removeData]
  314. */
  315. $.event = {
  316. /**
  317. * 添加事件
  318. * @param {HTMLElement} 元素
  319. * @param {String} 事件类型
  320. * @param {Function} 要添加的函数
  321. */
  322. add: function (elem, type, callback) {
  323. var cache, listeners,
  324. that = $.event,
  325. data = $.data(elem, '@events') || $.data(elem, '@events', {});
  326. cache = data[type] = data[type] || {};
  327. listeners = cache.listeners = cache.listeners || [];
  328. listeners.push(callback);
  329. if (!cache.handler) {
  330. cache.elem = elem;
  331. cache.handler = that.handler(cache);
  332. elem.addEventListener
  333. ? elem.addEventListener(type, cache.handler, false)
  334. : elem.attachEvent('on' + type, cache.handler);
  335. };
  336. },
  337. /**
  338. * 卸载事件
  339. * @param {HTMLElement} 元素
  340. * @param {String} 事件类型
  341. * @param {Function} 要卸载的函数
  342. */
  343. remove: function (elem, type, callback) {
  344. var i, cache, listeners,
  345. that = $.event,
  346. empty = true,
  347. data = $.data(elem, '@events');
  348. if (!data) return;
  349. if (!type) {
  350. for (i in data) that.remove(elem, i);
  351. return;
  352. };
  353. cache = data[type];
  354. if (!cache) return;
  355. listeners = cache.listeners;
  356. if (callback) {
  357. for (i = 0; i < listeners.length; i ++) {
  358. listeners[i] === callback && listeners.splice(i--, 1);
  359. };
  360. } else {
  361. cache.listeners = [];
  362. };
  363. if (cache.listeners.length === 0) {
  364. elem.removeEventListener
  365. ? elem.removeEventListener(type, cache.handler, false)
  366. : elem.detachEvent('on' + type, cache.handler);
  367. delete data[type];
  368. cache = $.data(elem, '@events');
  369. for (var n in cache) empty = false;
  370. if (empty) $.removeData(elem, '@events');
  371. };
  372. },
  373. /** @inner 事件句柄 */
  374. handler: function (cache) {
  375. return function (event) {
  376. event = $.event.fix(event || window.event);
  377. for (var i = 0, list = cache.listeners, fn; fn = list[i++];) {
  378. if (fn.call(cache.elem, event) === false) {
  379. event.preventDefault();
  380. event.stopPropagation();
  381. };
  382. };
  383. };
  384. },
  385. /** @inner Event对象兼容处理 */
  386. fix: function (event) {
  387. if (event.target) return event;
  388. var event2 = {
  389. target: event.srcElement || document,
  390. preventDefault: function () {event.returnValue = false},
  391. stopPropagation: function () {event.cancelBubble = true}
  392. };
  393. // IE6/7/8 在原生window.event对象写入数据会导致内存无法回收,应当采用拷贝
  394. for (var i in event) event2[i] = event[i];
  395. return event2;
  396. }
  397. };
  398. /**
  399. * 清理元素集的事件与缓存
  400. * @requires [$.removeData, $.event]
  401. * @param {HTMLCollection} 元素集
  402. */
  403. $.cleanData = function (elems) {
  404. var i = 0, elem,
  405. len = elems.length,
  406. removeEvent = $.event.remove,
  407. removeData = $.removeData;
  408. for (; i < len; i ++) {
  409. elem = elems[i];
  410. removeEvent(elem);
  411. removeData(elem);
  412. };
  413. };
  414. // DOM就绪事件
  415. $.isReady = false;
  416. $.ready = function () {
  417. if (!$.isReady) {
  418. if (!document.body) return setTimeout($.ready, 13);
  419. $.isReady = true;
  420. if (readyList) {
  421. var fn, i = 0;
  422. while ((fn = readyList[i++])) {
  423. fn.call(document, $);
  424. };
  425. readyList = null;
  426. };
  427. };
  428. };
  429. $.bindReady = function () {
  430. if (readyBound) return;
  431. readyBound = true;
  432. if (document.readyState === 'complete') {
  433. return $.ready();
  434. };
  435. if (document.addEventListener) {
  436. document.addEventListener('DOMContentLoaded', DOMContentLoaded, false);
  437. window.addEventListener('load', $.ready, false);
  438. } else if (document.attachEvent) {
  439. document.attachEvent('onreadystatechange', DOMContentLoaded);
  440. window.attachEvent('onload', $.ready);
  441. var toplevel = false;
  442. try {
  443. toplevel = window.frameElement == null;
  444. } catch (e) {};
  445. if (document.documentElement.doScroll && toplevel) {
  446. doScrollCheck();
  447. };
  448. };
  449. };
  450. if (document.addEventListener) {
  451. DOMContentLoaded = function () {
  452. document.removeEventListener('DOMContentLoaded', DOMContentLoaded, false);
  453. $.ready();
  454. };
  455. } else if (document.attachEvent) {
  456. DOMContentLoaded = function () {
  457. if (document.readyState === 'complete') {
  458. document.detachEvent('onreadystatechange', DOMContentLoaded);
  459. $.ready();
  460. };
  461. };
  462. };
  463. function doScrollCheck () {
  464. if ($.isReady) return;
  465. try {
  466. document.documentElement.doScroll('left');
  467. } catch (e) {
  468. setTimeout(doScrollCheck, 1);
  469. return;
  470. };
  471. $.ready();
  472. };
  473. // 获取css
  474. $.css = 'defaultView' in document && 'getComputedStyle' in document.defaultView ?
  475. function (elem, name) {
  476. return document.defaultView.getComputedStyle(elem, false)[name];
  477. } :
  478. function (elem, name) {
  479. var ret = name === 'opacity' ? $.opacity.get(elem) : elem.currentStyle[name];
  480. return ret || '';
  481. };
  482. // 跨浏览器处理opacity
  483. $.opacity = {
  484. get: function (elem) {
  485. return isOpacity ?
  486. document.defaultView.getComputedStyle(elem, false).opacity :
  487. ropacity.test((elem.currentStyle
  488. ? elem.currentStyle.filter
  489. : elem.style.filter) || '')
  490. ? (parseFloat(RegExp.$1) / 100) + ''
  491. : 1;
  492. },
  493. set: function (elem, value) {
  494. if (isOpacity) return elem.style.opacity = value;
  495. var style = elem.style;
  496. style.zoom = 1;
  497. var opacity = 'alpha(opacity=' + value * 100 + ')',
  498. filter = style.filter || '';
  499. style.filter = ralpha.test(filter) ?
  500. filter.replace(ralpha, opacity) :
  501. style.filter + ' ' + opacity;
  502. }
  503. };
  504. /**
  505. * 获取滚动条位置 - [不支持写入]
  506. * $.fn.scrollLeft, $.fn.scrollTop
  507. * @example 获取文档垂直滚动条:$(document).scrollTop()
  508. * @return {Number} 返回滚动条位置
  509. */
  510. $.each(['Left', 'Top'], function (i, name) {
  511. var method = 'scroll' + name;
  512. $.fn[method] = function () {
  513. var elem = this[0], win;
  514. win = getWindow(elem);
  515. return win ?
  516. ('pageXOffset' in win) ?
  517. win[i ? 'pageYOffset' : 'pageXOffset'] :
  518. win.document.documentElement[method] || win.document.body[method] :
  519. elem[method];
  520. };
  521. });
  522. function getWindow (elem) {
  523. return $.isWindow(elem) ?
  524. elem :
  525. elem.nodeType === 9 ?
  526. elem.defaultView || elem.parentWindow :
  527. false;
  528. };
  529. /**
  530. * 获取窗口或文档尺寸 - [只支持window与document读取]
  531. * @example
  532. 获取文档宽度:$(document).width()
  533. 获取可视范围:$(window).width()
  534. * @return {Number}
  535. */
  536. $.each(['Height', 'Width'], function (i, name) {
  537. var type = name.toLowerCase();
  538. $.fn[type] = function (size) {
  539. var elem = this[0];
  540. if (!elem) {
  541. return size == null ? null : this;
  542. };
  543. return $.isWindow(elem) ?
  544. elem.document.documentElement['client' + name] || elem.document.body['client' + name] :
  545. (elem.nodeType === 9) ?
  546. Math.max(
  547. elem.documentElement['client' + name],
  548. elem.body['scroll' + name], elem.documentElement['scroll' + name],
  549. elem.body['offset' + name], elem.documentElement['offset' + name]
  550. ) : null;
  551. };
  552. });
  553. /**
  554. * 简单ajax支持
  555. * @example
  556. * $.ajax({
  557. * url: url,
  558. * success: callback,
  559. * cache: cache
  560. * });
  561. */
  562. $.ajax = function (config) {
  563. var ajax = window.XMLHttpRequest ?
  564. new XMLHttpRequest() :
  565. new ActiveXObject('Microsoft.XMLHTTP'),
  566. url = config.url;
  567. if (config.cache === false) {
  568. var ts = + new Date,
  569. ret = url.replace(/([?&])_=[^&]*/, "$1_=" + ts );
  570. url = ret + ((ret === url) ? (/\?/.test(url) ? "&" : "?") + "_=" + ts : "");
  571. };
  572. ajax.onreadystatechange = function() {
  573. if (ajax.readyState === 4 && ajax.status === 200) {
  574. config.success && config.success(ajax.responseText);
  575. ajax.onreadystatechange = $.noop;
  576. };
  577. };
  578. ajax.open('GET', url, 1);
  579. ajax.send(null);
  580. };
  581. /** 动画引擎 - [不支持链式列队操作] */
  582. $.fn.animate = function (prop, speed, easing, callback) {
  583. speed = speed || 400;
  584. if (typeof easing === 'function') callback = easing;
  585. easing = easing && $.easing[easing] ? easing : 'swing';
  586. var elem = this[0], overflow,
  587. fx, parts, start, end, unit,
  588. opt = {
  589. speed: speed,
  590. easing: easing,
  591. callback: function () {
  592. if (overflow != null) elem.style.overflow = '';
  593. callback && callback();
  594. }
  595. };
  596. opt.curAnim = {};
  597. $.each(prop, function (name, val) {
  598. opt.curAnim[name] = val;
  599. });
  600. $.each(prop, function (name, val) {
  601. fx = new $.fx(elem, opt, name);
  602. parts = rfxnum.exec(val);
  603. start = parseFloat(name === 'opacity'
  604. || (elem.style && elem.style[name] != null) ?
  605. $.css(elem, name) :
  606. elem[name]);
  607. end = parseFloat(parts[2]);
  608. unit = parts[3];
  609. if (name === 'height' || name === 'width') {
  610. end = Math.max(0, end);
  611. overflow = [elem.style.overflow,
  612. elem.style.overflowX, elem.style.overflowY];
  613. };
  614. fx.custom(start, end, unit);
  615. });
  616. if (overflow != null) elem.style.overflow = 'hidden';
  617. return this;
  618. };
  619. $.timers = [];
  620. $.fx = function (elem, options, prop) {
  621. this.elem = elem;
  622. this.options = options;
  623. this.prop = prop;
  624. };
  625. $.fx.prototype = {
  626. custom: function (from, to, unit) {
  627. var that = this;
  628. that.startTime = $.fx.now();
  629. that.start = from;
  630. that.end = to;
  631. that.unit = unit;
  632. that.now = that.start;
  633. that.state = that.pos = 0;
  634. function t() {
  635. return that.step();
  636. };
  637. t.elem = that.elem;
  638. t();
  639. $.timers.push(t);
  640. if (!$.timerId) $.timerId = setInterval($.fx.tick, 13);
  641. },
  642. step: function () {
  643. var that = this, t = $.fx.now(), done = true;
  644. if (t >= that.options.speed + that.startTime) {
  645. that.now = that.end;
  646. that.state = that.pos = 1;
  647. that.update();
  648. that.options.curAnim[that.prop] = true;
  649. for (var i in that.options.curAnim) {
  650. if (that.options.curAnim[i] !== true) {
  651. done = false;
  652. };
  653. };
  654. if (done) that.options.callback.call(that.elem);
  655. return false;
  656. } else {
  657. var n = t - that.startTime;
  658. that.state = n / that.options.speed;
  659. that.pos = $.easing[that.options.easing](that.state, n, 0, 1, that.options.speed);
  660. that.now = that.start + ((that.end - that.start) * that.pos);
  661. that.update();
  662. return true;
  663. };
  664. },
  665. update: function () {
  666. var that = this;
  667. if (that.prop === 'opacity') {
  668. $.opacity.set(that.elem, that.now);
  669. } else
  670. if (that.elem.style && that.elem.style[that.prop] != null) {
  671. that.elem.style[that.prop] = that.now + that.unit;
  672. } else {
  673. that.elem[that.prop] = that.now;
  674. };
  675. }
  676. };
  677. $.fx.now = function () {
  678. return + new Date;
  679. };
  680. $.easing = {
  681. linear: function (p, n, firstNum, diff) {
  682. return firstNum + diff * p;
  683. },
  684. swing: function (p, n, firstNum, diff) {
  685. return ((-Math.cos(p * Math.PI) / 2) + 0.5) * diff + firstNum;
  686. }
  687. };
  688. $.fx.tick = function () {
  689. var timers = $.timers;
  690. for (var i = 0; i < timers.length; i++) {
  691. !timers[i]() && timers.splice(i--, 1);
  692. };
  693. !timers.length && $.fx.stop();
  694. };
  695. $.fx.stop = function () {
  696. clearInterval($.timerId);
  697. $.timerId = null;
  698. };
  699. $.fn.stop = function () {
  700. var timers = $.timers;
  701. for (var i = timers.length - 1; i >= 0; i--) {
  702. if (timers[i].elem === this[0]) timers.splice(i, 1);
  703. };
  704. return this;
  705. };
  706. //-------------end
  707. return $}(window));
  708. //------------------------------------------------
  709. // 对话框模块
  710. //------------------------------------------------
  711. ;(function ($, window, undefined) {
  712. $.noop = $.noop || function () {}; // jQuery 1.3.2
  713. var _box, _thisScript, _skin, _path,
  714. _count = 0,
  715. _$window = $(window),
  716. _$document = $(document),
  717. _$html = $('html'),
  718. _elem = document.documentElement,
  719. _isIE6 = window.VBArray && !window.XMLHttpRequest,
  720. _isMobile = 'createTouch' in document && !('onmousemove' in _elem)
  721. || /(iPhone|iPad|iPod)/i.test(navigator.userAgent),
  722. _expando = 'artDialog' + + new Date;
  723. var artDialog = function (config, ok, cancel) {
  724. config = config || {};
  725. if (typeof config === 'string' || config.nodeType === 1) {
  726. config = {content: config, fixed: !_isMobile};
  727. };
  728. var api,
  729. defaults = artDialog.defaults,
  730. elem = config.follow = this.nodeType === 1 && this || config.follow;
  731. // 合并默认配置
  732. for (var i in defaults) {
  733. if (config[i] === undefined) config[i] = defaults[i];
  734. };
  735. // 兼容v4.1.0之前的参数,未来版本将删除此
  736. $.each({ok:"yesFn",cancel:"noFn",close:"closeFn",init:"initFn",okVal:"yesText",cancelVal:"noText"},
  737. function(i,o){config[i]=config[i]!==undefined?config[i]:config[o]});
  738. // 返回跟随模式或重复定义的ID
  739. if (typeof elem === 'string') elem = $(elem)[0];
  740. config.id = elem && elem[_expando + 'follow'] || config.id || _expando + _count;
  741. api = artDialog.list[config.id];
  742. if (elem && api) return api.follow(elem).zIndex().focus();
  743. if (api) return api.zIndex().focus();
  744. // 目前主流移动设备对fixed支持不好
  745. if (_isMobile) config.fixed = false;
  746. // 按钮队列
  747. if (!$.isArray(config.button)) {
  748. config.button = config.button ? [config.button] : [];
  749. };
  750. if (ok !== undefined) config.ok = ok;
  751. if (cancel !== undefined) config.cancel = cancel;
  752. config.ok && config.button.push({
  753. name: config.okVal,
  754. callback: config.ok,
  755. focus: true
  756. });
  757. config.cancel && config.button.push({
  758. name: config.cancelVal,
  759. callback: config.cancel
  760. });
  761. // zIndex全局配置
  762. artDialog.defaults.zIndex = config.zIndex;
  763. _count ++;
  764. return artDialog.list[config.id] = _box ?
  765. _box._init(config) : new artDialog.fn._init(config);
  766. };
  767. artDialog.fn = artDialog.prototype = {
  768. version: '4.1.7',
  769. closed: true,
  770. _init: function (config) {
  771. var that = this, DOM,
  772. icon = config.icon,
  773. iconBg = icon && (_isIE6 ? {png: '../widget/artDialog/4.1.7/images/' + icon + '.png'}
  774. : {backgroundImage: 'url(\'' + '../widget/artDialog/4.1.7/images/' + icon + '.png\')'});
  775. var artIcon='';
  776. switch(config.artIcon)
  777. {
  778. case 'add':
  779. artIcon='<i class="art-icon icon-title-add"></i>';
  780. break;
  781. case 'edit':
  782. artIcon='<i class="art-icon icon-title-edit"></i>';
  783. break;
  784. case 'ask':
  785. artIcon='<i class="art-icon icon-title-ask"></i>';
  786. break;
  787. case 'error':
  788. artIcon='<i class="art-icon icon-title-error"></i>';
  789. break;
  790. }
  791. that.closed = false;
  792. that.config = config;
  793. that.DOM = DOM = that.DOM || that._getDOM();
  794. if(config.tips){
  795. $('#aui_dialog_title').addClass('c-hide');
  796. }else{
  797. $('#aui_dialog_title').removeClass('c-hide');
  798. }
  799. DOM.wrap.addClass(config.skin);
  800. DOM.close[config.cancel === false ? 'hide' : 'show']();
  801. DOM.icon[0].style.display = icon ? '' : 'none';
  802. DOM.iconBg.css(iconBg || {background: 'none'});
  803. DOM.se.css('cursor', config.resize ? 'se-resize' : 'auto');
  804. DOM.title.css('cursor', config.drag ? 'move' : 'auto');
  805. DOM.content.css('padding', config.padding);
  806. if(config.overflow){
  807. DOM.main.css({'overflow': 'auto','display':'block'});
  808. }
  809. that[config.show ? 'show' : 'hide'](true)
  810. that.button(config.button)
  811. .title(artIcon+config.title)
  812. .content(config.content, true)
  813. .size(config.width, config.height)
  814. .time(config.time);
  815. config.follow
  816. ? that.follow(config.follow)
  817. : that.position(config.left, config.top);
  818. that.zIndex().focus();
  819. config.lock && that.lock();
  820. that._addEvent();
  821. that._ie6PngFix();
  822. _box = null;
  823. config.init && config.init.call(that, window);
  824. return that;
  825. },
  826. /**
  827. * 设置内容
  828. * @param {String, HTMLElement} 内容 (可选)
  829. * @return {this, HTMLElement} 如果无参数则返回内容容器DOM对象
  830. */
  831. content: function (msg) {
  832. var prev, next, parent, display,
  833. that = this,
  834. DOM = that.DOM,
  835. wrap = DOM.wrap[0],
  836. width = wrap.offsetWidth,
  837. height = wrap.offsetHeight,
  838. left = parseInt(wrap.style.left),
  839. top = parseInt(wrap.style.top),
  840. cssWidth = wrap.style.width,
  841. $content = DOM.content,
  842. content = $content[0];
  843. that._elemBack && that._elemBack();
  844. wrap.style.width = 'auto';
  845. if (msg === undefined) return content;
  846. if (typeof msg === 'string') {
  847. $content.html(msg);
  848. } else if (msg && msg.nodeType === 1) {
  849. // 让传入的元素在对话框关闭后可以返回到原来的地方
  850. display = msg.style.display;
  851. prev = msg.previousSibling;
  852. next = msg.nextSibling;
  853. parent = msg.parentNode;
  854. that._elemBack = function () {
  855. if (prev && prev.parentNode) {
  856. prev.parentNode.insertBefore(msg, prev.nextSibling);
  857. } else if (next && next.parentNode) {
  858. next.parentNode.insertBefore(msg, next);
  859. } else if (parent) {
  860. parent.appendChild(msg);
  861. };
  862. msg.style.display = display;
  863. that._elemBack = null;
  864. };
  865. $content.html('');
  866. content.appendChild(msg);
  867. msg.style.display = 'block';
  868. };
  869. // 新增内容后调整位置
  870. if (!arguments[1]) {
  871. if (that.config.follow) {
  872. that.follow(that.config.follow);
  873. } else {
  874. width = wrap.offsetWidth - width;
  875. height = wrap.offsetHeight - height;
  876. left = left - width / 2;
  877. top = top - height / 2;
  878. wrap.style.left = Math.max(left, 0) + 'px';
  879. wrap.style.top = Math.max(top, 0) + 'px';
  880. };
  881. if (cssWidth && cssWidth !== 'auto') {
  882. wrap.style.width = wrap.offsetWidth + 'px';
  883. };
  884. that._autoPositionType();
  885. };
  886. that._ie6SelectFix();
  887. that._runScript(content);
  888. return that;
  889. },
  890. /**
  891. * 设置标题
  892. * @param {String, Boolean} 标题内容. 为false则隐藏标题栏
  893. * @return {this, HTMLElement} 如果无参数则返回内容器DOM对象
  894. */
  895. title: function (text) {
  896. var DOM = this.DOM,
  897. wrap = DOM.wrap,
  898. title = DOM.title,
  899. className = 'aui_state_noTitle';
  900. if (text === undefined) return title[0];
  901. if (text === false) {
  902. title.hide().html('');
  903. wrap.addClass(className);
  904. } else {
  905. title.show().html(text || '');
  906. wrap.removeClass(className);
  907. };
  908. return this;
  909. },
  910. /**
  911. * 位置(相对于可视区域)
  912. * @param {Number, String}
  913. * @param {Number, String}
  914. */
  915. position: function (left, top) {
  916. var that = this,
  917. config = that.config,
  918. wrap = that.DOM.wrap[0],
  919. isFixed = _isIE6 ? false : config.fixed,
  920. ie6Fixed = _isIE6 && that.config.fixed,
  921. docLeft = _$document.scrollLeft(),
  922. docTop = _$document.scrollTop(),
  923. dl = isFixed ? 0 : docLeft,
  924. dt = isFixed ? 0 : docTop,
  925. ww = _$window.width(),
  926. wh = _$window.height(),
  927. ow = wrap.offsetWidth,
  928. oh = wrap.offsetHeight,
  929. style = wrap.style;
  930. if (left || left === 0) {
  931. that._left = left.toString().indexOf('%') !== -1 ? left : null;
  932. left = that._toNumber(left, ww - ow);
  933. if (typeof left === 'number') {
  934. left = ie6Fixed ? (left += docLeft) : left + dl;
  935. style.left = Math.max(left, dl) + 'px';
  936. } else if (typeof left === 'string') {
  937. style.left = left;
  938. };
  939. };
  940. if (top || top === 0) {
  941. that._top = top.toString().indexOf('%') !== -1 ? top : null;
  942. top = that._toNumber(top, wh - oh);
  943. if (typeof top === 'number') {
  944. top = ie6Fixed ? (top += docTop) : top + dt;
  945. style.top = Math.max(top, dt) + 'px';
  946. } else if (typeof top === 'string') {
  947. style.top = top;
  948. };
  949. };
  950. if (left !== undefined && top !== undefined) {
  951. that._follow = null;
  952. that._autoPositionType();
  953. };
  954. return that;
  955. },
  956. /**
  957. * 尺寸
  958. * @param {Number, String} 宽度
  959. * @param {Number, String} 高度
  960. */
  961. size: function (width, height) {
  962. var maxWidth, maxHeight, scaleWidth, scaleHeight,
  963. that = this,
  964. config = that.config,
  965. DOM = that.DOM,
  966. wrap = DOM.wrap,
  967. main = DOM.main,
  968. wrapStyle = wrap[0].style,
  969. style = main[0].style;
  970. if (width) {
  971. that._width = width.toString().indexOf('%') !== -1 ? width : null;
  972. maxWidth = _$window.width() - wrap[0].offsetWidth + main[0].offsetWidth;
  973. scaleWidth = that._toNumber(width, maxWidth);
  974. width = scaleWidth;
  975. if (typeof width === 'number') {
  976. wrapStyle.width = 'auto';
  977. style.width = Math.max(that.config.minWidth, width) + 'px';
  978. wrapStyle.width = wrap[0].offsetWidth + 'px'; // 防止未定义宽度的表格遇到浏览器右边边界伸缩
  979. } else if (typeof width === 'string') {
  980. style.width = width;
  981. width === 'auto' && wrap.css('width', 'auto');
  982. };
  983. };
  984. if (height) {
  985. that._height = height.toString().indexOf('%') !== -1 ? height : null;
  986. maxHeight = _$window.height() - wrap[0].offsetHeight + main[0].offsetHeight;
  987. scaleHeight = that._toNumber(height, maxHeight);
  988. height = scaleHeight;
  989. if (typeof height === 'number') {
  990. style.height = Math.max(that.config.minHeight, height) + 'px';
  991. } else if (typeof height === 'string') {
  992. style.height = height;
  993. };
  994. };
  995. that._ie6SelectFix();
  996. return that;
  997. },
  998. /**
  999. * 跟随元素
  1000. * @param {HTMLElement, String}
  1001. */
  1002. follow: function (elem) {
  1003. var $elem, that = this, config = that.config;
  1004. if (typeof elem === 'string' || elem && elem.nodeType === 1) {
  1005. $elem = $(elem);
  1006. elem = $elem[0];
  1007. };
  1008. // 隐藏元素不可用
  1009. if (!elem || !elem.offsetWidth && !elem.offsetHeight) {
  1010. return that.position(that._left, that._top);
  1011. };
  1012. var expando = _expando + 'follow',
  1013. winWidth = _$window.width(),
  1014. winHeight = _$window.height(),
  1015. docLeft = _$document.scrollLeft(),
  1016. docTop = _$document.scrollTop(),
  1017. offset = $elem.offset(),
  1018. width = elem.offsetWidth,
  1019. height = elem.offsetHeight,
  1020. isFixed = _isIE6 ? false : config.fixed,
  1021. left = isFixed ? offset.left - docLeft : offset.left,
  1022. top = isFixed ? offset.top - docTop : offset.top,
  1023. wrap = that.DOM.wrap[0],
  1024. style = wrap.style,
  1025. wrapWidth = wrap.offsetWidth,
  1026. wrapHeight = wrap.offsetHeight,
  1027. setLeft = left - (wrapWidth - width) / 2,
  1028. setTop = top + height,
  1029. dl = isFixed ? 0 : docLeft,
  1030. dt = isFixed ? 0 : docTop;
  1031. setLeft = setLeft < dl ? left :
  1032. (setLeft + wrapWidth > winWidth) && (left - wrapWidth > dl)
  1033. ? left - wrapWidth + width
  1034. : setLeft;
  1035. setTop = (setTop + wrapHeight > winHeight + dt)
  1036. && (top - wrapHeight > dt)
  1037. ? top - wrapHeight
  1038. : setTop;
  1039. style.left = setLeft + 'px';
  1040. style.top = setTop + 'px';
  1041. that._follow && that._follow.removeAttribute(expando);
  1042. that._follow = elem;
  1043. elem[expando] = config.id;
  1044. that._autoPositionType();
  1045. return that;
  1046. },
  1047. /**
  1048. * 自定义按钮
  1049. * @example
  1050. button({
  1051. name: 'login',
  1052. callback: function () {},
  1053. disabled: false,
  1054. focus: true
  1055. }, .., ..)
  1056. */
  1057. button: function () {
  1058. var that = this,
  1059. ags = arguments,
  1060. DOM = that.DOM,
  1061. buttons = DOM.buttons,
  1062. elem = buttons[0],
  1063. strongButton = 'aui_state_highlight',
  1064. listeners = that._listeners = that._listeners || {},
  1065. list = $.isArray(ags[0]) ? ags[0] : [].slice.call(ags);
  1066. if (ags[0] === undefined) return elem;
  1067. $.each(list, function (i, val) {
  1068. var name = val.name,
  1069. isNewButton = !listeners[name],
  1070. button = !isNewButton ?
  1071. listeners[name].elem :
  1072. document.createElement('button');
  1073. if (!listeners[name]) listeners[name] = {};
  1074. if (val.callback) listeners[name].callback = val.callback;
  1075. if (val.className) button.className = val.className;
  1076. if (val.focus) {
  1077. that._focus && that._focus.removeClass(strongButton);
  1078. that._focus = $(button).addClass(strongButton);
  1079. that.focus();
  1080. };
  1081. // Internet Explorer 的默认类型是 "button",
  1082. // 而其他浏览器中(包括 W3C 规范)的默认值是 "submit"
  1083. // @see http://www.w3school.com.cn/tags/att_button_type.asp
  1084. button.setAttribute('type', 'button');
  1085. button[_expando + 'callback'] = name;
  1086. button.disabled = !!val.disabled;
  1087. if (isNewButton) {
  1088. button.innerHTML = name;
  1089. listeners[name].elem = button;
  1090. elem.appendChild(button);
  1091. };
  1092. });
  1093. buttons[0].style.display = list.length ? '' : 'none';
  1094. that._ie6SelectFix();
  1095. return that;
  1096. },
  1097. /** 显示对话框 */
  1098. show: function () {
  1099. this.DOM.wrap.show();
  1100. !arguments[0] && this._lockMaskWrap && this._lockMaskWrap.show();
  1101. return this;
  1102. },
  1103. /** 隐藏对话框 */
  1104. hide: function () {
  1105. this.DOM.wrap.hide();
  1106. !arguments[0] && this._lockMaskWrap && this._lockMaskWrap.hide();
  1107. return this;
  1108. },
  1109. /** 关闭对话框 */
  1110. close: function () {
  1111. if (this.closed) return this;
  1112. var that = this,
  1113. DOM = that.DOM,
  1114. wrap = DOM.wrap,
  1115. list = artDialog.list,
  1116. fn = that.config.close,
  1117. follow = that.config.follow,
  1118. closeAnimatedTime = that.config.closeAnimatedTime;
  1119. function closeBefroe(){
  1120. that.time();
  1121. if (typeof fn === 'function' && fn.call(that, window) === false) {
  1122. return that;
  1123. };
  1124. that.unlock();
  1125. // 置空内容
  1126. that._elemBack && that._elemBack();
  1127. wrap[0].className = wrap[0].style.cssText = '';
  1128. DOM.title.html('');
  1129. DOM.content.html('');
  1130. DOM.buttons.html('');
  1131. if (artDialog.focus === that) artDialog.focus = null;
  1132. if (follow) follow.removeAttribute(_expando + 'follow');
  1133. delete list[that.config.id];
  1134. that._removeEvent();
  1135. that.hide(true)._setAbsolute();
  1136. // 清空除this.DOM之外临时对象,恢复到初始状态,以便使用单例模式
  1137. for (var i in that) {
  1138. if (that.hasOwnProperty(i) && i !== 'DOM') delete that[i];
  1139. }
  1140. //wrap.remove();
  1141. // 移除HTMLElement或重用
  1142. _box ? wrap.remove() : _box = that;
  1143. }
  1144. if(closeAnimatedTime != 0){
  1145. wrap.animate({opacity: 0}, closeAnimatedTime,'linear',function(){
  1146. closeBefroe();
  1147. //wrap.remove();
  1148. });
  1149. }else{
  1150. closeBefroe();
  1151. //wrap.remove();
  1152. }
  1153. return that;
  1154. },
  1155. /**
  1156. * 定时关闭
  1157. * @param {Number} 单位为秒, 无参数则停止计时器
  1158. */
  1159. time: function (second) {
  1160. var that = this,
  1161. cancel = that.config.cancelVal,
  1162. timer = that._timer,
  1163. wrap = that.DOM.wrap,
  1164. mouseenterOffTime = that.config.mouseenterOffTime;
  1165. timer && clearTimeout(timer);
  1166. if(mouseenterOffTime){
  1167. wrap[0].onmouseover = function(){
  1168. that.offTimeB = true;
  1169. }
  1170. wrap[0].onmouseout = function(){
  1171. that.offTimeB = false;
  1172. }
  1173. }
  1174. if (second) {
  1175. function timerFun (){
  1176. that._timer = setTimeout(function(){
  1177. if(mouseenterOffTime && that.offTimeB){
  1178. setTimeout(function(){
  1179. timerFun();
  1180. },1000 * second);
  1181. }else{
  1182. that._click(cancel);
  1183. }
  1184. }, 1000 * second);
  1185. }
  1186. timerFun();
  1187. }
  1188. return that;
  1189. },
  1190. /** 设置焦点 */
  1191. focus: function () {
  1192. try {
  1193. if (this.config.focus) {
  1194. var elem = this._focus && this._focus[0] || this.DOM.close[0];
  1195. elem && elem.focus();
  1196. }
  1197. } catch (e) {}; // IE对不可见元素设置焦点会报错
  1198. return this;
  1199. },
  1200. /** 置顶对话框 */
  1201. zIndex: function () {
  1202. var that = this,
  1203. DOM = that.DOM,
  1204. wrap = DOM.wrap,
  1205. top = artDialog.focus,
  1206. index = artDialog.defaults.zIndex ++;
  1207. // 设置叠加高度
  1208. wrap.css('zIndex', index);
  1209. that._lockMask && that._lockMask.css('zIndex', index - 1);
  1210. // 设置最高层的样式
  1211. top && top.DOM.wrap.removeClass('aui_state_focus');
  1212. artDialog.focus = that;
  1213. wrap.addClass('aui_state_focus');
  1214. return that;
  1215. },
  1216. /** 设置屏锁 */
  1217. lock: function () {
  1218. if (this._lock) return this;
  1219. var that = this,
  1220. index = artDialog.defaults.zIndex - 1,
  1221. wrap = that.DOM.wrap,
  1222. config = that.config,
  1223. docWidth = _$document.width(),
  1224. docHeight = _$document.height(),
  1225. lockMaskWrap = that._lockMaskWrap || $(document.body.appendChild(document.createElement('div'))),
  1226. lockMask = that._lockMask || $(lockMaskWrap[0].appendChild(document.createElement('div'))),
  1227. domTxt = '(document).documentElement',
  1228. sizeCss = _isMobile ? 'width:' + docWidth + 'px;height:' + docHeight
  1229. + 'px' : 'width:100%;height:100%',
  1230. ie6Css = _isIE6 ?
  1231. 'position:absolute;left:expression(' + domTxt + '.scrollLeft);top:expression('
  1232. + domTxt + '.scrollTop);width:expression(' + domTxt
  1233. + '.clientWidth);height:expression(' + domTxt + '.clientHeight)'
  1234. : '';
  1235. that.zIndex();
  1236. wrap.addClass('aui_state_lock');
  1237. lockMaskWrap[0].style.cssText = sizeCss + ';position:fixed;z-index:'
  1238. + index + ';top:0;left:0;overflow:hidden;' + ie6Css;
  1239. lockMask[0].style.cssText = 'height:100%;background:' + config.background
  1240. + ';filter:alpha(opacity=0);opacity:0';
  1241. // 让IE6锁屏遮罩能够盖住下拉控件
  1242. if (_isIE6) lockMask.html(
  1243. '<iframe src="about:blank" style="width:100%;height:100%;position:absolute;' +
  1244. 'top:0;left:0;z-index:-1;filter:alpha(opacity=0)"></iframe>');
  1245. lockMask.stop();
  1246. lockMask.bind('click', function () {
  1247. that._reset();
  1248. }).bind('dblclick', function () {
  1249. return false;
  1250. //that._click(that.config.cancelVal);
  1251. });
  1252. if (config.duration === 0) {
  1253. lockMask.css({opacity: config.opacity});
  1254. } else {
  1255. lockMask.animate({opacity: config.opacity}, config.duration);
  1256. };
  1257. if(config.quickClose){
  1258. lockMaskWrap.bind('click',function(){
  1259. that._click(that.config.cancelVal);
  1260. });
  1261. }
  1262. that._lockMaskWrap = lockMaskWrap;
  1263. that._lockMask = lockMask;
  1264. that._lock = true;
  1265. return that;
  1266. },
  1267. /** 解开屏锁 */
  1268. unlock: function (b) {
  1269. var that = this,
  1270. lockMaskWrap = that._lockMaskWrap,
  1271. lockMask = that._lockMask;
  1272. if (!that._lock) return that;
  1273. if(b){
  1274. $(lockMaskWrap[0]).remove();
  1275. return that;
  1276. }
  1277. var style = lockMaskWrap[0].style;
  1278. var un = function () {
  1279. if (_isIE6) {
  1280. style.removeExpression('width');
  1281. style.removeExpression('height');
  1282. style.removeExpression('left');
  1283. style.removeExpression('top');
  1284. };
  1285. style.cssText = 'display:none';
  1286. _box && lockMaskWrap.remove();
  1287. };
  1288. lockMask.stop().unbind();
  1289. that.DOM.wrap.removeClass('aui_state_lock');
  1290. if (!that.config.duration) {// 取消动画,快速关闭
  1291. un();
  1292. } else {
  1293. lockMask.animate({opacity: 0}, that.config.duration, un);
  1294. };
  1295. that._lock = false;
  1296. return that;
  1297. },
  1298. // 获取元素
  1299. _getDOM: function () {
  1300. var wrap = document.createElement('div'),
  1301. body = document.body;
  1302. wrap.style.cssText = 'position:absolute;left:0;top:0';
  1303. wrap.innerHTML = artDialog._templates;
  1304. body.insertBefore(wrap, body.firstChild);
  1305. var name, i = 0,
  1306. DOM = {wrap: $(wrap)},
  1307. els = wrap.getElementsByTagName('*'),
  1308. elsLen = els.length;
  1309. for (; i < elsLen; i ++) {
  1310. name = els[i].className.split('aui_')[1];
  1311. if (name) DOM[name] = $(els[i]);
  1312. };
  1313. return DOM;
  1314. },
  1315. // px与%单位转换成数值 (百分比单位按照最大值换算)
  1316. // 其他的单位返回原值
  1317. _toNumber: function (thisValue, maxValue) {
  1318. if (!thisValue && thisValue !== 0 || typeof thisValue === 'number') {
  1319. return thisValue;
  1320. };
  1321. var last = thisValue.length - 1;
  1322. if (thisValue.lastIndexOf('px') === last) {
  1323. thisValue = parseInt(thisValue);
  1324. } else if (thisValue.lastIndexOf('%') === last) {
  1325. thisValue = parseInt(maxValue * thisValue.split('%')[0] / 100);
  1326. };
  1327. return thisValue;
  1328. },
  1329. // 让IE6 CSS支持PNG背景
  1330. _ie6PngFix: _isIE6 ? function () {
  1331. var i = 0, elem, png, pngPath, runtimeStyle,
  1332. path = artDialog.defaults.path + '/skins/',
  1333. list = this.DOM.wrap[0].getElementsByTagName('*');
  1334. for (; i < list.length; i ++) {
  1335. elem = list[i];
  1336. png = elem.currentStyle['png'];
  1337. if (png) {
  1338. pngPath = path + png;
  1339. runtimeStyle = elem.runtimeStyle;
  1340. runtimeStyle.backgroundImage = 'none';
  1341. runtimeStyle.filter = "progid:DXImageTransform.Microsoft." +
  1342. "AlphaImageLoader(src='" + pngPath + "',sizingMethod='crop')";
  1343. };
  1344. };
  1345. } : $.noop,
  1346. // 强制覆盖IE6下拉控件
  1347. _ie6SelectFix: _isIE6 ? function () {
  1348. var $wrap = this.DOM.wrap,
  1349. wrap = $wrap[0],
  1350. expando = _expando + 'iframeMask',
  1351. iframe = $wrap[expando],
  1352. width = wrap.offsetWidth,
  1353. height = wrap.offsetHeight;
  1354. width = width + 'px';
  1355. height = height + 'px';
  1356. if (iframe) {
  1357. iframe.style.width = width;
  1358. iframe.style.height = height;
  1359. } else {
  1360. iframe = wrap.appendChild(document.createElement('iframe'));
  1361. $wrap[expando] = iframe;
  1362. iframe.src = 'about:blank';
  1363. iframe.style.cssText = 'position:absolute;z-index:-1;left:0;top:0;'
  1364. + 'filter:alpha(opacity=0);width:' + width + ';height:' + height;
  1365. };
  1366. } : $.noop,
  1367. // 解析HTML片段中自定义类型脚本,其this指向artDialog内部
  1368. // <script type="text/dialog">/* [code] */</script>
  1369. _runScript: function (elem) {
  1370. var fun, i = 0, n = 0,
  1371. tags = elem.getElementsByTagName('script'),
  1372. length = tags.length,
  1373. script = [];
  1374. for (; i < length; i ++) {
  1375. if (tags[i].type === 'text/dialog') {
  1376. script[n] = tags[i].innerHTML;
  1377. n ++;
  1378. };
  1379. };
  1380. if (script.length) {
  1381. script = script.join('');
  1382. fun = new Function(script);
  1383. fun.call(this);
  1384. };
  1385. },
  1386. // 自动切换定位类型
  1387. _autoPositionType: function () {
  1388. this[this.config.fixed ? '_setFixed' : '_setAbsolute']();/////////////
  1389. },
  1390. // 设置静止定位
  1391. // IE6 Fixed @see: http://www.planeart.cn/?p=877
  1392. _setFixed: (function () {
  1393. _isIE6 && $(function () {
  1394. var bg = 'backgroundAttachment';
  1395. if (_$html.css(bg) !== 'fixed' && $('body').css(bg) !== 'fixed') {
  1396. _$html.css({
  1397. zoom: 1,// 避免偶尔出现body背景图片异常的情况
  1398. backgroundImage: 'url(about:blank)',
  1399. backgroundAttachment: 'fixed'
  1400. });
  1401. };
  1402. });
  1403. return function () {
  1404. var $elem = this.DOM.wrap,
  1405. style = $elem[0].style;
  1406. if (_isIE6) {
  1407. var left = parseInt($elem.css('left')),
  1408. top = parseInt($elem.css('top')),
  1409. sLeft = _$document.scrollLeft(),
  1410. sTop = _$document.scrollTop(),
  1411. txt = '(document.documentElement)';
  1412. this._setAbsolute();
  1413. style.setExpression('left', 'eval(' + txt + '.scrollLeft + '
  1414. + (left - sLeft) + ') + "px"');
  1415. style.setExpression('top', 'eval(' + txt + '.scrollTop + '
  1416. + (top - sTop) + ') + "px"');
  1417. } else {
  1418. style.position = 'fixed';
  1419. };
  1420. };
  1421. }()),
  1422. // 设置绝对定位
  1423. _setAbsolute: function () {
  1424. var style = this.DOM.wrap[0].style;
  1425. if (_isIE6) {
  1426. style.removeExpression('left');
  1427. style.removeExpression('top');
  1428. };
  1429. style.position = 'absolute';
  1430. },
  1431. // 按钮回调函数触发
  1432. _click: function (name) {
  1433. var that = this,
  1434. fn = that._listeners[name] && that._listeners[name].callback;
  1435. return typeof fn !== 'function' || fn.call(that, window) !== false ?
  1436. that.close() : that;
  1437. },
  1438. // 重置位置与尺寸
  1439. _reset: function (test) {
  1440. var newSize,
  1441. that = this,
  1442. oldSize = that._winSize || _$window.width() * _$window.height(),
  1443. elem = that._follow,
  1444. width = that._width,
  1445. height = that._height,
  1446. left = that._left,
  1447. top = that._top;
  1448. if (test) {
  1449. // IE6~7 window.onresize bug
  1450. newSize = that._winSize = _$window.width() * _$window.height();
  1451. if (oldSize === newSize) return;
  1452. };
  1453. if (width || height) that.size(width, height);
  1454. if (elem) {
  1455. that.follow(elem);
  1456. } else if (left || top) {
  1457. that.position(left, top);
  1458. };
  1459. },
  1460. // 事件代理
  1461. _addEvent: function () {
  1462. var resizeTimer,
  1463. that = this,
  1464. config = that.config,
  1465. isIE = 'CollectGarbage' in window,
  1466. DOM = that.DOM;
  1467. // 窗口调节事件
  1468. that._winResize = function () {
  1469. resizeTimer && clearTimeout(resizeTimer);
  1470. resizeTimer = setTimeout(function () {
  1471. that._reset(isIE);
  1472. }, 40);
  1473. };
  1474. _$window.bind('resize', that._winResize);
  1475. // 监听点击
  1476. DOM.wrap
  1477. .bind('click', function (event) {
  1478. var target = event.target, callbackID;
  1479. if (target.disabled) return false; // IE BUG
  1480. if (target === DOM.close[0]) {
  1481. that._click(config.cancelVal);
  1482. return false;
  1483. } else {
  1484. callbackID = target[_expando + 'callback'];
  1485. callbackID && that._click(callbackID);
  1486. };
  1487. that._ie6SelectFix();
  1488. })
  1489. .bind('mousedown', function () {
  1490. that.zIndex();
  1491. });
  1492. },
  1493. // 卸载事件代理
  1494. _removeEvent: function () {
  1495. var that = this,
  1496. DOM = that.DOM;
  1497. DOM.wrap.unbind();
  1498. _$window.unbind('resize', that._winResize);
  1499. }
  1500. };
  1501. artDialog.fn._init.prototype = artDialog.fn;
  1502. $.fn.dialog = $.fn.artDialog = function () {
  1503. var config = arguments;
  1504. this[this.live ? 'live' : 'bind']('click', function () {
  1505. artDialog.apply(this, config);
  1506. return false;
  1507. });
  1508. return this;
  1509. };
  1510. /** 最顶层的对话框API */
  1511. artDialog.focus = null;
  1512. /** 获取某对话框API */
  1513. artDialog.get = function (id) {
  1514. return id === undefined
  1515. ? artDialog.list
  1516. : artDialog.list[id];
  1517. };
  1518. artDialog.list = {};
  1519. // 全局快捷键
  1520. _$document.bind('keydown', function (event) {
  1521. var target = event.target,
  1522. nodeName = target.nodeName,
  1523. rinput = /^INPUT|TEXTAREA$/,
  1524. api = artDialog.focus,
  1525. keyCode = event.keyCode;
  1526. if (!api || !api.config.esc || rinput.test(nodeName)) return;
  1527. keyCode === 27 && api._click(api.config.cancelVal);
  1528. });
  1529. // 获取artDialog路径
  1530. _path = window['_artDialog_path'] || (function (script, i, me) {
  1531. for (i in script) {
  1532. // 如果通过第三方脚本加载器加载本文件,请保证文件名含有"artDialog"字符
  1533. if (script[i].src && script[i].src.indexOf('artDialog') !== -1) me = script[i];
  1534. };
  1535. _thisScript = me || script[script.length - 1];
  1536. me = _thisScript.src.replace(/\\/g, '/');
  1537. return me.lastIndexOf('/') < 0 ? '.' : me.substring(0, me.lastIndexOf('/'));
  1538. }(document.getElementsByTagName('script')));
  1539. // 无阻塞载入CSS (如"artDialog.js?skin=aero")
  1540. _skin = _thisScript.src.split('skin=')[1];
  1541. if (_skin) {
  1542. var link = document.createElement('link');
  1543. link.rel = 'stylesheet';
  1544. link.href = _path + '/skins/' + _skin + '.css?' + artDialog.fn.version;
  1545. _thisScript.parentNode.insertBefore(link, _thisScript);
  1546. };
  1547. // 触发浏览器预先缓存背景图片
  1548. _$window.bind('load', function () {
  1549. setTimeout(function () {
  1550. if (_count) return;
  1551. artDialog({left: '-9999em',time: 0,fixed: false,lock: false,focus: false});
  1552. }, 150);
  1553. });
  1554. // 开启IE6 CSS背景图片缓存
  1555. try {
  1556. document.execCommand('BackgroundImageCache', false, true);
  1557. } catch (e) {};
  1558. // 使用uglifyjs压缩能够预先处理"+"号合并字符串
  1559. // uglifyjs: http://marijnhaverbeke.nl/uglifyjs
  1560. artDialog._templates =
  1561. '<div class="aui_outer">'
  1562. + '<table class="aui_border">'
  1563. + '<tbody>'
  1564. + '<tr>'
  1565. + '<td class="aui_nw"></td>'
  1566. + '<td class="aui_n"></td>'
  1567. + '<td class="aui_ne"></td>'
  1568. + '</tr>'
  1569. + '<tr>'
  1570. + '<td class="aui_w"></td>'
  1571. + '<td class="aui_c">'
  1572. + '<div class="aui_inner">'
  1573. + '<table class="aui_dialog">'
  1574. + '<tbody>'
  1575. + '<tr id="aui_dialog_title">'
  1576. + '<td colspan="2" class="aui_header">'
  1577. + '<div class="aui_titleBar">'
  1578. + '<div class="aui_title"></div>'
  1579. + '<a class="aui_close" href="javascript:/*artDialog*/;">'
  1580. + '\xd7'
  1581. + '</a>'
  1582. + '</div>'
  1583. + '</td>'
  1584. + '</tr>'
  1585. + '<tr>'
  1586. + '<td class="aui_icon">'
  1587. + '<div class="aui_iconBg"></div>'
  1588. + '</td>'
  1589. + '<td class="aui_main">'
  1590. + '<div class="aui_content"></div>'
  1591. + '</td>'
  1592. + '</tr>'
  1593. + '<tr>'
  1594. + '<td colspan="2" class="aui_footer">'
  1595. + '<div class="aui_buttons"></div>'
  1596. + '</td>'
  1597. + '</tr>'
  1598. + '</tbody>'
  1599. + '</table>'
  1600. + '</div>'
  1601. + '</td>'
  1602. + '<td class="aui_e"></td>'
  1603. + '</tr>'
  1604. + '<tr>'
  1605. + '<td class="aui_sw"></td>'
  1606. + '<td class="aui_s"></td>'
  1607. + '<td class="aui_se"></td>'
  1608. + '</tr>'
  1609. + '</tbody>'
  1610. + '</table>'
  1611. +'</div>';
  1612. /**
  1613. * 默认配置
  1614. */
  1615. artDialog.defaults = {
  1616. content: '<div class="aui_loading"><span>loading..</span></div>', // 消息内容
  1617. title: '\u6d88\u606f', // 标题. 默认'消息'
  1618. button: null, // 自定义按钮
  1619. ok: null, // 确定按钮回调函数
  1620. cancel: null, // 取消按钮回调函数
  1621. init: null, // 对话框初始化后执行的函数
  1622. close: null, // 对话框关闭前执行的函数
  1623. okVal: '\u786E\u5B9A', // 确定按钮文本. 默认'确定'
  1624. cancelVal: '\u53D6\u6D88', // 取消按钮文本. 默认'取消'
  1625. width: 'auto', // 内容宽度
  1626. height: 'auto', // 内容高度
  1627. minWidth: 96, // 最小宽度限制
  1628. minHeight: 32, // 最小高度限制
  1629. overflow:false, // 内容滚动条
  1630. padding: '20px 25px', // 内容与边界填充距离
  1631. skin: '', // 皮肤名(预留接口,尚未实现)
  1632. icon: null, // 消息图标名称
  1633. time: null, // 自动关闭时间
  1634. esc: true, // 是否支持Esc键关闭
  1635. quickClose:false, // 是否支持快捷关闭(点击遮罩层自动关闭)
  1636. focus: true, // 是否支持对话框按钮自动聚焦
  1637. show: true, // 初始化后是否显示对话框
  1638. follow: null, // 跟随某元素(即让对话框在元素附近弹出)
  1639. path: _path, // artDialog路径
  1640. lock: false, // 是否锁屏
  1641. background: '#000', // 遮罩颜色
  1642. opacity: .7, // 遮罩透明度
  1643. duration: 300, // 遮罩透明度渐变动画速度
  1644. fixed: true, // 是否静止定位
  1645. left: '50%', // X轴坐标
  1646. top: '38.2%', // Y轴坐标
  1647. zIndex: 1987, // 对话框叠加高度值(重要:此值不能超过浏览器最大限制)
  1648. resize: true, // 是否允许用户调节尺寸
  1649. drag: true, // 是否允许用户拖动位置
  1650. artIcon: '', // 标题旁边的图标,
  1651. tips: false, // 提示框
  1652. closeAnimatedTime:0, // 对话框关闭时的动画时间
  1653. mouseenterOffTime:false // 自动关闭开始时鼠标移入取消自闭,移出再次开启
  1654. };
  1655. window.artDialog = $.dialog = $.artDialog = artDialog;
  1656. }(this.art || this.jQuery && (this.art = jQuery), this));
  1657. //------------------------------------------------
  1658. // 对话框模块-拖拽支持(可选外置模块)
  1659. //------------------------------------------------
  1660. ;(function ($) {
  1661. var _dragEvent, _use,
  1662. _$window = $(window),
  1663. _$document = $(document),
  1664. _elem = document.documentElement,
  1665. _isIE6 = !('minWidth' in _elem.style),
  1666. _isLosecapture = 'onlosecapture' in _elem,
  1667. _isSetCapture = 'setCapture' in _elem;
  1668. // 拖拽事件
  1669. artDialog.dragEvent = function () {
  1670. var that = this,
  1671. proxy = function (name) {
  1672. var fn = that[name];
  1673. that[name] = function () {
  1674. return fn.apply(that, arguments);
  1675. };
  1676. };
  1677. proxy('start');
  1678. proxy('move');
  1679. proxy('end');
  1680. };
  1681. artDialog.dragEvent.prototype = {
  1682. // 开始拖拽
  1683. onstart: $.noop,
  1684. start: function (event) {
  1685. _$document
  1686. .bind('mousemove', this.move)
  1687. .bind('mouseup', this.end);
  1688. this._sClientX = event.clientX;
  1689. this._sClientY = event.clientY;
  1690. this.onstart(event.clientX, event.clientY);
  1691. return false;
  1692. },
  1693. // 正在拖拽
  1694. onmove: $.noop,
  1695. move: function (event) {
  1696. this._mClientX = event.clientX;
  1697. this._mClientY = event.clientY;
  1698. this.onmove(
  1699. event.clientX - this._sClientX,
  1700. event.clientY - this._sClientY
  1701. );
  1702. return false;
  1703. },
  1704. // 结束拖拽
  1705. onend: $.noop,
  1706. end: function (event) {
  1707. _$document
  1708. .unbind('mousemove', this.move)
  1709. .unbind('mouseup', this.end);
  1710. this.onend(event.clientX, event.clientY);
  1711. return false;
  1712. }
  1713. };
  1714. _use = function (event) {
  1715. var limit, startWidth, startHeight, startLeft, startTop, isResize,
  1716. api = artDialog.focus,
  1717. //config = api.config,
  1718. DOM = api.DOM,
  1719. wrap = DOM.wrap,
  1720. title = DOM.title,
  1721. main = DOM.main;
  1722. // 清除文本选择
  1723. var clsSelect = 'getSelection' in window ? function () {
  1724. window.getSelection().removeAllRanges();
  1725. } : function () {
  1726. try {
  1727. document.selection.empty();
  1728. } catch (e) {};
  1729. };
  1730. // 对话框准备拖动
  1731. _dragEvent.onstart = function (x, y) {
  1732. if (isResize) {
  1733. startWidth = main[0].offsetWidth;
  1734. startHeight = main[0].offsetHeight;
  1735. } else {
  1736. startLeft = wrap[0].offsetLeft;
  1737. startTop = wrap[0].offsetTop;
  1738. };
  1739. _$document.bind('dblclick', _dragEvent.end);
  1740. !_isIE6 && _isLosecapture ?
  1741. title.bind('losecapture', _dragEvent.end) :
  1742. _$window.bind('blur', _dragEvent.end);
  1743. _isSetCapture && title[0].setCapture();
  1744. wrap.addClass('aui_state_drag');
  1745. api.focus();
  1746. };
  1747. // 对话框拖动进行中
  1748. _dragEvent.onmove = function (x, y) {
  1749. if (isResize) {
  1750. var wrapStyle = wrap[0].style,
  1751. style = main[0].style,
  1752. width = x + startWidth,
  1753. height = y + startHeight;
  1754. wrapStyle.width = 'auto';
  1755. style.width = Math.max(0, width) + 'px';
  1756. wrapStyle.width = wrap[0].offsetWidth + 'px';
  1757. style.height = Math.max(0, height) + 'px';
  1758. } else {
  1759. var style = wrap[0].style,
  1760. left = Math.max(limit.minX, Math.min(limit.maxX, x + startLeft)),
  1761. top = Math.max(limit.minY, Math.min(limit.maxY, y + startTop));
  1762. style.left = left + 'px';
  1763. style.top = top + 'px';
  1764. };
  1765. clsSelect();
  1766. api._ie6SelectFix();
  1767. };
  1768. // 对话框拖动结束
  1769. _dragEvent.onend = function (x, y) {
  1770. _$document.unbind('dblclick', _dragEvent.end);
  1771. !_isIE6 && _isLosecapture ?
  1772. title.unbind('losecapture', _dragEvent.end) :
  1773. _$window.unbind('blur', _dragEvent.end);
  1774. _isSetCapture && title[0].releaseCapture();
  1775. _isIE6 && !api.closed && api._autoPositionType();
  1776. wrap.removeClass('aui_state_drag');
  1777. };
  1778. isResize = event.target === DOM.se[0] ? true : false;
  1779. limit = (function () {
  1780. var maxX, maxY,
  1781. wrap = api.DOM.wrap[0],
  1782. fixed = wrap.style.position === 'fixed',
  1783. ow = wrap.offsetWidth,
  1784. oh = wrap.offsetHeight,
  1785. ww = _$window.width(),
  1786. wh = _$window.height(),
  1787. dl = fixed ? 0 : _$document.scrollLeft(),
  1788. dt = fixed ? 0 : _$document.scrollTop(),
  1789. // 坐标最大值限制
  1790. maxX = ww - ow + dl;
  1791. maxY = wh - oh + dt;
  1792. return {
  1793. minX: dl,
  1794. minY: dt,
  1795. maxX: maxX,
  1796. maxY: maxY
  1797. };
  1798. })();
  1799. _dragEvent.start(event);
  1800. };
  1801. // 代理 mousedown 事件触发对话框拖动
  1802. _$document.bind('mousedown', function (event) {
  1803. var api = artDialog.focus;
  1804. if (!api) return;
  1805. var target = event.target,
  1806. config = api.config,
  1807. DOM = api.DOM;
  1808. if (config.drag !== false && target === DOM.title[0]
  1809. || config.resize !== false && target === DOM.se[0]) {
  1810. _dragEvent = _dragEvent || new artDialog.dragEvent();
  1811. _use(event);
  1812. return false;// 防止firefox与chrome滚屏
  1813. };
  1814. });
  1815. })(this.art || this.jQuery && (this.art = jQuery));