From 4899454f6fc94075a7870b16090ac065b71e9e1b Mon Sep 17 00:00:00 2001 From: anekos Date: Wed, 5 May 2010 12:56:17 +0000 Subject: コマンドでも開けるように git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@37377 d0d07461-0603-4401-acd4-de1884942a52 --- open-frame.js | 48 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) (limited to 'open-frame.js') 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 = openframeコマンド Add ":openframe" command. ":openframe" コマンドを追加する - 1.0.0 + 1.1.0 anekos new BSD License (Please read the source code comments of this plugin) 修正BSDライセンス (ソースコードのコメントを参照してください) @@ -57,7 +57,7 @@ let PLUGIN_INFO = // INFO {{{ let INFO = <> - :tabopenframe - :tabopenframe + :tabopenframe Open the selected frame in new tab. - :tabopenframe - :tabopenframe + :tabopenframe 新しいタブに選択したフレームを開く @@ -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 || ''] + for each (f in frames()) + ]; + } }, - {}, true ); }); -- cgit v1.2.3
Open the selected frame in new tab.
新しいタブに選択したフレームを開く