mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
Added ability to turn keyboard shortcuts off
This commit is contained in:
@ -32,6 +32,7 @@ App.BrowsingSettings = function(
|
||||
sketchy: true,
|
||||
unsafe: true,
|
||||
},
|
||||
keyboardShortcuts: true,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
var App = App || {};
|
||||
|
||||
App.Keyboard = function(jQuery, mousetrap) {
|
||||
App.Keyboard = function(jQuery, mousetrap, browsingSettings) {
|
||||
|
||||
var enabled = browsingSettings.getSettings().keyboardShortcuts;
|
||||
var oldStopCallback = mousetrap.stopCallback;
|
||||
mousetrap.stopCallback = function(e, element, combo, sequence) {
|
||||
if (combo.indexOf('ctrl') === -1 && e.ctrlKey) {
|
||||
@ -28,12 +29,16 @@ App.Keyboard = function(jQuery, mousetrap) {
|
||||
|
||||
function keyup(key, callback) {
|
||||
unbind(key);
|
||||
mousetrap.bind(key, callback, 'keyup');
|
||||
if (enabled) {
|
||||
mousetrap.bind(key, callback, 'keyup');
|
||||
}
|
||||
}
|
||||
|
||||
function keydown(key, callback) {
|
||||
unbind(key);
|
||||
mousetrap.bind(key, callback);
|
||||
if (enabled) {
|
||||
mousetrap.bind(key, callback);
|
||||
}
|
||||
}
|
||||
|
||||
function reset() {
|
||||
@ -53,4 +58,4 @@ App.Keyboard = function(jQuery, mousetrap) {
|
||||
};
|
||||
};
|
||||
|
||||
App.DI.register('keyboard', ['jQuery', 'mousetrap'], App.Keyboard);
|
||||
App.DI.register('keyboard', ['jQuery', 'mousetrap', 'browsingSettings'], App.Keyboard);
|
||||
|
@ -51,6 +51,7 @@ App.Presenters.UserBrowsingSettingsPresenter = function(
|
||||
sketchy: $el.find('[name=listSketchyPosts]').is(':checked'),
|
||||
unsafe: $el.find('[name=listUnsafePosts]').is(':checked'),
|
||||
},
|
||||
keyboardShortcuts: $el.find('[name=keyboardShortcuts]').is(':checked'),
|
||||
};
|
||||
|
||||
promise.wait(browsingSettings.setSettings(newSettings))
|
||||
|
Reference in New Issue
Block a user