Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert the shortcut key for contextual post #276

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/_locales/en_US/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
"message": "use Keyconfig instead ( if this is checked, Taberareloo doesn't observe key input. )"
},
"label_shortcutkey": {
"message": "Shortcutkey - $1 Quick Post"
"message": "Shortcutkey - $1 Post"
},
"label_shortcutkey_general": {
"message": "Shortcutkey - Contextual Post"
},
"label_clear": {
"message": "clear"
Expand Down
7 changes: 5 additions & 2 deletions src/_locales/ja/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@
"description": "Taberarelooについてのタブ"
},
"label_tagprovider": {
"message": "クイックポストで使うタグの取得元"
"message": "タグの取得元"
},
"label_keyconfig": {
"message": "Keyconfig を使う ( チェックされているとTaberarelooによるキー監視は行われません )"
},
"label_shortcutkey": {
"message": "ショートカット - $1クイックポスト"
"message": "ショートカット - $1・ポスト"
},
"label_shortcutkey_general": {
"message": "ショートカット - コンテキスト・ポスト"
},
"label_clear": {
"message": "クリア"
Expand Down
4 changes: 3 additions & 1 deletion src/lib/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
group: 'Taberareloo',
actions: [
{name: 'Taberareloo.link'},
{name: 'Taberareloo.quote'}
{name: 'Taberareloo.quote'},
{name: 'Taberareloo.general'}
]
};
chrome.runtime.sendMessage(CHROME_GESTURES, action, function () {
Expand Down Expand Up @@ -85,6 +86,7 @@
'keyconfig': true,
'shortcutkey_linkquickpost': '',
'shortcutkey_quotequickpost': '',
'shortcutkey_quickpost': '',
'evernote_clip_fullpage': true,
'remove_hatena_keyword': false,
'tumblr_default_quote': false,
Expand Down
23 changes: 22 additions & 1 deletion src/lib/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
'use strict';

var TBRL = {
target : { x: 0, y: 0 },
clickTarget: { x: 0, y: 0 },
config : null,
id : chrome.runtime.id,
Expand All @@ -17,10 +18,12 @@
var userscripts;

TBRL.config = config;
document.addEventListener('mousemove', TBRL.mousehandler, false);
document.addEventListener('mousedown', TBRL.clickhandler, false);
document.addEventListener('unload', TBRL.unload, false);
window.addEventListener('Taberareloo.link', TBRL.link, false);
window.addEventListener('Taberareloo.quote', TBRL.quote, false);
window.addEventListener('Taberareloo.general', TBRL.general, false);

if (!TBRL.config.post.keyconfig) {
document.addEventListener('keydown', TBRL.keyhandler, false);
Expand All @@ -38,9 +41,11 @@
document.removeEventListener('keydown', TBRL.keyhandler, false);
}

document.removeEventListener('mousemove', TBRL.mousehandler, false);
document.removeEventListener('mousedown', TBRL.clickhandler, false);
window.removeEventListener('Taberareloo.link', TBRL.link, false);
window.removeEventListener('Taberareloo.quote', TBRL.quote, false);
window.removeEventListener('Taberareloo.general', TBRL.general, false);

TBRL.userscripts.forEach(function (script) {
script.unload();
Expand All @@ -58,6 +63,11 @@
var ext = (Extractors.Quote.check(ctx)) ? Extractors.Quote : Extractors.Text;
return TBRL.share(ctx, ext, true);
},
general: function () {
var ctx = TBRL.createContext();
var ext = Extractors.check(ctx)[0];
return TBRL.share(ctx, ext, true);
},
keyhandler: function (ev) {
var t = ev.target;
if (t.nodeType === 1) {
Expand All @@ -71,11 +81,14 @@
var key = keyString(ev);
var link_quick_post = TBRL.config.post.shortcutkey_linkquickpost;
var quote_quick_post = TBRL.config.post.shortcutkey_quotequickpost;
var quick_post = TBRL.config.post.shortcutkey_quickpost;

if (link_quick_post && key === link_quick_post) {
TBRL.link();
} else if (quote_quick_post && key === quote_quick_post) {
TBRL.quote();
} else if (quick_post && key === quick_post) {
TBRL.general();
}
} catch (e) {
window.alert(e);
Expand All @@ -89,7 +102,7 @@
window: window,
title: document.title || location.href.replace(new RegExp('(?:^http://)?(' + location.hostname + ')(?:/$)?'), '$1'),
selection: (sel.raw) ? sel : null,
target: target || document.documentElement
target: target || TBRL.getTarget() || document.documentElement
}, window.location);
if (ctx.target) {
ctx.link = $X('./ancestor-or-self::a[@href]', ctx.target)[0];
Expand All @@ -98,10 +111,18 @@
}
return ctx;
},
mousehandler: function (ev) {
// 監視
TBRL.target.x = ev.clientX;
TBRL.target.y = ev.clientY;
},
clickhandler: function (ev) {
TBRL.clickTarget.x = ev.clientX;
TBRL.clickTarget.y = ev.clientY;
},
getTarget : function () {
return document.elementFromPoint(TBRL.target.x, TBRL.target.y);
},
getContextMenuTarget: function () {
return document.elementFromPoint(TBRL.clickTarget.x, TBRL.clickTarget.y);
},
Expand Down
10 changes: 8 additions & 2 deletions src/lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@
this.link_quick_short = new Shortcutkey('shortcutkey_linkquickpost', true);
// shortcutkey quick link post
this.quote_quick_short = new Shortcutkey('shortcutkey_quotequickpost', true);
// quick post
this.quick_short = new Shortcutkey('shortcutkey_quickpost', true);

connect($('save'), 'onclick', this, this.save);

Expand All @@ -153,8 +155,10 @@

$('label_shortcutkey_linkquickpost').appendChild($T(chrome.i18n.getMessage('label_shortcutkey', 'Link')));
$('label_shortcutkey_quotequickpost').appendChild($T(chrome.i18n.getMessage('label_shortcutkey', 'Quote')));
$('label_shortcutkey_quickpost').appendChild($T(chrome.i18n.getMessage('label_shortcutkey_general')));

$('shortcutkey_linkquickpost_clear').value =
$('shortcutkey_quickpost_clear').value =
$('shortcutkey_linkquickpost_clear').value =
$('shortcutkey_quotequickpost_clear').value =
$('shortcutkey_ldr_plus_taberareloo_clear').value =
$('shortcutkey_dashboard_plus_taberareloo_clear').value =
Expand Down Expand Up @@ -203,11 +207,12 @@
save : function () {
var lk = this.link_quick_short.body();
var qk = this.quote_quick_short.body();
var k = this.quick_short.body();
var tcheck = this.tumble_check.body();
var enable_hatenablog = this.enableHatenaBlog_check.body();
var enable_webhook = this.enable_webhook_check.body();
var webhook_url = this.webhook_url_input.body();
if (!Shortcutkey.isConflict(lk, qk)) {
if (!Shortcutkey.isConflict(lk, qk, k)) {
background.TBRL.configSet({
'services' : this.services.body(),
'post' : {
Expand All @@ -234,6 +239,7 @@
'tumblr_default_quote' : this.tumblr_default_quote.body(),
'shortcutkey_linkquickpost': lk,
'shortcutkey_quotequickpost' : qk,
'shortcutkey_quickpost' : k,
'always_shorten_url' : this.shorten_check.body(),
'multi_tumblelogs' : tcheck,
'post_with_queue' : this.queue_check.body(),
Expand Down
5 changes: 5 additions & 0 deletions src/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
</div>
<div class="option">
<p id="label_keyconfig"></p><input id="keyconfig_checkbox" type="checkbox" name="keyconfig_checkbox">
<p id="label_shortcutkey_quickpost"></p>
<div>
<input id="shortcutkey_quickpost" type="text">
<input id="shortcutkey_quickpost_clear" type="button">
</div>
<p id="label_shortcutkey_linkquickpost"></p>
<div>
<input id="shortcutkey_linkquickpost" type="text">
Expand Down