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', '');
+ }
})
}