comparison sites/all/modules/quicktabs/js/quicktabs_bbq.js @ 2:b74b41bb73f0

-- Google analytics module
author danieleb <danielebarchiesi@me.com>
date Thu, 22 Aug 2013 17:22:54 +0100
parents
children
comparison
equal deleted inserted replaced
1:67ce89da90df 2:b74b41bb73f0
1 /**
2 * @file
3 * Implements history using the BBQ plugin.
4 * See http://benalman.com/code/projects/jquery-bbq/examples/fragment-jquery-ui-tabs
5 */
6 (function($) {
7
8 Drupal.quicktabsBbq = function($tabset, clickSelector, changeSelector) {
9
10 changeSelector = changeSelector || clickSelector;
11
12 // Define our own click handler for the tabs, overriding the default.
13 $(clickSelector, $tabset).each(function(i, el){
14 this.tabIndex = i;
15 $(this).click(function(e){
16 e.preventDefault();
17 var state = {},
18 id = $tabset.attr('id'), // qt container id
19 idx = this.tabIndex; // tab index
20
21 state[id] = idx;
22 $.bbq.pushState(state);
23 });
24 });
25
26 $(window).bind('hashchange', function(e) {
27 $tabset.each(function() {
28 var idx = $.bbq.getState(this.id, true);
29 var $active_link = $(this).find(changeSelector).eq(idx);
30 $active_link.triggerHandler('change');
31 });
32 });
33
34 $(window).trigger('hashchange');
35 }
36
37 })(jQuery);