From 2e22c5c550af9dfac5e1c0795a6c1c4237c822c2 Mon Sep 17 00:00:00 2001 From: "Amir E. Aharoni" Date: Mon, 8 Oct 2012 17:04:05 +0200 Subject: [PATCH 1/3] Initial whitespace cleanup --- src/jquery.uls.lcd.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/jquery.uls.lcd.js b/src/jquery.uls.lcd.js index a401960..c84667d 100644 --- a/src/jquery.uls.lcd.js +++ b/src/jquery.uls.lcd.js @@ -250,6 +250,7 @@ listen: function () { var that = this; + if ( this.options.clickhandler ) { this.$element.on( 'click', 'div.row li', function() { that.options.clickhandler.call( this, $( this ).data( 'code' ) ); @@ -258,28 +259,30 @@ // The region section need to be in sync with the map filter. that.$element.scroll( function () { - var scrollTop = $( this ).position().top; - var scrollBottom = $( this ).height(); - if ( this.offsetHeight + this.scrollTop >= this.scrollHeight/2 ) { + var scrollTop = $( this ).position().top, + scrollBottom = $( this ).height(); + + if ( this.offsetHeight + this.scrollTop >= this.scrollHeight / 2 ) { that.$element.trigger( 'scrollend' ); } + // The region section need to be in sync with the map filter. var inviewRegion = 'WW'; that.$element.find( 'div.uls-lcd-region-section' ).each( function () { - var top = $( this ).position().top; - var height = $( this ).height(); + var top = $( this ).position().top, + height = $( this ).height(); + if ( top < scrollTop && height > scrollBottom ) { inviewRegion = $( this ).attr( 'id' ); return true; } } ); + var inview = $.uls.data.regiongroups[inviewRegion]; $( '.regionselector' ).removeClass( 'active' ); $( '#uls-region-' + inview ).addClass( 'active' ); } ); - } - }; $.fn.lcd = function( option ) { From f14073a21a4226495c21d0ec4ffddccd0cbdf00a Mon Sep 17 00:00:00 2001 From: "Amir E. Aharoni" Date: Mon, 8 Oct 2012 17:22:01 +0200 Subject: [PATCH 2/3] Rename the variable that to lcd --- src/jquery.uls.lcd.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/jquery.uls.lcd.js b/src/jquery.uls.lcd.js index c84667d..01c3147 100644 --- a/src/jquery.uls.lcd.js +++ b/src/jquery.uls.lcd.js @@ -249,26 +249,26 @@ }, listen: function () { - var that = this; + var lcd = this; if ( this.options.clickhandler ) { this.$element.on( 'click', 'div.row li', function() { - that.options.clickhandler.call( this, $( this ).data( 'code' ) ); + lcd.options.clickhandler.call( this, $( this ).data( 'code' ) ); } ); } // The region section need to be in sync with the map filter. - that.$element.scroll( function () { + lcd.$element.scroll( function () { var scrollTop = $( this ).position().top, scrollBottom = $( this ).height(); if ( this.offsetHeight + this.scrollTop >= this.scrollHeight / 2 ) { - that.$element.trigger( 'scrollend' ); + lcd.$element.trigger( 'scrollend' ); } // The region section need to be in sync with the map filter. var inviewRegion = 'WW'; - that.$element.find( 'div.uls-lcd-region-section' ).each( function () { + lcd.$element.find( 'div.uls-lcd-region-section' ).each( function () { var top = $( this ).position().top, height = $( this ).height(); From 77e62c99a57e3d83b8d53c4ac5fb86167fabdd11 Mon Sep 17 00:00:00 2001 From: "Amir E. Aharoni" Date: Mon, 8 Oct 2012 17:34:35 +0200 Subject: [PATCH 3/3] Changed $( this ) into meaningful variables --- src/jquery.uls.lcd.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/jquery.uls.lcd.js b/src/jquery.uls.lcd.js index 01c3147..7aef642 100644 --- a/src/jquery.uls.lcd.js +++ b/src/jquery.uls.lcd.js @@ -259,8 +259,9 @@ // The region section need to be in sync with the map filter. lcd.$element.scroll( function () { - var scrollTop = $( this ).position().top, - scrollBottom = $( this ).height(); + var $ulsLanguageList = $( this ), + scrollTop = $ulsLanguageList.position().top, + scrollBottom = $ulsLanguageList.height(); if ( this.offsetHeight + this.scrollTop >= this.scrollHeight / 2 ) { lcd.$element.trigger( 'scrollend' ); @@ -269,11 +270,12 @@ // 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 () { - var top = $( this ).position().top, - height = $( this ).height(); + var $lcdRegionSection = $( this ), + top = $lcdRegionSection.position().top, + height = $lcdRegionSection.height(); if ( top < scrollTop && height > scrollBottom ) { - inviewRegion = $( this ).attr( 'id' ); + inviewRegion = $lcdRegionSection.attr( 'id' ); return true; } } );