aboutsummaryrefslogtreecommitdiffstats
path: root/google-plus-commando.js
diff options
context:
space:
mode:
authoranekos2011-07-17 07:31:58 +0900
committeranekos2011-07-17 07:31:58 +0900
commit320a7bb47aceda837aefbc207e2920e3092cb5a2 (patch)
treed5f50b72305adecee9efaa3354e40289d0ef1dce /google-plus-commando.js
parent57514964d7c32323d6d24920f7aab57809653af7 (diff)
downloadvimperator-plugins-320a7bb47aceda837aefbc207e2920e3092cb5a2.tar.bz2
通知表示関連の改善
Diffstat (limited to 'google-plus-commando.js')
-rw-r--r--google-plus-commando.js49
1 files changed, 33 insertions, 16 deletions
diff --git a/google-plus-commando.js b/google-plus-commando.js
index acc9ff6..59ec7ae 100644
--- a/google-plus-commando.js
+++ b/google-plus-commando.js
@@ -35,7 +35,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
// INFO {{{
let INFO =
<>
- <plugin name="GooglePlusCommando" version="1.9.1"
+ <plugin name="GooglePlusCommando" version="1.9.2"
href="http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/google-plus-commando.js"
summary="The handy commands for Google+"
lang="en-US"
@@ -104,6 +104,10 @@ let INFO =
get viewer () MakeElement(Viewer, Elements.doc.querySelector('.' + Names.viewer)),
get dialog () MakeElement(Dialog, Elements.doc.querySelector('.' + Names.dialog)),
+ frames: {
+ get notifications () MakeElement(Notifications, Elements.doc.querySelector('iframe[src*="/_/notifications/"]'))
+ },
+
get focusedEditor () {
function hasIFrame (elem) {
let iframe = elem.querySelector('iframe');
@@ -221,6 +225,14 @@ let INFO =
return self;
}
+ function Notifications (root) {
+ let self = {
+ get root () root,
+ get visible () (parseInt(root.style.height, 10) > 0)
+ };
+ return self;
+ }
+
// }}}
// Post Help {{{
@@ -293,26 +305,27 @@ let INFO =
// Commands {{{
const Commands = {
- next: withCount(function () {
+ moveEntry: function (arrow, vim) {
if (Elements.viewer)
return click(Elements.viewer.next);
- let menus = A(Elements.doc.querySelectorAll('[tabindex="0"][role="menu"]'));
- plugins.feedSomeKeys_3.API.feed.apply(
- null,
- menus.length === 1 ? ['<Down>', ['keypress'], menus[0]]
- : ['j', ['vkeypress'], Elements.doc]
- );
- }),
- prev: withCount(function () {
- if (Elements.viewer)
- return click(Elements.viewer.prev);
- let menus = A(Elements.doc.querySelectorAll('[tabindex="0"][role="menu"]'));
+
+ let arrowTarget = (function () {
+ let notifications = Elements.frames.notifications;
+ if (notifications && notifications.visible)
+ return notifications.root.contentDocument.body;
+
+ let menus = A(Elements.doc.querySelectorAll('[tabindex="0"][role="menu"]'));
+ if (menus.length === 1)
+ return menus[0];
+ })();
+
plugins.feedSomeKeys_3.API.feed.apply(
null,
- menus.length === 1 ? ['<Up>', ['keypress'], menus[0]]
- : ['k', ['vkeypress'], Elements.doc]
+ arrowTarget ? [arrow, ['keypress'], arrowTarget] : [vim, ['vkeypress'], Elements.doc]
);
- }),
+ },
+ next: withCount(function () Commands.moveEntry('<Down>', 'j')),
+ prev: withCount(function () Commands.moveEntry('<Up>', 'k')),
comment: function() {
let entry = Elements.currentEntry;
click(entry.comment);
@@ -341,6 +354,10 @@ let INFO =
if (e && e.cancel)
return click(e.cancel);
}
+
+ if (Elements.frames.notifications.visible)
+ return click(Elements.notification);
+
click(Elements.doc.body);
},
submit: function () {