1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 06:20:56 +01:00
phorge-phorge/webroot/rsrc/js/phui/behavior-phui-submenu.js
epriestley 56d3197fe0 Fold task-relationship actions into an accordion dropdown
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
2016-06-20 19:14:27 -07:00

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);
});
});