canvas manager wip - splitting node
[fnpeditor.git] / modules / diffViewer / diffViewer.js
1 define([\r
2 'libs/jquery-1.9.1.min',\r
3 'libs/underscore-min',\r
4 'views/tabs/tabs',\r
5 'libs/text!./diff.html'\r
6 ], function($, _, tabs, diffTemplateSrc) {\r
7 \r
8 'use strict';\r
9 \r
10 return function(sandbox) {\r
11     \r
12     var dom = $('<div>').addClass('rng-module-diffViewer');\r
13     var tabsView = (new tabs.View({position: 'right'})).render();\r
14     dom.append(tabsView.getAsView());\r
15     \r
16     var DiffView = function() {\r
17         this.dom = $(diffTemplateSrc)\r
18     }\r
19     DiffView.prototype.setTable = function(table) {\r
20         this.dom.append(table);\r
21     }\r
22     \r
23 \r
24     return {\r
25         start: function() {sandbox.publish('ready');},\r
26         getView: function() {return dom;},\r
27         setDiff: function(diff) {\r
28             var diffView = new DiffView();\r
29             diffView.setTable(diff.table);\r
30             var slug = diff.ver1 + '-' + diff.ver2;\r
31             tabsView.addTab(diff.ver1 + '->' + diff.ver2, slug, diffView.dom);\r
32             tabsView.selectTab(slug);\r
33         }\r
34     };\r
35 };\r
36 \r
37 });