Fixed bad arrows behavior while editing post notes

This commit is contained in:
Marcin Kurczewski 2015-02-22 19:30:07 +01:00
parent b416868aa7
commit e7ea60f293
3 changed files with 55 additions and 51 deletions

View file

@ -61,8 +61,8 @@ App.Presenters.PostNotesPresenter = function(
$postNote.data('postNote', postNote); $postNote.data('postNote', postNote);
$postNote.find('.text-wrapper').click(postNoteClicked); $postNote.find('.text-wrapper').click(postNoteClicked);
postNote.$element = $postNote; postNote.$element = $postNote;
draggable.makeDraggable($postNote, draggable.relativeDragStrategy); draggable.makeDraggable($postNote, draggable.relativeDragStrategy, true);
resizable.makeResizable($postNote); resizable.makeResizable($postNote, true);
}); });
$form.find('button').click(formSubmitted); $form.find('button').click(formSubmitted);
@ -163,7 +163,7 @@ App.Presenters.PostNotesPresenter = function(
$form.data('postNote', postNote); $form.data('postNote', postNote);
$form.find('textarea').val(postNote.text); $form.find('textarea').val(postNote.text);
$form.show(); $form.show();
draggable.makeDraggable($form, draggable.absoluteDragStrategy); draggable.makeDraggable($form, draggable.absoluteDragStrategy, false);
} }
function hideForm() { function hideForm() {

View file

@ -82,7 +82,7 @@ App.Util.Draggable = function(jQuery) {
}; };
} }
function makeDraggable($element, dragStrategy) { function makeDraggable($element, dragStrategy, enableHotkeys) {
var strategy = dragStrategy($element); var strategy = dragStrategy($element);
$element.data('drag-strategy', strategy); $element.data('drag-strategy', strategy);
@ -108,6 +108,7 @@ App.Util.Draggable = function(jQuery) {
}); });
}); });
if (enableHotkeys) {
$element.keydown(function(e) { $element.keydown(function(e) {
var position = strategy.getPosition(); var position = strategy.getPosition();
var oldPosition = {x: position.x, y: position.y}; var oldPosition = {x: position.x, y: position.y};
@ -134,6 +135,7 @@ App.Util.Draggable = function(jQuery) {
} }
}); });
} }
}
return { return {
makeDraggable: makeDraggable, makeDraggable: makeDraggable,

View file

@ -48,7 +48,7 @@ App.Util.Resizable = function(jQuery) {
}; };
} }
function makeResizable($element) { function makeResizable($element, enableHotkeys) {
var $resizer = jQuery('<div class="resizer"></div>'); var $resizer = jQuery('<div class="resizer"></div>');
var strategy = relativeResizeStrategy($element); var strategy = relativeResizeStrategy($element);
$element.append($resizer); $element.append($resizer);
@ -72,6 +72,7 @@ App.Util.Resizable = function(jQuery) {
}); });
}); });
if (enableHotkeys) {
$element.keydown(function(e) { $element.keydown(function(e) {
var size = strategy.getSize(); var size = strategy.getSize();
var oldSize = {width: size.width, height: size.height}; var oldSize = {width: size.width, height: size.height};
@ -98,6 +99,7 @@ App.Util.Resizable = function(jQuery) {
} }
}); });
} }
}
return { return {
makeResizable: makeResizable, makeResizable: makeResizable,