Added new fit mode for both dimensions

This commit is contained in:
rr- 2015-07-19 18:50:36 +02:00
parent 6380043a9a
commit c0a474ed82
3 changed files with 28 additions and 2 deletions

View file

@ -38,6 +38,25 @@ App.Presenters.PostContentPresenter = function(
var containerWidth = $wrapper.parent().outerWidth() - 10; var containerWidth = $wrapper.parent().outerWidth() - 10;
return { 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) { 'fit-height': function(allowUpscale) {
var width = containerHeight * ratio; var width = containerHeight * ratio;
if (width > originalWidth && !allowUpscale) { if (width > originalWidth && !allowUpscale) {

View file

@ -56,13 +56,19 @@
<div class="form-input"> <div class="form-input">
<input <% print(settings.fitMode === 'fit-width' ? 'checked="checked"' : '') %> type="radio" id="browsing-settings-fit-width" name="fitMode" value="fit-width"/> <input <% print(settings.fitMode === 'fit-width' ? 'checked="checked"' : '') %> type="radio" id="browsing-settings-fit-width" name="fitMode" value="fit-width"/>
<label for="browsing-settings-fit-width"> <label for="browsing-settings-fit-width">
Fit width Fit to width
</label> </label>
<br/> <br/>
<input <% print(settings.fitMode === 'fit-height' ? 'checked="checked"' : '') %> type="radio" id="browsing-settings-fit-height" name="fitMode" value="fit-height"/> <input <% print(settings.fitMode === 'fit-height' ? 'checked="checked"' : '') %> type="radio" id="browsing-settings-fit-height" name="fitMode" value="fit-height"/>
<label for="browsing-settings-fit-height"> <label for="browsing-settings-fit-height">
Fit height Fit to height
</label>
<br/>
<input <% print(settings.fitMode === 'fit-both' ? 'checked="checked"' : '') %> type="radio" id="browsing-settings-fit-both" name="fitMode" value="fit-both"/>
<label for="browsing-settings-fit-both">
Fit width and height
</label> </label>
<br/> <br/>

View file

@ -272,6 +272,7 @@ if (forceHttpInPermalinks > 0) {
Fit: Fit:
<a data-fit-mode="fit-width" href="#">width</a>, <a data-fit-mode="fit-width" href="#">width</a>,
<a data-fit-mode="fit-height" href="#">height</a>, <a data-fit-mode="fit-height" href="#">height</a>,
<a data-fit-mode="fit-both" href="#">both</a>,
<a data-fit-mode="original" href="#">original</a> <a data-fit-mode="original" href="#">original</a>
</li> </li>
</ul> </ul>