Added new fit mode for both dimensions
This commit is contained in:
parent
6380043a9a
commit
c0a474ed82
3 changed files with 28 additions and 2 deletions
|
@ -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) {
|
||||||
|
|
|
@ -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/>
|
||||||
|
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Reference in a new issue