Permalink
Browse files

ENHANCEMENT Moving X-Status message handling in CMS from global ajaxE…

…rror to ajaxComplete handler, to allow success messages being passed this way as well.
  • Loading branch information...
1 parent 6956b1b commit 2753744f9ebd781718186c6dc0040af7dec33f05 @chillu chillu committed May 10, 2012
Showing with 9 additions and 8 deletions.
  1. +9 −8 admin/javascript/LeftAndMain.js
@@ -47,18 +47,19 @@ jQuery.noConflict();
window.History.pushState(opts, '', url);
}
}
- });
- $(document).ajaxError(function(e, xhr, settings, error) {
- if(xhr.status == 0) return; // ignore aborted requests
- if(xhr.status < 200 || xhr.status > 399) {
- var msg = (xhr.getResponseHeader('X-Status')) ? xhr.getResponseHeader('X-Status') : xhr.statusText;
- } else {
- msg = error;
+ // Handle custom status message headers
+ var msg = (xhr.getResponseHeader('X-Status')) ? xhr.getResponseHeader('X-Status') : xhr.statusText,
+ msgType = (xhr.status < 200 || xhr.status > 399) ? 'bad' : 'good',
+ ignoredMessages = ['OK'];
+
+ // Show message (but ignore aborted requests)
+ if(xhr.status !== 0 && msg && $.inArray(msg, ignoredMessages)) {
+ statusMessage(msg, msgType);
}
- statusMessage(msg, 'bad');
});
+
/**
* Main LeftAndMain interface with some control panel and an edit form.
*

0 comments on commit 2753744

Please sign in to comment.