|
76 | 76 |
|
77 | 77 | <script
|
78 | 78 | src="plugins/step/intranda_step_transcription/tinymce/tinymce.min.js"></script>
|
79 |
| - <script> |
80 |
| - let mytiny = tinymce.init({ |
81 |
| - plugins: 'paste table', |
82 |
| - selector : '.ocr-text', |
83 |
| - menubar : '', |
84 |
| - toolbar: 'undo redo | formatselect | fontsizeselect | bold italic underline strikethrough | alignleft aligncenter alignright alighnblock | indent outdent | table | pastetext | forecolor backcolor', |
85 |
| - paste_as_text: true, |
86 |
| - height : "90vh", |
87 |
| - init_instance_callback: function (editor) { |
88 |
| - editor.on('blur', function (e) { |
89 |
| - save(); |
90 |
| - }); |
91 |
| - } |
92 |
| - |
93 |
| - }); |
94 |
| - mytiny.then(mt => { |
95 |
| - console.log(mt) |
96 |
| - }) |
97 |
| - </script> |
98 | 79 |
|
99 | 80 | <section:section type="neutral">
|
100 | 81 | <section:header
|
|
105 | 86 | id="id10"
|
106 | 87 | action="#{NavigationForm.Reload}"
|
107 | 88 | styleClass="btn d-flex align-items-center btn--title-action"
|
108 |
| - pt:data-bs-toggle="tooltip"> |
| 89 | + pt:data-bs-toggle="tooltip" |
| 90 | + title="#{msgs.reload}"> |
109 | 91 | <span
|
110 | 92 | aria-hidden="true"
|
111 | 93 | class="fa fa-refresh" />
|
|
202 | 184 | <h:inputText
|
203 | 185 | value="#{AktuelleSchritteForm.myPlugin.image.ocrText}"
|
204 | 186 | class="input_0"></h:inputText>
|
| 187 | + <h:inputText |
| 188 | + value="#{AktuelleSchritteForm.myPlugin.image.image.url}" |
| 189 | + id="inputImageUrl"></h:inputText> |
205 | 190 | </h:panelGroup>
|
206 | 191 |
|
207 | 192 | <h:panelGroup layout="block"
|
|
264 | 249 | </section:section>
|
265 | 250 |
|
266 | 251 | <script>
|
267 |
| - let configViewer = { |
268 |
| - global: { |
269 |
| - divId: 'bigImage', |
270 |
| - useTiles: #{AktuelleSchritteForm.myPlugin.useTiles}, |
271 |
| - footerHeight: 0, |
272 |
| - adaptContainerHeight: false, |
273 |
| - zoomSlider: "#zoomSlider", |
274 |
| - zoomSliderHandle: "#zoomSlider .zoom-slider-handle", |
275 |
| - zoomSliderLabel: "#zoomSliderLabel input" |
276 |
| - }, |
277 |
| - image: { |
278 |
| - mimeType: "image/jpeg", |
279 |
| - tileSource: "#{AktuelleSchritteForm.myPlugin.image.image.url}" |
| 252 | + let useTilesBool = #{AktuelleSchritteForm.myPlugin.useTiles}; |
| 253 | + |
| 254 | + function save() { |
| 255 | + let editors = tinymce.editors |
| 256 | + for (let i = 0; i != editors.length; i++) { |
| 257 | + let editor = editors[i]; |
| 258 | + let textAreaID = editor.id; |
| 259 | + let content = editor.getContent(); |
| 260 | + let inputID = "input_0".replace("textarea_", ""); |
| 261 | + document.querySelector('.' + inputID).value = content; |
280 | 262 | }
|
281 |
| - }; |
| 263 | + return true; |
| 264 | + } |
282 | 265 |
|
283 |
| - let viewImage = new ImageView.Image( configViewer ); |
284 |
| - viewImage.load() |
285 |
| - .then(function(image) { |
286 |
| - image.onFirstTileLoaded() |
287 |
| - .then(function() { |
288 |
| - $('#ajaxloader_image').fadeOut(800); |
| 266 | + const showImage = () => { |
| 267 | + let imageUrl = document.querySelector('[id$="inputImageUrl"]').value; |
| 268 | + let configViewer = { |
| 269 | + global: { |
| 270 | + divId: 'bigImage', |
| 271 | + useTiles: useTilesBool, |
| 272 | + footerHeight: 0, |
| 273 | + adaptContainerHeight: false, |
| 274 | + zoomSlider: "#zoomSlider", |
| 275 | + zoomSliderHandle: "#zoomSlider .zoom-slider-handle", |
| 276 | + zoomSliderLabel: "#zoomSliderLabel input", |
| 277 | + }, |
| 278 | + image: { |
| 279 | + mimeType: "image/jpeg", |
| 280 | + tileSource: imageUrl, |
| 281 | + }, |
| 282 | + }; |
| 283 | + let viewImage = new ImageView.Image( configViewer ); |
| 284 | + viewImage.load() |
| 285 | + .then(function(image) { |
| 286 | + image.onFirstTileLoaded() |
| 287 | + .then(function() { |
| 288 | + $('#ajaxloader_image').fadeOut(800); |
| 289 | + }) |
| 290 | + .catch(function() { |
| 291 | + $('#ajaxloader_image').fadeOut(800); |
| 292 | + }) |
289 | 293 | })
|
290 |
| - .catch(function() { |
| 294 | + .catch(function(error){ |
| 295 | + console.error( 'Error opening image', error ); |
291 | 296 | $('#ajaxloader_image').fadeOut(800);
|
292 |
| - }) |
293 |
| - }) |
294 |
| - .catch(function(error){ |
295 |
| - console.error( 'Error opening image', error ); |
296 |
| - $('#ajaxloader_image').fadeOut(800); |
297 |
| - $('#' + configViewer.global.divId).html( 'Failed to load image: "' + error + '"' ); |
298 |
| - }); |
| 297 | + $('#' + configViewer.global.divId).html( 'Failed to load image: "' + error + '"' ); |
| 298 | + }); |
| 299 | + }; |
299 | 300 |
|
| 301 | + const initTinyMCE = () => { |
| 302 | + let mytiny = tinymce.init({ |
| 303 | + plugins: 'table', |
| 304 | + selector : '.ocr-text', |
| 305 | + menubar : '', |
| 306 | + toolbar: 'undo redo | formatselect | fontsizeselect | bold italic underline strikethrough | alignleft aligncenter alignright alighnblock | indent outdent | table | pastetext | forecolor backcolor', |
| 307 | + paste_as_text: true, |
| 308 | + height : "90vh", |
| 309 | + license_key: 'gpl', |
| 310 | + promotion: false, |
| 311 | + init_instance_callback: function (editor) { |
| 312 | + editor.on('blur', function (e) { |
| 313 | + save(); |
| 314 | + }); |
| 315 | + } |
| 316 | + |
| 317 | + }); |
| 318 | + mytiny.then(mt => { |
| 319 | + console.log(mt) |
| 320 | + }) |
| 321 | + }; |
300 | 322 |
|
| 323 | + document.addEventListener('DOMContentLoaded', function() { |
| 324 | + showImage(); |
| 325 | + initTinyMCE(); |
| 326 | + }); |
301 | 327 |
|
302 |
| - function save() { |
303 |
| - let editors = tinymce.editors |
304 |
| - for (let i = 0; i != editors.length; i++) { |
305 |
| - let editor = editors[i]; |
306 |
| - let textAreaID = editor.id; |
307 |
| - let content = editor.getContent(); |
308 |
| - let inputID = "input_0".replace("textarea_", ""); |
309 |
| - document.querySelector('.' + inputID).value = content; |
310 |
| - } |
311 |
| - return true; |
312 |
| - } |
313 |
| - </script> |
| 328 | + // initialize image viewer and tinyMCE after ajax request |
| 329 | + jsf.ajax.addOnEvent(function (data) { |
| 330 | + if (data.status === 'success') { |
| 331 | + showImage(); |
| 332 | + initTinyMCE(); |
| 333 | + } |
| 334 | + }); |
| 335 | + </script> |
314 | 336 |
|
315 | 337 |
|
316 | 338 | </ui:define>
|
|
0 commit comments