application.js 2.46 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
 * JavaScript for Bootstrap's docs (http://getbootstrap.com)
7
 * Copyright 2011-2014 Twitter, Inc.
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/)) {
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').appendChild(msViewportStyle)
28
29
30
    }


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
      target: '.bs-sidebar',
Mark Otto's avatar
Mark Otto committed
38
      // offset: navHeight
fat's avatar
fat committed
39
40
    })

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
          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)
61
62
          },
          bottom: function () {
fat's avatar
fat committed
63
64
            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({
XhmikosR's avatar
XhmikosR committed
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
    $('.bs-docs-navbar').tooltip({
XhmikosR's avatar
XhmikosR committed
83
84
      selector: 'a[data-toggle=tooltip]',
      container: '.bs-docs-navbar .nav'
Mark Otto's avatar
Mark Otto committed
85
86
    })

Jacob Thornton's avatar
Jacob Thornton committed
87
    // popover demo
Mark Otto's avatar
quotes    
Mark Otto committed
88
    $('[data-toggle=popover]').popover()
Jacob Thornton's avatar
Jacob Thornton committed
89
90

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

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