-
Notifications
You must be signed in to change notification settings - Fork 3
/
CountryFlags.js
44 lines (42 loc) · 2.08 KB
/
CountryFlags.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/** global: VRS */
if(VRS && VRS.globalDispatch && VRS.serverConfig) {
VRS.globalDispatch.hook(VRS.globalEvent.bootstrapCreated, function(bootStrap) {
if(VRS.renderPropertyHandlers) {
VRS.renderPropertyHandlers[VRS.RenderProperty.Country] = new VRS.RenderPropertyHandler({
property: VRS.RenderProperty.Country,
surfaces: VRS.RenderSurface.List + VRS.RenderSurface.DetailHead + VRS.RenderSurface.InfoWindow,
headingKey: 'ListCountry',
labelKey: 'Country',
sortableField: VRS.AircraftListSortableField.Country,
suppressLabelCallback: function() { return true; },
fixedWidth: function() { return '27px'; },
hasChangedCallback: function(aircraft) { return aircraft.country.chg; },
renderCallback: function(aircraft) { return customFormatCountryFlagImageHtml(aircraft); },
tooltipChangedCallback: function(aircraft) { return aircraft.country.chg; },
tooltipCallback: function(aircraft) { return aircraft.country.val; }
});
}
});
}
function customFormatCountryFlagImageHtml(aircraft)
{
var result = '';
if(aircraft.country.val) {
var codeToUse = '';
codeToUse = aircraft.country.val;
//Place images on 'country' folder
result = '<img src="images/web-country/Wdth-27/Hght-20';
if(VRS.browserHelper.isHighDpi()) result += '/HiDpi';
result += '/' + encodeURIComponent(codeToUse) +'.bmp" width="27px" height="20px" />';
}
return result;
}
function customPipeSeparatedCode(text, code)
{
var result = text;
if(code && code.length) {
if(result.length) result += '|';
result += code;
}
return result;
}