tutorial in editor (mechanics only)
[fnpeditor.git] / src / editor / modules / statusBar / statusBar.js
1 define(function(require) {
2     
3 'use strict';
4 /* globals gettext */
5
6 var $ = require('libs/jquery'),
7     template = require('libs/text!modules/statusBar/statusBar.html'),
8     logging = require('fnpjs/logging/logging');
9
10 var logger = logging.getLogger('statusBar');
11
12 return function(sandbox){
13
14     var view = $(template);
15
16     return {
17         start: function() {
18             return sandbox.publish('ready');
19         },
20         getView: function() {
21             return view;
22         },
23         showAction: function(action) {
24             var state = action.getState(),
25                 description;
26             
27             if(!state) {
28                 description = gettext('error :(');
29                 logger.error('Got undefined action state: ' + action.name);
30             } else {
31                 description = state.description;
32                 if(!description) {
33                     description = state.allowed ? gettext('Undescribed action') : gettext('Action not allowed');
34                     logger.info('Undescribed action: ' + action.name);
35                 }
36             }
37
38             view.text(description);
39             if(!state.allowed) {
40                 view.prepend('<span class="badge badge-warning" style="margin-right: 5px">!</span>');
41             }
42         },
43         clearAction: function() {
44             view.text('');
45         }
46     };
47
48 };
49
50 });