Avoid jquery filter for the region div for each language

Keep it in an object and reuse.

Change-Id: I1a367132e9b99b4fc6b2b8ff4023f638e6bc183f
This commit is contained in:
Santhosh Thottingal
2012-08-21 17:56:22 +05:30
parent 5760df80d3
commit 79139e650d

View File

@@ -26,6 +26,7 @@
this.$element = $( element );
this.options = $.extend( {}, $.fn.lcd.defaults, options );
this.$element.addClass( 'lcd' );
this.regionDivs = {};
this.show();
this.listen();
};
@@ -93,9 +94,9 @@
var $divRegionCode, $rowDiv, $ul;
forceNew = forceNew || false;
$divRegionCode = this.$element.find( 'div#' + regionCode );
$divRegionCode = this.regionDivs[regionCode];
$rowDiv = $divRegionCode.find( 'div.row:last' );
$ul = $divRegionCode.find( 'ul:last' );
$ul = $rowDiv.find( 'ul:last' );
// Each column can have maximum 8 languages.
if ( $ul.length === 0 || $ul.find( 'li' ).length >= 8 || forceNew ) {
@@ -124,6 +125,7 @@
$section.append( $( '<h3>' ).addClass( 'eleven columns uls-lcd-region-section offset-by-one' ).html( regionCode ) );
// FIXME this is regioncode(NA, EU etc). Should be proper localized region name.
that.$element.append( $section );
that.regionDivs[regionCode] = $section;
} );
},