Skip to content

Commit

Permalink
Adding support for is_hover to Tabs
Browse files Browse the repository at this point in the history
Adding is_hover support for tabs.  Handy for building megamenus whilst
using existing tab functionality.
  • Loading branch information
David Ollerhead committed Mar 27, 2014
1 parent 645f025 commit 68547c7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
6 changes: 5 additions & 1 deletion doc/includes/examples_javascript_data_options.html
Expand Up @@ -303,10 +303,14 @@
<td>1</td>
</tr>
<tr>
<td rowspan="1">Tab</td>
<td rowspan="2">Tab</td>
<td>active_class</td>
<td>'active'</td>
</tr>
<tr>
<td>is_hover</td>
<td>false</td>
</tr>
<tr>
<td rowspan="6">Tooltip</td>
<td>additional_inheritable_classes</td>
Expand Down
21 changes: 14 additions & 7 deletions js/foundation/foundation.tab.js
Expand Up @@ -11,7 +11,8 @@
active_class: 'active',
callback : function () {},
deep_linking: false,
scroll_to_content: true
scroll_to_content: true,
is_hover: false
},

default_tab_hashes: [],
Expand All @@ -35,12 +36,18 @@
var self = this,
S = this.S;

// Click event: tab title
S(this.scope).off('.tab').on('click.fndtn.tab', '[' + this.attr_name() + '] > dd > a', function (e) {
e.preventDefault();
e.stopPropagation();
self.toggle_active_tab(S(this).parent());
});
S(this.scope)
.off('.tab')
.on('click.fndtn.tab', '[' + this.attr_name() + '] > dd > a', function (e) {
var settings = S(this).closest('[' + self.attr_name() +']').data(self.attr_name(true) + '-init');
e.preventDefault();
e.stopPropagation();
if (!settings.is_hover || Modernizr.touch) self.toggle_active_tab(S(this).parent());
})
.on('mouseenter.fndtn.tab', '[' + this.attr_name() + '] > dd > a', function (e) {
var settings = S(this).closest('[' + self.attr_name() +']').data(self.attr_name(true) + '-init');
if (settings.is_hover) self.toggle_active_tab(S(this).parent());
});

// Location hash change event
S(window).on('hashchange.fndtn.tab', function (e) {
Expand Down

0 comments on commit 68547c7

Please sign in to comment.