Fixed bad arrows behavior while editing post notes
This commit is contained in:
parent
b416868aa7
commit
e7ea60f293
3 changed files with 55 additions and 51 deletions
|
@ -61,8 +61,8 @@ App.Presenters.PostNotesPresenter = function(
|
|||
$postNote.data('postNote', postNote);
|
||||
$postNote.find('.text-wrapper').click(postNoteClicked);
|
||||
postNote.$element = $postNote;
|
||||
draggable.makeDraggable($postNote, draggable.relativeDragStrategy);
|
||||
resizable.makeResizable($postNote);
|
||||
draggable.makeDraggable($postNote, draggable.relativeDragStrategy, true);
|
||||
resizable.makeResizable($postNote, true);
|
||||
});
|
||||
|
||||
$form.find('button').click(formSubmitted);
|
||||
|
@ -163,7 +163,7 @@ App.Presenters.PostNotesPresenter = function(
|
|||
$form.data('postNote', postNote);
|
||||
$form.find('textarea').val(postNote.text);
|
||||
$form.show();
|
||||
draggable.makeDraggable($form, draggable.absoluteDragStrategy);
|
||||
draggable.makeDraggable($form, draggable.absoluteDragStrategy, false);
|
||||
}
|
||||
|
||||
function hideForm() {
|
||||
|
|
|
@ -82,7 +82,7 @@ App.Util.Draggable = function(jQuery) {
|
|||
};
|
||||
}
|
||||
|
||||
function makeDraggable($element, dragStrategy) {
|
||||
function makeDraggable($element, dragStrategy, enableHotkeys) {
|
||||
var strategy = dragStrategy($element);
|
||||
$element.data('drag-strategy', strategy);
|
||||
|
||||
|
@ -108,31 +108,33 @@ App.Util.Draggable = function(jQuery) {
|
|||
});
|
||||
});
|
||||
|
||||
$element.keydown(function(e) {
|
||||
var position = strategy.getPosition();
|
||||
var oldPosition = {x: position.x, y: position.y};
|
||||
if (e.shiftKey) {
|
||||
return;
|
||||
}
|
||||
if (enableHotkeys) {
|
||||
$element.keydown(function(e) {
|
||||
var position = strategy.getPosition();
|
||||
var oldPosition = {x: position.x, y: position.y};
|
||||
if (e.shiftKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
var delta = e.ctrlKey ? 10 : 1;
|
||||
if (e.which === KEY_LEFT) {
|
||||
position.x -= delta;
|
||||
} else if (e.which === KEY_RIGHT) {
|
||||
position.x += delta;
|
||||
} else if (e.which === KEY_UP) {
|
||||
position.y -= delta;
|
||||
} else if (e.which === KEY_DOWN) {
|
||||
position.y += delta;
|
||||
}
|
||||
var delta = e.ctrlKey ? 10 : 1;
|
||||
if (e.which === KEY_LEFT) {
|
||||
position.x -= delta;
|
||||
} else if (e.which === KEY_RIGHT) {
|
||||
position.x += delta;
|
||||
} else if (e.which === KEY_UP) {
|
||||
position.y -= delta;
|
||||
} else if (e.which === KEY_DOWN) {
|
||||
position.y += delta;
|
||||
}
|
||||
|
||||
if (position.x !== oldPosition.x || position.y !== oldPosition.y) {
|
||||
e.stopPropagation();
|
||||
e.stopImmediatePropagation();
|
||||
e.preventDefault();
|
||||
strategy.setPosition(position.x, position.y);
|
||||
}
|
||||
});
|
||||
if (position.x !== oldPosition.x || position.y !== oldPosition.y) {
|
||||
e.stopPropagation();
|
||||
e.stopImmediatePropagation();
|
||||
e.preventDefault();
|
||||
strategy.setPosition(position.x, position.y);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
@ -48,7 +48,7 @@ App.Util.Resizable = function(jQuery) {
|
|||
};
|
||||
}
|
||||
|
||||
function makeResizable($element) {
|
||||
function makeResizable($element, enableHotkeys) {
|
||||
var $resizer = jQuery('<div class="resizer"></div>');
|
||||
var strategy = relativeResizeStrategy($element);
|
||||
$element.append($resizer);
|
||||
|
@ -72,31 +72,33 @@ App.Util.Resizable = function(jQuery) {
|
|||
});
|
||||
});
|
||||
|
||||
$element.keydown(function(e) {
|
||||
var size = strategy.getSize();
|
||||
var oldSize = {width: size.width, height: size.height};
|
||||
if (!e.shiftKey) {
|
||||
return;
|
||||
}
|
||||
if (enableHotkeys) {
|
||||
$element.keydown(function(e) {
|
||||
var size = strategy.getSize();
|
||||
var oldSize = {width: size.width, height: size.height};
|
||||
if (!e.shiftKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
var delta = e.ctrlKey ? 10 : 1;
|
||||
if (e.which === KEY_LEFT) {
|
||||
size.width -= delta;
|
||||
} else if (e.which === KEY_RIGHT) {
|
||||
size.width += delta;
|
||||
} else if (e.which === KEY_UP) {
|
||||
size.height -= delta;
|
||||
} else if (e.which === KEY_DOWN) {
|
||||
size.height += delta;
|
||||
}
|
||||
var delta = e.ctrlKey ? 10 : 1;
|
||||
if (e.which === KEY_LEFT) {
|
||||
size.width -= delta;
|
||||
} else if (e.which === KEY_RIGHT) {
|
||||
size.width += delta;
|
||||
} else if (e.which === KEY_UP) {
|
||||
size.height -= delta;
|
||||
} else if (e.which === KEY_DOWN) {
|
||||
size.height += delta;
|
||||
}
|
||||
|
||||
if (size.width !== oldSize.width || size.height !== oldSize.height) {
|
||||
e.stopPropagation();
|
||||
e.stopImmediatePropagation();
|
||||
e.preventDefault();
|
||||
strategy.setSize(size.width, size.height);
|
||||
}
|
||||
});
|
||||
if (size.width !== oldSize.width || size.height !== oldSize.height) {
|
||||
e.stopPropagation();
|
||||
e.stopImmediatePropagation();
|
||||
e.preventDefault();
|
||||
strategy.setSize(size.width, size.height);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
Loading…
Reference in a new issue