2012-06-11 18:37:06 +02:00
|
|
|
/**
|
|
|
|
* @provides javelin-behavior-aphlict-dropdown
|
|
|
|
* @requires javelin-behavior
|
|
|
|
* javelin-request
|
|
|
|
* javelin-stratcom
|
2012-06-14 15:13:53 +02:00
|
|
|
* javelin-vector
|
|
|
|
* javelin-dom
|
2012-12-08 01:26:43 +01:00
|
|
|
* javelin-uri
|
2014-01-29 05:19:20 +01:00
|
|
|
* javelin-behavior-device
|
2014-09-10 19:17:49 +02:00
|
|
|
* phabricator-title
|
2016-10-20 20:41:57 +02:00
|
|
|
* phabricator-favicon
|
2012-06-11 18:37:06 +02:00
|
|
|
*/
|
|
|
|
|
Allow only one global top menu to be open at a time
Summary: Fixes T3715. Makes "visible" global instead of per-menu, so all the menus share a visible state.
Test Plan: For menus A and B, clicked "A, A", "A, B, A", "A, B, B", "A, B, B, A", etc. Couldn't figure out a way to break it.
Reviewers: btrahan, chad
Reviewed By: chad
CC: aran
Maniphest Tasks: T3715
Differential Revision: https://secure.phabricator.com/D6745
2013-08-13 23:57:52 +02:00
|
|
|
JX.behavior('aphlict-dropdown', function(config, statics) {
|
|
|
|
// Track the current globally visible menu.
|
|
|
|
statics.visible = statics.visible || null;
|
|
|
|
|
2012-07-31 01:09:14 +02:00
|
|
|
var dropdown = JX.$(config.dropdownID);
|
2012-11-27 23:03:25 +01:00
|
|
|
var bubble = JX.$(config.bubbleID);
|
2014-12-11 01:11:32 +01:00
|
|
|
var icon = JX.DOM.scry(bubble, 'span', 'menu-icon')[0];
|
2016-10-20 20:41:57 +02:00
|
|
|
var favicon = config.favicon;
|
|
|
|
var message_favicon = config.message_favicon;
|
2014-01-29 05:19:20 +01:00
|
|
|
|
|
|
|
var count;
|
|
|
|
if (config.countID) {
|
|
|
|
count = JX.$(config.countID);
|
|
|
|
}
|
|
|
|
|
2012-06-12 02:49:32 +02:00
|
|
|
var request = null;
|
2014-01-29 05:19:20 +01:00
|
|
|
var dirty = config.local ? false : true;
|
2012-06-11 18:37:06 +02:00
|
|
|
|
2016-10-20 20:41:57 +02:00
|
|
|
function _updateFavicon(new_count) {
|
|
|
|
if ((config.countType == 'messages') && (new_count)) {
|
|
|
|
JX.Favicon.setFavicon(message_favicon);
|
|
|
|
} else if (config.countType == 'messages') {
|
|
|
|
JX.Favicon.setFavicon(favicon);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-28 04:00:35 +02:00
|
|
|
if (config.countType) {
|
|
|
|
JX.Title.setCount(config.countType, config.countNumber);
|
2016-10-20 20:41:57 +02:00
|
|
|
_updateFavicon(config.countNumber);
|
2016-08-28 04:00:35 +02:00
|
|
|
}
|
2014-09-10 19:17:49 +02:00
|
|
|
|
2015-04-22 00:46:36 +02:00
|
|
|
function _updateCount(number) {
|
2016-08-28 04:00:35 +02:00
|
|
|
if (config.countType) {
|
|
|
|
JX.Title.setCount(config.countType, number);
|
2016-10-20 20:41:57 +02:00
|
|
|
_updateFavicon(number);
|
2016-08-28 04:00:35 +02:00
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
2015-04-22 00:46:36 +02:00
|
|
|
|
|
|
|
JX.DOM.setContent(count, number);
|
|
|
|
if (number === 0) {
|
|
|
|
JX.DOM.alterClass(bubble, config.unreadClass, false);
|
|
|
|
} else {
|
|
|
|
JX.DOM.alterClass(bubble, config.unreadClass, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-12 02:49:32 +02:00
|
|
|
function refresh() {
|
2013-01-29 02:34:59 +01:00
|
|
|
if (dirty) {
|
|
|
|
JX.DOM.setContent(dropdown, config.loadingText);
|
|
|
|
JX.DOM.alterClass(
|
|
|
|
dropdown,
|
|
|
|
'phabricator-notification-menu-loading',
|
|
|
|
true);
|
|
|
|
}
|
|
|
|
|
2015-01-14 22:08:08 +01:00
|
|
|
if (request) {
|
|
|
|
// Already fetching.
|
2012-06-12 02:49:32 +02:00
|
|
|
return;
|
|
|
|
}
|
Allow only one global top menu to be open at a time
Summary: Fixes T3715. Makes "visible" global instead of per-menu, so all the menus share a visible state.
Test Plan: For menus A and B, clicked "A, A", "A, B, A", "A, B, B", "A, B, B, A", etc. Couldn't figure out a way to break it.
Reviewers: btrahan, chad
Reviewed By: chad
CC: aran
Maniphest Tasks: T3715
Differential Revision: https://secure.phabricator.com/D6745
2013-08-13 23:57:52 +02:00
|
|
|
|
2013-08-08 22:43:33 +02:00
|
|
|
request = new JX.Request(config.uri, function(response) {
|
2015-04-22 00:46:36 +02:00
|
|
|
var number = response.number;
|
|
|
|
_updateCount(number);
|
2013-01-29 02:34:59 +01:00
|
|
|
dirty = false;
|
|
|
|
JX.DOM.alterClass(
|
|
|
|
dropdown,
|
|
|
|
'phabricator-notification-menu-loading',
|
|
|
|
false);
|
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
|
|
|
|
2015-04-22 00:46:36 +02:00
|
|
|
JX.Stratcom.listen(
|
|
|
|
'quicksand-redraw',
|
|
|
|
null,
|
|
|
|
function (e) {
|
2015-04-22 21:05:27 +02:00
|
|
|
var data = e.getData();
|
2015-04-22 00:46:36 +02:00
|
|
|
if (!data.fromServer) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var new_data = data.newResponse.aphlictDropdownData;
|
2015-05-08 01:04:56 +02:00
|
|
|
update_counts(new_data);
|
|
|
|
});
|
|
|
|
|
|
|
|
JX.Stratcom.listen(
|
|
|
|
'conpherence-redraw-aphlict',
|
|
|
|
null,
|
|
|
|
function (e) {
|
|
|
|
update_counts(e.getData());
|
|
|
|
});
|
|
|
|
|
|
|
|
function update_counts(new_data) {
|
|
|
|
var updated = false;
|
|
|
|
for (var ii = 0; ii < new_data.length; ii++) {
|
|
|
|
if (new_data[ii].countType != config.countType) {
|
|
|
|
continue;
|
2015-04-22 00:46:36 +02:00
|
|
|
}
|
2015-05-08 01:04:56 +02:00
|
|
|
if (!new_data[ii].isInstalled) {
|
|
|
|
continue;
|
2015-04-22 00:46:36 +02:00
|
|
|
}
|
2015-05-08 01:04:56 +02:00
|
|
|
updated = true;
|
|
|
|
_updateCount(parseInt(new_data[ii].count));
|
|
|
|
}
|
|
|
|
if (updated) {
|
|
|
|
dirty = true;
|
|
|
|
}
|
|
|
|
}
|
2015-04-22 00:46:36 +02:00
|
|
|
|
2014-12-11 01:26:40 +01:00
|
|
|
function set_visible(menu, icon) {
|
|
|
|
if (menu) {
|
|
|
|
statics.visible = {menu: menu, icon: icon};
|
|
|
|
if (icon) {
|
2015-06-04 05:21:12 +02:00
|
|
|
JX.DOM.alterClass(icon, 'menu-icon-selected', true);
|
2014-12-11 01:26:40 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (statics.visible) {
|
|
|
|
JX.DOM.hide(statics.visible.menu);
|
|
|
|
if (statics.visible.icon) {
|
2015-06-04 05:21:12 +02:00
|
|
|
JX.DOM.alterClass(statics.visible.icon, 'menu-icon-selected', false);
|
2014-12-11 01:26:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
statics.visible = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-11 18:37:06 +02:00
|
|
|
JX.Stratcom.listen(
|
|
|
|
'click',
|
|
|
|
null,
|
|
|
|
function(e) {
|
2012-12-08 01:26:43 +01:00
|
|
|
if (!e.getNode('phabricator-notification-menu')) {
|
|
|
|
// Click outside the dropdown; hide it.
|
2014-12-11 01:26:40 +01:00
|
|
|
set_visible(null);
|
2012-06-11 18:37:06 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-12-08 01:26:43 +01:00
|
|
|
if (e.getNode('tag:a')) {
|
2015-04-24 23:25:44 +02:00
|
|
|
// User clicked a link. Hide the menu, then follow the link.
|
|
|
|
set_visible(null);
|
2012-12-08 01:26:43 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-06-24 01:26:16 +02:00
|
|
|
if (!e.getNode('notification')) {
|
|
|
|
// User clicked somewhere in the dead area of the menu, like the header
|
|
|
|
// or footer.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-12-08 01:26:43 +01:00
|
|
|
// If the user clicked a notification (but missed a link) and it has a
|
|
|
|
// primary URI, go there.
|
|
|
|
var href = e.getNodeData('notification').href;
|
|
|
|
if (href) {
|
|
|
|
JX.$U(href).go();
|
|
|
|
e.kill();
|
2015-04-24 23:25:44 +02:00
|
|
|
set_visible(null);
|
2012-12-08 01:26:43 +01:00
|
|
|
}
|
2012-06-11 18:37:06 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
JX.DOM.listen(
|
2012-11-27 23:03:25 +01:00
|
|
|
bubble,
|
2012-06-11 18:37:06 +02:00
|
|
|
'click',
|
|
|
|
null,
|
|
|
|
function(e) {
|
2012-11-27 23:03:25 +01:00
|
|
|
if (!e.isNormalClick()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-01-29 05:19:20 +01:00
|
|
|
if (config.desktop && JX.Device.getDevice() != 'desktop') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Allow only one global top menu to be open at a time
Summary: Fixes T3715. Makes "visible" global instead of per-menu, so all the menus share a visible state.
Test Plan: For menus A and B, clicked "A, A", "A, B, A", "A, B, B", "A, B, B, A", etc. Couldn't figure out a way to break it.
Reviewers: btrahan, chad
Reviewed By: chad
CC: aran
Maniphest Tasks: T3715
Differential Revision: https://secure.phabricator.com/D6745
2013-08-13 23:57:52 +02:00
|
|
|
e.kill();
|
2012-11-27 23:03:25 +01:00
|
|
|
|
Allow only one global top menu to be open at a time
Summary: Fixes T3715. Makes "visible" global instead of per-menu, so all the menus share a visible state.
Test Plan: For menus A and B, clicked "A, A", "A, B, A", "A, B, B", "A, B, B, A", etc. Couldn't figure out a way to break it.
Reviewers: btrahan, chad
Reviewed By: chad
CC: aran
Maniphest Tasks: T3715
Differential Revision: https://secure.phabricator.com/D6745
2013-08-13 23:57:52 +02:00
|
|
|
// If a menu is currently open, close it.
|
|
|
|
if (statics.visible) {
|
|
|
|
var previously_visible = statics.visible;
|
2014-12-11 01:26:40 +01:00
|
|
|
set_visible(null);
|
2012-06-14 15:13:53 +02:00
|
|
|
|
Allow only one global top menu to be open at a time
Summary: Fixes T3715. Makes "visible" global instead of per-menu, so all the menus share a visible state.
Test Plan: For menus A and B, clicked "A, A", "A, B, A", "A, B, B", "A, B, B, A", etc. Couldn't figure out a way to break it.
Reviewers: btrahan, chad
Reviewed By: chad
CC: aran
Maniphest Tasks: T3715
Differential Revision: https://secure.phabricator.com/D6745
2013-08-13 23:57:52 +02:00
|
|
|
// If the menu we just closed was the menu attached to the clicked
|
|
|
|
// icon, we're all done -- clicking the icon for an open menu just
|
|
|
|
// closes it. Otherwise, we closed some other menu and still need to
|
|
|
|
// open the one the user just clicked.
|
2014-12-11 01:26:40 +01:00
|
|
|
if (previously_visible.menu === dropdown) {
|
Allow only one global top menu to be open at a time
Summary: Fixes T3715. Makes "visible" global instead of per-menu, so all the menus share a visible state.
Test Plan: For menus A and B, clicked "A, A", "A, B, A", "A, B, B", "A, B, B, A", etc. Couldn't figure out a way to break it.
Reviewers: btrahan, chad
Reviewed By: chad
CC: aran
Maniphest Tasks: T3715
Differential Revision: https://secure.phabricator.com/D6745
2013-08-13 23:57:52 +02:00
|
|
|
return;
|
|
|
|
}
|
2012-06-11 18:37:06 +02:00
|
|
|
}
|
Allow only one global top menu to be open at a time
Summary: Fixes T3715. Makes "visible" global instead of per-menu, so all the menus share a visible state.
Test Plan: For menus A and B, clicked "A, A", "A, B, A", "A, B, B", "A, B, B, A", etc. Couldn't figure out a way to break it.
Reviewers: btrahan, chad
Reviewed By: chad
CC: aran
Maniphest Tasks: T3715
Differential Revision: https://secure.phabricator.com/D6745
2013-08-13 23:57:52 +02:00
|
|
|
|
|
|
|
if (dirty) {
|
|
|
|
refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
var p = JX.$V(bubble);
|
2014-01-29 05:19:20 +01:00
|
|
|
JX.DOM.show(dropdown);
|
|
|
|
|
Allow only one global top menu to be open at a time
Summary: Fixes T3715. Makes "visible" global instead of per-menu, so all the menus share a visible state.
Test Plan: For menus A and B, clicked "A, A", "A, B, A", "A, B, B", "A, B, B, A", etc. Couldn't figure out a way to break it.
Reviewers: btrahan, chad
Reviewed By: chad
CC: aran
Maniphest Tasks: T3715
Differential Revision: https://secure.phabricator.com/D6745
2013-08-13 23:57:52 +02:00
|
|
|
p.y = null;
|
Conpherence - make the durable column kind of work and stuff
Summary:
Ref T7014. This hooks up the durable column such that when you open it up it loads your most recent Conpherence. You can then switch amongst the various widgets and stuff and everything works nicely.
Except...
- scroll bar does not work
- also doesn't work at HEAD when I add a ton of text to the UI with no changes? (wrapped $copy in array_fill(0, 1000, $copy))
- "widget selector" does not collapse when you select something else
- this part wasn't really specified so I used the aphlict dropdown stuff. didn't want to keep working on that if this was the wrong UI choice
- can not edit title
- do we still want that to be done by clicking on the title, which pops a dialogue?
- can not add participants or calendar events
- what should this UI be? maybe just a button on the top for "participants" and a button on the bottom for calendar? both on top?
- this is not pixel perfect to the mock or two I've seen around. Aside from generally being bad at that, I definitely didn't get the name + timestamps formatting correctly, because the standard DOM of that has timestamp FIRST which appears second due to a "float right". Seemed like a lot of special-casing for what might not even be that important in the UI so I punted. (And again, there's likely many unknown ways in which this isn't pixel perfect)
There's also code quality issues
- `ConpherenceWidgetConfigConstants` is hopefully temporary or at least gets more sleek as we keep progressing here
- copied some CSS from main Conpherence app
- DOM structure is pretty different
- there's some minor CSS tweaks too given the different width (not to mention the DOM structure being different)
- copied some JS from behavior-pontificate.js to sync threads relative to aphlict updates
- JS in general is like a better version of existing JS; these should collapse I'd hope?
- maybe the aphlict-behavior-dropdown change was badsauce?
...but all that said, this definitely feels really nice and I feel like adding stuff is going to be really easy compared to how normal Conpherence is.
Also includes a bonus bug fix - we now correctly update participation. The user would encounter this issue if they were in a conpherence that got some updates and then they went to a different page; they would have unread status for the messages that were ajax'd in. This patch fixes that by making sure we mark participation up to date with the proper transaction in all cases.
Test Plan: hit "\" to invoke the column and saw nice loading UI and my latest conpherence load. sent messages and verified they received A-OK by looking in DOM console. toggled various widges and verified they rendered correctly. opened up a second browser with a second user on the thread, sent a message, and it was received in a nice asynchronous fashion
Reviewers: chad, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Maniphest Tasks: T7014
Differential Revision: https://secure.phabricator.com/D11968
2015-03-05 19:33:39 +01:00
|
|
|
if (config.containerDivID) {
|
|
|
|
var pc = JX.$V(JX.$(config.containerDivID));
|
|
|
|
p.x -= (JX.Vector.getDim(dropdown).x - JX.Vector.getDim(bubble).x +
|
|
|
|
pc.x);
|
|
|
|
} else if (config.right) {
|
2014-01-29 05:19:20 +01:00
|
|
|
p.x -= (JX.Vector.getDim(dropdown).x - JX.Vector.getDim(bubble).x);
|
|
|
|
} else {
|
|
|
|
p.x -= 6;
|
|
|
|
}
|
Allow only one global top menu to be open at a time
Summary: Fixes T3715. Makes "visible" global instead of per-menu, so all the menus share a visible state.
Test Plan: For menus A and B, clicked "A, A", "A, B, A", "A, B, B", "A, B, B, A", etc. Couldn't figure out a way to break it.
Reviewers: btrahan, chad
Reviewed By: chad
CC: aran
Maniphest Tasks: T3715
Differential Revision: https://secure.phabricator.com/D6745
2013-08-13 23:57:52 +02:00
|
|
|
p.setPos(dropdown);
|
|
|
|
|
2014-12-11 01:26:40 +01:00
|
|
|
set_visible(dropdown, icon);
|
2012-06-11 18:37:06 +02:00
|
|
|
}
|
2013-05-19 02:04:22 +02:00
|
|
|
);
|
2012-06-11 18:37:06 +02:00
|
|
|
|
2013-01-29 02:34:59 +01:00
|
|
|
JX.Stratcom.listen('notification-panel-update', null, function() {
|
2014-01-29 05:19:20 +01:00
|
|
|
if (config.local) {
|
|
|
|
return;
|
|
|
|
}
|
2013-01-29 02:34:59 +01:00
|
|
|
dirty = true;
|
|
|
|
refresh();
|
|
|
|
});
|
2015-03-06 00:32:42 +01:00
|
|
|
|
|
|
|
JX.Stratcom.listen('notification-panel-close', null, function() {
|
|
|
|
set_visible(null);
|
|
|
|
});
|
2012-06-11 18:37:06 +02:00
|
|
|
});
|