aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/data/scripts/follow.js
diff options
context:
space:
mode:
authorGravatar Brendan Taylor <whateley@gmail.com>2011-09-26 18:28:43 +0000
committerGravatar Brendan Taylor <whateley@gmail.com>2011-09-26 18:28:43 +0000
commit4bb5c202f366bb1818054ceaa89474545344d554 (patch)
tree826f394c4f8f19a13f9ac0e414e47b4a00ce9e62 /examples/data/scripts/follow.js
parent17f5e0d6bb15965573df41de12c77f0b26f1397a (diff)
fix following input[type=email], [type=search], etc.
Diffstat (limited to 'examples/data/scripts/follow.js')
-rw-r--r--examples/data/scripts/follow.js32
1 files changed, 19 insertions, 13 deletions
diff --git a/examples/data/scripts/follow.js b/examples/data/scripts/follow.js
index 2b4fcd0..45ecfc6 100644
--- a/examples/data/scripts/follow.js
+++ b/examples/data/scripts/follow.js
@@ -138,26 +138,32 @@ uzbl.follow.generateHint = function(doc, el, label, top, left) {
return hint;
}
-// Here we choose what to do with an element if we
-// want to "follow" it. On form elements we "select"
-// or pass the focus, on links we try to perform a click,
-// but at least set the href of the link. (needs some improvements)
+// this is pointlessly duplicated in uzbl.formfiller
+uzbl.follow.textInputTypes = [
+ 'text', 'password', 'search', 'email', 'url', 'number', 'range', 'color',
+ 'date', 'month', 'week', 'time', 'datetime', 'datetime-local'
+];
+
+// this is pointlessly duplicated in uzbl.formfiller
+uzbl.follow.inputTypeIsText = function(type) {
+ return uzbl.follow.textInputTypes.indexOf(type) >= 0;
+}
+
+// Here we choose what to do with an element that's been selected.
+// On text form elements we focus and select the content. On other
+// elements we simulate a mouse click.
uzbl.follow.clickElem = function(item) {
if(!item) return;
- if (item instanceof HTMLInputElement) {
- var type = item.type;
- if (type == 'text' || type == 'file' || type == 'password') {
- item.focus();
- item.select();
- return "XXXEMIT_FORM_ACTIVEXXX";
- }
- // otherwise fall through to a simulated mouseclick.
+ if (item instanceof HTMLInputElement && uzbl.follow.inputTypeIsText(item.type)) {
+ item.focus();
+ item.select();
+ return "XXXFORM_ACTIVEXXX";
} else if (item instanceof HTMLTextAreaElement || item instanceof HTMLSelectElement) {
item.focus();
if(typeof item.select != 'undefined')
item.select();
- return "XXXEMIT_FORM_ACTIVEXXX";
+ return "XXXFORM_ACTIVEXXX";
}
// simulate a mouseclick to activate the element