Fixing canvas.nodeInsideList
[fnpeditor.git] / modules / rng / rng.js
index cd7122c..4189902 100644 (file)
@@ -50,23 +50,23 @@ return function(sandbox) {
     }\r
     \r
     var commands = {\r
     }\r
     \r
     var commands = {\r
-        highlightDocumentNode: function(wlxmlNode, origin) {\r
+        highlightDocumentNode: function(canvasNode, origin) {\r
             ['documentCanvas', 'nodeBreadCrumbs', 'nodeFamilyTree'].forEach(function(moduleName) {\r
                 if(!origin || moduleName != origin)\r
             ['documentCanvas', 'nodeBreadCrumbs', 'nodeFamilyTree'].forEach(function(moduleName) {\r
                 if(!origin || moduleName != origin)\r
-                    sandbox.getModule(moduleName).highlightNode(wlxmlNode)\r
+                    sandbox.getModule(moduleName).highlightNode(canvasNode)\r
             });\r
         },\r
             });\r
         },\r
-        dimDocumentNode: function(wlxmlNode, origin) {\r
+        dimDocumentNode: function(canvasNode, origin) {\r
             ['documentCanvas', 'nodeBreadCrumbs', 'nodeFamilyTree'].forEach(function(moduleName) {\r
                 if(!origin || moduleName != origin)\r
             ['documentCanvas', 'nodeBreadCrumbs', 'nodeFamilyTree'].forEach(function(moduleName) {\r
                 if(!origin || moduleName != origin)\r
-                    sandbox.getModule(moduleName).dimNode(wlxmlNode)\r
+                    sandbox.getModule(moduleName).dimNode(canvasNode)\r
             });\r
         },\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
+        selectNode: function(canvasNode, origin) {\r
+            sandbox.getModule('documentCanvas').selectNode(canvasNode);\r
+            sandbox.getModule('nodePane').setNode(canvasNode);\r
+            sandbox.getModule('nodeFamilyTree').setNode(canvasNode);\r
+            sandbox.getModule('nodeBreadCrumbs').setNode(canvasNode);\r
             \r
         },\r
         resetDocument: function(document, reason) {\r
             \r
         },\r
         resetDocument: function(document, reason) {\r
@@ -96,7 +96,7 @@ return function(sandbox) {
     \r
     views.visualEditing.setView('rightColumn', views.visualEditingSidebar.getAsView());\r
     addMainTab('Edytor', 'editor', views.visualEditing.getAsView());\r
     \r
     views.visualEditing.setView('rightColumn', views.visualEditingSidebar.getAsView());\r
     addMainTab('Edytor', 'editor', views.visualEditing.getAsView());\r
-    \r
+    addMainTab(gettext('Source'), 'sourceEditor',  '');\r
     addMainTab('Historia', 'history', views.diffLayout.getAsView());\r
     \r
     sandbox.getDOM().append(views.mainLayout.getAsView());\r
     addMainTab('Historia', 'history', views.diffLayout.getAsView());\r
     \r
     sandbox.getDOM().append(views.mainLayout.getAsView());\r
@@ -147,7 +147,7 @@ return function(sandbox) {
         },\r
         restoringStarted: function(event) {\r
             sandbox.getModule('mainBar').setCommandEnabled('save', false);\r
         },\r
         restoringStarted: function(event) {\r
             sandbox.getModule('mainBar').setCommandEnabled('save', false);\r
-            sandbox.getModule('indicator').showMessage(gettext('Restoring version ' + event.version + '...'));\r
+            sandbox.getModule('indicator').showMessage(gettext('Restoring version ') + event.version + '...');\r
         },\r
         historyItemAdded: function(item) {\r
             sandbox.getModule('documentHistory').addHistory([item], {animate: true});\r
         },\r
         historyItemAdded: function(item) {\r
             sandbox.getModule('documentHistory').addHistory([item], {animate: true});\r
@@ -158,12 +158,14 @@ return function(sandbox) {
         documentReverted: function(event) {\r
             commands.resetDocument(event.document, 'revert');\r
             sandbox.getModule('mainBar').setCommandEnabled('save', true);\r
         documentReverted: function(event) {\r
             commands.resetDocument(event.document, 'revert');\r
             sandbox.getModule('mainBar').setCommandEnabled('save', true);\r
-            sandbox.getModule('indicator').clearMessage({message:'Wersja ' + event.version + ' przywrócona'});\r
+            sandbox.getModule('indicator').clearMessage({message:'Wersja ' + event.reverted_version + ' przywrócona'});\r
+            sandbox.getModule('mainBar').setVersion(event.current_version);\r
         }\r
     }\r
     \r
     eventHandlers.mainBar = {\r
         ready: function() {\r
         }\r
     }\r
     \r
     eventHandlers.mainBar = {\r
         ready: function() {\r
+            sandbox.getModule('mainBar').setVersion(sandbox.getModule('data').getDocumentVersion());\r
             views.mainLayout.setView('topPanel', sandbox.getModule('mainBar').getView());\r
         },\r
         'cmd.save': function() {\r
             views.mainLayout.setView('topPanel', sandbox.getModule('mainBar').getView());\r
         },\r
         'cmd.save': function() {\r
@@ -189,20 +191,20 @@ return function(sandbox) {
             dirty.documentCanvas = false;\r
         },\r
         \r
             dirty.documentCanvas = false;\r
         },\r
         \r
-        nodeSelected: function(wlxmlNode) {\r
-            commands.selectNode(wlxmlNode);\r
+        nodeSelected: function(canvasNode) {\r
+            commands.selectNode(canvasNode);\r
         },\r
         \r
         contentChanged: function() {\r
             dirty.documentCanvas = true;\r
         },\r
         \r
         },\r
         \r
         contentChanged: function() {\r
             dirty.documentCanvas = true;\r
         },\r
         \r
-        nodeHovered: function(wlxmlNode) {\r
-            commands.highlightDocumentNode(wlxmlNode);\r
+        nodeHovered: function(canvasNode) {\r
+            commands.highlightDocumentNode(canvasNode);\r
         },\r
         \r
         },\r
         \r
-        nodeBlured: function(wlxmlNode) {\r
-            commands.dimDocumentNode(wlxmlNode);\r
+        nodeBlured: function(canvasNode) {\r
+            commands.dimDocumentNode(canvasNode);\r
         }\r
     };\r
 \r
         }\r
     };\r
 \r
@@ -233,14 +235,14 @@ return function(sandbox) {
         ready: function() {\r
             views.currentNodePaneLayout.appendView(sandbox.getModule('nodeFamilyTree').getView());\r
         },\r
         ready: function() {\r
             views.currentNodePaneLayout.appendView(sandbox.getModule('nodeFamilyTree').getView());\r
         },\r
-        nodeEntered: function(wlxmlNode) {\r
-            commands.highlightDocumentNode(wlxmlNode, 'nodeFamilyTree');\r
+        nodeEntered: function(canvasNode) {\r
+            commands.highlightDocumentNode(canvasNode, 'nodeFamilyTree');\r
         },\r
         },\r
-        nodeLeft: function(wlxmlNode) {\r
-            commands.dimDocumentNode(wlxmlNode, 'nodeFamilyTree');\r
+        nodeLeft: function(canvasNode) {\r
+            commands.dimDocumentNode(canvasNode, 'nodeFamilyTree');\r
         },\r
         },\r
-        nodeSelected: function(wlxmlNode) {\r
-            commands.selectNode(wlxmlNode);\r
+        nodeSelected: function(canvasNode) {\r
+            commands.selectNode(canvasNode);\r
         }\r
     };\r
     \r
         }\r
     };\r
     \r
@@ -252,11 +254,10 @@ return function(sandbox) {
             sandbox.getModule('documentCanvas').toggleGrid(toggle);\r
         },\r
         newNodeRequested: function(wlxmlTag, wlxmlClass) {\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
                 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
         }\r
     };\r
     \r
@@ -264,14 +265,14 @@ return function(sandbox) {
         ready: function() {\r
             views.visualEditing.setView('statusBar', sandbox.getModule('nodeBreadCrumbs').getView());\r
         },\r
         ready: function() {\r
             views.visualEditing.setView('statusBar', sandbox.getModule('nodeBreadCrumbs').getView());\r
         },\r
-        nodeHighlighted: function(wlxmlNode) {\r
-            commands.highlightDocumentNode(wlxmlNode, 'nodeBreadCrumbs');\r
+        nodeHighlighted: function(canvasNode) {\r
+            commands.highlightDocumentNode(canvasNode, 'nodeBreadCrumbs');\r
         },\r
         },\r
-        nodeDimmed: function(wlxmlNode) {\r
-            commands.dimDocumentNode(wlxmlNode, 'nodeBreadCrumbs');\r
+        nodeDimmed: function(canvasNode) {\r
+            commands.dimDocumentNode(canvasNode, 'nodeBreadCrumbs');\r
         },\r
         },\r
-        nodeSelected: function(wlxmlNode) {\r
-            commands.selectNode(wlxmlNode);\r
+        nodeSelected: function(canvasNode) {\r
+            commands.selectNode(canvasNode);\r
         }        \r
     }\r
     \r
         }        \r
     }\r
     \r
@@ -285,6 +286,9 @@ return function(sandbox) {
         },\r
         restoreVersion: function(event) {\r
             sandbox.getModule('data').restoreVersion(event);\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
         }\r
     }\r
     \r
         }\r
     }\r
     \r