Add summary and activity screens, remove private datasets from counts
[ckanext-dga-stats.git] / ckanext / stats-nav.js





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* Quick module to enhance the Bootstrap tags plug-in to update the url
 * hash when a tab changes to allow the user to bookmark the page.
 *
 * Each tab id must use a prefix which which will be stripped from the hash.
 * This is to prevent the page jumping when the hash fragment changes.
 *
 * prefix - The prefix used on the ids.
 *
 */
this.ckan.module('stats-nav', {
  /* An options object */
  options: {
    prefix: 'stats-'
  },
 
  /* Initializes the module and sets up event listeners.
   *
   * Returns nothing.
   */
  initialize: function () {
    var location = this.sandbox.location;
    var prefix = this.options.prefix;
    var hash = location.hash.slice(1);
    var selected = this.$('[href^=#' + prefix + hash + ']');
 
    // Update the hash fragment when the tab changes.
    this.el.on('shown', function (event) {
      location.hash = event.target.hash.slice(prefix.length + 1);
    });
 
    // Show the current tab if the location provides one.
    if (selected.length) {
      selected.tab('show');
    }
  }
});