| 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 | import theTranslator from '../../core/uiLib/Translator.js'; |
| 26 | import theConfig from '../../data/Config.js'; |
| 27 | import ModalBaseDialog from '../baseDialog/ModalBaseDialog.js'; |
| 28 | import theTravelNotesData from '../../data/TravelNotesData.js'; |
| 29 | import NumberInputControl from '../../controls/numberInputControl/NumberInputControl.js'; |
| 30 | import CheckboxInputControl from '../../controls/checkboxInputControl/CheckboxInputControl.js'; |
| 31 | import RadioInputControl from '../../controls/radioInputControl/RadioInputControl.js'; |
| 32 | import PrintRouteMapOptions from './PrintRouteMapOptions.js'; |
| 33 | import { ZERO } from '../../main/Constants.js'; |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | class PrintRouteMapDialog extends ModalBaseDialog { |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | #paperWidthControl; |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | #paperHeightControl; |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | #borderWidthControl; |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | #zoomFactorControl; |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | #printNotesControl; |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | #firefoxBrowserControl; |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | static get #MAX_ZOOM ( ) { return 15; } |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | constructor ( ) { |
| 98 | super ( ); |
| 99 | } |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | createContentHTML ( ) { |
| 107 | this.#paperWidthControl = new NumberInputControl ( |
| 108 | { |
| 109 | beforeText : theTranslator.getText ( 'PrintRouteMapDialog - Paper width' ), |
| 110 | afterText : theTranslator.getText ( 'PrintRouteMapDialog - Paper width units' ), |
| 111 | value : theConfig.printRouteMap.paperWidth |
| 112 | } |
| 113 | ); |
| 114 | this.#paperHeightControl = new NumberInputControl ( |
| 115 | { |
| 116 | beforeText : theTranslator.getText ( 'PrintRouteMapDialog - Paper height' ), |
| 117 | afterText : theTranslator.getText ( 'PrintRouteMapDialog - Paper height units' ), |
| 118 | value : theConfig.printRouteMap.paperHeight |
| 119 | } |
| 120 | ); |
| 121 | this.#borderWidthControl = new NumberInputControl ( |
| 122 | { |
| 123 | beforeText : theTranslator.getText ( 'PrintRouteMapDialog - Border width' ), |
| 124 | afterText : theTranslator.getText ( 'PrintRouteMapDialog - Border width units' ), |
| 125 | value : theConfig.printRouteMap.borderWidth |
| 126 | } |
| 127 | ); |
| 128 | this.#zoomFactorControl = new NumberInputControl ( |
| 129 | { |
| 130 | beforeText : theTranslator.getText ( 'PrintRouteMapDialog - Zoom factor' ), |
| 131 | value : Math.min ( theConfig.printRouteMap.zoomFactor, PrintRouteMapDialog.#MAX_ZOOM ), |
| 132 | min : theTravelNotesData.map.getMinZoom ( ), |
| 133 | max : Math.min ( theTravelNotesData.map.getMaxZoom ( ), PrintRouteMapDialog.#MAX_ZOOM ) |
| 134 | } |
| 135 | ); |
| 136 | this.#printNotesControl = new CheckboxInputControl ( |
| 137 | { |
| 138 | afterText : theTranslator.getText ( 'PrintRouteMapDialog - Print notes' ), |
| 139 | checked : theConfig.printRouteMap.printNotes |
| 140 | } |
| 141 | ); |
| 142 | this.#firefoxBrowserControl = new RadioInputControl ( |
| 143 | { |
| 144 | headerText : theTranslator.getText ( 'PrintRouteMapDialog - Print with' ), |
| 145 | buttons : [ |
| 146 | { |
| 147 | label : 'Firefox', |
| 148 | checked : theConfig.printRouteMap.firefoxBrowser |
| 149 | }, |
| 150 | { |
| 151 | label : theTranslator.getText ( 'PrintRouteMapDialog - Another browser' ), |
| 152 | checked : ! theConfig.printRouteMap.firefoxBrowser |
| 153 | } |
| 154 | ] |
| 155 | } |
| 156 | ); |
| 157 | } |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | show ( ) { |
| 164 | let showPromise = super.show ( ); |
| 165 | this.addCssClass ( 'TravelNotes-PrintRouteMapDialog' ); |
| 166 | return showPromise; |
| 167 | } |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | onOk ( ) { |
| 174 | const printRouteMapOptions = new PrintRouteMapOptions ( ); |
| 175 | printRouteMapOptions.paperWidth = this.#paperWidthControl.value; |
| 176 | printRouteMapOptions.paperHeight = this.#paperHeightControl.value; |
| 177 | printRouteMapOptions.borderWidth = this.#borderWidthControl.value; |
| 178 | printRouteMapOptions.zoomFactor = this.#zoomFactorControl.value; |
| 179 | printRouteMapOptions.printNotes = this.#printNotesControl.checked; |
| 180 | printRouteMapOptions.firefoxBrowser = ZERO === this.#firefoxBrowserControl.value; |
| 181 | Object.freeze ( printRouteMapOptions ); |
| 182 | super.onOk ( printRouteMapOptions ); |
| 183 | } |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | get contentHTMLElements ( ) { |
| 191 | return [ |
| 192 | this.#paperWidthControl.controlHTMLElement, |
| 193 | this.#paperHeightControl.controlHTMLElement, |
| 194 | this.#borderWidthControl.controlHTMLElement, |
| 195 | this.#zoomFactorControl.controlHTMLElement, |
| 196 | this.#printNotesControl.controlHTMLElement, |
| 197 | this.#firefoxBrowserControl.controlHTMLElement |
| 198 | ]; |
| 199 | } |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | get title ( ) { return theTranslator.getText ( 'PrintRouteMapDialog - Print' ); } |
| 207 | |
| 208 | } |
| 209 | |
| 210 | export default PrintRouteMapDialog; |
| 211 | |
| 212 | |
| 213 | |