From 07d99ee056267e0d1ebb5a24d4ce74940d0121c3 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 21 Jan 2012 01:06:11 +0530 Subject: [PATCH] delay timeout error to avoid it on page unload --- static/js/pandora/errorDialog.js | 71 +++++++++++++++++--------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/static/js/pandora/errorDialog.js b/static/js/pandora/errorDialog.js index 7bb03527..31dd2ee5 100644 --- a/static/js/pandora/errorDialog.js +++ b/static/js/pandora/errorDialog.js @@ -48,41 +48,44 @@ pandora.ui.errorDialog = function(data) { // on window unload, pending request will time out, so // in order to keep the dialog from appearing, delay it - - that = Ox.Dialog({ - buttons: [ - Ox.Button({ - id: 'close', - title: 'Close' - }) - .bindEvent({ - click: function() { - that.close(); - } - }) - ], - content: Ox.Element() - .append( - $('') - .attr({src: Ox.UI.PATH + 'png/icon128.png'}) - .css({position: 'absolute', left: '16px', top: '16px', width: '64px', height: '64px'}) - ) - .append( - Ox.Element() - .css({position: 'absolute', left: '96px', top: '16px', width: '256px'}) - .html( - 'Sorry, a server ' + error - + ' occured while handling your request. To help us find out what went wrong, you may want to report this error to an administrator. Otherwise, please try again later.' + setTimeout(function() { + if ($('.OxErrorDialog').length ==0 && !pandora.isUnloading) { + that = Ox.Dialog({ + buttons: [ + Ox.Button({ + id: 'close', + title: 'Close' + }) + .bindEvent({ + click: function() { + that.close(); + } + }) + ], + content: Ox.Element() + .append( + $('') + .attr({src: Ox.UI.PATH + 'png/icon128.png'}) + .css({position: 'absolute', left: '16px', top: '16px', width: '64px', height: '64px'}) ) - ), - fixedSize: true, - height: 192, - keys: {enter: 'close', escape: 'close'}, - removeOnClose: true, - title: 'Server ' + Ox.toTitleCase(error), - width: 368 - }) - .open(); + .append( + Ox.Element() + .css({position: 'absolute', left: '96px', top: '16px', width: '256px'}) + .html( + 'Sorry, a server ' + error + + ' occured while handling your request. To help us find out what went wrong, you may want to report this error to an administrator. Otherwise, please try again later.' + ) + ), + fixedSize: true, + height: 192, + keys: {enter: 'close', escape: 'close'}, + removeOnClose: true, + title: 'Server ' + Ox.toTitleCase(error), + width: 368 + }) + .open(); + } + }, 250); } that.addClass('OxErrorDialog'); };