1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-21 21:10:56 +01:00
phorge-phorge/webroot/rsrc/js/application/conpherence/behavior-widget-pane.js
Bob Trahan 8ede9dc061 Conpherence - continue the load less quest
Summary: basically makes it so we only really load what we need from the server for any particular update action. the javascript thus then has some things deleted from it. made a spot or two ready for when the pertinent UI won't be there as well. also added a feature in javascript -- updating the document title to the current conpherence title.  Ref T2867 T2399

Test Plan: played with conpherence for quite a bit.

Reviewers: epriestley, chad

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2867

Differential Revision: https://secure.phabricator.com/D5625
2013-04-10 11:37:04 -07:00

117 lines
3.1 KiB
JavaScript

/**
* @requires javelin-behavior
* javelin-dom
* javelin-stratcom
* javelin-workflow
* javelin-util
* phabricator-notification
* @provides javelin-behavior-conpherence-widget-pane
*/
JX.behavior('conpherence-widget-pane', function(config) {
JX.Stratcom.listen(
'click',
'conpherence-change-widget',
function(e) {
e.kill();
var data = e.getNodeData('conpherence-change-widget');
// abort if this widget isn't exactly involved in this toggle business
if (!config.widgetRegistery[data.widget]) {
return;
}
for (var widget in config.widgetRegistery) {
if (!config.widgetRegistery[widget]) {
continue;
} else if (widget == data.widget) {
JX.$(widget).style.display = 'block';
JX.DOM.alterClass(e.getTarget(), data.toggleClass, true);
} else {
JX.$(widget).style.display = 'none';
var cur_toggle = JX.$(widget + '-toggle');
JX.DOM.alterClass(
cur_toggle,
JX.Stratcom.getData(cur_toggle).toggleClass,
false
);
}
}
}
);
/* people widget */
JX.Stratcom.listen(
['submit', 'didSyntheticSubmit'],
'add-person',
function (e) {
e.kill();
var root = e.getNode('conpherence-layout');
var form = e.getNode('tag:form');
var data = e.getNodeData('add-person');
var peopleRoot = e.getNode('widgets-people');
var messages = null;
try {
messages = JX.DOM.find(root, 'div', 'conpherence-messages');
} catch (ex) {
}
var latestTransactionData = JX.Stratcom.getData(
JX.DOM.find(
root,
'input',
'latest-transaction-id'
));
data.latest_transaction_id = latestTransactionData.id;
JX.Workflow.newFromForm(form, data)
.setHandler(JX.bind(this, function (r) {
if (messages) {
JX.DOM.appendContent(messages, JX.$H(r.transactions));
messages.scrollTop = messages.scrollHeight;
}
// update the people widget
JX.DOM.setContent(
peopleRoot,
JX.$H(r.people_widget)
);
}))
.start();
}
);
JX.Stratcom.listen(
['click'],
'remove-person',
function (e) {
var peopleRoot = e.getNode('widgets-people');
var form = JX.DOM.find(peopleRoot, 'form');
var data = e.getNodeData('remove-person');
// we end up re-directing to conpherence home
JX.Workflow.newFromForm(form, data)
.start();
}
);
/* settings widget */
var onsubmitSettings = function (e) {
e.kill();
var form = e.getNode('tag:form');
var button = JX.DOM.find(form, 'button');
JX.Workflow.newFromForm(form)
.setHandler(JX.bind(this, function (r) {
new JX.Notification()
.setDuration(6000)
.setContent(r)
.show();
button.disabled = '';
JX.DOM.alterClass(button, 'disabled', false);
}))
.start();
};
JX.Stratcom.listen(
['submit', 'didSyntheticSubmit'],
'notifications-update',
onsubmitSettings
);
});