diff --git a/src/jquery.uls.core.js b/src/jquery.uls.core.js index b88f0fa..3ab4a33 100644 --- a/src/jquery.uls.core.js +++ b/src/jquery.uls.core.js @@ -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. diff --git a/src/jquery.uls.lcd.js b/src/jquery.uls.lcd.js index afc7e0a..36f7429 100644 --- a/src/jquery.uls.lcd.js +++ b/src/jquery.uls.lcd.js @@ -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;