mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-23 15:22:41 +01:00
34b6c32d2e
Summary: i think the DOM changed in conpherence with the menu upgrades. just noticed that when you select a new conpherence the old one is not de-selected. this fixes it by updating the javascript to ascend one node higher and then use DOM.scry with the right data sigil to get the nodes Test Plan: read some messages, noted only the one I was reading had the entry highlighted in the left. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2399 Differential Revision: https://secure.phabricator.com/D4819
103 lines
2.6 KiB
JavaScript
103 lines
2.6 KiB
JavaScript
/**
|
|
* @provides javelin-behavior-conpherence-menu
|
|
* @requires javelin-behavior
|
|
* javelin-dom
|
|
* javelin-workflow
|
|
* javelin-util
|
|
* javelin-stratcom
|
|
* javelin-uri
|
|
*/
|
|
|
|
JX.behavior('conpherence-menu', function(config) {
|
|
|
|
function onresponse(context, response) {
|
|
var header = JX.$H(response.header);
|
|
var messages = JX.$H(response.messages);
|
|
var form = JX.$H(response.form);
|
|
var widgets = JX.$H(response.widgets);
|
|
var headerRoot = JX.$(config.header);
|
|
var messagesRoot = JX.$(config.messages);
|
|
var formRoot = JX.$(config.form_pane);
|
|
var widgetsRoot = JX.$(config.widgets_pane);
|
|
var menuRoot = JX.$(config.menu_pane);
|
|
JX.DOM.setContent(headerRoot, header);
|
|
JX.DOM.setContent(messagesRoot, messages);
|
|
messagesRoot.scrollTop = messagesRoot.scrollHeight;
|
|
JX.DOM.setContent(formRoot, form);
|
|
JX.DOM.setContent(widgetsRoot, widgets);
|
|
|
|
var conpherences = JX.DOM.scry(
|
|
menuRoot,
|
|
'a',
|
|
'conpherence-menu-click'
|
|
);
|
|
|
|
for (var i = 0; i < conpherences.length; i++) {
|
|
var current = conpherences[i];
|
|
if (current.id == context.id) {
|
|
JX.DOM.alterClass(current, 'conpherence-selected', true);
|
|
JX.DOM.alterClass(current, 'hide-unread-count', true);
|
|
} else {
|
|
JX.DOM.alterClass(current, 'conpherence-selected', false);
|
|
}
|
|
}
|
|
|
|
// TODO - update the browser URI T2086
|
|
|
|
JX.Stratcom.invoke(
|
|
'conpherence-selected-loaded',
|
|
null,
|
|
{}
|
|
);
|
|
}
|
|
|
|
JX.Stratcom.listen(
|
|
'click',
|
|
'conpherence-menu-click',
|
|
function(e) {
|
|
e.kill();
|
|
var selected = e.getNode(['conpherence-menu-click']);
|
|
if (config.fancy_ajax) {
|
|
JX.Stratcom.invoke(
|
|
'conpherence-selected',
|
|
null,
|
|
{ selected : selected }
|
|
);
|
|
} else {
|
|
var data = JX.Stratcom.getData(selected);
|
|
var uri = new JX.URI(config.base_uri + data.id + '/');
|
|
uri.go();
|
|
}
|
|
}
|
|
);
|
|
|
|
JX.Stratcom.listen(
|
|
'conpherence-initial-selected',
|
|
null,
|
|
function(e) {
|
|
var selected = e.getData().selected;
|
|
e.kill();
|
|
JX.Stratcom.invoke(
|
|
'conpherence-selected',
|
|
null,
|
|
{ selected : selected }
|
|
);
|
|
}
|
|
);
|
|
|
|
JX.Stratcom.listen(
|
|
'conpherence-selected',
|
|
null,
|
|
function(e) {
|
|
|
|
var selected = e.getData().selected;
|
|
var data = JX.Stratcom.getData(selected);
|
|
|
|
var uri = config.base_uri + 'view/' + data.id + '/';
|
|
new JX.Workflow(uri, {})
|
|
.setHandler(JX.bind(null, onresponse, selected))
|
|
.start();
|
|
}
|
|
);
|
|
|
|
});
|