Merge "Cleanup page creation in RevisionIntegrationTest"
[lhc/web/wiklou.git] / resources / src / jquery / jquery.textSelection.js
index b6fbe35..522e95b 100644 (file)
@@ -4,7 +4,7 @@
 ( function ( $ ) {
        if ( document.selection && document.selection.createRange ) {
                // On IE, patch the focus() method to restore the windows' scroll position
-               // (bug 32241)
+               // (T34241)
                $.fn.extend( {
                        focus: ( function ( jqFocus ) {
                                return function () {
 
                /**
                 * Helper function to get an IE TextRange object for an element
+                *
+                * @param {HTMLElement} element
+                * @return {TextRange}
                 */
-               function rangeForElementIE( e ) {
+               function rangeForElementIE( element ) {
                        var sel;
-                       if ( e.nodeName.toLowerCase() === 'input' ) {
-                               return e.createTextRange();
+                       if ( element.nodeName.toLowerCase() === 'input' ) {
+                               return element.createTextRange();
                        } else {
                                sel = document.body.createTextRange();
-                               sel.moveToElementText( e );
+                               sel.moveToElementText( element );
                                return sel;
                        }
                }
                 * Helper function for IE for activating the textarea. Called only in the
                 * IE-specific code paths below; makes use of IE-specific non-standard
                 * function setActive() if possible to avoid screen flicker.
+                *
+                * @param {HTMLElement} element
                 */
                function activateElementOnIE( element ) {
                        if ( element.setActive ) {
-                               element.setActive(); // bug 32241: doesn't scroll
+                               element.setActive(); // T34241: doesn't scroll
                        } else {
                                $( element ).focus(); // may scroll (but we patched it above)
                        }
                fn = {
                        /**
                         * Get the contents of the textarea
+                        *
+                        * @return {string}
                         */
                        getContents: function () {
                                return this.val();
                        },
                        /**
                         * Set the contents of the textarea, replacing anything that was there before
+                        *
+                        * @param {string} content
                         */
                        setContents: function ( content ) {
                                this.val( content );
@@ -73,6 +82,8 @@
                        /**
                         * Get the currently selected text in this textarea. Will focus the textarea
                         * in some browsers (IE/Opera)
+                        *
+                        * @return {string}
                         */
                        getSelection: function () {
                                var retval, range,
                         * Inserts text at the beginning and end of a text selection, optionally
                         * inserting text at the caret when selection is empty.
                         *
+                        * @param {Object} options Options
                         * FIXME document the options parameters
+                        * @return {jQuery}
                         */
                        encapsulateSelection: function ( options ) {
                                return this.each( function () {
                                         * Do the splitlines stuff.
                                         *
                                         * Wrap each line of the selected text with pre and post
+                                        *
+                                        * @param {string} selText Selected text
+                                        * @param {string} pre Text before
+                                        * @param {string} post Text after
+                                        * @return {string} Wrapped text
                                         */
                                        function doSplitLines( selText, pre, post ) {
                                                var i,
                                                        // IE
 
                                                        // Note that IE9 will trigger the next section unless we check this first.
-                                                       // See bug 35201.
+                                                       // See bug T37201.
 
                                                        activateElementOnIE( this );
-                                                       if ( context ) {
-                                                               context.fn.restoreCursorAndScrollTop();
-                                                       }
                                                        if ( options.selectionStart !== undefined ) {
                                                                $( this ).textSelection( 'setSelection', { start: options.selectionStart, end: options.selectionEnd } );
                                                        }
                         *
                         * Will focus the textarea in some browsers (IE/Opera)
                         *
+                        * @param {Object} options Options
                         * FIXME document the options parameters
+                        * @return {number} Position
                         */
                        getCaretPosition: function ( options ) {
                                function getCaret( e ) {
                                                // IE doesn't properly report non-selected caret position through
                                                // the selection ranges when textarea isn't focused. This can
                                                // lead to saving a bogus empty selection, which then screws up
-                                               // whatever we do later (bug 31847).
+                                               // whatever we do later (T33847).
                                                activateElementOnIE( e );
 
                                                preFinished = false;
                                return getCaret( this.get( 0 ) );
                        },
                        /**
+                        * @param {Object} options options
                         * FIXME document the options parameters
+                        * @return {jQuery}
                         */
                        setSelection: function ( options ) {
                                return this.each( function () {
                         * Scroll a textarea to the current cursor position. You can set the cursor
                         * position with setSelection()
                         *
-                        * @param {boolean} options Whether to force a scroll even if the caret position
-                        *  is already visible. Defaults to false
-                        *
-                        * FIXME document the options parameters (function body suggests options.force is a boolean, not options itself)
+                        * @param {Object} options options
+                        * @cfg {boolean} [force=false] Whether to force a scroll even if the caret position
+                        *  is already visible.
+                        * FIXME document the options parameters
+                        * @return {jQuery}
                         */
                        scrollToCaretPosition: function ( options ) {
                                function getLineLength( e ) {