update "scrollbarWidth()" function to work in IE

This commit is contained in:
Fabian Jakobs 2010-04-23 15:22:40 +02:00
commit b5679cb6b6

View file

@ -120,20 +120,35 @@ ace.computedStyle = function(element, style) {
} }
}; };
ace.scrollbarWidth = function(parent) { ace.scrollbarWidth = function() {
var el = document.createElement("div");
var style = el.style; var inner = document.createElement('p');
inner.style.width = "100%";
inner.style.height = "200px";
var outer = document.createElement("div");
var style = outer.style;
style.position = "absolute"; style.position = "absolute";
style.left = "-10000px"; style.left = "-10000px";
style.overflow = "hidden";
style.width = "200px";
style.height = "150px";
outer.appendChild(inner);
document.body.appendChild(outer);
var noScrollbar = inner.offsetWidth;
style.overflow = "scroll"; style.overflow = "scroll";
style.width = "100px"; var withScrollbar = inner.offsetWidth;
(parent || document.body).appendChild(el); if (noScrollbar == withScrollbar) {
var width = el.offsetWidth - el.clientWidth; withScrollbar = outer.clientWidth;
document.body.removeChild(el); }
return width; document.body.removeChild(outer);
return noScrollbar-withScrollbar;
}; };
ace.stringReverse = function(string) { ace.stringReverse = function(string) {