editor: disable drop draft link when there is no draft loaded
[fnpeditor.git] / src / editor / modules / mainBar / mainBar.js
1 define([
2 'libs/jquery',
3 'libs/underscore',
4 'libs/text!./template.html'], function($, _, template) {
5
6 'use strict';
7
8 return function(sandbox) {
9
10     /* globals gettext*/
11
12     var config = sandbox.getConfig(),
13         userName = config.user && config.user.name,
14         view = $(_.template(template)({
15             userName: userName || gettext('anonymous')
16         }));
17
18     view.find('[data-cmd]').click(function(e) {
19         e.preventDefault();
20         var target = $(e.target);
21         if(target.hasClass('disabled')) {
22             return;
23         }
24         sandbox.publish('cmd.' + $(e.target).attr('data-cmd'));
25     });
26
27     return {
28         start: function() { sandbox.publish('ready'); },
29         getView: function() {return view;},
30         setCommandEnabled: function(cmd, enabled) {
31             view.find('[data-cmd='+cmd+']').toggleClass('disabled', !enabled);
32         },
33         setVersion: function(version) {
34             view.find('.version').text(version);
35         }
36     };
37
38 };
39
40 });