From a8232e613ad41c8ed1901ad0ee634f8c8dce7973 Mon Sep 17 00:00:00 2001 From: Arved Solth Date: Wed, 22 Dec 2021 10:12:17 +0100 Subject: [PATCH 1/2] Reset rotation when changing image in metadata editor --- .../webapp/WEB-INF/resources/js/ol_custom.js | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/Kitodo/src/main/webapp/WEB-INF/resources/js/ol_custom.js b/Kitodo/src/main/webapp/WEB-INF/resources/js/ol_custom.js index 156a975a8f0..ede49b6be03 100644 --- a/Kitodo/src/main/webapp/WEB-INF/resources/js/ol_custom.js +++ b/Kitodo/src/main/webapp/WEB-INF/resources/js/ol_custom.js @@ -88,24 +88,14 @@ kitodo.RotateRightControl = function(options = {}) { * @constructor */ kitodo.ResetNorthControl = function(options = {}) { - var buttonResetNorth = document.createElement("button"); + let buttonResetNorth = document.createElement("button"); buttonResetNorth.innerHTML = ""; buttonResetNorth.setAttribute("type", "button"); buttonResetNorth.setAttribute("title", "Reset orientation"); - var this_ = this; - - var handleResetNorth = function() { - var view = this_.getMap().getView(); - view.animate({ - rotation: 0, - duration: 100 - }); - }; + buttonResetNorth.addEventListener("click", resetNorth, false); - buttonResetNorth.addEventListener("click", handleResetNorth, false); - - var elementResetNorth = document.createElement("div"); + let elementResetNorth = document.createElement("div"); elementResetNorth.className = "ol-rotate ol-unselectable ol-control"; /*ol-rotate-reset*/ elementResetNorth.appendChild(buttonResetNorth); @@ -165,6 +155,16 @@ function showCanvas() { } } +function resetNorth() { + if (kitodo.map) { + let view = kitodo.map.getView(); + view.animate({ + rotation: 0, + duration: 0 + }); + } +} + function initializeMap(imageDimensions, imagePath) { // Map image coordinates to map coordinates to be able to use image extent in pixels. let extent = [0, 0, imageDimensions[0], imageDimensions[1]]; @@ -224,6 +224,7 @@ function addListener(element) { } function initializeImage() { + resetNorth(); hideCanvas(); let image = $("#imagePreviewForm\\:mediaViewData"); addListener(image); From dba48562b8021e9484417c3fc33e0be514465b40 Mon Sep 17 00:00:00 2001 From: Arved Solth Date: Wed, 22 Dec 2021 10:19:34 +0100 Subject: [PATCH 2/2] Move function declaration to fix Codacy issue --- .../webapp/WEB-INF/resources/js/ol_custom.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Kitodo/src/main/webapp/WEB-INF/resources/js/ol_custom.js b/Kitodo/src/main/webapp/WEB-INF/resources/js/ol_custom.js index ede49b6be03..5bcd176802b 100644 --- a/Kitodo/src/main/webapp/WEB-INF/resources/js/ol_custom.js +++ b/Kitodo/src/main/webapp/WEB-INF/resources/js/ol_custom.js @@ -82,6 +82,16 @@ kitodo.RotateRightControl = function(options = {}) { }); }; +function resetNorth() { + if (kitodo.map) { + let view = kitodo.map.getView(); + view.animate({ + rotation: 0, + duration: 0 + }); + } +} + /** * @param {Object=} options Custom control options for Kitodo in OpenLayers * @extends {ol.control.Rotate} @@ -155,16 +165,6 @@ function showCanvas() { } } -function resetNorth() { - if (kitodo.map) { - let view = kitodo.map.getView(); - view.animate({ - rotation: 0, - duration: 0 - }); - } -} - function initializeMap(imageDimensions, imagePath) { // Map image coordinates to map coordinates to be able to use image extent in pixels. let extent = [0, 0, imageDimensions[0], imageDimensions[1]];