1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-30 02:32: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/auth/behavior-persona-login.js' => '9414ff18',
'rsrc/js/application/config/behavior-reorder-fields.js' => '14a827de', 'rsrc/js/application/config/behavior-reorder-fields.js' => '14a827de',
'rsrc/js/application/conpherence/behavior-durable-column.js' => '0c404426', 'rsrc/js/application/conpherence/behavior-durable-column.js' => '0c404426',
'rsrc/js/application/conpherence/behavior-menu.js' => 'f0a41b9f', 'rsrc/js/application/conpherence/behavior-menu.js' => 'b255d93b',
'rsrc/js/application/conpherence/behavior-pontificate.js' => '2f6efe18', 'rsrc/js/application/conpherence/behavior-pontificate.js' => '86df5915',
'rsrc/js/application/conpherence/behavior-widget-pane.js' => '40b1ff90', 'rsrc/js/application/conpherence/behavior-widget-pane.js' => '40b1ff90',
'rsrc/js/application/countdown/timer.js' => 'e4cc26b3', 'rsrc/js/application/countdown/timer.js' => 'e4cc26b3',
'rsrc/js/application/dashboard/behavior-dashboard-async-panel.js' => '469c0d9e', 'rsrc/js/application/dashboard/behavior-dashboard-async-panel.js' => '469c0d9e',
@ -557,8 +557,8 @@ return array(
'javelin-behavior-boards-dropdown' => '0ec56e1d', 'javelin-behavior-boards-dropdown' => '0ec56e1d',
'javelin-behavior-choose-control' => '6153c708', 'javelin-behavior-choose-control' => '6153c708',
'javelin-behavior-config-reorder-fields' => '14a827de', 'javelin-behavior-config-reorder-fields' => '14a827de',
'javelin-behavior-conpherence-menu' => 'f0a41b9f', 'javelin-behavior-conpherence-menu' => 'b255d93b',
'javelin-behavior-conpherence-pontificate' => '2f6efe18', 'javelin-behavior-conpherence-pontificate' => '86df5915',
'javelin-behavior-conpherence-widget-pane' => '40b1ff90', 'javelin-behavior-conpherence-widget-pane' => '40b1ff90',
'javelin-behavior-countdown-timer' => 'e4cc26b3', 'javelin-behavior-countdown-timer' => 'e4cc26b3',
'javelin-behavior-dark-console' => '08883e8b', 'javelin-behavior-dark-console' => '08883e8b',
@ -1013,13 +1013,6 @@ return array(
'javelin-uri', 'javelin-uri',
'javelin-util', 'javelin-util',
), ),
'2f6efe18' => array(
'javelin-behavior',
'javelin-dom',
'javelin-util',
'javelin-workflow',
'javelin-stratcom',
),
'316b8fa1' => array( '316b8fa1' => array(
'javelin-install', 'javelin-install',
'javelin-typeahead-source', 'javelin-typeahead-source',
@ -1464,6 +1457,13 @@ return array(
'85ea0626' => array( '85ea0626' => array(
'javelin-install', 'javelin-install',
), ),
'86df5915' => array(
'javelin-behavior',
'javelin-dom',
'javelin-util',
'javelin-workflow',
'javelin-stratcom',
),
'87cb6b51' => array( '87cb6b51' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-dom', 'javelin-dom',
@ -1648,6 +1648,17 @@ return array(
'javelin-dom', 'javelin-dom',
'javelin-reactor-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( 'b2b4fbaf' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-dom', 'javelin-dom',
@ -1882,17 +1893,6 @@ return array(
'javelin-install', 'javelin-install',
'javelin-util', '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( 'f2441746' => array(
'javelin-dom', 'javelin-dom',
'javelin-util', 'javelin-util',

View file

@ -57,14 +57,6 @@ JX.behavior('conpherence-menu', function(config) {
/** /**
* Selecting threads * Selecting threads
*/ */
JX.Stratcom.listen(
'conpherence-selectthread',
null,
function (e) {
selectThreadByID(e.getData().id);
}
);
function selectThreadByID(id, update_page_data) { function selectThreadByID(id, update_page_data) {
var thread = JX.$(id); var thread = JX.$(id);
selectThread(thread, update_page_data); selectThread(thread, update_page_data);
@ -134,6 +126,7 @@ JX.behavior('conpherence-menu', function(config) {
.start(); .start();
} else if (config.hasThread) { } else if (config.hasThread) {
_scrollMessageWindow(); _scrollMessageWindow();
_focusTextarea();
} else { } else {
didRedrawThread(); didRedrawThread();
} }
@ -271,6 +264,7 @@ JX.behavior('conpherence-menu', function(config) {
*/ */
function didRedrawThread(build_device_widget_selector) { function didRedrawThread(build_device_widget_selector) {
_scrollMessageWindow(); _scrollMessageWindow();
_focusTextarea();
JX.Stratcom.invoke( JX.Stratcom.invoke(
'conpherence-did-redraw-thread', 'conpherence-did-redraw-thread',
null, null,
@ -285,6 +279,17 @@ JX.behavior('conpherence-menu', function(config) {
var messages_root = JX.DOM.find(root, 'div', 'conpherence-messages'); var messages_root = JX.DOM.find(root, 'div', 'conpherence-messages');
messages_root.scrollTop = messages_root.scrollHeight; 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( JX.Stratcom.listen(
'conpherence-redraw-thread', 'conpherence-redraw-thread',
null, null,
@ -334,11 +339,7 @@ JX.behavior('conpherence-menu', function(config) {
JX.$(r.conpherence_phid + '-nav-item'), JX.$(r.conpherence_phid + '-nav-item'),
JX.$H(r.nav_item) JX.$H(r.nav_item)
); );
JX.Stratcom.invoke( selectThreadByID(r.conpherence_phid + '-nav-item');
'conpherence-selectthread',
null,
{ id : r.conpherence_phid + '-nav-item' }
);
} catch (ex) { } catch (ex) {
// Ignore; this view may not have a menu. // Ignore; this view may not have a menu.
} }
@ -514,11 +515,7 @@ JX.behavior('conpherence-menu', function(config) {
menu_root.scrollTop += scroll_y; menu_root.scrollTop += scroll_y;
if (reselect_id) { if (reselect_id) {
JX.Stratcom.invoke( selectThreadByID(reselect_id);
'conpherence-selectthread',
null,
{ id : reselect_id }
);
} }
}; };

View file

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