r83586 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83585‎ | r83586 | r83587 >
Date:13:54, 9 March 2011
Author:catrope
Status:ok (Comments)
Tags:
Comment:
(bug 27944) Search placeholder was inserted even when the search box was already focused, leading to the placeholder being added to the search string. This revision doesn't fix the initial insertion of the placeholder if the search box is focused but empty, but it does remove it upon keydown (and paste), which fixes the search string munging.

(bug 26135) Support drag and drop in the search box in Firefox. Done by adding 'drop' to the list of events to update search suggestions for and to remove the placeholder for. Removing the placeholder is trickier in this case because 'drop' fires after the text has already been inserted, and because it could have been inserted at any offset in the placeholder string. Used dataTransfer magic to obtain the text being dropped and just overwrote the search box text with that.
Modified paths:
  • /trunk/extensions/Vector/modules/ext.vector.simpleSearch.js (modified) (history)
  • /trunk/phase3/resources/jquery/jquery.placeholder.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/jquery/jquery.placeholder.js
@@ -37,9 +37,16 @@
3838 } )
3939
4040 // Hide on focus
41 - .focus( function() {
 41+ // Also listen for other events in case $input was
 42+ // already focused when the events were bound
 43+ .bind( 'focus drop keydown paste', function( e ) {
4244 if ( $input.hasClass( 'placeholder' ) ) {
43 - this.value = '';
 45+ // Support for drag&drop in Firefox
 46+ if ( e.type == 'drop' && e.originalEvent.dataTransfer ) {
 47+ this.value = e.originalEvent.dataTransfer.getData( 'text/plain' );
 48+ } else {
 49+ this.value = '';
 50+ }
4451 $input.removeClass( 'placeholder' );
4552 }
4653 } );
Index: trunk/extensions/Vector/modules/ext.vector.simpleSearch.js
@@ -78,8 +78,9 @@
7979 positionFromLeft: $( 'body' ).is( '.rtl' ),
8080 highlightInput: true
8181 } )
82 - .bind( 'paste cut', function( e ) {
83 - // make sure paste and cut events from the mouse trigger the keypress handler and cause the suggestions to update
 82+ .bind( 'paste cut drop', function( e ) {
 83+ // make sure paste and cut events from the mouse and drag&drop events
 84+ // trigger the keypress handler and cause the suggestions to update
8485 $( this ).trigger( 'keypress' );
8586 } );
8687 // Special suggestions functionality for skin-provided search box

Follow-up revisions

RevisionCommit summaryAuthorDate
r83587Fix r83586 (drag and drop support for placeholder plugin) to work in IE, whos...catrope14:27, 9 March 2011
r844201.17wmf1: MFT r76372, r76377, r83586, r83587, r83817, r83876, r83979, r84118,...catrope21:04, 20 March 2011
r85033MFT more extension revs: r82601, r82654, r82698, r82755, r82756, r82759, r829...demon18:49, 30 March 2011
r85354MFT r82518, r82530, r82538, r82547, r82550, r82565, r82572, r82608, r82696, r...demon18:25, 4 April 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r80777Partial revert of r80772....hartman23:13, 22 January 2011

Comments

#Comment by 😂 (talk | contribs)   18:50, 30 March 2011

Still needs phase3 merge

Status & tagging log