diff --git a/UniversalLanguageSelector.hooks.php b/UniversalLanguageSelector.hooks.php index 9af3b102..dbc71b9e 100644 --- a/UniversalLanguageSelector.hooks.php +++ b/UniversalLanguageSelector.hooks.php @@ -48,5 +48,50 @@ class UniversalLanguageSelectorHooks { ) ) + $personal_urls; return true; } - + /** + * Add the template for the ULS to the body. + * Hooks: SkinAfterContent + * TODO: move to JavaScript side + * TODO: hardcoded English + */ + public static function addTemplate( &$data, $skin ) { + global $wgContLang; + $languages = Language::fetchLanguageNames( $wgContLang->getCode() ); + $languageData = htmlspecialchars( FormatJSON::encode( $languages ) ); + $data .= " +
"; + return true; + } } diff --git a/UniversalLanguageSelector.i18n.php b/UniversalLanguageSelector.i18n.php index 9dd57915..481ea134 100644 --- a/UniversalLanguageSelector.i18n.php +++ b/UniversalLanguageSelector.i18n.php @@ -8,11 +8,21 @@ $messages = array(); -/** English +/** + * English * @author santhosh -*/ + */ $messages['en'] = array( 'UniversalLanguageSelector' => 'Universal Language Selector', - 'uls-desc' => 'Universal Language Selector', - 'uls-select-content-language' => 'Select Content Language', + 'uls-desc' => 'Universal Language Selector', + 'uls-select-content-language' => 'Select language', ); +/** + * Message documentation + * @author santhosh + */ +$messages['qqq'] = array( + 'UniversalLanguageSelector' => 'Extension name', + 'uls-desc' => 'Extension description', + 'uls-select-content-language' => 'Main heading in the language selector popup.', +); \ No newline at end of file diff --git a/UniversalLanguageSelector.php b/UniversalLanguageSelector.php index 8636df22..ad9f6e16 100644 --- a/UniversalLanguageSelector.php +++ b/UniversalLanguageSelector.php @@ -1,7 +1,7 @@ 'uls-desc', ); -$dir = dirname( __FILE__ ); +$dir = __DIR__ ; // Internationalization $wgExtensionMessagesFiles['UniversalLanguageSelector'] = "$dir/UniversalLanguageSelector.i18n.php"; @@ -34,6 +34,7 @@ $wgAutoloadClasses['UniversalLanguageSelectorHooks'] = "$dir/UniversalLanguageSe $wgHooks['BeforePageDisplay'][] = 'UniversalLanguageSelectorHooks::addModules'; $wgHooks['PersonalUrls'][] = 'UniversalLanguageSelectorHooks::addTrigger'; +$wgHooks['SkinAfterContent'][] = 'UniversalLanguageSelectorHooks::addTemplate'; $wgResourceModules['ext.uls.init'] = array( 'scripts' => 'resources/ext.uls.init.js', @@ -44,15 +45,14 @@ $wgResourceModules['ext.uls.init'] = array( ); $wgResourceModules['ext.uls.core'] = array( - 'scripts' => array( 'resources/ext.uls.core.js' ), + 'scripts' => array( 'resources/ext.uls.core.js', 'resources/ext.uls.languagefilter.js' ), 'styles' => 'resources/css/ext.uls.css', 'localBasePath' => $dir, 'remoteExtPath' => 'UniversalLanguageSelector', 'dependencies' => array( 'mediawiki.util', - ), - 'messages' => array( - 'uls-select-content-language', + 'mediawiki.Uri', + 'jquery.ui.autocomplete' ), 'position' => 'top', ); diff --git a/resources/css/ext.uls.css b/resources/css/ext.uls.css index 485a1f1e..3f75eddf 100644 --- a/resources/css/ext.uls.css +++ b/resources/css/ext.uls.css @@ -5,17 +5,15 @@ } .uls-menu { - position: absolute; - top: 100%; - left: 0; + position: fixed; z-index: 1000; display: none; - float: left; - min-width: 400px; - min-height: 400px; - padding: 4px 0; - margin: 1px 0 0; - list-style: none; + min-width: 600px; + min-height: 500px; + margin-top: 1px; + width: 50%; + + /* Styling */ background-color: #ffffff; border: 1px solid #ccc; border: 1px solid rgba(0, 0, 0, 0.2); @@ -30,20 +28,109 @@ -webkit-background-clip: padding-box; -moz-background-clip: padding; background-clip: padding-box; - width: 50% -} -.uls-menu h2 { - float:left; -} -a.close{ - float: right; - padding: 10px; } -div#worldmap { +.uls-menu-header { + margin: 2%; + margin-top: 20px; +} + +.uls-lang-selector { + margin: 2%; +} + +.uls-menu-header-left { + float: left; +} + +.uls-menu-header-left h1 { + font-weight: bold; + padding-top: 12px; + border:none; + padding-bottom: 3px; +} + +.uls-menu-header-right { + float: right; +} + +.uls-worldmap { /* @embed */ background: url('../images/world_map.png') no-repeat scroll left center transparent; - float: right; width: 400px; - height: 200px; + height: 197px; } + +.uls-region { + float: left; + cursor: pointer; + text-align: center; + width: 133px; + padding: 0; + margin: 0; + height: 197px; +} + +.uls-region:hover { + outline: 1px solid #0E90D2; + background: black; + opacity: 0.4; +} + +.uls-region.active { + background: black; + opacity: 0.4; +} + +.icon-close { + /* @embed */ + background: url('../images/close.png') no-repeat scroll left center transparent; + float: right; + padding: 10px; + cursor: pointer; +} + +/* Language list */ +.uls-language-list { + height: 300px; + overflow: auto; + margin-top: 2%; +} + +.uls-language-list ul { + list-style: none; + margin-left: 0; + -moz-column-count: 3; + -webkit-column-count: 3; + column-count: 3; +} + +.uls-language-list ul li { + font-weight: bold; +} + +.uls-language-list strong { + text-decoration: underline; +} + +.uls-language-list a { + color: #0645AD; +} + +input#languagefilter { + height: 20px; + border: 1px solid #0E90D2; + border-right: none; + width: 95%; +} + +span.search-button { + /* @embed */ + background: url('../images/search.png') no-repeat scroll left center transparent; + cursor: pointer; + height: 22px; + border: 1px solid #0E90D2; + position: absolute; + width: 20px; + border-left: none; +} \ No newline at end of file diff --git a/resources/ext.uls.core.js b/resources/ext.uls.core.js index e4749cd7..85a50dbe 100644 --- a/resources/ext.uls.core.js +++ b/resources/ext.uls.core.js @@ -1,48 +1,59 @@ -(function($) { +(function ( $, mw ) { "use strict"; - var ULS = function(element, options) { + var ULS = function( element, options ) { this.$element = $( element ); this.options = $.extend( {}, $.fn.uls.defaults, options ); - this.$menu = $( this.options.menu ).appendTo( 'body' ); + this.$menu = $( this.options.menu ); this.shown = false; this.render(); this.listen(); - } + }; ULS.prototype = { - constructor : ULS, - show : function() { + constructor: ULS, + show: function() { var pos = $.extend( {}, this.$element.offset(), { - height : this.$element[0].offsetHeight + height: this.$element[0].offsetHeight } ); this.$menu.css( { - top : pos.top + pos.height, - left : '25%' //pos.left // FIXME + top: pos.top + pos.height, + left: '25%' //pos.left // FIXME } ); this.$menu.show(); this.shown = true; + return this; }, - hide : function() { + hide: function() { this.$menu.hide(); this.shown = false; return this; }, - render: function(){ - // TODO : All UI construction code to go here. - var $heading = $("