privacy-policy.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import Ember from 'ember';
  2. import ResetScroll from 'misago/mixins/reset-scroll';
  3. export default Ember.Route.extend(ResetScroll, {
  4. page: 'privacy-policy',
  5. defaultTitle: gettext('Privacy policy'),
  6. setting: function() {
  7. return this.get('page').replace(/-/g, '_');
  8. }.property('page'),
  9. title: function() {
  10. return this.get('settings.' + this.get('setting') + '_title') || this.get('defaultTitle');
  11. }.property('defaultTitle', 'settings'),
  12. link: function() {
  13. return this.get('settings.' + this.get('setting') + '_link');
  14. }.property('settings'),
  15. beforeModel: function(transition) {
  16. if (this.get('link')) {
  17. transition.abort();
  18. window.location.replace(this.get('link'));
  19. }
  20. },
  21. model: function() {
  22. return this.store.find('legal-page', this.get('page'));
  23. },
  24. afterModel: function(model, transition) {
  25. if (model.get('link')) {
  26. transition.abort();
  27. window.location.replace(model.get('link'));
  28. }
  29. },
  30. actions: {
  31. didTransition: function() {
  32. this.get('page-title').setTitle(this.get('title'));
  33. }
  34. }
  35. });