v1.18.x
psychobunny 10 years ago
parent 4cb58d976b
commit 2f05ec7de0

@ -19,11 +19,13 @@ define('composer/resize', ['autosize'], function(autosize) {
env = utils.findBootstrapEnvironment(); env = utils.findBootstrapEnvironment();
} }
postContainer.percentage = percentage;
if (percentage) { if (percentage) {
var max = getMaximumPercentage();
if (percentage < 0.25) { if (percentage < 0.25) {
percentage = 0.25; percentage = 0.25;
} else if (percentage > max) {
percentage = max;
} }
if (env === 'md' || env === 'lg') { if (env === 'md' || env === 'lg') {
@ -31,6 +33,8 @@ define('composer/resize', ['autosize'], function(autosize) {
} }
} }
postContainer.percentage = percentage;
// todo, lump in browsers that don't support transform (ie8) here // todo, lump in browsers that don't support transform (ie8) here
// at this point we should use modernizr // at this point we should use modernizr
if (env === 'sm' || env === 'xs' || window.innerHeight < 480) { if (env === 'sm' || env === 'xs' || window.innerHeight < 480) {
@ -94,7 +98,7 @@ define('composer/resize', ['autosize'], function(autosize) {
function toggleMaximize(e) { function toggleMaximize(e) {
if (e.clientY - resizeDown === 0 || snapToTop) { if (e.clientY - resizeDown === 0 || snapToTop) {
var newPercentage = ($(window).height() - $('#header-menu').height() - 1) / $(window).height(); var newPercentage = getMaximumPercentage();
if (!postContainer.hasClass('maximized') || !snapToTop) { if (!postContainer.hasClass('maximized') || !snapToTop) {
oldPercentage = postContainer.percentage; oldPercentage = postContainer.percentage;
@ -132,8 +136,9 @@ define('composer/resize', ['autosize'], function(autosize) {
} }
function resizeSavePosition(px) { function resizeSavePosition(px) {
var percentage = px / $(window).height(); var percentage = px / $(window).height(),
localStorage.setItem('composer:resizePercentage', percentage); max = getMaximumPercentage();
localStorage.setItem('composer:resizePercentage', percentage < max ? percentage : max);
} }
var resizeActive = false, var resizeActive = false,
@ -142,23 +147,27 @@ define('composer/resize', ['autosize'], function(autosize) {
snapToTop = false, snapToTop = false,
resizeEl = postContainer.find('.resizer'); resizeEl = postContainer.find('.resizer');
resizeEl.on('mousedown', resizeStart); resizeEl
.on('mousedown', resizeStart)
resizeEl.on('touchstart', function(e) { .on('touchstart', function(e) {
e.preventDefault(); e.preventDefault();
resizeStart(e.touches[0]); resizeStart(e.touches[0]);
}); })
.on('touchend', function(e) {
resizeEl.on('touchend', function(e) { e.preventDefault();
e.preventDefault(); resizeStop();
resizeStop(); });
});
}; };
function getMaximumPercentage() {
return ($(window).height() - $('#header-menu').height() - 1) / $(window).height();
}
function resizeWritePreview(postContainer) { function resizeWritePreview(postContainer) {
var total = getFormattingHeight(postContainer); var total = getFormattingHeight(postContainer);
postContainer.find('.write-preview-container').css('height', postContainer.percentage * $(window).height() - $('#header-menu').height() - total); postContainer
.find('.write-preview-container')
.css('height', postContainer.percentage * $(window).height() - $('#header-menu').height() - total);
} }
function getFormattingHeight(postContainer) { function getFormattingHeight(postContainer) {

Loading…
Cancel
Save