application.js 2.52 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
    var $window = $(window)
Jacob Thornton's avatar
Jacob Thornton committed
18
    var $body   = $(document.body)
19

Jacob Thornton's avatar
Jacob Thornton committed
20
    $body.scrollspy({
XhmikosR's avatar
XhmikosR committed
21
      target: '.bs-docs-sidebar'
fat's avatar
fat committed
22
23
    })

24
25
26
27
    $window.on('load', function () {
      $body.scrollspy('refresh')
    })

Jacob Thornton's avatar
Jacob Thornton committed
28
    $('.bs-docs-container [href=#]').click(function (e) {
29
30
31
      e.preventDefault()
    })

32
    // back to top
Mark Otto's avatar
Mark Otto committed
33
    setTimeout(function () {
34
      var $sideBar = $('.bs-docs-sidebar')
fat's avatar
fat committed
35
36

      $sideBar.affix({
Mark Otto's avatar
Mark Otto committed
37
        offset: {
fat's avatar
fat committed
38
39
40
41
42
43
          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)
44
45
          },
          bottom: function () {
46
            return (this.bottom = $('.bs-docs-footer').outerHeight(true))
fat's avatar
fat committed
47
          }
Mark Otto's avatar
Mark Otto committed
48
49
50
        }
      })
    }, 100)
51

52
    setTimeout(function () {
Mark Otto's avatar
Mark Otto committed
53
      $('.bs-top').affix()
54
55
    }, 100)

56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
    // theme toggler
    ;(function () {
      var stylesheetLink = $('#bs-theme-stylesheet')
      var themeBtn = $('#bs-theme-btn')
      themeBtn.click(function () {
        if (stylesheetLink.attr('href')) {
          stylesheetLink.attr('href', '')
          themeBtn.text('Activate Theme')
        }
        else {
          stylesheetLink.attr('href', stylesheetLink.attr('data-href'))
          themeBtn.text('Deactivate Theme')
        }
      })
    })();

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

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

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

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

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

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

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