X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/2a66af7ee0ee2d9943f58db45417b78764a43483..5fa477181f00d867a51d9f6e4fb1915522d725f5:/modules/data.js diff --git a/modules/data.js b/modules/data.js index 33c8df6..9e18512 100644 --- a/modules/data.js +++ b/modules/data.js @@ -1,4 +1,4 @@ -define(function() { +define(['./data/saveDialog'], function(saveDialog) { 'use strict'; @@ -66,14 +66,29 @@ return function(sandbox) { sandbox.publish('documentChanged', doc, reason); }, saveDocument: function() { - sandbox.publish('savingStarted'); - $.ajax({ - method: 'post', - url: '/' + gettext('editor') + '/' + document_id, - data: JSON.stringify({document:doc}), - success: function() {sandbox.publish('savingEnded', 'success'); reloadHistory();}, - error: function() {sandbox.publish('savingEnded', 'error');} + + var dialog = saveDialog.create(); + dialog.on('save', function(event) { + sandbox.publish('savingStarted'); + dialog.toggleButtons(false); + $.ajax({ + method: 'post', + url: '/' + gettext('editor') + '/' + document_id, + data: JSON.stringify({document:doc, description: event.data.description}), + success: function() { + event.success(); + sandbox.publish('savingEnded', 'success'); + reloadHistory(); + }, + error: function() {event.error(); sandbox.publish('savingEnded', 'error');} + }); + console.log('save'); + }); + dialog.on('cancel', function() { }); + dialog.show(); + + }, getHistory: function() { return history;