From 635d44e05306b5bd5f5238a31a122528fee1e779 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Thu, 20 Mar 2014 11:37:37 +0100 Subject: [PATCH 1/1] editor: dropping a working draft --- src/editor/modules/data/data.js | 6 ++++++ src/editor/modules/mainBar/mainBar.js | 2 +- src/editor/modules/mainBar/template.html | 1 + src/editor/modules/rng/rng.js | 3 +++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/editor/modules/data/data.js b/src/editor/modules/data/data.js index 7488390..ef1c87d 100644 --- a/src/editor/modules/data/data.js +++ b/src/editor/modules/data/data.js @@ -238,6 +238,12 @@ return function(sandbox) { }); dialog.show(); }, + dropDraft: function() { + logger.debug('Dropping a draft...'); + wlxmlDocument.loadXML(sandbox.getBootstrappedData().document); + draftDirty = false; + logger.debug('Draft dropped'); + }, getDocumentId: function() { return document_id; }, diff --git a/src/editor/modules/mainBar/mainBar.js b/src/editor/modules/mainBar/mainBar.js index ecf6812..e2e09c3 100644 --- a/src/editor/modules/mainBar/mainBar.js +++ b/src/editor/modules/mainBar/mainBar.js @@ -8,7 +8,7 @@ define([ return function(sandbox) { var view = $(_.template(template)()); - view.find('button').click(function(e) { + view.find('[data-cmd]').click(function(e) { e.preventDefault(); sandbox.publish('cmd.' + $(e.target).attr('data-cmd')); }); diff --git a/src/editor/modules/mainBar/template.html b/src/editor/modules/mainBar/template.html index e3c971b..eeecd62 100644 --- a/src/editor/modules/mainBar/template.html +++ b/src/editor/modules/mainBar/template.html @@ -1,6 +1,7 @@
diff --git a/src/editor/modules/rng/rng.js b/src/editor/modules/rng/rng.js index bed3e86..78145a5 100644 --- a/src/editor/modules/rng/rng.js +++ b/src/editor/modules/rng/rng.js @@ -151,6 +151,9 @@ return function(sandbox) { sourceEditor.commitChanges(); } sandbox.getModule('data').saveDocument(); + }, + 'cmd.drop-draft': function() { + sandbox.getModule('data').dropDraft(); } }; -- 2.20.1