--- /dev/null
+define([\r
+'libs/jquery-1.9.1.min',\r
+'libs/underscore-min',\r
+'libs/text!./templates/main.html',\r
+'libs/text!./templates/item.html'\r
+], function($, _, mainTemplateSrc, itemTemplateSrc) {\r
+\r
+'use strict';\r
+ \r
+return function(sandbox) {\r
+ \r
+ var dom = $(_.template(mainTemplateSrc)());\r
+ var domNodes = {\r
+ itemList: dom.find('.rng-module-documentHistory-itemsList'),\r
+ }\r
+ var itemViews = [];\r
+ \r
+ var addHistoryItem = function(item) {\r
+ historyItems.add(item);\r
+ var view = new itemView(item);\r
+ itemViews.push(view);\r
+ domNodes.itemList.append(view.dom);\r
+ }\r
+ \r
+ var toggleItemViews = function(toggle) {\r
+ itemViews.forEach(function(view) {\r
+ view.toggle(toggle);\r
+ });\r
+ }\r
+ \r
+ var historyItems = {\r
+ _itemsById: {},\r
+ _selected: [],\r
+ select: function(id) {\r
+ if(this._selected.length < 2) {\r
+ this._selected.push(id);\r
+ if(this._selected.length === 2)\r
+ toggleItemViews(false);\r
+ return true;\r
+ }\r
+ return false;\r
+ },\r
+ unselect: function(item) {\r
+ this._selected = _.without(this._selected, id);\r
+ if(this._selected.length < 2)\r
+ toggleItemViews(true);\r
+ },\r
+ add: function(item) {\r
+ this._itemsById[item.id] = item;\r
+ },\r
+ selected: function(item) {\r
+ return _.contains(_selected, item.id);\r
+ }\r
+ };\r
+ \r
+ var itemView = function(item) {\r
+ this.item = item;\r
+ this.dom = $(this.template(item));\r
+ this.dom.on('click', this.onItemClicked);\r
+ };\r
+ itemView.prototype.template = _.template(itemTemplateSrc);\r
+ itemView.prototype.onItemClicked = function() {\r
+ if(historyItems.selected(item)) {\r
+ historyItems.unselect(item);\r
+ this.dimItem();\r
+ } else if(historyItems.select(item)) {\r
+ this.highlightItem();\r
+ } \r
+ };\r
+ itemView.prototype.highlightItem = function() {\r
+ \r
+ };\r
+ itemView.prototype.dimItem = function() {\r
+ \r
+ };\r
+ itemView.prototype.toggle = function(toggle) {\r
+ \r
+ };\r
+\r
+ \r
+ \r
+ return {\r
+ start: function() { sandbox.publish('ready'); },\r
+ setHistory: function(history) {\r
+ history.forEach(function(historyItem) {\r
+ addHistoryItem(historyItem);\r
+ });\r
+ },\r
+ getView: function() {\r
+ return dom;\r
+ }\r
+ }\r
+}\r
+\r
+});
\ No newline at end of file
ready: function() {\r
views.mainLayout.setView('mainView', views.mainTabs.getAsView());\r
\r
- _.each(['sourceEditor', 'documentCanvas', 'documentToolbar', 'nodePane', 'metadataEditor', 'nodeFamilyTree', 'nodeBreadCrumbs', 'mainBar', 'indicator'], function(moduleName) {\r
+ _.each(['sourceEditor', 'documentCanvas', 'documentToolbar', 'nodePane', 'metadataEditor', 'nodeFamilyTree', 'nodeBreadCrumbs', 'mainBar', 'indicator', 'documentHistory'], function(moduleName) {\r
sandbox.getModule(moduleName).start();\r
});\r
},\r
} \r
}\r
\r
+ eventHandlers.documentHistory = {\r
+ ready: function() {\r
+ sandbox.getModule('documentHistory').setHistory(sandbox.getModule('data').getHistory());\r
+ addMainTab('Historia', 'history', sandbox.getModule('documentHistory').getView());\r
+ }\r
+ }\r
+ \r
/* api */\r
\r
return {\r