Files
discourse/app/assets/javascripts/discourse/controllers/header_controller.js
Robin Ward aa269c92a0 Revert "ES6: AvatarSelector and HeaderController - also includes support for controllers with"
This reverts commit 44b2f82be84b5fbd316421159859996e1594b850.
2014-05-05 13:58:57 -04:00

46 lines
1.0 KiB
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,
notifications: null,
showStarButton: function() {
return Discourse.User.current() && !this.get('topic.isPrivateMessage');
}.property('topic.isPrivateMessage'),
actions: {
toggleStar: function() {
var topic = this.get('topic');
if (topic) topic.toggleStar();
return false;
},
showNotifications: function(headerView) {
var self = this;
Discourse.ajax("/notifications").then(function(result) {
self.set("notifications", result);
self.set("currentUser.unread_notifications", 0);
headerView.showDropdownBySelector("#user-notifications");
});
},
jumpToTopPost: function () {
var topic = this.get('topic');
if (topic) {
Discourse.URL.routeTo(topic.get('firstPostUrl'));
}
}
}
});