Fix indentation and tweak comments a bit

Bug: 50859
Change-Id: Ic827e200674fb72b8b88e362bab30662cc13e304
This commit is contained in:
Amir E. Aharoni
2013-07-06 14:00:35 +03:00
parent 70d6a7febc
commit 6fdc9241e6

View File

@@ -137,6 +137,7 @@
if ( previousLang === currentLang ) { if ( previousLang === currentLang ) {
$ulsTrigger.tipsy( { gravity: rtlPage ? 'e' : 'w' } ); $ulsTrigger.tipsy( { gravity: rtlPage ? 'e' : 'w' } );
return true; return true;
} }
@@ -224,108 +225,115 @@
$( document ).ready( function () { $( document ).ready( function () {
mw.uls.init( function () { mw.uls.init( function () {
var $ulsTrigger = $( '.uls-trigger' ), var $ulsSettingsTrigger,
$ulsSettingsTrigger, $pLang,
$pLang, ulsOptions,
ulsOptions, $ulsTrigger = $( '.uls-trigger' ),
rtlPage = $( 'body' ).hasClass( 'rtl' ), rtlPage = $( 'body' ).hasClass( 'rtl' ),
anonMode = ( mw.user.isAnon() && anonMode = ( mw.user.isAnon() &&
!mw.config.get( 'wgULSAnonCanChangeLanguage' ) ), !mw.config.get( 'wgULSAnonCanChangeLanguage' ) ),
ulsPosition = mw.config.get( 'wgULSPosition' ); ulsPosition = mw.config.get( 'wgULSPosition' );
if ( ulsPosition === 'interlanguage' ) { if ( ulsPosition === 'interlanguage' ) {
// The interlanguage links section // The interlanguage links section
$pLang = $( '#p-lang' ); $pLang = $( '#p-lang' );
// Add an element near the interlanguage links header // Add an element near the interlanguage links header
$ulsSettingsTrigger = $( '<span>' ) $ulsSettingsTrigger = $( '<span>' )
.addClass( 'uls-settings-trigger' ) .addClass( 'uls-settings-trigger' )
.attr( 'title', $.i18n( 'ext-uls-language-settings-title' ) ); .attr( 'title', $.i18n( 'ext-uls-language-settings-title' ) );
// Append ULS cog to languages section. But make sure it is visible. // Append ULS cog to languages section, but make sure it is visible.
$pLang.show().prepend( $ulsSettingsTrigger ); $pLang.show().prepend( $ulsSettingsTrigger );
// Remove the dummy link that was added to make sure that the section appears // Remove the dummy link, which was added to make sure that the section appears
$pLang.find( '.uls-p-lang-dummy' ).remove(); $pLang.find( '.uls-p-lang-dummy' ).remove();
if ( !$pLang.find( 'div ul' ).children().length ) { if ( !$pLang.find( 'div ul' ).children().length ) {
// Replace the title of the interlanguage links // Replace the title of the interlanguage links area
// area if there are no interlanguage links // if there are no interlanguage links
$pLang.find( 'h3' ) $pLang.find( 'h3' )
.text( mw.msg( 'uls-plang-title-languages' ) ); .text( mw.msg( 'uls-plang-title-languages' ) );
// Remove the empty box that appears in the monobook skin // Remove the empty box that appears in the monobook skin
if ( mw.config.get( 'skin' ) === 'monobook' ) { if ( mw.config.get( 'skin' ) === 'monobook' ) {
$pLang.find( 'div.pBody' ).remove(); $pLang.find( 'div.pBody' ).remove();
}
} }
} }
}
// ULS options that are common to all modes of showing // ULS options that are common to all modes of showing
ulsOptions = { ulsOptions = {
onReady: function () { onReady: function () {
if ( $.fn.languagesettings ) { if ( $.fn.languagesettings ) {
addDisplaySettings( this ); addDisplaySettings( this );
addInputSettings( this ); addInputSettings( this );
}
},
onSelect: function ( language ) {
mw.uls.changeLanguage( language );
},
languages: mw.config.get( 'wgULSLanguages' ),
searchAPI: mw.util.wikiScript( 'api' ) + '?action=languagesearch',
quickList: function () {
return mw.uls.getFrequentLanguageList();
} }
}, };
onSelect: function ( language ) {
mw.uls.changeLanguage( language ); if ( ulsPosition === 'interlanguage' ) {
}, $ulsSettingsTrigger.attr( {
languages: mw.config.get( 'wgULSLanguages' ), title: $.i18n( 'ext-uls-select-language-settings-icon-tooltip' )
searchAPI: mw.util.wikiScript( 'api' ) + '?action=languagesearch', } );
quickList: function () {
return mw.uls.getFrequentLanguageList(); $ulsSettingsTrigger.languagesettings( {
defaultModule: 'display',
onVisible: function () {
var topRowHeight, caretHeight, caretWidth,
$caretBefore = $( '<span>' ).addClass( 'caret-before' ),
$caretAfter = $( '<span>' ).addClass( 'caret-after' ),
ulsTriggerWidth = $ulsSettingsTrigger.width(),
ulsTriggerOffset = $ulsSettingsTrigger.offset();
// Add the callout caret triangle
// pointing to the trigger icon
this.$window.addClass( 'callout' );
this.$window.prepend( $caretBefore, $caretAfter );
// Calculate the positioning of the panel
// according to the position of the trigger icon
if ( rtlPage ) {
caretWidth = parseInt( $caretBefore.css( 'border-left-width' ), '10' );
this.left = ulsTriggerOffset.left - this.$window.width() - caretWidth;
} else {
caretWidth = parseInt( $caretBefore.css( 'border-right-width' ), '10' );
this.left = ulsTriggerOffset.left + ulsTriggerWidth + caretWidth;
}
topRowHeight = this.$window.find( '.row' ).height();
caretHeight = parseInt( $caretBefore.css( 'top' ), '10' );
this.top = ulsTriggerOffset.top - topRowHeight - caretHeight / 2;
this.position();
}
} );
} else if ( anonMode ) {
$ulsTrigger.languagesettings();
} else {
$ulsTrigger.uls( ulsOptions );
} }
};
if ( ulsPosition === 'interlanguage' ) { // Bind language settings to preferences page link
$ulsSettingsTrigger.attr( 'title', $.i18n( 'ext-uls-select-language-settings-icon-tooltip' ) ); $( '#uls-preferences-link' )
.text( $.i18n( 'ext-uls-language-settings-preferences-link' ) )
$ulsSettingsTrigger.languagesettings( { .click( function () {
defaultModule: 'display', if ( $ulsTrigger.length ) {
onVisible: function () { $ulsTrigger.click();
var topRowHeight, caretHeight, caretWidth,
$caretBefore = $( '<span>' ).addClass( 'caret-before' ),
$caretAfter = $( '<span>' ).addClass( 'caret-after' ),
ulsTriggerWidth = $ulsSettingsTrigger.width(),
ulsTriggerOffset = $ulsSettingsTrigger.offset();
this.$window.addClass( 'callout' );
this.$window.prepend( $caretBefore, $caretAfter );
if ( rtlPage ) {
caretWidth = parseInt( $caretBefore.css( 'border-left-width' ), '10' );
this.left = ulsTriggerOffset.left - this.$window.width() - caretWidth;
} else { } else {
caretWidth = parseInt( $caretBefore.css( 'border-right-width' ), '10' ); $( '.uls-settings-trigger' ).click();
this.left = ulsTriggerOffset.left + ulsTriggerWidth + caretWidth;
} }
topRowHeight = this.$window.find( '.row' ).height(); return false;
caretHeight = parseInt( $caretBefore.css( 'top' ), '10' ); } );
this.top = ulsTriggerOffset.top - topRowHeight - caretHeight / 2;
this.position(); showULSTooltip();
} } );
} );
} else if ( anonMode ) {
$ulsTrigger.languagesettings();
} else {
$ulsTrigger.uls( ulsOptions );
}
// Bind language settings to preferences page link
$( '#uls-preferences-link' )
.text( $.i18n( 'ext-uls-language-settings-preferences-link' ) )
.click( function () {
if ( $ulsTrigger.length ) {
$ulsTrigger.click();
} else {
$( '.uls-settings-trigger' ).click();
}
return false;
} );
showULSTooltip();
} );
} ); } );
}( jQuery, mediaWiki ) ); }( jQuery, mediaWiki ) );