Ignore click event when adding note
Instead of double-toggling, ignore click events for some milliseconds after adding a note.
This commit is contained in:
@@ -107,6 +107,10 @@ Danbooru.Note = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
toggle_all: function() {
|
toggle_all: function() {
|
||||||
|
// Ignore the click event when adding a note
|
||||||
|
if ((new Date).getTime() < Danbooru.Note.ignore_click_until) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$(".note-box").toggle();
|
$(".note-box").toggle();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -419,7 +423,6 @@ Danbooru.Note = {
|
|||||||
|
|
||||||
Danbooru.Note.TranslationMode.active = true;
|
Danbooru.Note.TranslationMode.active = true;
|
||||||
$("#original-file-link").click();
|
$("#original-file-link").click();
|
||||||
$("#image").one("click", function() { $(".note-box").show() }); /* override the 'hide all note boxes' click event */
|
|
||||||
$("#image").one("mousedown", Danbooru.Note.TranslationMode.Drag.start);
|
$("#image").one("mousedown", Danbooru.Note.TranslationMode.Drag.start);
|
||||||
$(window).bind("mouseup", Danbooru.Note.TranslationMode.Drag.stop);
|
$(window).bind("mouseup", Danbooru.Note.TranslationMode.Drag.stop);
|
||||||
Danbooru.notice('Click or drag on the image to create a note (shortcut is <span class="key">n</span>)');
|
Danbooru.notice('Click or drag on the image to create a note (shortcut is <span class="key">n</span>)');
|
||||||
@@ -444,6 +447,10 @@ Danbooru.Note = {
|
|||||||
$(".note-box").show();
|
$(".note-box").show();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
// Hack to ignore clicks for some milliseconds
|
||||||
|
// The mouseup event is executed before the click event, so it's hard to do this properly
|
||||||
|
Danbooru.Note.ignore_click_until = (new Date).getTime() + 200;
|
||||||
},
|
},
|
||||||
|
|
||||||
Drag: {
|
Drag: {
|
||||||
@@ -541,6 +548,7 @@ Danbooru.Note = {
|
|||||||
editing: false,
|
editing: false,
|
||||||
timeouts: [],
|
timeouts: [],
|
||||||
pending: {},
|
pending: {},
|
||||||
|
ignore_click_until: 0,
|
||||||
|
|
||||||
add: function(id, x, y, w, h, text) {
|
add: function(id, x, y, w, h, text) {
|
||||||
var $note_box = Danbooru.Note.Box.create(id);
|
var $note_box = Danbooru.Note.Box.create(id);
|
||||||
|
|||||||
Reference in New Issue
Block a user