(function( $ ) { "use strict"; var LanguageCategoryDisplay = function( element, options ) { this.$element = $( element ); this.options = $.extend( {}, $.fn.lcd.defaults, options ); this.$element.addClass( 'lcd' ); this.show(); this.listen(); }; LanguageCategoryDisplay.prototype = { constructor: LanguageCategoryDisplay, append: function( langCode, regionCode ) { var that = this; this.addToRegion( langCode, regionCode ); }, /** * Add the language to a region. * If the region parameter is given , add to that region alone * Otherwise to all regions that this language belongs. * @param langCode * @param region */ addToRegion: function( langCode, region ) { var that = this, language = $.uls.data.languages[langCode]; // TODO: This shouldn't happen. // This currently happens with some special cases, such as qqq and // some codes that are incorrectly used in Wikimedia projects for // historical reasons. if ( !language ) { console.log( "Definition for " + langCode + " was not found in the language database." ); return; } var langName = that.options.languages[langCode]; var regions = []; if ( region ) { regions.push( region ); } else { regions = $.uls.data.regions( langCode ); } for ( var i = 0; i < regions.length; i++ ) { var regionCode = regions[i]; var $li = $( '
  • ' ) .data( 'code', langCode ) .append( $( '' ).prop( 'href', '#' ).html( langName ) ); // Append the element to the column in the list var column = that.getColumn( regionCode ); column.append( $li ); if ( that.options.clickhandler ) { $li.click( function() { that.options.clickhandler.call( this, langCode ); } ); } } }, getColumn: function( regionCode ) { var $divRegionCode = $( 'div#' + regionCode ); var $ul = $divRegionCode.find( 'ul:last' ); if ( $ul.length === 0 || $ul.find( 'li' ).length >= 10 ) { $ul = $( '