r102391 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102390‎ | r102391 | r102392 >
Date:11:20, 8 November 2011
Author:santhosh
Status:ok
Tags:
Comment:
Follow-up r101592.
Make number of recent input methods to be shown configurable. Default value 3.
Minor whitespace correction.
Use userVariant, wgContentLanguage, wgUserLanguage for showing the input method options.
Modified paths:
  • /trunk/extensions/Narayam/Narayam.hooks.php (modified) (history)
  • /trunk/extensions/Narayam/Narayam.php (modified) (history)
  • /trunk/extensions/Narayam/js/ext.narayam.core.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Narayam/Narayam.hooks.php
@@ -25,7 +25,7 @@
2626 }
2727
2828 public static function addConfig( &$vars ) {
29 - global $wgNarayamEnabledByDefault, $wgUser;
 29+ global $wgNarayamEnabledByDefault, $wgNarayamRecentItemsLength, $wgUser;
3030
3131 if ( $wgUser->getOption( 'narayamDisable' ) ) {
3232 // User disabled Narayam
@@ -33,7 +33,8 @@
3434 }
3535
3636 $vars['wgNarayamEnabledByDefault'] = $wgNarayamEnabledByDefault;
37 -
 37+ $vars['wgNarayamRecentItemsLength'] = $wgNarayamRecentItemsLength;
 38+
3839 return true;
3940 }
4041
Index: trunk/extensions/Narayam/js/ext.narayam.core.js
@@ -37,7 +37,8 @@
3838 var currentScheme = null;
3939 // Shortcut key for turning Narayam on and off
4040 var shortcutKey = getShortCutKey();
41 -
 41+ // Number of recent input methods to be shown
 42+ var recentItemsLength = mw.config.get( 'wgNarayamRecentItemsLength' );
4243 /* Private functions */
4344
4445 /**
@@ -345,7 +346,7 @@
346347 * Enable Narayam
347348 */
348349 this.enable = function() {
349 - if ( !enabled) {
 350+ if ( !enabled ) {
350351 $.cookie( 'narayam-enabled', '1', { 'path': '/', 'expires': 30 } );
351352 $( '#narayam-toggle' ).attr( 'checked', true );
352353 $( 'li#pt-narayam').removeClass( 'narayam-inactive' );
@@ -437,12 +438,13 @@
438439 return value != name;
439440 });
440441 recent.unshift( name );
441 - recent = recent.slice( 0, 5 );
 442+ recent = recent.slice( 0, recentItemsLength );
442443 recent = recent.join( "," );
443444 $.cookie( 'narayam-scheme', recent, { 'path': '/', 'expires': 30 } );
444 - if (name in schemes){
 445+ if ( name in schemes ) {
445446 currentScheme = schemes[name];
446 - }else{
 447+ }
 448+ else {
447449 // load the rules dynamically.
448450 mw.loader.using( "ext.narayam.rules." + name, function() {
449451 currentScheme = schemes[name];
@@ -534,21 +536,26 @@
535537 var scheme = recent[i];
536538 if ( $.inArray( scheme, seen ) > -1 ) { continue; }
537539 seen.push( scheme );
538 - //we show 5 recent input methods.
539 - if ( count++ > 5 ) { break; }
540 - $narayamMenuItem = that.buildMenuItem(scheme);
 540+ if ( count++ > recentItemsLength ) { break; }
 541+ $narayamMenuItem = that.buildMenuItem(scheme);
541542 $narayamMenuItem.addClass('narayam-recent-menu-item');
542543 $narayamMenuItems.append( $narayamMenuItem );
543544 }
544 -
545 - for ( var scheme in schemes ) {
546 - haveSchemes = true;
547 - if ( $.inArray( scheme, seen ) > -1 ) { continue; }
548 - seen.push( scheme );
549 - $narayamMenuItem = that.buildMenuItem(scheme);
550 - $narayamMenuItems.append( $narayamMenuItem );
 545+ // menu items for the language of wiki.
 546+ var userVariant = (typeof wgUserVariant != 'undefined' )? wgUserVariant : null;
 547+ var requested = [userVariant, wgContentLanguage, wgUserLanguage];
 548+ for ( var i = 0; i < requested.length; i++ ) {
 549+ var lang = requested[i];
 550+ var langschemes = allImes[lang];
 551+ if ( !langschemes ) continue;
 552+ for ( var scheme in langschemes ) {
 553+ haveSchemes = true;
 554+ if ( $.inArray( scheme, seen ) > -1 ) { continue; }
 555+ seen.push( scheme );
 556+ $narayamMenuItem = that.buildMenuItem(scheme);
 557+ $narayamMenuItems.append( $narayamMenuItem );
 558+ }
551559 }
552 -
553560 if ( !haveSchemes ) {
554561 // No schemes available, don't show the tool
555562 // So return false
Index: trunk/extensions/Narayam/Narayam.php
@@ -32,6 +32,8 @@
3333 // Whether the input method should be active as default or not
3434 $wgNarayamEnabledByDefault = true;
3535
 36+// Number of recently used input methods to be shown
 37+$wgNarayamRecentItemsLength = 3;
3638
3739 // Array mapping language codes and scheme names to module names
3840 // Custom schemes can be added here

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r101592Show the recently used 5 inputmethod in menu,- No need to select them from th...santhosh09:14, 2 November 2011

Status & tagging log