don't saveBoard on trivial note drags

This commit is contained in:
Alex Pankratov
2021-03-30 10:31:28 +02:00
parent dde0f6e4a6
commit 6fa42cc86a

View File

@@ -2202,9 +2202,18 @@
/* /*
* this should *really* be in a separate file * this should *really* be in a separate file
*/ */
function noteLocation($item)
{
var loc = 0;
for (var $p = $item.closest('.note'); $p.length; $p = $p.prev(), loc += 1);
for (var $p = $item.closest('.list'); $p.length; $p = $p.prev(), loc += 10000);
return loc;
}
function Drag() function Drag()
{ {
this.item = null; // .text of .note this.item = null; // .text of .note
this.org_log = 0; // original noteLocation();
this.priming = null; this.priming = null;
this.primexy = { x: 0, y: 0 }; this.primexy = { x: 0, y: 0 };
this.$drag = null; this.$drag = null;
@@ -2253,6 +2262,8 @@
var $note = $text.parent(); var $note = $text.parent();
$note.addClass('dragging'); $note.addClass('dragging');
this.org_log = noteLocation($note);
$('body').append('<div class=dragster></div>'); $('body').append('<div class=dragster></div>');
var $drag = $('body .dragster').last(); var $drag = $('body .dragster').last();
@@ -2418,7 +2429,6 @@
$have.animate({ height: 0 }, 'fast', function(){ $have.animate({ height: 0 }, 'fast', function(){
$have.remove(); $have.remove();
$want.css({ marginTop: 5 }); $want.css({ marginTop: 5 });
// saveBoard();
}); });
$want.css({ display: 'block', height: 0, marginTop: 0 }); $want.css({ display: 'block', height: 0, marginTop: 0 });
@@ -2451,7 +2461,11 @@
this.stopDragging = function() this.stopDragging = function()
{ {
$(this.item).parent().removeClass('dragging'); var $text = $(this.item);
var $note = $text.parent();
$note.addClass('dragging');
$note.removeClass('dragging');
$('body').removeClass('dragging'); $('body').removeClass('dragging');
if (this.$drag) if (this.$drag)
@@ -2463,6 +2477,9 @@
else if (document.selection) { document.selection.empty(); } else if (document.selection) { document.selection.empty(); }
} }
if (noteLocation($note) != this.org_log)
saveBoard();
this.item = null; this.item = null;
} }
} }