fix #1852
This commit is contained in:
@@ -772,7 +772,7 @@ $(function() {
|
|||||||
if ($("#c-posts").length && $("#a-show").length && $("#image").length && !$("video#image").length) {
|
if ($("#c-posts").length && $("#a-show").length && $("#image").length && !$("video#image").length) {
|
||||||
if ($("#note-locked-notice").length == 0) {
|
if ($("#note-locked-notice").length == 0) {
|
||||||
$("#translate").bind("click", Danbooru.Note.TranslationMode.toggle);
|
$("#translate").bind("click", Danbooru.Note.TranslationMode.toggle);
|
||||||
$(document).bind("keypress", "n", Danbooru.Note.TranslationMode.toggle);
|
$(document).bind("keydown", "n", Danbooru.Note.TranslationMode.toggle);
|
||||||
}
|
}
|
||||||
Danbooru.Note.embed = (Danbooru.meta("post-has-embedded-notes") === "true");
|
Danbooru.Note.embed = (Danbooru.meta("post-has-embedded-notes") === "true");
|
||||||
Danbooru.Note.load_all();
|
Danbooru.Note.load_all();
|
||||||
|
|||||||
@@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
if ($(".paginator").length && (Danbooru.meta("enable-js-navigation") === "true")) {
|
if ($(".paginator").length && (Danbooru.meta("enable-js-navigation") === "true")) {
|
||||||
$(document).bind("keypress", "d", Danbooru.Paginator.next_page);
|
$(document).bind("keydown", "d", Danbooru.Paginator.next_page);
|
||||||
$(document).bind("keypress", "a", Danbooru.Paginator.prev_page);
|
$(document).bind("keydown", "a", Danbooru.Paginator.prev_page);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
Danbooru.PostModeMenu.initialize_shortcuts = function() {
|
Danbooru.PostModeMenu.initialize_shortcuts = function() {
|
||||||
$(document).bind("keypress", "1 2 3 4 5 6 7 8 9 0", Danbooru.PostModeMenu.change_tag_script);
|
$(document).bind("keydown", "1 2 3 4 5 6 7 8 9 0", Danbooru.PostModeMenu.change_tag_script);
|
||||||
}
|
}
|
||||||
|
|
||||||
Danbooru.PostModeMenu.show_notice = function(i) {
|
Danbooru.PostModeMenu.show_notice = function(i) {
|
||||||
|
|||||||
@@ -22,12 +22,12 @@
|
|||||||
Danbooru.PostPopular.initialize_all = function() {
|
Danbooru.PostPopular.initialize_all = function() {
|
||||||
if ($("#c-explore-posts").length) {
|
if ($("#c-explore-posts").length) {
|
||||||
if (Danbooru.meta("enable-js-navigation") === "true") {
|
if (Danbooru.meta("enable-js-navigation") === "true") {
|
||||||
$(document).bind("keypress", "a", function(e) {
|
$(document).bind("keydown", "a", function(e) {
|
||||||
Danbooru.PostPopular.nav_prev();
|
Danbooru.PostPopular.nav_prev();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).bind("keypress", "d", function(e) {
|
$(document).bind("keydown", "d", function(e) {
|
||||||
Danbooru.PostPopular.nav_next();
|
Danbooru.PostPopular.nav_next();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -169,23 +169,23 @@
|
|||||||
|
|
||||||
Danbooru.Post.initialize_shortcuts = function() {
|
Danbooru.Post.initialize_shortcuts = function() {
|
||||||
if ($("#a-show").length) {
|
if ($("#a-show").length) {
|
||||||
$(document).bind("keypress", "e", function(e) {
|
$(document).bind("keydown", "e", function(e) {
|
||||||
$("#post-edit-link").trigger("click");
|
$("#post-edit-link").trigger("click");
|
||||||
$("#post_tag_string").focus();
|
$("#post_tag_string").focus();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).bind("keypress", "a", function(e) {
|
$(document).bind("keydown", "a", function(e) {
|
||||||
Danbooru.Post.nav_prev();
|
Danbooru.Post.nav_prev();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).bind("keypress", "d", function(e) {
|
$(document).bind("keydown", "d", function(e) {
|
||||||
Danbooru.Post.nav_next();
|
Danbooru.Post.nav_next();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).bind("keypress", "f", function(e) {
|
$(document).bind("keydown", "f", function(e) {
|
||||||
if ($("#add-to-favorites").is(":visible")) {
|
if ($("#add-to-favorites").is(":visible")) {
|
||||||
$("#add-to-favorites").click();
|
$("#add-to-favorites").click();
|
||||||
} else {
|
} else {
|
||||||
@@ -322,7 +322,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
if ($("#image-resize-notice").length && Danbooru.meta("enable-js-navigation") === "true") {
|
if ($("#image-resize-notice").length && Danbooru.meta("enable-js-navigation") === "true") {
|
||||||
$(document).bind("keypress", "v", function(e) {
|
$(document).bind("keydown", "v", function(e) {
|
||||||
if ($("#image-resize-notice").is(":visible")) {
|
if ($("#image-resize-notice").is(":visible")) {
|
||||||
$("#image-resize-link").click();
|
$("#image-resize-link").click();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2,21 +2,21 @@
|
|||||||
Danbooru.Shortcuts = {};
|
Danbooru.Shortcuts = {};
|
||||||
|
|
||||||
Danbooru.Shortcuts.initialize = function() {
|
Danbooru.Shortcuts.initialize = function() {
|
||||||
$(document).bind("keypress", "s", function(e) {
|
$(document).bind("keydown", "s", function(e) {
|
||||||
Danbooru.Shortcuts.nav_scroll_down();
|
Danbooru.Shortcuts.nav_scroll_down();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).bind("keypress", "w", function(e) {
|
$(document).bind("keydown", "w", function(e) {
|
||||||
Danbooru.Shortcuts.nav_scroll_up();
|
Danbooru.Shortcuts.nav_scroll_up();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).bind("keypress", "q", function(e) {
|
$(document).bind("keydown", "q", function(e) {
|
||||||
$("#tags, #search_name, #search_name_matches, #query").trigger("focus").selectEnd();
|
$("#tags, #search_name, #search_name_matches, #query").trigger("focus").selectEnd();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($("#image").length) { // post page or bookmarklet upload page
|
if ($("#image").length) { // post page or bookmarklet upload page
|
||||||
$(document).bind("keypress", "shift+e", function(e) {
|
$(document).bind("keydown", "shift+e", function(e) {
|
||||||
if (!$("#edit-dialog").length) {
|
if (!$("#edit-dialog").length) {
|
||||||
$("#edit").show();
|
$("#edit").show();
|
||||||
$("#comments").hide();
|
$("#comments").hide();
|
||||||
@@ -32,17 +32,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($("#c-posts").length && $("#a-show").length) {
|
if ($("#c-posts").length && $("#a-show").length) {
|
||||||
$(document).bind("keypress", "shift+o", function(e) {
|
$(document).bind("keydown", "shift+o", function(e) {
|
||||||
Danbooru.Post.approve(Danbooru.meta("post-id"));
|
Danbooru.Post.approve(Danbooru.meta("post-id"));
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).bind("keypress", "r", function(e) {
|
$(document).bind("keydown", "r", function(e) {
|
||||||
$("#random-post")[0].click();
|
$("#random-post")[0].click();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($("#c-posts").length && $("#a-index").length) {
|
if ($("#c-posts").length && $("#a-index").length) {
|
||||||
$(document).bind("keypress", "r", function(e) {
|
$(document).bind("keydown", "r", function(e) {
|
||||||
$("#random-post")[0].click();
|
$("#random-post")[0].click();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
|
|
||||||
Danbooru.WikiPage.initialize_shortcuts = function() {
|
Danbooru.WikiPage.initialize_shortcuts = function() {
|
||||||
if ($("#a-show").length) {
|
if ($("#a-show").length) {
|
||||||
$(document).bind("keypress", "e", function(e) {
|
$(document).bind("keydown", "e", function(e) {
|
||||||
$("#wiki-page-edit-link")[0].click();
|
$("#wiki-page-edit-link")[0].click();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|||||||
257
vendor/assets/javascripts/jquery.hotkeys.js
vendored
257
vendor/assets/javascripts/jquery.hotkeys.js
vendored
@@ -1,111 +1,204 @@
|
|||||||
|
/*jslint browser: true*/
|
||||||
|
/*jslint jquery: true*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* jQuery Hotkeys Plugin
|
* jQuery Hotkeys Plugin
|
||||||
* Copyright 2010, John Resig
|
* Copyright 2010, John Resig
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||||
*
|
*
|
||||||
* Based upon the plugin by Tzury Bar Yochay:
|
* Based upon the plugin by Tzury Bar Yochay:
|
||||||
* http://github.com/tzuryby/hotkeys
|
* https://github.com/tzuryby/jquery.hotkeys
|
||||||
*
|
*
|
||||||
* Original idea by:
|
* Original idea by:
|
||||||
* Binny V A, http://www.openjs.com/scripts/events/keyboard_shortcuts/
|
* Binny V A, http://www.openjs.com/scripts/events/keyboard_shortcuts/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* One small change is: now keys are passed by object { keys: '...' }
|
* One small change is: now keys are passed by object { keys: '...' }
|
||||||
* Might be useful, when you want to pass some other data to your handler
|
* Might be useful, when you want to pass some other data to your handler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function(jQuery){
|
(function(jQuery) {
|
||||||
|
|
||||||
jQuery.hotkeys = {
|
|
||||||
version: "0.8",
|
|
||||||
|
|
||||||
specialKeys: {
|
jQuery.hotkeys = {
|
||||||
8: "backspace", 9: "tab", 10: "return", 13: "return", 16: "shift", 17: "ctrl", 18: "alt", 19: "pause",
|
version: "0.8",
|
||||||
20: "capslock", 27: "esc", 32: "space", 33: "pageup", 34: "pagedown", 35: "end", 36: "home",
|
|
||||||
37: "left", 38: "up", 39: "right", 40: "down", 45: "insert", 46: "del",
|
|
||||||
96: "0", 97: "1", 98: "2", 99: "3", 100: "4", 101: "5", 102: "6", 103: "7",
|
|
||||||
104: "8", 105: "9", 106: "*", 107: "+", 109: "-", 110: ".", 111 : "/",
|
|
||||||
112: "f1", 113: "f2", 114: "f3", 115: "f4", 116: "f5", 117: "f6", 118: "f7", 119: "f8",
|
|
||||||
120: "f9", 121: "f10", 122: "f11", 123: "f12", 144: "numlock", 145: "scroll", 186: ";", 191: "/",
|
|
||||||
220: "\\", 222: "'", 224: "meta"
|
|
||||||
},
|
|
||||||
|
|
||||||
shiftNums: {
|
|
||||||
"`": "~", "1": "!", "2": "@", "3": "#", "4": "$", "5": "%", "6": "^", "7": "&",
|
|
||||||
"8": "*", "9": "(", "0": ")", "-": "_", "=": "+", ";": ": ", "'": "\"", ",": "<",
|
|
||||||
".": ">", "/": "?", "\\": "|"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function keyHandler( handleObj ) {
|
specialKeys: {
|
||||||
if ( typeof handleObj.data === "string" ) {
|
8: "backspace",
|
||||||
handleObj.data = { keys: handleObj.data };
|
9: "tab",
|
||||||
}
|
10: "return",
|
||||||
|
13: "return",
|
||||||
|
16: "shift",
|
||||||
|
17: "ctrl",
|
||||||
|
18: "alt",
|
||||||
|
19: "pause",
|
||||||
|
20: "capslock",
|
||||||
|
27: "esc",
|
||||||
|
32: "space",
|
||||||
|
33: "pageup",
|
||||||
|
34: "pagedown",
|
||||||
|
35: "end",
|
||||||
|
36: "home",
|
||||||
|
37: "left",
|
||||||
|
38: "up",
|
||||||
|
39: "right",
|
||||||
|
40: "down",
|
||||||
|
45: "insert",
|
||||||
|
46: "del",
|
||||||
|
59: ";",
|
||||||
|
61: "=",
|
||||||
|
96: "0",
|
||||||
|
97: "1",
|
||||||
|
98: "2",
|
||||||
|
99: "3",
|
||||||
|
100: "4",
|
||||||
|
101: "5",
|
||||||
|
102: "6",
|
||||||
|
103: "7",
|
||||||
|
104: "8",
|
||||||
|
105: "9",
|
||||||
|
106: "*",
|
||||||
|
107: "+",
|
||||||
|
109: "-",
|
||||||
|
110: ".",
|
||||||
|
111: "/",
|
||||||
|
112: "f1",
|
||||||
|
113: "f2",
|
||||||
|
114: "f3",
|
||||||
|
115: "f4",
|
||||||
|
116: "f5",
|
||||||
|
117: "f6",
|
||||||
|
118: "f7",
|
||||||
|
119: "f8",
|
||||||
|
120: "f9",
|
||||||
|
121: "f10",
|
||||||
|
122: "f11",
|
||||||
|
123: "f12",
|
||||||
|
144: "numlock",
|
||||||
|
145: "scroll",
|
||||||
|
173: "-",
|
||||||
|
186: ";",
|
||||||
|
187: "=",
|
||||||
|
188: ",",
|
||||||
|
189: "-",
|
||||||
|
190: ".",
|
||||||
|
191: "/",
|
||||||
|
192: "`",
|
||||||
|
219: "[",
|
||||||
|
220: "\\",
|
||||||
|
221: "]",
|
||||||
|
222: "'"
|
||||||
|
},
|
||||||
|
|
||||||
// Only care when a possible input has been specified
|
shiftNums: {
|
||||||
if ( !handleObj.data || !handleObj.data.keys || typeof handleObj.data.keys !== "string" ) {
|
"`": "~",
|
||||||
return;
|
"1": "!",
|
||||||
}
|
"2": "@",
|
||||||
|
"3": "#",
|
||||||
|
"4": "$",
|
||||||
|
"5": "%",
|
||||||
|
"6": "^",
|
||||||
|
"7": "&",
|
||||||
|
"8": "*",
|
||||||
|
"9": "(",
|
||||||
|
"0": ")",
|
||||||
|
"-": "_",
|
||||||
|
"=": "+",
|
||||||
|
";": ": ",
|
||||||
|
"'": "\"",
|
||||||
|
",": "<",
|
||||||
|
".": ">",
|
||||||
|
"/": "?",
|
||||||
|
"\\": "|"
|
||||||
|
},
|
||||||
|
|
||||||
var origHandler = handleObj.handler,
|
// excludes: button, checkbox, file, hidden, image, password, radio, reset, search, submit, url
|
||||||
keys = handleObj.data.keys.toLowerCase().split(" "),
|
textAcceptingInputTypes: [
|
||||||
textAcceptingInputTypes = ["text", "password", "number", "email", "url", "range", "date", "month", "week", "time", "datetime", "datetime-local", "search", "color", "tel"];
|
"text", "password", "number", "email", "url", "range", "date", "month", "week", "time", "datetime",
|
||||||
|
"datetime-local", "search", "color", "tel"],
|
||||||
handleObj.handler = function( event ) {
|
|
||||||
// Don't fire in text-accepting inputs that we didn't directly bind to
|
|
||||||
if ( this !== event.target && (/textarea|select/i.test( event.target.nodeName ) ||
|
|
||||||
jQuery.inArray(event.target.type, textAcceptingInputTypes) > -1 ) ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var special = jQuery.hotkeys.specialKeys[ event.keyCode ],
|
// default input types not to bind to unless bound directly
|
||||||
// character codes are available only in keypress
|
textInputTypes: /textarea|input|select/i,
|
||||||
character = event.type === "keypress" && String.fromCharCode( event.which ).toLowerCase(),
|
|
||||||
modif = "", possible = {};
|
|
||||||
|
|
||||||
// check combinations (alt|ctrl|shift+anything)
|
options: {
|
||||||
if ( event.altKey && special !== "alt" ) {
|
filterInputAcceptingElements: true,
|
||||||
modif += "alt+";
|
filterTextInputs: true,
|
||||||
}
|
filterContentEditable: true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if ( event.ctrlKey && special !== "ctrl" ) {
|
function keyHandler(handleObj) {
|
||||||
modif += "ctrl+";
|
if (typeof handleObj.data === "string") {
|
||||||
}
|
handleObj.data = {
|
||||||
|
keys: handleObj.data
|
||||||
// TODO: Need to make sure this works consistently across platforms
|
};
|
||||||
if ( event.metaKey && !event.ctrlKey && special !== "meta" ) {
|
}
|
||||||
modif += "meta+";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( event.shiftKey && special !== "shift" ) {
|
// Only care when a possible input has been specified
|
||||||
modif += "shift+";
|
if (!handleObj.data || !handleObj.data.keys || typeof handleObj.data.keys !== "string") {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( special ) {
|
var origHandler = handleObj.handler,
|
||||||
possible[ modif + special ] = true;
|
keys = handleObj.data.keys.toLowerCase().split(" ");
|
||||||
}
|
|
||||||
|
|
||||||
if ( character ) {
|
handleObj.handler = function(event) {
|
||||||
possible[ modif + character ] = true;
|
// Don't fire in text-accepting inputs that we didn't directly bind to
|
||||||
possible[ modif + jQuery.hotkeys.shiftNums[ character ] ] = true;
|
if (this !== event.target &&
|
||||||
|
(jQuery.hotkeys.options.filterInputAcceptingElements &&
|
||||||
|
jQuery.hotkeys.textInputTypes.test(event.target.nodeName) ||
|
||||||
|
(jQuery.hotkeys.options.filterContentEditable && jQuery(event.target).attr('contenteditable')) ||
|
||||||
|
(jQuery.hotkeys.options.filterTextInputs &&
|
||||||
|
jQuery.inArray(event.target.type, jQuery.hotkeys.textAcceptingInputTypes) > -1))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// "$" can be triggered as "Shift+4" or "Shift+$" or just "$"
|
var special = event.type !== "keypress" && jQuery.hotkeys.specialKeys[event.which],
|
||||||
if ( modif === "shift+" ) {
|
character = String.fromCharCode(event.which).toLowerCase(),
|
||||||
possible[ jQuery.hotkeys.shiftNums[ character ] ] = true;
|
modif = "",
|
||||||
}
|
possible = {};
|
||||||
}
|
|
||||||
|
|
||||||
for ( var i = 0, l = keys.length; i < l; i++ ) {
|
jQuery.each(["alt", "ctrl", "shift"], function(index, specialKey) {
|
||||||
if ( possible[ keys[i] ] ) {
|
|
||||||
return origHandler.apply( this, arguments );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
jQuery.each([ "keydown", "keyup", "keypress" ], function() {
|
if (event[specialKey + 'Key'] && special !== specialKey) {
|
||||||
jQuery.event.special[ this ] = { add: keyHandler };
|
modif += specialKey + '+';
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
})( this.jQuery );
|
// metaKey is triggered off ctrlKey erronously
|
||||||
|
if (event.metaKey && !event.ctrlKey && special !== "meta") {
|
||||||
|
modif += "meta+";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.metaKey && special !== "meta" && modif.indexOf("alt+ctrl+shift+") > -1) {
|
||||||
|
modif = modif.replace("alt+ctrl+shift+", "hyper+");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (special) {
|
||||||
|
possible[modif + special] = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
possible[modif + character] = true;
|
||||||
|
possible[modif + jQuery.hotkeys.shiftNums[character]] = true;
|
||||||
|
|
||||||
|
// "$" can be triggered as "Shift+4" or "Shift+$" or just "$"
|
||||||
|
if (modif === "shift+") {
|
||||||
|
possible[jQuery.hotkeys.shiftNums[character]] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0, l = keys.length; i < l; i++) {
|
||||||
|
if (possible[keys[i]]) {
|
||||||
|
return origHandler.apply(this, arguments);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
jQuery.each(["keydown", "keyup", "keypress"], function() {
|
||||||
|
jQuery.event.special[this] = {
|
||||||
|
add: keyHandler
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
})(jQuery || this.jQuery || window.jQuery);
|
||||||
|
|||||||
Reference in New Issue
Block a user