Commits

g...@13f79535-47bb-0310-9956-ffa450edef68  committed ea78268

adding the basic scrollspy - towards #174 (from olemis)

  • Participants
  • Parent commits 2dbd0c8

Comments (0)

Files changed (4)

File bhtheme/htdocs/bloodhound.css

   margin-top: 2px !important;
 }
 
+.visible-affix {
+  display: none !important;
+}
+
+.affix .visible-affix {
+  display: inherit !important;
+}
+
+.hidden-affix {
+  display: inherit !important;
+}
+
+.affix .hidden-affix {
+  display: none !important;
+}
+
 /* Revert some changes introduced in 2.1.0 */
 
 h6 {

File bhtheme/htdocs/js/theme.js

   target.parent('.stickyBox').height(target.height());
   target = null;
   $(window).on('scroll.affix.data-api', function() {
-      affix_data = $(selector).data('affix');
-      if (affix_data && !affix_data.affixed) {
-        var target = $(selector);
+      var affix_data = $(selector).data('affix');
+      var target = $(selector);
+
+      if (affix_data && !affix_data.affixed)
         target.parent('.stickyBox').height(target.height());
-      }
+      else
+        target.parent('.stickyBox').css('height', '');
     })
 }
 

File bhtheme/templates/bh_ticket.html

     <script py:if="ticket.exists" type="text/javascript" src="${chrome.htdocs_location}js/threaded_comments.js"></script>
     <script type="text/javascript" py:choose="">
       jQuery(document).ready(function($) {
+        /* Affixed navbar */
+        $(".navbar a").click(function() { $($(this).attr('href')).removeClass('collapsed').parent().removeClass("collapsed"); });
+        $('.trac-nav').hide();
+        $('.trac-topnav').hide();
+        $('body').scrollspy({ 
+            'target' : '.navbar' , 
+            'offset' : $('.stickyBox').height() + 40
+          })
+
         $("div.description").find("h1,h2,h3,h4,h5,h6").addAnchor(_("Link to this section"));
         $(".foldable").enableFolding(false, true);
       <py:when test="ticket.exists">/*<![CDATA[*/
                 </h6>
               </div>
             </div>
+            <div class="navbar visible-affix" py:if="ticket.exists"
+                py:with="sections = (
+                        (_('Overview'), 'content', True, _('View ticket fields and description')),
+                        (_('Attachments'), 'attachments', True, _('Go to the list of attachments')),
+                        (_('Comments'), 'changelog', True, _('Go to the changelog')),
+                        (_('Add comment'), 'propertyform', ticket.exists and can_append, _('Go to the ticket editor')),
+                        (_('Modify Ticket'), 'modify', can_modify or can_edit or can_create, _('Modify ticket fields and description')),
+                    )">
+              <div class="navbar-inner">
+                <ul class="nav">
+                  <li py:for="s in sections" py:if="s[2]">
+                    <a href="#${s[1]}" title="${s[3]}">${s[0]}</a>
+                  </li>
+                </ul>
+              </div>
+            </div>
             <div class="stickyEndMark"></div>
           </div>
         </div>

File bhtheme/theme.py

 from trac.util.translation import _
 from trac.versioncontrol.web_ui.browser import BrowserModule
 from trac.web.api import IRequestFilter, IRequestHandler, ITemplateStreamFilter
-from trac.web.chrome import (add_stylesheet, INavigationContributor, 
+from trac.web.chrome import (add_script, add_stylesheet, INavigationContributor,
                              ITemplateProvider, prevnext_nav)
 
 from themeengine.api import ThemeBase, ThemeEngineSystem
         'report_edit.html' : ('bh_report_edit.html', None), 
         'report_list.html' : ('bh_report_list.html', None),
         'report_view.html' : ('bh_report_view.html', None),
-        'ticket.html' : ('bh_ticket.html', None),
+        'ticket.html' : ('bh_ticket.html', '_modify_scrollspy'),
         'ticket_preview.html' : ('bh_ticket_preview.html', None),
 
         # Multi Product
         """
         add_stylesheet(req, 'dashboard/css/roadmap.css')
 
+    def _modify_scrollspy(self, req, template, data, content_type, is_active):
+        """Insert Bootstrap scroll spy files.
+        """
+        add_script(req, 'dashboard/js/bootstrap-scrollspy.js')
+
     # INavigationContributor methods
 
     def get_active_navigation_item(self, req):