From c0a474ed82ada104d08a41b4640a02cbab2a4705 Mon Sep 17 00:00:00 2001 From: rr- Date: Sun, 19 Jul 2015 18:50:36 +0200 Subject: [PATCH] Added new fit mode for both dimensions --- .../js/Presenters/PostContentPresenter.js | 19 +++++++++++++++++++ public_html/templates/browsing-settings.tpl | 10 ++++++++-- public_html/templates/post.tpl | 1 + 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/public_html/js/Presenters/PostContentPresenter.js b/public_html/js/Presenters/PostContentPresenter.js index 698037be..a74b6dab 100644 --- a/public_html/js/Presenters/PostContentPresenter.js +++ b/public_html/js/Presenters/PostContentPresenter.js @@ -38,6 +38,25 @@ App.Presenters.PostContentPresenter = function( var containerWidth = $wrapper.parent().outerWidth() - 10; return { + 'fit-both': function(allowUpscale) { + var width = containerWidth; + var height = containerWidth / ratio; + if (height > containerHeight) { + width = containerHeight * ratio; + height = containerHeight; + } + if (!allowUpscale) { + if (width > originalWidth) { + width = originalWidth; + height = originalWidth / ratio; + } + if (height > originalHeight) { + width = originalHeight * ratio; + height = originalHeight; + } + } + $wrapper.css({maxWidth: width + 'px', width: ''}); + }, 'fit-height': function(allowUpscale) { var width = containerHeight * ratio; if (width > originalWidth && !allowUpscale) { diff --git a/public_html/templates/browsing-settings.tpl b/public_html/templates/browsing-settings.tpl index 7747b71d..b4b29633 100644 --- a/public_html/templates/browsing-settings.tpl +++ b/public_html/templates/browsing-settings.tpl @@ -56,13 +56,19 @@
type="radio" id="browsing-settings-fit-width" name="fitMode" value="fit-width"/>
type="radio" id="browsing-settings-fit-height" name="fitMode" value="fit-height"/> +
+ + type="radio" id="browsing-settings-fit-both" name="fitMode" value="fit-both"/> +
diff --git a/public_html/templates/post.tpl b/public_html/templates/post.tpl index 545d15e8..5e233c17 100644 --- a/public_html/templates/post.tpl +++ b/public_html/templates/post.tpl @@ -272,6 +272,7 @@ if (forceHttpInPermalinks > 0) { Fit: width, height, + both, original