mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-24 03:54:10 +01:00
[ticket/11552] Fixes for auto-resize textarea
Changing auto-resize code to work with all possible box-sizing and checking for negative height. PHPBB3-11552
This commit is contained in:
parent
f93d2cbdc1
commit
12c34e4176
@ -624,8 +624,7 @@ phpbb.resizeTextArea = function(items, options) {
|
|||||||
function resetAutoResize(item)
|
function resetAutoResize(item)
|
||||||
{
|
{
|
||||||
var $item = $(item);
|
var $item = $(item);
|
||||||
if ($item.hasClass('auto-resized'))
|
if ($item.hasClass('auto-resized')) {
|
||||||
{
|
|
||||||
$(item).css({height: '', resize: ''}).removeClass('auto-resized');
|
$(item).css({height: '', resize: ''}).removeClass('auto-resized');
|
||||||
configuration.resetCallback.call(item, $item);
|
configuration.resetCallback.call(item, $item);
|
||||||
}
|
}
|
||||||
@ -635,14 +634,14 @@ phpbb.resizeTextArea = function(items, options) {
|
|||||||
{
|
{
|
||||||
function setHeight(height)
|
function setHeight(height)
|
||||||
{
|
{
|
||||||
|
height += parseInt($item.css('height')) - $item.height();
|
||||||
$item.css({height: height + 'px', resize: 'none'}).addClass('auto-resized');
|
$item.css({height: height + 'px', resize: 'none'}).addClass('auto-resized');
|
||||||
configuration.resizeCallback.call(item, $item);
|
configuration.resizeCallback.call(item, $item);
|
||||||
}
|
}
|
||||||
|
|
||||||
var windowHeight = $(window).height();
|
var windowHeight = $(window).height();
|
||||||
|
|
||||||
if (windowHeight < configuration.minWindowHeight)
|
if (windowHeight < configuration.minWindowHeight) {
|
||||||
{
|
|
||||||
resetAutoResize(item);
|
resetAutoResize(item);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -652,12 +651,14 @@ phpbb.resizeTextArea = function(items, options) {
|
|||||||
height = parseInt($item.height()),
|
height = parseInt($item.height()),
|
||||||
scrollHeight = (item.scrollHeight) ? item.scrollHeight : 0;
|
scrollHeight = (item.scrollHeight) ? item.scrollHeight : 0;
|
||||||
|
|
||||||
if (height > maxHeight)
|
if (height < 0) {
|
||||||
{
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (height > maxHeight) {
|
||||||
setHeight(maxHeight);
|
setHeight(maxHeight);
|
||||||
}
|
}
|
||||||
else if (scrollHeight > (height + 5))
|
else if (scrollHeight > (height + 5)) {
|
||||||
{
|
|
||||||
setHeight(Math.min(maxHeight, scrollHeight));
|
setHeight(Math.min(maxHeight, scrollHeight));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -670,8 +671,7 @@ phpbb.resizeTextArea = function(items, options) {
|
|||||||
|
|
||||||
$(window).resize(function() {
|
$(window).resize(function() {
|
||||||
items.each(function() {
|
items.each(function() {
|
||||||
if ($(this).hasClass('auto-resized'))
|
if ($(this).hasClass('auto-resized')) {
|
||||||
{
|
|
||||||
autoResize(this);
|
autoResize(this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user