huffpostlabs/highlighter.js — pull request #6 by jamienk (2014-03-24 02:39:51+00:00)
Title: Make popup be centered, not right

This popup always came up to the right because a (used to calculate position) was only inserted at the end. This code also puts a at the beginning of the selection, so we can find the center. (I think this was hard because, in order to put a span at the beginning, the selection needs to be collapsed and we thus loose the selection. But this pull req restores the selection.)

I think this only works in IE 9 and later, not sure though. Over the years I've gotten sloppy about testing earlier IEs, especially for javascript stuff...