diff --git a/.github/publication_assets/lightbox.png b/.github/publication_assets/lightbox.png index b509b83..9949916 100644 Binary files a/.github/publication_assets/lightbox.png and b/.github/publication_assets/lightbox.png differ diff --git a/localization/de.po b/localization/de.po index 8288c1a..8c28419 100644 --- a/localization/de.po +++ b/localization/de.po @@ -81,3 +81,9 @@ msgstr "Dur wirst in %1$s Sekunden zur Startseite weitergeleitet" msgid "Today" msgstr "Heute" + +msgid "Rotate image to the left" +msgstr "Bild nach links drehen" + +msgid "Rotate image to the right" +msgstr "Bild nach rechts drehen" diff --git a/localization/en.po b/localization/en.po index 9f1229f..4b623d3 100644 --- a/localization/en.po +++ b/localization/en.po @@ -81,3 +81,9 @@ msgstr "You will be redirected to the default page in %1$s seconds" msgid "Today" msgstr "Today" + +msgid "Rotate image to the left" +msgstr "Rotate image to the left" + +msgid "Rotate image to the right" +msgstr "Rotate image to the right" diff --git a/localization/strings.pot b/localization/strings.pot index b06bfa7..1f2daf9 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -87,3 +87,9 @@ msgstr "" msgid "Today" msgstr "" + +msgid "Rotate image to the left" +msgstr "" + +msgid "Rotate image to the right" +msgstr "" diff --git a/public/piksi.js b/public/piksi.js index f775cc4..acffad7 100644 --- a/public/piksi.js +++ b/public/piksi.js @@ -123,7 +123,19 @@ $(document).on("click", ".show-as-dialog-image", function(e) ' + __t('Back') + ' \ \ \ - '; + \ +
\ +
\ + \ +
\ +
\ + \ +
\ +
'; bootbox.dialog({ "message": dialogHtml, @@ -218,3 +230,35 @@ bootbox.setDefaults({ "closeButton": false, "centerVertical": true }) + +RotateImage = function(img, rotationFactor) +{ + var currentRotation = 0 + if (img.hasAttr("data-current-rotation")) + { + currentRotation = Number.parseInt(img.attr("data-current-rotation")) + } + + currentRotation += rotationFactor; + if (Math.abs(currentRotation) == 360) + { + currentRotation = 0; + } + + var scale = 1; + if (Math.abs(currentRotation) == 90 || Math.abs(currentRotation) == 270) + { + scale = img.get(0).naturalHeight / img.get(0).naturalWidth; + } + + img.attr("data-current-rotation", currentRotation); + img.css("transform", `rotate(${currentRotation}deg) scale(${scale})`); +} + +$(document).on("click", ".rotate-image-button", function(e) +{ + e.preventDefault(); + + var button = $(e.currentTarget); + RotateImage(button.parent().parent().parent().find("img"), Number.parseInt(button.attr("data-rotation-factor"))); +});