Last modified: 2013-12-12 01:01:29 UTC
jquery.textSelection's scrollToCaretPosition() function has some weird-looking UA sniffing bits: function getLineLength( e ) { return Math.floor( e.scrollWidth / ( $.client.profile().platform == 'linux' ? 7 : 8 ) ); } What's that even mean? Why would being on Linux specifically mean the magic 7 number comes in? This looks like some awful magic code which is totally undocumented. Then a bit later similar: return ( $.client.profile().platform == 'mac' ? 13 : ( $.client.profile().platform == 'linux' ? 15 : 16 ) ) * row; What is this? Is it assuming that certain font sizes are always in use? This shouldn't fly...
This is code we don't use anymore, so it can really just be dropped. The code was originally borrowed from somewhere else (I think a Wikia extension but I don't recall details). It's fundamentally broken and the approach is very inaccurate.
WikiEditor's search-replace dialog appears to actively call $textarea.textSelection('scrollToCaretPosition') when selecting the next match. LiquidThreads seems to have a partial copy of the search-replace in lqt.toolbar.js which also does this. (WTF?) The getCaretScrollPosition() subfunction (with the 13 / 15 / 16 pixel hardcoding) appears to be used for 'Mozilla'-style browsers, and the getLineLength() is used by that.
Do you mean dropping scrollToCaretPosition, or the whole jquery.textSelection library?