2013-01-25 02:23:05 +01:00
|
|
|
/**
|
|
|
|
* @requires javelin-behavior
|
|
|
|
* javelin-dom
|
|
|
|
* javelin-stratcom
|
2013-03-26 21:30:35 +01:00
|
|
|
* javelin-workflow
|
|
|
|
* javelin-util
|
|
|
|
* phabricator-notification
|
2013-04-16 01:27:41 +02:00
|
|
|
* javelin-behavior-device
|
2013-03-26 21:30:35 +01:00
|
|
|
* @provides javelin-behavior-conpherence-widget-pane
|
2013-01-25 02:23:05 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
JX.behavior('conpherence-widget-pane', function(config) {
|
|
|
|
|
2013-04-16 01:27:41 +02:00
|
|
|
var toggle_widget = function (data) {
|
|
|
|
var device = JX.Device.getDevice();
|
|
|
|
var is_desktop = device == 'desktop';
|
|
|
|
if (config.widgetRegistery[data.widget] == config.devicesOnly &&
|
|
|
|
is_desktop) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var root = JX.DOM.find(document, 'div', 'conpherence-layout');
|
|
|
|
var widgetPane = JX.DOM.find(root, 'div', 'conpherence-widget-pane');
|
|
|
|
for (var widget in config.widgetRegistery) {
|
|
|
|
// device-only widgets are *always shown* on the desktop
|
|
|
|
if (config.widgetRegistery[widget] == config.devicesOnly) {
|
|
|
|
if (is_desktop) {
|
2013-01-25 02:23:05 +01:00
|
|
|
JX.$(widget).style.display = 'block';
|
2013-04-16 01:27:41 +02:00
|
|
|
if (config.widgetExtraNodes[widget]) {
|
|
|
|
for (var i in config.widgetExtraNodes[widget]) {
|
|
|
|
var tag_data = config.widgetExtraNodes[widget][i];
|
|
|
|
var node = JX.DOM.find(root, tag_data.tagname, tag_data.sigil);
|
|
|
|
node.style.display = tag_data.desktopstyle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var cur_toggle = JX.$(widget + '-toggle');
|
|
|
|
var toggle_class = config.widgetToggleMap[widget];
|
|
|
|
if (widget == data.widget) {
|
|
|
|
JX.DOM.alterClass(cur_toggle, toggle_class, true);
|
|
|
|
JX.$(widget).style.display = 'block';
|
|
|
|
if (config.widgetRegistery[widget] == config.devicesOnly) {
|
|
|
|
widgetPane.style.height = '42px';
|
2013-01-25 02:23:05 +01:00
|
|
|
} else {
|
2013-04-16 01:27:41 +02:00
|
|
|
widgetPane.style.height = '100%';
|
|
|
|
}
|
|
|
|
if (config.widgetExtraNodes[widget]) {
|
|
|
|
for (var i in config.widgetExtraNodes[widget]) {
|
|
|
|
var tag_data = config.widgetExtraNodes[widget][i];
|
|
|
|
var node = JX.DOM.find(root, tag_data.tagname, tag_data.sigil);
|
|
|
|
node.style.display = tag_data.showstyle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// some one off code for conpherence messages
|
|
|
|
if (widget == 'conpherence-message-pane') {
|
|
|
|
JX.Stratcom.invoke('conpherence-redraw-thread', null, {});
|
|
|
|
JX.Stratcom.invoke('conpherence-update-page-data', null, {});
|
|
|
|
}
|
|
|
|
// some one off code for conpherence list
|
|
|
|
if (widget == 'conpherence-menu-pane') {
|
|
|
|
JX.Stratcom.invoke(
|
|
|
|
'conpherence-update-page-data',
|
|
|
|
null,
|
2013-04-23 01:18:18 +02:00
|
|
|
{ use_base_uri : true, title: 'Conpherence' }
|
2013-02-05 04:01:46 +01:00
|
|
|
);
|
2013-01-25 02:23:05 +01:00
|
|
|
}
|
2013-04-16 01:27:41 +02:00
|
|
|
} else {
|
|
|
|
JX.DOM.alterClass(
|
|
|
|
cur_toggle,
|
|
|
|
toggle_class,
|
|
|
|
false
|
|
|
|
);
|
|
|
|
JX.$(widget).style.display = 'none';
|
|
|
|
if (config.widgetExtraNodes[widget]) {
|
|
|
|
for (var i in config.widgetExtraNodes[widget]) {
|
|
|
|
var tag_data = config.widgetExtraNodes[widget][i];
|
|
|
|
var node = JX.DOM.find(root, tag_data.tagname, tag_data.sigil);
|
|
|
|
node.style.display = tag_data.hidestyle;
|
|
|
|
}
|
|
|
|
}
|
2013-01-25 02:23:05 +01:00
|
|
|
}
|
|
|
|
}
|
2013-04-16 01:27:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
JX.Stratcom.listen(
|
|
|
|
['touchstart', 'mousedown'],
|
|
|
|
'conpherence-change-widget',
|
|
|
|
function(e) {
|
|
|
|
e.kill();
|
|
|
|
var data = e.getNodeData('conpherence-change-widget');
|
|
|
|
toggle_widget(data);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
JX.Stratcom.listen(
|
|
|
|
'conpherence-toggle-widget',
|
|
|
|
null,
|
|
|
|
function (e) {
|
|
|
|
toggle_widget(e.getData());
|
|
|
|
}
|
2013-01-25 02:23:05 +01:00
|
|
|
);
|
|
|
|
|
2013-04-16 01:27:41 +02:00
|
|
|
|
2013-04-02 18:32:40 +02:00
|
|
|
/* people widget */
|
2013-04-08 20:13:35 +02:00
|
|
|
JX.Stratcom.listen(
|
|
|
|
['submit', 'didSyntheticSubmit'],
|
2013-04-02 18:32:40 +02:00
|
|
|
'add-person',
|
|
|
|
function (e) {
|
|
|
|
e.kill();
|
2013-04-08 20:13:35 +02:00
|
|
|
var root = e.getNode('conpherence-layout');
|
|
|
|
var form = e.getNode('tag:form');
|
2013-04-02 18:32:40 +02:00
|
|
|
var data = e.getNodeData('add-person');
|
2013-04-08 20:13:35 +02:00
|
|
|
var peopleRoot = e.getNode('widgets-people');
|
2013-04-10 20:37:04 +02:00
|
|
|
var messages = null;
|
|
|
|
try {
|
|
|
|
messages = JX.DOM.find(root, 'div', 'conpherence-messages');
|
|
|
|
} catch (ex) {
|
|
|
|
}
|
2013-04-08 20:13:35 +02:00
|
|
|
var latestTransactionData = JX.Stratcom.getData(
|
|
|
|
JX.DOM.find(
|
|
|
|
root,
|
|
|
|
'input',
|
|
|
|
'latest-transaction-id'
|
|
|
|
));
|
|
|
|
data.latest_transaction_id = latestTransactionData.id;
|
2013-04-02 18:32:40 +02:00
|
|
|
JX.Workflow.newFromForm(form, data)
|
2013-04-08 20:13:35 +02:00
|
|
|
.setHandler(JX.bind(this, function (r) {
|
2013-04-10 20:37:04 +02:00
|
|
|
if (messages) {
|
|
|
|
JX.DOM.appendContent(messages, JX.$H(r.transactions));
|
|
|
|
messages.scrollTop = messages.scrollHeight;
|
2013-04-08 20:13:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// update the people widget
|
|
|
|
JX.DOM.setContent(
|
|
|
|
peopleRoot,
|
|
|
|
JX.$H(r.people_widget)
|
|
|
|
);
|
|
|
|
}))
|
2013-04-02 18:32:40 +02:00
|
|
|
.start();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2013-04-08 20:13:35 +02:00
|
|
|
JX.Stratcom.listen(
|
2013-04-16 01:27:41 +02:00
|
|
|
['touchstart', 'mousedown'],
|
2013-04-02 18:32:40 +02:00
|
|
|
'remove-person',
|
|
|
|
function (e) {
|
2013-04-08 20:13:35 +02:00
|
|
|
var peopleRoot = e.getNode('widgets-people');
|
2013-04-02 18:32:40 +02:00
|
|
|
var form = JX.DOM.find(peopleRoot, 'form');
|
|
|
|
var data = e.getNodeData('remove-person');
|
2013-04-08 20:13:35 +02:00
|
|
|
// we end up re-directing to conpherence home
|
2013-04-02 18:32:40 +02:00
|
|
|
JX.Workflow.newFromForm(form, data)
|
|
|
|
.start();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
/* settings widget */
|
2013-03-26 21:30:35 +01:00
|
|
|
var onsubmitSettings = function (e) {
|
|
|
|
e.kill();
|
2013-04-08 20:13:35 +02:00
|
|
|
var form = e.getNode('tag:form');
|
2013-03-26 21:30:35 +01:00
|
|
|
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();
|
|
|
|
};
|
|
|
|
|
2013-04-08 20:13:35 +02:00
|
|
|
JX.Stratcom.listen(
|
|
|
|
['submit', 'didSyntheticSubmit'],
|
2013-03-26 21:30:35 +01:00
|
|
|
'notifications-update',
|
|
|
|
onsubmitSettings
|
|
|
|
);
|
|
|
|
|
2013-01-25 02:23:05 +01:00
|
|
|
});
|