X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/3cb3fafa935f0f4536f7ed45abc26123b224f068..f129f1dd6ba62fa571960330c62191e08e53deb2:/modules/tabsManager.js?ds=inline diff --git a/modules/tabsManager.js b/modules/tabsManager.js index 1dd857d..4103887 100644 --- a/modules/tabsManager.js +++ b/modules/tabsManager.js @@ -3,7 +3,7 @@ rng.modules.tabsManager = function(sandbox) { var $ = sandbox.$; var view = $(sandbox.getTemplate('main')()); - + var currentSlug; var tabContent = {}; function selectTab(slug) { @@ -16,6 +16,8 @@ rng.modules.tabsManager = function(sandbox) { if(prevSlug == slug) return; + if(prevSlug) + sandbox.publish('leaving', prevSlug); tabBar.find('li').removeClass('active'); tabBar.find('a[href=#' + slug + ']').parent().addClass('active'); @@ -23,10 +25,10 @@ rng.modules.tabsManager = function(sandbox) { if(prevSlug) tabContent[prevSlug].detach(); tabContent[slug].appendTo(view.find('#rng-tabsManager-content')); + currentSlug = slug; } - view.on('click', 'li a', function(e) { selectTab($(e.target).attr('href').substr(1)); }); @@ -45,6 +47,9 @@ 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; } }