r68177 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68176‎ | r68177 | r68178 >
Date:19:01, 17 June 2010
Author:catrope
Status:resolved (Comments)
Tags:
Comment:
(bug 23520) Add preference for SimpleSearch so users can disable it, and make it obey the "Disable AJAX suggestions" preference
Modified paths:
  • /trunk/extensions/UsabilityInitiative/Vector/Modules/SimpleSearch/SimpleSearch.i18n.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/Vector/Modules/SimpleSearch/SimpleSearch.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/Vector/Vector.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/Vector/Vector.combined.min.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/Vector/Vector.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/Vector/Vector.php (modified) (history)
  • /trunk/phase3/skins/Vector.php (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/Vector.php
@@ -675,7 +675,7 @@
676676 * when UI is in RTL mode
677677 */
678678 private function renderNavigation( $elements ) {
679 - global $wgContLang, $wgVectorUseSimpleSearch, $wgVectorShowVariantName;
 679+ global $wgContLang, $wgVectorUseSimpleSearch, $wgVectorShowVariantName, $wgUser;
680680
681681 // If only one element was given, wrap it in an array, allowing more
682682 // flexible arguments
@@ -768,7 +768,7 @@
769769 <h5<?php $this->html('userlangattributes') ?>><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h5>
770770 <form action="<?php $this->text( 'wgScript' ) ?>" id="searchform">
771771 <input type='hidden' name="title" value="<?php $this->text( 'searchtitle' ) ?>"/>
772 - <?php if ( $wgVectorUseSimpleSearch ): ?>
 772+ <?php if ( $wgVectorUseSimpleSearch && $wgUser->getOption( 'vector-simplesearch' ) ): ?>
773773 <div id="simpleSearch">
774774 <input id="searchInput" name="search" type="text" <?php echo $this->skin->tooltipAndAccesskey( 'search' ); ?> <?php if( isset( $this->data['search'] ) ): ?> value="<?php $this->text( 'search' ) ?>"<?php endif; ?> />
775775 <button id="searchButton" type='submit' name='button' <?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?>>&#160;</button>
Index: trunk/extensions/UsabilityInitiative/Vector/Modules/SimpleSearch/SimpleSearch.i18n.php
@@ -14,6 +14,7 @@
1515 $messages['en'] = array(
1616 'vector-simplesearch-search' => 'Search',
1717 'vector-simplesearch-containing' => 'containing...',
 18+ 'vector-simplesearch-preference' => 'Enable enhanced search suggestions (Vector skin only)',
1819 );
1920
2021 /** Message documentation (Message documentation)
Index: trunk/extensions/UsabilityInitiative/Vector/Modules/SimpleSearch/SimpleSearch.js
@@ -9,7 +9,7 @@
1010
1111 $j(document).ready( function() {
1212 // Only use this function in conjuction with the Vector skin
13 - if( !wgVectorEnabledModules.simplesearch || skin != 'vector' ) {
 13+ if( !wgVectorEnabledModules.simplesearch || wgVectorPreferences.simplesearch.disablesuggest || skin != 'vector' ) {
1414 return true;
1515 }
1616 var mod = {
Index: trunk/extensions/UsabilityInitiative/Vector/Vector.php
@@ -25,9 +25,11 @@
2626 'editwarning' => array( 'global' => false, 'user' => true ),
2727 'expandablesearch' => array( 'global' => true, 'user' => true ),
2828 'footercleanup' => array( 'global' => false, 'user' => false ),
29 - 'simplesearch' => array( 'global' => true, 'user' => false ),
 29+ 'simplesearch' => array( 'global' => false, 'user' => true ),
3030 );
3131
 32+$wgDefaultUserOptions['vector-simplesearch'] = 1;
 33+
3234 /* Setup */
3335
3436 // Enable bucket testing for new version of collapsible nav
Index: trunk/extensions/UsabilityInitiative/Vector/Vector.hooks.php
@@ -17,13 +17,13 @@
1818 array( 'src' => 'Modules/ExpandableSearch/ExpandableSearch.js', 'version' => 5 ),
1919 array( 'src' => 'Modules/EditWarning/EditWarning.js', 'version' => 8 ),
2020 array( 'src' => 'Modules/FooterCleanup/FooterCleanup.js', 'version' => 5 ),
21 - array( 'src' => 'Modules/SimpleSearch/SimpleSearch.js', 'version' => 17 ),
 21+ array( 'src' => 'Modules/SimpleSearch/SimpleSearch.js', 'version' => 18 ),
2222 ),
2323 'combined' => array(
24 - array( 'src' => 'Vector.combined.js', 'version' => 54 ),
 24+ array( 'src' => 'Vector.combined.js', 'version' => 55 ),
2525 ),
2626 'minified' => array(
27 - array( 'src' => 'Vector.combined.min.js', 'version' => 55 ),
 27+ array( 'src' => 'Vector.combined.min.js', 'version' => 56 ),
2828 ),
2929 );
3030 static $modules = array(
@@ -71,7 +71,20 @@
7272 'footercleanup' => array(
7373 ),
7474 'simplesearch' => array(
75 - 'i18n' => 'WikiEditorToc',
 75+ 'preferences' => array(
 76+ 'enable' => array(
 77+ 'key' => 'vector-simplesearch',
 78+ 'ui' => array(
 79+ 'type' => 'toggle',
 80+ 'label-message' => 'vector-simplesearch-preference',
 81+ 'section' => 'searchoptions/display'
 82+ ),
 83+ ),
 84+ 'disablesuggest' => array(
 85+ 'key' => 'disablesuggest',
 86+ ),
 87+ ),
 88+ 'i18n' => 'VectorSimpleSearch',
7689 'messages' => array(
7790 'vector-simplesearch-search',
7891 'vector-simplesearch-containing',
@@ -167,7 +180,7 @@
168181 isset( self::$modules[$module]['preferences'] ) ) {
169182 wfLoadExtensionMessages( self::$modules[$module]['i18n'] );
170183 foreach ( self::$modules[$module]['preferences'] as $key => $preference ) {
171 - if ( $key == 'enable' && !$enable['user'] ) {
 184+ if ( ( $key == 'enable' && !$enable['user'] ) || !isset( $preference['ui'] ) ) {
172185 continue;
173186 }
174187
Index: trunk/extensions/UsabilityInitiative/Vector/Vector.combined.js
@@ -495,7 +495,7 @@
496496
497497 $j(document).ready( function() {
498498 // Only use this function in conjuction with the Vector skin
499 - if( !wgVectorEnabledModules.simplesearch || skin != 'vector' ) {
 499+ if( !wgVectorEnabledModules.simplesearch || wgVectorPreferences.simplesearch.disablesuggest || skin != 'vector' ) {
500500 return true;
501501 }
502502 var mod = {
Index: trunk/extensions/UsabilityInitiative/Vector/Vector.combined.min.js
@@ -24,7 +24,7 @@
2525 $j('#editpage-copywarn').add('.editOptions').wrapAll('<div id="editpage-bottom"></div>');$j('#wpSummary').data('hint',$j('#wpSummaryLabel span small').remove().text().replace(/\)|\(/g,'')).change(function(){if($j(this).val().length==0){$j(this).addClass('inline-hint').val($j(this).data('hint'));}else{$j(this).removeClass('inline-hint');}}).focus(function(){if($j(this).val()==$j(this).data('hint')){$j(this).removeClass('inline-hint').val("");}}).blur(function(){$j(this).trigger('change');}).trigger('change');$j('#wpSummary').add('.editCheckboxes').wrapAll('<div id="editpage-summary-fields"></div>');$j('#editpage-specialchars').remove();var transclusionCount=$j('.templatesUsed ul li').size();$j('.templatesUsed ul').wrap('<div id="transclusions-list" class="collapsible-list collapsed"></div>').parent().prepend('<label>This page contains <a href="http://en.wikipedia.org/wiki/transclusion">transclusions</a> of <strong>'
2626 +transclusionCount
2727 +'</strong> other pages.</label>');$j('.mw-templatesUsedExplanation').remove();$j('.collapsible-list label').click(function(){$j(this).parent().toggleClass('expanded').toggleClass('collapsed').find('ul').slideToggle('fast');return false;}).trigger('click');$j('#wpPreview, #wpDiff, .editHelp, #editpage-specialchars').remove();$j('#mw-editform-cancel').remove().appendTo('.editButtons');});if(wgVectorEnabledModules.simplesearch&&skin=='vector'&&typeof os_autoload_inputs!=='undefined'&&os_autoload_forms!=='undefined'){os_autoload_inputs=[];os_autoload_forms=[];}
28 -$j(document).ready(function(){if(!wgVectorEnabledModules.simplesearch||skin!='vector'){return true;}
 28+$j(document).ready(function(){if(!wgVectorEnabledModules.simplesearch||wgVectorPreferences.simplesearch.disablesuggest||skin!='vector'){return true;}
2929 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;}
3030 $j('div#simpleSearch > input#searchInput').each(function(){$j('<label />').text(mw.usability.getMsg('vector-simplesearch-search')).css({'display':'none','position':'absolute','color':'#999999','cursor':'text','margin':'0 4px','top':'6px','line-height':'13px'}).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)
3131 $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)

Follow-up revisions

RevisionCommit summaryAuthorDate
r68224Followup to r68177: per CR, move SimpleSearch preference to core.catrope17:36, 18 June 2010
r687451.16wmf4: Merge Vector fixes from trunk: r68079, r68105, r68109, r68177, r682...catrope21:18, 29 June 2010

Comments

#Comment by 😂 (talk | contribs)   17:21, 18 June 2010

Defined a preference in an extension but implemented it in core. Eww :)

Status & tagging log