Update ULS from upstream

Change-Id: Ic1bcfb82ad433600ebb4896e303f3cf205d384e1
This commit is contained in:
Amir E. Aharoni
2013-04-25 15:17:44 +03:00
parent 1844228c35
commit 2b2477c36c
2 changed files with 29 additions and 3 deletions

View File

@@ -114,12 +114,33 @@
ULS.prototype = { ULS.prototype = {
constructor: ULS, constructor: ULS,
/**
* A "hook" that runs after the ULS constructor.
* At this point it is not guaranteed that the ULS has its dimensions
* and that the languages lists are initialized.
*
* To use it, pass a function as the onReady parameter
* in the options when initializing ULS.
*/
ready: function () { ready: function () {
if ( this.options.onReady ) { if ( this.options.onReady ) {
this.options.onReady.call( this ); this.options.onReady.call( this );
} }
}, },
/**
* A "hook" that runs after the ULS panel becomes visible
* by using the show method.
*
* To use it, pass a function as the onVisible parameter
* in the options when initializing ULS.
*/
visible: function () {
if ( this.options.onVisible ) {
this.options.onVisible.call( this );
}
},
/** /**
* Calculate the position of ULS * Calculate the position of ULS
* Returns an object with top and left properties. * Returns an object with top and left properties.
@@ -152,13 +173,15 @@
if ( !this.initialized ) { if ( !this.initialized ) {
$( 'body' ).prepend( this.$menu ); $( 'body' ).prepend( this.$menu );
this.i18n(); this.i18n();
// Initialize with a full search. // Initialize with a full search.
// This happens on first time click of uls trigger. // This happens on first time click of uls trigger.
this.defaultSearch(); this.defaultSearch();
this.initialized = true; this.initialized = true;
} }
// hide any other ULS visible // hide any other visible ULS
$( '.uls-menu' ).hide(); $( '.uls-menu' ).hide();
this.$menu.show(); this.$menu.show();
@@ -167,6 +190,8 @@
if ( !this.isMobile() ) { if ( !this.isMobile() ) {
this.$languageFilter.focus(); this.$languageFilter.focus();
} }
this.visible();
}, },
i18n: function () { i18n: function () {

View File

@@ -159,14 +159,15 @@
}, },
search: function() { search: function() {
var query = $.trim( this.$element.val() ), var languagesInScript,
query = $.trim( this.$element.val() ),
languages = $.uls.data.getLanguagesByScriptGroup( this.options.languages ), languages = $.uls.data.getLanguagesByScriptGroup( this.options.languages ),
scriptGroup, langNum, langCode; scriptGroup, langNum, langCode;
this.resultCount = 0; this.resultCount = 0;
for ( scriptGroup in languages ) { for ( scriptGroup in languages ) {
var languagesInScript = languages[scriptGroup]; languagesInScript = languages[scriptGroup];
languagesInScript.sort( $.uls.data.sortByAutonym ); languagesInScript.sort( $.uls.data.sortByAutonym );