application.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. // IE10 viewport hack for Surface/desktop Windows 8 bug
  13. //
  14. // See Getting Started docs for more information
  15. if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
  16. var msViewportStyle = document.createElement("style");
  17. msViewportStyle.appendChild(
  18. document.createTextNode(
  19. "@-ms-viewport{width:auto!important}"
  20. )
  21. );
  22. document.getElementsByTagName("head")[0].
  23. appendChild(msViewportStyle);
  24. }
  25. var $window = $(window)
  26. var $body = $(document.body)
  27. var navHeight = $('.navbar').outerHeight(true) + 10
  28. $body.scrollspy({
  29. target: '.bs-sidebar',
  30. offset: navHeight
  31. })
  32. $window.on('load', function () {
  33. $body.scrollspy('refresh')
  34. })
  35. $('.bs-docs-container [href=#]').click(function (e) {
  36. e.preventDefault()
  37. })
  38. // back to top
  39. setTimeout(function () {
  40. var $sideBar = $('.bs-sidebar')
  41. $sideBar.affix({
  42. offset: {
  43. top: function () {
  44. var offsetTop = $sideBar.offset().top
  45. var sideBarMargin = parseInt($sideBar.children(0).css('margin-top'), 10)
  46. var navOuterHeight = $('.bs-docs-nav').height()
  47. return (this.top = offsetTop - navOuterHeight - sideBarMargin)
  48. }
  49. , bottom: function () {
  50. return (this.bottom = $('.bs-footer').outerHeight(true))
  51. }
  52. }
  53. })
  54. }, 100)
  55. setTimeout(function () {
  56. $('.bs-top').affix()
  57. }, 100)
  58. // tooltip demo
  59. $('.tooltip-demo').tooltip({
  60. selector: "[data-toggle=tooltip]",
  61. container: "body"
  62. })
  63. $('.tooltip-test').tooltip()
  64. $('.popover-test').popover()
  65. $('.bs-docs-navbar').tooltip({
  66. selector: "a[data-toggle=tooltip]",
  67. container: ".bs-docs-navbar .nav"
  68. })
  69. // popover demo
  70. $("[data-toggle=popover]")
  71. .popover()
  72. // button state demo
  73. $('#fat-btn')
  74. .click(function () {
  75. var btn = $(this)
  76. btn.button('loading')
  77. setTimeout(function () {
  78. btn.button('reset')
  79. }, 3000)
  80. })
  81. })
  82. }(jQuery)