X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/a5871ab5512d87a33e7e95451d26ee7d3e789742..0214643f72c6aaa8e85eaba2ad27f2ca03ca6401:/modules/tabsManager.js diff --git a/modules/tabsManager.js b/modules/tabsManager.js index a57a47e..70058a9 100644 --- a/modules/tabsManager.js +++ b/modules/tabsManager.js @@ -1,36 +1,33 @@ -rng.modules.tabsManager = function(sandbox) { +define(['views/tabs/tabs'], function(tabsView) { - var $ = sandbox.$; +return function(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)); + var view = new tabsView.View(); + view.on('leaving', function(slug) { + sandbox.publish('leaving', slug); + }); + view.on('tabSelected', function(slug) { + sandbox.publish('showed', slug); }); return { start: function() { + view.render(); sandbox.publish('ready'); }, getView: function() { - return view; + return view.$el; }, - addTab: function(title, view) { - tabContent[title] = view; + addTab: function(title, slug, contentView) { + view.addTab(title, slug, contentView); + + }, + getCurrentSlug: function() { + return view.selectedTab; } } +}; -}; \ No newline at end of file +}); \ No newline at end of file