privacy-policy.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import MisagoRoute from 'misago/routes/misago';
  2. export default MisagoRoute.extend({
  3. page: 'privacy-policy',
  4. defaultTitle: gettext('Privacy policy'),
  5. setting: function() {
  6. return this.get('page').replace(/-/g, '_');
  7. }.property('page'),
  8. title: function() {
  9. return this.get('settings.' + this.get('setting') + '_title') || this.get('defaultTitle');
  10. }.property('defaultTitle', 'settings'),
  11. link: function() {
  12. return this.get('settings.' + this.get('setting') + '_link');
  13. }.property('settings'),
  14. beforeModel: function(transition) {
  15. if (this.get('link')) {
  16. transition.abort();
  17. window.location.replace(this.get('link'));
  18. }
  19. },
  20. model: function() {
  21. var preloadedPage = this.preloadStore.pop(this.get('page'));
  22. if (preloadedPage) {
  23. this.store.push('legal-page', preloadedPage);
  24. }
  25. return this.store.find('legal-page', this.get('page'));
  26. },
  27. afterModel: function(model, transition) {
  28. if (model.get('link')) {
  29. transition.abort();
  30. window.location.replace(model.get('link'));
  31. }
  32. },
  33. actions: {
  34. didTransition: function() {
  35. this.set('title', this.get('title'));
  36. }
  37. }
  38. });