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,
20 previewTutorial: sandbox.getTutorialItem('preview'),
21 attachmentsTutorial: sandbox.getTutorialItem('attachments'),
22 draftTutorial: sandbox.getTutorialItem('draft'),
23 saveTutorial: sandbox.getTutorialItem('save'),
24 mainPageTutorial: sandbox.getTutorialItem('mainpage'),
25 exitTutorial: sandbox.getTutorialItem('exit')
28 view.find('[data-cmd]').click(function(e) {
30 var target = $(e.target);
31 if(target.hasClass('disabled')) {
34 sandbox.publish('cmd.' + $(e.target).attr('data-cmd'));
38 start: function() { sandbox.publish('ready'); },
39 getView: function() {return view;},
40 setCommandEnabled: function(cmd, enabled) {
41 var trigger = view.find('[data-cmd='+cmd+']'),
42 disabledText = trigger.attr('data-disabled-text'),
43 originalContent = trigger.data('originalContent');
44 trigger.toggleClass('disabled', !enabled);
45 if(enabled && originalContent) {
46 trigger.html(originalContent);
47 trigger.removeData('originalContent');
49 if(!enabled && disabledText) {
50 trigger.data('originalContent', trigger.html());
51 trigger.text(disabledText);
54 setSummaryView: function(summaryView) {
55 view.find('.bottom').prepend(summaryView);