/
TopMenu.js
59 lines (50 loc) · 1.9 KB
/
TopMenu.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
var TopMenu = {
hasLoadedAboutPopupHtml: false,
init: function() {
// PROFILE
if (UserManager.isLoggedIn()) {
/*$('#top .profile').append('<img src="'+ user.smallImageUrl + '" width="24" height="24" />');*/
$('#top .profile').css('background-image', 'url(' + UserManager.currentUser.smallImageUrl + ')');
$('#top .profile').click(function(event) {
$(this).arrowPopup('#profile-popup');
});
EventSystem.addEventListener('user_profile_updated', function(params) {
$('#top .profile .display-name').text(params.displayName);
});
// I know, not the most natural place to put this...
$('#profile-popup .profile-page').click(function(event) {
UserManager.loadCurrentUser();
Utils.closeAnyOpenArrowPopup();
});
$('#top .login-link').hide();
} else {
$('#top .profile').hide();
$('#top .activities').hide();
}
// ABOUT
$('#top .about').click(function() {
$(this).arrowPopup('#about-popup');
if (!TopMenu.hasLoadedAboutPopupHtml) {
$.ajax({
url: '/about',
statusCode: {
200: function(data) {
TopMenu.hasLoadedAboutPopupHtml = true;
$('#about-popup').html(data);
}
}
});
}
});
// NOTIFICATIONS
$('#top .activities').click(function() {
$(this).arrowPopup('#activities-popup');
Activities.loadNotificationsPopup();
});
// SETTINGS
$('#top .settings').click(function() {
$(this).arrowPopup('#settings');
SettingsPopup.markAllPuffsAsSeen();
});
}
};