r98499 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98498‎ | r98499 | r98500 >
Date:01:57, 30 September 2011
Author:johnduhart
Status:ok
Tags:
Comment:
Followup r95572, replace insertAtCaret with textSelection per CR
Modified paths:
  • /trunk/extensions/AbuseFilter/modules/ext.abuseFilter.edit.js (modified) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/modules/ext.abuseFilter.edit.js
@@ -96,7 +96,9 @@
9797 return;
9898 }
9999
100 - $filterBox.insertAtCaret( $filterBuilder.val() + " " );
 100+ $filterBox.textSelection(
 101+ 'encapsulateSelection', { 'pre': $filterBuilder.val() + " " }
 102+ );
101103 $filterBuilder.prop( 'selectedIndex', 0 );
102104 };
103105
@@ -172,40 +174,6 @@
173175 window.location = mw.config.get( 'wgScript' ) + '?title=MediaWiki:' + mw.util.wikiUrlencode( message ) + '&action=edit';
174176 };
175177
176 - // From http://stackoverflow.com/questions/946534/insert-text-into-textarea-with-jquery/2819568#2819568
177 - $.fn.extend({
178 - /**
179 - * Inserts a string in a textarea at the current caret position
180 - *
181 - * @param {String} myValue String to insert
182 - * @returns {jQuery}
183 - */
184 - insertAtCaret: function(myValue){
185 - return this.each( function() {
186 - if ( document.selection ) {
187 - this.focus();
188 - sel = document.selection.createRange();
189 - sel.text = myValue;
190 - this.focus();
191 - } else if ( this.selectionStart || this.selectionStart == '0' ) {
192 - var startPos = this.selectionStart;
193 - var endPos = this.selectionEnd;
194 - var scrollTop = this.scrollTop;
195 - this.value = this.value.substring( 0, startPos )
196 - + myValue
197 - + this.value.substring( endPos, this.value.length );
198 - this.focus();
199 - this.selectionStart = startPos + myValue.length;
200 - this.selectionEnd = startPos + myValue.length;
201 - this.scrollTop = scrollTop;
202 - } else {
203 - this.value += myValue;
204 - this.focus();
205 - }
206 - } );
207 - }
208 - });
209 -
210178 /*
211179 * On ready initialization
212180 */

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r95572Adds ResourceLoader support to AbuseFilter...johnduhart20:12, 26 August 2011

Status & tagging log