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