123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- import Ember from 'ember';
- export default Ember.Route.extend({
- actions: {
- setTitle: function(title) {
- if (typeof title === 'string') {
- title = {title: title};
- }
- var complete_title = title.title;
- if (typeof title.page !== 'undefined') {
- complete_title += ' (' + interpolate(gettext('page %(page)s'), {page:title.page}, true) + ')';
- }
- if (typeof title.parent !== 'undefined') {
- complete_title += ' | ' + title.parent;
- }
- complete_title += ' | ' + this.get('settings.forum_name');
- document.title = complete_title;
- return false;
- },
- // Error handler
- error: function(reason) {
- if (reason.status === 0) {
- this.send('setTitle', gettext('Connection lost'));
- return this.intermediateTransitionTo('error-0');
- }
- if (typeof reason.ban !== 'undefined') {
- this.send('setTitle', gettext('You are banned'));
- return this.intermediateTransitionTo('error-banned', reason.ban);
- }
- if (reason.status === 403) {
- this.send('setTitle', gettext('Page not available'));
- var final_error = {status: 403, message: null};
- if (reason.detail !== 'Permission denied') {
- final_error.message = reason.detail;
- }
- return this.intermediateTransitionTo('error-403', final_error);
- }
- if (reason.status === 404) {
- this.send('setTitle', gettext('Page not found'));
- return this.intermediateTransitionTo('error-404');
- }
- this.send('setTitle', gettext('Error'));
- return true;
- },
- showBan: function(ban) {
- this.send('setTitle', gettext('You are banned'));
- this.intermediateTransitionTo('error-banned', ban);
- return false;
- },
- // Flashes
- flashInfo: function(message) {
- this.controllerFor("flashMessage").send('setFlash', 'info', message);
- return false;
- },
- flashSuccess: function(message) {
- this.controllerFor("flashMessage").send('setFlash', 'success', message);
- return false;
- },
- flashWarning: function(message) {
- this.controllerFor("flashMessage").send('setFlash', 'warning', message);
- return false;
- },
- flashError: function(message) {
- this.controllerFor("flashMessage").send('setFlash', 'error', message);
- return false;
- },
- // Auth
- openLoginModal: function() {
- this.controllerFor("loginModal").send('open');
- return false;
- },
- logOut: function() {
- this.get('auth').logout();
- Ember.$('#hidden-logout-form').submit();
- return false;
- }
- }
- });
|