Skip to content

Instantly share code, notes, and snippets.

@rtivital
Created April 2, 2016 15:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtivital/38259acad4cd55379b06feea98db514e to your computer and use it in GitHub Desktop.
Save rtivital/38259acad4cd55379b06feea98db514e to your computer and use it in GitHub Desktop.
function resizeFormIsValid() {
var x = +resizeX.value;
var y = +resizeY.value;
var side = +resizeSize.value;
var imageWidth = currentResizer._image.naturalWidth;
var imageHeight = currentResizer._image.naturalHeight;
var messageWrapper = document.getElementById('upload-resize-message');
if (x + side <= imageWidth && y + side <= imageHeight) {
resizeFwd.disabled = false;
resizeFwd.style.opacity = 1;
if (messageWrapper) {
messageWrapper.textContent = '';
}
// resizeMessage.classList.add('invisible');
return true;
}
if (!messageWrapper) {
messageWrapper = document.createElement('div');
messageWrapper.id = 'upload-resize-message';
}
resizeFwd.disabled = true;
messageWrapper.textContent = 'Ошибочка!';
resizeFwd.style.opacity = .3;
console.log(messageWrapper);
resizeForm.appendChild(messageWrapper);
return false;
}
resizeForm.onchange = function() {
resizeFormIsValid();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment