tex4ht-footnote-hack.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // The code below is released as CC0:
  2. // http://creativecommons.org/publicdomain/zero/1.0/ by
  3. // Bradley M. Kuhn <bkuhn@ebb.org>
  4. $(function() {
  5. $( ".footnote-mark" ).tooltip({
  6. items: "a",
  7. hide: { duration: 5000 },
  8. position: {
  9. my: "center bottom-20",
  10. at: "center left",
  11. using: function( position, feedback ) {
  12. $( this ).css( position );
  13. $( "<div>" )
  14. .addClass( "arrow" )
  15. .addClass( feedback.vertical )
  16. .addClass( feedback.horizontal )
  17. .appendTo( this );
  18. }
  19. },
  20. content: function() {
  21. var element = $( this );
  22. if ( element.is( 'a' ) ) {
  23. var footnoteVal = element.attr( "href" );
  24. return tex4ht[footnoteVal.substring(footnoteVal.search("#") + 1)];
  25. }
  26. }});
  27. });
  28. // ####################################################################
  29. // The following code was borrowed from:
  30. // https://github.com/pierre-rouanet/sphinxjp.themes.basicstrap/commit/05ac6055be8cbb6097f16ab106df5244c19a067f
  31. // which was licensed under the permissive MIT license.
  32. // and modified by Bradley M. Kuhn, (C) 2014, also permissive MIT license'd:
  33. // Permission is hereby granted, free of charge, to any person obtaining a
  34. // copy of this software and associated documentation files (the
  35. // "Software"), to deal in the Software without restriction, including
  36. // without limitation the rights to use, copy, modify, merge, publish,
  37. // distribute, sublicense, and/or sell copies of the Software, and to
  38. // permit persons to whom the Software is furnished to do so, subject to
  39. // the following conditions:
  40. // The above copyright notice and this permission notice shall be
  41. // included in all copies or substantial portions of the Software.
  42. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  43. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  44. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  45. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  46. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  47. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  48. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  49. // This below code is designed to handle the proper handling of in-page
  50. // anchor offsets. Specifically, it handles only those in-page anchors which
  51. // have both an href and id attribute to correct for the issue of the a fixed
  52. // bootstrap navbar header which by default causes in-page anchor offsets to
  53. // be obscured by the top navbar.
  54. // This Javascript solution is not as preferable as the pure CSS solution, so
  55. // the pure CSS solution is used for those anchors which have no href
  56. // attribute.
  57. $(window).load(function () {
  58. /*
  59. * Scroll the window to avoid the topnav bar
  60. * https://github.com/twitter/bootstrap/issues/1768
  61. */
  62. if ($(".navbar.navbar-fixed-top").length > 0) {
  63. var navHeight = $(".navbar").height(),
  64. shiftWindow = function() {
  65. var ourURL = document.URL;
  66. if ( (ourURL.search("#fn") > 0) || (ourURL.search("#QQ") > 0)) {
  67. scrollBy(0, -navHeight - 5);
  68. }
  69. };
  70. if (location.hash) {
  71. setTimeout(shiftWindow, 1);
  72. }
  73. window.addEventListener("hashchange", shiftWindow);
  74. }
  75. });