[304] Remove minornavigation elements from ga-report extension.
[304] Remove minornavigation elements from ga-report extension.

--- a/ckanext/ga_report/public/css/ga_report.css
+++ b/ckanext/ga_report/public/css/ga_report.css
@@ -2,6 +2,11 @@
   padding: 1px 0 0 0;
   width: 108px;
   text-align: center;
+  /* Hack to hide the momentary flash of text 
+   * before sparklines are fully rendered */
+  font-size: 1px;
+  color: transparent;
+  overflow: hidden;
 }
 .rickshaw_chart_container {
   position: relative;

--- a/ckanext/ga_report/public/scripts/ckanext_ga_reports.js
+++ b/ckanext/ga_report/public/scripts/ckanext_ga_reports.js
@@ -55,24 +55,29 @@
    * Sparkline graphs should be drawn.
    * Note that they cannot be drawn sooner.
    */
+  var created = false;
   $('a[href="#totals"]').on(
     'shown', 
-    function() {
-      var sparkOptions = {
-        enableTagOptions: true,
-        type: 'line',
-        width: 100,
-        height: 26,
-        chartRangeMin: 0,
-        spotColor: '',
-        maxSpotColor: '',
-        minSpotColor: '',
-        highlightSpotColor: '000000',
-        lineColor: '3F8E6D',
-        fillColor: 'B7E66B'
-      };
-      $('.sparkline').sparkline('html',sparkOptions);
-    }
+      function() {
+        if (!created) {
+          var sparkOptions = {
+            enableTagOptions: true,
+            type: 'line',
+            width: 100,
+            height: 26,
+            chartRangeMin: 0,
+            spotColor: '',
+            maxSpotColor: '',
+            minSpotColor: '',
+            highlightSpotColor: '#000000',
+            lineColor: '#3F8E6D',
+            fillColor: '#B7E66B'
+          };
+          $('.sparkline').sparkline('html',sparkOptions);
+          created = true;
+        }
+        $.sparkline_display_visible();
+      }
   );
 };
 
@@ -82,7 +87,7 @@
    * Show the correct rickshaw graph in the sidebar. 
    * Not to be called before all graphs load.
    */
-  $('a[data-toggle="hashchange"]').on(
+  $('a[data-toggle="hashtab"]').on(
     'shown',
     function(e) {
       var href = $(e.target).attr('href');
@@ -99,6 +104,8 @@
       $(legend_name).show();
     }
   );
+  /* The first tab might already have been shown */
+  $('li.active > a[data-toggle="hashtab"]').trigger('shown');
 };
 
 CKAN.GA_Reports.bind_month_selector = function() {
@@ -113,22 +120,3 @@
   selectors.bind('change', handler);
 };
 
-/* 
- * Custom bootstrap plugin for handling data-toggle="hashchange".
- * Behaves like data-toggle="tab" but I respond to the hashchange.
- * Page state is memo-ized in the URL this way. Why doesn't Bootstrap do this?
- */
-$(function() {
-  var mapping = {};
-  $('a[data-toggle="hashchange"]').each(
-    function(i,link) {
-      link = $(link);
-      mapping[link.attr('href')] = link;
-    }
-  );
-  $(window).hashchange(function() {
-    var link = mapping[window.location.hash];
-    if (link) { link.tab('show'); }
-  });
-});
-

--- a/ckanext/ga_report/templates/ga_report/ga_util.html
+++ b/ckanext/ga_report/templates/ga_report/ga_util.html
@@ -59,21 +59,15 @@
  </table>
 
 
