This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/controllers/header_controller.js
Gosha Arinich 7ec34b205a inject currentUser into controllers & routes
Through Ember's DI, instead of doing so via a mixin.
2013-09-07 19:34:25 +03:00

42 lines
1011 B
JavaScript

/**
This controller supports actions on the site header
@class HeaderController
@extends Discourse.Controller
@namespace Discourse
@module Discourse
**/
Discourse.HeaderController = Discourse.Controller.extend({
topic: null,
showExtraInfo: null,
toggleStar: function() {
var topic = this.get('topic');
if (topic) topic.toggleStar();
return false;
},
categories: function() {
return Discourse.Category.list();
}.property(),
showFavoriteButton: function() {
return this.get('currentUser') && !this.get('topic.isPrivateMessage');
}.property('currentUser', 'topic.isPrivateMessage'),
mobileDevice: function() {
return Discourse.Session.currentProp('mobileDevice');
}.property(),
mobileView: function() {
return Discourse.Session.currentProp('mobileView');
}.property(),
toggleMobileView: function() {
window.location.assign(window.location.pathname + '?mobile_view=' + (Discourse.Session.currentProp('mobileView') ? '0' : '1'));
}
});