From 5961ba42ff4f3c3410e0400d7582b43b3067fc27 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Fri, 21 Mar 2014 14:21:57 +0100 Subject: [PATCH] editor: disable drop draft link when there is no draft loaded --- src/editor/modules/mainBar/mainBar.js | 4 ++++ src/editor/modules/mainBar/mainBar.less | 9 +++++++++ src/editor/modules/rng/rng.js | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/src/editor/modules/mainBar/mainBar.js b/src/editor/modules/mainBar/mainBar.js index 8658c27..04e7c9e 100644 --- a/src/editor/modules/mainBar/mainBar.js +++ b/src/editor/modules/mainBar/mainBar.js @@ -17,6 +17,10 @@ return function(sandbox) { view.find('[data-cmd]').click(function(e) { e.preventDefault(); + var target = $(e.target); + if(target.hasClass('disabled')) { + return; + } sandbox.publish('cmd.' + $(e.target).attr('data-cmd')); }); diff --git a/src/editor/modules/mainBar/mainBar.less b/src/editor/modules/mainBar/mainBar.less index 32f18ec..8fb99a5 100644 --- a/src/editor/modules/mainBar/mainBar.less +++ b/src/editor/modules/mainBar/mainBar.less @@ -30,4 +30,13 @@ .bottom { margin-top: 8px; } + + a.disabled { + color: @gray; + + &:hover { + text-decoration: none; + cursor: default; + } + } } \ No newline at end of file diff --git a/src/editor/modules/rng/rng.js b/src/editor/modules/rng/rng.js index a00bf3c..c1382fd 100644 --- a/src/editor/modules/rng/rng.js +++ b/src/editor/modules/rng/rng.js @@ -95,6 +95,8 @@ return function(sandbox) { documentSummary.setDraftField(usingDraft ? (draftTimestamp || '???') : '-'); views.currentNodePaneLayout.appendView(documentSummary.dom); + sandbox.getModule('mainBar').setCommandEnabled('drop-draft', usingDraft); + _.each(['sourceEditor', 'documentCanvas', 'documentToolbar', 'nodePane', 'metadataEditor', 'nodeFamilyTree', 'nodeBreadCrumbs', 'mainBar', 'indicator', 'documentHistory', 'diffViewer'], function(moduleName) { sandbox.getModule(moduleName).start(); }); @@ -110,6 +112,7 @@ return function(sandbox) { }, draftDropped: function() { documentSummary.setDraftField('-'); + sandbox.getModule('mainBar').setCommandEnabled('drop-draft', false); }, savingStarted: function(what) { var msg = { @@ -132,9 +135,11 @@ return function(sandbox) { sandbox.getModule('mainBar').setVersion(data.version); documentSummary.render(data); documentSummary.setDraftField('-'); + sandbox.getModule('mainBar').setCommandEnabled('drop-draft', false); } if(what === 'local') { documentSummary.setDraftField(data.timestamp); + sandbox.getModule('mainBar').setCommandEnabled('drop-draft', true); } }, restoringStarted: function(event) { -- 2.20.1