-<div py:def="usage_nav(active_name)" id="minornavigation">
-    <div id="minornavigation-bg-left">
-    <div id="minornavigation-bg-right">
-      <ul class="nav nav-pills">
-        <?python querystring='?month='+c.month if c.month else '' ?>
-        <li py:attrs="{'class': 'active' if active_name=='Site-wide' else None}"><a py:attrs="{'class': 'active' if active_name=='Site-wide' else None}"  href="${h.url_for(controller='ckanext.ga_report.controller:GaReport',action='index')}${querystring}"><img src="/images/icons/page_white.png" height="16px" width="16px" alt="None" class="inline-icon "/> Site-wide</a></li>
-        <li py:attrs="{'class': 'active' if active_name=='Publishers' else None}">
-        <a py:attrs="{'class': 'active' if active_name=='Publishers' else None}"  href="${h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='publishers')}${querystring}"><img src="/images/icons/page_white.png" height="16px" width="16px" alt="None" class="inline-icon "/> Publishers</a>
-        </li>
-        <li py:attrs="{'class': 'active' if active_name=='Datasets' else None}">
-        <a py:attrs="{'class': 'active' if active_name=='Datasets' else None}"  href="${h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='read')}${querystring}"><img src="/images/icons/page_white.png" height="16px" width="16px" alt="None" class="inline-icon "/> Datasets</a>
-        </li>
-      </ul>
-    </div>
-    </div>
+<div py:def="usage_nav(active_name)">
+  <span class="subheading">
+    <img src="/images/arrow-down-right.png" />
+    <a class="${if_(active_name=='Site-wide','active')}" href="${h.url_for(controller='ckanext.ga_report.controller:GaReport',action='index')}${if_(c.month,'?month='+c.month)}">Site-wide</a>
+    <span class="divider">|</span>
+    <a class="${if_(active_name=='Publishers','active')}" href="${h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='publishers')}${if_(c.month,'?month='+c.month)}">Publishers</a>
+    <span class="divider">|</span>
+    <a class="${if_(active_name=='Datasets','active')}" href="${h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='read')}${if_(c.month,'?month='+c.month)}">Datasets</a>
+  </span>
 </div>
 
 

--- a/ckanext/ga_report/templates/ga_report/publisher/index.html
+++ b/ckanext/ga_report/templates/ga_report/publisher/index.html
@@ -6,6 +6,8 @@
   <xi:include href="../ga_util.html" />
 
   <py:def function="page_title">Usage by Publisher</py:def>
+
+  <py:def function="content_class"><!----></py:def>
 
   <py:match path="primarysidebar">
     <li class="widget-container boxed widget_text">
@@ -24,8 +26,8 @@
 
   <py:def function="optional_head">
     <link rel="stylesheet" type="text/css" href="/scripts/vendor/rickshaw.min.css"/>
-    <link rel="stylesheet" type="text/css" href="/css/ga_report.css"/>
-    <script type="text/javascript" src="/scripts/ckanext_ga_reports.js"></script>
+    <link rel="stylesheet" type="text/css" href="/css/ga_report.css?1"/>
+    <script type="text/javascript" src="/scripts/ckanext_ga_reports.js?1"></script>
     <script type="text/javascript" src="/scripts/vendor/jquery.sparkline.modified.js"></script>
     <script type="text/javascript" src="/scripts/rickshaw_ie7_shim.js"></script>
     <script type="text/javascript" src="/scripts/vendor/d3.v2.js"></script>
@@ -35,13 +37,12 @@
 
   <div py:match="content">
 
-      <h1>Site Usage</h1>
+    <h1>Site Usage ${usage_nav('Publishers')}</h1>
 
-      ${usage_nav('Publishers')}
-
+    <div class="boxed">
 
        ${rickshaw_graph(c.top_publishers_graph,'publishers')}
-      <form class="form-inline" action="${h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='publishers')}" method="get">
+       <form class="form-inline" action="${h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='publishers')}" method="get">
           <div class="controls">
             <label>Show stats table for:</label>
             ${month_selector(c.month, c.months, c.day)}
@@ -49,22 +50,21 @@
        </form>
 
        <table class="ga-reports-table table table-condensed table-bordered table-striped">
-	 <tr>
-	   <th>Publisher</th>
-	   <th class="td-numeric">Dataset Views</th>
-	 </tr>
+         <tr>
+           <th>Publisher</th>
+           <th class="td-numeric">Dataset Views</th>
+         </tr>
         <py:for each="publisher, views, visits in c.top_publishers">
