X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/0add3b13ce4ef42557d9ca33342a159b80a4f42f..4e0553edaf87974f2e9565fcb0514b928cb48d8e:/modules/tabsManager.js?ds=sidebyside diff --git a/modules/tabsManager.js b/modules/tabsManager.js index 56d647d..a204858 100644 --- a/modules/tabsManager.js +++ b/modules/tabsManager.js @@ -1,9 +1,11 @@ -rng.modules.tabsManager = function(sandbox) { +define(function() { + +return function(sandbox) { var $ = sandbox.$; var view = $(sandbox.getTemplate('main')()); - + var currentSlug; var tabContent = {}; function selectTab(slug) { @@ -25,10 +27,12 @@ rng.modules.tabsManager = function(sandbox) { if(prevSlug) tabContent[prevSlug].detach(); tabContent[slug].appendTo(view.find('#rng-tabsManager-content')); + currentSlug = slug; + sandbox.publish('showed', slug); } - view.on('click', 'li a', function(e) { + view.on('click', '#rng-tabsManager-tabBar li a', function(e) { selectTab($(e.target).attr('href').substr(1)); }); @@ -46,7 +50,12 @@ rng.modules.tabsManager = function(sandbox) { view.find('#rng-tabsManager-tabBar').append(sandbox.getTemplate('tabHandle')({title: title, slug: slug})); if(_.values(tabContent).length === 1) selectTab(slug); + }, + getCurrentSlug: function() { + return currentSlug; } } -}; \ No newline at end of file +}; + +}); \ No newline at end of file