+ var dirty = {\r
+ sourceEditor: false,\r
+ documentCanvas: false,\r
+ metadataEditor: 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
+ if(slug === 'sourceEditor') {\r
+ sandbox.getModule('data').commitDocument(sandbox.getModule('sourceEditor').getDocument(), '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
+ }\r
+ }\r
+ }\r
+ \r
+ var commands = {\r
+ highlightDocumentNode: function(wlxmlNode, origin) {\r
+ ['documentCanvas', 'nodeBreadCrumbs', 'nodeFamilyTree'].forEach(function(moduleName) {\r
+ if(!origin || moduleName != origin)\r
+ sandbox.getModule(moduleName).highlightNode(wlxmlNode)\r
+ });\r
+ },\r
+ dimDocumentNode: function(wlxmlNode, origin) {\r
+ ['documentCanvas', 'nodeBreadCrumbs', 'nodeFamilyTree'].forEach(function(moduleName) {\r
+ if(!origin || moduleName != origin)\r
+ sandbox.getModule(moduleName).dimNode(wlxmlNode)\r
+ });\r
+ },\r
+ selectNode: function(wlxmlNode, origin) {\r
+ sandbox.getModule('documentCanvas').selectNode(wlxmlNode);\r
+ sandbox.getModule('nodePane').setNode(wlxmlNode);\r
+ sandbox.getModule('nodeFamilyTree').setNode(wlxmlNode);\r
+ sandbox.getModule('nodeBreadCrumbs').setNode(wlxmlNode);\r
+ \r
+ }\r
+ }\r
+ \r
+\r