Index: trunk/extensions/AbuseFilter/modules/ext.abuseFilter.edit.js |
— | — | @@ -96,7 +96,9 @@ |
97 | 97 | return; |
98 | 98 | } |
99 | 99 | |
100 | | - $filterBox.insertAtCaret( $filterBuilder.val() + " " ); |
| 100 | + $filterBox.textSelection( |
| 101 | + 'encapsulateSelection', { 'pre': $filterBuilder.val() + " " } |
| 102 | + ); |
101 | 103 | $filterBuilder.prop( 'selectedIndex', 0 ); |
102 | 104 | }; |
103 | 105 | |
— | — | @@ -172,40 +174,6 @@ |
173 | 175 | window.location = mw.config.get( 'wgScript' ) + '?title=MediaWiki:' + mw.util.wikiUrlencode( message ) + '&action=edit'; |
174 | 176 | }; |
175 | 177 | |
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 | | - |
210 | 178 | /* |
211 | 179 | * On ready initialization |
212 | 180 | */ |