2014-05-05 19:57:23 +02:00
|
|
|
/**
|
2015-05-19 21:14:44 +02:00
|
|
|
* @provides javelin-behavior-phui-dropdown-menu
|
2014-05-05 19:57:23 +02:00
|
|
|
* @requires javelin-behavior
|
|
|
|
* javelin-stratcom
|
|
|
|
* javelin-dom
|
|
|
|
* phuix-dropdown-menu
|
|
|
|
*/
|
|
|
|
|
2015-05-19 21:14:44 +02:00
|
|
|
JX.behavior('phui-dropdown-menu', function() {
|
2014-05-05 19:57:23 +02:00
|
|
|
|
2015-05-19 21:14:44 +02:00
|
|
|
JX.Stratcom.listen('click', 'phui-dropdown-menu', function(e) {
|
|
|
|
var data = e.getNodeData('phui-dropdown-menu');
|
2014-05-05 19:57:23 +02:00
|
|
|
if (data.menu) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
e.kill();
|
|
|
|
|
2016-06-21 02:49:38 +02:00
|
|
|
var list;
|
|
|
|
var placeholder;
|
|
|
|
if (data.items) {
|
|
|
|
list = JX.$H(data.items).getFragment().firstChild;
|
|
|
|
} else {
|
|
|
|
list = JX.$(data.menuID);
|
|
|
|
placeholder = JX.$N('span');
|
|
|
|
}
|
2014-05-05 19:57:23 +02:00
|
|
|
|
2015-05-19 21:14:44 +02:00
|
|
|
var icon = e.getNode('phui-dropdown-menu');
|
2014-05-05 19:57:23 +02:00
|
|
|
data.menu = new JX.PHUIXDropdownMenu(icon);
|
2016-06-21 02:49:38 +02:00
|
|
|
|
|
|
|
data.menu.listen('open', function() {
|
|
|
|
if (placeholder) {
|
|
|
|
JX.DOM.replace(list, placeholder);
|
|
|
|
}
|
|
|
|
data.menu.setContent(list);
|
|
|
|
});
|
|
|
|
|
|
|
|
data.menu.listen('close', function() {
|
|
|
|
if (placeholder) {
|
|
|
|
JX.DOM.replace(placeholder, list);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-05-05 19:57:23 +02:00
|
|
|
data.menu.open();
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|