/** * Universal Language Selector * Language category display component - Used for showing the search results, * grouped by regions, scripts * * Copyright (C) 2012 Alolita Sharma, Amir Aharoni, Arun Ganesh, Brandon Harris, * Niklas Laxström, Pau Giner, Santhosh Thottingal, Siebrand Mazeland and other * contributors. See CREDITS for a list. * * UniversalLanguageSelector is dual licensed GPLv2 or later and MIT. You don't * have to do anything special to choose one license or the other and you don't * have to notify anyone which license you are using. You are free to use * UniversalLanguageSelector in commercial projects as long as the copyright * header is left intact. See files GPL-LICENSE and MIT-LICENSE for details. * * @file * @ingroup Extensions * @licence GNU General Public Licence 2.0 or later * @licence MIT License */ (function( $ ) { "use strict"; var LanguageCategoryDisplay = function( element, options ) { this.$element = $( element ); this.options = $.extend( {}, $.fn.lcd.defaults, options ); this.$element.addClass( 'lcd' ); this.regionDivs = {}; this.render(); this.listen(); }; LanguageCategoryDisplay.prototype = { constructor: LanguageCategoryDisplay, append: function( langCode, regionCode ) { 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 Optional region */ addToRegion: function( langCode, region ) { var that = this; var language = that.options.languages[langCode], langName = $.uls.data.autonym( langCode ) || language || langCode, 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 = $( '