Layout informs its views on being shown
[fnpeditor.git] / modules / data / data.js
index 9b2b0cb..108f2ea 100644 (file)
@@ -6,6 +6,7 @@ return function(sandbox) {
 \r
     var doc = sandbox.getBootstrappedData().document;\r
     var document_id = sandbox.getBootstrappedData().document_id;\r
 \r
     var doc = sandbox.getBootstrappedData().document;\r
     var document_id = sandbox.getBootstrappedData().document_id;\r
+    var document_version = sandbox.getBootstrappedData().version\r
     var history = sandbox.getBootstrappedData().history;\r
 \r
     \r
     var history = sandbox.getBootstrappedData().history;\r
 \r
     \r
@@ -102,6 +103,29 @@ return function(sandbox) {
                     sandbox.publish('diffFetched', {table: data, ver1: ver1, ver2: ver2})\r
                 },\r
             });\r
                     sandbox.publish('diffFetched', {table: data, ver1: ver1, ver2: ver2})\r
                 },\r
             });\r
+        },\r
+        restoreVersion: function(options) {\r
+            if(options.version && options.description) {\r
+                sandbox.publish('restoringStarted', {version: options.version});\r
+                $.ajax({\r
+                    method: 'post',\r
+                    dataType: 'json',\r
+                    url: '/' + gettext('editor') + '/' + document_id + '/revert',\r
+                    data: JSON.stringify(options),\r
+                    success: function(data) {\r
+                        doc = data.document;\r
+                        document_version = data.version;\r
+                        reloadHistory();\r
+                        sandbox.publish('documentReverted', data);\r
+                    },\r
+                }); \r
+            }\r
+        },\r
+        getDocumentId: function() {\r
+            return document_id;\r
+        },\r
+        getDocumentVersion: function() {\r
+            return document_version;\r
         }\r
     }\r
 };\r
         }\r
     }\r
 };\r