diff options
| author | ForklessAnon <REDACTED@gmail.com> | 2014-11-01 16:49:34 -0500 |
|---|---|---|
| committer | czaks <marcin@6irc.net> | 2016-05-05 12:36:28 +0200 |
| commit | 69a6631742c2c2b464c5beca289619dca5760e45 (patch) | |
| tree | e8bd72cd57f762029b21a6a10b64076951c66507 /js/comment-toolbar.js | |
| parent | 86ddb4ecbbca36739da1993497376fb309c6b79f (diff) | |
Added option to disable/ignore keybinds.
Diffstat (limited to 'js/comment-toolbar.js')
| -rw-r--r-- | js/comment-toolbar.js | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/js/comment-toolbar.js b/js/comment-toolbar.js index 2c8b9ca8..74654868 100644 --- a/js/comment-toolbar.js +++ b/js/comment-toolbar.js @@ -226,7 +226,6 @@ if (active_page == 'thread' || active_page == 'index') { self.save_rules = function(){ var newrules = {}, rules = $('.format_rule'); for (var index=0;rules[index];index++) { - console.log(rules[index]); newrules[$(rules[index]).attr('name')] = { text: $(rules[index]).find('[name="text"]').val(), key: $(rules[index]).find('[name="key"]').val(), @@ -236,7 +235,6 @@ if (active_page == 'thread' || active_page == 'index') { exclusiveline: $(rules[index]).find('[name="exclusiveline"]').is(':checked') }; } - console.log(newrules); localStorage.formatText_rules = JSON.stringify(newrules); self.build_toolbars(); }; @@ -250,12 +248,19 @@ if (active_page == 'thread' || active_page == 'index') { // Add settings to Options panel general tab if (window.Options && Options.get_tab('general')) { - var s1 = '#formatText_enable>input', s2 = '#formatText_toolbar>input', e = 'change'; - Options.extend_tab('general', '<label id="formatText_enable"><input type="checkbox" checked="checked" id="formatText_enable">' + _('Enable post formatting') + '</label>'); - Options.extend_tab('general', '<label id="formatText_toolbar"><input type="checkbox" checked="checked" id="formatText_toolbar">' + _('Show formatting toolbar') + '</label>'); + var s1 = '#formatText_enable>input', s2 = '#formatText_keybinds>input', s3 = '#formatText_toolbar>input', e = 'change'; + Options.extend_tab('general', '\ + <fieldset>\ + <legend>Formatting Options</legend>\ + <label id="formatText_enable"><input type="checkbox" checked="checked" id="formatText_enable">' + _('Enable post formatting') + '</label>\ + <label id="formatText_keybinds"><input type="checkbox" checked="checked" id="formatText_keybinds">' + _('Enable formatting keybinds') + '</label>\ + <label id="formatText_toolbar"><input type="checkbox" checked="checked" id="formatText_toolbar">' + _('Show formatting toolbar') + '</label>\ + </fieldset>\ + '); } else { - var s1 = '#formatText_enable', s2 = '#formatText_toolbar', e = 'click'; + var s1 = '#formatText_enable', s2 = '#formatText_keybinds', s3 = '#formatText_toolbar', e = 'click'; $('hr:first').before('<div id="formatText_enable" style="text-align:right"><a class="unimportant" href="javascript:void(0)">'+ _('Enable post formatting') +'</a></div>'); + $('hr:first').before('<div id="formatText_keybinds" style="text-align:right"><a class="unimportant" href="javascript:void(0)">'+ _('Enable formatting keybinds') +'</a></div>'); $('hr:first').before('<div id="formatText_toolbar" style="text-align:right"><a class="unimportant" href="javascript:void(0)">'+ _('Show formatting toolbar') +'</a></div>'); } @@ -270,8 +275,19 @@ if (active_page == 'thread' || active_page == 'index') { } }); - // setting for toolbar injection + // setting for enableing formatting keybinds $(s2).on(e, function(e) { + if (!localStorage.formatText_keybinds || localStorage.formatText_keybinds == 'false') { + localStorage.formatText_keybinds = 'true'; + if (window.Options && Options.get_tab('general')) e.target.checked = true; + } else { + localStorage.formatText_keybinds = 'false'; + if (window.Options && Options.get_tab('general')) e.target.checked = false; + } + }); + + // setting for toolbar injection + $(s3).on(e, function(e) { if (!localStorage.formatText_toolbar || localStorage.formatText_toolbar == 'false') { localStorage.formatText_toolbar = 'true'; if (window.Options && Options.get_tab('general')) e.target.checked = true; @@ -287,8 +303,10 @@ if (active_page == 'thread' || active_page == 'index') { if (window.Options && Options.get_tab('general')) { if (localStorage.formatText_enable == 'true') $(s1)[0].checked = true; else $(s1)[0].checked = false; - if (localStorage.formatText_toolbar == 'true') $(s2)[0].checked = true; + if (localStorage.formatText_keybinds == 'true') $(s2)[0].checked = true; else $(s2)[0].checked = false; + if (localStorage.formatText_toolbar == 'true') $(s2)[0].checked = true; + else $(s3)[0].checked = false; } // add the tab for customizing the format settings @@ -309,6 +327,9 @@ if (active_page == 'thread' || active_page == 'index') { .format_option:last-child{\ margin-right:0;\ }\ + fieldset{\ + margin-top:5px;\ + }\ </style>\ '); @@ -346,6 +367,7 @@ if (active_page == 'thread' || active_page == 'index') { //attach listeners to <body> so it also works on quick-reply box $('body').on('keydown', '#body, #quick-reply #body', function(e) { if (!localStorage.formatText_enable || localStorage.formatText_enable == 'false') return; + if (!localStorage.formatText_keybinds || localStorage.formatText_keybinds == 'false') return; var key = String.fromCharCode(e.which).toLowerCase(); var rules = JSON.parse(localStorage.formatText_rules); for (var index in rules) { @@ -361,4 +383,4 @@ if (active_page == 'thread' || active_page == 'index') { } }); $(document).trigger('formatText'); -} +}
\ No newline at end of file |
