dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Cleanup page creation in RevisionIntegrationTest"
[lhc/web/wiklou.git]
/
resources
/
src
/
jquery
/
jquery.textSelection.js
diff --git
a/resources/src/jquery/jquery.textSelection.js
b/resources/src/jquery/jquery.textSelection.js
index
5e93ba6
..
522e95b
100644
(file)
--- a/
resources/src/jquery/jquery.textSelection.js
+++ b/
resources/src/jquery/jquery.textSelection.js
@@
-4,7
+4,7
@@
( function ( $ ) {
if ( document.selection && document.selection.createRange ) {
// On IE, patch the focus() method to restore the windows' scroll position
( function ( $ ) {
if ( document.selection && document.selection.createRange ) {
// On IE, patch the focus() method to restore the windows' scroll position
- // (
bug 32
241)
+ // (
T34
241)
$.fn.extend( {
focus: ( function ( jqFocus ) {
return function () {
$.fn.extend( {
focus: ( function ( jqFocus ) {
return function () {
@@
-32,13
+32,17
@@
/**
* Helper function to get an IE TextRange object for an element
/**
* Helper function to get an IE TextRange object for an element
+ *
+ * @param {HTMLElement} element
+ * @return {TextRange}
*/
*/
- function rangeForElementIE( e ) {
- if ( e.nodeName.toLowerCase() === 'input' ) {
- return e.createTextRange();
+ function rangeForElementIE( element ) {
+ var sel;
+ if ( element.nodeName.toLowerCase() === 'input' ) {
+ return element.createTextRange();
} else {
} else {
-
var
sel = document.body.createTextRange();
- sel.moveToElementText( e );
+ sel = document.body.createTextRange();
+ sel.moveToElementText( e
lement
);
return sel;
}
}
return sel;
}
}
@@
-47,10
+51,12
@@
* 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.
* 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 ) {
*/
function activateElementOnIE( element ) {
if ( element.setActive ) {
- element.setActive(); //
bug 32
241: doesn't scroll
+ element.setActive(); //
T34
241: doesn't scroll
} else {
$( element ).focus(); // may scroll (but we patched it above)
}
} else {
$( element ).focus(); // may scroll (but we patched it above)
}
@@
-59,12
+65,16
@@
fn = {
/**
* Get the contents of the textarea
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
*/
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 );
*/
setContents: function ( content ) {
this.val( content );
@@
-72,6
+82,8
@@
/**
* Get the currently selected text in this textarea. Will focus the textarea
* in some browsers (IE/Opera)
/**
* Get the currently selected text in this textarea. Will focus the textarea
* in some browsers (IE/Opera)
+ *
+ * @return {string}
*/
getSelection: function () {
var retval, range,
*/
getSelection: function () {
var retval, range,
@@
-96,7
+108,9
@@
* Inserts text at the beginning and end of a text selection, optionally
* inserting text at the caret when selection is empty.
*
* 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
* FIXME document the options parameters
+ * @return {jQuery}
*/
encapsulateSelection: function ( options ) {
return this.each( function () {
*/
encapsulateSelection: function ( options ) {
return this.each( function () {
@@
-132,6
+146,11
@@
* Do the splitlines stuff.
*
* Wrap each line of the selected text with pre and post
* 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,
*/
function doSplitLines( selText, pre, post ) {
var i,
@@
-153,12
+172,9
@@
// IE
// Note that IE9 will trigger the next section unless we check this first.
// IE
// Note that IE9 will trigger the next section unless we check this first.
- // See bug
35
201.
+ // See bug
T37
201.
activateElementOnIE( this );
activateElementOnIE( this );
- if ( context ) {
- context.fn.restoreCursorAndScrollTop();
- }
if ( options.selectionStart !== undefined ) {
$( this ).textSelection( 'setSelection', { start: options.selectionStart, end: options.selectionEnd } );
}
if ( options.selectionStart !== undefined ) {
$( this ).textSelection( 'setSelection', { start: options.selectionStart, end: options.selectionEnd } );
}
@@
-268,14
+284,16
@@
*
* Will focus the textarea in some browsers (IE/Opera)
*
*
* Will focus the textarea in some browsers (IE/Opera)
*
+ * @param {Object} options Options
* FIXME document the options parameters
* FIXME document the options parameters
+ * @return {number} Position
*/
getCaretPosition: function ( options ) {
function getCaret( e ) {
var caretPos = 0,
endPos = 0,
preText, rawPreText, periText,
*/
getCaretPosition: function ( options ) {
function getCaret( e ) {
var caretPos = 0,
endPos = 0,
preText, rawPreText, periText,
- rawPeriText, postText,
rawPostText,
+ rawPeriText, postText,
// IE Support
preFinished,
periFinished,
// IE Support
preFinished,
periFinished,
@@
-291,7
+309,7
@@
// 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
// 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 31
847).
+ // whatever we do later (
T33
847).
activateElementOnIE( e );
preFinished = false;
activateElementOnIE( e );
preFinished = false;
@@
-310,7
+328,7
@@
// Load the text values we need to compare
preText = rawPreText = preRange.text;
periText = rawPeriText = periRange.text;
// Load the text values we need to compare
preText = rawPreText = preRange.text;
periText = rawPeriText = periRange.text;
- postText =
rawPostText =
postRange.text;
+ postText = postRange.text;
/*
* Check each range for trimmed newlines by shrinking the range by 1
/*
* Check each range for trimmed newlines by shrinking the range by 1
@@
-347,9
+365,7
@@
postFinished = true;
} else {
postRange.moveEnd( 'character', -1 );
postFinished = true;
} else {
postRange.moveEnd( 'character', -1 );
- if ( postRange.text === postText ) {
- rawPostText += '\r\n';
- } else {
+ if ( postRange.text !== postText ) {
postFinished = true;
}
}
postFinished = true;
}
}
@@
-367,7
+383,9
@@
return getCaret( this.get( 0 ) );
},
/**
return getCaret( this.get( 0 ) );
},
/**
+ * @param {Object} options options
* FIXME document the options parameters
* FIXME document the options parameters
+ * @return {jQuery}
*/
setSelection: function ( options ) {
return this.each( function () {
*/
setSelection: function ( options ) {
return this.each( function () {
@@
-412,10
+430,11
@@
* Scroll a textarea to the current cursor position. You can set the cursor
* position with setSelection()
*
* 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 ) {
*/
scrollToCaretPosition: function ( options ) {
function getLineLength( e ) {