Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Commit

Permalink
Don't mess with CSS, instead use API to set size
Browse files Browse the repository at this point in the history
Instead of detecting & altering stylesheets, run through CM instances
and set the size
Needs to be done via setTimeout to avoid timing issues
  • Loading branch information
mattpass committed Sep 13, 2012
1 parent 2c1e032 commit 6cf1def
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions lib/coder.js
Expand Up @@ -70,7 +70,7 @@ var ICEcoder = {

// Set our layout according to the browser size
setLayout: function(dontSetEditor) {
var winW, winH, headerH, footerH, accountH, tabsBarH, findBarH, cMCSS;
var winW, winH, headerH, footerH, accountH, tabsBarH, findBarH, cM;

// Determin width & height available
winW = window.innerWidth ? window.innerWidth : document.body.clientWidth;
Expand All @@ -88,17 +88,12 @@ var ICEcoder = {
if (!dontSetEditor) {
this.editor.style.width = ICEcoder.content.style.width = (winW-this.filesW) + "px";
ICEcoder.content.style.height = (winH-headerH-footerH-tabsBarH-findBarH) + "px";

// Resize the CodeMirror instances to match the window size
cMCSS = ICEcoder.content.contentWindow.document.styleSheets[2];
if (cMCSS) {
strCSS = cMCSS.rules ? 'rules' : 'cssRules';
for(var i=0;i<cMCSS[strCSS].length;i++) {
if(cMCSS[strCSS][i].selectorText==".CodeMirror-scroll") {
cMCSS[strCSS][i].style['height'] = ICEcoder.content.style.height;
}
}
}
setTimeout(function(){
for (i=0;i<top.ICEcoder.openFiles.length;i++) {
top.ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[i]].setSize("100%",top.ICEcoder.content.style.height);
}},4);
}
},

Expand Down

0 comments on commit 6cf1def

Please sign in to comment.