X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/39f85f733b10ae8b454fa140eec6ad7c106cc8f1..a5871ab5512d87a33e7e95451d26ee7d3e789742:/modules/tabsManager.js diff --git a/modules/tabsManager.js b/modules/tabsManager.js new file mode 100644 index 0000000..a57a47e --- /dev/null +++ b/modules/tabsManager.js @@ -0,0 +1,36 @@ +rng.modules.tabsManager = function(sandbox) { + + var $ = sandbox.$; + + var view = $(sandbox.getTemplate('main')()); + + var tabContent = {}; + + function selectTab(tabCode) { + var tabBar = $(view, '#rng-main-tabs'); + var prevTabCode = tabBar.find('li.active a').attr('href').substr(1); + tabBar.find('li').removeClass('active'); + tabBar.find('a[href=#' + tabCode + ']').parent().addClass('active'); + $(view, '.rng-tab-content').hide(); + $(view, '#rng-tab-content-' + tabCode).show(); + } + + $('#rng-main-tabs li a').click(function(e) { + selectTab($(e.target).attr('href').substr(1)); + }); + + return { + start: function() { + sandbox.publish('ready'); + }, + + getView: function() { + return view; + }, + + addTab: function(title, view) { + tabContent[title] = view; + } + } + +}; \ No newline at end of file