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

Commit

Permalink
make code folding setup less brittle
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Apr 3, 2014
1 parent 51cb669 commit 9987363
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions index.html
Expand Up @@ -174,19 +174,26 @@
if (this.selected == 'code') {
this.designToCode();
this.$.code.refresh();
this.async(function() {
this.$.code.focus();
// TODO(sorvell): we want to fold the <style> element.
// we should search for it rather than assume it's on the first line
// search looks like it needs a CodeMirror plugin.
this.$.code.mirror.foldCode(0);
this.$.code.mirror.execCommand('goLineDown');
});
this.async('prepareCode')
} else {
this.$.frame.style.display = 'none';
this.codeToDesign();
}
},
// TODO(sorvell): probably should factor this code setup to be elsewhere
prepareCode: function() {
this.$.code.focus();
// fold style tag
var cm = this.$.code.mirror;
var c = cm.getSearchCursor('<style>');
if (c.find()) {
var l = c.pos.from.line;
cm.foldCode(l);
cm.setSelection({line: l})
cm.execCommand('goLineDown');
cm.execCommand('goLineStart');
}
},
get html() {
return this.$.serializer.dumpElement(this.designer.$.canvas);
},
Expand Down

0 comments on commit 9987363

Please sign in to comment.