summaryrefslogtreecommitdiff
path: root/program/js/treelist.js
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2014-08-20 09:03:19 +0200
committerThomas Bruederli <thomas@roundcube.net>2014-08-20 09:03:19 +0200
commit3fb36a11fe58cca1a12bd5653d70d484f997807d (patch)
tree43716ee2fd91d9c8cd0eab31a19b77e315c1985d /program/js/treelist.js
parent44b47dfb359f8a7412208079202fca0adf741540 (diff)
Add option to focus a treelist widget on clicks to the container (#1489997)
Diffstat (limited to 'program/js/treelist.js')
-rw-r--r--program/js/treelist.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/program/js/treelist.js b/program/js/treelist.js
index 3a1360229..a7cd7cd43 100644
--- a/program/js/treelist.js
+++ b/program/js/treelist.js
@@ -47,6 +47,7 @@ function rcube_treelist_widget(node, p)
save_state: false,
keyboard: true,
tabexit: true,
+ parent_focus: false,
check_droptarget: function(node) { return !node.virtual; }
}, p || {});
@@ -187,6 +188,17 @@ function rcube_treelist_widget(node, p)
$(document.body)
.bind('keydown', keypress);
+ // catch focus when clicking the list container area
+ if (p.parent_focus) {
+ container.parent(':not(body)').click(function(e) {
+ if (!has_focus && selection) {
+ $(get_item(selection)).find(':focusable').first().focus();
+ }
+ else if (!has_focus) {
+ container.children('li:has(:focusable)').first().find(':focusable').first().focus();
+ }
+ });
+ }
/////// private methods