[Phpfreechat-svn] SF.net SVN: phpfreechat: [1120] trunk/data/public/js/pfcclient.js
Status: Beta
Brought to you by:
kerphi
From: <gpi...@us...> - 2007-08-14 17:05:13
|
Revision: 1120 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1120&view=rev Author: gpinzone Date: 2007-08-14 10:05:15 -0700 (Tue, 14 Aug 2007) Log Message: ----------- Attempt to implement IE selection tracking code to insert_text. Does not seem to retain last known caret/selection positions. Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-08-13 17:08:34 UTC (rev 1119) +++ trunk/data/public/js/pfcclient.js 2007-08-14 17:05:15 UTC (rev 1120) @@ -1708,7 +1708,15 @@ if (document.selection && document.selection.createRange) { msgfield.focus(); - pfcp.sel = document.selection.createRange(); + + // Set range based on stored values. + var range = msgfield.createTextRange(); + range.collapse(true); + range.moveStart("character", msgfield.selStart); + range.moveEnd("character", msgfield.selEnd - msgfield.selStart); + range.select(); + + pfcp.sel = range; var text = pfcp.sel.text; if (text == "" && promptifselempty) { @@ -1757,9 +1765,13 @@ if (text == null) text = ""; if (text.length > 0 || !promptifselempty) { + msgfield.focus(); sel.text = open + text + close; // @todo move the cursor just after the BBCODE, this doesn't work when the text to enclose is selected, IE6 keeps the whole selection active after the operation. - msgfield.focus(); + // Increment caret position. + // Check if internally kept values for selection are initialized. + msgfield.selStart = (msgfield.selStart) ? msgfield.selStart + sel.text.length : sel.text.length; + msgfield.selEnd = msgfield.selStart; } } // Mozilla support This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |