views.mainTabs.addTab(title, slug, view);\r
}\r
\r
- function tabIsDirty(slug) {\r
- if(slug === 'editor' && (dirty.documentCanvas || dirty.metadataEditor))\r
- return true;\r
- if(slug === 'sourceEditor' && dirty.sourceEditor)\r
- return true;\r
- return false;\r
- }\r
- \r
var dirty = {\r
sourceEditor: false,\r
documentCanvas: false,\r
};\r
\r
var synchronizeTab = function(slug) {\r
+ function tabIsDirty(slug) {\r
+ if(slug === 'editor' && (dirty.documentCanvas || dirty.metadataEditor))\r
+ return true;\r
+ if(slug === 'sourceEditor' && dirty.sourceEditor)\r
+ return true;\r
+ return false;\r
+ }\r
+ \r
if(tabIsDirty(slug)) {\r
+ var reason, doc;\r
if(slug === 'sourceEditor') {\r
- sandbox.getModule('data').commitDocument(sandbox.getModule('sourceEditor').getDocument(), 'source_edit');\r
+ doc = sandbox.getModule('sourceEditor').getDocument();\r
+ reason = 'source_edit';\r
}\r
if(slug === 'editor') {\r
var doc = dirty.documentCanvas ? sandbox.getModule('documentCanvas').getDocument() : sandbox.getModule('data').getDocument();\r
if(dirty.metadataEditor) {\r
doc = sandbox.getModule('metadataEditor').attachMetadata(doc);\r
}\r
- sandbox.getModule('data').commitDocument(doc, 'edit');\r
+ reason = 'edit';\r
}\r
+ sandbox.getModule('data').commitDocument(doc, reason);\r
}\r
}\r
\r
ready: function() {\r
views.mainLayout.setView('mainView', views.mainTabs.getAsView());\r
\r
- _.each(['sourceEditor', 'documentCanvas', 'documentToolbar', 'nodePane', 'metadataEditor', 'nodeFamilyTree', 'nodeBreadCrumbs', 'mainBar', 'indicator'], function(moduleName) {\r
+ _.each(['sourceEditor', 'documentCanvas', 'documentToolbar', 'nodePane', 'metadataEditor', 'nodeFamilyTree', 'nodeBreadCrumbs', 'mainBar', 'indicator', 'documentHistory'], function(moduleName) {\r
sandbox.getModule(moduleName).start();\r
});\r
},\r
savingEnded: function(status) {\r
sandbox.getModule('mainBar').setCommandEnabled('save', true);\r
sandbox.getModule('indicator').clearMessage();\r
+ },\r
+ historyItemAdded: function(item) {\r
+ sandbox.getModule('documentHistory').addHistory([item], {animate: true});\r
}\r
}\r
\r
} \r
}\r
\r
+ eventHandlers.documentHistory = {\r
+ ready: function() {\r
+ sandbox.getModule('documentHistory').addHistory(sandbox.getModule('data').getHistory());\r
+ addMainTab('Historia', 'history', sandbox.getModule('documentHistory').getView());\r
+ }\r
+ }\r
+ \r
/* api */\r
\r
return {\r