diff options
author | pekepeke | 2008-11-05 13:20:00 +0000 |
---|---|---|
committer | pekepeke | 2008-11-05 13:20:00 +0000 |
commit | c63f3f885873bd35efceb4b4205e768cc121656e (patch) | |
tree | 40b6cb957228356169b2b48f9ed1ed6ff657428d | |
parent | d6df15ef6cf3ac2ff6c042c121977a69ca86d782 (diff) | |
download | vimperator-plugins-c63f3f885873bd35efceb4b4205e768cc121656e.tar.bz2 |
2.0pre対応
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@22782 d0d07461-0603-4401-acd4-de1884942a52
-rw-r--r-- | ubiquity.js | 1 | ||||
-rw-r--r-- | walk-input.js | 51 |
2 files changed, 52 insertions, 0 deletions
diff --git a/ubiquity.js b/ubiquity.js index e1f152a..35c11b1 100644 --- a/ubiquity.js +++ b/ubiquity.js @@ -65,6 +65,7 @@ preExec(gUbiquity, 'openWindow', function(anchor, flag){ // ------------------------------------------------- commands.addUserCommand(['ubi[quity]'], 'Vimperator Ubiquity Glue', function(args){ + args = (typeof args.string == 'undefined') ? args: args.string; if (!args){ gUbiquity.openWindow(getBrowser(), true); return; diff --git a/walk-input.js b/walk-input.js new file mode 100644 index 0000000..cf84325 --- /dev/null +++ b/walk-input.js @@ -0,0 +1,51 @@ +// Vimperator plugin: 'Walk Input' +// Last Change: 2008-05-22. +// License: BSD +// Version: 1.0 +// Maintainer: Takayama Fumihiko <tekezo@pqrs.org> + +// ------------------------------------------------------------ +// The focus walks <input> & <textarea> elements. +// If you type M-i first, the focus moves to "<input name='search' />". +// Then if you type M-i once more, the focus moves to "<input name='name' />". +// +// <html><body> +// <input name="search" /> +// <a href="xxx">xxx</a> +// <a href="yyy">yyy</a> +// <a href="zzz">zzz</a> +// <input name="name" /> +// <textarea name="comment" /> +// </body></html> + +(function(){ +var walkinput = function() { + var win = document.commandDispatcher.focusedWindow; + var d = win.document; + var xpath = '//input[@type="text" or @type="password" or @type="search" or not(@type)] | //textarea'; + var list = d.evaluate(xpath, d, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); + if (list.snapshotLength == 0) return; + + var focused = document.commandDispatcher.focusedElement; + var current = null; + var next = null; + for (var i = 0; i < list.snapshotLength; ++i) { + var e = list.snapshotItem(i); + if (e == focused) { + current = e; + } else if (current && next == null) { + next = e; + } + } + if (next) { + next.focus(); + } else { + list.snapshotItem(0).focus(); + } +}; + +liberator.modules.mappings.add([liberator.modules.modes.NORMAL], ['<M-i>'], 'Walk Input Fields', function() { walkinput(); }); +liberator.modules.mappings.add([liberator.modules.modes.INSERT], ['<M-i>'], 'Walk Input Fields', function() { walkinput(); }); +liberator.modules.mappings.add([liberator.modules.modes.NORMAL], ['<A-i>'], 'Walk Input Fields', function() { walkinput(); }); +liberator.modules.mappings.add([liberator.modules.modes.INSERT], ['<A-i>'], 'Walk Input Fields', function() { walkinput(); }); +})(); |