Skip to content

Commit

Permalink
fix resize of terminal when scrollbar appear/disappear while you type #…
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Mar 18, 2018
1 parent 6a07ebc commit 5aaf96c
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 17 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
* fix newline as first character in formatting [#375](https://github.com/jcubic/jquery.terminal/pull/375).
* fix error when echo undefined (it will echo string undefined since it's converted to string)
* fix first argument to keymap function, it's now keypress event
* trigger resize handler on keypress so it's resizing when scrollbar appear/disappear
[#378](https://github.com/jcubic/jquery.terminal/issues/378)

## 1.12.1
* fix minified css file + fix scrollbar
Expand Down
16 changes: 11 additions & 5 deletions js/jquery.terminal-1.12.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* Copyright (c) 2007-2013 Alexandru Marasteanu <hello at alexei dot ro>
* licensed under 3 clause BSD license
*
* Date: Sun, 18 Mar 2018 09:33:02 +0000
* Date: Sun, 18 Mar 2018 11:23:42 +0000
*/

/* TODO:
Expand Down Expand Up @@ -803,13 +803,15 @@
$this.data('observer', resizer);
return;
}
//var iframe = $('<iframe/>').addClass('resizer').appendTo(this)[0];
var self = this;
resizer = $('<div/>').addClass('resizer').appendTo(this)[0];
var style =
'position: absolute; left: 0; top: 0; right: 0; bottom: 0; ' +
'overflow: hidden; z-index: -1; visibility: hidden;';
var styleChild = 'position: absolute; left: 0; top: 0; transition: 0s;';
resizer.style.cssText = style;
//iframe.style.cssText = style;
resizer.innerHTML =
'<div class="resize-sensor-expand" style="' + style + '">' +
'<div style="' + styleChild + '"></div>' + "</div>" +
Expand Down Expand Up @@ -848,6 +850,7 @@
lastHeight = newHeight;
callbacks.fire();
};
//$(iframe.contentWindow).on('resize', onResized);

var onScroll = function() {
newWidth = self.offsetWidth;
Expand Down Expand Up @@ -2886,7 +2889,7 @@
}
$.terminal = {
version: 'DEV',
date: 'Sun, 18 Mar 2018 09:33:02 +0000',
date: 'Sun, 18 Mar 2018 11:23:42 +0000',
// colors from http://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -7117,7 +7120,10 @@
interpreters = new Stack($.extend({}, settings.extra, {
name: settings.name,
prompt: settings.prompt,
keypress: settings.keypress,
keypress: function keypress(e) {
setTimeout(resize, 0);
return settings.keypress(e);
},
keydown: settings.keydown,
resize: settings.onResize,
greetings: settings.greetings,
Expand Down Expand Up @@ -7317,8 +7323,8 @@
}
function resize() {
if (self.is(':visible')) {
var width = self.width();
var height = self.height();
var width = fill.width();
var height = fill.height();
// prevent too many calculations in IE
if (old_height !== height || old_width !== width) {
self.resize();
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal-1.12.1.min.js

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions js/jquery.terminal-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -803,13 +803,15 @@
$this.data('observer', resizer);
return;
}
//var iframe = $('<iframe/>').addClass('resizer').appendTo(this)[0];
var self = this;
resizer = $('<div/>').addClass('resizer').appendTo(this)[0];
var style =
'position: absolute; left: 0; top: 0; right: 0; bottom: 0; ' +
'overflow: hidden; z-index: -1; visibility: hidden;';
var styleChild = 'position: absolute; left: 0; top: 0; transition: 0s;';
resizer.style.cssText = style;
//iframe.style.cssText = style;
resizer.innerHTML =
'<div class="resize-sensor-expand" style="' + style + '">' +
'<div style="' + styleChild + '"></div>' + "</div>" +
Expand Down Expand Up @@ -848,6 +850,7 @@
lastHeight = newHeight;
callbacks.fire();
};
//$(iframe.contentWindow).on('resize', onResized);

var onScroll = function() {
newWidth = self.offsetWidth;
Expand Down Expand Up @@ -7117,7 +7120,10 @@
interpreters = new Stack($.extend({}, settings.extra, {
name: settings.name,
prompt: settings.prompt,
keypress: settings.keypress,
keypress: function keypress(e) {
setTimeout(resize, 0);
return settings.keypress(e);
},
keydown: settings.keydown,
resize: settings.onResize,
greetings: settings.greetings,
Expand Down Expand Up @@ -7317,8 +7323,8 @@
}
function resize() {
if (self.is(':visible')) {
var width = self.width();
var height = self.height();
var width = fill.width();
var height = fill.height();
// prevent too many calculations in IE
if (old_height !== height || old_width !== width) {
self.resize();
Expand Down
16 changes: 11 additions & 5 deletions js/jquery.terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* Copyright (c) 2007-2013 Alexandru Marasteanu <hello at alexei dot ro>
* licensed under 3 clause BSD license
*
* Date: Sun, 18 Mar 2018 09:33:02 +0000
* Date: Sun, 18 Mar 2018 11:23:42 +0000
*/

/* TODO:
Expand Down Expand Up @@ -803,13 +803,15 @@
$this.data('observer', resizer);
return;
}
//var iframe = $('<iframe/>').addClass('resizer').appendTo(this)[0];
var self = this;
resizer = $('<div/>').addClass('resizer').appendTo(this)[0];
var style =
'position: absolute; left: 0; top: 0; right: 0; bottom: 0; ' +
'overflow: hidden; z-index: -1; visibility: hidden;';
var styleChild = 'position: absolute; left: 0; top: 0; transition: 0s;';
resizer.style.cssText = style;
//iframe.style.cssText = style;
resizer.innerHTML =
'<div class="resize-sensor-expand" style="' + style + '">' +
'<div style="' + styleChild + '"></div>' + "</div>" +
Expand Down Expand Up @@ -848,6 +850,7 @@
lastHeight = newHeight;
callbacks.fire();
};
//$(iframe.contentWindow).on('resize', onResized);

var onScroll = function() {
newWidth = self.offsetWidth;
Expand Down Expand Up @@ -2886,7 +2889,7 @@
}
$.terminal = {
version: 'DEV',
date: 'Sun, 18 Mar 2018 09:33:02 +0000',
date: 'Sun, 18 Mar 2018 11:23:42 +0000',
// colors from http://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -7117,7 +7120,10 @@
interpreters = new Stack($.extend({}, settings.extra, {
name: settings.name,
prompt: settings.prompt,
keypress: settings.keypress,
keypress: function keypress(e) {
setTimeout(resize, 0);
return settings.keypress(e);
},
keydown: settings.keydown,
resize: settings.onResize,
greetings: settings.greetings,
Expand Down Expand Up @@ -7317,8 +7323,8 @@
}
function resize() {
if (self.is(':visible')) {
var width = self.width();
var height = self.height();
var width = fill.width();
var height = fill.height();
// prevent too many calculations in IE
if (old_height !== height || old_width !== width) {
self.resize();
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal.min.js

Large diffs are not rendered by default.

0 comments on commit 5aaf96c

Please sign in to comment.