aboutsummaryrefslogtreecommitdiffstats
path: root/open-frame.js
diff options
context:
space:
mode:
authoranekos2010-05-05 12:56:17 +0000
committeranekos2010-05-05 12:56:17 +0000
commit4899454f6fc94075a7870b16090ac065b71e9e1b (patch)
tree1d85992c5ef9952c4a40a7172da863d65c7b56f0 /open-frame.js
parent43bebd2bb6e1a7672ad69254dc4058c4e5f366f6 (diff)
downloadvimperator-plugins-4899454f6fc94075a7870b16090ac065b71e9e1b.tar.bz2
コマンドでも開けるように
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@37377 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'open-frame.js')
-rwxr-xr-xopen-frame.js48
1 files changed, 36 insertions, 12 deletions
diff --git a/open-frame.js b/open-frame.js
index 6b60623..d4239f9 100755
--- a/open-frame.js
+++ b/open-frame.js
@@ -39,7 +39,7 @@ let PLUGIN_INFO =
<name lang="ja">openframeコマンド</name>
<description>Add ":openframe" command.</description>
<description lang="ja">":openframe" コマンドを追加する</description>
- <version>1.0.0</version>
+ <version>1.1.0</version>
<author mail="anekos@snca.net" homepage="http://d.hatena.ne.jp/nokturnalmortum/">anekos</author>
<license>new BSD License (Please read the source code comments of this plugin)</license>
<license lang="ja">修正BSDライセンス (ソースコードのコメントを参照してください)</license>
@@ -57,7 +57,7 @@ let PLUGIN_INFO =
// INFO {{{
let INFO =
<>
- <plugin name="openframe-command" version="1.0.0"
+ <plugin name="openframe-command" version="1.1.0"
href="http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/open-frame.js"
summary="Add openframe command."
lang="en-US"
@@ -72,11 +72,11 @@ let INFO =
</item>
<item>
<tags>:tabopenframe</tags>
- <spec>:tabopenf<oa>rame</oa></spec>
+ <spec>:t<oa>ab</oa>o<oa>pen</oa>f<oa>rame</oa></spec>
<description><p>Open the selected frame in new tab.</p></description>
</item>
</plugin>
- <plugin name="openframe-command" version="1.0.0"
+ <plugin name="openframe-command" version="1.1.0"
href="http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/open-frame.js"
summary="Add openframe command."
lang="ja"
@@ -91,7 +91,7 @@ let INFO =
</item>
<item>
<tags>:tabopenframe</tags>
- <spec>:tabopenf<oa>rame</oa></spec>
+ <spec>:t<oa>ab</oa>o<oa>pen</oa>f<oa>rame</oa></spec>
<description><p>新しいタブに選択したフレームを開く</p></description>
</item>
</plugin>
@@ -100,28 +100,52 @@ let INFO =
(function () {
+ function frames () {
+ let result = [];
+
+ (function (win) {
+ result = result.concat(Array.map(win.frames, function (win) win));
+ Array.forEach(win.frames, arguments.callee);
+ })(config.browser.contentWindow);
+
+ return result;
+ }
+
[true, false].forEach(function (tab) {
let desc = 'Open frame in ' + (tab ? 'current tab' : 'new tab');
let modeName = (tab ? 'tab-' : '') + 'open-frame';
+
+ let open = function (url) liberator.open(url, tab ? liberator.NEW_TAB : liberator.CURRENT_TAB);
+
hints.addMode(
modeName,
desc,
function (elem) {
- liberator.open(
- elem.ownerDocument.location.href,
- tab ? liberator.NEW_TAB : liberator.CURRENT_TAB
- );
+ open(elem.ownerDocument.location.href);
},
function () util.makeXPath(["body"])
);
commands.addUserCommand(
- [(tab ? 'tab' : '') + 'openf[rame]'],
+ tab ? ['tabopenf[rame]', 'topenf[rame]', 'tof[rame]']
+ : ['openf[rame]'],
desc,
function (args) {
- hints.show(modeName);
+ if (args.literalArg) {
+ open(args.literalArg);
+ } else {
+ hints.show(modeName);
+ }
+ },
+ {
+ literal: 0,
+ completer: function (context) {
+ context.completions = [
+ [f.location.href, f.document.title || '<No Title>']
+ for each (f in frames())
+ ];
+ }
},
- {},
true
);
});