Skip to content

Commit

Permalink
fix textarea sizing and position #744
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Mar 27, 2022
1 parent 47a15d3 commit 4d71b7f
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 33 deletions.
34 changes: 24 additions & 10 deletions js/jquery.terminal-2.32.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*
* broken image by Sophia Bai from the Noun Project (CC-BY)
*
* Date: Sun, 27 Mar 2022 10:38:45 +0000
* Date: Sun, 27 Mar 2022 11:29:21 +0000
*/
/* global define, Map */
/* eslint-disable */
Expand Down Expand Up @@ -1290,6 +1290,21 @@
}
}
// -----------------------------------------------------------------------
// :: return CSS property with pixel size & proper
// -----------------------------------------------------------------------
function style_prop(name, value, important) {
var props = [
name + ':' + value + 'px',
name + ':' + 'calc(' + value + 'px / var(--pixel-density, 1))'
];
if (important) {
props = props.map(function(prop) {
return prop + ' !important';
});
}
return props.join(';');
}
// -----------------------------------------------------------------------
// :: hide elements from screen readers
// -----------------------------------------------------------------------
function a11y_hide(element) {
Expand Down Expand Up @@ -5154,7 +5169,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Sun, 27 Mar 2022 10:38:45 +0000',
date: 'Sun, 27 Mar 2022 11:29:21 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -11636,7 +11651,7 @@
var width = 5 * 14;
var rect = self[0].getBoundingClientRect();
// we need width without scrollbar
var content_width = fill.outerWidth();
var content_width = fill.outerWidth() * pixel_density;
// fix jumping when click near bottom or left edge #592
var diff_h = (top + cmd_rect.top + height);
diff_h = diff_h - rect.height - rect.top;
Expand All @@ -11651,10 +11666,10 @@
width -= Math.ceil(diff_w);
}
$clip.attr('style', [
'left:' + left + 'px !important',
'top:' + top + 'px !important',
'width:' + width + 'px !important',
'height:' + height + 'px !important'
style_prop('left', left, true),
style_prop('top', top, true),
style_prop('width', width, true),
style_prop('height', height, true)
].join(';'));
if (!$clip.is(':focus')) {
$clip.focus();
Expand Down Expand Up @@ -11774,9 +11789,8 @@
var top = $('<div class="terminal-scroll-marker"/>').appendTo(self);
var marker = top;
if (settings.scrollBottomOffset !== -1) {
marker = $('<div/>').css({
height: settings.scrollBottomOffset
}).appendTo(top);
var style = style_prop('height', settings.scrollBottomOffset);
marker = $('<div style="' + style + '"/>').appendTo(top);
}
is_bottom_observer = new IntersectionObserver(bottom_detect, {
root: self[0]
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal-2.32.1.min.js

Large diffs are not rendered by default.

30 changes: 22 additions & 8 deletions js/jquery.terminal-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,21 @@
}
}
// -----------------------------------------------------------------------
// :: return CSS property with pixel size & proper
// -----------------------------------------------------------------------
function style_prop(name, value, important) {
var props = [
name + ':' + value + 'px',
name + ':' + 'calc(' + value + 'px / var(--pixel-density, 1))'
];
if (important) {
props = props.map(function(prop) {
return prop + ' !important';
});
}
return props.join(';');
}
// -----------------------------------------------------------------------
// :: hide elements from screen readers
// -----------------------------------------------------------------------
function a11y_hide(element) {
Expand Down Expand Up @@ -11636,7 +11651,7 @@
var width = 5 * 14;
var rect = self[0].getBoundingClientRect();
// we need width without scrollbar
var content_width = fill.outerWidth();
var content_width = fill.outerWidth() * pixel_density;
// fix jumping when click near bottom or left edge #592
var diff_h = (top + cmd_rect.top + height);
diff_h = diff_h - rect.height - rect.top;
Expand All @@ -11651,10 +11666,10 @@
width -= Math.ceil(diff_w);
}
$clip.attr('style', [
'left:' + left + 'px !important',
'top:' + top + 'px !important',
'width:' + width + 'px !important',
'height:' + height + 'px !important'
style_prop('left', left, true),
style_prop('top', top, true),
style_prop('width', width, true),
style_prop('height', height, true)
].join(';'));
if (!$clip.is(':focus')) {
$clip.focus();
Expand Down Expand Up @@ -11774,9 +11789,8 @@
var top = $('<div class="terminal-scroll-marker"/>').appendTo(self);
var marker = top;
if (settings.scrollBottomOffset !== -1) {
marker = $('<div/>').css({
height: settings.scrollBottomOffset
}).appendTo(top);
var style = style_prop('height', settings.scrollBottomOffset);
marker = $('<div style="' + style + '"/>').appendTo(top);
}
is_bottom_observer = new IntersectionObserver(bottom_detect, {
root: self[0]
Expand Down
34 changes: 24 additions & 10 deletions js/jquery.terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*
* broken image by Sophia Bai from the Noun Project (CC-BY)
*
* Date: Sun, 27 Mar 2022 10:38:45 +0000
* Date: Sun, 27 Mar 2022 11:29:21 +0000
*/
/* global define, Map */
/* eslint-disable */
Expand Down Expand Up @@ -1290,6 +1290,21 @@
}
}
// -----------------------------------------------------------------------
// :: return CSS property with pixel size & proper
// -----------------------------------------------------------------------
function style_prop(name, value, important) {
var props = [
name + ':' + value + 'px',
name + ':' + 'calc(' + value + 'px / var(--pixel-density, 1))'
];
if (important) {
props = props.map(function(prop) {
return prop + ' !important';
});
}
return props.join(';');
}
// -----------------------------------------------------------------------
// :: hide elements from screen readers
// -----------------------------------------------------------------------
function a11y_hide(element) {
Expand Down Expand Up @@ -5154,7 +5169,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Sun, 27 Mar 2022 10:38:45 +0000',
date: 'Sun, 27 Mar 2022 11:29:21 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -11636,7 +11651,7 @@
var width = 5 * 14;
var rect = self[0].getBoundingClientRect();
// we need width without scrollbar
var content_width = fill.outerWidth();
var content_width = fill.outerWidth() * pixel_density;
// fix jumping when click near bottom or left edge #592
var diff_h = (top + cmd_rect.top + height);
diff_h = diff_h - rect.height - rect.top;
Expand All @@ -11651,10 +11666,10 @@
width -= Math.ceil(diff_w);
}
$clip.attr('style', [
'left:' + left + 'px !important',
'top:' + top + 'px !important',
'width:' + width + 'px !important',
'height:' + height + 'px !important'
style_prop('left', left, true),
style_prop('top', top, true),
style_prop('width', width, true),
style_prop('height', height, true)
].join(';'));
if (!$clip.is(':focus')) {
$clip.focus();
Expand Down Expand Up @@ -11774,9 +11789,8 @@
var top = $('<div class="terminal-scroll-marker"/>').appendTo(self);
var marker = top;
if (settings.scrollBottomOffset !== -1) {
marker = $('<div/>').css({
height: settings.scrollBottomOffset
}).appendTo(top);
var style = style_prop('height', settings.scrollBottomOffset);
marker = $('<div style="' + style + '"/>').appendTo(top);
}
is_bottom_observer = new IntersectionObserver(bottom_detect, {
root: self[0]
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/jquery.terminal.min.js.map

Large diffs are not rendered by default.

0 comments on commit 4d71b7f

Please sign in to comment.