Index: trunk/extensions/Narayam/Narayam.hooks.php |
— | — | @@ -25,7 +25,7 @@ |
26 | 26 | } |
27 | 27 | |
28 | 28 | public static function addConfig( &$vars ) { |
29 | | - global $wgNarayamEnabledByDefault, $wgUser; |
| 29 | + global $wgNarayamEnabledByDefault, $wgNarayamRecentItemsLength, $wgUser; |
30 | 30 | |
31 | 31 | if ( $wgUser->getOption( 'narayamDisable' ) ) { |
32 | 32 | // User disabled Narayam |
— | — | @@ -33,7 +33,8 @@ |
34 | 34 | } |
35 | 35 | |
36 | 36 | $vars['wgNarayamEnabledByDefault'] = $wgNarayamEnabledByDefault; |
37 | | - |
| 37 | + $vars['wgNarayamRecentItemsLength'] = $wgNarayamRecentItemsLength; |
| 38 | + |
38 | 39 | return true; |
39 | 40 | } |
40 | 41 | |
Index: trunk/extensions/Narayam/js/ext.narayam.core.js |
— | — | @@ -37,7 +37,8 @@ |
38 | 38 | var currentScheme = null; |
39 | 39 | // Shortcut key for turning Narayam on and off |
40 | 40 | var shortcutKey = getShortCutKey(); |
41 | | - |
| 41 | + // Number of recent input methods to be shown |
| 42 | + var recentItemsLength = mw.config.get( 'wgNarayamRecentItemsLength' ); |
42 | 43 | /* Private functions */ |
43 | 44 | |
44 | 45 | /** |
— | — | @@ -345,7 +346,7 @@ |
346 | 347 | * Enable Narayam |
347 | 348 | */ |
348 | 349 | this.enable = function() { |
349 | | - if ( !enabled) { |
| 350 | + if ( !enabled ) { |
350 | 351 | $.cookie( 'narayam-enabled', '1', { 'path': '/', 'expires': 30 } ); |
351 | 352 | $( '#narayam-toggle' ).attr( 'checked', true ); |
352 | 353 | $( 'li#pt-narayam').removeClass( 'narayam-inactive' ); |
— | — | @@ -437,12 +438,13 @@ |
438 | 439 | return value != name; |
439 | 440 | }); |
440 | 441 | recent.unshift( name ); |
441 | | - recent = recent.slice( 0, 5 ); |
| 442 | + recent = recent.slice( 0, recentItemsLength ); |
442 | 443 | recent = recent.join( "," ); |
443 | 444 | $.cookie( 'narayam-scheme', recent, { 'path': '/', 'expires': 30 } ); |
444 | | - if (name in schemes){ |
| 445 | + if ( name in schemes ) { |
445 | 446 | currentScheme = schemes[name]; |
446 | | - }else{ |
| 447 | + } |
| 448 | + else { |
447 | 449 | // load the rules dynamically. |
448 | 450 | mw.loader.using( "ext.narayam.rules." + name, function() { |
449 | 451 | currentScheme = schemes[name]; |
— | — | @@ -534,21 +536,26 @@ |
535 | 537 | var scheme = recent[i]; |
536 | 538 | if ( $.inArray( scheme, seen ) > -1 ) { continue; } |
537 | 539 | 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); |
541 | 542 | $narayamMenuItem.addClass('narayam-recent-menu-item'); |
542 | 543 | $narayamMenuItems.append( $narayamMenuItem ); |
543 | 544 | } |
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 | + } |
551 | 559 | } |
552 | | - |
553 | 560 | if ( !haveSchemes ) { |
554 | 561 | // No schemes available, don't show the tool |
555 | 562 | // So return false |
Index: trunk/extensions/Narayam/Narayam.php |
— | — | @@ -32,6 +32,8 @@ |
33 | 33 | // Whether the input method should be active as default or not |
34 | 34 | $wgNarayamEnabledByDefault = true; |
35 | 35 | |
| 36 | +// Number of recently used input methods to be shown |
| 37 | +$wgNarayamRecentItemsLength = 3; |
36 | 38 | |
37 | 39 | // Array mapping language codes and scheme names to module names |
38 | 40 | // Custom schemes can be added here |