diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sites/all/modules/quicktabs/js/quicktabs_bbq.js	Thu Aug 22 17:22:54 2013 +0100
@@ -0,0 +1,37 @@
+/**
+ * @file
+ * Implements history using the BBQ plugin.
+ * See http://benalman.com/code/projects/jquery-bbq/examples/fragment-jquery-ui-tabs
+ */
+(function($) {
+
+Drupal.quicktabsBbq = function($tabset, clickSelector, changeSelector) {
+
+  changeSelector = changeSelector || clickSelector;
+
+  // Define our own click handler for the tabs, overriding the default.
+  $(clickSelector, $tabset).each(function(i, el){
+    this.tabIndex = i;
+    $(this).click(function(e){
+      e.preventDefault();
+      var state = {},
+        id = $tabset.attr('id'), // qt container id
+        idx = this.tabIndex; // tab index
+
+      state[id] = idx;
+      $.bbq.pushState(state);
+    });
+  });
+
+  $(window).bind('hashchange', function(e) {
+    $tabset.each(function() {
+      var idx = $.bbq.getState(this.id, true);
+      var $active_link = $(this).find(changeSelector).eq(idx);
+      $active_link.triggerHandler('change');
+    });
+  });
+
+  $(window).trigger('hashchange');
+}
+
+})(jQuery);
\ No newline at end of file