Whitespace cleanup, remove deprecated methods

* Fixed many white space issues- mainly whitespace missing before
  function start paranthesis eg: function()
* Removed the deprecated live methods and replaced with on
* Added file documentation for ext.uls.geoclient

Change-Id: Ib2c8cfed1a6ff3859495e707680d5c19882a33e8
This commit is contained in:
Santhosh Thottingal
2012-09-07 16:43:53 +05:30
parent d29364989f
commit 5b3f7cc269
6 changed files with 85 additions and 63 deletions

View File

@@ -152,8 +152,7 @@
left: that.$parent.left, left: that.$parent.left,
top: that.$parent.top, top: that.$parent.top,
onReady: function ( uls ) { onReady: function ( uls ) {
var $back = $( '<a>' ) var $back = $( '<a>' ).prop( 'href', '#' )
.prop( 'href', '#' )
.prop( 'title', 'Back to display settings' ) .prop( 'title', 'Back to display settings' )
.text( '← Back to display settings' ); // FIXME i18n .text( '← Back to display settings' ); // FIXME i18n
@@ -227,8 +226,7 @@
if ( fonts && fonts.length ) { if ( fonts && fonts.length ) {
$.each( fonts, function ( key, font ) { $.each( fonts, function ( key, font ) {
var $fontOption = $( "<option>" ) var $fontOption = $( "<option>" ).attr( "value", font ).text( font );
.attr( "value", font ).text( font );
$fontSelector.append( $fontOption ); $fontSelector.append( $fontOption );
$fontOption.attr( 'selected', savedFont === font ); $fontOption.attr( 'selected', savedFont === font );
} ); } );
@@ -256,8 +254,7 @@
if ( fonts && fonts.length ) { if ( fonts && fonts.length ) {
$.each( fonts, function ( key, font ) { $.each( fonts, function ( key, font ) {
var $fontOption = $( "<option>" ) var $fontOption = $( "<option>" ).attr( "value", font ).text( font );
.attr( "value", font ).text( font );
$fontSelector.append( $fontOption ); $fontSelector.append( $fontOption );
$fontOption.attr( 'selected', savedFont === font ); $fontOption.attr( 'selected', savedFont === font );
} ); } );
@@ -277,9 +274,10 @@
* Register general event listeners * Register general event listeners
*/ */
listen: function () { listen: function () {
var that = this, var that = this;
$contentFontSelector = this.$template.find( "select#content-font-selector" ), var $contentFontSelector = this.$template
$uiFontSelector = this.$template.find( "select#ui-font-selector" ); .find( "select#content-font-selector" ), $uiFontSelector = this.$template
.find( "select#ui-font-selector" );
// TODO all these repeated selectors can be placed in object constructor. // TODO all these repeated selectors can be placed in object constructor.
this.$template.find( 'button#uls-displaysettings-apply' ).on( 'click', function () { this.$template.find( 'button#uls-displaysettings-apply' ).on( 'click', function () {
@@ -361,4 +359,6 @@
$.fn.languagesettings.modules = $.extend( $.fn.languagesettings.modules, { $.fn.languagesettings.modules = $.extend( $.fn.languagesettings.modules, {
display: DisplaySettings display: DisplaySettings
} ); } );
}( jQuery, mediaWiki, window ) ); }( jQuery, mediaWiki, window ) );

View File

@@ -1,3 +1,22 @@
/**
* ULS GeoIP client
*
* Copyright (C) 2012 Alolita Sharma, Amir Aharoni, Arun Ganesh, Brandon Harris,
* Niklas Laxström, Pau Giner, Santhosh Thottingal, Siebrand Mazeland and other
* contributors. See CREDITS for a list.
*
* UniversalLanguageSelector is dual licensed GPLv2 or later and MIT. You don't
* have to do anything special to choose one license or the other and you don't
* have to notify anyone which license you are using. You are free to use
* UniversalLanguageSelector in commercial projects as long as the copyright
* header is left intact. See files GPL-LICENSE and MIT-LICENSE for details.
*
* @file
* @ingroup Extensions
* @licence GNU General Public Licence 2.0 or later
* @licence MIT License
*/
( function( mw, $ ) { ( function( mw, $ ) {
"use strict"; "use strict";

View File

@@ -173,27 +173,27 @@
// to give the user a better chance to see it. // to give the user a better chance to see it.
6000 6000
); );
$( '.tipsy' ).live( 'mouseout', function( e ) {
tipsyTimer = window.setTimeout( function() { // manually show the tooltip
$ulsTrigger.tipsy('hide'); $ulsTrigger.on( 'mouseover', function ( e ) {
}, $( this ).tipsy( 'show' );
3000 // hide the link in 3 seconds
);
} );
// if the mouse is over the tooltip, do not hide // if the mouse is over the tooltip, do not hide
$( '.tipsy' ).live( 'mouseover', function( e ) { $( '.tipsy' ).on( 'mouseover', function ( e ) {
window.clearTimeout( tipsyTimer ); window.clearTimeout( tipsyTimer );
} ); } );
// manually show the tooltip $( '.tipsy' ).on( 'mouseout', function ( e ) {
$ulsTrigger.bind( 'mouseover', function( e ) { tipsyTimer = window.setTimeout( function () {
$( this ).tipsy( 'show' ); $ulsTrigger.tipsy( 'hide' );
}, 3000 // hide the link in 3 seconds
);
} );
} ); } );
// hide the tooltip when clicked on uls trigger // hide the tooltip when clicked on uls trigger
$ulsTrigger.bind( 'click', function( e ) { $ulsTrigger.on( 'click', function ( e ) {
$( this ).tipsy( 'hide' ); $( this ).tipsy( 'hide' );
} ); } );
// Event handler for links in the tooltip // Event handler for links in the tooltip
$( 'a.uls-lang-link' ).live( 'click', function() { $( 'a.uls-lang-link' ).on( 'click', function () {
mw.uls.changeLanguage( $( this ).attr( 'lang' ) ); mw.uls.changeLanguage( $( this ).attr( 'lang' ) );
} ); } );
} ); } );

View File

@@ -64,7 +64,8 @@
var that = this; var that = this;
// Register all event listeners to the ULS language settings here. // Register all event listeners to the ULS language settings here.
that.$element.on( "click", $.proxy( that.show, that ) ); that.$element.on( "click", $.proxy( that.show, that ) );
that.$window.find( 'span#languagesettings-close' ).on( "click", $.proxy( that.hide, that ) ); that.$window.find( 'languagesettings-close' )
.on( "click", $.proxy( that.hide, that ) );
}, },
render: function () { render: function () {

View File

@@ -18,7 +18,7 @@
* @licence MIT License * @licence MIT License
*/ */
( function( $, mw ) { ( function ( $, mw, undefined ) {
"use strict"; "use strict";
var ULSPreferences = function ( group ) { var ULSPreferences = function ( group ) {
@@ -46,6 +46,7 @@
/** /**
* Set the preference * Set the preference
*
* @param {String} key * @param {String} key
* @param value * @param value
*/ */
@@ -58,6 +59,7 @@
/** /**
* Get a preference value for the given preference name * Get a preference value for the given preference name
*
* @param key * @param key
* @returns * @returns
*/ */