+ documentSet: function() {\r
+ dirty.documentCanvas = false;\r
+ },\r
+ \r
+ nodeSelected: function(wlxmlNode) {\r
+ commands.selectNode(wlxmlNode);\r
+ },\r
+ \r
+ contentChanged: function() {\r
+ dirty.documentCanvas = true;\r
+ },\r
+ \r
+ nodeHovered: function(wlxmlNode) {\r
+ commands.highlightDocumentNode(wlxmlNode);\r
+ },\r
+ \r
+ nodeBlured: function(wlxmlNode) {\r
+ commands.dimDocumentNode(wlxmlNode);\r
+ }\r
+ };\r
+\r
+ eventHandlers.nodePane = {\r
+ ready: function() {\r
+ views.currentNodePaneLayout.appendView(sandbox.getModule('nodePane').getView());\r
+ },\r
+ \r
+ nodeChanged: function(attr, value) {\r
+ sandbox.getModule('documentCanvas').modifyCurrentNode(attr, value);\r
+ }\r
+ };\r
+ \r
+ eventHandlers.metadataEditor = {\r
+ ready: function() {\r
+ sandbox.getModule('metadataEditor').setDocument(sandbox.getModule('data').getDocument());\r
+ views.visualEditingSidebar.addTab({icon: 'info-sign'}, 'metadataEditor', sandbox.getModule('metadataEditor').getView());\r
+ },\r
+ metadataChanged: function(metadata) {\r
+ dirty.metadataEditor = true;\r
+ },\r
+ metadataSet: function() {\r
+ dirty.metadataEditor = false;\r
+ },\r
+ };\r
+ \r
+ eventHandlers.nodeFamilyTree = {\r
+ ready: function() {\r
+ views.currentNodePaneLayout.appendView(sandbox.getModule('nodeFamilyTree').getView());\r
+ },\r
+ nodeEntered: function(wlxmlNode) {\r
+ commands.highlightDocumentNode(wlxmlNode, 'nodeFamilyTree');\r
+ },\r
+ nodeLeft: function(wlxmlNode) {\r
+ commands.dimDocumentNode(wlxmlNode, 'nodeFamilyTree');\r
+ },\r
+ nodeSelected: function(wlxmlNode) {\r
+ commands.selectNode(wlxmlNode);\r
+ }\r
+ };\r
+ \r
+ eventHandlers.documentToolbar = {\r
+ ready: function() {\r
+ views.visualEditing.setView('toolbar', sandbox.getModule('documentToolbar').getView());\r
+ },\r
+ toggleGrid: function(toggle) {\r
+ sandbox.getModule('documentCanvas').toggleGrid(toggle);\r
+ },\r
+ newNodeRequested: function(wlxmlTag, wlxmlClass) {\r
+ if(window.getSelection().isCollapsed) {\r
+ sandbox.getModule('documentCanvas').insertNewNode(wlxmlTag, wlxmlClass);\r
+ } else {\r
+ sandbox.getModule('documentCanvas').wrapSelectionWithNewNode(wlxmlTag, wlxmlClass);\r
+ }\r
+ },\r
+ command: function(cmd, meta) {\r
+ sandbox.getModule('documentCanvas').command(cmd, meta);\r
+ }\r
+ };\r
+ \r
+ eventHandlers.nodeBreadCrumbs = {\r
+ ready: function() {\r
+ views.visualEditing.setView('statusBar', sandbox.getModule('nodeBreadCrumbs').getView());\r
+ },\r
+ nodeHighlighted: function(wlxmlNode) {\r
+ commands.highlightDocumentNode(wlxmlNode, 'nodeBreadCrumbs');\r
+ },\r
+ nodeDimmed: function(wlxmlNode) {\r
+ commands.dimDocumentNode(wlxmlNode, 'nodeBreadCrumbs');\r
+ },\r
+ nodeSelected: function(wlxmlNode) {\r
+ commands.selectNode(wlxmlNode);\r
+ } \r
+ }\r
+ \r
+ eventHandlers.documentHistory = {\r
+ ready: function() {\r
+ sandbox.getModule('documentHistory').addHistory(sandbox.getModule('data').getHistory());\r
+ views.diffLayout.setView('left', sandbox.getModule('documentHistory').getView());\r
+ },\r
+ compare: function(ver1, ver2) {\r
+ sandbox.getModule('data').fetchDiff(ver1, ver2);\r
+ },\r
+ restoreVersion: function(event) {\r
+ sandbox.getModule('data').restoreVersion(event);\r
+ },\r
+ displayVersion: function(event) {\r
+ window.open('/' + gettext('editor') + '/' + sandbox.getModule('data').getDocumentId() + '?version=' + event.version, _.uniqueId());\r