define([
+'libs/jquery',
'libs/text!./templates/main.html',
'libs/text!./templates/handle.html',
'libs/underscore',
'libs/backbone'
-], function(mainTemplate, handleTemplate, _, Backbone) {
+], function($, mainTemplate, handleTemplate, _, Backbone) {
'use strict';
var View = Backbone.View.extend({
className: 'rng-view-tabs',
events: {
- 'click ul a, i': '_onTabTitleClicked'
+ 'click .rng-view-tabs-tabBar a, .rng-view-tabs-tabBar i': '_onTabTitleClicked'
},
initialize: function(options) {
return this;
},
- addTab: function(title, slug, content) {
+ addTab: function(title, slug, content, tutorial) {
if(this.contents[slug]) {
this.contents[slug].detach();
}
var text = (typeof title === 'string') ? title : (title.text || '');
var icon = title.icon || null;
- if(!this.tabExists(slug))
- this.nodes.tabBar.append(this.handleTemplate({text: text, icon: icon, slug: slug}));
- if(!this.selectedTab)
+ if(!this.tabExists(slug)) {
+ this.nodes.tabBar.append(this.handleTemplate({text: text, icon: icon, slug: slug, tutorial: tutorial}));
+ }
+ if(!this.selectedTab) {
this.selectTab(slug);
+ }
},
selectTab: function(slug) {
if(this.selectedTab) {
var toDetach = this.contents[this.selectedTab];
- if(toDetach.onHide)
+ if(toDetach.onHide) {
toDetach.onHide();
+ }
toDetach.detach();
}
this.nodes.content.append(this.contents[slug]);
_onTabTitleClicked: function(e) {
e.preventDefault();
var target = $(e.target);
- if(target.is('i'))
+ if(target.is('i')) {
target = target.parent();
+ }
var slug = target.attr('href').substr(1);
this.selectTab(slug);
}