Skip to content

Commit

Permalink
start live update
Browse files Browse the repository at this point in the history
  • Loading branch information
gpoitch committed Aug 26, 2014
1 parent ccd33c4 commit 1e5b1cf
Show file tree
Hide file tree
Showing 11 changed files with 2,191 additions and 2,147 deletions.
21 changes: 15 additions & 6 deletions demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,35 @@

'use strict';

exports.ContentKitDemo = {
toggleCodePane: function(editor) {
var ContentKitDemo = exports.ContentKitDemo = {
toggleCodePane: function() {
if(document.body.className === 'code-pane-open') {
this.closeCodePane();
} else {
this.openCodePane(editor);
}
},

openCodePane: function(editor) {
this.syncCodePane(editor);
openCodePane: function() {
window.getSelection().removeAllRanges();
document.body.className = 'code-pane-open';
location.hash = 'code';
},

closeCodePane: function() {
window.getSelection().removeAllRanges();
document.body.className = '';
location.hash = '';
},

syncCodePane: function(editor) {
var codePaneJSON = document.getElementById('code-json');
var codePaneHTML = document.getElementById('code-html');
var json = editor.model;
var html = editor.compiler.render(json);
//var html = editor.compiler.render(json);

codePaneJSON.innerHTML = this.syntaxHighlight(json);
codePaneHTML.textContent = this.formatXML(html);
//codePaneHTML.textContent = this.formatXML(html);
},

formatXML: function(xml) {
Expand Down Expand Up @@ -91,4 +92,12 @@ exports.ContentKitDemo = {

};

// Initialize
if (editor) {
ContentKitDemo.syncCodePane(editor);
}
if (location.hash === '#code') {
ContentKitDemo.openCodePane();
}

}(this, document));
2 changes: 1 addition & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<header>
<h1 class="demo-title">ContentKit Editor</h1>
<div class="mode-buttons">
<button onclick="ContentKitDemo.toggleCodePane(editor)">Toggle Code</button>
<button onclick="ContentKitDemo.toggleCodePane()">Toggle Code</button>
</div>
</header>

Expand Down
Loading

0 comments on commit 1e5b1cf

Please sign in to comment.