application.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import MisagoRoute from 'misago/routes/misago';
  2. export default MisagoRoute.extend({
  3. actions: {
  4. // Loading handler
  5. loading: function() {
  6. document.title = this.get('settings.forum_name');
  7. return true;
  8. },
  9. // Error handlers
  10. error: function(reason) {
  11. if (reason.status === 0) {
  12. return this.intermediateTransitionTo('error-0');
  13. }
  14. if (typeof reason.responseJSON !== 'undefined' && typeof reason.responseJSON.ban !== 'undefined') {
  15. return this.intermediateTransitionTo('error-banned', reason.responseJSON.ban);
  16. }
  17. if (reason.status === 403) {
  18. var final_error = {status: 403, message: null};
  19. if (typeof reason.responseJSON !== 'undefined' && typeof reason.responseJSON.detail !== 'undefined' && reason.responseJSON.detail !== 'Permission denied') {
  20. final_error.message = reason.responseJSON.detail;
  21. }
  22. return this.intermediateTransitionTo('error-403', final_error);
  23. }
  24. if (reason.status === 404) {
  25. return this.intermediateTransitionTo('error-404');
  26. }
  27. this.set('title', gettext('Error'));
  28. return true;
  29. }
  30. }
  31. });