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
 * 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

Jacob Thornton's avatar
Jacob Thornton committed
34
    $body.scrollspy({
XhmikosR's avatar
XhmikosR committed
35
      target: '.bs-docs-sidebar'
fat's avatar
fat committed
36
37
    })

38
39
40
41
    $window.on('load', function () {
      $body.scrollspy('refresh')
    })

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

46
    // back to top
Mark Otto's avatar
Mark Otto committed
47
    setTimeout(function () {
48
      var $sideBar = $('.bs-docs-sidebar')
fat's avatar
fat committed
49
50

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

66
    setTimeout(function () {
Mark Otto's avatar
Mark Otto committed
67
      $('.bs-top').affix()
68
69
    }, 100)

Jacob Thornton's avatar
Jacob Thornton committed
70
    // tooltip demo
71
    $('.tooltip-demo').tooltip({
XhmikosR's avatar
XhmikosR committed
72
73
      selector: '[data-toggle=tooltip]',
      container: 'body'
Jacob Thornton's avatar
Jacob Thornton committed
74
    })
75

76
77
    $('.tooltip-test').tooltip()
    $('.popover-test').popover()
Jacob Thornton's avatar
Jacob Thornton committed
78

Mark Otto's avatar
Mark Otto committed
79
    $('.bs-docs-navbar').tooltip({
XhmikosR's avatar
XhmikosR committed
80
81
      selector: 'a[data-toggle=tooltip]',
      container: '.bs-docs-navbar .nav'
Mark Otto's avatar
Mark Otto committed
82
83
    })

Jacob Thornton's avatar
Jacob Thornton committed
84
    // popover demo
Mark Otto's avatar
Mark Otto committed
85
86
87
88
89
90
    $('.bs-docs-popover').popover()

    // Popover dismiss on next click
    $('.bs-docs-popover-dismiss').popover({
      trigger: 'focus'
    })
Jacob Thornton's avatar
Jacob Thornton committed
91
92

    // 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)