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
2013-11-22 21:07:03 +01:00

55 lines
1.2 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,
categories: function() {
return Discourse.Category.list();
}.property(),
showFavoriteButton: function() {
return Discourse.User.current() && !this.get('topic.isPrivateMessage');
}.property('topic.isPrivateMessage'),
mobileView: function() {
return Discourse.Mobile.mobileView;
}.property(),
showMobileToggle: function() {
return Discourse.SiteSettings.enable_mobile_theme;
}.property(),
actions: {
toggleStar: function() {
var topic = this.get('topic');
if (topic) topic.toggleStar();
return false;
},
toggleMobileView: function() {
Discourse.Mobile.toggleMobileView();
},
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");
});
}
}
});