Index: trunk/extensions/Kieli/Kieli.i18n.php |
— | — | @@ -0,0 +1,11 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +$messages = array(); |
| 5 | + |
| 6 | +/** English |
| 7 | + * @author Niklas Laström |
| 8 | + */ |
| 9 | +$messages['en'] = array( |
| 10 | + 'kieli-desc' => 'ULUNUM The ultimate universal umpteen language picker', |
| 11 | + 'kieli-load' => 'Language', |
| 12 | +); |
\ No newline at end of file |
Property changes on: trunk/extensions/Kieli/Kieli.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 13 | + native |
Index: trunk/extensions/Kieli/Kieli.php |
— | — | @@ -0,0 +1,46 @@ |
| 2 | +<?php |
| 3 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 4 | + exit( 1 ); |
| 5 | +} |
| 6 | + |
| 7 | +$dir = dirname( __FILE__ ); |
| 8 | + |
| 9 | +// Register extension credits |
| 10 | +$wgExtensionCredits['other'][] = array( |
| 11 | + 'path' => __FILE__, |
| 12 | + 'name' => 'Kieli', |
| 13 | + 'version' => 2011-10-23, |
| 14 | + #'url' => 'http://www.mediawiki.org/wiki/Extension:Kieli', |
| 15 | + 'descriptionmsg' => 'kieli-desc' |
| 16 | +); |
| 17 | + |
| 18 | +// Localization |
| 19 | +$wgExtensionMessagesFiles['Kieli'] = $dir . '/Kieli.i18n.php'; |
| 20 | + |
| 21 | +// Register hook function |
| 22 | +$wgHooks['BeforePageDisplay'][] = 'Kieli::addModules'; |
| 23 | +$wgHooks['ResourceLoaderGetConfigVars'][] = 'Kieli::addConfig'; |
| 24 | + |
| 25 | +class Kieli { |
| 26 | + public static function addModules( $out, $skin ) { |
| 27 | + $out->addModules( 'ext.kieli' ); |
| 28 | + return true; |
| 29 | + } |
| 30 | + |
| 31 | + public static function addConfig( &$vars ) { |
| 32 | + global $wgLang; |
| 33 | + $names = Language::getTranslatedLanguageNames( $wgLang->getCode() ); |
| 34 | + $vars['wgKieliLanguages'] = $names; |
| 35 | + return true; |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +$wgResourceModules['ext.kieli'] = array( |
| 40 | + 'localBasePath' => $dir, |
| 41 | + 'remoteExtPath' => 'Kieli', |
| 42 | + 'scripts' => 'ext.kieli.js', |
| 43 | + 'styles' => 'ext.kieli.css', |
| 44 | + 'messages' => array( 'kieli-load' ), |
| 45 | + 'dependencies' => array( 'mediawiki.Uri', 'jquery.ui.autocomplete' ), |
| 46 | +); |
| 47 | + |
Property changes on: trunk/extensions/Kieli/Kieli.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 48 | + native |
Index: trunk/extensions/Kieli/ext.kieli.css |
— | — | @@ -0,0 +1,121 @@ |
| 2 | +#pt-kieli { |
| 3 | + background: url(15px-Shivakannada.png) no-repeat scroll left top transparent; |
| 4 | + padding-left: 15px !important; |
| 5 | +} |
| 6 | + |
| 7 | +.lt-menu, |
| 8 | +.lt-list { |
| 9 | + font-size: 100%; |
| 10 | + z-index: 99999; |
| 11 | +} |
| 12 | + |
| 13 | + |
| 14 | +.lt-list ul { |
| 15 | + padding-left: 5px !important; |
| 16 | +} |
| 17 | + |
| 18 | + |
| 19 | +#pt-kieli .lt-list li { |
| 20 | + margin: 0; |
| 21 | + padding: 5px; |
| 22 | + font-size: 100%; |
| 23 | + float: none; |
| 24 | +} |
| 25 | + |
| 26 | +/* Variants and Actions */ |
| 27 | +/* @noflip */ |
| 28 | +.lt-menu { |
| 29 | + direction: ltr; |
| 30 | + float: left; |
| 31 | + cursor: pointer; |
| 32 | +} |
| 33 | +.lt-menuFocus { |
| 34 | + background-position: -22px 60%; |
| 35 | +} |
| 36 | + |
| 37 | +/* @noflip */ |
| 38 | +body.rtl .lt-menu ul li { |
| 39 | + direction: rtl; |
| 40 | +} |
| 41 | + |
| 42 | +.lt-menu .lt-list { |
| 43 | + position: relative; |
| 44 | + display: none; |
| 45 | + clear: both; |
| 46 | + text-align: left; |
| 47 | +} |
| 48 | + |
| 49 | +/* OVERRIDDEN BY COMPLIANT BROWSERS */ |
| 50 | +/* @noflip */ |
| 51 | +body.rtl .lt-menu div.menu { |
| 52 | + margin-left: 24px; |
| 53 | +} |
| 54 | +/* IGNORED BY IE6 */ |
| 55 | +/* @noflip */ |
| 56 | +body.rtl .lt-menu > div.menu { |
| 57 | + margin-left: auto; |
| 58 | +} |
| 59 | +/* IGNORED BY IE6 */ |
| 60 | +/* Also fixes old versions of FireFox */ |
| 61 | +/* @noflip */ |
| 62 | +body.rtl .lt-menu > div.menu, |
| 63 | +x:-moz-any-link { |
| 64 | + margin-left: 23px; |
| 65 | +} |
| 66 | +/* Enable forcing showing of the menu for accessibility */ |
| 67 | +.lt-menu:hover div.menu, .lt-menu div.menuForceShow { |
| 68 | + display: block; |
| 69 | +} |
| 70 | +.lt-menu ul { |
| 71 | + position: absolute; |
| 72 | + background-color: white; |
| 73 | + border: solid 1px silver; |
| 74 | + border-top-width: 0; |
| 75 | + list-style: none; |
| 76 | + list-style-image: none; |
| 77 | + list-style-type: none; |
| 78 | + padding: 0; |
| 79 | + margin: 0; |
| 80 | + margin-left: -1px; |
| 81 | + text-align: left; |
| 82 | +} |
| 83 | +/* Fixes old versions of FireFox */ |
| 84 | +.lt-menu ul, |
| 85 | +x:-moz-any-link { |
| 86 | + min-width: 5em; |
| 87 | +} |
| 88 | +/* Returns things back to normal in modern versions of FireFox */ |
| 89 | +.lt-menu ul, |
| 90 | +x:-moz-any-link, |
| 91 | +x:default { |
| 92 | + min-width: 0; |
| 93 | +} |
| 94 | +.lt-menu li { |
| 95 | + padding: 0; |
| 96 | + margin: 0; |
| 97 | + text-align: left; |
| 98 | + line-height: 1em; |
| 99 | +} |
| 100 | +/* OVERRIDDEN BY COMPLIANT BROWSERS */ |
| 101 | +.lt-menu li a { |
| 102 | + display: inline-block; |
| 103 | + padding: 0.5em; |
| 104 | + white-space: nowrap; |
| 105 | + color: #0645ad; |
| 106 | + cursor: pointer; |
| 107 | + font-size: 0.8em; |
| 108 | +} |
| 109 | +/* IGNORED BY IE6 */ |
| 110 | +.lt-menu li > a { |
| 111 | + display: block; |
| 112 | +} |
| 113 | +.lt-menu li.selected a, |
| 114 | +.lt-menu li.selected a:visited { |
| 115 | + color: #333333; |
| 116 | + text-decoration: none; |
| 117 | +} |
| 118 | +.lt-menu a { |
| 119 | + display: block; |
| 120 | + padding-left:5px; |
| 121 | + padding-right:5px; |
| 122 | +} |
Property changes on: trunk/extensions/Kieli/ext.kieli.css |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 123 | + native |
Index: trunk/extensions/Kieli/15px-Shivakannada.png |
Cannot display: file marked as a binary type. |
svn:mime-type = image/png |
Property changes on: trunk/extensions/Kieli/15px-Shivakannada.png |
___________________________________________________________________ |
Added: svn:mime-type |
2 | 124 | + image/png |
Index: trunk/extensions/Kieli/ext.kieli.js |
— | — | @@ -0,0 +1,169 @@ |
| 2 | +( function( $ ) { |
| 3 | + |
| 4 | + $( document ).ready( function() { |
| 5 | + $.kieli.setup(); |
| 6 | + } ); |
| 7 | + |
| 8 | + $.kieli = { |
| 9 | + loaded: false, |
| 10 | + |
| 11 | + setup: function() { |
| 12 | + $.kieli.addMenuLabel(); |
| 13 | + }, |
| 14 | + |
| 15 | + set: function( val ) { |
| 16 | + var recent = $.cookie( 'kieli-recent' ) || []; |
| 17 | + if ( typeof recent === "string" ) { |
| 18 | + recent = recent.split( "," ); |
| 19 | + } |
| 20 | + recent.unshift( val ); |
| 21 | + recent = recent.slice( 0, 5 ); |
| 22 | + recent = recent.join( "," ); |
| 23 | + |
| 24 | + $.cookie( 'kieli-recent', recent, { 'path': '/', 'expires': 30 } ); |
| 25 | + var uri = new mw.Uri( window.location.href ); |
| 26 | + uri.extend( { setlang: val } ); |
| 27 | + window.location.href = uri.toString(); |
| 28 | + }, |
| 29 | + |
| 30 | + setCustom: function( event, data ) { |
| 31 | + $.kieli.set( data.item.value ); |
| 32 | + }, |
| 33 | + |
| 34 | + loadMenu: function() { |
| 35 | + if ( $.kieli.loaded ) { |
| 36 | + return; |
| 37 | + } |
| 38 | + $.kieli.loaded = true; |
| 39 | + |
| 40 | + var params = { |
| 41 | + action: "query", |
| 42 | + meta: "userinfo", |
| 43 | + uiprop: "acceptlang", |
| 44 | + format: "json" |
| 45 | + }; |
| 46 | + $.get( mw.util.wikiScript( "api" ), params, $.kieli.buildMenu ); |
| 47 | + |
| 48 | + var params = { |
| 49 | + action: "query", |
| 50 | + meta: "siteinfo", |
| 51 | + siprop: "languages", |
| 52 | + format: "json" |
| 53 | + }; |
| 54 | + $.get( mw.util.wikiScript( "api" ), params, $.kieli.buildLanguageInput ); |
| 55 | + }, |
| 56 | + |
| 57 | + buildLanguageInput: function( result ) { |
| 58 | + var langlist = []; |
| 59 | + var languages = result.query.languages; |
| 60 | + var localnames = mw.config.get( "wgKieliLanguages" ); |
| 61 | + for ( var i = 0; i < languages.length; i++ ) { |
| 62 | + var name = languages[i]["*"]; |
| 63 | + var code = languages[i]["code"]; |
| 64 | + if ( localnames[code] && localnames[code] !== name ) { |
| 65 | + var localnamecode = localnames[code] + " (" + code + ")"; |
| 66 | + langlist.push( { label: localnamecode, value: code } ); |
| 67 | + } |
| 68 | + var namecode = name + " (" + code + ")"; |
| 69 | + langlist.push( { label: namecode, value: code } ); |
| 70 | + } |
| 71 | + |
| 72 | + var $list = $( "#pt-kieli .lt-list ul" ); |
| 73 | + var $input = $( "<input />" ) |
| 74 | + .attr( "placeholder", "Search all languages..." ); |
| 75 | + $input.autocomplete({ |
| 76 | + source: langlist, |
| 77 | + select: $.kieli.setCustom |
| 78 | + }); |
| 79 | + |
| 80 | + $list.prepend( $input ); |
| 81 | + }, |
| 82 | + |
| 83 | + buildMenu: function( result ) { |
| 84 | + var $menu = $( "#pt-kieli .lt-list" ); |
| 85 | + var $list = $( "<ul />" ); |
| 86 | + $menu.append( $list ); |
| 87 | + |
| 88 | + var count = 1; |
| 89 | + var seen = []; |
| 90 | + |
| 91 | + var current = mw.config.get( "wgUserLanguage" ); |
| 92 | + $list.append( $.kieli.createMenuItem( current ) ); |
| 93 | + seen.push( current ); |
| 94 | + |
| 95 | + var recent = $.cookie( "kieli-recent" ) || []; |
| 96 | + if ( typeof recent === "string" ) { |
| 97 | + recent = recent.split( "," ); |
| 98 | + } |
| 99 | + for ( var i = 0; i < recent.length; i++ ) { |
| 100 | + var id = recent[i]; |
| 101 | + if ( $.inArray( id, seen ) > -1 ) { continue; } |
| 102 | + seen.push( id ); |
| 103 | + if ( count++ >= 5 ) { continue; } |
| 104 | + $list.append( $.kieli.createMenuItem( id ) ); |
| 105 | + } |
| 106 | + |
| 107 | + var languages = result.query.userinfo.acceptlang; |
| 108 | + for ( var i = 0; i < languages.length; i++ ) { |
| 109 | + var id = languages[i]["*"]; |
| 110 | + if ( $.inArray( id, seen ) > -1 ) { continue; } |
| 111 | + seen.push( id ); |
| 112 | + if ( count++ >= 5 ) { continue; } |
| 113 | + $list.append( $.kieli.createMenuItem( id ) ); |
| 114 | + } |
| 115 | + |
| 116 | + $list.delegate('input:radio', 'change', function( event ) { |
| 117 | + $.kieli.set( $(this).val() ); |
| 118 | + }); |
| 119 | + }, |
| 120 | + |
| 121 | + createMenuItem: function( id ) { |
| 122 | + var current = mw.config.get( "wgUserLanguage" ); |
| 123 | + var names = mw.config.get( "wgKieliLanguages" ); |
| 124 | + var name = names && names[id] || id; |
| 125 | + |
| 126 | + var $link = $( '<input type="radio" name="language" />' ) |
| 127 | + .val( id ) |
| 128 | + if ( id === current ) { |
| 129 | + $link = $link.attr( "checked", true ); |
| 130 | + } |
| 131 | + var $label = $( "<label />" ) |
| 132 | + .append( $link ) |
| 133 | + .append( name ); |
| 134 | + var $menuItem = $( "<li />" ).append( $label ); |
| 135 | + return $menuItem; |
| 136 | + }, |
| 137 | + |
| 138 | + addMenuLabel: function(config) { |
| 139 | + var $menuDiv = $( '<div />' ) |
| 140 | + .addClass( 'menu' ) |
| 141 | + .addClass( 'lt-list' ) |
| 142 | + .append(); |
| 143 | + |
| 144 | + var $div = $( '<div />' ) |
| 145 | + .addClass( 'lt-menu-kieli' ) |
| 146 | + .addClass( 'lt-menu' ) |
| 147 | + .append( $('<a href="#" />').append(mw.msg("kieli-load")) ) |
| 148 | + .append( $menuDiv ) |
| 149 | + .hover( $.kieli.loadMenu ); |
| 150 | + |
| 151 | + //this is the fonts link |
| 152 | + var $li = $( '<li />' ).attr('id','pt-kieli') |
| 153 | + .append( $div ); |
| 154 | + |
| 155 | + //if rtl, add to the right of top personal links. Else, to the left |
| 156 | + var fn = $('body').hasClass( 'rtl' ) ? "append" : "prepend"; |
| 157 | + $('#p-personal ul:first')[fn]( $li ); |
| 158 | + //workaround for IE bug - activex components like input fields coming on top of everything. |
| 159 | + //TODO: is there a better solution other than hiding it on hover? |
| 160 | + if ( $.browser.msie ) { |
| 161 | + $("#pt-kieli .lt-menu").hover(function(){ |
| 162 | + $("#searchform").css({ visibility: "hidden" }); |
| 163 | + },function(){ |
| 164 | + $("#searchform").css({ visibility: "visible" }); |
| 165 | + }); |
| 166 | + } |
| 167 | + } |
| 168 | + }; |
| 169 | + |
| 170 | +})(jQuery); |
\ No newline at end of file |
Property changes on: trunk/extensions/Kieli/ext.kieli.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 171 | + native |