script(translate.js): dragging does not toggle original text.

This commit is contained in:
Zhimin YE (Rex) 2016-07-05 12:53:58 +01:00
parent 6fcde3f63f
commit 800f2e6439
1 changed files with 28 additions and 5 deletions

View File

@ -45,11 +45,34 @@ var sourceVisible = localStorage.getItem('source-visible') === 'true';
$prevNode.addClass('hidden'); $prevNode.addClass('hidden');
} }
if (!isLink(node) && !isButton(node)) { if (!isLink(node) && !isButton(node)) {
$node.on('click', function () { var isDragging = false;
$prevNode.toggleClass('hidden'); $node.on('mousedown', function(){
$(window).on('mousemove', function(){
isDragging = true;
$(window).unbind('mousemove');
}); });
$prevNode.on('click', function () { });
$prevNode.on('mousedown', function(){
$(window).on('mousemove', function(){
isDragging = true;
$(window).unbind('mousemove');
});
});
$node.on('mouseup', function () {
var wasDragging = isDragging;
isDragging = false;
$(window).unbind('mousemove');
if(!wasDragging){
$prevNode.toggleClass('hidden');
}
});
$prevNode.on('mouseup', function () {
var wasDragging = isDragging;
isDragging = false;
$(window).unbind('mousemove');
if(!wasDragging){
$prevNode.addClass('hidden'); $prevNode.addClass('hidden');
}
}); });
} }
$node.after($prevNode); $node.after($prevNode);