* These plugins provide extra functionality for interaction with textareas.
*
* - encapsulateSelection: Ported from skins/common/edit.js by Trevor Parscal
- * © 2009 Wikimedia Foundation (GPLv2) - http://www.wikimedia.org
+ * © 2009 Wikimedia Foundation (GPLv2) - https://www.wikimedia.org
* - getCaretPosition, scrollToCaretPosition: Ported from Wikia's LinkSuggest extension
* https://github.com/Wikia/app/blob/c0cd8b763/extensions/wikia/LinkSuggest/js/jquery.wikia.linksuggest.js
* © 2010 Inez Korczyński (korczynski@gmail.com) & Jesús Martínez Novo (martineznovo@gmail.com) (GPLv2)
setContents: function ( content ) {
return this.each( function () {
var scrollTop = this.scrollTop;
- this.select();
- if ( !document.execCommand( 'insertText', false, content ) ) {
- $( this ).val( content );
- }
+ $( this ).val( content );
// Setting this.value may scroll the textarea, restore the scroll position
this.scrollTop = scrollTop;
} );
return this.each( function () {
var allText, currSelection, startPos, endPos;
- if ( !document.execCommand( 'insertText', false, value ) ) {
- allText = $( this ).textSelection( 'getContents' );
- currSelection = $( this ).textSelection( 'getCaretPosition', { startAndEnd: true } );
- startPos = currSelection[ 0 ];
- endPos = currSelection[ 1 ];
+ allText = $( this ).textSelection( 'getContents' );
+ currSelection = $( this ).textSelection( 'getCaretPosition', { startAndEnd: true } );
+ startPos = currSelection[ 0 ];
+ endPos = currSelection[ 1 ];
- $( this ).textSelection( 'setContents', allText.slice( 0, startPos ) + value +
- allText.slice( endPos ) );
- $( this ).textSelection( 'setSelection', {
- start: startPos,
- end: startPos + value.length
- } );
- }
+ $( this ).textSelection( 'setContents', allText.slice( 0, startPos ) + value +
+ allText.slice( endPos ) );
+ $( this ).textSelection( 'setSelection', {
+ start: startPos,
+ end: startPos + value.length
+ } );
} );
},
}
isSample = false;
- $( this ).focus();
+ $( this ).trigger( 'focus' );
if ( options.selectionStart !== undefined ) {
$( this ).textSelection( 'setSelection', { start: options.selectionStart, end: options.selectionEnd } );
}