application.js 2.41 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
/*!
 * Copyright 2013 Twitter, Inc.
7
8
9
 *
 * Licensed under the Creative Commons Attribution 3.0 Unported License. For
 * details, see http://creativecommons.org/licenses/by/3.0/.
10
11
 */

12

13
!function ($) {
14

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

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


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

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

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

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

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

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

      $sideBar.affix({
Mark Otto's avatar
Mark Otto committed
55
        offset: {
fat's avatar
fat committed
56
57
58
59
60
61
          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)
62
63
          },
          bottom: function () {
fat's avatar
fat committed
64
65
            return (this.bottom = $('.bs-footer').outerHeight(true))
          }
Mark Otto's avatar
Mark Otto committed
66
67
68
        }
      })
    }, 100)
69

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

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

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

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

Jacob Thornton's avatar
Jacob Thornton committed
88
    // popover demo
XhmikosR's avatar
XhmikosR committed
89
    $('[data-toggle=popover]')
Jacob Thornton's avatar
Jacob Thornton committed
90
91
92
      .popover()

    // button state demo
93
    $('#loading-example-btn')
Jacob Thornton's avatar
Jacob Thornton committed
94
95
96
97
98
99
100
      .click(function () {
        var btn = $(this)
        btn.button('loading')
        setTimeout(function () {
          btn.button('reset')
        }, 3000)
      })
101
  })
102

Zlatan Vasović's avatar
Zlatan Vasović committed
103
}(jQuery)