1 rng.modules.tabsManager = function(sandbox) {
\r
5 var view = $(sandbox.getTemplate('main')());
\r
9 function selectTab(slug) {
\r
10 var tabBar = view.find('#rng-tabsManager-tabBar');
\r
12 var prevActive = tabBar.find('li.active');
\r
14 if(prevActive.length)
\r
15 prevSlug = prevActive.find('a').attr('href').substr(1);
\r
17 if(prevSlug == slug)
\r
20 tabBar.find('li').removeClass('active');
\r
21 tabBar.find('a[href=#' + slug + ']').parent().addClass('active');
\r
24 tabContent[prevSlug].detach();
\r
25 tabContent[slug].appendTo(view.find('#rng-tabsManager-content'));
\r
30 view.on('click', 'li a', function(e) {
\r
31 selectTab($(e.target).attr('href').substr(1));
\r
36 sandbox.publish('ready');
\r
39 getView: function() {
\r
43 addTab: function(title, slug, contentView) {
\r
44 tabContent[slug] = contentView;
\r
45 view.find('#rng-tabsManager-tabBar').append(sandbox.getTemplate('tabHandle')({title: title, slug: slug}));
\r
46 if(_.values(tabContent).length === 1)
\r