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 sandbox.publish('leaving', prevSlug);
\r
22 tabBar.find('li').removeClass('active');
\r
23 tabBar.find('a[href=#' + slug + ']').parent().addClass('active');
\r
26 tabContent[prevSlug].detach();
\r
27 tabContent[slug].appendTo(view.find('#rng-tabsManager-content'));
\r
29 sandbox.publish('showed', slug);
\r
33 view.on('click', '#rng-tabsManager-tabBar li a', function(e) {
\r
34 selectTab($(e.target).attr('href').substr(1));
\r
39 sandbox.publish('ready');
\r
42 getView: function() {
\r
46 addTab: function(title, slug, contentView) {
\r
47 tabContent[slug] = contentView;
\r
48 view.find('#rng-tabsManager-tabBar').append(sandbox.getTemplate('tabHandle')({title: title, slug: slug}));
\r
49 if(_.values(tabContent).length === 1)
\r
52 getCurrentSlug: function() {
\r