diff --git a/lib/export-control.ts b/lib/export-control.ts index 2855a60..bdd6ffc 100644 --- a/lib/export-control.ts +++ b/lib/export-control.ts @@ -2,10 +2,23 @@ import { IControl, Map as MapboxMap } from 'mapbox-gl'; import CrosshairManager from './crosshair-manager'; import PrintableAreaManager from './printable-area-manager'; import { - english, finnish, french, german, swedish, Translation, vietnam, zhHans, zhHant + english, + finnish, + french, + german, + swedish, + Translation, + vietnam, + ukranian, + zhHans, + zhHant } from './local'; import MapGenerator, { - Size, Format, PageOrientation, DPI, Unit, + Size, + Format, + PageOrientation, + DPI, + Unit, } from './map-generator'; type Options = { @@ -16,8 +29,8 @@ type Options = { Crosshair?: boolean; PrintableArea: boolean; accessToken?: string; - Local?: 'de' | 'en' | 'fr' | 'fi' | 'sv' | 'vi' | 'zhHans' | 'zhHant'; -} + Local?: 'de' | 'en' | 'fr' | 'fi' | 'sv' | 'vi' | 'uk' | 'zhHans' | 'zhHant'; +}; /** * Mapbox GL Export Control. @@ -72,6 +85,8 @@ export default class MapboxExportControl implements IControl { return swedish; case 'vi': return vietnam; + case 'uk': + return ukranian; case 'zhHans': return zhHans; case 'zhHant': @@ -105,16 +120,40 @@ export default class MapboxExportControl implements IControl { const table = document.createElement('TABLE'); table.className = 'print-table'; - const tr1 = this.createSelection(Size, this.getTranslation().PageSize, 'page-size', this.options.PageSize, (data, key) => JSON.stringify(data[key])); + const tr1 = this.createSelection( + Size, + this.getTranslation().PageSize, + 'page-size', + this.options.PageSize, + (data, key) => JSON.stringify(data[key]), + ); table.appendChild(tr1); - const tr2 = this.createSelection(PageOrientation, this.getTranslation().PageOrientation, 'page-orientaiton', this.options.PageOrientation, (data, key) => data[key]); + const tr2 = this.createSelection( + PageOrientation, + this.getTranslation().PageOrientation, + 'page-orientaiton', + this.options.PageOrientation, + (data, key) => data[key], + ); table.appendChild(tr2); - const tr3 = this.createSelection(Format, this.getTranslation().Format, 'format-type', this.options.Format, (data, key) => data[key]); + const tr3 = this.createSelection( + Format, + this.getTranslation().Format, + 'format-type', + this.options.Format, + (data, key) => data[key], + ); table.appendChild(tr3); - const tr4 = this.createSelection(DPI, this.getTranslation().DPI, 'dpi-type', this.options.DPI, (data, key) => data[key]); + const tr4 = this.createSelection( + DPI, + this.getTranslation().DPI, + 'dpi-type', + this.options.DPI, + (data, key) => data[key], + ); table.appendChild(tr4); this.exportContainer.appendChild(table); @@ -124,10 +163,18 @@ export default class MapboxExportControl implements IControl { generateButton.textContent = this.getTranslation().Generate; generateButton.classList.add('generate-button'); generateButton.addEventListener('click', () => { - const pageSize: HTMLSelectElement = document.getElementById('mapbox-gl-export-page-size'); - const pageOrientation: HTMLSelectElement = document.getElementById('mapbox-gl-export-page-orientaiton'); - const formatType: HTMLSelectElement = document.getElementById('mapbox-gl-export-format-type'); - const dpiType: HTMLSelectElement = document.getElementById('mapbox-gl-export-dpi-type'); + const pageSize: HTMLSelectElement = ( + document.getElementById('mapbox-gl-export-page-size') + ); + const pageOrientation: HTMLSelectElement = ( + document.getElementById('mapbox-gl-export-page-orientaiton') + ); + const formatType: HTMLSelectElement = ( + document.getElementById('mapbox-gl-export-format-type') + ); + const dpiType: HTMLSelectElement = ( + document.getElementById('mapbox-gl-export-dpi-type') + ); const orientValue = pageOrientation.value; let pageSizeValue = JSON.parse(pageSize.value); if (orientValue === PageOrientation.Portrait) { @@ -171,7 +218,9 @@ export default class MapboxExportControl implements IControl { } content.appendChild(optionLayout); }); - content.addEventListener('change', () => { this.updatePrintableArea(); }); + content.addEventListener('change', () => { + this.updatePrintableArea(); + }); const tr1 = document.createElement('TR'); const tdLabel = document.createElement('TD'); @@ -184,10 +233,12 @@ export default class MapboxExportControl implements IControl { } public onRemove(): void { - if (!this.controlContainer + if ( + !this.controlContainer || !this.controlContainer.parentNode || !this.map - || !this.exportButton) { + || !this.exportButton + ) { return; } this.exportButton.removeEventListener('click', this.onDocumentClick); @@ -207,7 +258,8 @@ export default class MapboxExportControl implements IControl { this.controlContainer && !this.controlContainer.contains(event.target as Element) && this.exportContainer - && this.exportButton) { + && this.exportButton + ) { this.exportContainer.style.display = 'none'; this.exportButton.style.display = 'block'; this.toggleCrosshair(false); @@ -247,8 +299,12 @@ export default class MapboxExportControl implements IControl { if (this.printableArea === undefined) { return; } - const pageSize: HTMLSelectElement = document.getElementById('mapbox-gl-export-page-size'); - const pageOrientation: HTMLSelectElement = document.getElementById('mapbox-gl-export-page-orientaiton'); + const pageSize: HTMLSelectElement = ( + document.getElementById('mapbox-gl-export-page-size') + ); + const pageOrientation: HTMLSelectElement = ( + document.getElementById('mapbox-gl-export-page-orientaiton') + ); const orientValue = pageOrientation.value; let pageSizeValue = JSON.parse(pageSize.value); if (orientValue === PageOrientation.Portrait) { diff --git a/lib/local/index.ts b/lib/local/index.ts index 2604dc7..afd9187 100644 --- a/lib/local/index.ts +++ b/lib/local/index.ts @@ -4,6 +4,7 @@ import finnish from './fi'; import german from './de'; import swedish from './sv'; import vietnam from './vi'; +import ukranian from './uk'; import zhHans from './zhHans'; import zhHant from './zhHant'; @@ -13,7 +14,7 @@ type Translation = { Format: string; DPI: string; Generate: string; -} +}; export { english, @@ -22,6 +23,7 @@ export { german, swedish, vietnam, + ukranian, zhHans, zhHant, Translation, diff --git a/lib/local/uk.ts b/lib/local/uk.ts new file mode 100644 index 0000000..3d5e169 --- /dev/null +++ b/lib/local/uk.ts @@ -0,0 +1,9 @@ +const translation = { + PageSize: 'Розмір сторінки', + PageOrientation: 'Орієнтація сторінки', + Format: 'Формат', + DPI: 'DPI', + Generate: 'Згенерувати', +}; + +export default translation;