Aucune description
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

dialog.js 46KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514
  1. __DIALOG_WRAPPER__ = {};
  2. /* IE6有个Bug,如果不给定对话框的宽度的话,在IE6下,对话框将以100%宽度显示 */
  3. DialogManager = {
  4. 'create' :function(id){
  5. var d = {};
  6. if (!__DIALOG_WRAPPER__[id])
  7. {
  8. d = new Dialog(id);
  9. __DIALOG_WRAPPER__[id] = d;
  10. }
  11. else
  12. {
  13. d = DialogManager.get(id);
  14. }
  15. return d;
  16. },
  17. 'get' :function(id){
  18. return __DIALOG_WRAPPER__[id];
  19. },
  20. 'set' :function(id, val){
  21. __DIALOG_WRAPPER__[id] = val;
  22. },
  23. 'close' :function(id){
  24. if (__DIALOG_WRAPPER__[id].close())
  25. {
  26. __DIALOG_WRAPPER__[id] = null;
  27. }
  28. },
  29. 'onClose' :function (){
  30. return true;
  31. },
  32. /* 加载对话框样式 */
  33. 'loadStyle' :function(){
  34. var _dialog_js_path = $('#dialog_js').attr('src');
  35. var _path = _dialog_js_path.split('/');
  36. var _dialog_css = _path.slice(0, _path.length - 1).join('/') + '/dialog.css';
  37. $('#dialog_js').after('<link href="' + _dialog_css + '" rel="stylesheet" type="text/css" />');
  38. }
  39. };
  40. ScreenLocker = {
  41. 'style' : {
  42. 'position' : 'absolute',
  43. 'top' : '0',
  44. 'left' : '0',
  45. 'backgroundColor' : '#000000',
  46. 'opacity' : 0.25,
  47. 'zIndex' : 999
  48. },
  49. 'masker' : null,
  50. 'lock' : function(zIndex){
  51. if (this.masker !== null)
  52. {
  53. this.masker.width($(document).width()).height($(document).height());
  54. return true;
  55. }
  56. this.masker = $('<div id="dialog_manage_screen_locker"></div>');
  57. /* 样式 */
  58. this.masker.css(this.style);
  59. if (zIndex)
  60. {
  61. this.masker.css('zIndex', zIndex);
  62. }
  63. /* 整个文档的宽高 */
  64. this.masker.width($(document).width()).height($(document).height());
  65. $(document.body).append(this.masker);
  66. $("#dialog_manage_screen_locker").show();
  67. },
  68. 'unlock' : function(){
  69. if (this.masker === null)
  70. {
  71. return true;
  72. }
  73. this.masker.remove();
  74. this.masker = null;
  75. }
  76. };
  77. Dialog = function (id){
  78. /* 构造函数生成对话框代码,并加入到文档中 */
  79. this.id = id;
  80. this.init();
  81. };
  82. Dialog.prototype = {
  83. /* 唯一标识 */
  84. 'id' : null,
  85. /* 文档对象 */
  86. 'dom' : null,
  87. 'lastPos' : null,
  88. 'status' : 'complete',
  89. 'onClose' : function (){
  90. return true;
  91. },
  92. 'tmp' : {},
  93. /* 初始化 */
  94. 'init' : function(){
  95. this.dom = {'wrapper' : null, 'body':null, 'head':null, 'title':null, 'close_button':null, 'content':null};
  96. /* 创建外层容器 */
  97. this.dom.wrapper = $('<div id="fwin_' + this.id + '" class="dialog_wrapper"></div>').get(0);
  98. /* 创建对话框主体 */
  99. this.dom.body = $('<div class="dialog_body"></div>').get(0);
  100. /* 创建标题栏 */
  101. this.dom.head = $('<h3 class="dialog_head"></h3>').get(0);
  102. /* 创建标题文本 */
  103. this.dom.title = $('<span class="dialog_title_icon"></span>').get(0);
  104. /* 创建关闭按钮 */
  105. this.dom.close_button = $('<span class="dialog_close_button">X</span>').get(0);
  106. /* 创建内容区域 */
  107. this.dom.content = $('<div class="dialog_content"></div>').get(0);
  108. /* 组合 */
  109. $(this.dom.head).append($('<span class="dialog_title"></span>').append(this.dom.title)).append(this.dom.close_button);
  110. $(this.dom.body).append(this.dom.head).append(this.dom.content);
  111. $(this.dom.wrapper).append(this.dom.body).append('<div style="clear:both; display:block;"></div>');
  112. /* 初始化样式 */
  113. $(this.dom.wrapper).css({
  114. 'zIndex' : 1100,
  115. 'display' : 'none',
  116. 'position' : 'absolute'
  117. });
  118. $(this.dom.body).css({
  119. 'position' : 'relative'
  120. });
  121. $(this.dom.head).css({
  122. 'cursor' : 'move'
  123. });
  124. $(this.dom.content).css({
  125. 'margin' : '0px',
  126. 'padding' : '0px'
  127. });
  128. var self = this;
  129. /* 初始化组件事件 */
  130. $(this.dom.close_button).click(function(){
  131. DialogManager.close(self.id);
  132. });
  133. /* 可拖放 */
  134. // if(typeof draggable != 'undefined'){
  135. // $(this.dom.wrapper).draggable({
  136. // 'handle' : this.dom.head
  137. // });
  138. // }
  139. /* 放入文档流 */
  140. $(document.body).append(this.dom.wrapper);
  141. },
  142. /* 隐藏 */
  143. 'hide' : function(){
  144. $(this.dom.wrapper).hide();
  145. },
  146. /* 显示 */
  147. 'show' : function(pos,lock){
  148. if (pos)
  149. {
  150. this.setPosition(pos);
  151. }
  152. /* 锁定屏幕 */
  153. if (lock == 1) ScreenLocker.lock(999);
  154. $(this.dom.wrapper).draggable({
  155. 'handle' : this.dom.head
  156. });
  157. /* 显示对话框 */
  158. $(this.dom.wrapper).show();
  159. },
  160. /* 关闭 */
  161. 'close' : function(lock){
  162. if (!this.onClose())
  163. {
  164. return false;
  165. }
  166. /* 关闭对话框 */
  167. $(this.dom.wrapper).remove();
  168. /* 解锁屏幕 */
  169. if (typeof lock == 'undefined'){
  170. ScreenLocker.unlock();
  171. }
  172. DialogManager.set(this.id,null);
  173. return true;
  174. },
  175. /* 对话框标题 */
  176. 'setTitle' : function(title){
  177. $(this.dom.title).html(title);
  178. },
  179. /* 改变对话框内容 */
  180. 'setContents' : function(type, options){
  181. contents = this.createContents(type, options);
  182. if (typeof(contents) == 'string')
  183. {
  184. $(this.dom.content).html(contents);
  185. }
  186. else
  187. {
  188. $(this.dom.content).empty();
  189. $(this.dom.content).append(contents);
  190. }
  191. },
  192. /* 设置对话框样式 */
  193. 'setStyle' : function(style){
  194. if (typeof(style) == 'object')
  195. {
  196. /* 否则为CSS */
  197. $(this.dom.wrapper).css(style);
  198. }
  199. else
  200. {
  201. /* 如果是字符串,则认为是样式名 */
  202. $(this.dom.wrapper).addClass(style);
  203. }
  204. },
  205. 'setWidth' : function(width){
  206. this.setStyle({'width' : width + 'px'});
  207. },
  208. 'setHeight' : function(height){
  209. this.setStyle({'height' : height + 'px'});
  210. },
  211. /* 生成对话框内容 */
  212. 'createContents' : function(type, options){
  213. var _html = '',
  214. self = this,
  215. status= 'complete';
  216. if (!options)
  217. {
  218. /* 如果只有一个参数,则认为其传递的是HTML字符串 */
  219. this.setStatus(status);
  220. return type;
  221. }
  222. switch(type){
  223. case 'ajax':
  224. /* 通过Ajax取得HTML,显示到页面上,此过程是异步的 */
  225. $.get(options, function(data){
  226. self.setContents(data);
  227. /* 使用上次定位重新定位窗口位置 */
  228. self.setPosition(self.lastPos);
  229. });
  230. /* 先提示正在加载 */
  231. _html = this.createContents('loading', {'text' : 'loading...'});
  232. break;
  233. case 'ajax_notice':
  234. /* 通过Ajax取得HTML,显示到页面上,此过程是异步的 */
  235. $.get(options, function(data) {
  236. var json = eval('(' + data + ')');
  237. var MsgTxt = '<div class="dialog_message_body"></div><div class="dialog_message_contents dialog_message_notice">' + json.Msg + '</div><div class="dialog_buttons_bar"></div>'
  238. self.setContents(MsgTxt);
  239. /* 使用上次定位重新定位窗口位置 */
  240. self.setPosition(self.lastPos);
  241. });
  242. /* 先提示正在加载 */
  243. _html = this.createContents('loading', { 'text': '正在处理...' });
  244. break;
  245. /* 以下是内置的几种对话框类型 */
  246. case 'loading':
  247. _html = '<div class="dialog_loading"><div class="dialog_loading_text">' + options.text + '</div></div>';
  248. status = 'loading';
  249. break;
  250. case 'message':
  251. var type = 'notice';
  252. if (options.type)
  253. {
  254. type = options.type;
  255. }
  256. _message_body = $('<div class="dialog_message_body"></div>');
  257. _message_contents = $('<div class="dialog_message_contents dialog_message_' + type + '">' + options.text + '</div>');
  258. _buttons_bar = $('<div class="dialog_buttons_bar"></div>');
  259. switch (type){
  260. case 'notice':
  261. case 'warning':
  262. var button_name = '确定';
  263. if (options.button_name)
  264. {
  265. button_name = options.button_name;
  266. }
  267. _ok_button = $('<input type="button" class="btn1" value="' + button_name + '" />');
  268. $(_ok_button).click(function(){
  269. if (options.onclick)
  270. {
  271. if(!options.onclick.call())
  272. {
  273. return;
  274. }
  275. }
  276. DialogManager.close(self.id);
  277. });
  278. $(_buttons_bar).append(_ok_button);
  279. break;
  280. case 'confirm':
  281. var yes_button_name = "确定";
  282. var no_button_name = "取消";
  283. if (options.yes_button_name)
  284. {
  285. yes_button_name = options.yes_button_name;
  286. }
  287. if (options.no_button_name)
  288. {
  289. no_button_name = options.no_button_name;
  290. }
  291. _yes_button = $('<input type="button" class="btn1" value="' + yes_button_name + '" />');
  292. _no_button = $('<input type="button" class="btn2" value="' + no_button_name + '" />');
  293. $(_yes_button).click(function(){
  294. if (options.onClickYes)
  295. {
  296. if (options.onClickYes.call() === false)
  297. {
  298. return;
  299. }
  300. }
  301. DialogManager.close(self.id);
  302. });
  303. $(_no_button).click(function(){
  304. if (options.onClickNo)
  305. {
  306. if (!options.onClickNo.call())
  307. {
  308. return;
  309. }
  310. }
  311. DialogManager.close(self.id);
  312. });
  313. $(_buttons_bar).append(_yes_button).append(_no_button);
  314. break;
  315. }
  316. _html = $(_message_body).append(_message_contents).append(_buttons_bar);
  317. break;
  318. }
  319. this.setStatus(status);
  320. return _html;
  321. },
  322. /* 定位 */
  323. 'setPosition' : function(pos){
  324. /* 上次定位 */
  325. this.lastPos = pos;
  326. if (typeof(pos) == 'string')
  327. {
  328. switch(pos){
  329. case 'center':
  330. var left = 0;
  331. var top = 0;
  332. var dialog_width = $(this.dom.wrapper).width();
  333. var dialog_height = $(this.dom.wrapper).height() > 500 ? $(this.dom.wrapper).height() : 500;
  334. /* left=滚动条的宽度 + (当前可视区的宽度 - 对话框的宽度 ) / 2 */
  335. left = $(window).scrollLeft() + ($(window).width() - dialog_width) / 2;
  336. /* top =滚动条的高度 + (当前可视区的高度 - 对话框的高度 ) / 2 */
  337. top = $(window).scrollTop() + ($(window).height() - dialog_height) / 2;
  338. $(this.dom.wrapper).css({left:left + 'px', top:top + 'px'});
  339. break;
  340. }
  341. }
  342. else
  343. {
  344. var _pos = {};
  345. if (typeof(pos.left) != 'undefined')
  346. {
  347. _pos.left = pos.left;
  348. }
  349. if (typeof(pos.top) != 'undefined')
  350. {
  351. _pos.top = pos.top;
  352. }
  353. $(this.dom.wrapper).css(_pos);
  354. }
  355. },
  356. /* 设置状态 */
  357. 'setStatus' : function(code){
  358. this.status = code;
  359. },
  360. /* 获取状态 */
  361. 'getStatus' : function(){
  362. return this.status;
  363. },
  364. 'disableClose' : function(msg){
  365. this.tmp['oldOnClose'] = this.onClose;
  366. this.onClose = function(){
  367. if(msg)alert(msg);
  368. return false;
  369. };
  370. },
  371. 'enableClose' : function(){
  372. this.onClose = this.tmp['oldOnClose'];
  373. this.tmp['oldOnClose'] = null;
  374. }
  375. };
  376. DialogManager.loadStyle();
  377. /*common2.2.js*/
  378. DIALOGIMGDIR = SITEURL+"/"+'resource/js/dialog/images/dialog';
  379. var BROWSER = {};
  380. var USERAGENT = navigator.userAgent.toLowerCase();
  381. browserVersion({'ie':'msie','firefox':'','chrome':'','opera':'','safari':'','mozilla':'','webkit':'','maxthon':'','qq':'qqbrowser'});
  382. if(BROWSER.safari) {
  383. BROWSER.firefox = true;
  384. }
  385. BROWSER.opera = BROWSER.opera ? opera.version() : 0;
  386. HTMLNODE = document.getElementsByTagName('head')[0].parentNode;
  387. if(BROWSER.ie) {
  388. BROWSER.iemode = parseInt(typeof document.documentMode != 'undefined' ? document.documentMode : BROWSER.ie);
  389. HTMLNODE.className = 'ie_all ie' + BROWSER.iemode;
  390. }
  391. var JSLOADED = [];
  392. var JSMENU = [];
  393. JSMENU['active'] = [];
  394. JSMENU['timer'] = [];
  395. JSMENU['drag'] = [];
  396. JSMENU['layer'] = 0;
  397. JSMENU['zIndex'] = {'win':1000,'menu':1100,'dialog':1200,'prompt':1300};
  398. JSMENU['float'] = '';
  399. var CURRENTSTYPE = null;
  400. var EXTRAFUNC = [], EXTRASTR = '';
  401. if(BROWSER.firefox && window.HTMLElement) {
  402. HTMLElement.prototype.__defineGetter__( "innerText", function(){
  403. var anyString = "";
  404. var childS = this.childNodes;
  405. for(var i=0; i <childS.length; i++) {
  406. if(childS[i].nodeType==1) {
  407. anyString += childS[i].tagName=="BR" ? '\n' : childS[i].innerText;
  408. } else if(childS[i].nodeType==3) {
  409. anyString += childS[i].nodeValue;
  410. }
  411. }
  412. return anyString;
  413. });
  414. HTMLElement.prototype.__defineSetter__( "innerText", function(sText){
  415. this.textContent=sText;
  416. });
  417. HTMLElement.prototype.__defineSetter__('outerHTML', function(sHTML) {
  418. var r = this.ownerDocument.createRange();
  419. r.setStartBefore(this);
  420. var df = r.createContextualFragment(sHTML);
  421. this.parentNode.replaceChild(df,this);
  422. return sHTML;
  423. });
  424. HTMLElement.prototype.__defineGetter__('outerHTML', function() {
  425. var attr;
  426. var attrs = this.attributes;
  427. var str = '<' + this.tagName.toLowerCase();
  428. for(var i = 0;i < attrs.length;i++){
  429. attr = attrs[i];
  430. if(attr.specified)
  431. str += ' ' + attr.name + '="' + attr.value + '"';
  432. }
  433. if(!this.canHaveChildren) {
  434. return str + '>';
  435. }
  436. return str + '>' + this.innerHTML + '</' + this.tagName.toLowerCase() + '>';
  437. });
  438. HTMLElement.prototype.__defineGetter__('canHaveChildren', function() {
  439. switch(this.tagName.toLowerCase()) {
  440. case 'area':case 'base':case 'basefont':case 'col':case 'frame':case 'hr':case 'img':case 'br':case 'input':case 'isindex':case 'link':case 'meta':case 'param':
  441. return false;
  442. }
  443. return true;
  444. });
  445. }
  446. function $$(id) {
  447. return !id ? null : document.getElementById(id);
  448. }
  449. function _attachEvent(obj, evt, func, eventobj) {
  450. eventobj = !eventobj ? obj : eventobj;
  451. if(obj.addEventListener) {
  452. obj.addEventListener(evt, func, false);
  453. } else if(eventobj.attachEvent) {
  454. obj.attachEvent('on' + evt, func);
  455. }
  456. }
  457. function browserVersion(types) {
  458. var other = 1;
  459. for(i in types) {
  460. var v = types[i] ? types[i] : i;
  461. if(USERAGENT.indexOf(v) != -1) {
  462. var re = new RegExp(v + '(\\/|\\s)([\\d\\.]+)', 'ig');
  463. var matches = re.exec(USERAGENT);
  464. var ver = matches != null ? matches[2] : 0;
  465. other = ver !== 0 && v != 'mozilla' ? 0 : other;
  466. }else {
  467. var ver = 0;
  468. }
  469. eval('BROWSER.' + i + '= ver');
  470. }
  471. BROWSER.other = other;
  472. }
  473. function getEvent() {
  474. if(document.all) return window.event;
  475. func = getEvent.caller;
  476. while(func != null) {
  477. var arg0 = func.arguments[0];
  478. if (arg0) {
  479. if((arg0.constructor == Event || arg0.constructor == MouseEvent) || (typeof(arg0) == "object" && arg0.preventDefault && arg0.stopPropagation)) {
  480. return arg0;
  481. }
  482. }
  483. func=func.caller;
  484. }
  485. return null;
  486. }
  487. function isUndefined(variable) {
  488. return typeof variable == 'undefined' ? true : false;
  489. }
  490. function in_array(needle, haystack) {
  491. if(typeof needle == 'string' || typeof needle == 'number') {
  492. for(var i in haystack) {
  493. if(haystack[i] == needle) {
  494. return true;
  495. }
  496. }
  497. }
  498. return false;
  499. }
  500. function strlen(str) {
  501. return (BROWSER.ie && str.indexOf('\n') != -1) ? str.replace(/\r?\n/g, '_').length : str.length;
  502. }
  503. function Ajax(recvType, waitId) {
  504. var aj = new Object();
  505. aj.loading = '请稍候...';
  506. aj.recvType = recvType ? recvType : 'XML';
  507. aj.waitId = waitId ? $$(waitId) : null;
  508. aj.resultHandle = null;
  509. aj.sendString = '';
  510. aj.targetUrl = '';
  511. aj.setLoading = function(loading) {
  512. if(typeof loading !== 'undefined' && loading !== null) aj.loading = loading;
  513. };
  514. aj.setRecvType = function(recvtype) {
  515. aj.recvType = recvtype;
  516. };
  517. aj.setWaitId = function(waitid) {
  518. aj.waitId = typeof waitid == 'object' ? waitid : $$(waitid);
  519. };
  520. aj.createXMLHttpRequest = function() {
  521. var request = false;
  522. if(window.XMLHttpRequest) {
  523. request = new XMLHttpRequest();
  524. if(request.overrideMimeType) {
  525. request.overrideMimeType('text/xml');
  526. }
  527. } else if(window.ActiveXObject) {
  528. var versions = ['Microsoft.XMLHTTP', 'MSXML.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.7.0', 'Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP'];
  529. for(var i=0; i<versions.length; i++) {
  530. try {
  531. request = new ActiveXObject(versions[i]);
  532. if(request) {
  533. return request;
  534. }
  535. } catch(e) {}
  536. }
  537. }
  538. return request;
  539. };
  540. aj.XMLHttpRequest = aj.createXMLHttpRequest();
  541. aj.showLoading = function() {
  542. if(aj.waitId && (aj.XMLHttpRequest.readyState != 4 || aj.XMLHttpRequest.status != 200)) {
  543. aj.waitId.style.display = '';
  544. aj.waitId.innerHTML = '<span><img src="' + DIALOGIMGDIR + '/loading.gif" class="vm"> ' + aj.loading + '</span>';
  545. }
  546. };
  547. aj.processHandle = function() {
  548. if(aj.XMLHttpRequest.readyState == 4 && aj.XMLHttpRequest.status == 200) {
  549. if(aj.waitId) {
  550. aj.waitId.style.display = 'none';
  551. }
  552. if(aj.recvType == 'HTML') {
  553. aj.resultHandle(aj.XMLHttpRequest.responseText, aj);
  554. } else if(aj.recvType == 'XML') {
  555. if(!aj.XMLHttpRequest.responseXML || !aj.XMLHttpRequest.responseXML.lastChild || aj.XMLHttpRequest.responseXML.lastChild.localName == 'parsererror') {
  556. aj.resultHandle('<a href="' + aj.targetUrl + '" target="_blank" style="color:red">内部错误,无法显示此内容</a>' , aj);
  557. } else {
  558. aj.resultHandle(aj.XMLHttpRequest.responseXML.lastChild.firstChild.nodeValue, aj);
  559. }
  560. }
  561. }
  562. };
  563. aj.get = function(targetUrl, resultHandle) {
  564. targetUrl = hostconvert(targetUrl);
  565. setTimeout(function(){aj.showLoading()}, 250);
  566. aj.targetUrl = targetUrl;
  567. aj.XMLHttpRequest.onreadystatechange = aj.processHandle;
  568. aj.resultHandle = resultHandle;
  569. var attackevasive = isUndefined(attackevasive) ? 0 : attackevasive;
  570. if(window.XMLHttpRequest) {
  571. aj.XMLHttpRequest.open('GET', aj.targetUrl);
  572. aj.XMLHttpRequest.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
  573. aj.XMLHttpRequest.send(null);
  574. } else {
  575. aj.XMLHttpRequest.open("GET", targetUrl, true);
  576. aj.XMLHttpRequest.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
  577. aj.XMLHttpRequest.send();
  578. }
  579. };
  580. aj.post = function(targetUrl, sendString, resultHandle) {
  581. targetUrl = hostconvert(targetUrl);
  582. setTimeout(function(){aj.showLoading()}, 250);
  583. aj.targetUrl = targetUrl;
  584. aj.sendString = sendString;
  585. aj.XMLHttpRequest.onreadystatechange = aj.processHandle;
  586. aj.resultHandle = resultHandle;
  587. aj.XMLHttpRequest.open('POST', targetUrl);
  588. aj.XMLHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  589. aj.XMLHttpRequest.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
  590. aj.XMLHttpRequest.send(aj.sendString);
  591. };
  592. return aj;
  593. }
  594. function getHost(url) {
  595. var host = "null";
  596. if(typeof url == "undefined"|| null == url) {
  597. url = window.location.href;
  598. }
  599. var regex = /^\w+\:\/\/([^\/]*).*/;
  600. var match = url.match(regex);
  601. if(typeof match != "undefined" && null != match) {
  602. host = match[1];
  603. }
  604. return host;
  605. }
  606. function hostconvert(url) {
  607. if(!url.match(/^http?:\/\//) && !url.match(/^https?:\/\//)) url = SITEURL.replace(/(\/+)$/g, '') + '/' + url;
  608. var url_host = getHost(url);
  609. var cur_host = getHost().toLowerCase();
  610. if(url_host && cur_host != url_host) {
  611. url = url.replace(url_host, cur_host);
  612. }
  613. return url;
  614. }
  615. function newfunction(func) {
  616. var args = [];
  617. for(var i=1; i<arguments.length; i++) args.push(arguments[i]);
  618. return function(event) {
  619. doane(event);
  620. window[func].apply(window, args);
  621. return false;
  622. }
  623. }
  624. function evalscript(s) {
  625. if(s.indexOf('<script') == -1) return s;
  626. var p = /<script[^\>]*?>([^\x00]*?)<\/script>/ig;
  627. var arr = [];
  628. while(arr = p.exec(s)) {
  629. var p1 = /<script[^\>]*?src=\"([^\>]*?)\"[^\>]*?(reload=\"1\")?(?:charset=\"([\w\-]+?)\")?><\/script>/i;
  630. var arr1 = [];
  631. arr1 = p1.exec(arr[0]);
  632. if(arr1) {
  633. appendscript(arr1[1], '', arr1[2], arr1[3]);
  634. } else {
  635. p1 = /<script(.*?)>([^\x00]+?)<\/script>/i;
  636. arr1 = p1.exec(arr[0]);
  637. appendscript('', arr1[2], arr1[1].indexOf('reload=') != -1);
  638. }
  639. }
  640. return s;
  641. }
  642. var evalscripts = [];
  643. function appendscript(src, text, reload, charset) {
  644. var id = hash(src + text);
  645. if(!reload && in_array(id, evalscripts)) return;
  646. if(reload && $$(id)) {
  647. $$(id).parentNode.removeChild($$(id));
  648. }
  649. evalscripts.push(id);
  650. var scriptNode = document.createElement("script");
  651. scriptNode.type = "text/javascript";
  652. scriptNode.id = id;
  653. scriptNode.charset = charset ? charset : (BROWSER.firefox ? document.characterSet : document.charset);
  654. try {
  655. if(src) {
  656. scriptNode.src = src;
  657. scriptNode.onloadDone = false;
  658. scriptNode.onload = function () {
  659. scriptNode.onloadDone = true;
  660. JSLOADED[src] = 1;
  661. };
  662. scriptNode.onreadystatechange = function () {
  663. if((scriptNode.readyState == 'loaded' || scriptNode.readyState == 'complete') && !scriptNode.onloadDone) {
  664. scriptNode.onloadDone = true;
  665. JSLOADED[src] = 1;
  666. }
  667. };
  668. } else if(text){
  669. scriptNode.text = text;
  670. }
  671. document.getElementsByTagName('head')[0].appendChild(scriptNode);
  672. } catch(e) {}
  673. }
  674. function ajaxupdateevents(obj, tagName) {
  675. tagName = tagName ? tagName : 'A';
  676. var objs = obj.getElementsByTagName(tagName);
  677. for(k in objs) {
  678. var o = objs[k];
  679. ajaxupdateevent(o);
  680. }
  681. }
  682. function ajaxupdateevent(o) {
  683. if(typeof o == 'object' && o.getAttribute) {
  684. if(o.getAttribute('ajaxtarget')) {
  685. if(!o.id) o.id = Math.random();
  686. var ajaxevent = o.getAttribute('ajaxevent') ? o.getAttribute('ajaxevent') : 'click';
  687. var ajaxurl = o.getAttribute('ajaxurl') ? o.getAttribute('ajaxurl') : o.href;
  688. _attachEvent(o, ajaxevent, newfunction('ajaxget', ajaxurl, o.getAttribute('ajaxtarget'), o.getAttribute('ajaxwaitid'), o.getAttribute('ajaxloading'), o.getAttribute('ajaxdisplay')));
  689. if(o.getAttribute('ajaxfunc')) {
  690. o.getAttribute('ajaxfunc').match(/(\w+)\((.+?)\)/);
  691. _attachEvent(o, ajaxevent, newfunction(RegExp.$1, RegExp.$2));
  692. }
  693. }
  694. }
  695. }
  696. function ajaxget(url, showid, waitid, loading, display, recall) {
  697. waitid = typeof waitid == 'undefined' || waitid === null ? showid : waitid;
  698. var x = new Ajax();
  699. x.setLoading(loading);
  700. x.setWaitId(waitid);
  701. x.display = typeof display == 'undefined' || display == null ? '' : display;
  702. x.showId = $$(showid);
  703. if(url.substr(strlen(url) - 1) == '#') {
  704. url = url.substr(0, strlen(url) - 1);
  705. x.autogoto = 1;
  706. }
  707. // var url = url + '&inajax=1&ajaxtarget=' + showid;
  708. var url = url + '&inajax=1&ajaxtarget=';
  709. x.get(url, function(s, x) {
  710. var evaled = false;
  711. if(s.indexOf('ajaxerror') != -1) {
  712. evalscript(s);
  713. evaled = true;
  714. }
  715. if(!evaled && (typeof ajaxerror == 'undefined' || !ajaxerror)) {
  716. if(x.showId) {
  717. x.showId.style.display = x.display;
  718. ajaxinnerhtml(x.showId, s);
  719. ajaxupdateevents(x.showId);
  720. if(x.autogoto) scroll(0, x.showId.offsetTop);
  721. }
  722. }
  723. ajaxerror = null;
  724. if(recall && typeof recall == 'function') {
  725. recall();
  726. } else if(recall) {
  727. eval(recall);
  728. }
  729. if(!evaled) evalscript(s);
  730. });
  731. }
  732. function ajaxpost(formid, showid, waitid, showidclass, submitbtn, recall) {
  733. var waitid = typeof waitid == 'undefined' || waitid === null ? showid : (waitid !== '' ? waitid : '');
  734. var showidclass = '';
  735. var ajaxframeid = 'ajaxframe';
  736. var ajaxframe = $$(ajaxframeid);
  737. var formtarget = $$(formid).target;
  738. var handleResult = function() {
  739. var s = '';
  740. var evaled = false;
  741. // showloading('none');
  742. try {
  743. s = $$(ajaxframeid).contentWindow.document.XMLDocument.text;
  744. } catch(e) {
  745. try {
  746. s = $$(ajaxframeid).contentWindow.document.documentElement.firstChild.wholeText;
  747. } catch(e) {
  748. try {
  749. s = $$(ajaxframeid).contentWindow.document.documentElement.firstChild.nodeValue;
  750. } catch(e) {
  751. s = '内部错误,无法显示此内容';
  752. }
  753. }
  754. }
  755. if( s != '' && s.indexOf('ajaxerror') != -1) {
  756. evalscript(s);
  757. evaled = true;
  758. }
  759. if(showidclass) {
  760. if(showidclass != 'onerror') {
  761. $$(showid).className = showidclass;
  762. } else {
  763. showError(s);
  764. ajaxerror = true;
  765. }
  766. }
  767. if(submitbtn) {
  768. submitbtn.disabled = false;
  769. }
  770. if(!evaled && (typeof ajaxerror == 'undefined' || !ajaxerror)) {
  771. //ajaxinnerhtml($$(showid), s);
  772. }
  773. ajaxerror = null;
  774. if($$(formid)) $$(formid).target = formtarget;
  775. if(typeof recall == 'function') {
  776. recall();
  777. } else {
  778. eval(recall);
  779. }
  780. if(!evaled) evalscript(s);
  781. ajaxframe.loading = 0;
  782. $$('append_parent').removeChild(ajaxframe.parentNode);
  783. };
  784. if(!ajaxframe) {
  785. var div = document.createElement('div');
  786. div.style.display = 'none';
  787. div.innerHTML = '<iframe name="' + ajaxframeid + '" id="' + ajaxframeid + '" loading="1"></iframe>';
  788. $$('append_parent').appendChild(div);
  789. ajaxframe = $$(ajaxframeid);
  790. } else if(ajaxframe.loading) {
  791. return false;
  792. }
  793. _attachEvent(ajaxframe, 'load', handleResult);
  794. //showloading();
  795. $$(formid).target = ajaxframeid;
  796. var action = $$(formid).getAttribute('action');
  797. action = hostconvert(action);
  798. $$(formid).action = action.replace(/\&inajax\=1/g, '')+'&inajax=1';
  799. $$(formid).submit();
  800. if(submitbtn) {
  801. submitbtn.disabled = true;
  802. }
  803. doane();
  804. return false;
  805. }
  806. function hash(string, length) {
  807. var length = length ? length : 32;
  808. var start = 0;
  809. var i = 0;
  810. var result = '';
  811. filllen = length - string.length % length;
  812. for(i = 0; i < filllen; i++){
  813. string += "0";
  814. }
  815. while(start < string.length) {
  816. result = stringxor(result, string.substr(start, length));
  817. start += length;
  818. }
  819. return result;
  820. }
  821. function stringxor(s1, s2) {
  822. var s = '';
  823. var hash = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  824. var max = Math.max(s1.length, s2.length);
  825. for(var i=0; i<max; i++) {
  826. var k = s1.charCodeAt(i) ^ s2.charCodeAt(i);
  827. s += hash.charAt(k % 52);
  828. }
  829. return s;
  830. }
  831. function showloading(display, waiting) {
  832. var display = display ? display : 'block';
  833. var waiting = waiting ? waiting : '请稍候...';
  834. $$('ajaxwaitid').innerHTML = waiting;
  835. $$('ajaxwaitid').style.display = display;
  836. }
  837. function ajaxinnerhtml(showid, s) {
  838. if(showid.tagName != 'TBODY') {
  839. showid.innerHTML = s;
  840. } else {
  841. while(showid.firstChild) {
  842. showid.firstChild.parentNode.removeChild(showid.firstChild);
  843. }
  844. var div1 = document.createElement('DIV');
  845. div1.id = showid.id+'_div';
  846. div1.innerHTML = '<table><tbody id="'+showid.id+'_tbody">'+s+'</tbody></table>';
  847. $$('append_parent').appendChild(div1);
  848. var trs = div1.getElementsByTagName('TR');
  849. var l = trs.length;
  850. for(var i=0; i<l; i++) {
  851. showid.appendChild(trs[0]);
  852. }
  853. var inputs = div1.getElementsByTagName('INPUT');
  854. var l = inputs.length;
  855. for(var i=0; i<l; i++) {
  856. showid.appendChild(inputs[0]);
  857. }
  858. div1.parentNode.removeChild(div1);
  859. }
  860. }
  861. function doane(event, preventDefault, stopPropagation) {
  862. var preventDefault = isUndefined(preventDefault) ? 1 : preventDefault;
  863. var stopPropagation = isUndefined(stopPropagation) ? 1 : stopPropagation;
  864. e = event ? event : window.event;
  865. if(!e) {
  866. e = getEvent();
  867. }
  868. if(!e) {
  869. return null;
  870. }
  871. if(preventDefault) {
  872. if(e.preventDefault) {
  873. e.preventDefault();
  874. } else {
  875. e.returnValue = false;
  876. }
  877. }
  878. if(stopPropagation) {
  879. if(e.stopPropagation) {
  880. e.stopPropagation();
  881. } else {
  882. e.cancelBubble = true;
  883. }
  884. }
  885. return e;
  886. }
  887. function showMenu(v) {
  888. var ctrlid = isUndefined(v['ctrlid']) ? v : v['ctrlid'];
  889. var showid = isUndefined(v['showid']) ? ctrlid : v['showid'];
  890. var menuid = isUndefined(v['menuid']) ? showid + '_menu' : v['menuid'];
  891. var ctrlObj = $$(ctrlid);
  892. var menuObj = $$(menuid);
  893. if(!menuObj) return;
  894. var mtype = isUndefined(v['mtype']) ? 'menu' : v['mtype'];
  895. var evt = isUndefined(v['evt']) ? 'mouseover' : v['evt'];
  896. var pos = isUndefined(v['pos']) ? '43' : v['pos'];
  897. var layer = isUndefined(v['layer']) ? 1 : v['layer'];
  898. var duration = isUndefined(v['duration']) ? 2 : v['duration'];
  899. var timeout = isUndefined(v['timeout']) ? 250 : v['timeout'];
  900. var maxh = isUndefined(v['maxh']) ? 600 : v['maxh'];
  901. var cache = isUndefined(v['cache']) ? 1 : v['cache'];
  902. var drag = isUndefined(v['drag']) ? '' : v['drag'];
  903. var dragobj = drag && $$(drag) ? $$(drag) : menuObj;
  904. var fade = isUndefined(v['fade']) ? 0 : v['fade'];
  905. var cover = isUndefined(v['cover']) ? 0 : v['cover'];
  906. var zindex = isUndefined(v['zindex']) ? JSMENU['zIndex']['menu'] : v['zindex'];
  907. var ctrlclass = isUndefined(v['ctrlclass']) ? '' : v['ctrlclass'];
  908. var winhandlekey = isUndefined(v['win']) ? '' : v['win'];
  909. zindex = cover ? zindex + 500 : zindex;
  910. if(typeof JSMENU['active'][layer] == 'undefined') {
  911. JSMENU['active'][layer] = [];
  912. }
  913. for(i in EXTRAFUNC['showmenu']) {
  914. try {
  915. eval(EXTRAFUNC['showmenu'][i] + '()');
  916. } catch(e) {}
  917. }
  918. if(evt == 'click' && in_array(menuid, JSMENU['active'][layer]) && mtype != 'win') {
  919. hideMenu(menuid, mtype);
  920. return;
  921. }
  922. if(mtype == 'menu') {
  923. hideMenu(layer, mtype);
  924. }
  925. if(ctrlObj) {
  926. if(!ctrlObj.getAttribute('initialized')) {
  927. ctrlObj.setAttribute('initialized', true);
  928. ctrlObj.unselectable = true;
  929. ctrlObj.outfunc = typeof ctrlObj.onmouseout == 'function' ? ctrlObj.onmouseout : null;
  930. ctrlObj.onmouseout = function() {
  931. if(this.outfunc) this.outfunc();
  932. if(duration < 3 && !JSMENU['timer'][menuid]) {
  933. JSMENU['timer'][menuid] = setTimeout(function () {
  934. hideMenu(menuid, mtype);
  935. }, timeout);
  936. }
  937. };
  938. ctrlObj.overfunc = typeof ctrlObj.onmouseover == 'function' ? ctrlObj.onmouseover : null;
  939. ctrlObj.onmouseover = function(e) {
  940. doane(e);
  941. if(this.overfunc) this.overfunc();
  942. if(evt == 'click') {
  943. clearTimeout(JSMENU['timer'][menuid]);
  944. JSMENU['timer'][menuid] = null;
  945. } else {
  946. for(var i in JSMENU['timer']) {
  947. if(JSMENU['timer'][i]) {
  948. clearTimeout(JSMENU['timer'][i]);
  949. JSMENU['timer'][i] = null;
  950. }
  951. }
  952. }
  953. };
  954. }
  955. }
  956. if(!menuObj.getAttribute('initialized')) {
  957. menuObj.setAttribute('initialized', true);
  958. menuObj.ctrlkey = ctrlid;
  959. menuObj.mtype = mtype;
  960. menuObj.layer = layer;
  961. menuObj.cover = cover;
  962. if(ctrlObj && ctrlObj.getAttribute('fwin')) {menuObj.scrolly = true;}
  963. menuObj.style.position = 'absolute';
  964. menuObj.style.zIndex = zindex + layer;
  965. menuObj.onclick = function(e) {
  966. return doane(e, 0, 1);
  967. };
  968. if(duration < 3) {
  969. if(duration > 1) {
  970. menuObj.onmouseover = function() {
  971. clearTimeout(JSMENU['timer'][menuid]);
  972. JSMENU['timer'][menuid] = null;
  973. };
  974. }
  975. if(duration != 1) {
  976. menuObj.onmouseout = function() {
  977. JSMENU['timer'][menuid] = setTimeout(function () {
  978. hideMenu(menuid, mtype);
  979. }, timeout);
  980. };
  981. }
  982. }
  983. if(cover) {
  984. var coverObj = document.createElement('div');
  985. coverObj.id = menuid + '_cover';
  986. coverObj.style.position = 'absolute';
  987. coverObj.style.zIndex = menuObj.style.zIndex - 1;
  988. coverObj.style.left = coverObj.style.top = '0px';
  989. coverObj.style.width = '100%';
  990. coverObj.style.height = Math.max(document.documentElement.clientHeight, document.body.offsetHeight) + 'px';
  991. coverObj.style.backgroundColor = 'transparent';
  992. coverObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=0)';
  993. coverObj.style.opacity = 0;
  994. coverObj.onclick = function () { hideMenu(); };
  995. $$('append_parent').appendChild(coverObj);
  996. _attachEvent(window, 'load', function () {
  997. coverObj.style.height = Math.max(document.documentElement.clientHeight, document.body.offsetHeight) + 'px';
  998. }, document);
  999. }
  1000. }
  1001. if(drag) {
  1002. dragobj.style.cursor = 'move';
  1003. dragobj.onmousedown = function(event) {try{dragMenu(menuObj, event, 1);}catch(e){}};
  1004. }
  1005. if(cover) $$(menuid + '_cover').style.display = '';
  1006. if(fade) {
  1007. var O = 0;
  1008. var fadeIn = function(O) {
  1009. if(O > 100) {
  1010. clearTimeout(fadeInTimer);
  1011. return;
  1012. }
  1013. menuObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + O + ')';
  1014. menuObj.style.opacity = O / 100;
  1015. O += 20;
  1016. var fadeInTimer = setTimeout(function () {
  1017. fadeIn(O);
  1018. }, 40);
  1019. };
  1020. fadeIn(O);
  1021. menuObj.fade = true;
  1022. } else {
  1023. menuObj.fade = false;
  1024. }
  1025. menuObj.style.display = '';
  1026. if(ctrlObj && ctrlclass) {
  1027. ctrlObj.className += ' ' + ctrlclass;
  1028. menuObj.setAttribute('ctrlid', ctrlid);
  1029. menuObj.setAttribute('ctrlclass', ctrlclass);
  1030. }
  1031. if(pos != '*') {
  1032. setMenuPosition(showid, menuid, pos);
  1033. }
  1034. if(BROWSER.ie && BROWSER.ie < 7 && winhandlekey && $$('fwin_' + winhandlekey)) {
  1035. $$(menuid).style.left = (parseInt($$(menuid).style.left) - parseInt($$('fwin_' + winhandlekey).style.left)) + 'px';
  1036. $$(menuid).style.top = (parseInt($$(menuid).style.top) - parseInt($$('fwin_' + winhandlekey).style.top)) + 'px';
  1037. }
  1038. if(maxh && menuObj.scrollHeight > maxh) {
  1039. menuObj.style.height = maxh + 'px';
  1040. if(BROWSER.opera) {
  1041. menuObj.style.overflow = 'auto';
  1042. } else {
  1043. menuObj.style.overflowY = 'auto';
  1044. }
  1045. }
  1046. if(!duration) {
  1047. setTimeout('hideMenu(\'' + menuid + '\', \'' + mtype + '\')', timeout);
  1048. }
  1049. if(!in_array(menuid, JSMENU['active'][layer])) JSMENU['active'][layer].push(menuid);
  1050. menuObj.cache = cache;
  1051. if(layer > JSMENU['layer']) {
  1052. JSMENU['layer'] = layer;
  1053. }
  1054. }
  1055. var dragMenuDisabled = false;
  1056. function dragMenu(menuObj, e, op) {
  1057. e = e ? e : window.event;
  1058. if(op == 1) {
  1059. if(dragMenuDisabled || in_array(e.target ? e.target.tagName : e.srcElement.tagName, ['TEXTAREA', 'INPUT', 'BUTTON', 'SELECT'])) {
  1060. return;
  1061. }
  1062. JSMENU['drag'] = [e.clientX, e.clientY];
  1063. JSMENU['drag'][2] = parseInt(menuObj.style.left);
  1064. JSMENU['drag'][3] = parseInt(menuObj.style.top);
  1065. document.onmousemove = function(e) {try{dragMenu(menuObj, e, 2);}catch(err){}};
  1066. document.onmouseup = function(e) {try{dragMenu(menuObj, e, 3);}catch(err){}};
  1067. doane(e);
  1068. }else if(op == 2 && JSMENU['drag'][0]) {
  1069. var menudragnow = [e.clientX, e.clientY];
  1070. menuObj.style.left = (JSMENU['drag'][2] + menudragnow[0] - JSMENU['drag'][0]) + 'px';
  1071. menuObj.style.top = (JSMENU['drag'][3] + menudragnow[1] - JSMENU['drag'][1]) + 'px';
  1072. menuObj.removeAttribute('top_');menuObj.removeAttribute('left_');
  1073. doane(e);
  1074. }else if(op == 3) {
  1075. JSMENU['drag'] = [];
  1076. document.onmousemove = null;
  1077. document.onmouseup = null;
  1078. }
  1079. }
  1080. function setMenuPosition(showid, menuid, pos) {
  1081. var showObj = $$(showid);
  1082. var menuObj = menuid ? $$(menuid) : $$(showid + '_menu');
  1083. if(isUndefined(pos) || !pos) pos = '43';
  1084. var basePoint = parseInt(pos.substr(0, 1));
  1085. var direction = parseInt(pos.substr(1, 1));
  1086. var important = pos.indexOf('!') != -1 ? 1 : 0;
  1087. var sxy = 0, sx = 0, sy = 0, sw = 0, sh = 0, ml = 0, mt = 0, mw = 0, mcw = 0, mh = 0, mch = 0, bpl = 0, bpt = 0;
  1088. if(!menuObj || (basePoint > 0 && !showObj)) return;
  1089. if(showObj) {
  1090. sxy = fetchOffset(showObj);
  1091. sx = sxy['left'];
  1092. sy = sxy['top'];
  1093. sw = showObj.offsetWidth;
  1094. sh = showObj.offsetHeight;
  1095. }
  1096. mw = menuObj.offsetWidth;
  1097. mcw = menuObj.clientWidth;
  1098. mh = menuObj.offsetHeight;
  1099. mch = menuObj.clientHeight;
  1100. switch(basePoint) {
  1101. case 1:
  1102. bpl = sx;
  1103. bpt = sy;
  1104. break;
  1105. case 2:
  1106. bpl = sx + sw;
  1107. bpt = sy;
  1108. break;
  1109. case 3:
  1110. bpl = sx + sw;
  1111. bpt = sy + sh;
  1112. break;
  1113. case 4:
  1114. bpl = sx;
  1115. bpt = sy + sh;
  1116. break;
  1117. }
  1118. switch(direction) {
  1119. case 0:
  1120. menuObj.style.left = (document.body.clientWidth - menuObj.clientWidth) / 2 + 'px';
  1121. mt = (document.documentElement.clientHeight - menuObj.clientHeight) / 2;
  1122. break;
  1123. case 1:
  1124. ml = bpl - mw;
  1125. mt = bpt - mh;
  1126. break;
  1127. case 2:
  1128. ml = bpl;
  1129. mt = bpt - mh;
  1130. break;
  1131. case 3:
  1132. ml = bpl;
  1133. mt = bpt;
  1134. break;
  1135. case 4:
  1136. ml = bpl - mw;
  1137. mt = bpt;
  1138. break;
  1139. }
  1140. var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
  1141. var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
  1142. if(!important) {
  1143. if(in_array(direction, [1, 4]) && ml < 0) {
  1144. ml = bpl;
  1145. if(in_array(basePoint, [1, 4])) ml += sw;
  1146. } else if(ml + mw > scrollLeft + document.body.clientWidth && sx >= mw) {
  1147. ml = bpl - mw;
  1148. if(in_array(basePoint, [2, 3])) {
  1149. ml -= sw;
  1150. } else if(basePoint == 4) {
  1151. ml += sw;
  1152. }
  1153. }
  1154. if(in_array(direction, [1, 2]) && mt < 0) {
  1155. mt = bpt;
  1156. if(in_array(basePoint, [1, 2])) mt += sh;
  1157. } else if(mt + mh > scrollTop + document.documentElement.clientHeight && sy >= mh) {
  1158. mt = bpt - mh;
  1159. if(in_array(basePoint, [3, 4])) mt -= sh;
  1160. }
  1161. }
  1162. if(pos.substr(0, 3) == '210') {
  1163. ml += 69 - sw / 2;
  1164. mt -= 5;
  1165. if(showObj.tagName == 'TEXTAREA') {
  1166. ml -= sw / 2;
  1167. mt += sh / 2;
  1168. }
  1169. }
  1170. if(direction == 0 || menuObj.scrolly) {
  1171. if(BROWSER.ie && BROWSER.ie < 7) {
  1172. if(direction == 0) mt += scrollTop;
  1173. } else {
  1174. if(menuObj.scrolly) mt -= scrollTop;
  1175. menuObj.style.position = 'fixed';
  1176. }
  1177. }
  1178. if(ml) menuObj.style.left = ml + 'px';
  1179. if(mt) menuObj.style.top = mt + 'px';
  1180. if(direction == 0 && BROWSER.ie && !document.documentElement.clientHeight) {
  1181. menuObj.style.position = 'absolute';
  1182. menuObj.style.top = (document.body.clientHeight - menuObj.clientHeight) / 2 + 'px';
  1183. }
  1184. if(menuObj.style.clip && !BROWSER.opera) {
  1185. menuObj.style.clip = 'rect(auto, auto, auto, auto)';
  1186. }
  1187. }
  1188. function hideMenu(attr, mtype) {
  1189. attr = isUndefined(attr) ? '' : attr;
  1190. mtype = isUndefined(mtype) ? 'menu' : mtype;
  1191. if(attr == '') {
  1192. for(var i = 1; i <= JSMENU['layer']; i++) {
  1193. hideMenu(i, mtype);
  1194. }
  1195. return;
  1196. } else if(typeof attr == 'number') {
  1197. for(var j in JSMENU['active'][attr]) {
  1198. hideMenu(JSMENU['active'][attr][j], mtype);
  1199. }
  1200. return;
  1201. }else if(typeof attr == 'string') {
  1202. var menuObj = $$(attr);
  1203. if(!menuObj || (mtype && menuObj.mtype != mtype)) return;
  1204. var ctrlObj = '', ctrlclass = '';
  1205. if((ctrlObj = $$(menuObj.getAttribute('ctrlid'))) && (ctrlclass = menuObj.getAttribute('ctrlclass'))) {
  1206. var reg = new RegExp(' ' + ctrlclass);
  1207. ctrlObj.className = ctrlObj.className.replace(reg, '');
  1208. }
  1209. clearTimeout(JSMENU['timer'][attr]);
  1210. var hide = function() {
  1211. if(menuObj.cache) {
  1212. if(menuObj.style.visibility != 'hidden') {
  1213. menuObj.style.display = 'none';
  1214. if(menuObj.cover) $$(attr + '_cover').style.display = 'none';
  1215. }
  1216. }else {
  1217. menuObj.parentNode.removeChild(menuObj);
  1218. if(menuObj.cover) $$(attr + '_cover').parentNode.removeChild($$(attr + '_cover'));
  1219. }
  1220. var tmp = [];
  1221. for(var k in JSMENU['active'][menuObj.layer]) {
  1222. if(attr != JSMENU['active'][menuObj.layer][k]) tmp.push(JSMENU['active'][menuObj.layer][k]);
  1223. }
  1224. JSMENU['active'][menuObj.layer] = tmp;
  1225. };
  1226. if(menuObj.fade) {
  1227. var O = 100;
  1228. var fadeOut = function(O) {
  1229. if(O == 0) {
  1230. clearTimeout(fadeOutTimer);
  1231. hide();
  1232. return;
  1233. }
  1234. menuObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + O + ')';
  1235. menuObj.style.opacity = O / 100;
  1236. O -= 20;
  1237. var fadeOutTimer = setTimeout(function () {
  1238. fadeOut(O);
  1239. }, 40);
  1240. };
  1241. fadeOut(O);
  1242. } else {
  1243. hide();
  1244. }
  1245. }
  1246. }
  1247. function getCurrentStyle(obj, cssproperty, csspropertyNS) {
  1248. if(obj.style[cssproperty]){
  1249. return obj.style[cssproperty];
  1250. }
  1251. if (obj.currentStyle) {
  1252. return obj.currentStyle[cssproperty];
  1253. } else if (document.defaultView.getComputedStyle(obj, null)) {
  1254. var currentStyle = document.defaultView.getComputedStyle(obj, null);
  1255. var value = currentStyle.getPropertyValue(csspropertyNS);
  1256. if(!value){
  1257. value = currentStyle[cssproperty];
  1258. }
  1259. return value;
  1260. } else if (window.getComputedStyle) {
  1261. var currentStyle = window.getComputedStyle(obj, "");
  1262. return currentStyle.getPropertyValue(csspropertyNS);
  1263. }
  1264. }
  1265. function fetchOffset(obj, mode) {
  1266. var left_offset = 0, top_offset = 0, mode = !mode ? 0 : mode;
  1267. if(obj.getBoundingClientRect && !mode) {
  1268. var rect = obj.getBoundingClientRect();
  1269. var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
  1270. var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
  1271. if(document.documentElement.dir == 'rtl') {
  1272. scrollLeft = scrollLeft + document.documentElement.clientWidth - document.documentElement.scrollWidth;
  1273. }
  1274. left_offset = rect.left + scrollLeft - document.documentElement.clientLeft;
  1275. top_offset = rect.top + scrollTop - document.documentElement.clientTop;
  1276. }
  1277. if(left_offset <= 0 || top_offset <= 0) {
  1278. left_offset = obj.offsetLeft;
  1279. top_offset = obj.offsetTop;
  1280. while((obj = obj.offsetParent) != null) {
  1281. position = getCurrentStyle(obj, 'position', 'position');
  1282. if(position == 'relative') {
  1283. continue;
  1284. }
  1285. left_offset += obj.offsetLeft;
  1286. top_offset += obj.offsetTop;
  1287. }
  1288. }
  1289. return {'left' : left_offset, 'top' : top_offset};
  1290. }
  1291. var showDialogST = null;
  1292. function showDialog(msg, mode, t, func, cover, funccancel, leftmsg, confirmtxt, canceltxt, closetime, locationtime) {
  1293. if (mode == 'js'){
  1294. if(typeof func == 'function') func();
  1295. else eval(func);
  1296. //hideMenu(null, 'dialog');
  1297. return ;
  1298. }
  1299. clearTimeout(showDialogST);
  1300. cover = isUndefined(cover) ? (mode == 'info' ? 0 : 1) : cover;
  1301. leftmsg = isUndefined(leftmsg) ? '' : leftmsg;
  1302. mode = in_array(mode, ['confirm', 'notice', 'info', 'succ','js']) ? mode : 'alert';
  1303. var menuid = 'fwin_dialog';
  1304. var menuObj = $$(menuid);
  1305. var showconfirm = 1;
  1306. confirmtxtdefault = '确定';
  1307. closetime = isUndefined(closetime) ? '' : closetime;
  1308. closefunc = function () {
  1309. if(typeof func == 'function') func();
  1310. else eval(func);
  1311. hideMenu(menuid, 'dialog');
  1312. };
  1313. if(closetime) {
  1314. leftmsg = closetime + ' 秒后窗口关闭';
  1315. showDialogST = setTimeout(closefunc, closetime * 1000);
  1316. showconfirm = 0;
  1317. }
  1318. locationtime = isUndefined(locationtime) ? '' : locationtime;
  1319. if(locationtime) {
  1320. leftmsg = locationtime + ' 秒后页面跳转';
  1321. showDialogST = setTimeout(closefunc, locationtime * 1000);
  1322. showconfirm = 0;
  1323. }
  1324. confirmtxt = confirmtxt ? confirmtxt : confirmtxtdefault;
  1325. canceltxt = canceltxt ? canceltxt : '取消';
  1326. if(menuObj) hideMenu('fwin_dialog', 'dialog');
  1327. menuObj = document.createElement('div');
  1328. menuObj.style.display = 'none';
  1329. menuObj.className = 'dialog_body';
  1330. menuObj.id = menuid;
  1331. $$('append_parent').appendChild(menuObj);
  1332. var hidedom = '';
  1333. if(!BROWSER.ie) {
  1334. hidedom = '<style type="text/css">object{visibility:hidden;}</style>';
  1335. }
  1336. var s = hidedom + '<h3 class="dialog_head"><span class="dialog_title">';
  1337. s += t ? t : '<span class="dialog_title_icon">提示信息</span>';
  1338. s += '</span><span class="dialog_close_button" id="fwin_dialog_close" onclick="hideMenu(\'' + menuid + '\', \'dialog\')" title="关闭">X</span></h3>';
  1339. if(mode == 'info') {
  1340. s += msg ? msg : '';
  1341. } else {
  1342. s += '<div class="eject_con"><div class="dialog_message_contents">';
  1343. s += '<i class="' + (mode == 'alert' ? 'alert_error' : (mode == 'succ' ? 'alert_right' : 'alert_info')) + '"></i>' + msg + '</div></div>';
  1344. s += '<div class="dialog_buttons_bar">' + (leftmsg ? '<time class="countdown">'+'<i class="icon-time"></i>' + leftmsg + '</time>' : '') + (showconfirm ? '<a href="javascript:void(0)" id="fwin_dialog_submit" class="dialog-bottom-btn dialog-bottom-btn mr10">'+confirmtxt+'</a>' : '');
  1345. s += mode == 'confirm' ? '<a href="javascript:void(0)" id="fwin_dialog_cancel" class="dialog-bottom-btn" onclick="hideMenu(\'' + menuid + '\', \'dialog\')">'+canceltxt+'</a>' : '';
  1346. s += '</div>';
  1347. }
  1348. menuObj.innerHTML = s;
  1349. if($$('fwin_dialog_submit')) $$('fwin_dialog_submit').onclick = function() {
  1350. if(typeof func == 'function') func();
  1351. else eval(func);
  1352. hideMenu(menuid, 'dialog');
  1353. };
  1354. if($$('fwin_dialog_cancel')) {
  1355. $$('fwin_dialog_cancel').onclick = function() {
  1356. if(typeof funccancel == 'function') funccancel();
  1357. else eval(funccancel);
  1358. hideMenu(menuid, 'dialog');
  1359. };
  1360. $$('fwin_dialog_close').onclick = $$('fwin_dialog_cancel').onclick;
  1361. }
  1362. showMenu({'mtype':'dialog','menuid':menuid,'duration':3,'pos':'00','zindex':JSMENU['zIndex']['dialog'],'cache':0,'cover':cover});
  1363. try {
  1364. if($$('fwin_dialog_submit')) $$('fwin_dialog_submit').focus();
  1365. } catch(e) {}
  1366. }
  1367. function showSucc(msg) {
  1368. var p = /<script[^\>]*?>([^\x00]*?)<\/script>/ig;
  1369. msg = msg.replace(p, '');
  1370. if(msg !== '') {
  1371. showDialog(msg, 'succ', '提示信息', null, true, null, '', '', '', 3);
  1372. }
  1373. }
  1374. function showError(msg) {
  1375. var p = /<script[^\>]*?>([^\x00]*?)<\/script>/ig;
  1376. msg = msg.replace(p, '');
  1377. if(msg !== '') {
  1378. showDialog(msg, 'alert', '错误信息', null, true, null, '', '', '', 3);
  1379. }
  1380. }
  1381. function hideWindow(k, all, clear) {
  1382. all = isUndefined(all) ? 1 : all;
  1383. clear = isUndefined(clear) ? 1 : clear;
  1384. hideMenu('fwin_' + k, 'win');
  1385. if(clear && $$('fwin_' + k)) {
  1386. $$('append_parent').removeChild($$('fwin_' + k));
  1387. }
  1388. if(all) {
  1389. hideMenu();
  1390. }
  1391. }
  1392. function ajax_get_confirm(msg, url){
  1393. if (msg != ''){
  1394. showDialog(msg, 'confirm', '', function(){ajaxget(url);});
  1395. }else{
  1396. ajaxget(url);
  1397. }
  1398. }
  1399. function get_confirm(msg, url){
  1400. if(msg != ''){
  1401. showDialog(msg, 'confirm', '', function(){ window.location = url;});
  1402. }else{
  1403. window.location = url;
  1404. }
  1405. }