application.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT
  2. // IT'S ALL JUST JUNK FOR OUR DOCS!
  3. // ++++++++++++++++++++++++++++++++++++++++++
  4. /*!
  5. * Copyright 2013 Twitter, Inc.
  6. *
  7. * Licensed under the Creative Commons Attribution 3.0 Unported License. For
  8. * details, see http://creativecommons.org/licenses/by/3.0/.
  9. */
  10. !function ($) {
  11. $(function(){
  12. var $window = $(window)
  13. var $body = $(document.body)
  14. var navHeight = $('.navbar').outerHeight(true) + 10
  15. $.fn.validator.Constructor.FOCUS_OFFSET = navHeight
  16. $body.scrollspy({
  17. target: '.bs-sidebar',
  18. offset: navHeight
  19. })
  20. $window.on('load', function () {
  21. $body.scrollspy('refresh')
  22. })
  23. $('.bs-docs-container [href=#]').click(function (e) {
  24. e.preventDefault()
  25. })
  26. // back to top
  27. setTimeout(function () {
  28. var $sideBar = $('.bs-sidebar')
  29. $sideBar.affix({
  30. offset: {
  31. top: function () {
  32. var offsetTop = $sideBar.offset().top
  33. var sideBarMargin = parseInt($sideBar.children(0).css('margin-top'), 10)
  34. var navOuterHeight = $('.bs-docs-nav').height()
  35. return (this.top = offsetTop - navOuterHeight - sideBarMargin)
  36. }
  37. , bottom: function () {
  38. return (this.bottom = $('.bs-footer').outerHeight(true))
  39. }
  40. }
  41. })
  42. }, 100)
  43. })
  44. }(window.jQuery)