First take on diffViewer
[fnpeditor.git] / modules / diffViewer / diffViewer.js
diff --git a/modules/diffViewer/diffViewer.js b/modules/diffViewer/diffViewer.js
new file mode 100644 (file)
index 0000000..254a19a
--- /dev/null
@@ -0,0 +1,35 @@
+define([\r
+'libs/jquery-1.9.1.min',\r
+'libs/underscore-min',\r
+'views/tabs/tabs',\r
+'libs/text!./diff.html'\r
+], function($, _, tabs, diffTemplateSrc) {\r
+\r
+'use strict';\r
+\r
+return function(sandbox) {\r
+    \r
+    var dom = $('<div>').addClass('rng-module-diffViewer');\r
+    var tabsView = (new tabs.View({position: 'right'})).render();\r
+    dom.append(tabsView.getAsView());\r
+    \r
+    var DiffView = function() {\r
+        this.dom = $(diffTemplateSrc)\r
+    }\r
+    DiffView.prototype.setTable = function(table) {\r
+        this.dom.append(table);\r
+    }\r
+    \r
+\r
+    return {\r
+        start: function() {sandbox.publish('ready');},\r
+        getView: function() {return dom;},\r
+        setDiff: function(diff) {\r
+            var diffView = new DiffView();\r
+            diffView.setTable(diff.table);\r
+            tabsView.addTab(diff.ver1 + '->' + diff.ver2, diff.ver1 + '-' + diff.ver2, diffView.dom);\r
+        }\r
+    };\r
+};\r
+\r
+});
\ No newline at end of file