editor: refactoring the way document properties are kept
[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         sandbox.publish('cmd.' + $(e.target).attr('data-cmd'));
21     });
22
23     return {
24         start: function() { sandbox.publish('ready'); },
25         getView: function() {return view;},
26         setCommandEnabled: function(cmd, enabled) {
27             view.find('[data-cmd='+cmd+']').toggleClass('disabled', !enabled);
28         },
29         setVersion: function(version) {
30             view.find('.version').text(version);
31         }
32     };
33
34 };
35
36 });