1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 15:22:41 +01:00
phorge-phorge/webroot/rsrc/js/phui/behavior-phui-object-box-tabs.js
epriestley 2228029201 Wire up object box tabs
Summary: Make tabs do stuff when you click 'em.

Test Plan:
  - Clicked object box tabs in UIExample.
  - Viewed some existing non-tab UIs (Differential, Maniphest).
  - Viewed some existing non-tab, multiple-list UIs (Diffusion).
  - Grepped for methods I changed.

Reviewers: chad, btrahan

Reviewed By: chad

CC: aran

Differential Revision: https://secure.phabricator.com/D7361
2013-10-19 12:07:50 -07:00

36 lines
900 B
JavaScript

/**
* @provides javelin-behavior-phui-object-box-tabs
* @requires javelin-behavior
* javelin-stratcom
* javelin-dom
*/
JX.behavior('phui-object-box-tabs', function() {
JX.Stratcom.listen(
'click',
'phui-object-box-tab',
function (e) {
var key = e.getNodeData('phui-object-box-tab').tabKey;
var map = e.getNodeData('phui-object-box').tabMap;
var tab = e.getNode('phui-object-box-tab');
var box = e.getNode('phui-object-box');
var tabs = JX.DOM.scry(box, 'li', 'phui-object-box-tab');
for (var ii = 0; ii < tabs.length; ii++) {
JX.DOM.alterClass(
tabs[ii],
'phui-list-item-selected',
(tabs[ii] == tab));
}
for (var k in map) {
if (k == key) {
JX.DOM.show(JX.$(map[k]));
} else {
JX.DOM.hide(JX.$(map[k]));
}
}
});
});