diff --git a/public_html/css/post.css b/public_html/css/post.css index 17fb8779..c658cffd 100644 --- a/public_html/css/post.css +++ b/public_html/css/post.css @@ -269,9 +269,6 @@ background: lemonchiffon; border: 1px solid black; } -.post-note:hover .text-wrapper { - display: block; -} .post-note .text p:first-of-type { margin-top: 0; diff --git a/public_html/js/Presenters/PostNotesPresenter.js b/public_html/js/Presenters/PostNotesPresenter.js index 50f83baa..483f55ca 100644 --- a/public_html/js/Presenters/PostNotesPresenter.js +++ b/public_html/js/Presenters/PostNotesPresenter.js @@ -63,6 +63,8 @@ App.Presenters.PostNotesPresenter = function( postNote.$element = $postNote; draggable.makeDraggable($postNote, draggable.relativeDragStrategy, true); resizable.makeResizable($postNote, true); + $postNote.mouseenter(function() { postNoteMouseEnter(postNote); }); + $postNote.mouseleave(function() { postNoteMouseLeave(postNote); }); }); $form.find('button').click(formSubmitted); @@ -144,13 +146,25 @@ App.Presenters.PostNotesPresenter = function( } 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) { postNote.$element.find('.text-wrapper').css('display', ''); } + function postNoteMouseEnter(postNote) { + showPostNoteText(postNote); + } + + function postNoteMouseLeave(postNote) { + hidePostNoteText(postNote); + } + function postNoteClicked(e) { e.preventDefault(); var $postNote = jQuery(e.currentTarget).parents('.post-note');