Make the close button of language settings work

* Actually it should go to previous context. but that is a FIXME
* Jslint fixes

Change-Id: I2e0685adc42331fd86716dfa73be3630208aa893
This commit is contained in:
Santhosh Thottingal
2012-08-21 14:53:19 +05:30
parent 5c6567adbc
commit d070071274
2 changed files with 29 additions and 13 deletions

View File

@@ -17,7 +17,7 @@
* @licence MIT License
*/
( function( $, mw ) {
( function( $, mw, window, undefined ) {
"use strict";
var template = '<div class="row"><div class="twelve columns"><h3>Display Settings</h3></div></div>'
@@ -112,6 +112,15 @@
languages.push( previousLanguages[lang] );
}
function buttonHandler( button ) {
return function () {
that.uiLanguage = button.data( "language" ) || that.uiLanguage;
$( "div.uls-ui-languages button.button" ).removeClass( "down" );
button.addClass( "down" );
that.prepareUIFonts();
};
}
for ( var i = 0; i < 3; i++ ) {
var language = languages[i];
var $button = $( '<button>' )
@@ -122,12 +131,7 @@
}
$button.data( 'language', language );
$languages.append( $button );
$button.on ( 'click', function () {
that.uiLanguage = $( this ).data( "language" ) || that.uiLanguage;
$( "div.uls-ui-languages button.button" ).removeClass( "down" );
$( this ).addClass( "down" );
that.prepareUIFonts();
} );
$button.on ( 'click', buttonHandler( $button ) );
}
this.prepareMoreLanguages();
},
@@ -190,7 +194,7 @@
*/
getUILanguage: function () {
if ( !window.mw ) {
return navigator.language || navigator.userLanguage;
return window.navigator.language || window.navigator.userLanguage;
}
return mw.config.get( 'wgUserLanguage' );
},
@@ -277,10 +281,15 @@
$uiFontSelector = this.$template.find( "select#ui-font-selector" );
// TODO all these repeated selectors can be placed in object constructor.
this.$template.find( '#uls-displaysettings-apply' ).on( 'click', function () {
this.$template.find( 'button#uls-displaysettings-apply' ).on( 'click', function () {
that.apply();
} );
this.$template.find( 'button.uls-settings-close' ).on( 'click', function () {
// FIXME This should actually go to the previous context than just hiding.
that.hide();
} );
this.$template.find( '#webfonts-enable-checkbox' ).on( 'click', function () {
if ( this.checked ) {
that.webfontPreferences.set( 'webfonts-enabled', true );
@@ -308,6 +317,14 @@
} );
},
/**
* Hide this window.2
*/
hide: function () {
this.$parent.hide();
},
/**
* Change the language of wiki using setlang URL parameter
* @param {String} language
@@ -356,4 +373,4 @@
$.fn.languagesettings.modules = $.extend( $.fn.languagesettings.modules, {
display: DisplaySettings
} );
} ) ( jQuery, mediaWiki );
} ) ( jQuery, mediaWiki, window );