Moving data.js to its own module directory
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 13 Jun 2013 13:36:46 +0000 (15:36 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 13 Jun 2013 13:36:46 +0000 (15:36 +0200)
modules.js
modules/data.js [deleted file]
modules/data/data.js [new file with mode: 0644]

index 6c514b5..990905b 100644 (file)
@@ -7,7 +7,7 @@ define(function(require) {
     'use strict';\r
     \r
     return {\r
-        data: require('modules/data'),\r
+        data: require('modules/data/data'),\r
         rng: require('modules/rng/rng'),\r
         mainBar: require('modules/mainBar/mainBar'),\r
         indicator: require('modules/indicator/indicator'),\r
diff --git a/modules/data.js b/modules/data.js
deleted file mode 100644 (file)
index 9e18512..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-define(['./data/saveDialog'], function(saveDialog) {\r
-\r
-'use strict';\r
-\r
-return function(sandbox) {\r
-\r
-    var doc = sandbox.getBootstrappedData().document;\r
-    var document_id = sandbox.getBootstrappedData().document_id;\r
-    var history = sandbox.getBootstrappedData().history;\r
-\r
-    \r
-    if(doc === '') {\r
-        doc = '<section\n\\r
-        xmlns="http://nowoczesnapolska.org.pl/sst#"\n\\r
-        xmlns:xlink="http://www.w3.org/1999/xlink"\n\\r
-        xmlns:dc="http://purl.org/dc/elements/1.1/"\n\\r
-        xmlns:dcterms="http://purl.org/dc/terms/"\n\\r
-    >\n\\r
-        <metadata>\n\\r
-        </metadata>\n\\r
-        <div class="p"></div>\n\\r
-    </section>';\r
-    }\r
-    \r
-    \r
-    function readCookie(name) {\r
-        var nameEQ = escape(name) + "=";\r
-        var ca = document.cookie.split(';');\r
-        for (var i = 0; i < ca.length; i++) {\r
-            var c = ca[i];\r
-            while (c.charAt(0) == ' ') c = c.substring(1, c.length);\r
-            if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length, c.length));\r
-        }\r
-        return null;\r
-    }\r
-    \r
-    $.ajaxSetup({\r
-        crossDomain: false,\r
-        beforeSend: function(xhr, settings) {\r
-            if (!(/^(GET|HEAD|OPTIONS|TRACE)$/.test(settings.type))) {\r
-                xhr.setRequestHeader("X-CSRFToken", readCookie('csrftoken'));\r
-            }\r
-        }\r
-    });\r
-    \r
-    var reloadHistory = function() {\r
-        $.ajax({\r
-            method: 'get',\r
-            url: '/' + gettext('editor') + '/' + document_id + '/history',\r
-            success: function(data) {\r
-                history = data; \r
-                sandbox.publish('historyItemAdded', data.slice(-1)[0]);\r
-            },\r
-        });\r
-    }\r
-    \r
-    return {\r
-        start: function() {\r
-            sandbox.publish('ready');\r
-        },\r
-        getDocument: function() {\r
-            return doc;\r
-        },\r
-        commitDocument: function(newDocument, reason) {\r
-            doc = newDocument;\r
-            sandbox.publish('documentChanged', doc, reason);\r
-        },\r
-        saveDocument: function() {\r
-\r
-            var dialog = saveDialog.create();\r
-            dialog.on('save', function(event) {\r
-                sandbox.publish('savingStarted');\r
-                dialog.toggleButtons(false);\r
-                $.ajax({\r
-                    method: 'post',\r
-                    url: '/' + gettext('editor') + '/' + document_id,\r
-                    data: JSON.stringify({document:doc, description: event.data.description}),\r
-                    success: function() {\r
-                        event.success();\r
-                        sandbox.publish('savingEnded', 'success');\r
-                        reloadHistory();\r
-                    },\r
-                    error: function() {event.error(); sandbox.publish('savingEnded', 'error');}\r
-                });\r
-                console.log('save');\r
-            });\r
-            dialog.on('cancel', function() {\r
-            });\r
-            dialog.show();\r
-            \r
-\r
-        },\r
-        getHistory: function() {\r
-            return history;\r
-        }\r
-    }\r
-};\r
-\r
-});
\ No newline at end of file
diff --git a/modules/data/data.js b/modules/data/data.js
new file mode 100644 (file)
index 0000000..22c77fe
--- /dev/null
@@ -0,0 +1,99 @@
+define(['./saveDialog'], function(saveDialog) {\r
+\r
+'use strict';\r
+\r
+return function(sandbox) {\r
+\r
+    var doc = sandbox.getBootstrappedData().document;\r
+    var document_id = sandbox.getBootstrappedData().document_id;\r
+    var history = sandbox.getBootstrappedData().history;\r
+\r
+    \r
+    if(doc === '') {\r
+        doc = '<section\n\\r
+        xmlns="http://nowoczesnapolska.org.pl/sst#"\n\\r
+        xmlns:xlink="http://www.w3.org/1999/xlink"\n\\r
+        xmlns:dc="http://purl.org/dc/elements/1.1/"\n\\r
+        xmlns:dcterms="http://purl.org/dc/terms/"\n\\r
+    >\n\\r
+        <metadata>\n\\r
+        </metadata>\n\\r
+        <div class="p"></div>\n\\r
+    </section>';\r
+    }\r
+    \r
+    \r
+    function readCookie(name) {\r
+        var nameEQ = escape(name) + "=";\r
+        var ca = document.cookie.split(';');\r
+        for (var i = 0; i < ca.length; i++) {\r
+            var c = ca[i];\r
+            while (c.charAt(0) == ' ') c = c.substring(1, c.length);\r
+            if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length, c.length));\r
+        }\r
+        return null;\r
+    }\r
+    \r
+    $.ajaxSetup({\r
+        crossDomain: false,\r
+        beforeSend: function(xhr, settings) {\r
+            if (!(/^(GET|HEAD|OPTIONS|TRACE)$/.test(settings.type))) {\r
+                xhr.setRequestHeader("X-CSRFToken", readCookie('csrftoken'));\r
+            }\r
+        }\r
+    });\r
+    \r
+    var reloadHistory = function() {\r
+        $.ajax({\r
+            method: 'get',\r
+            url: '/' + gettext('editor') + '/' + document_id + '/history',\r
+            success: function(data) {\r
+                history = data; \r
+                sandbox.publish('historyItemAdded', data.slice(-1)[0]);\r
+            },\r
+        });\r
+    }\r
+    \r
+    return {\r
+        start: function() {\r
+            sandbox.publish('ready');\r
+        },\r
+        getDocument: function() {\r
+            return doc;\r
+        },\r
+        commitDocument: function(newDocument, reason) {\r
+            doc = newDocument;\r
+            sandbox.publish('documentChanged', doc, reason);\r
+        },\r
+        saveDocument: function() {\r
+\r
+            var dialog = saveDialog.create();\r
+            dialog.on('save', function(event) {\r
+                sandbox.publish('savingStarted');\r
+                dialog.toggleButtons(false);\r
+                $.ajax({\r
+                    method: 'post',\r
+                    url: '/' + gettext('editor') + '/' + document_id,\r
+                    data: JSON.stringify({document:doc, description: event.data.description}),\r
+                    success: function() {\r
+                        event.success();\r
+                        sandbox.publish('savingEnded', 'success');\r
+                        reloadHistory();\r
+                    },\r
+                    error: function() {event.error(); sandbox.publish('savingEnded', 'error');}\r
+                });\r
+                console.log('save');\r
+            });\r
+            dialog.on('cancel', function() {\r
+            });\r
+            dialog.show();\r
+            \r
+\r
+        },\r
+        getHistory: function() {\r
+            return history;\r
+        }\r
+    }\r
+};\r
+\r
+});
\ No newline at end of file