Allow sending the number of lcd columns as a parameter

This is needed for https://phabricator.wikimedia.org/T76196
and may also nbe useful for many other features.
This commit is contained in:
Amir E. Aharoni
2014-12-02 13:23:22 +02:00
parent 03a1baa4ed
commit 752a295ee2
3 changed files with 18 additions and 6 deletions

View File

@@ -144,12 +144,20 @@
* @returns {Object}
*/
position: function () {
var pos = $.extend( {}, this.$element.offset(), {
var width, minWidth, pos;
width = 11 * this.options.columns;
minWidth = 179 * this.options.columns;
pos = $.extend( {}, this.$element.offset(), {
height: this.$element[0].offsetHeight
} );
return {
top: this.top !== undefined ? this.top : pos.top + pos.height,
left: this.left !== undefined ? this.left : '25%'
'width': width + '%',
'min-width': minWidth,
'top': this.top !== undefined ? this.top : pos.top + pos.height,
'left': this.left !== undefined ? this.left : '25%'
};
},
@@ -264,6 +272,7 @@
lcd = this.$resultsView.lcd( {
languages: this.languages,
columns: this.options.columns,
quickList: this.options.quickList,
clickhandler: $.proxy( this.select, this ),
source: this.$languageFilter,
@@ -401,6 +410,7 @@
languages: $.uls.data.getAutonyms(), // Languages to be used for ULS, default is all languages
quickList: null, // Array of language codes or function that returns such
compact: false, // Show ULS in compact mode
columns: 2, // How many columns of languages to show
showRegions: [ 'WW', 'AM', 'EU', 'ME', 'AF', 'AS', 'PA' ],
languageDecorator: null // Callback function to be called when a language link is prepared - for custom decoration.
};

View File

@@ -153,8 +153,7 @@
*/
renderRegions: function () {
var lcd = this, languages,
items = lcd.options.itemsPerColumn,
columns = 4;
items = lcd.options.itemsPerColumn;
this.$noResults.addClass( 'hide' );
this.$element.find( '.uls-lcd-region-section' ).each( function () {
@@ -173,7 +172,7 @@
return;
}
lcd.renderRegion( $region, languages, items, columns );
lcd.renderRegion( $region, languages, items, lcd.options.columns );
$region.removeClass( 'hide' );
lcd.regionLanguages[regionCode] = [];
@@ -386,6 +385,7 @@
};
$.fn.lcd.defaults = {
columns: 4,
languages: null,
showRegions: ['WW', 'AM', 'EU', 'ME', 'AF', 'AS', 'PA'],
itemsPerColumn: 8,