Fix for the js being shitty inside the compiled main.js.
This commit is contained in:
parent
f6b4b2ac18
commit
81daf934fb
@ -257,8 +257,8 @@ if (active_page == 'thread' || active_page == 'index') {
|
||||
Options.extend_tab('general', '\
|
||||
<fieldset>\
|
||||
<legend>Formatting Options</legend>\
|
||||
<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>\
|
||||
<label id="formatText_keybinds"><input type="checkbox">' + _('Enable formatting keybinds') + '</label>\
|
||||
<label id="formatText_toolbar"><input type="checkbox">' + _('Show formatting toolbar') + '</label>\
|
||||
</fieldset>\
|
||||
');
|
||||
} else {
|
||||
@ -267,39 +267,6 @@ if (active_page == 'thread' || active_page == 'index') {
|
||||
$('hr:first').before('<div id="formatText_toolbar" style="text-align:right"><a class="unimportant" href="javascript:void(0)">'+ _('Show formatting toolbar') +'</a></div>');
|
||||
}
|
||||
|
||||
|
||||
// setting for enableing formatting keybinds
|
||||
$(s1).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
|
||||
$(s2).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;
|
||||
formatText.build_toolbars();
|
||||
} else {
|
||||
localStorage.formatText_toolbar = 'false';
|
||||
if (window.Options && Options.get_tab('general')) e.target.checked = false;
|
||||
$('.format-text').remove();
|
||||
}
|
||||
});
|
||||
|
||||
// make sure the tab settings are switch properly at loadup
|
||||
if (window.Options && Options.get_tab('general')) {
|
||||
if (localStorage.formatText_keybinds == 'true') $(s1)[0].checked = true;
|
||||
else $(s1)[0].checked = false;
|
||||
if (localStorage.formatText_toolbar == 'true') $(s2)[0].checked = true;
|
||||
else $(s2)[0].checked = false;
|
||||
}
|
||||
|
||||
// add the tab for customizing the format settings
|
||||
if (window.Options && !Options.get_tab('formatting')) {
|
||||
Options.add_tab('formatting', 'angle-right', 'Customize Formatting');
|
||||
@ -350,28 +317,67 @@ if (active_page == 'thread' || active_page == 'index') {
|
||||
}
|
||||
}
|
||||
|
||||
// setup code to be ran when page is ready (work around for main.js compilation).
|
||||
$(document).ready(function(){
|
||||
// setting for enabling formatting keybinds
|
||||
$(s1).on(e, function(e) {
|
||||
console.log('Keybind');
|
||||
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
|
||||
$(s2).on(e, function(e) {
|
||||
console.log('Toolbar');
|
||||
if (!localStorage.formatText_toolbar || localStorage.formatText_toolbar == 'false') {
|
||||
localStorage.formatText_toolbar = 'true';
|
||||
if (window.Options && Options.get_tab('general')) e.target.checked = true;
|
||||
formatText.build_toolbars();
|
||||
} else {
|
||||
localStorage.formatText_toolbar = 'false';
|
||||
if (window.Options && Options.get_tab('general')) e.target.checked = false;
|
||||
$('.format-text').remove();
|
||||
}
|
||||
});
|
||||
|
||||
// make sure the tab settings are switch properly at loadup
|
||||
if (window.Options && Options.get_tab('general')) {
|
||||
if (localStorage.formatText_keybinds == 'true') $(s1)[0].checked = true;
|
||||
else $(s1)[0].checked = false;
|
||||
if (localStorage.formatText_toolbar == 'true') $(s2)[0].checked = true;
|
||||
else $(s2)[0].checked = false;
|
||||
}
|
||||
|
||||
// Initial toolbar injection
|
||||
formatText.build_toolbars();
|
||||
|
||||
//attach listener to <body> so it also works on quick-reply box
|
||||
$('body').on('keydown', '[name="body"]', function(e) {
|
||||
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) {
|
||||
if (!rules.hasOwnProperty(index)) continue;
|
||||
if (key === rules[index].key && e.ctrlKey) {
|
||||
e.preventDefault();
|
||||
if (e.shiftKey) {
|
||||
formatText.wrap(e.target, 'textarea[name="body"]', index, true);
|
||||
} else {
|
||||
formatText.wrap(e.target, 'textarea[name="body"]', index, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Signal that comment-toolbar loading has completed.
|
||||
$(document).trigger('formatText');
|
||||
});
|
||||
|
||||
return self;
|
||||
})(jQuery);
|
||||
|
||||
// run initial toolbar injection
|
||||
formatText.build_toolbars();
|
||||
|
||||
//attach listeners to <body> so it also works on quick-reply box
|
||||
$('body').on('keydown', '#body, #quick-reply #body', function(e) {
|
||||
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) {
|
||||
if (!rules.hasOwnProperty(index)) continue;
|
||||
if (key === rules[index].key && e.ctrlKey) {
|
||||
e.preventDefault();
|
||||
if (e.shiftKey) {
|
||||
formatText.wrap(e.target, 'textarea[name="body"]', index, true);
|
||||
} else {
|
||||
formatText.wrap(e.target, 'textarea[name="body"]', index, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
$(document).trigger('formatText');
|
||||
}
|
Loading…
Reference in New Issue
Block a user