diff --git a/UniversalLanguageSelector.hooks.php b/UniversalLanguageSelector.hooks.php
index 04600b0d..ae97eb67 100644
--- a/UniversalLanguageSelector.hooks.php
+++ b/UniversalLanguageSelector.hooks.php
@@ -71,12 +71,18 @@ class UniversalLanguageSelectorHooks {
* Add some tabs for navigation for users who do not use Ajax interface.
* Hooks: SkinTemplateNavigation, SkinTemplateTabs
*/
- static function addTrigger( array &$personal_urls, &$title ) {
- global $wgLang, $wgUser;
+ static function addPersonalBarTrigger( array &$personal_urls, &$title ) {
+ global $wgLang, $wgUser, $wgULSPosition;
+
+ if ( $wgULSPosition !== 'personal' ) {
+ return true;
+ }
+
if ( !self::isToolbarEnabled( $wgUser ) ) {
return true;
}
+ // The element id will be 'pt-uls'
$personal_urls = array(
'uls' => array(
'text' => $wgLang->getLanguageName( $wgLang->getCode() ),
@@ -251,6 +257,8 @@ class UniversalLanguageSelectorHooks {
$out->getLanguage()->getCode(), 'mwfile'
);
$vars['wgULSAcceptLanguageList'] = array_keys( $out->getRequest()->getAcceptLang() );
+ global $wgULSPosition;
+ $vars['wgULSPosition'] = $wgULSPosition;
return true;
}
@@ -262,4 +270,27 @@ class UniversalLanguageSelectorHooks {
return true;
}
+
+ /**
+ * Hook: SkinTemplateOutputPageBeforeExec
+ * @param Skin $skin
+ * @param QuickTemplate $template
+ * @return bool
+ */
+ public static function onSkinTemplateOutputPageBeforeExec( Skin &$skin, QuickTemplate &$template ) {
+ global $wgULSPosition;
+
+ if ( $wgULSPosition !== 'interlanguage' ) {
+ return true;
+ }
+
+ // A dummy link, just to make sure that the section appears
+ $template->data['language_urls'][] = array(
+ 'href' => '#',
+ 'text' => '',
+ 'class' => 'uls-p-lang-dummy',
+ );
+
+ return true;
+ }
}
diff --git a/UniversalLanguageSelector.php b/UniversalLanguageSelector.php
index b2615998..b5cf0490 100644
--- a/UniversalLanguageSelector.php
+++ b/UniversalLanguageSelector.php
@@ -83,6 +83,18 @@ $wgULSEnable = true;
*/
$wgULSEnableAnon = true;
+/**
+ * The location and the form of the language selection trigger.
+ * The possible values are:
+ * 'personal': as a link near the username or the log in link in
+ * the personal toolbar (default).
+ * 'interlanguage': as an icon near the header of the list of interlanguage
+ * links in the sidebar.
+ *
+ * @since 2013.04
+ */
+$wgULSPosition = 'personal';
+
$dir = __DIR__;
// Internationalization
@@ -94,12 +106,13 @@ $wgAutoloadClasses['ApiLanguageSearch'] = "$dir/api/ApiLanguageSearch.php";
$wgAutoloadClasses['LanguageNameSearch'] = "$dir/data/LanguageNameSearch.php";
$wgHooks['BeforePageDisplay'][] = 'UniversalLanguageSelectorHooks::addModules';
-$wgHooks['PersonalUrls'][] = 'UniversalLanguageSelectorHooks::addTrigger';
+$wgHooks['PersonalUrls'][] = 'UniversalLanguageSelectorHooks::addPersonalBarTrigger';
$wgHooks['ResourceLoaderTestModules'][] = 'UniversalLanguageSelectorHooks::addTestModules';
$wgHooks['ResourceLoaderGetConfigVars'][] = 'UniversalLanguageSelectorHooks::addConfig';
$wgHooks['MakeGlobalVariablesScript'][] = 'UniversalLanguageSelectorHooks::addVariables';
$wgAPIModules['languagesearch'] = 'ApiLanguageSearch';
$wgHooks['UserGetLanguageObject'][] = 'UniversalLanguageSelectorHooks::getLanguage';
+$wgHooks['SkinTemplateOutputPageBeforeExec'][] = 'UniversalLanguageSelectorHooks::onSkinTemplateOutputPageBeforeExec';
$wgDefaultUserOptions['uls-preferences'] = '';
$wgHooks['GetPreferences'][] = 'UniversalLanguageSelectorHooks::onGetPreferences';
diff --git a/i18n/en.json b/i18n/en.json
index 1a3bc03d..7d1322ee 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -1,6 +1,7 @@
{
"@metadata": {
"authors": [
+ "Amire80",
"Santhosh Thottingal"
],
"message-documentation": "qqq"
@@ -8,6 +9,7 @@
"ext-uls-display-settings-title": "Display settings",
"ext-uls-display-settings-title-short": "Display",
"ext-uls-display-settings-desc": "Set language used for menus and fonts.",
+"ext-uls-select-language-settings-icon-tooltip": "Language settings",
"ext-uls-undo-language-tooltip-text": "Language changed from $1",
"ext-uls-language-settings-title": "Language settings",
"ext-uls-language-settings-apply": "Apply settings",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index ff3cf4c1..52f57cbf 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -1,6 +1,7 @@
{
"@metadata": {
"authors": [
+ "Amire80",
"Hyperborean",
"Lloffiwr",
"Santhosh Thottingal",
@@ -10,6 +11,7 @@
"ext-uls-display-settings-title": "Display settings title text",
"ext-uls-display-settings-title-short": "A short name for display settings screen. Can be a translation for 'Display'",
"ext-uls-display-settings-desc": "Short description about display settings. 'Set language used for menus and set fonts' is equivalent in meaning to the source message.",
+ "ext-uls-select-language-settings-icon-tooltip": "A tooltip for the icon that shows the language selector.",
"ext-uls-undo-language-tooltip-text": "Text for the tooltip appearing when language is changed. $1 is the previous language acronym.",
"ext-uls-language-settings-title": "Title text for language settings screen",
"ext-uls-language-settings-apply": "Label for apply settings button in language settings screen",
@@ -40,4 +42,4 @@
"ext-uls-input-enable": "Label for enable input tools button",
"ext-uls-input-disable-info": "Info text for the disable input tools button",
"ext-uls-input-settings-noime": "Text to be shown when no input methods are available for a selected language"
-}
\ No newline at end of file
+}
diff --git a/resources/css/ext.uls.css b/resources/css/ext.uls.css
index 9f51ce44..fba7185f 100644
--- a/resources/css/ext.uls.css
+++ b/resources/css/ext.uls.css
@@ -1,7 +1,29 @@
+/*
+ * The trigger can be placed in the personal toolbar near the username
+ * or near the interlanguage links.
+ */
+
#pt-uls a.uls-trigger {
padding-left: 30px;
}
+#p-lang .uls-trigger {
+ /* @embed */
+ background: transparent url('../images/cog-sprite.png') right top no-repeat;
+ background-image: -webkit-linear-gradient(transparent, transparent), url('../images/cog-sprite.svg');
+ background-image: -moz-linear-gradient(transparent, transparent), url('../images/cog-sprite.svg');
+ background-image: linear-gradient(transparent, transparent), url('../images/cog-sprite.svg');
+ background-size: 14px auto;
+ border-radius: 0 0 5px 5px;
+ height: 14px;
+ float: right;
+ cursor: pointer;
+}
+
+#p-lang .uls-trigger:hover {
+ background-position: right -18px;
+}
+
/* Opera for some inexplicable reason confuses right and left padding with */
/* RTL text direction here (bug 45142). x:-o-prefocus won't match anything, */
/* but will make other browsers ignore this rule. */
diff --git a/resources/images/cog-sprite.png b/resources/images/cog-sprite.png
new file mode 100644
index 00000000..c8278048
Binary files /dev/null and b/resources/images/cog-sprite.png differ
diff --git a/resources/images/cog-sprite.svg b/resources/images/cog-sprite.svg
new file mode 100644
index 00000000..75cd2a2f
--- /dev/null
+++ b/resources/images/cog-sprite.svg
@@ -0,0 +1,29 @@
+
+
+
+
\ No newline at end of file
diff --git a/resources/js/ext.uls.interface.js b/resources/js/ext.uls.interface.js
index 3e635dc6..05cb0105 100644
--- a/resources/js/ext.uls.interface.js
+++ b/resources/js/ext.uls.interface.js
@@ -21,9 +21,27 @@
'use strict';
$( document ).ready( function () {
- var $ulsTrigger, previousLanguages, previousLang,
+ var $ulsTrigger, $pLang,
+ previousLanguages, previousLang,
+ ulsPosition = mw.config.get( 'wgULSPosition' ),
+ tipsyGravity = {
+ personal: 'n',
+ interlanguage: $( 'body' ).hasClass( 'rtl' ) ? 'e' : 'w'
+ },
currentLang = mw.config.get( 'wgUserLanguage' );
+ if ( ulsPosition === 'interlanguage' ) {
+ // The interlanguage links section
+ $pLang = $( '#p-lang' );
+ // Add an element near the interlanguage links header
+ $pLang.prepend( $( '' )
+ .addClass( 'uls-trigger' )
+ .attr( 'title', $.i18n( 'ext-uls-language-settings-title' ) )
+ );
+ // Remove the dummy link that was added to make sure that the section appears
+ $pLang.find( '.uls-p-lang-dummy' ).remove();
+ }
+
$ulsTrigger = $( '.uls-trigger' );
previousLanguages = mw.uls.getPreviousLanguages() || [];
previousLang = previousLanguages.slice( -1 )[0];
@@ -117,6 +135,10 @@
}
} );
+ if ( ulsPosition === 'interlanguage' ) {
+ $ulsTrigger.attr( 'title', $.i18n( 'ext-uls-select-language-settings-icon-tooltip' ) );
+ }
+
if ( !previousLang ) {
previousLanguages.push( currentLang );
mw.uls.setPreviousLanguages( previousLanguages );
@@ -135,7 +157,7 @@
// Attach a tipsy tooltip to the trigger
$ulsTrigger.tipsy( {
- gravity: 'n',
+ gravity: tipsyGravity[ulsPosition],
delayOut: 3000,
html: true,
fade: true,