Thanks for the plugin - small improvement to the position handling

This discussion is related to the MentionsLookup addon.
edited April 2013 in Feedback

Instead of roughly trying to calculate the selection box position, I used jquery-caret-position-getter (https://github.com/beviz/jquery-caret-position-getter) which will actually place the window below the caret is.

in default.php add (inside LoadLookup function):
$Sender->AddJsFile($this->GetResource('js/jquery.caretposition.js', FALSE, FALSE));

Then in the js/query.js replace all the textarea position handling with:

var caretpos = $(context).getCaretPosition();
var boxleft = $(context).offset().left+caretpos.left;
var boxtop = $(context).offset().top+caretpos.top;
$('.MentionsLookup').css({'left':boxleft,'top':boxtop});
UnderDogSrggamer50sQuiff

Comments

  • I will bare this in mind for a later date.

    I'd probably do my own you have rangy to get the caret position (in order not to replicate), and then use some of these methods to get the offset.

    grep is your friend.

    UnderDogSrggamer
Sign In or Register to comment.