-	  <tr>
-	    <td>
-	        ${h.link_to(publisher.title, h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport', action='read_publisher', id=publisher.name) + (("?month=" + c.month) if c.month else ''))}
-	    </td>
-	    <td class="td-numeric">${views}</td>
-	  </tr>
+          <tr>
+            <td>
+                ${h.link_to(publisher.title, h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport', action='read_publisher', id=publisher.name) + (("?month=" + c.month) if c.month else ''))}
+            </td>
+            <td class="td-numeric">${views}</td>
+          </tr>
         </py:for>
        </table>
-
-
-  </div>
+    </div><!--/boxed-->
+  </div><!--/content-->
 
   <py:def function="optional_footer">
     <script type="text/javascript">

--- a/ckanext/ga_report/templates/ga_report/publisher/read.html
+++ b/ckanext/ga_report/templates/ga_report/publisher/read.html
@@ -7,10 +7,12 @@
 
   <py:def function="page_title">Usage by Dataset</py:def>
 
+  <py:def function="content_class"><!----></py:def>
+
   <py:def function="optional_head">
     <link rel="stylesheet" type="text/css" href="/scripts/vendor/rickshaw.min.css"/>
-    <link rel="stylesheet" type="text/css" href="/css/ga_report.css"/>
-    <script type="text/javascript" src="/scripts/ckanext_ga_reports.js"></script>
+    <link rel="stylesheet" type="text/css" href="/css/ga_report.css?1"/>
+    <script type="text/javascript" src="/scripts/ckanext_ga_reports.js?1"></script>
     <script type="text/javascript" src="/scripts/vendor/jquery.sparkline.modified.js"></script>
     <script type="text/javascript" src="/scripts/rickshaw_ie7_shim.js"></script>
     <script type="text/javascript" src="/scripts/vendor/d3.v2.js"></script>
@@ -35,11 +37,9 @@
 
 
   <div py:match="content">
-     <h1>Site Usage</h1>
+    <h1>Site Usage ${usage_nav('Datasets')}</h1>
 
-     ${usage_nav('Datasets')}
-
-
+    <div class="boxed">
      <h3 py:if="c.publisher"><a href="${h.url_for(controller='ckanext.dgu.controllers.publisher:PublisherController',action='read',id=c.publisher.name)}">${c.publisher.title}</a></h3>
 
      <p py:if="not c.top_packages">No page views in this period</p>
@@ -80,6 +80,7 @@
       </table>
     </py:if>
 
+  </div>
 
   </div>
 

--- a/ckanext/ga_report/templates/ga_report/site/downloads.html
+++ b/ckanext/ga_report/templates/ga_report/site/downloads.html
@@ -6,6 +6,8 @@
   <xi:include href="../ga_util.html" />
 
   <py:def function="page_title">Downloads</py:def>
+
+  <py:def function="content_class"><!----></py:def>
 
   <py:match path="primarysidebar">
     <li py:if="c.downloads" class="widget-container boxed widget_text">
@@ -19,8 +21,9 @@
   </py:match>
 
   <div py:match="content">
-      <h1>Downloads</h1>
-      ${usage_nav('Downloads')}
+      <h1>Downloads ${usage_nav('Downloads')}</h1>
+
+    <div class="boxed">
 
       <form class="form-inline" action="${h.url_for(controller='ckanext.ga_report.controller:GaReport',action='downloads')}" method="get">
           <div class="controls">
@@ -38,6 +41,7 @@
          <h4>No data</h4>
          <p>There is no download data available for this month</p>
        </py:if>
+     </div>
   </div>
 
   <xi:include href="../../layout.html" />

--- a/ckanext/ga_report/templates/ga_report/site/index.html
+++ b/ckanext/ga_report/templates/ga_report/site/index.html
@@ -7,10 +7,12 @@
 
   <py:def function="page_title">Site usage</py:def>
 
+  <py:def function="content_class"><!----></py:def>
+
   <py:def function="optional_head">
     <link rel="stylesheet" type="text/css" href="/scripts/vendor/rickshaw.min.css"/>
-    <link rel="stylesheet" type="text/css" href="/css/ga_report.css"/>
-    <script type="text/javascript" src="/scripts/ckanext_ga_reports.js"></script>
+    <link rel="stylesheet" type="text/css" href="/css/ga_report.css?1"/>
+    <script type="text/javascript" src="/scripts/ckanext_ga_reports.js?1"></script>
     <script type="text/javascript" src="/scripts/vendor/jquery.sparkline.modified.js"></script>
     <script type="text/javascript" src="/scripts/rickshaw_ie7_shim.js"></script>
     <script type="text/javascript" src="/scripts/vendor/d3.v2.js"></script>
@@ -36,41 +38,45 @@
   </py:match>
 
   <div py:match="content">
-      <h1>Site Usage</h1>
-      ${usage_nav('Site-wide')}
+      <h1>Site Usage ${usage_nav('Site-wide')}</h1>
 
+    <div class="boxed">
     <div class="tabbable">
       <ul class="nav nav-tabs">
-        <li><a href="#totals" data-toggle="hashchange">Totals</a></li>
+        <li class="active"><a href="#totals" data-toggle="hashtab">Totals</a></li>
         <li class="dropdown">
             <a href="#" class="dropdown-toggle" data-toggle="dropdown">Browsers
                 <b class="caret"></b></a>
             <ul class="dropdown-menu">
-                <li><a href="#browsers_names" data-toggle="hashchange">Browsers</a></li>
-                <li><a href="#browsers_versions" data-toggle="hashchange">Versions</a></li>
+                <li><a href="#browsers_names" data-toggle="hashtab">Browsers</a></li>
+                <li><a href="#browsers_versions" data-toggle="hashtab">Versions</a></li>
             </ul>
         </li>
         <li class="dropdown">
             <a href="#" class="dropdown-toggle" data-toggle="dropdown">Operating Systems
                 <b class="caret"></b></a>
             <ul class="dropdown-menu">
-                <li><a href="#os" data-toggle="hashchange">Operating Systems</a></li>
-                <li><a href="#os_versions" data-toggle="hashchange">Versions</a></li>
+                <li><a href="#os" data-toggle="hashtab">Operating Systems</a></li>
+                <li><a href="#os_versions" data-toggle="hashtab">Versions</a></li>
             </ul>
         </li>
         <li class="dropdown">
             <a href="#" class="dropdown-toggle" data-toggle="dropdown">Social
                 <b class="caret"></b></a>
             <ul class="dropdown-menu">
-                <li><a href="#social_networks" data-toggle="hashchange">All networks</a></li>
-                <li><a href="#social_referrals_totals" data-toggle="hashchange">Referral links</a></li>
+                <li><a href="#social_networks" data-toggle="hashtab">All networks</a></li>
+                <li><a href="#social_referrals_totals" data-toggle="hashtab">Referral links</a></li>
             </ul>
         </li>
-        <li><a href="#languages" data-toggle="hashchange">Languages</a></li>
-        <li><a href="#country" data-toggle="hashchange">Country</a></li>
+        <li><a href="#languages" data-toggle="hashtab">Languages</a></li>
+        <li><a href="#country" data-toggle="hashtab">Country</a></li>
       </ul>
       <div class="tab-content">
-        <div class="tab-pane" id="totals">
+        <div class="tab-pane active" id="totals">
+             <form class="form-inline" action="${h.url_for(controller='ckanext.ga_report.controller:GaReport',action='index')}" method="get">
+               <label>Show stats table for:</label>
+               ${month_selector(c.month, c.months, c.day)}
+             </form>
              <table class="ga-reports-table table table-condensed table-bordered table-striped">
             	 <tr>
             	   <th>Name</th>
@@ -158,6 +164,7 @@
         </div>
        </div>
      </div>
+   </div>
   </div>
 
 
@@ -167,12 +174,6 @@
         CKAN.GA_Reports.bind_sparklines();
         CKAN.GA_Reports.bind_sidebar();
         CKAN.GA_Reports.bind_month_selector();
-        if (!window.location.hash) {
-          window.location.hash='totals';
-        }
-        else {
-          $(window).trigger('hashchange');
-        }
       });  
     </script>
   </py:def>