Hi John,

On Tue, Dec 21, 2010 at 04:11, John J. Foerch <[email protected]> wrote:
>
> First thing I noticed is that using fallthrough bindings for 's' and '/'
> is not the best way to focus the search boxes, because those keys will
> fail to work for anybody using the aggressive focus-blocker which disables
> focus events initiated from content.  It would be more robust to do the
> focus in chrome code with a couple of normal (non-fallthrough)
> keys/commands.

Attach 0001 is the patch you want.  0002 also uses chrome code to show
keyboard shortcuts help instead of the jquery approach.  I think the
latter is dirty, because it will insert a script node every time.

Thanks,
Des
From f79de2e9e094d4fe294e8bbd8677ad308840f8b6 Mon Sep 17 00:00:00 2001
From: Desmond O. Chang <[email protected]>
Date: Wed, 22 Dec 2010 01:57:27 +0800
Subject: [PATCH 1/2] github.js: do the focus in chrome code

---
 modules/page-modes/github.js |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/modules/page-modes/github.js b/modules/page-modes/github.js
index 23615d1..a517ad5 100644
--- a/modules/page-modes/github.js
+++ b/modules/page-modes/github.js
@@ -19,6 +19,22 @@ interactive("github-keyboard-shortcuts", null, function (I) {
     d.body.appendChild(js);
 });
 
+interactive("github-focus-site-search", null, function (I) {
+    var buf = I.buffer;
+    var elem = buf.document.querySelector("#top_search_form input[name=q]");
+    if (elem) {
+        browser_element_focus(buf, elem);
+    }
+});
+
+interactive("github-focus-issues-search", null, function (I) {
+    var buf = I.buffer;
+    var elem = buf.document.querySelector("#issues span.search input[name=q]");
+    if (elem) {
+        browser_element_focus(buf, elem);
+    }
+});
+
 [// Site-wide shortcuts
  "s",                        // Focus site search
  "?",                        // Bring up this help dialog
@@ -59,6 +75,8 @@ interactive("github-keyboard-shortcuts", null, function (I) {
     .map(function (x) define_key(github_keymap, x, null, $fallthrough));
 
 define_key(github_keymap, "?", "github-keyboard-shortcuts");
+define_key(github_keymap, "s", "github-focus-site-search");
+define_key(github_keymap, "/", "github-focus-issues-search");
 
 
 var github_modality = {
-- 
1.7.2.3

From 966a3f920fa61911e1503f7b5cb44669588422d8 Mon Sep 17 00:00:00 2001
From: Desmond O. Chang <[email protected]>
Date: Wed, 22 Dec 2010 02:20:07 +0800
Subject: [PATCH 2/2] github.js: use chrome code to show keyboard shortcuts

---
 modules/page-modes/github.js |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/modules/page-modes/github.js b/modules/page-modes/github.js
index a517ad5..640c818 100644
--- a/modules/page-modes/github.js
+++ b/modules/page-modes/github.js
@@ -12,11 +12,11 @@ require("content-buffer.js");
 define_keymap("github_keymap", $display_name = "github");
 
 interactive("github-keyboard-shortcuts", null, function (I) {
-    var d = I.buffer.document;
-    var js = d.createElement("script");
-    js.setAttribute("type", "text/javascript");
-    js.textContent = "jQuery('#main a.keyboard-shortcuts').click();";
-    d.body.appendChild(js);
+    var buf = I.buffer;
+    var elem = buf.document.querySelector("#main a.keyboard-shortcuts");
+    if (elem) {
+        browser_object_follow(buf, FOLLOW_DEFAULT, elem);
+    }
 });
 
 interactive("github-focus-site-search", null, function (I) {
-- 
1.7.2.3

_______________________________________________
Conkeror mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/conkeror

Reply via email to