application.js 2.6 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 ($) {
XhmikosR's avatar
XhmikosR committed
14
  'use strict';
15

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

18
    var $window = $(window)
Jacob Thornton's avatar
Jacob Thornton committed
19
    var $body   = $(document.body)
20

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

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

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

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

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

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

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

Jacob Thornton's avatar
Jacob Thornton committed
74
    // tooltip demo
75
    $('.tooltip-demo').tooltip({
76
      selector: '[data-toggle="tooltip"]',
XhmikosR's avatar
XhmikosR committed
77
      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({
84
      selector: 'a[data-toggle="tooltip"]',
XhmikosR's avatar
XhmikosR committed
85
      container: '.bs-docs-navbar .nav'
Mark Otto's avatar
Mark Otto committed
86
87
    })

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

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

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

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