]>
Commit | Line | Data |
---|---|---|
91e44d91 S |
1 | // NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT |
2 | // IT'S ALL JUST JUNK FOR OUR DOCS! | |
3 | // ++++++++++++++++++++++++++++++++++++++++++ | |
4 | ||
5 | /*! | |
6 | * JavaScript for Bootstrap's docs (https://getbootstrap.com) | |
7 | * Copyright 2011-2017 The Bootstrap Authors | |
8 | * Copyright 2011-2017 Twitter, Inc. | |
9 | * Licensed under the Creative Commons Attribution 3.0 Unported License. For | |
10 | * details, see https://creativecommons.org/licenses/by/3.0/. | |
11 | */ | |
12 | ||
13 | /* global Clipboard, anchors */ | |
14 | ||
15 | (function ($) { | |
16 | 'use strict' | |
17 | ||
18 | $(function () { | |
19 | ||
20 | // Tooltip and popover demos | |
21 | $('.tooltip-demo').tooltip({ | |
22 | selector: '[data-toggle="tooltip"]', | |
23 | container: 'body' | |
24 | }) | |
25 | ||
26 | $('[data-toggle="popover"]').popover() | |
27 | ||
28 | // Demos within modals | |
29 | $('.tooltip-test').tooltip() | |
30 | $('.popover-test').popover() | |
31 | ||
32 | // Indeterminate checkbox example | |
33 | $('.bd-example-indeterminate [type="checkbox"]').prop('indeterminate', true) | |
34 | ||
35 | // Disable empty links in docs examples | |
36 | $('.bd-content [href="#"]').click(function (e) { | |
37 | e.preventDefault() | |
38 | }) | |
39 | ||
40 | // Modal relatedTarget demo | |
41 | $('#exampleModal').on('show.bs.modal', function (event) { | |
42 | var $button = $(event.relatedTarget) // Button that triggered the modal | |
43 | var recipient = $button.data('whatever') // Extract info from data-* attributes | |
44 | // If necessary, you could initiate an AJAX request here (and then do the updating in a callback). | |
45 | // Update the modal's content. We'll use jQuery here, but you could use a data binding library or other methods instead. | |
46 | var $modal = $(this) | |
47 | $modal.find('.modal-title').text('New message to ' + recipient) | |
48 | $modal.find('.modal-body input').val(recipient) | |
49 | }) | |
50 | ||
51 | // Activate animated progress bar | |
52 | $('.bd-toggle-animated-progress').on('click', function () { | |
53 | $(this).siblings('.progress').find('.progress-bar-striped').toggleClass('progress-bar-animated') | |
54 | }) | |
55 | ||
56 | // Insert copy to clipboard button before .highlight | |
57 | $('.highlight').each(function () { | |
58 | var btnHtml = '<div class="bd-clipboard"><span class="btn-clipboard" title="Copy to clipboard">Copy</span></div>' | |
59 | $(this).before(btnHtml) | |
60 | $('.btn-clipboard').tooltip() | |
61 | }) | |
62 | ||
63 | var clipboard = new Clipboard('.btn-clipboard', { | |
64 | target: function (trigger) { | |
65 | return trigger.parentNode.nextElementSibling | |
66 | } | |
67 | }) | |
68 | ||
69 | clipboard.on('success', function (e) { | |
70 | $(e.trigger) | |
71 | .attr('title', 'Copied!') | |
72 | .tooltip('_fixTitle') | |
73 | .tooltip('show') | |
74 | .attr('title', 'Copy to clipboard') | |
75 | .tooltip('_fixTitle') | |
76 | ||
77 | e.clearSelection() | |
78 | }) | |
79 | ||
80 | clipboard.on('error', function (e) { | |
81 | var modifierKey = /Mac/i.test(navigator.userAgent) ? '\u2318' : 'Ctrl-' | |
82 | var fallbackMsg = 'Press ' + modifierKey + 'C to copy' | |
83 | ||
84 | $(e.trigger) | |
85 | .attr('title', fallbackMsg) | |
86 | .tooltip('_fixTitle') | |
87 | .tooltip('show') | |
88 | .attr('title', 'Copy to clipboard') | |
89 | .tooltip('_fixTitle') | |
90 | }) | |
91 | ||
92 | }) | |
93 | ||
94 | }(jQuery)) | |
95 | ||
96 | ;(function () { | |
97 | 'use strict' | |
98 | ||
99 | anchors.options.placement = 'left' | |
100 | anchors.add('.bd-content > h1, .bd-content > h2, .bd-content > h3, .bd-content > h4, .bd-content > h5') | |
101 | }()) |