From 1e4505e96429395f0b2ebfb03eeeee5ad8329828 Mon Sep 17 00:00:00 2001 From: Santhosh Thottingal Date: Mon, 7 Jan 2013 20:16:57 +0530 Subject: [PATCH] (bug 43568) Languages are shown multiple times Update jquery.uls from upstream Change-Id: I5e3aef0c78c60df93f2c031721049b0164134fc0 --- lib/jquery.uls/jquery.uls.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/jquery.uls/jquery.uls.js b/lib/jquery.uls/jquery.uls.js index 6961d794..566b4534 100644 --- a/lib/jquery.uls/jquery.uls.js +++ b/lib/jquery.uls/jquery.uls.js @@ -741,7 +741,8 @@ // The region section need to be in sync with the map filter. lcd.$element.scroll( function () { - var $ulsLanguageList = $( this ), + var inview, inviewRegion, + $ulsLanguageList = $( this ), scrollTop = $ulsLanguageList.position().top, scrollBottom = $ulsLanguageList.height(); @@ -751,7 +752,7 @@ } } // The region section need to be in sync with the map filter. - var inviewRegion = 'WW'; + inviewRegion = 'WW'; lcd.$element.find( 'div.uls-lcd-region-section' ).each( function () { var $lcdRegionSection = $( this ), top = $lcdRegionSection.position().top, @@ -765,7 +766,7 @@ } } ); - var inview = $.uls.data.regiongroups[inviewRegion]; + inview = $.uls.data.regiongroups[inviewRegion]; $( '.regionselector' ).removeClass( 'active' ); $( '#uls-region-' + inview ).addClass( 'active' ); } ); @@ -1253,21 +1254,22 @@ }, next: function () { - if ( !this.$element.hasClass( 'active') ) { + var regionSelector = this; + + if ( !this.$element.hasClass( 'active' ) ) { return true; } - var regionSelector = this; // Do not respond to all scroll end events, but only after a short interval delay( function () { - var regiongroup = regionSelector.$element.data( 'regiongroup' ); - var nextRegiongroup = regiongroup + 1; + var nextRegionGroupNumber = regionSelector.$element.data( 'regiongroup' ) + 1, + $nextRegion = $( '#uls-region-' + nextRegionGroupNumber ), + nextRegionSelector = $nextRegion.length && $nextRegion.data( 'regionselector' ); - var $nextRegion = $( '#uls-region-' + nextRegiongroup ); - var next = $nextRegion.length && $nextRegion.data( 'regionselector' ); - - if ( next ) { - next.show(); + // If cache is defined, then it is already rendered and there's no need + // to re-render it. + if ( nextRegionSelector && nextRegionSelector.cache === null ) { + nextRegionSelector.show(); } }, 100 ); @@ -1276,7 +1278,7 @@ listen: function () { this.$element.on( 'click', $.proxy( this.click, this ) ); - this.options.$target.$element.bind( 'scrollend', $.proxy( this.next, this) ); + this.options.$target.$element.bind( 'scrollend', $.proxy( this.next, this ) ); }, click: function ( e ) {