From 3fb36a11fe58cca1a12bd5653d70d484f997807d Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Wed, 20 Aug 2014 03:03:19 -0400
Subject: [PATCH] Add option to focus a treelist widget on clicks to the container (#1489997)
---
program/js/treelist.js | 12 ++++++++++++
program/js/app.js | 2 ++
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/program/js/app.js b/program/js/app.js
index 0fca471..e5a70c9 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -563,6 +563,7 @@
this.treelist = new rcube_treelist_widget(this.gui_objects.folderlist, {
selectable: true,
id_prefix: 'rcmli',
+ parent_focus: true,
id_encode: this.html_identifier_encode,
id_decode: this.html_identifier_decode,
check_droptarget: function(node) { return !node.virtual && ref.check_droptarget(node.id) }
@@ -5751,6 +5752,7 @@
this.subscription_list = new rcube_treelist_widget(this.gui_objects.subscriptionlist, {
selectable: true,
tabexit: false,
+ parent_focus: true,
id_prefix: 'rcmli',
id_encode: this.html_identifier_encode,
id_decode: this.html_identifier_decode,
diff --git a/program/js/treelist.js b/program/js/treelist.js
index 3a13602..a7cd7cd 100644
--- a/program/js/treelist.js
+++ b/program/js/treelist.js
@@ -47,6 +47,7 @@
save_state: false,
keyboard: true,
tabexit: true,
+ parent_focus: false,
check_droptarget: function(node) { return !node.virtual; }
}, p || {});
@@ -187,6 +188,17 @@
$(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
--
Gitblit v1.9.1