Introduce lazyload option with default value true.
This can be set false when language list is very small. Change-Id: I024f01a2a62f0d0def553e2d6f7a3fdcce1a7968
This commit is contained in:
@@ -162,7 +162,7 @@
|
||||
this.$resultsView.lcd( 'empty' );
|
||||
|
||||
// Use lazy loading only when there are 100+ languages.
|
||||
if ( count > 100 ) {
|
||||
if ( this.options.lazyload ) {
|
||||
this.$regionFilters.first().regionselector( 'show' );
|
||||
} else{
|
||||
this.$regionFilters.regionselector( 'show' );
|
||||
@@ -224,7 +224,8 @@
|
||||
lcd = that.$resultsView.lcd( {
|
||||
languages: that.languages,
|
||||
quickList: that.options.quickList,
|
||||
clickhandler: $.proxy( that.onSelect, that )
|
||||
clickhandler: $.proxy( that.onSelect, that ),
|
||||
lazyload: that.options.lazyload
|
||||
} ).data( "lcd" );
|
||||
|
||||
that.$languageFilter.languagefilter( {
|
||||
@@ -328,7 +329,8 @@
|
||||
onSelect: null, // Callback function to be called when a language is selected
|
||||
searchAPI: null, // Language search API
|
||||
languages: $.uls.data.getAutonyms(), // Languages to be used for ULS, default is all languages
|
||||
quickList: null // Array of language codes of function that returns such
|
||||
quickList: null, // Array of language codes of function that returns such
|
||||
lazyload: true // Lazy load the language list when scrolled.
|
||||
};
|
||||
|
||||
// Define a dummy i18n function, if jquery.i18n not integrated.
|
||||
|
||||
@@ -262,11 +262,11 @@
|
||||
var $ulsLanguageList = $( this ),
|
||||
scrollTop = $ulsLanguageList.position().top,
|
||||
scrollBottom = $ulsLanguageList.height();
|
||||
|
||||
if ( this.offsetHeight + this.scrollTop >= this.scrollHeight / 2 ) {
|
||||
lcd.$element.trigger( 'scrollend' );
|
||||
if ( lcd.options.lazyload ) {
|
||||
if ( this.offsetHeight + this.scrollTop >= this.scrollHeight / 2 ) {
|
||||
lcd.$element.trigger( 'scrollend' );
|
||||
}
|
||||
}
|
||||
|
||||
// The region section need to be in sync with the map filter.
|
||||
var inviewRegion = 'WW';
|
||||
lcd.$element.find( 'div.uls-lcd-region-section' ).each( function () {
|
||||
@@ -304,7 +304,8 @@
|
||||
};
|
||||
|
||||
$.fn.lcd.defaults = {
|
||||
languages: null
|
||||
languages: null,
|
||||
lazyload: true
|
||||
};
|
||||
|
||||
$.fn.lcd.Constructor = LanguageCategoryDisplay;
|
||||
|
||||
Reference in New Issue
Block a user