diff --git a/static/js/pandora.js b/static/js/pandora.js
index 4d7c6d952..6cf415773 100644
--- a/static/js/pandora.js
+++ b/static/js/pandora.js
@@ -172,7 +172,7 @@ appPanel
function loadPandoraFiles(callback) {
var prefix = '/static/';
if (localStorage && localStorage['pandora.debug']) {
- Ox.getJSON(prefix + 'json/pandora.json', function(files) {
+ Ox.getJSON(prefix + 'json/pandora.json?' + Ox.random(1000), function(files) {
var promises = [];
files.forEach(function(file) {
var dfd = new $.Deferred();
@@ -287,7 +287,9 @@ appPanel
Ox.Request.requests() && pandora.$ui.loadingIcon.start();
pandora.$ui.body.ajaxStart(pandora.$ui.loadingIcon.start);
pandora.$ui.body.ajaxStop(pandora.$ui.loadingIcon.stop);
-
+ Ox.Request.bindEvent({
+ error: pandora.ui.errorDialog
+ });
pandora.site.sectionButtonsWidth = pandora.$ui.sectionButtons.width() + 8;
});
diff --git a/static/js/pandora/errorDialog.js b/static/js/pandora/errorDialog.js
new file mode 100644
index 000000000..7bb035276
--- /dev/null
+++ b/static/js/pandora/errorDialog.js
@@ -0,0 +1,88 @@
+// vim: et:ts=4:sw=4:sts=4:ft=javascript
+'use strict';
+
+pandora.ui.errorDialog = function(data) {
+ var that, error;
+
+ //dont open dialog on unload or if antoher error is open
+ //fixme: error dialog should updated instead
+ if ($('.OxErrorDialog').length || pandora.isUnloading) {
+ return;
+ }
+
+ if (data.status.code == 401 || data.status.code == 403) {
+ 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, you have made an unauthorized request.')
+ ),
+ fixedSize: true,
+ height: 192,
+ keys: {enter: 'close', escape: 'close'},
+ removeOnClose: true,
+ title: Ox.toTitleCase(data.status.text),
+ width: 368
+ })
+ .open();
+ } else {
+ // 0 (timeout) or 500 (error)
+ var error = data.status.code == 0 ? 'timeout' : 'error';
+
+ // 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.'
+ )
+ ),
+ fixedSize: true,
+ height: 192,
+ keys: {enter: 'close', escape: 'close'},
+ removeOnClose: true,
+ title: 'Server ' + Ox.toTitleCase(error),
+ width: 368
+ })
+ .open();
+ }
+ that.addClass('OxErrorDialog');
+};
diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js
index 8d2a07d45..2881f786e 100644
--- a/static/js/pandora/utils.js
+++ b/static/js/pandora/utils.js
@@ -1034,6 +1034,8 @@ pandora.selectList = function() {
};
pandora.unloadWindow = function() {
+ //prevent errors on unload
+ pandora.isUnloading = true;
/*
// fixme: ajax request has to have async set to false for this to work
pandora.user.ui.section == 'items'