12e022af13465f6c61167a43b5dfcd55b55453a0
[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     \r
20     DiffView.prototype.setTable = function(table) {\r
21         this.dom.append(table);\r
22     };\r
23     \r
24 \r
25     return {\r
26         start: function() {sandbox.publish('ready');},\r
27         getView: function() {return dom;},\r
28         setDiff: function(diff) {\r
29             var diffView = new DiffView();\r
30             diffView.setTable(diff.table);\r
31             var slug = diff.ver1 + '-' + diff.ver2;\r
32             tabsView.addTab(diff.ver1 + '->' + diff.ver2, slug, diffView.dom);\r
33             tabsView.selectTab(slug);\r
34         }\r
35     };\r
36 };\r
37 \r
38 });