4 'libs/text!./template.html'], function($, _, template) {
8 return function(sandbox) {
12 var config = sandbox.getConfig(),
13 userName = config.user && config.user.name,
14 view = $(_.template(template)({
15 userName: userName || gettext('anonymous'),
16 documentScheduleUrl: config.documentScheduleUrl,
17 documentForkUrl: config.documentForkUrl,
18 documentPreviewUrl: config.documentPreviewMainUrl(data.revision),
19 documentGalleryUrl: config.documentGalleryUrl,
22 view.find('[data-cmd]').click(function(e) {
24 var target = $(e.target);
25 if(target.hasClass('disabled')) {
28 sandbox.publish('cmd.' + $(e.target).attr('data-cmd'));
32 start: function() { sandbox.publish('ready'); },
33 getView: function() {return view;},
34 setCommandEnabled: function(cmd, enabled) {
35 var trigger = view.find('[data-cmd='+cmd+']'),
36 disabledText = trigger.attr('data-disabled-text'),
37 originalContent = trigger.data('originalContent');
38 trigger.toggleClass('disabled', !enabled);
39 if(enabled && originalContent) {
40 trigger.html(originalContent);
41 trigger.removeData('originalContent');
43 if(!enabled && disabledText) {
44 trigger.data('originalContent', trigger.html());
45 trigger.text(disabledText);
48 setSummaryView: function(summaryView) {
49 view.find('.bottom').prepend(summaryView);