application.js 2.49 KB
Newer Older
1
2
3
// NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT
// IT'S ALL JUST JUNK FOR OUR DOCS!
// ++++++++++++++++++++++++++++++++++++++++++
4
5
6
7
8
9
10
/*!
 * Copyright 2013 Twitter, Inc.
 * This work is licensed under the Creative Commons Attribution 3.0 Unported License.
 * You should have received a copy of this license along with this work.
 * If not, visit http://creativecommons.org/licenses/by/3.0/ .
 */

11

12
!function ($) {
13

14
  $(function(){
Jacob Thornton's avatar
Jacob Thornton committed
15

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    // IE10 viewport hack for Surface/desktop Windows 8 bug
    //
    // See Getting Started docs for more information
    if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
      var msViewportStyle = document.createElement("style");
      msViewportStyle.appendChild(
        document.createTextNode(
          "@-ms-viewport{width:auto!important}"
        )
      );
      document.getElementsByTagName("head")[0].
        appendChild(msViewportStyle);
    }


31
    var $window = $(window)
Jacob Thornton's avatar
Jacob Thornton committed
32
    var $body   = $(document.body)
33

fat's avatar
fat committed
34
35
    var navHeight = $('.navbar').outerHeight(true) + 10

Jacob Thornton's avatar
Jacob Thornton committed
36
    $body.scrollspy({
fat's avatar
fat committed
37
38
39
40
      target: '.bs-sidebar',
      offset: navHeight
    })

41
42
43
44
    $window.on('load', function () {
      $body.scrollspy('refresh')
    })

Jacob Thornton's avatar
Jacob Thornton committed
45
    $('.bs-docs-container [href=#]').click(function (e) {
46
47
48
      e.preventDefault()
    })

49
    // back to top
Mark Otto's avatar
Mark Otto committed
50
    setTimeout(function () {
fat's avatar
fat committed
51
52
53
      var $sideBar = $('.bs-sidebar')

      $sideBar.affix({
Mark Otto's avatar
Mark Otto committed
54
        offset: {
fat's avatar
fat committed
55
56
57
58
59
60
61
62
63
64
          top: function () {
            var offsetTop      = $sideBar.offset().top
            var sideBarMargin  = parseInt($sideBar.children(0).css('margin-top'), 10)
            var navOuterHeight = $('.bs-docs-nav').height()

            return (this.top = offsetTop - navOuterHeight - sideBarMargin)
          }
        , bottom: function () {
            return (this.bottom = $('.bs-footer').outerHeight(true))
          }
Mark Otto's avatar
Mark Otto committed
65
66
67
        }
      })
    }, 100)
68

69
    setTimeout(function () {
Mark Otto's avatar
Mark Otto committed
70
      $('.bs-top').affix()
71
72
    }, 100)

Jacob Thornton's avatar
Jacob Thornton committed
73
    // tooltip demo
74
    $('.tooltip-demo').tooltip({
75
76
      selector: "[data-toggle=tooltip]",
      container: "body"
Jacob Thornton's avatar
Jacob Thornton committed
77
    })
78

79
80
    $('.tooltip-test').tooltip()
    $('.popover-test').popover()
Jacob Thornton's avatar
Jacob Thornton committed
81

Mark Otto's avatar
Mark Otto committed
82
83
84
85
86
    $('.bs-docs-navbar').tooltip({
      selector: "a[data-toggle=tooltip]",
      container: ".bs-docs-navbar .nav"
    })

Jacob Thornton's avatar
Jacob Thornton committed
87
    // popover demo
88
    $("[data-toggle=popover]")
Jacob Thornton's avatar
Jacob Thornton committed
89
90
91
92
93
94
95
96
97
98
99
100
      .popover()

    // button state demo
    $('#fat-btn')
      .click(function () {
        var btn = $(this)
        btn.button('loading')
        setTimeout(function () {
          btn.button('reset')
        }, 3000)
      })
})
101

102
}(window.jQuery)