data: require('modules/data/data'),
rng: require('modules/rng/rng'),
mainBar: require('modules/mainBar/mainBar'),
+ statusBar: require('modules/statusBar/statusBar'),
indicator: require('modules/indicator/indicator'),
sourceEditor: require('modules/sourceEditor/sourceEditor'),
sandbox.getModule('mainBar').setCommandEnabled('drop-draft', usingDraft);
sandbox.getModule('mainBar').setCommandEnabled('save', usingDraft);
- _.each(['sourceEditor', 'documentCanvas', 'documentToolbar', 'metadataEditor', 'nodeBreadCrumbs', 'mainBar', 'indicator', 'documentHistory', 'diffViewer'], function(moduleName) {
+ _.each(['sourceEditor', 'documentCanvas', 'documentToolbar', 'metadataEditor', 'nodeBreadCrumbs', 'mainBar', 'indicator', 'documentHistory', 'diffViewer', 'statusBar'], function(moduleName) {
sandbox.getModule(moduleName).start();
});
}
};
+ eventHandlers.statusBar = {
+ ready: function() {
+ views.mainLayout.setView('bottomPanel', sandbox.getModule('statusBar').getView());
+ }
+ };
+
+ eventHandlers.__all__ = {
+ actionHovered: function(action) {
+ sandbox.getModule('statusBar').showAction(action);
+ },
+ actionOff: function() {
+ sandbox.getModule('statusBar').clearAction();
+ }
+ };
+
window.addEventListener('beforeunload', function(event) {
var txt = gettext('Do you really want to exit?');
if(documentIsDirty) {
if(eventHandlers[moduleName] && eventHandlers[moduleName][eventName]) {
logger.debug('Handling event ' + eventRepr);
eventHandlers[moduleName][eventName].apply(eventHandlers, args);
- } else {
- logger.warning('No event handler for ' + eventRepr);
+ return;
+ }
+
+ if(eventHandlers.__all__[eventName]) {
+ logger.debug('Handling event ' + eventRepr);
+ eventHandlers.__all__[eventName].apply(eventHandlers.__all__, args);
+ return;
}
+ logger.warning('No event handler for ' + eventRepr);
}
};
};
--- /dev/null
+define(function(require) {
+
+'use strict';
+/* globals gettext */
+
+var $ = require('libs/jquery'),
+ template = require('libs/text!modules/statusBar/statusBar.html'),
+ logging = require('fnpjs/logging/logging');
+
+var logger = logging.getLogger('statusBar');
+
+return function(sandbox){
+
+ var view = $(template);
+
+ return {
+ start: function() {
+ return sandbox.publish('ready');
+ },
+ getView: function() {
+ return view;
+ },
+ showAction: function(action) {
+ var state = action.getState(),
+ description = state.description;
+ if(!description) {
+ description = state.allowed ? gettext('Undescribed action') : gettext('Action not allowed');
+ logger.info('Undescribed action: ' + action.name);
+ }
+ view.text(description);
+ if(!state.allowed) {
+ view.prepend('<span class="badge badge-warning" style="margin-right: 5px">!</span>');
+ }
+ },
+ clearAction: function() {
+ view.text('');
+ }
+ };
+
+};
+
+});
\ No newline at end of file