hotkeys: refactor to use .on(), namespaces.

* Use .on() instead of .bind() because bind is deprecated in jquery 3.0.
* Ensure enable-js-navigation is always respected.
* Namespace keybindings so they may be disabled by userscripts with
  e.g. $(document).off("keydown.danbooru") or $(document).off("next_page").
This commit is contained in:
evazion
2017-01-24 00:19:38 -06:00
parent 6430a9b0a4
commit c3fa653fc5
10 changed files with 61 additions and 85 deletions

View File

@@ -45,6 +45,12 @@
}
}
Danbooru.keydown = function(keys, namespace, handler) {
if (Danbooru.meta("enable-js-navigation") === "true") {
$(document).on("keydown" + ".danbooru." + namespace, null, keys, handler);
}
};
Danbooru.is_subset = function(array, subarray) {
var all = true;