1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +01:00

Conpherence - auto focus the textarea on thread select and after sending a message

Summary: Fixes T7135. Also does a bit of a javascript cleanup in that we had an event - "conpherence-selectthread" - which really didn't need to be an event.

Test Plan: selected various conpherences from the list and they loaded correctly, including putting the cursor at the end of the text as appropriate. send many messages rapid fire without ever taking my hands off the keyboard.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7135

Differential Revision: https://secure.phabricator.com/D11890
This commit is contained in:
Bob Trahan 2015-02-25 15:14:27 -08:00
parent 64be155551
commit 2d4d79d171
3 changed files with 49 additions and 56 deletions

View file

@ -353,8 +353,8 @@ return array(
'rsrc/js/application/auth/behavior-persona-login.js' => '9414ff18',
'rsrc/js/application/config/behavior-reorder-fields.js' => '14a827de',
'rsrc/js/application/conpherence/behavior-durable-column.js' => '0c404426',
'rsrc/js/application/conpherence/behavior-menu.js' => 'f0a41b9f',
'rsrc/js/application/conpherence/behavior-pontificate.js' => '2f6efe18',
'rsrc/js/application/conpherence/behavior-menu.js' => 'b255d93b',
'rsrc/js/application/conpherence/behavior-pontificate.js' => '86df5915',
'rsrc/js/application/conpherence/behavior-widget-pane.js' => '40b1ff90',
'rsrc/js/application/countdown/timer.js' => 'e4cc26b3',
'rsrc/js/application/dashboard/behavior-dashboard-async-panel.js' => '469c0d9e',
@ -557,8 +557,8 @@ return array(
'javelin-behavior-boards-dropdown' => '0ec56e1d',
'javelin-behavior-choose-control' => '6153c708',
'javelin-behavior-config-reorder-fields' => '14a827de',
'javelin-behavior-conpherence-menu' => 'f0a41b9f',
'javelin-behavior-conpherence-pontificate' => '2f6efe18',
'javelin-behavior-conpherence-menu' => 'b255d93b',
'javelin-behavior-conpherence-pontificate' => '86df5915',
'javelin-behavior-conpherence-widget-pane' => '40b1ff90',
'javelin-behavior-countdown-timer' => 'e4cc26b3',
'javelin-behavior-dark-console' => '08883e8b',
@ -1013,13 +1013,6 @@ return array(
'javelin-uri',
'javelin-util',
),
'2f6efe18' => array(
'javelin-behavior',
'javelin-dom',
'javelin-util',
'javelin-workflow',
'javelin-stratcom',
),
'316b8fa1' => array(
'javelin-install',
'javelin-typeahead-source',
@ -1464,6 +1457,13 @@ return array(
'85ea0626' => array(
'javelin-install',
),
'86df5915' => array(
'javelin-behavior',
'javelin-dom',
'javelin-util',
'javelin-workflow',
'javelin-stratcom',
),
'87cb6b51' => array(
'javelin-behavior',
'javelin-dom',
@ -1648,6 +1648,17 @@ return array(
'javelin-dom',
'javelin-reactor-dom',
),
'b255d93b' => array(
'javelin-behavior',
'javelin-dom',
'javelin-util',
'javelin-stratcom',
'javelin-workflow',
'javelin-behavior-device',
'javelin-history',
'javelin-vector',
'phabricator-shaped-request',
),
'b2b4fbaf' => array(
'javelin-behavior',
'javelin-dom',
@ -1882,17 +1893,6 @@ return array(
'javelin-install',
'javelin-util',
),
'f0a41b9f' => array(
'javelin-behavior',
'javelin-dom',
'javelin-util',
'javelin-stratcom',
'javelin-workflow',
'javelin-behavior-device',
'javelin-history',
'javelin-vector',
'phabricator-shaped-request',
),
'f2441746' => array(
'javelin-dom',
'javelin-util',

View file

@ -57,14 +57,6 @@ JX.behavior('conpherence-menu', function(config) {
/**
* Selecting threads
*/
JX.Stratcom.listen(
'conpherence-selectthread',
null,
function (e) {
selectThreadByID(e.getData().id);
}
);
function selectThreadByID(id, update_page_data) {
var thread = JX.$(id);
selectThread(thread, update_page_data);
@ -134,6 +126,7 @@ JX.behavior('conpherence-menu', function(config) {
.start();
} else if (config.hasThread) {
_scrollMessageWindow();
_focusTextarea();
} else {
didRedrawThread();
}
@ -269,22 +262,34 @@ JX.behavior('conpherence-menu', function(config) {
* - notably when the widget selector is used to invoke the message pane.
* The following three functions get 'er done.
*/
function didRedrawThread(build_device_widget_selector) {
_scrollMessageWindow();
JX.Stratcom.invoke(
'conpherence-did-redraw-thread',
null,
{
widget : getDefaultWidget(),
threadID : _thread.selected,
buildDeviceWidgetSelector : build_device_widget_selector
});
function didRedrawThread(build_device_widget_selector) {
_scrollMessageWindow();
_focusTextarea();
JX.Stratcom.invoke(
'conpherence-did-redraw-thread',
null,
{
widget : getDefaultWidget(),
threadID : _thread.selected,
buildDeviceWidgetSelector : build_device_widget_selector
});
}
function _scrollMessageWindow() {
var root = JX.DOM.find(document, 'div', 'conpherence-layout');
var messages_root = JX.DOM.find(root, 'div', 'conpherence-messages');
messages_root.scrollTop = messages_root.scrollHeight;
}
function _focusTextarea() {
var root = JX.DOM.find(document, 'div', 'conpherence-layout');
var form_root = JX.DOM.find(root, 'div', 'conpherence-form');
var textarea = JX.DOM.find(form_root, 'textarea');
// We may have a draft so do this JS trick so we end up focused at the
// end of the draft.
var textarea_value = textarea.value;
textarea.value = '';
JX.DOM.focus(textarea);
textarea.value = textarea_value;
}
JX.Stratcom.listen(
'conpherence-redraw-thread',
null,
@ -334,11 +339,7 @@ JX.behavior('conpherence-menu', function(config) {
JX.$(r.conpherence_phid + '-nav-item'),
JX.$H(r.nav_item)
);
JX.Stratcom.invoke(
'conpherence-selectthread',
null,
{ id : r.conpherence_phid + '-nav-item' }
);
selectThreadByID(r.conpherence_phid + '-nav-item');
} catch (ex) {
// Ignore; this view may not have a menu.
}
@ -514,11 +515,7 @@ JX.behavior('conpherence-menu', function(config) {
menu_root.scrollTop += scroll_y;
if (reselect_id) {
JX.Stratcom.invoke(
'conpherence-selectthread',
null,
{ id : reselect_id }
);
selectThreadByID(reselect_id);
}
};

View file

@ -142,13 +142,9 @@ JX.behavior('conpherence-pontificate', function() {
var textarea = JX.DOM.find(form, 'textarea');
textarea.value = '';
JX.Stratcom.invoke(
'conpherence-selectthread',
null,
{ id : r.conpherence_phid + '-nav-item' }
);
JX.DOM.alterClass(form_root, 'loading', false);
setTimeout(function() { JX.DOM.focus(textarea); }, 100);
}));
sync_workflow(workflow, get_thread_data());