incubator-bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g..@apache.org
Subject svn commit: r1421336 - /incubator/bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/js/theme.js
Date Thu, 13 Dec 2012 15:21:27 GMT
Author: gjm
Date: Thu Dec 13 15:21:26 2012
New Revision: 1421336

URL: http://svn.apache.org/viewvc?rev=1421336&view=rev
Log:
reverts r1411625, providing a different fix for jumping to a better location for anchor links
- for #289 (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=1421336&r1=1421335&r2=1421336&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/js/theme.js (original)
+++ incubator/bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/js/theme.js Thu Dec 13 15:21:26
2012
@@ -115,28 +115,30 @@ function setup_sticky_panel(selector) {
   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);
+      var affix_data = target.data('affix');
 
       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', '');
       }
     })
+  $(function() {
+      var prev_onhashchange = window.onhashchange;
+
+      window.onhashchange = function() {
+        prev_onhashchange();
+        var target = $(selector);
+        var affix_data = target.data('affix');
+    
+        if (affix_data && !affix_data.affixed)
+          window.scrollBy(0, -target.height());
+      }
+    })
 }
 



Mime
View raw message