Remove useless wrapper

This commit is contained in:
Florian Mounier
2015-04-14 14:23:10 +02:00
parent 53c880964e
commit 909bc5ab44
10 changed files with 49 additions and 79 deletions

View File

@@ -21,7 +21,7 @@ $shadow-alpha: 0 !default
$bg: #110f13
$fg: #f4ead5
#wrapper
html, body
background-color: $bg
.terminal

View File

@@ -16,20 +16,13 @@
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
html, body
height: 100%
margin: 0
padding: 0
line-height: 1.2
#wrapper
height: 100%
overflow: hidden
overflow-x: hidden
overflow-y: auto
white-space: nowrap
body[data-native-scroll="yes"]
#wrapper
overflow-y: scroll
::-webkit-scrollbar
background: $bg
width: .75em

View File

@@ -1,12 +0,0 @@
html, body{
height: 100%;
margin: 0;
padding: 0;
line-height: 1.2;}
#wrapper{
height: 100%;
overflow-x: hidden;
overflow-y: auto;
white-space: nowrap;}
.terminal{
outline: none;}

File diff suppressed because one or more lines are too long

View File

@@ -130,7 +130,7 @@ body {
/* GNU General Public License for more details. */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#wrapper {
html, body {
background-color: #110f13; }
.terminal {
@@ -3018,23 +3018,19 @@ body {
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
html, body {
height: 100%;
margin: 0;
padding: 0;
line-height: 1.2; }
#wrapper {
height: 100%;
overflow: hidden;
line-height: 1.2;
overflow-x: hidden;
overflow-y: auto;
white-space: nowrap; }
body[data-native-scroll="yes"] #wrapper {
overflow-y: scroll; }
body[data-native-scroll="yes"] ::-webkit-scrollbar {
::-webkit-scrollbar {
background: #110f13;
width: .75em;
height: .75em; }
body[data-native-scroll="yes"] ::-webkit-scrollbar-thumb {
::-webkit-scrollbar-thumb {
background: rgba(244, 234, 213, 0.1); }
.terminal {

View File

@@ -73,7 +73,7 @@
return open('', '_self').close();
}
});
term = new Terminal($('#wrapper')[0], send, ctl);
term = new Terminal(document.body, send, ctl);
addEventListener('beforeunload', function() {
if (!quit) {
return 'This will exit the terminal session';
@@ -139,7 +139,7 @@
Terminal = (function() {
function Terminal(parent, out1, ctl1) {
var div, i, px, term_height, term_width;
var div, i, px;
this.parent = parent;
this.out = out1;
this.ctl = ctl1 != null ? ctl1 : function() {};
@@ -152,20 +152,18 @@
this.element.style.outline = 'none';
this.element.setAttribute('tabindex', 0);
this.element.setAttribute('spellcheck', 'false');
this.parent.appendChild(this.element);
this.parent.insertBefore(this.element, this.parent.firstChild);
div = this.document.createElement('div');
div.className = 'line';
this.element.appendChild(div);
this.children = [div];
this.compute_char_size();
term_width = this.element.getBoundingClientRect().width;
term_height = this.parent.getBoundingClientRect().height;
this.cols = Math.floor(term_width / this.char_size.width);
this.rows = Math.floor(term_height / this.char_size.height);
px = term_height % this.char_size.height;
this.cols = Math.floor(window.innerWidth / this.char_size.width);
this.rows = Math.floor(window.innerHeight / this.char_size.height);
px = window.innerHeight % this.char_size.height;
this.element.style['padding-bottom'] = px + "px";
this.html = {};
i = this.rows - 1;
i = Math.max(this.rows - 1, 0);
while (i--) {
div = this.document.createElement('div');
div.className = 'line';
@@ -646,13 +644,14 @@
scroll = -1;
}
if (scroll === -1) {
scroll = this.parent.scrollHeight - this.parent.getBoundingClientRect().height;
return this.children.slice(-1)[0].scrollIntoView();
} else {
return window.scrollTo(scroll);
}
return this.parent.scrollTop = scroll;
};
Terminal.prototype.scroll_display = function(disp) {
return this.native_scroll_to(this.parent.scrollTop + disp * this.char_size.height);
return this.native_scroll_to(window.scrollY + disp * this.char_size.height);
};
Terminal.prototype.new_line = function() {
@@ -1477,15 +1476,13 @@
};
Terminal.prototype.resize = function() {
var el, i, j, line, old_cols, old_rows, px, term_height, term_width;
var el, i, j, line, old_cols, old_rows, px;
old_cols = this.cols;
old_rows = this.rows;
this.compute_char_size();
term_width = this.element.getBoundingClientRect().width;
term_height = this.parent.getBoundingClientRect().height;
this.cols = Math.floor(term_width / this.char_size.width);
this.rows = Math.floor(term_height / this.char_size.height);
px = term_height % this.char_size.height;
this.cols = Math.floor(window.innerWidth / this.char_size.width);
this.rows = Math.floor(window.innerHeight / this.char_size.height);
px = window.innerHeight % this.char_size.height;
this.element.style['padding-bottom'] = px + "px";
if (old_cols === this.cols && old_rows === this.rows) {
return;

File diff suppressed because one or more lines are too long

View File

@@ -15,7 +15,6 @@
<body spellcheck="false"
data-allow-html="{{ 'yes' if options.allow_html_escapes else 'no' }}">
<main id="wrapper"> </main>
<script src="{{ static_url('main.%sjs' % (
'' if options.unminified else 'min.')) }}"></script>
<script src="{{ static_url('ext.%sjs' % (

View File

@@ -79,7 +79,7 @@ document.addEventListener 'DOMContentLoaded', ->
if (new Date()).getTime() - open_ts > 60 * 1000
open('','_self').close()
term = new Terminal $('#wrapper')[0], send, ctl
term = new Terminal document.body, send, ctl
addEventListener 'beforeunload', ->
if not quit
'This will exit the terminal session'

View File

@@ -61,7 +61,7 @@ class Terminal
@element.setAttribute 'tabindex', 0
@element.setAttribute 'spellcheck', 'false'
@parent.appendChild(@element)
@parent.insertBefore @element, @parent.firstChild
# Adding one line to compute char size
div = @document.createElement('div')
@@ -70,15 +70,13 @@ class Terminal
@children = [div]
@compute_char_size()
term_width = @element.getBoundingClientRect().width
term_height = @parent.getBoundingClientRect().height
@cols = Math.floor(term_width / @char_size.width)
@rows = Math.floor(term_height / @char_size.height)
px = term_height % @char_size.height
@cols = Math.floor(window.innerWidth / @char_size.width)
@rows = Math.floor(window.innerHeight / @char_size.height)
px = window.innerHeight % @char_size.height
@element.style['padding-bottom'] = "#{px}px"
@html = {}
i = @rows - 1
i = Math.max @rows - 1, 0
while i--
div = @document.createElement('div')
div.className = 'line'
@@ -530,11 +528,12 @@ class Terminal
native_scroll_to: (scroll=-1) ->
if scroll is -1
scroll = @parent.scrollHeight - @parent.getBoundingClientRect().height
@parent.scrollTop = scroll
@children.slice(-1)[0].scrollIntoView()
else
window.scrollTo scroll
scroll_display: (disp) ->
@native_scroll_to @parent.scrollTop + disp * @char_size.height
@native_scroll_to window.scrollY + disp * @char_size.height
new_line: ->
div = @document.createElement('div')
@@ -1430,11 +1429,9 @@ class Terminal
old_cols = @cols
old_rows = @rows
@compute_char_size()
term_width = @element.getBoundingClientRect().width
term_height = @parent.getBoundingClientRect().height
@cols = Math.floor(term_width / @char_size.width)
@rows = Math.floor(term_height / @char_size.height)
px = term_height % @char_size.height
@cols = Math.floor(window.innerWidth / @char_size.width)
@rows = Math.floor(window.innerHeight / @char_size.height)
px = window.innerHeight % @char_size.height
@element.style['padding-bottom'] = "#{px}px"
if old_cols == @cols and old_rows == @rows