mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-15 18:10:53 +01:00
56d3197fe0
Summary: Ref T11179. Alternative to D16152. I think this turned out a bit better than the other one did. Currently, we render two copies of the menu (one for mobile, one for desktop). A big chunk of this is sharing the nodes instead: when you open the mobile dropdown menu, it steals the nodes from the document. When you close it, it puts them back. Magic! Sneaky! Test Plan: {F1695499} {F1695500} Reviewers: chad Reviewed By: chad Maniphest Tasks: T11179 Differential Revision: https://secure.phabricator.com/D16157
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
/**
|
|
* @provides javelin-behavior-phui-submenu
|
|
* @requires javelin-behavior
|
|
* javelin-stratcom
|
|
* javelin-dom
|
|
*/
|
|
|
|
JX.behavior('phui-submenu', function() {
|
|
|
|
JX.Stratcom.listen('click', 'phui-submenu', function(e) {
|
|
if (!e.isNormalClick()) {
|
|
return;
|
|
}
|
|
|
|
var node = e.getNode('phui-submenu');
|
|
var data = e.getNodeData('phui-submenu');
|
|
|
|
e.kill();
|
|
|
|
data.open = !data.open;
|
|
|
|
for (var ii = 0; ii < data.itemIDs.length; ii++) {
|
|
var id = data.itemIDs[ii];
|
|
var item = JX.$(id);
|
|
if (data.open) {
|
|
JX.DOM.show(item);
|
|
} else {
|
|
JX.DOM.hide(item);
|
|
}
|
|
|
|
// Add a class so we can animate zany effects.
|
|
JX.DOM.alterClass(item, 'phui-submenu-animate', data.open);
|
|
}
|
|
|
|
JX.DOM.alterClass(node, 'phui-submenu-open', data.open);
|
|
|
|
// Toggle the caret from ">" to "V" when opening the menu, and back again
|
|
// when closing it.
|
|
var caret = JX.$(data.caretID);
|
|
JX.DOM.alterClass(caret, 'caret', data.open);
|
|
JX.DOM.alterClass(caret, 'caret-right', !data.open);
|
|
});
|
|
|
|
});
|