Skip to content

Commit 5508b7a

Browse files
committed
Merge pull request #910 from Martii/Issue-136recheck
Refix source code viewer has tiny height Auto-merge
2 parents 318628e + 5603dda commit 5508b7a

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

views/includes/scripts/scriptEditor.html

+27-12
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,29 @@
55
$(document).ready(function () {
66
var editor = ace.edit("editor");
77

8-
function hasCalc(aPrefix) {
9-
var el = null;
8+
function hasRelative(aPrefix) {
9+
var hasCalc = null;
10+
var hasUnitV = null;
1011

1112
aPrefix = aPrefix || "";
12-
el = document.createElement("div");
13-
el.style.setProperty(aPrefix + "width", "calc(1px)", "");
14-
return !!el.style.length;
13+
hasCalc = document.createElement("div");
14+
hasCalc.style.setProperty(aPrefix + "width", "calc(1px)", "");
15+
16+
if (!!hasCalc.style.length) {
17+
hasUnitV = document.createElement("div");
18+
hasUnitV.style.setProperty(aPrefix + "width", "calc(5vw + 5vw)", "");
19+
}
20+
21+
return !!hasCalc.style.length && !!hasUnitV.style.length;
1522
}
1623

17-
function hasAnyCalc() {
18-
return hasCalc("-moz-") || hasCalc("-ms-") || hasCalc("-o-") || hasCalc("-webkit-") || hasCalc();
24+
function hasOurRelative() {
25+
return hasRelative("-moz-") || hasRelative("-ms-") || hasRelative("-o-") ||
26+
hasRelative("-webkit-") || hasRelative();
1927
}
2028

2129
function calcHeight() {
22-
return window.innerHeight - {{#newScript}}190{{/newScript}}{{^newScript}}303{{/newScript}};
30+
return window.innerHeight - {{#newScript}}190{{/newScript}}{{^newScript}}302{{/newScript}};
2331
}
2432

2533
editor.setTheme("ace/theme/dawn");
@@ -34,12 +42,19 @@
3442
});
3543
{{/readOnly}}
3644

37-
// Older browser JavaScript work-around for #136
38-
if (!hasAnyCalc()) {
45+
// Some older and newer browser JavaScript work-around for #136
46+
if (!hasOurRelative()) {
3947
$("#editor").height(calcHeight());
40-
$(document).on("resize", function () {
48+
49+
function onresize() {
4150
$("#editor").height(calcHeight);
42-
});
51+
}
52+
53+
if (window.addEventListener) {
54+
window.addEventListener('resize', onresize, false);
55+
} else if (window.attachEvent) {
56+
window.attachEvent('resize', onresize);
57+
}
4358
}
4459
});
4560

0 commit comments

Comments
 (0)