http://www.mediawiki.org/wiki/Special:Code/MediaWiki/67258
Revision: 67258 Author: adam Date: 2010-06-02 22:12:23 +0000 (Wed, 02 Jun 2010) Log Message: ----------- adding a dragend handler to simple search to handle text being dragged into the search box. Only works for mozilla. Addresses a comment on bug 23517 Modified Paths: -------------- trunk/extensions/UsabilityInitiative/Vector/Modules/SimpleSearch/SimpleSearch.js trunk/extensions/UsabilityInitiative/Vector/Vector.combined.js trunk/extensions/UsabilityInitiative/Vector/Vector.combined.min.js trunk/extensions/UsabilityInitiative/Vector/Vector.hooks.php Modified: trunk/extensions/UsabilityInitiative/Vector/Modules/SimpleSearch/SimpleSearch.js =================================================================== --- trunk/extensions/UsabilityInitiative/Vector/Modules/SimpleSearch/SimpleSearch.js 2010-06-02 22:04:40 UTC (rev 67257) +++ trunk/extensions/UsabilityInitiative/Vector/Modules/SimpleSearch/SimpleSearch.js 2010-06-02 22:12:23 UTC (rev 67258) @@ -70,6 +70,13 @@ $j(this).parent().find( 'label' ).fadeIn( 100 ); } }); + // listen for dragend events in order to clear the label from the search field if + // text is dragged into it. Only works for mozilla + $j( document ).bind( 'dragend', function( event ) { + if ( $j( 'div#simpleSearch > label:visible' ).size() > 0 + && $j( 'div#simpleSearch > input#searchInput' ).val().length > 0 ) + $j( 'div#simpleSearch > label' ).fadeOut( 100 ); + } ); $j( '#searchInput, #searchInput2, #powerSearchText, #searchText' ).suggestions( { fetch: function( query ) { var $this = $j(this); Modified: trunk/extensions/UsabilityInitiative/Vector/Vector.combined.js =================================================================== --- trunk/extensions/UsabilityInitiative/Vector/Vector.combined.js 2010-06-02 22:04:40 UTC (rev 67257) +++ trunk/extensions/UsabilityInitiative/Vector/Vector.combined.js 2010-06-02 22:12:23 UTC (rev 67258) @@ -401,6 +401,13 @@ $j(this).parent().find( 'label' ).fadeIn( 100 ); } }); + // listen for dragend events in order to clear the label from the search field if + // text is dragged into it. Only works for mozilla + $j( document ).bind( 'dragend', function( event ) { + if ( $j( 'div#simpleSearch > label:visible' ).size() > 0 + && $j( 'div#simpleSearch > input#searchInput' ).val().length > 0 ) + $j( 'div#simpleSearch > label' ).fadeOut( 100 ); + } ); $j( '#searchInput, #searchInput2, #powerSearchText, #searchText' ).suggestions( { fetch: function( query ) { var $this = $j(this); Modified: trunk/extensions/UsabilityInitiative/Vector/Vector.combined.min.js =================================================================== --- trunk/extensions/UsabilityInitiative/Vector/Vector.combined.min.js 2010-06-02 22:04:40 UTC (rev 67257) +++ trunk/extensions/UsabilityInitiative/Vector/Vector.combined.min.js 2010-06-02 22:12:23 UTC (rev 67258) @@ -19,5 +19,6 @@ $j(document).ready(function(){if(!wgVectorEnabledModules.simplesearch||skin!='vector'){return true;} var mod={'browsers':{'ltr':{'opera':[['>=',9.6]],'blackberry':false,'ipod':false,'iphone':false},'rtl':{'opera':[['>=',9.6]],'blackberry':false,'ipod':false,'iphone':false}}};if(!$j.wikiEditor.isSupported(mod)){return true;} $j('div#simpleSearch > input#searchInput').each(function(){$j('<label />').text(mw.usability.getMsg('vector-simplesearch-search')).css({'display':'none','position':'absolute','bottom':0,'padding':'0.25em','color':'#999999','cursor':'text'}).css(($j('body').is('.rtl')?'right':'left'),0).click(function(){$j(this).parent().find('input#searchInput').focus();}).appendTo($j(this).parent());if($j(this).val()==''){$j(this).parent().find('label').fadeIn(100);}}).bind('keypress',function(){if($j(this).parent().find('label:visible').size()>0) -$j(this).parent().find('label').fadeOut(100);}).focus(function(){$j(this).parent().find('label').fadeOut(100);}).blur(function(){if($j(this).val()==''){$j(this).parent().find('label').fadeIn(100);}});$j('#searchInput, #searchInput2, #powerSearchText, #searchText').suggestions({fetch:function(query){var $this=$j(this);var request=$j.ajax({url:wgScriptPath+'/api.php',data:{'action':'opensearch','search':query,'namespace':0,'suggest':''},dataType:'json',success:function(data){$this.suggestions('suggestions',data[1]);}});$j(this).data('request',request);},cancel:function(){var request=$j(this).data('request');if(request&&typeof request.abort=='function'){request.abort();$j(this).removeData('request');}},result:{select:function($textbox){$textbox.closest('form').submit();}},delay:120,positionFromLeft:$j('body').is('.rtl')}).bind('paste cut click',function(){$j(this).trigger('keypress');});$j('#searchInput').suggestions({result:{select:function($textbox){$textbox.closest('form').submit();}},special:{render:function(query){if($j(this).children().size()==0){$j(this).show() +$j(this).parent().find('label').fadeOut(100);}).focus(function(){$j(this).parent().find('label').fadeOut(100);}).blur(function(){if($j(this).val()==''){$j(this).parent().find('label').fadeIn(100);}});$j(document).bind('dragend',function(event){if($j('div#simpleSearch > label:visible').size()>0&&$j('div#simpleSearch > input#searchInput').val().length>0) +$j('div#simpleSearch > label').fadeOut(100);});$j('#searchInput, #searchInput2, #powerSearchText, #searchText').suggestions({fetch:function(query){var $this=$j(this);var request=$j.ajax({url:wgScriptPath+'/api.php',data:{'action':'opensearch','search':query,'namespace':0,'suggest':''},dataType:'json',success:function(data){$this.suggestions('suggestions',data[1]);}});$j(this).data('request',request);},cancel:function(){var request=$j(this).data('request');if(request&&typeof request.abort=='function'){request.abort();$j(this).removeData('request');}},result:{select:function($textbox){$textbox.closest('form').submit();}},delay:120,positionFromLeft:$j('body').is('.rtl')}).bind('paste cut click',function(){$j(this).trigger('keypress');});$j('#searchInput').suggestions({result:{select:function($textbox){$textbox.closest('form').submit();}},special:{render:function(query){if($j(this).children().size()==0){$j(this).show() $label=$j('<div />').addClass('special-label').text(mw.usability.getMsg('vector-simplesearch-containing')).appendTo($j(this));$query=$j('<div />').addClass('special-query').text(query).appendTo($j(this));$query.autoEllipsis();}else{$j(this).find('.special-query').empty().text(query).autoEllipsis();}},select:function($textbox){$textbox.closest('form').append($j('<input />').attr({'type':'hidden','name':'fulltext','value':1}));$textbox.closest('form').submit();}},$region:$j('#simpleSearch')}).bind('paste cut click',function(){$j(this).trigger('keypress');});}); \ No newline at end of file Modified: trunk/extensions/UsabilityInitiative/Vector/Vector.hooks.php =================================================================== --- trunk/extensions/UsabilityInitiative/Vector/Vector.hooks.php 2010-06-02 22:04:40 UTC (rev 67257) +++ trunk/extensions/UsabilityInitiative/Vector/Vector.hooks.php 2010-06-02 22:12:23 UTC (rev 67258) @@ -17,13 +17,13 @@ array( 'src' => 'Modules/ExpandableSearch/ExpandableSearch.js', 'version' => 2 ), array( 'src' => 'Modules/EditWarning/EditWarning.js', 'version' => 8 ), array( 'src' => 'Modules/FooterCleanup/FooterCleanup.js', 'version' => 5 ), - array( 'src' => 'Modules/SimpleSearch/SimpleSearch.js', 'version' => 14 ), + array( 'src' => 'Modules/SimpleSearch/SimpleSearch.js', 'version' => 15 ), ), 'combined' => array( - array( 'src' => 'Vector.combined.js', 'version' => 35 ), + array( 'src' => 'Vector.combined.js', 'version' => 36 ), ), 'minified' => array( - array( 'src' => 'Vector.combined.min.js', 'version' => 35 ), + array( 'src' => 'Vector.combined.min.js', 'version' => 36 ), ), ); static $modules = array( _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs