1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-21 09:48:47 +02:00
phorge-phorge/webroot/rsrc/js/phui/behavior-phui-profile-menu.js

40 lines
1.1 KiB
JavaScript
Raw Normal View History

/**
* @provides javelin-behavior-phui-profile-menu
* @requires javelin-behavior
* javelin-stratcom
* javelin-dom
*/
JX.behavior('phui-profile-menu', function(config) {
// NOTE: This behavior is not initialized in the rendering pipeline for the
// menu, so it can get initialized when we build but do not render a menu
// (for example, when a page like the panel edit page only has items in
// the mobile/application menu, and does not show the profile menu). For now,
// just bail if we can't find the menu.
try {
var menu_node = JX.$(config.menuID);
} catch (ex) {
return;
}
var collapse_node = JX.$(config.collapseID);
var is_collapsed = config.isCollapsed;
JX.DOM.listen(collapse_node, 'click', null, function(e) {
is_collapsed = !is_collapsed;
JX.DOM.alterClass(menu_node, 'phui-profile-menu-collapsed', is_collapsed);
JX.DOM.alterClass(menu_node, 'phui-profile-menu-expanded', !is_collapsed);
if (config.settingsURI) {
new JX.Request(config.settingsURI)
.setData({value: (is_collapsed ? 1 : 0)})
.send();
}
e.kill();
});
});