- if ( document.selection && document.selection.createRange ) {
- // IE
-
- // Note that IE9 will trigger the next section unless we check this first.
- // See bug T37201.
-
- activateElementOnIE( this );
- if ( options.selectionStart !== undefined ) {
- $( this ).textSelection( 'setSelection', { start: options.selectionStart, end: options.selectionEnd } );
- }
-
- selText = $( this ).textSelection( 'getSelection' );
- scrollTop = this.scrollTop;
- range = document.selection.createRange();
-
- checkSelectedText();
- insertText = pre + selText + post;
- if ( options.splitlines ) {
- insertText = doSplitLines( selText, pre, post );
- }
- if ( options.ownline && range.moveStart ) {
- range2 = document.selection.createRange();
- range2.collapse();
- range2.moveStart( 'character', -1 );
- // FIXME: Which check is correct?
- if ( range2.text !== '\r' && range2.text !== '\n' && range2.text !== '' ) {
- insertText = '\n' + insertText;
- pre += '\n';
- }
- range3 = document.selection.createRange();
- range3.collapse( false );
- range3.moveEnd( 'character', 1 );
- if ( range3.text !== '\r' && range3.text !== '\n' && range3.text !== '' ) {
- insertText += '\n';
- post += '\n';
- }
- }
-
- range.text = insertText;
- if ( isSample && options.selectPeri && range.moveStart ) {
- range.moveStart( 'character', -post.length - selText.length );
- range.moveEnd( 'character', -post.length );
- }
- range.select();
- // Restore the scroll position
- this.scrollTop = scrollTop;
- } else if ( this.selectionStart || this.selectionStart === 0 ) {
- // Mozilla/Opera
-