window_management.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. /* This file is part of AToMPM - A Tool for Multi-Paradigm Modelling
  2. * Copyright 2011 by the AToMPM team and licensed under the LGPL
  3. * See COPYING.lesser and README.md in the root of this project for full details
  4. */
  5. ///////////////////////////////////////////////////////////////////////////////
  6. // DEPRECATED FUNCTIONS
  7. ///////////////////////////////////////////////////////////////////////////////
  8. function _openDialog(type, args, callback){
  9. AtomPMClient.alertDeprecatedFunctionCall("_openDialog");
  10. WindowManagement.openDialog(type, args, callback);
  11. }
  12. function _spawnClient(fname,callbackURL){
  13. AtomPMClient.alertDeprecatedFunctionCall("_spawnClient");
  14. WindowManagement.spawnClient(fname, callbackURL);
  15. }
  16. function _spawnHeadlessClient(context,onready,onchlog){
  17. AtomPMClient.alertDeprecatedFunctionCall("_spawnHeadlessClient");
  18. WindowManagement.spawnHeadlessClient(context, onready, onchlog);
  19. }
  20. function __showDialog(){
  21. alert(AtomPMClient);
  22. AtomPMClient.alertDeprecatedFunctionCall("__showDialog");
  23. WindowManagement.showDialog();
  24. }
  25. function __closeDialog(){
  26. AtomPMClient.alertDeprecatedFunctionCall("__closeDialog");
  27. WindowManagement.closeDialog();
  28. }
  29. ///////////////////////////////////////////////////////////////////////////////
  30. //DEPRECATED FUNCTIONS
  31. ///////////////////////////////////////////////////////////////////////////////
  32. var __dialog_stack = [];
  33. WindowManagement = function(){
  34. /**
  35. * Hides the login screen
  36. */
  37. this.hideLoginScreen = function()
  38. {
  39. //$('#div_login').style.display = 'none';
  40. $('#div_login').css('display', 'none');
  41. __setCanvasScrolling(true);
  42. };
  43. /**
  44. * Shows the login screen
  45. */
  46. this.showLoginScreen = function()
  47. {
  48. //$('#div_login').style.display = 'inline';
  49. $('#div_login').css('display', 'inline');
  50. __setCanvasScrolling(false);
  51. };
  52. //Todo: Shred this function into smaller functions, as this should
  53. // really just amount to a switch statement
  54. //TBI: complete comments about each dialog (copy from user's manual)
  55. /**
  56. * Opens a general dialog window
  57. */
  58. this.openDialog = function(type,args,callback)
  59. {
  60. args = args || {};
  61. function error(err,fatal)
  62. {
  63. console.error("Error! " + err);
  64. GUIUtils.setupAndShowDialog(
  65. [GUIUtils.getTextSpan(
  66. err,
  67. 'error')],
  68. undefined,
  69. (fatal ? __NO_BUTTONS : __ONE_BUTTON),
  70. (fatal ? 'FATAL ERROR (restart required)' : 'ERROR'));
  71. //console.error(err,args);
  72. }
  73. // TODO: Fix this, convert to JQuery
  74. if( type == _CLOUD_DATA_MANAGER )
  75. /* args: extensions,readonly,title */
  76. {
  77. HttpUtils.httpReq(
  78. 'GET',
  79. HttpUtils.url('/filelist',__NO_WID),
  80. undefined,
  81. function(statusCode,resp){
  82. var fnames = __localizeFilenames(
  83. __filterFilenamesByExtension(
  84. resp.split('\n'),
  85. args['extensions'] || ['.*'])).sort(),
  86. maxFnameLength =
  87. utils.max(fnames, function(_) {
  88. return _.length;
  89. }),
  90. fileb = FileBrowser.getFileBrowser(fnames,true),
  91. feedbackarea = $('<div>'),
  92. feedback = GUIUtils.getTextSpan(''),
  93. progressbar = $('<div>'),
  94. progressfill = $('<div>'),
  95. download = $('<div>'),
  96. trash = $('<div>'),
  97. div_dldel = $('<div>'),
  98. hldropzone =
  99. /* highlight or unhighlight the dropzone */
  100. function(zone)
  101. {
  102. if( zone == undefined )
  103. {
  104. fileb['filepane']().attr('class', 'fileb_pane');
  105. download.attr('class', 'dropzone');
  106. trash.attr('class', 'dropzone');
  107. }
  108. else if( zone == 'upload' )
  109. {
  110. var filepane = fileb['filepane']();
  111. filepane.attr('class', 'fileb_pane droppable');
  112. filepane.get(0).ondrop = onfilepanedrop;
  113. }
  114. else if( zone == 'dl/del' )
  115. {
  116. download.attr('class', 'dropzone droppable');
  117. trash.attr('class', 'dropzone droppable');
  118. }
  119. },
  120. cancelevt =
  121. /* prevent event bubbling */
  122. function(event)
  123. {
  124. event.stopPropagation();
  125. event.preventDefault();
  126. return false;
  127. },
  128. ondownloaddrop =
  129. function(event)
  130. {
  131. cancelevt(event);
  132. hldropzone();
  133. window.location.assign(event.dataTransfer.getData('uri'));
  134. },
  135. ontrashdrop =
  136. function(event)
  137. {
  138. cancelevt(event);
  139. hldropzone();
  140. var uri = event.dataTransfer.getData('uri');
  141. DataUtils.deleteFromCloud(uri,
  142. function(statusCode,resp)
  143. {
  144. if( ! utils.isHttpSuccessCode(statusCode) )
  145. return error(resp);
  146. feedback.html('deleted '+uri.match(/.*\/(.+)\.file/)[1]);
  147. });
  148. },
  149. onfilepanedrop =
  150. /* react to file drop from desktop
  151. 1. exit with error if non-zip files
  152. 2. move to handleFiles() otherwise */
  153. function(event)
  154. {
  155. cancelevt(event);
  156. hldropzone();
  157. var files = event.dataTransfer.files;
  158. for( var i=0; i<files.length; i++ )
  159. if( files[i].type != 'application/zip' )
  160. return error('uploaded files must zip archives');
  161. handleFiles(event.dataTransfer.files,0);
  162. },
  163. handleFiles =
  164. /* handle each dropped file from desktop
  165. 1. retrieve next file to handle
  166. 2. update feedback message and show progress bar
  167. 3. init file reader event handlers
  168. . onprogress updates progress bar
  169. . onload reacts to upload completion by adjusting
  170. feedback message, hiding progress bar and sending
  171. file to backend
  172. 4. start upload */
  173. function(files,i)
  174. {
  175. if( i >= files.length)
  176. return;
  177. var file = files[i];
  178. feedback.html('uploading '+file.name);
  179. progressbar.css("display", 'inline-block');
  180. var reader = new FileReader();
  181. reader.onprogress =
  182. function(event)
  183. {
  184. if( event.lengthComputable )
  185. progressfill.css("width",
  186. (100*event.loaded/event.total)+'%');
  187. };
  188. reader.onload =
  189. function(event)
  190. {
  191. progressfill.css("width", '100%');
  192. feedback.html('processing '+file.name+' ...');
  193. progressbar.css("display", 'none');
  194. DataUtils.uploadToCloud(
  195. fileb['getcurrfolder'](),
  196. event.target.result,
  197. function(statusCode,resp)
  198. {
  199. if( ! utils.isHttpSuccessCode(statusCode) )
  200. return error(resp);
  201. feedback.html('successfully processed '+file.name);
  202. handleFiles(files,++i);
  203. });
  204. };
  205. reader.readAsBinaryString(file);
  206. },
  207. cloudmgrClosed =
  208. function()
  209. {
  210. return fileb['filebrowser'].parent() == null;
  211. };
  212. document.body.ondragenter =
  213. /* show dropzone when file drag from desktop enters window */
  214. function(event)
  215. {
  216. if(cloudmgrClosed()) return true;
  217. cancelevt(event);
  218. hldropzone(
  219. (event.dataTransfer.effectAllowed == 'copyMove' ? 'dl/del' : 'upload'));
  220. return false;
  221. };
  222. document.body.ondragleave =
  223. /* hide dropzone when file drag from desktop leaves window (which
  224. causes event.pageX == 0) */
  225. function(event)
  226. {
  227. if(cloudmgrClosed()) return true;
  228. cancelevt(event);
  229. if( event.pageX == 0 )
  230. hldropzone();
  231. return false;
  232. };
  233. document.body.ondrop =
  234. function(event)
  235. {
  236. if(cloudmgrClosed()) return true;
  237. cancelevt(event);
  238. hldropzone();
  239. console.warn('non-dropzone drops are ignored');
  240. return false;
  241. };
  242. fileb['filebrowser'].attr('title',
  243. 'drag\'n\'drop files to file pane to upload\n'+
  244. '(close and re-open dialog to observe effects)');
  245. download.attr('title', 'drag\'n\'drop files from file pane to download');
  246. trash.attr('title', 'drag\'n\'drop files from file pane to delete\n'+
  247. '(close and re-open dialog to observe effects)');
  248. progressfill.attr('class', 'progress_fill');
  249. progressfill.html('&nbsp;');
  250. progressbar.attr('class', 'progress_bar');
  251. progressbar.append(progressfill);
  252. progressbar.css("display", 'none');
  253. feedbackarea.append(feedback);
  254. feedbackarea.append(progressbar);
  255. download.css("backgroundImage", 'url(client/media/download.png)');
  256. trash.css("backgroundImage", 'url(client/media/trash.png)');
  257. download.attr('class', 'dropzone');
  258. trash.attr('class', 'dropzone');
  259. download.css("cssFloat", 'left');
  260. trash.css("cssFloat", 'right');
  261. download.get(0).ondragover = cancelevt;
  262. trash.get(0).ondragover = cancelevt;
  263. download.get(0).ondrop = ondownloaddrop;
  264. trash.get(0).ondrop = ontrashdrop;
  265. div_dldel.append(download);
  266. div_dldel.append(trash);
  267. if( args['readonly'] )
  268. trash.css("display", 'none');
  269. GUIUtils.setupAndShowDialog(
  270. [fileb['filebrowser'],div_dldel,feedbackarea],
  271. undefined,
  272. __ONE_BUTTON,
  273. args['title'] ||
  274. 'manage your cloud data\n(note:: you must close and re-open '+
  275. 'dialog to view upload and deletion effects)');
  276. });
  277. }
  278. else if( type == _CUSTOM )
  279. /* args: widgets, title
  280. 'widgets' must be a list where each entry is either
  281. ['id':___,'type':'input','label':___,'default':___], or
  282. ['id':___,'type':'select','choices':___,'multipleChoice':___] */
  283. {
  284. var elements = [],
  285. getinputs = [];
  286. args['widgets'].forEach(
  287. function(w)
  288. {
  289. if( w['type'] == 'select' )
  290. {
  291. var select = GUIUtils.getSelector(w['choices'],w['multipleChoice']);
  292. getinputs.push(function(_)
  293. {
  294. _[w['id']] = HttpUtils.getSelectorSelection(select);
  295. });
  296. elements.push(select);
  297. }
  298. else if( w['type'] == 'input' )
  299. {
  300. var label = GUIUtils.getTextSpan(w['label'] || ''),
  301. input = GUIUtils.getStringInput(w['default'] || '');
  302. getinputs.push(function(_)
  303. {
  304. _[w['id']] = input[0].value;
  305. });
  306. elements.push(label,input);
  307. }
  308. });
  309. GUIUtils.setupAndShowDialog(
  310. elements,
  311. function()
  312. {
  313. var values = {};
  314. getinputs.forEach( function(gi) {gi(values);} );
  315. return values;
  316. },
  317. __TWO_BUTTONS,
  318. args['title'],
  319. callback);
  320. }
  321. else if( type == _ENTITY_EDITOR )
  322. /* args: uri */
  323. {
  324. var uri = (args['uri'] || __selection['items'][0]),
  325. matches = uri.match(/.*\/(.*)Icon\/(.*)\.instance/) ||
  326. uri.match(/.*\/(.*)Link\/(.*)\.instance/),
  327. type = matches[1],
  328. id = matches[2];
  329. HttpUtils.httpReq(
  330. 'GET',
  331. HttpUtils.url(uri),
  332. undefined,
  333. function(statusCode,resp)
  334. {
  335. if( ! utils.isHttpSuccessCode(statusCode) )
  336. return error(resp);
  337. return openDialog(
  338. _DICTIONARY_EDITOR,
  339. {'data': utils.jsonp( utils.jsonp(resp)['data'] ),
  340. 'ignoreKey':
  341. function(attr,val)
  342. {
  343. return attr.charAt(0) == '$' || val == undefined;
  344. },
  345. 'keepEverything':
  346. function()
  347. {
  348. return __changed(uri);
  349. },
  350. 'title':'edit '+type+' #'+id},
  351. callback || function(changes) {DataUtils.update(uri,changes);});
  352. });
  353. }
  354. else if( type == _ERROR )
  355. error(args);
  356. else if( type == __FATAL_ERROR )
  357. error(args,true);
  358. else if( type == _FILE_BROWSER )
  359. /* args: extensions,manualInput,title,startDir */
  360. {
  361. FileBrowser.buildFileBrowser(args['extensions'], args['manualInput'], args['title'], args['startDir'], callback);
  362. }
  363. else if( type == _LEGAL_CONNECTIONS )
  364. /* args: uri1, uri2, ctype, forceCallback */
  365. {
  366. var legalConnections = __legalConnections(args['uri1'],args['uri2'],args['ctype']);
  367. if( legalConnections.length == 0 )
  368. {
  369. var err = 'no valid connection between selected types';
  370. if( args['forceCallback'] )
  371. callback({'$err':err});
  372. else
  373. error(err);
  374. }
  375. else if( legalConnections.length == 1 )
  376. callback( legalConnections[0]+'Link.type' );
  377. else
  378. {
  379. var select = GUIUtils.getSelector(legalConnections);
  380. GUIUtils.setupAndShowDialog(
  381. [select],
  382. function() {return HttpUtils.getSelectorSelection(select)+'Link.type';},
  383. __TWO_BUTTONS,
  384. 'choose connection type',
  385. callback);
  386. }
  387. }
  388. else if( type == _LOADED_TOOLBARS )
  389. /* args: multipleChoice, type, title */
  390. {
  391. var choosableToolbars = [];
  392. for( var tb in __loadedToolbars )
  393. {
  394. if( (args['type'] == undefined &&
  395. (__isIconMetamodel(tb) || __isButtonModel(tb))) ||
  396. (args['type'] == 'metamodels' &&
  397. __isIconMetamodel(tb)) ||
  398. (args['type'] == 'buttons' &&
  399. __isButtonModel(tb)) )
  400. choosableToolbars.push(tb);
  401. }
  402. var select = GUIUtils.getSelector(choosableToolbars,args['multipleChoice']);
  403. GUIUtils.setupAndShowDialog(
  404. [select],
  405. function() {return HttpUtils.getSelectorSelection(select);},
  406. __TWO_BUTTONS,
  407. args['title'],
  408. callback);
  409. }
  410. else if( type == _DICTIONARY_EDITOR )
  411. /* args: data, ignoreKey, keepEverything, title */
  412. {
  413. var form = $('<form>'),
  414. table = $('<table>'),
  415. attrs2ii = {};
  416. form.onsubmit = function() {return false;};
  417. form.append(table);
  418. for( var attr in args['data'] )
  419. {
  420. if( args['ignoreKey'] != undefined &&
  421. args['ignoreKey'](attr,args['data'][attr]['value']) )
  422. continue;
  423. var tr = $('<tr>');
  424. var ii = GUIUtils.getInputField(
  425. args['data'][attr]['type'],
  426. args['data'][attr]['value']);
  427. // var tr = table.append( $('<tr>') ),
  428. // ii = GUIUtils.getInputField(
  429. // args['data'][attr]['type'],
  430. // args['data'][attr]['value']);
  431. tr.append( $('<td>').append( GUIUtils.getTextSpan(attr)) );
  432. tr.append( $('<td>').append(ii.input) );
  433. if (ii.input.extra_el) tr.append( $('<td>').append(ii.input.extra_el) );
  434. attrs2ii[attr] = ii;
  435. table.append( tr );
  436. }
  437. GUIUtils.setupAndShowDialog(
  438. [form],
  439. function()
  440. {
  441. var changes = {},
  442. keepAll = (args['keepEverything'] != undefined &&
  443. args['keepEverything']());
  444. for( var attr in attrs2ii )
  445. {
  446. var am = attrs2ii[attr];
  447. var newVal = am['getinput'](am['input']);
  448. if( keepAll ||
  449. utils.jsons(newVal) != utils.jsons(am['oldVal']) )
  450. changes[attr] = newVal;
  451. }
  452. return changes;
  453. },
  454. __TWO_BUTTONS,
  455. args['title'],
  456. callback);
  457. }
  458. else if( type == __SVG_TEXT_EDITOR )
  459. {
  460. if( args.tagName != 'tspan' )
  461. {
  462. console.warn('SVG text editing only works on "Text" VisualObjects');
  463. return;
  464. }
  465. var vobj = args.parentNode,
  466. vobjuri = vobj.getAttribute('__vobjuri'),
  467. iconuri = __vobj2uri(vobj),
  468. lines = [];
  469. for( var i=0; i < vobj.children.length; i++ )
  470. if( vobj.children[i].tagName == 'tspan' )
  471. lines.push(vobj.children[i].textContent);
  472. var input =
  473. GUIUtils.getTextInput(
  474. lines.join('\n'),
  475. undefined,
  476. Math.min(lines.length,__MAX_TEXTAREA_LINES) );
  477. GUIUtils.setupAndShowDialog(
  478. [input],
  479. function() {return input.value;},
  480. __TWO_BUTTONS,
  481. 'enter new text',
  482. function(newVal)
  483. {
  484. DataUtils.update(
  485. iconuri+'/'+vobjuri+'.vobject',{'textContent':newVal});
  486. });
  487. }
  488. };
  489. /* spawn a new instance of atompm... if a model is specified (as 'fname'), it is
  490. loaded into the new instance... if a callback url is specified, critical
  491. information about the new instance is POSTed to it
  492. NOTE:: window.open returns a reference to the created window... however, this
  493. reference is not always complete (e.g. body.onload has not necessarily
  494. run its course)... for this reason, before proceeding with handling
  495. 'fname' and 'callbackURL', we poll the reference to ensure its
  496. completion */
  497. this.spawnClient = function (fname,callbackURL)
  498. {
  499. var c = window.open(window.location.href, '_blank'),
  500. onspawn =
  501. function()
  502. {
  503. if( (fname || callbackURL) &&
  504. (c.__wid == undefined ||
  505. c.__aswid == undefined ||
  506. c._loadModel == undefined) )
  507. return window.setTimeout(onspawn,250);
  508. c.__user = __user;
  509. if( fname )
  510. c._loadModel(fname);
  511. if( callbackURL )
  512. _httpReq(
  513. 'POST',
  514. callbackURL,
  515. {'aswid':c.__aswid,
  516. 'cswid':c.__wid,
  517. 'fname':fname,
  518. 'host':window.location.host});
  519. };
  520. onspawn();
  521. };
  522. /* NOTE:: Automating activities
  523. spawn a new instance of atompm... if a model is specified (as 'fname'), it is
  524. loaded into the new instance, if a toolbar is especified (as 'tbname'), it's loaded
  525. into the new instance, if a message is especified a popup message will show in
  526. the instance*/
  527. this.spawnClientOption = function (fname,tbname,option,trafo,msg)
  528. {
  529. var c = window.open(window.location.href, '_blank'),
  530. onspawn =
  531. function()
  532. {
  533. if( (fname|| tbname) &&
  534. (c.__wid == undefined ||
  535. c.__aswid == undefined ||
  536. c._loadModel == undefined ||
  537. c._loadToolbar == undefined) )
  538. return window.setTimeout(onspawn,250);
  539. c.__user = __user;
  540. c.__name = fname;
  541. c.__option = option;
  542. c.__trafo = trafo;
  543. c.__msg = msg;
  544. if (trafo == undefined){
  545. trafo = option
  546. }
  547. if( tbname ){
  548. toolbars = tbname.split(",");
  549. for ( var n in toolbars){
  550. c._loadToolbar(toolbars[n]);
  551. }
  552. }
  553. if( fname ){
  554. c.__saveas = fname;
  555. if( option.length > 2 ){
  556. c._loadModel(fname);
  557. }
  558. }
  559. };
  560. onspawn();
  561. };
  562. /* initialize a headless client, i.e. a client with a proper backend but whose
  563. socket-message handling code is user-defined
  564. 1. setup new backend csworker and subscribe to it
  565. 2. call 'onready'
  566. 3. from this point on, all incoming socket messages are dispatched to
  567. 'onchlog'
  568. NOTE:: this code and the above comments are simplified versions of what's in
  569. initClient() (TBI:: merge this function with initClient()??)
  570. NOTE:: the context object gets populated with the headless client's wids and
  571. with a pointer to a function that closes it (as 'close') */
  572. this.spawnHeadlessClient = function (context,onready,onchlog)
  573. {
  574. var socket = io.connect(
  575. window.location.hostname,
  576. {'port':8124,'reconnect':false,'force new connection':true});
  577. socket.on('message',
  578. function(msg)
  579. {
  580. console.debug(' >>> '+utils.jsons(msg));
  581. if( msg['statusCode'] != undefined )
  582. {
  583. if( msg['statusCode'] == 201 )
  584. {
  585. HttpUtils.httpReq(
  586. 'PUT',
  587. '/aswSubscription?wid='+context.__wid,
  588. undefined,
  589. function(statusCode,resp)
  590. {
  591. context.__aswid = utils.jsonp(resp)['data'];
  592. onready();
  593. });
  594. context.close = socket.socket.disconnect;
  595. }
  596. else
  597. console.error('headless client failed to connect to back-end');
  598. }
  599. else
  600. onchlog(
  601. msg['data']['changelog'],
  602. msg['data']['sequence#'],
  603. msg['data']['hitchhiker']);
  604. });
  605. socket.on('disconnect',
  606. function()
  607. {
  608. console.debug('headless client lost connection to back-end');
  609. });
  610. socket.on('connect',
  611. function()
  612. {
  613. HttpUtils.httpReq(
  614. 'POST',
  615. '/csworker',
  616. undefined,
  617. function(statusCode,resp)
  618. {
  619. console.debug("Connect!");
  620. console.debug(statusCode);
  621. console.debug(resp);
  622. context.__wid = resp;
  623. socket.emit(
  624. 'message',
  625. {'method':'POST','url':'/changeListener?wid='+context.__wid});
  626. });
  627. });
  628. };
  629. /**
  630. * Sets whether to update the window title or not
  631. * @param changed whether or not the title has changed
  632. */
  633. this.setWindowTitle = function(changed)
  634. {
  635. if( __saveas == undefined )
  636. document.title =
  637. __TITLE +' - '+
  638. (changed ? '+ ' :'')+
  639. '[Unnamed]';
  640. else
  641. document.title =
  642. __TITLE+' - '+
  643. (changed ? '+ ' :'')+
  644. __saveas.match(/(.*\/){0,1}(.*)\.model/)[2]+' - '+
  645. __saveas;
  646. };
  647. /**
  648. * Displays the modal dialog
  649. */
  650. this.showDialog = function()
  651. {
  652. var dialog = __dialog_stack[__dialog_stack.length-1],
  653. dim_bg = $('#div_dim_bg');
  654. dim_bg.css("display", 'inline');
  655. dialog.css("display", 'block');
  656. dialog.css("left", document.body.scrollLeft +
  657. window.innerWidth/2 -
  658. dialog.width()/2 + "px");
  659. dialog.css("top", document.body.scrollTop +
  660. window.innerHeight/2 -
  661. dialog.height()/2 + "px");
  662. __setCanvasScrolling(false);
  663. };
  664. /**
  665. * Closes the modal dialog if it is currently opened (with arg js event)
  666. * Huseyin Ergin
  667. * HUSEYIN-ENTER
  668. */
  669. this.closeDialog = function(ev)
  670. {
  671. if(ev!=null && ev.keyCode==13) {
  672. $('#div_dialog_' + (__dialog_stack.length-1).toString() + " .okbutton").click();
  673. }
  674. __dialog_stack.pop()
  675. var dialog = $('#div_dialog_'+__dialog_stack.length);
  676. dialog.remove();
  677. if (!__dialog_stack.length) {
  678. __setCanvasScrolling(true);
  679. $('#div_dim_bg').css("display", 'none');
  680. BehaviorManager.setActiveBehaviourStatechart(__SC_CANVAS);
  681. }
  682. };
  683. return this;
  684. }();