This commit is contained in:
Toks
2013-08-29 21:28:10 -04:00

View File

@@ -469,6 +469,7 @@ Danbooru.Note = {
Danbooru.Note.TranslationMode.active = true; Danbooru.Note.TranslationMode.active = true;
$(document.body).addClass("mode-translation"); $(document.body).addClass("mode-translation");
$("#original-file-link").click(); $("#original-file-link").click();
$("#image").unbind("click", Danbooru.Note.Box.toggle_all);
$("#image").bind("mousedown", Danbooru.Note.TranslationMode.Drag.start); $("#image").bind("mousedown", Danbooru.Note.TranslationMode.Drag.start);
$(window).bind("mouseup", Danbooru.Note.TranslationMode.Drag.stop); $(window).bind("mouseup", Danbooru.Note.TranslationMode.Drag.stop);
@@ -482,6 +483,7 @@ Danbooru.Note = {
stop: function() { stop: function() {
Danbooru.Note.TranslationMode.active = false; Danbooru.Note.TranslationMode.active = false;
$("#image").css("cursor", "auto"); $("#image").css("cursor", "auto");
$("#image").bind("click", Danbooru.Note.Box.toggle_all);
$("#image").unbind("mousedown", Danbooru.Note.TranslationMode.Drag.start); $("#image").unbind("mousedown", Danbooru.Note.TranslationMode.Drag.start);
$(window).unbind("mouseup", Danbooru.Note.TranslationMode.Drag.stop); $(window).unbind("mouseup", Danbooru.Note.TranslationMode.Drag.stop);
$(document.body).removeClass("mode-translation"); $(document.body).removeClass("mode-translation");
@@ -503,10 +505,6 @@ Danbooru.Note = {
$("#note-container").css('visibility', 'visible'); $("#note-container").css('visibility', 'visible');
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: {
@@ -596,7 +594,7 @@ Danbooru.Note = {
Danbooru.Note.TranslationMode.create_note(e, Danbooru.Note.TranslationMode.Drag.x, Danbooru.Note.TranslationMode.Drag.y, Danbooru.Note.TranslationMode.Drag.w-1, Danbooru.Note.TranslationMode.Drag.h-1); Danbooru.Note.TranslationMode.create_note(e, Danbooru.Note.TranslationMode.Drag.x, Danbooru.Note.TranslationMode.Drag.y, Danbooru.Note.TranslationMode.Drag.w-1, Danbooru.Note.TranslationMode.Drag.h-1);
Danbooru.Note.TranslationMode.Drag.dragging = false; /* border of the note is pixel-perfect on the preview border */ Danbooru.Note.TranslationMode.Drag.dragging = false; /* border of the note is pixel-perfect on the preview border */
} else { /* no dragging -> toggle display of notes */ } else { /* no dragging -> toggle display of notes */
Danbooru.Note.toggle_all(); Danbooru.Note.Box.toggle_all();
} }
Danbooru.Note.TranslationMode.Drag.dragStartX = 0; Danbooru.Note.TranslationMode.Drag.dragStartX = 0;
@@ -610,7 +608,6 @@ Danbooru.Note = {
editing: false, editing: false,
timeouts: [], timeouts: [],
pending: {}, pending: {},
ignore_click_until: 0,
add: function(container, id, x, y, w, h, text) { add: function(container, id, x, y, w, h, text) {
var $note_box = Danbooru.Note.Box.create(id); var $note_box = Danbooru.Note.Box.create(id);
@@ -677,11 +674,6 @@ $(function() {
$(document).bind("keypress", "n", Danbooru.Note.TranslationMode.toggle); $(document).bind("keypress", "n", Danbooru.Note.TranslationMode.toggle);
} }
Danbooru.Note.load_all(); Danbooru.Note.load_all();
$("#image").click(function(e) { $("#image").bind("click", Danbooru.Note.Box.toggle_all);
// Ignore the click event when adding a note
if ((new Date).getTime() >= Danbooru.Note.ignore_click_until) {
Danbooru.Note.Box.toggle_all();
}
});
} }
}); });