Dialogs.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874
  1. /* Copyright (c) Business Objects 2006. All rights reserved. */
  2. if (typeof bobj.crv.PrintUI == 'undefined') {
  3. bobj.crv.PrintUI = {};
  4. }
  5. if (typeof bobj.crv.ExportUI == 'undefined') {
  6. bobj.crv.ExportUI = {};
  7. }
  8. if (typeof bobj.crv.ErrorDialog == 'undefined') {
  9. bobj.crv.ErrorDialog = {};
  10. }
  11. if (typeof bobj.crv.ReportProcessingUI == 'undefined') {
  12. bobj.crv.ReportProcessingUI = {};
  13. }
  14. /*
  15. ================================================================================
  16. PrintUI
  17. ================================================================================
  18. */
  19. bobj.crv.newPrintUI = function(kwArgs) {
  20. if (!kwArgs.id) {
  21. kwArgs = MochiKit.Base.update({id: bobj.uniqueId()}, kwArgs);
  22. }
  23. var lbl = kwArgs.submitBtnLabel;
  24. if (!lbl) {
  25. lbl = L_bobj_crv_submitBtnLbl;
  26. }
  27. var infoTitle = kwArgs.infoTitle;
  28. if (!infoTitle) {
  29. infoTitle = L_bobj_crv_PrintInfoTitle;
  30. }
  31. var dialogTitle = kwArgs.dialogTitle;
  32. if (!dialogTitle) {
  33. if (kwArgs.isActxPrinting) {
  34. dialogTitle = L_bobj_crv_ActiveXPrintDialogTitle;
  35. }
  36. else {
  37. dialogTitle = L_bobj_crv_PDFPrintDialogTitle;
  38. }
  39. }
  40. var infoMsg = kwArgs.infoMsg;
  41. if (!infoMsg) {
  42. infoMsg = L_bobj_crv_PrintInfo1;
  43. infoMsg += '\n';
  44. infoMsg += L_bobj_crv_PrintInfo2;
  45. }
  46. var o = newDialogBoxWidget(kwArgs.id + '_dialog',
  47. dialogTitle,
  48. 250,
  49. 100,
  50. null,
  51. bobj.crv.PrintUI._cancel,
  52. false);
  53. o.actxId = o.id + '_actx';
  54. o.actxContainerId = o.id + '_actxdiv';
  55. o._processingPrinting = false;
  56. o._initOld = o.init;
  57. o._showOld = o.show;
  58. if (!kwArgs.isActxPrinting) {
  59. o._fromBox = newIntFieldWidget(o.id + "_fromBox",
  60. null,
  61. null,
  62. null,
  63. null,
  64. true,
  65. '',
  66. 50);
  67. o._fromBox.setDisabled = bobj.crv.PrintUI.disabledTextFieldWidget;
  68. o._toBox = newIntFieldWidget(o.id + "_toBox",
  69. null,
  70. null,
  71. null,
  72. null,
  73. true,
  74. '',
  75. 50);
  76. o._toBox.setDisabled = bobj.crv.PrintUI.disabledTextFieldWidget;
  77. o._submitBtn = newButtonWidget(o.id + "_submitBtn",
  78. lbl,
  79. MochiKit.Base.bind(bobj.crv.PrintUI._submitBtnCB, o));
  80. o._allRadio = newRadioWidget(o.id + "_allRadio",
  81. o.id + "_grp",
  82. L_bobj_crv_PrintAllLbl,
  83. MochiKit.Base.bind(bobj.crv.PrintUI.disabledPageRange ,o, true));
  84. o._rangeRadio = newRadioWidget(o.id + "_rangeRadio",
  85. o.id + "_grp",
  86. L_bobj_crv_PrintPagesLbl,
  87. MochiKit.Base.bind(bobj.crv.PrintUI.disabledPageRange ,o, false));
  88. o._optionsFrame = newFrameZoneWidget(o.id + "_optionsFrame", 250);
  89. if (!kwArgs.isExporting) {
  90. o._info = newInfoWidget(o.id + "_info",
  91. infoTitle,
  92. null,
  93. infoMsg,
  94. 100 );
  95. }
  96. }
  97. o.widgetType = 'PrintUI';
  98. // Update instance with constructor arguments
  99. bobj.fillIn(o, kwArgs);
  100. // Update instance with member functions
  101. MochiKit.Base.update(o, bobj.crv.PrintUI);
  102. return o;
  103. };
  104. bobj.crv.PrintUI.disabledTextFieldWidget = function(disabled)
  105. {
  106. TextFieldWidget_setDisabled.call(this,disabled);
  107. if(disabled)
  108. {
  109. MochiKit.DOM.addElementClass(this.layer, "textDisabled");
  110. }
  111. else {
  112. MochiKit.DOM.removeElementClass(this.layer, "textDisabled");
  113. }
  114. }
  115. bobj.crv.PrintUI.disabledPageRange = function(bool)
  116. {
  117. if(this._fromBox && this._toBox)
  118. {
  119. this._fromBox.setDisabled(bool);
  120. this._toBox.setDisabled(bool);
  121. }
  122. }
  123. bobj.crv.PrintUI._submitBtnCB = function() {
  124. var start = null;
  125. var end = null;
  126. if (this._rangeRadio.isChecked()) {
  127. start = parseInt(this._fromBox.getValue(), 10);
  128. end = parseInt(this._toBox.getValue(), 10);
  129. if (!start || !end || (start < 0) || (start > end)) {
  130. alert(L_bobj_crv_PrintPageRangeError);
  131. return;
  132. }
  133. }
  134. if (this.widgetType == 'PrintUI') {
  135. MochiKit.Signal.signal(this, 'printSubmitted', start, end);
  136. }
  137. else {
  138. MochiKit.Signal.signal(this, 'exportSubmitted', start, end, this._comboBox.getSelection().value);
  139. }
  140. this.show(false);
  141. };
  142. bobj.crv.PrintUI._getRPSafeURL = function(url) {
  143. if (!url) {
  144. return;
  145. }
  146. if (url.indexOf('/') === 0) {
  147. return url;
  148. }
  149. var winLoc = window.location.href;
  150. var lPos = winLoc.lastIndexOf('/');
  151. if (lPos < 0) {
  152. return url;
  153. }
  154. winLoc = winLoc.substring(0, lPos);
  155. return winLoc + '/' + url;
  156. };
  157. bobj.crv.PrintUI._getObjectTag = function(postData) {
  158. var oa = [];
  159. oa.push('<OBJECT width="0" height="0" ID="');
  160. oa.push(this.actxId);
  161. oa.push('" CLASSID="CLSID:');
  162. oa.push(bobj.crv.ActxPrintControl_CLSID);
  163. oa.push('" CODEBASE="');
  164. oa.push(this._getRPSafeURL(this.codeBase));
  165. oa.push('#Version=');
  166. oa.push(bobj.crv.ActxPrintControl_Version);
  167. oa.push('" VIEWASTEXT>');
  168. oa.push('<PARAM NAME="PostBackData" VALUE="');
  169. oa.push(postData);
  170. oa.push('">');
  171. oa.push('<PARAM NAME="ServerResourceVersion" VALUE="');
  172. oa.push(bobj.crv.ActxPrintControl_Version);
  173. oa.push('">');
  174. if (this.lcid) {
  175. oa.push('<PARAM NAME="LocaleID" VALUE="');
  176. oa.push(this.lcid);
  177. oa.push('">');
  178. }
  179. if (this.url) {
  180. oa.push('<PARAM NAME="URL" VALUE="');
  181. oa.push(this._getRPSafeURL(this.url));
  182. oa.push('">');
  183. }
  184. if (this.title) {
  185. oa.push('<PARAM NAME="Title" VALUE="');
  186. oa.push(this.title);
  187. oa.push('">');
  188. }
  189. if (this.maxPage) {
  190. oa.push('<PARAM NAME="MaxPageNumber" VALUE="');
  191. oa.push(this.maxPage);
  192. oa.push('">');
  193. }
  194. if (this.paperOrientation) {
  195. oa.push('<PARAM NAME="PageOrientation" VALUE="');
  196. oa.push(this.paperOrientation);
  197. oa.push('">');
  198. }
  199. if (this.paperSize) {
  200. oa.push('<PARAM NAME="PaperSize" VALUE="');
  201. oa.push(this.paperSize);
  202. oa.push('">');
  203. }
  204. if (this.paperWidth) {
  205. oa.push('<PARAM NAME="PaperWidth" VALUE="');
  206. oa.push(this.paperWidth);
  207. oa.push('">');
  208. }
  209. if (this.paperLength) {
  210. oa.push('<PARAM NAME="PaperLength" VALUE="');
  211. oa.push(this.paperLength);
  212. oa.push('">');
  213. }
  214. if (this.driverName) {
  215. oa.push('<PARAM NAME="PrinterDriverName" VALUE="');
  216. oa.push(this.driverName);
  217. oa.push('">');
  218. }
  219. if (this.useDefPrinter) {
  220. oa.push('<PARAM NAME="UseDefaultPrinter" VALUE="');
  221. oa.push(this.useDefPrinter);
  222. oa.push('">');
  223. }
  224. if (this.useDefPrinterSettings) {
  225. oa.push('<PARAM NAME="UseDefaultPrinterSettings" VALUE="');
  226. oa.push(this.useDefPrinterSettings);
  227. oa.push('">');
  228. }
  229. if (this.sendPostDataOnce) {
  230. oa.push('<PARAM NAME="SendPostDataOnce" VALUE="');
  231. oa.push(this.sendPostDataOnce);
  232. oa.push('">');
  233. }
  234. oa.push('</OBJECT>');
  235. // Add waiting UI while the control is loading
  236. oa.push('<table id="')
  237. oa.push(this.actxId);
  238. oa.push('_wait" border="0" cellspacing="0" cellpadding="0" width="100%" ><tbody>');
  239. oa.push('<tr><td align="center" valign="top">');
  240. // Frame Zone
  241. var o = this;
  242. var zoneW=o.getContainerWidth()-10;
  243. var zoneH=o.getContainerHeight()-(2*o.pad+21+10);
  244. oa.push('<table class="waitdialogzone" style="');
  245. oa.push(sty("width",zoneW));
  246. oa.push(sty("height",zoneH));
  247. oa.push('" id="frame_table_');
  248. oa.push(o.id);
  249. oa.push('" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top" class="dialogzone" id="frame_cont_');
  250. oa.push(o.id);
  251. oa.push('">');
  252. oa.push('<table border="0" cellspacing="0" cellpadding="0" width="100%"><tbody>');
  253. oa.push('<tr><td align="center" style="padding-top:5px;">');
  254. oa.push(img(_skin+'wait01.gif',200,40));
  255. oa.push('</td></tr>');
  256. oa.push('<tr><td align="left" style="padding-left:2px;padding-right:2px;padding-top:5px;">');
  257. oa.push('<div class="icontext" style="wordWrap:break_word;">');
  258. oa.push(convStr(L_bobj_crv_PrintControlProcessingMessage,false,true));
  259. oa.push('</div></td></tr></tbody></table>');
  260. oa.push('</td></tr></tbody></table>');
  261. oa.push('</td></tr></tbody></table>');
  262. return oa.join('');
  263. };
  264. bobj.crv.PrintUI._cancel = function () {
  265. if (this.isActxPrinting) {
  266. document.getElementById(this.actxContainerId).innerHTML = '';
  267. this._processingPrinting = false;
  268. }
  269. };
  270. bobj.crv.PrintUI._processPrinting = function(){
  271. if (!this._processingPrinting){
  272. var o = document.getElementById(this.actxId);
  273. var w = document.getElementById(this.actxId + '_wait');
  274. if (o && w){
  275. o.width = "100%";
  276. o.height = "100%";
  277. w.style.display="none";
  278. }
  279. this._processingPrinting = true;
  280. }
  281. };
  282. bobj.crv.PrintUI.show = function(visible, postBackData) {
  283. this._processingPrinting = false;
  284. if (visible) {
  285. if (!this.layer) {
  286. targetApp(this.getHTML());
  287. this.init();
  288. }
  289. if (this.isActxPrinting) {
  290. document.getElementById(this.actxContainerId).innerHTML = this._getObjectTag(postBackData);
  291. }
  292. this._showOld(true);
  293. }
  294. else if (this.layer) {
  295. this._showOld(false);
  296. }
  297. };
  298. bobj.crv.PrintUI.init = function() {
  299. this._initOld();
  300. if (!this.isActxPrinting) {
  301. this._fromBox.init();
  302. this._toBox.init();
  303. this._submitBtn.init();
  304. this._optionsFrame.init();
  305. this._allRadio.init();
  306. this._rangeRadio.init();
  307. if (!this.isExporting) {
  308. this._info.init();
  309. }
  310. this._allRadio.check(true);
  311. this._toBox.setDisabled(true);
  312. this._fromBox.setDisabled(true);
  313. if (this.widgetType == 'ExportUI') {
  314. this._initExportList();
  315. }
  316. }
  317. };
  318. bobj.crv.PrintUI.getHTML = function(){
  319. var h = bobj.html;
  320. var o = this;
  321. var strArr = [];
  322. strArr.push( o.beginHTML());
  323. if (!this.isActxPrinting) {
  324. strArr.push( '<table class="dialogzone" border=0 cellpadding=0 cellspacing=2>');
  325. strArr.push( '<tr>');
  326. strArr.push( ' <td style="padding-top:4px;">');
  327. strArr.push( o._optionsFrame.beginHTML());
  328. if (this.widgetType == 'ExportUI') {
  329. strArr.push( this._getExportList());
  330. }
  331. if(_ie)
  332. {
  333. strArr.push('<label tabIndex="0">' + L_bobj_crv_PrintRangeLbl + '</label>');
  334. }
  335. else
  336. {
  337. strArr.push(L_bobj_crv_PrintRangeLbl);
  338. }
  339. strArr.push( o._allRadio.getHTML());
  340. strArr.push( o._rangeRadio.getHTML());
  341. strArr.push( '<span style="padding-left:20px">' + L_bobj_crv_PrintFromLbl + '</span>');
  342. strArr.push( o._fromBox.getHTML());
  343. strArr.push( '<span style="padding-left:4px">' + L_bobj_crv_PrintToLbl + '</span>');
  344. strArr.push( o._toBox.getHTML());
  345. strArr.push( o._optionsFrame.endHTML());
  346. strArr.push( ' </td>');
  347. strArr.push( '</tr><tr>');
  348. if (!this.isExporting) {
  349. strArr.push( ' <td style="padding-top:8px;">');
  350. strArr.push( o._info.getHTML());
  351. strArr.push( ' </td>');
  352. strArr.push( '</tr><tr>');
  353. }
  354. strArr.push( ' <td align="right" style="padding-top:4px;">');
  355. strArr.push( o._submitBtn.getHTML());
  356. strArr.push( ' </td>');
  357. strArr.push( '</tr></table>');
  358. }
  359. else {
  360. strArr.push( h.DIV({id:this.actxContainerId}));
  361. strArr.push( '<script for="' + this.actxId + '" EVENT="Finished(status, statusText)" language="javascript">');
  362. strArr.push( 'getWidgetFromID("' + this.id + '").show(false);');
  363. strArr.push( '</script>');
  364. strArr.push( '<script for="' + this.actxId + '" EVENT="PrintingProgress(pageNumber)" language="javascript">');
  365. strArr.push( 'getWidgetFromID("' + this.id + '")._processPrinting();');
  366. strArr.push( '</script>');
  367. }
  368. strArr.push( o.endHTML());
  369. strArr.push( bobj.crv.getInitHTML(this.widx));
  370. return strArr.join('');
  371. };
  372. /*
  373. ================================================================================
  374. ExportUI
  375. ================================================================================
  376. */
  377. bobj.crv.newExportUI = function(kwArgs) {
  378. kwArgs = MochiKit.Base.update({ submitBtnLabel:L_bobj_crv_ExportBtnLbl,
  379. dialogTitle:L_bobj_crv_ExportDialogTitle,
  380. infoTitle:L_bobj_crv_ExportInfoTitle,
  381. infoMsg:L_bobj_crv_PrintInfo1,
  382. isExporting:true}, kwArgs);
  383. var o = bobj.crv.newPrintUI(kwArgs);
  384. o._comboBox = newCustomCombo(
  385. o.id + "_combo",
  386. MochiKit.Base.bind(bobj.crv.ExportUI._onSelectFormat, o),
  387. false,
  388. 270,
  389. L_bobj_crv_ExportFormatLbl,
  390. _skin + "../transp.gif", // Screen reader can't read its text without transp.gif
  391. 0,
  392. 14);
  393. //Adjustment to combo box after adding transp.gif as icon
  394. if(o._comboBox) {
  395. o._comboBox.icon.border=0;
  396. o._comboBox.icon.h=14;
  397. o._comboBox.arrow.h=12;
  398. o._comboBox.arrow.dy+=2
  399. o._comboBox.arrow.disDy+=2
  400. }
  401. o.availableFormats = (o.availableFormats ? eval(o.availableFormats) : null);
  402. var itemsCount = (bobj.isArray(o.availableFormats) ? o.availableFormats.length : 0);
  403. for (var i = 0; i < itemsCount; i++) {
  404. var item = o.availableFormats[i];
  405. o._comboBox.add(item.name, item.value, item.isSelected);
  406. }
  407. o.widgetType = 'ExportUI';
  408. MochiKit.Base.update(o, bobj.crv.ExportUI);
  409. return o;
  410. };
  411. bobj.crv.ExportUI._onSelectFormat = function() {
  412. var format = this._comboBox.getSelection().value;
  413. if (format == 'CrystalReports' || format == 'RecordToMSExcel' || format == 'CharacterSeparatedValues' || format == 'XML') {
  414. this._fromBox.setDisabled(true);
  415. this._toBox.setDisabled(true);
  416. this._rangeRadio.check(false);
  417. this._rangeRadio.setDisabled(true);
  418. this._allRadio.check(true);
  419. }
  420. else {
  421. this._rangeRadio.setDisabled(false);
  422. }
  423. };
  424. bobj.crv.ExportUI._initExportList = function() {
  425. if(!this._comboBox.initialized())
  426. {
  427. this._comboBox.init();
  428. var item0 = this._comboBox.getItemByIndex(0);
  429. if(item0 != null)
  430. {
  431. this._comboBox.selectItem(item0);
  432. }
  433. }
  434. this._onSelectFormat();
  435. };
  436. bobj.crv.ExportUI._getExportList = function() {
  437. var exportLabel = L_bobj_crv_ExportFormatLbl;
  438. if(_ie) {
  439. exportLabel = '<label tabIndex="0">' + L_bobj_crv_ExportFormatLbl + '</label>';
  440. }
  441. return exportLabel + this._comboBox.getHTML();
  442. };
  443. /*
  444. ================================================================================
  445. ErrorDialog
  446. TODO Dave: If time permits, make dialog resizable with mouse
  447. ================================================================================
  448. */
  449. /**
  450. * Static function.
  451. * @returns [ErrorDialog] Returns a shared Error Dialog
  452. */
  453. bobj.crv.ErrorDialog.getInstance = function() {
  454. if (!bobj.crv.ErrorDialog.__instance) {
  455. bobj.crv.ErrorDialog.__instance = bobj.crv.newErrorDialog();
  456. }
  457. return bobj.crv.ErrorDialog.__instance;
  458. };
  459. bobj.crv.newErrorDialog = function(kwArgs) {
  460. kwArgs = MochiKit.Base.update({
  461. id: bobj.uniqueId(),
  462. title: L_bobj_crv_Error,
  463. text: null,
  464. detailText: null,
  465. okLabel: L_bobj_crv_OK,
  466. promptType: _promptDlgCritical
  467. }, kwArgs);
  468. var o = newPromptDialog(
  469. kwArgs.id,
  470. kwArgs.title,
  471. kwArgs.text,
  472. kwArgs.okLabel,
  473. null, // cancelLabel
  474. kwArgs.promptType,
  475. null, // yesCB
  476. null, // noCB,
  477. true); // noCloseButton
  478. o.widgetType = 'ErrorDialog';
  479. // Update instance with constructor arguments
  480. bobj.fillIn(o, kwArgs);
  481. // Update instance with member functions
  482. o._promptDlgInit = o.init;
  483. o._promptDialogSetText = o.setText;
  484. o._promptDialogShow = o.show;
  485. o._promptDialogSetTitle = o.setTitle;
  486. o._promptDialogSetPromptType = o.setPromptType;
  487. MochiKit.Base.update(o, bobj.crv.ErrorDialog);
  488. o.noCB = MochiKit.Base.bind(o._onClose, o);
  489. o.yesCB = o.noCB;
  490. o._detailBtn = newIconWidget(
  491. o.id + "_detailBtn",
  492. bobj.skinUri('../help.gif'),
  493. MochiKit.Base.bind(bobj.crv.ErrorDialog._onDetailBtnClick, o),
  494. L_bobj_crv_showDetails, // Text
  495. null, // Tooltip
  496. 16,16,0,0,22,0);
  497. return o;
  498. };
  499. bobj.crv.ErrorDialog.init = function() {
  500. this._promptDlgInit();
  501. this._detailBtn.init();
  502. this._detailRow = document.getElementById(this.id + '_detRow');
  503. this._detailArea = document.getElementById(this.id + '_detArea');
  504. if (!this.detailText) {
  505. this._detailBtn.show(false);
  506. }
  507. };
  508. bobj.crv.ErrorDialog.getHTML = function() {
  509. var TABLE = bobj.html.TABLE;
  510. var TBODY = bobj.html.TBODY;
  511. var TR = bobj.html.TR;
  512. var TD = bobj.html.TD;
  513. var PRE = bobj.html.PRE;
  514. var DIV = bobj.html.DIV;
  515. var imgPath = PromptDialog_getimgPath(this.promptType);
  516. var imgAlt = PromptDialog_getimgAlt(this.promptType);
  517. var width = "320";
  518. var detailWidth = "300px";
  519. var detailHeight = "100px";
  520. var contentHTML =
  521. TABLE({'class':"dialogzone", width: width, cellpadding:"0", cellspacing:"5", border:"0"},
  522. TBODY(null,
  523. TR(null, TD(null,
  524. TABLE({'class':"dialogzone", cellpadding:"5", cellspacing:"0", border:"0"},
  525. TBODY(null,
  526. TR(null,
  527. TD({align:"right", width:"32"},
  528. img(imgPath, 32, 32, null, 'id="dlg_img_' + this.id + '"', imgAlt)),
  529. TD(),
  530. TD({id:"dlg_txt_" + this.id, align:"left", tabindex:"0"},
  531. convStr(this.text, false, true))))))),
  532. TR({id: this.id + '_detRow', style: {display: "none"}},
  533. TD(null, DIV({'class': "infozone", style: {width: detailWidth, 'height': detailHeight, overflow: "auto"}},
  534. PRE({id: this.id + '_detArea'}, this.detailText)))),
  535. TR(null, TD(null, getSep())),
  536. TR(null, TD(null,
  537. TABLE({cellpadding:"5", cellspacing:"0", border:"0", width:"100%"},
  538. TBODY(null,
  539. TR(null,
  540. TD({align:"left"}, this._detailBtn.getHTML()),
  541. TD({align:"right"}, this.yes.getHTML()))))))));
  542. return this.beginHTML() + contentHTML + this.endHTML();
  543. };
  544. /**
  545. * Set the error message and detail text.
  546. *
  547. * @param text [String] Error message
  548. * @param detailText [String] Detailed error message or technical info
  549. */
  550. bobj.crv.ErrorDialog.setText = function (text, detailText) {
  551. this.text = text;
  552. this.detailText = detailText;
  553. if (this.layer) {
  554. this._promptDialogSetText(text || '');
  555. if (this._detailArea) {
  556. this._detailArea.innerHTML = detailText || '';
  557. }
  558. var showDetails = detailText ? true : false;
  559. this._detailBtn.show(showDetails);
  560. if (!showDetails) {
  561. this.showDetails(false);
  562. }
  563. }
  564. };
  565. bobj.crv.ErrorDialog.setTitle = function (title) {
  566. this.title = title;
  567. if (this.layer) {
  568. this._promptDialogSetTitle(title || '');
  569. }
  570. };
  571. bobj.crv.ErrorDialog.setPromptType = function (promptType) {
  572. this.promptType = promptType;
  573. if (this.layer) {
  574. this._promptDialogSetPromptType(promptType);
  575. }
  576. };
  577. /**
  578. * Show/Hide the dialog
  579. *
  580. * @param isShow [bool(=true)] True value displays the dialog, false hides it.
  581. * @param closeCB [function] Callback to call after the next close event
  582. */
  583. bobj.crv.ErrorDialog.show = function(isShow, closeCB) {
  584. if (typeof isShow == 'undefined') {
  585. isShow = true;
  586. }
  587. if (isShow) {
  588. this._closeCB = closeCB;
  589. if (!this.layer) {
  590. targetApp(this.getHTML());
  591. this.init();
  592. }
  593. this.layer.onkeyup = DialogBoxWidget_keypress;
  594. DialogBoxWidget_keypress = MochiKit.Base.noop;
  595. this._promptDialogShow(true);
  596. }
  597. else if (this.layer){
  598. this._closeCB = null;
  599. this._promptDialogShow(false);
  600. }
  601. };
  602. /**
  603. * Show/Hide the detailed error message
  604. *
  605. * @param isShow [bool(=true)] True value displays the details, false hides them.
  606. */
  607. bobj.crv.ErrorDialog.showDetails = function(isShow) {
  608. if (typeof isShow == 'undefined') {
  609. isShow = true;
  610. }
  611. if (this._detailRow && this._detailBtn) {
  612. if (isShow) {
  613. this._detailRow.style.display = '';
  614. this._detailBtn.changeText(L_bobj_crv_hideDetails);
  615. }
  616. else {
  617. this._detailRow.style.display = 'none';
  618. this._detailBtn.changeText(L_bobj_crv_showDetails);
  619. }
  620. }
  621. };
  622. /**
  623. * Private. Handles detail button clicks.
  624. */
  625. bobj.crv.ErrorDialog._onDetailBtnClick = function() {
  626. if (this._detailRow) {
  627. this.showDetails(this._detailRow.style.display == 'none');
  628. }
  629. };
  630. /**
  631. * Private. Notifies listener that dialog has closed;
  632. */
  633. bobj.crv.ErrorDialog._onClose = function() {
  634. if (this._closeCB) {
  635. this._closeCB();
  636. this._closeCB = null;
  637. }
  638. DialogBoxWidget_keypress = this.layer.onkeyup;
  639. this.layer.onkeyup = null;
  640. };
  641. /*
  642. ================================================================================
  643. Report Processing Dialog
  644. ================================================================================
  645. kwArgs
  646. delay - the wait time prior to showing the dialog.
  647. message - a customized message to display in the dialog.
  648. */
  649. bobj.crv.newReportProcessingUI = function(kwArgs) {
  650. kwArgs = MochiKit.Base.update({
  651. id: bobj.uniqueId(),
  652. delay: 3000,
  653. message: L_bobj_crv_ReportProcessingMessage
  654. }, kwArgs);
  655. /* Since JSON escapes the '\' in unicode character references (\uXXXX) in Viewer
  656. * process indicator text is converted to html numeric referece (&#ddddd) which Javascript
  657. * don't display as expected. Little hack here to it as HTML string */
  658. var d = document.createElement('div');
  659. d.style.visibility = 'hidden';
  660. d.innerHTML = kwArgs.message;
  661. var newMsg = d.innerHTML;
  662. d = null;
  663. var o = newWaitDialogBoxWidget(
  664. kwArgs.id, // id
  665. 0, // width
  666. 0, // height
  667. '', // title
  668. true, // show cancel
  669. bobj.crv.ReportProcessingUI.cancelCB, // cancel callback
  670. true, // show label
  671. newMsg // label text
  672. );
  673. o.widgetType = 'ReportProcessingUI';
  674. o.delay = kwArgs.delay;
  675. // Update instance with member functions
  676. MochiKit.Base.update(o, bobj.crv.ReportProcessingUI);
  677. return o;
  678. };
  679. bobj.crv.reportProcessingDialog = null;
  680. bobj.crv.timerID = null;
  681. bobj.crv.ReportProcessingUI.cancelCB = function ()
  682. {
  683. bobj.crv.reportProcessingDialog.cancelled = true;
  684. if (bobj.crv.reportProcessingDialog.deferred !== null) {
  685. bobj.crv.reportProcessingDialog.deferred.cancel ();
  686. }
  687. bobj.crv.reportProcessingDialog.cancelShow ();
  688. };
  689. bobj.crv.ReportProcessingUI.wasCancelled = function ()
  690. {
  691. return bobj.crv.reportProcessingDialog.cancelled;
  692. };
  693. bobj.crv.ReportProcessingUI.delayedShow = function (showCancel) {
  694. // cleanup any existing dialog?
  695. if (bobj.crv.reportProcessingDialog !== null) {
  696. bobj.crv.reportProcessingDialog.cancelShow ();
  697. }
  698. if (!this.layer) {
  699. targetApp(this.getHTML());
  700. this.init();
  701. }
  702. this.cancelled = false;
  703. this.deferred = null;
  704. this.setShowCancel (showCancel, showCancel ? this.cancelCB : null);
  705. bobj.crv.reportProcessingDialog = this;
  706. bobj.crv.timerID = setTimeout("bobj.crv._showReportProcessingDialog ()", bobj.crv.reportProcessingDialog.delay);
  707. };
  708. bobj.crv.ReportProcessingUI.cancelShow = function () {
  709. if (bobj.crv.timerID) {
  710. clearTimeout (bobj.crv.timerID);
  711. }
  712. if (bobj.crv.reportProcessingDialog){
  713. bobj.crv.reportProcessingDialog.show (false);
  714. }
  715. bobj.crv.reportProcessingDialog = null;
  716. bobj.crv.timerID = null;
  717. };
  718. bobj.crv.ReportProcessingUI.setDeferred = function (deferred) {
  719. bobj.crv.reportProcessingDialog.deferred = deferred;
  720. if (bobj.crv.reportProcessingDialog.wasCancelled () === true) {
  721. deferred.cancel ();
  722. }
  723. };
  724. bobj.crv._showReportProcessingDialog = function () {
  725. if (bobj.crv.reportProcessingDialog && bobj.crv.reportProcessingDialog.delay !== 0) {
  726. bobj.crv.logger.info('ShowReportProcessingDialog');
  727. bobj.crv.reportProcessingDialog.show (true);
  728. }
  729. };