incubator-bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g..@apache.org
Subject svn commit: r1411625 - /incubator/bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/js/theme.js
Date Tue, 20 Nov 2012 11:43:01 GMT
Author: gjm
Date: Tue Nov 20 11:43:01 2012
New Revision: 1411625

URL: http://svn.apache.org/viewvc?rev=1411625&view=rev
Log:
add appropriate stickybox height offset to get to right location when clicking page anchor
links - fixes #167 (from olemis)

Modified:
    incubator/bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/js/theme.js

Modified: incubator/bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/js/theme.js
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/js/theme.js?rev=1411625&r1=1411624&r2=1411625&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/js/theme.js (original)
+++ incubator/bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/js/theme.js Tue Nov 20 11:43:01
2012
@@ -112,16 +112,31 @@ function setup_sticky_panel(selector) {
     var $spy = $(this);
     $spy.affix( { 'offset' : $spy.position().top } )
   });
-  target.parent('.stickyBox').height(target.height());
-  target = null;
+  var h = target.height();
+  target.parent('.stickyBox').height(h);
+
+  // Create style tag to fix anchor position
+  function _sticky_offset_rules(_h) {
+    return '.stickyBox~* form[id], .stickyBox~* div[id] { margin-top:-' +
+      _h + 'px; padding-top: ' + _h + 'px } ' +
+      '.stickyBox, .stickyBox [id] { margin-top: 0px ; padding-top: 0px }';
+  }
+  $('<style id="sticky-offset" /> ').text( _sticky_offset_rules(h) )
+      .appendTo('head');
+
+  target = h = null;
   $(window).on('scroll.affix.data-api', function() {
       var affix_data = $(selector).data('affix');
       var target = $(selector);
 
-      if (affix_data && !affix_data.affixed)
-        target.parent('.stickyBox').height(target.height());
-      else
+      if (affix_data && !affix_data.affixed) {
+        var h = target.height();
+        target.parent('.stickyBox').height(h);
+        $('style#sticky-offset').text(_sticky_offset_rules(h))
+      }
+      else {
         target.parent('.stickyBox').css('height', '');
+      }
     })
 }
 



Mime
View raw message