Fixed notes disappearing off the screen

This commit is contained in:
rr- 2015-12-24 20:59:39 +01:00
parent e623513e3d
commit 92631df9a4
2 changed files with 15 additions and 4 deletions

View file

@ -269,9 +269,6 @@
background: lemonchiffon; background: lemonchiffon;
border: 1px solid black; border: 1px solid black;
} }
.post-note:hover .text-wrapper {
display: block;
}
.post-note .text p:first-of-type { .post-note .text p:first-of-type {
margin-top: 0; margin-top: 0;

View file

@ -63,6 +63,8 @@ App.Presenters.PostNotesPresenter = function(
postNote.$element = $postNote; postNote.$element = $postNote;
draggable.makeDraggable($postNote, draggable.relativeDragStrategy, true); draggable.makeDraggable($postNote, draggable.relativeDragStrategy, true);
resizable.makeResizable($postNote, true); resizable.makeResizable($postNote, true);
$postNote.mouseenter(function() { postNoteMouseEnter(postNote); });
$postNote.mouseleave(function() { postNoteMouseLeave(postNote); });
}); });
$form.find('button').click(formSubmitted); $form.find('button').click(formSubmitted);
@ -144,13 +146,25 @@ App.Presenters.PostNotesPresenter = function(
} }
function showPostNoteText(postNote) { function showPostNoteText(postNote) {
postNote.$element.find('.text-wrapper').show(); var $textWrapper = postNote.$element.find('.text-wrapper');
$textWrapper.show();
if ($textWrapper.offset().left + $textWrapper.width() > jQuery(window).outerWidth()) {
$textWrapper.offset({left: jQuery(window).outerWidth() - $textWrapper.width()});
}
} }
function hidePostNoteText(postNote) { function hidePostNoteText(postNote) {
postNote.$element.find('.text-wrapper').css('display', ''); postNote.$element.find('.text-wrapper').css('display', '');
} }
function postNoteMouseEnter(postNote) {
showPostNoteText(postNote);
}
function postNoteMouseLeave(postNote) {
hidePostNoteText(postNote);
}
function postNoteClicked(e) { function postNoteClicked(e) {
e.preventDefault(); e.preventDefault();
var $postNote = jQuery(e.currentTarget).parents('.post-note'); var $postNote = jQuery(e.currentTarget).parents('.post-note');