application.js 3.82 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
 */

XhmikosR's avatar
XhmikosR committed
12
/* global ZeroClipboard, addAnchors */
13

14
!function ($) {
XhmikosR's avatar
XhmikosR committed
15
  'use strict';
16

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

19
20
21
    // // Scrollspy
    // var $window = $(window)
    // var $body   = $(document.body)
22

23
    // $body.scrollspy({
24
    //   target: '.active .bd-sidenav'
25
26
27
28
    // })
    // $window.on('load', function () {
    //   $body.scrollspy('refresh')
    // })
29

Mark Otto's avatar
Mark Otto committed
30
    // Kill links
31
32
33
    // $('[href=#]').click(function (e) {
    //   e.preventDefault()
    // })
34

Mark Otto's avatar
Mark Otto committed
35
    // Tooltip and popover demos
36
    $('.tooltip-demo').tooltip({
37
      selector: '[data-toggle="tooltip"]',
XhmikosR's avatar
XhmikosR committed
38
      container: 'body'
Jacob Thornton's avatar
Jacob Thornton committed
39
    })
40
41
42
43
    $('.popover-demo').popover({
      selector: '[data-toggle="popover"]',
      container: 'body'
    })
44

45
    // Demos within modals
46
47
    $('.tooltip-test').tooltip()
    $('.popover-test').popover()
Jacob Thornton's avatar
Jacob Thornton committed
48

49
    // Popover demos
50
    $('.bd-popover').popover()
Mark Otto's avatar
Mark Otto committed
51

Mark Otto's avatar
Mark Otto committed
52
    // Button state demo
53
    $('#loading-example-btn').on('click', function () {
54
      var $btn = $(this)
Mark Otto's avatar
Mark Otto committed
55
56
57
58
      btn.button('loading')
      setTimeout(function () {
        btn.button('reset')
      }, 3000)
Mark Otto's avatar
Mark Otto committed
59
    })
Jacob Thornton's avatar
Jacob Thornton committed
60

61
62
    // Modal relatedTarget demo
    $('#exampleModal').on('show.bs.modal', function (event) {
63
      var $button = $(event.relatedTarget) // Button that triggered the modal
64
65
66
      var recipient = button.data('whatever') // Extract info from data-* attributes
      // If necessary, you could initiate an AJAX request here (and then do the updating in a callback).
      // Update the modal's content. We'll use jQuery here, but you could use a data binding library or other methods instead.
67
      var $modal = $(this)
68
69
70
71
      modal.find('.modal-title').text('New message to ' + recipient)
      modal.find('.modal-body input').val(recipient)
    })

72
    // Activate animated progress bar
73
    $('.bd-activate-animated-progressbar').on('click', function () {
Mark Otto's avatar
Mark Otto committed
74
      $(this).prev('.progress-striped').toggleClass('progress-animated')
75
    })
Mark Otto's avatar
Mark Otto committed
76

Mark Otto's avatar
Mark Otto committed
77
78
79
    // Custom indeterminate checkbox
    $('.bs-example-indeterminate input').prop('indeterminate', true)

Mark Otto's avatar
Mark Otto committed
80
81
    // Config ZeroClipboard
    ZeroClipboard.config({
XhmikosR's avatar
XhmikosR committed
82
      moviePath: '/assets/flash/ZeroClipboard.swf',
Mark Otto's avatar
Mark Otto committed
83
84
85
      hoverClass: 'btn-clipboard-hover'
    })

XhmikosR's avatar
XhmikosR committed
86
    // Insert copy to clipboard button before .highlight
87
    $('.highlight').each(function () {
Mark Otto's avatar
Mark Otto committed
88
      var btnHtml = '<div class="zero-clipboard"><span class="btn-clipboard">Copy</span></div>'
XhmikosR's avatar
XhmikosR committed
89
      $(this).before(btnHtml)
Mark Otto's avatar
Mark Otto committed
90
91
    })
    var zeroClipboard = new ZeroClipboard($('.btn-clipboard'))
92
    var $htmlBridge = $('#global-zeroclipboard-html-bridge')
93
94

    // Handlers for ZeroClipboard
95
    zeroClipboard.on('load', function () {
96
      htmlBridge
Mark Otto's avatar
Mark Otto committed
97
98
        .data('placement', 'top')
        .attr('title', 'Copy to clipboard')
99
100
101
102
        .tooltip()
    })

    // Copy to clipboard
103
    zeroClipboard.on('dataRequested', function (client) {
104
105
106
107
108
      var highlight = $(this).parent().nextAll('.highlight').first()
      client.setText(highlight.text())
    })

    // Notify copy success and reset tooltip title
109
    zeroClipboard.on('complete', function () {
110
      htmlBridge
Mark Otto's avatar
Mark Otto committed
111
        .attr('title', 'Copied!')
112
113
        .tooltip('fixTitle')
        .tooltip('show')
Mark Otto's avatar
Mark Otto committed
114
        .attr('title', 'Copy to clipboard')
115
116
117
118
        .tooltip('fixTitle')
    })

    // Notify copy failure
119
    zeroClipboard.on('noflash wrongflash', function () {
120
      htmlBridge
Mark Otto's avatar
Mark Otto committed
121
        .attr('title', 'Flash required')
122
123
124
125
        .tooltip('fixTitle')
        .tooltip('show')
    })

126
  })
127

Zlatan Vasović's avatar
Zlatan Vasović committed
128
}(jQuery)
XhmikosR's avatar
XhmikosR committed
129
130
131

;(function () {
  'use strict';
132
133


134
  addAnchors('.bd-container > h2, .bd-container > h3, .bd-container > h4, .bd-container > h5');
XhmikosR's avatar
XhmikosR committed
135
})();