From 669b8a5676a6ebf9212acfc22c4d5a01a85e1f89 Mon Sep 17 00:00:00 2001
From: anekos
Date: Sat, 10 Apr 2010 15:16:47 +0000
Subject: 変則的なコマンドの利用をやめる
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@37181 d0d07461-0603-4401-acd4-de1884942a52
---
option-selector.js | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
(limited to 'option-selector.js')
diff --git a/option-selector.js b/option-selector.js
index 8b52686..2ee38c9 100755
--- a/option-selector.js
+++ b/option-selector.js
@@ -38,7 +38,7 @@ let PLUGIN_INFO =
Option Selector
Select a option of the select element.
select 要素の option を選択する。
- 1.1.0
+ 1.1.1
anekos
new BSD License (Please read the source code comments of this plugin)
修正BSDライセンス (ソースコードのコメントを参照してください)
@@ -56,21 +56,19 @@ let PLUGIN_INFO =
(function () {
- {
- let targetElement = null;
+ function select () {
+ let targetElement = buffer.lastInputField;
- commands.addUserCommand(
- ['selectoption'],
- 'Select a option of the select element',
- function (args) {
- targetElement.selectedIndex = parseInt(args[0], 10);
+ commandline.input(
+ 'Select a option of the select element: ',
+ function (arg) {
+ targetElement.selectedIndex = parseInt(arg, 10);
let event = content.document.createEvent('Event');
event.initEvent('change', true, true);
targetElement.dispatchEvent(event);
targetElement.focus();
},
{
- literal: 0,
completer: function (context, args) {
let elem = targetElement = buffer.lastInputField;
if (!elem)
@@ -82,9 +80,9 @@ let PLUGIN_INFO =
for ([n, opt] in Iterator(Array.slice(elem.options)))
];
}
- },
- true
+ }
);
+ events.feedkeys('', true); // FIXME
}
autocommands.add(
@@ -95,7 +93,7 @@ let PLUGIN_INFO =
let action = mapping.action;
mapping.action = function () {
if (buffer.lastInputField instanceof HTMLSelectElement)
- commandline.open(':', 'selectoption ', modes.EX)
+ select()
else
action.apply(action, arguments);
};
--
cgit v1.2.3