|
@@ -170,6 +170,11 @@ $(document).ready(function() {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
_ws.makeView('sandbox-iframe', {
|
|
_ws.makeView('sandbox-iframe', {
|
|
|
|
|
+ reload: function() {
|
|
|
|
|
+ var src = this.$elem.prop('src');
|
|
|
|
|
+ this.$elem.prop('src', '/empty.html');
|
|
|
|
|
+ this.$elem.prop('src', src);
|
|
|
|
|
+ },
|
|
|
render: function(src) {
|
|
render: function(src) {
|
|
|
this.$elem.prop('src', src);
|
|
this.$elem.prop('src', src);
|
|
|
}
|
|
}
|
|
@@ -206,16 +211,28 @@ $(document).ready(function() {
|
|
|
function onSaveChanges() {
|
|
function onSaveChanges() {
|
|
|
// console.log('Saving', this.file, editorSession.getValue())
|
|
// console.log('Saving', this.file, editorSession.getValue())
|
|
|
var filename = this.file.name;
|
|
var filename = this.file.name;
|
|
|
|
|
+ // var payload = editorStorage.getSources();
|
|
|
var payload = {
|
|
var payload = {
|
|
|
content: editorSession.getValue()
|
|
content: editorSession.getValue()
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
|
|
+ // Submit the new file content to server
|
|
|
rp.put('/' + _ws.repo.path + '/examples/' + _ws.example.slug + '/files/' + filename, payload)
|
|
rp.put('/' + _ws.repo.path + '/examples/' + _ws.example.slug + '/files/' + filename, payload)
|
|
|
- // var payload = editorStorage.getSources();
|
|
|
|
|
- // rp.put('/examples/' + currentHash, payload)
|
|
|
|
|
.then(function(updatedFile) {
|
|
.then(function(updatedFile) {
|
|
|
- // console.log(updatedFile);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // notify
|
|
|
_ws.notify('success', "Fichier " + filename + " sauvegardé !");
|
|
_ws.notify('success', "Fichier " + filename + " sauvegardé !");
|
|
|
|
|
+
|
|
|
|
|
+ // remove the dirty state on current editor tab
|
|
|
_ws.ui.tabs.getActiveTab().removeClass('dirty');
|
|
_ws.ui.tabs.getActiveTab().removeClass('dirty');
|
|
|
|
|
+
|
|
|
|
|
+ // replace content with the updated one in _ws.files
|
|
|
|
|
+ var originalFile = _ws.files.find(f => (f.name === updatedFile.name));
|
|
|
|
|
+ var index = _ws.files.indexOf(originalFile);
|
|
|
|
|
+ _ws.files[index].content = updatedFile.content;
|
|
|
|
|
+
|
|
|
|
|
+ // reload sandbox iframe
|
|
|
|
|
+ _ws.ui.sandboxIframe.reload();
|
|
|
})
|
|
})
|
|
|
.catch(function(err) {
|
|
.catch(function(err) {
|
|
|
// console.error(err);
|
|
// console.error(err);
|