application.js 1.3 KB

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