|
|
@@ -18,6 +18,7 @@ $(document).ready(function() {
|
|
|
var $detailsExmp = $('#details-example');
|
|
|
var $window = $(window);
|
|
|
var activeMode = 'html';
|
|
|
+ var currentFileIdx;
|
|
|
|
|
|
var editor;
|
|
|
var editorSession;
|
|
|
@@ -61,6 +62,10 @@ $(document).ready(function() {
|
|
|
if(_ws.files.length > 0) {
|
|
|
editorSession.setMode("ace/mode/html");
|
|
|
var firstHtml = _ws.files.find(f => (f.type === 'html'));
|
|
|
+ currentFileIdx = _ws.files.indexOf(firstHtml);
|
|
|
+ _ws.ui.tabs.$elem
|
|
|
+ .find('li:eq(' + currentFileIdx + ')')
|
|
|
+ .addClass('bold');
|
|
|
editorSession.setValue(firstHtml.content);
|
|
|
}
|
|
|
}
|
|
|
@@ -82,6 +87,13 @@ $(document).ready(function() {
|
|
|
editorSession.setMode("ace/mode/" + mapTypes[type]);
|
|
|
var name = clickedItem.html();
|
|
|
var file = _ws.files.find(f => (f.name === name));
|
|
|
+ _ws.ui.tabs.$elem
|
|
|
+ .find('li:eq(' + currentFileIdx + ')')
|
|
|
+ .removeClass('bold');
|
|
|
+ currentFileIdx = _ws.files.indexOf(file);
|
|
|
+ _ws.ui.tabs.$elem
|
|
|
+ .find('li:eq(' + currentFileIdx + ')')
|
|
|
+ .addClass('bold');
|
|
|
editorSession.setValue(file.content);
|
|
|
// saveToLocalStorage();
|
|
|
// var mode = $(this).prop('id').substr(5);
|
|
|
@@ -90,16 +102,43 @@ $(document).ready(function() {
|
|
|
}
|
|
|
|
|
|
|
|
|
- initEditor();
|
|
|
+ _ws.makeView('tabs', {
|
|
|
+ setCurrentFile: function(name) {
|
|
|
|
|
|
+ },
|
|
|
+ getCurrentTab: function() {
|
|
|
|
|
|
- _ws.makeView('tabs', {
|
|
|
+ },
|
|
|
events: {
|
|
|
'click li[data-type]': onTabClicked
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+ initEditor();
|
|
|
+
|
|
|
+
|
|
|
_ws.makeView('editor', {
|
|
|
+ aceEditor: editor,
|
|
|
+ aceSession: editor.getSession(),
|
|
|
+
|
|
|
+ init: function() {
|
|
|
+ this.aceSession.on('change', this.editorContentChanged);
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * React to changes in editor by saving a copy
|
|
|
+ */
|
|
|
+ editorContentChanged: function() {
|
|
|
+ console.log('editorContent changed')
|
|
|
+ // if(saveTimeout1 || saveTimeout2) {
|
|
|
+ // clearTimeout(saveTimeout1);
|
|
|
+ // clearTimeout(saveTimeout2);
|
|
|
+ // }
|
|
|
+ // saveTimeout1 = setTimeout(saveToLocalStorage, 500);
|
|
|
+ // // saveTimeout2 = setTimeout(saveChanges, 1000);
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
render: function() {
|
|
|
console.log('render editor', this);
|
|
|
setDefaultEditorContent();
|
|
|
@@ -134,20 +173,7 @@ $(document).ready(function() {
|
|
|
// }
|
|
|
|
|
|
|
|
|
- // /**
|
|
|
- // * React to changes in editor by saving a copy
|
|
|
- // */
|
|
|
- // function editorContentChanged() {
|
|
|
- // // console.log('editorContent changed')
|
|
|
- // if(saveTimeout1 || saveTimeout2) {
|
|
|
- // clearTimeout(saveTimeout1);
|
|
|
- // clearTimeout(saveTimeout2);
|
|
|
- // }
|
|
|
- // saveTimeout1 = setTimeout(saveToLocalStorage, 500);
|
|
|
- // // saveTimeout2 = setTimeout(saveChanges, 1000);
|
|
|
- // }
|
|
|
|
|
|
- // editor.getSession().on('change', editorContentChanged);
|
|
|
|
|
|
|
|
|
// function revertEditor() {
|