1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00
phorge-phorge/webroot/rsrc/js/application/conpherence/behavior-widget-pane.js
Bob Trahan 42c1e39ae6 Conpherence - mobilized
Summary:
makes conpherence switch to a liquid layout once we go from desktop -> less than that. When we make the switch conpherence updates to show a few more "Widgets" -- the list of conpherences and the current conversation -- and the switcher starts working. As you transition from device to device you are automagically forced to have the "conversation" widget toggled on initial change to smaller than desktop and then file widget once you get back to desktop.

Generally looks good when I make my browser small. Does not look as good on iOS simulator - in particular there seems to be a weird visual artifact on the "add people" widget that is present in all tokenizers, and the pontificate UI on mobile could use some work. ref T2399.

Test Plan: played in Safari, FF, Chrome and iOS Simulator. The first 3 were all pretty spiffy, and otherwise iOS add people widget was a bit ugly.

Reviewers: epriestley, chad

Reviewed By: epriestley

CC: aran, Korvin, AnhNhan

Maniphest Tasks: T2399

Differential Revision: https://secure.phabricator.com/D5674
2013-04-15 16:27:41 -07:00

182 lines
5.3 KiB
JavaScript

/**
* @requires javelin-behavior
* javelin-dom
* javelin-stratcom
* javelin-workflow
* javelin-util
* phabricator-notification
* javelin-behavior-device
* @provides javelin-behavior-conpherence-widget-pane
*/
JX.behavior('conpherence-widget-pane', function(config) {
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) {
JX.$(widget).style.display = 'block';
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';
} else {
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,
{ use_base_uri : true }
);
}
} 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;
}
}
}
}
};
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());
}
);
/* 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(
['touchstart', 'mousedown'],
'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
);
});