2012-06-11 18:37:06 +02:00
|
|
|
/**
|
|
|
|
* @provides javelin-behavior-aphlict-dropdown
|
|
|
|
* @requires javelin-behavior
|
|
|
|
* javelin-aphlict
|
|
|
|
* javelin-util
|
|
|
|
* javelin-request
|
|
|
|
* javelin-stratcom
|
|
|
|
*/
|
|
|
|
|
|
|
|
JX.behavior('aphlict-dropdown', function(config) {
|
|
|
|
var dropdown = JX.$('phabricator-notification-dropdown');
|
|
|
|
var indicator = JX.$('phabricator-notification-indicator');
|
|
|
|
var visible = false;
|
2012-06-12 02:49:32 +02:00
|
|
|
var request = null;
|
2012-06-11 18:37:06 +02:00
|
|
|
|
2012-06-12 02:49:32 +02:00
|
|
|
function refresh() {
|
|
|
|
if (request) { //already fetching
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
request = new JX.Request('/notification/panel/', function(response) {
|
|
|
|
indicator.textContent = '' + response.number;
|
|
|
|
if (response.number == 0) {
|
|
|
|
indicator.style.fontWeight = "";
|
|
|
|
} else {
|
|
|
|
indicator.style.fontWeight = "bold";
|
|
|
|
}
|
2012-06-11 18:37:06 +02:00
|
|
|
JX.DOM.setContent(dropdown, JX.$H(response.content));
|
2012-06-12 02:49:32 +02:00
|
|
|
request = null;
|
|
|
|
});
|
|
|
|
request.send();
|
|
|
|
}
|
2012-06-11 18:37:06 +02:00
|
|
|
|
2012-06-12 02:49:32 +02:00
|
|
|
//populate panel
|
|
|
|
refresh();
|
2012-06-11 18:37:06 +02:00
|
|
|
|
|
|
|
JX.Stratcom.listen(
|
|
|
|
'click',
|
|
|
|
null,
|
|
|
|
function(e) {
|
|
|
|
if(e.getNode('aphlict-dropdown') ||
|
|
|
|
e.getNode('aphlict-indicator')) {
|
|
|
|
// Click is inside the dropdown, or on indicator
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
JX.DOM.hide(dropdown);
|
|
|
|
visible = false;
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
JX.DOM.listen(
|
|
|
|
indicator,
|
|
|
|
'click',
|
|
|
|
null,
|
|
|
|
function(e) {
|
|
|
|
if(visible) {
|
|
|
|
JX.DOM.hide(dropdown);
|
|
|
|
} else {
|
|
|
|
JX.DOM.show(dropdown);
|
|
|
|
}
|
|
|
|
visible = !visible;
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2012-06-12 02:49:32 +02:00
|
|
|
JX.Stratcom.listen('notification-panel-update', null, refresh);
|
2012-06-11 18:37:06 +02:00
|
|
|
});
|