application.js 2.58 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
    // theme toggler
    ;(function () {
      var stylesheetLink = $('#bs-theme-stylesheet')
Mark Otto's avatar
Mark Otto committed
59
      var themeBtn = $('.bs-docs-theme-toggle')
60
      themeBtn.click(function () {
61
62
        var href = stylesheetLink.attr('href');
        if (!href || href.indexOf('data') === 0) {
63
          stylesheetLink.attr('href', stylesheetLink.attr('data-href'))
Mark Otto's avatar
Mark Otto committed
64
          themeBtn.text('Disable theme preview')
65
        }
66
67
        else {
          stylesheetLink.attr('href', '')
Mark Otto's avatar
Mark Otto committed
68
          themeBtn.text('Preview theme')
69
        }
70
71
72
      })
    })();

Jacob Thornton's avatar
Jacob Thornton committed
73
    // tooltip demo
74
    $('.tooltip-demo').tooltip({
75
      selector: '[data-toggle="tooltip"]',
XhmikosR's avatar
XhmikosR committed
76
      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({
83
      selector: 'a[data-toggle="tooltip"]',
XhmikosR's avatar
XhmikosR committed
84
      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
Mark Otto committed
88
89
90
91
92
93
    $('.bs-docs-popover').popover()

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

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

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