Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

113 lignes
3.6KB

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