1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-01 19:22:42 +01:00

Add loading state to notification menu.

Summary: Notification menu shows a loading message before the menu is populated with the actual response.

Test Plan: Checked by having the function sleep between getting the response and populating the menu.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4696
This commit is contained in:
Bryan Cuccioli 2013-01-28 17:34:59 -08:00 committed by epriestley
parent 13eb77fe6c
commit 15e284caa9
3 changed files with 28 additions and 2 deletions

View file

@ -390,6 +390,7 @@ final class PhabricatorMainMenuView extends AphrontView {
'bubbleID' => $bubble_id, 'bubbleID' => $bubble_id,
'countID' => $count_id, 'countID' => $count_id,
'dropdownID' => $dropdown_id, 'dropdownID' => $dropdown_id,
'loadingText' => pht('Loading...'),
)); ));
$notification_dropdown = javelin_render_tag( $notification_dropdown = javelin_render_tag(

View file

@ -9,6 +9,12 @@
overflow-y: auto; overflow-y: auto;
} }
.phabricator-notification-menu-loading {
text-align: center;
padding: 10px 0;
color: #888888;
}
.device-desktop .phabricator-notification-menu { .device-desktop .phabricator-notification-menu {
position: fixed; position: fixed;
width: 360px; width: 360px;

View file

@ -14,8 +14,17 @@ JX.behavior('aphlict-dropdown', function(config) {
var bubble = JX.$(config.bubbleID); var bubble = JX.$(config.bubbleID);
var visible = false; var visible = false;
var request = null; var request = null;
var dirty = true;
function refresh() { function refresh() {
if (dirty) {
JX.DOM.setContent(dropdown, config.loadingText);
JX.DOM.alterClass(
dropdown,
'phabricator-notification-menu-loading',
true);
}
if (request) { //already fetching if (request) { //already fetching
return; return;
} }
@ -30,6 +39,11 @@ JX.behavior('aphlict-dropdown', function(config) {
} else { } else {
JX.DOM.alterClass(bubble, 'alert-unread', true); JX.DOM.alterClass(bubble, 'alert-unread', true);
} }
dirty = false;
JX.DOM.alterClass(
dropdown,
'phabricator-notification-menu-loading',
false);
JX.DOM.setContent(dropdown, JX.$H(response.content)); JX.DOM.setContent(dropdown, JX.$H(response.content));
request = null; request = null;
}); });
@ -74,7 +88,9 @@ JX.behavior('aphlict-dropdown', function(config) {
if (visible) { if (visible) {
JX.DOM.hide(dropdown); JX.DOM.hide(dropdown);
} else { } else {
if (dirty) {
refresh(); refresh();
}
var p = JX.$V(bubble); var p = JX.$V(bubble);
p.y = null; p.y = null;
@ -88,5 +104,8 @@ JX.behavior('aphlict-dropdown', function(config) {
} }
) )
JX.Stratcom.listen('notification-panel-update', null, refresh); JX.Stratcom.listen('notification-panel-update', null, function() {
dirty = true;
refresh();
});
}); });