mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-30 10:42:41 +01:00
3c7944d297
Summary: - Looks better (can probably still use some tweaks), especially search. - Moves logout from weird footer location to main menu. - Reactive: on tablets and phones, the menu adjusts to remain useful. - Fixed position on desktops for future side nav changes. - Adds an icon header thing that's currently hard-coded but will be application-driven soon. Test Plan: Used menu on desktop, tablet, phone, logged in / logged out, toggled darkconsole. Will add some screenshots. Reviewers: btrahan, chad Reviewed By: btrahan CC: aran Maniphest Tasks: T1569 Differential Revision: https://secure.phabricator.com/D3105
73 lines
1.6 KiB
JavaScript
73 lines
1.6 KiB
JavaScript
/**
|
|
* @provides javelin-behavior-aphlict-dropdown
|
|
* @requires javelin-behavior
|
|
* javelin-request
|
|
* javelin-stratcom
|
|
* javelin-vector
|
|
* javelin-dom
|
|
*/
|
|
|
|
JX.behavior('aphlict-dropdown', function(config) {
|
|
var dropdown = JX.$(config.dropdownID);
|
|
var indicator = JX.$(config.indicatorID);
|
|
var menu = JX.$(config.menuID);
|
|
var visible = false;
|
|
var request = null;
|
|
|
|
function refresh() {
|
|
if (request) { //already fetching
|
|
return;
|
|
}
|
|
request = new JX.Request('/notification/panel/', function(response) {
|
|
JX.DOM.setContent(indicator, response.number);
|
|
if (response.number == 0) {
|
|
JX.DOM.alterClass(indicator,
|
|
"phabricator-main-menu-alert-indicator-unread", false);
|
|
} else {
|
|
JX.DOM.alterClass(indicator,
|
|
"phabricator-main-menu-alert-indicator-unread", true);
|
|
}
|
|
JX.DOM.setContent(dropdown, JX.$H(response.content));
|
|
request = null;
|
|
});
|
|
request.send();
|
|
}
|
|
|
|
refresh();
|
|
|
|
JX.Stratcom.listen(
|
|
'click',
|
|
null,
|
|
function(e) {
|
|
if(e.getNode('phabricator-notification-menu')) {
|
|
// Click is inside the dropdown.
|
|
return;
|
|
}
|
|
|
|
JX.DOM.hide(dropdown);
|
|
visible = false;
|
|
});
|
|
|
|
|
|
JX.DOM.listen(
|
|
menu,
|
|
'click',
|
|
null,
|
|
function(e) {
|
|
if (visible) {
|
|
JX.DOM.hide(dropdown);
|
|
} else {
|
|
var p = JX.$V(menu);
|
|
p.y = null;
|
|
p.x -= 6;
|
|
p.setPos(dropdown);
|
|
|
|
JX.DOM.show(dropdown);
|
|
}
|
|
visible = !visible;
|
|
e.kill();
|
|
}
|
|
)
|
|
|
|
JX.Stratcom.listen('notification-panel-update', null, refresh);
|
|
});
|