Adding a special region
This is supposed to allow adding special languages. This region's section is hidden by default and can be enabled by passing different options to the lcd object.
This commit is contained in:
@@ -236,7 +236,8 @@
|
||||
quickList: uls.options.quickList,
|
||||
clickhandler: $.proxy( uls.select, uls ),
|
||||
lazyload: uls.options.lazyload,
|
||||
source: uls.$languageFilter
|
||||
source: uls.$languageFilter,
|
||||
showRegions: uls.options.showRegions
|
||||
} ).data( 'lcd' );
|
||||
|
||||
uls.$languageFilter.languagefilter( {
|
||||
@@ -366,7 +367,8 @@
|
||||
searchAPI: null, // Language search API
|
||||
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
|
||||
lazyload: true // Lazy load the language list when scrolled.
|
||||
lazyload: true, // Lazy load the language list when scrolled.
|
||||
showRegions: ['WW', 'AM', 'EU', 'ME', 'AF', 'AS', 'PA']
|
||||
};
|
||||
|
||||
// Define a dummy i18n function, if jquery.i18n not integrated.
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -417,4 +417,36 @@
|
||||
return $.uls.data.territories[territory];
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds a language in run time and sets its options as provided.
|
||||
* If the target option is provided, the language is defined as a redirect.
|
||||
* Other possible options are script, regions and autonym.
|
||||
*
|
||||
* @param code string New language code.
|
||||
* @param options Object Language properties.
|
||||
* @return list of language codes
|
||||
*/
|
||||
$.uls.data.addLanguage = function( code, options ) {
|
||||
if ( options.target ) {
|
||||
$.uls.data.languages[code] = [options.target];
|
||||
} else {
|
||||
$.uls.data.languages[code] = [options.script, options.regions, options.autonym];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes a language from the langdb in run time.
|
||||
*
|
||||
* @param code string Language code to delete.
|
||||
* @return true if the language was removed, false otherwise.
|
||||
*/
|
||||
$.uls.data.deleteLanguage = function( code ) {
|
||||
if ( $.uls.data.languages[code] ) {
|
||||
delete $.uls.data.languages[code];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
} ( jQuery ) );
|
||||
|
||||
@@ -146,7 +146,10 @@
|
||||
$rowDiv.append( $ul );
|
||||
}
|
||||
|
||||
$divRegionCode.show();
|
||||
// Don't show the region unless it was enabled
|
||||
if ( $.inArray( regionCode, this.options.showRegions ) > -1 ) {
|
||||
$divRegionCode.show();
|
||||
}
|
||||
|
||||
return $ul;
|
||||
},
|
||||
@@ -157,6 +160,7 @@
|
||||
regions = {
|
||||
// These are fallback text when i18n library not present
|
||||
WW: 'Worldwide',
|
||||
SP: 'Special',
|
||||
AM: 'America',
|
||||
EU: 'Europe',
|
||||
ME: 'Middle East',
|
||||
@@ -307,6 +311,7 @@
|
||||
|
||||
$.fn.lcd.defaults = {
|
||||
languages: null,
|
||||
showRegions: ['WW', 'AM', 'EU', 'ME', 'AF', 'AS', 'PA'],
|
||||
lazyload: true
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user