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.

popover.js 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /* ========================================================================
  2. * Bootstrap: popover.js v3.3.2
  3. * http://getbootstrap.com/javascript/#popovers
  4. * ========================================================================
  5. * Copyright 2011-2015 Twitter, Inc.
  6. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  7. * ======================================================================== */
  8. +function ($) {
  9. 'use strict';
  10. // POPOVER PUBLIC CLASS DEFINITION
  11. // ===============================
  12. var Popover = function (element, options) {
  13. this.init('popover', element, options)
  14. }
  15. if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
  16. Popover.VERSION = '3.3.2'
  17. Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
  18. placement: 'right',
  19. trigger: 'click',
  20. content: '',
  21. template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
  22. })
  23. // NOTE: POPOVER EXTENDS tooltip.js
  24. // ================================
  25. Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
  26. Popover.prototype.constructor = Popover
  27. Popover.prototype.getDefaults = function () {
  28. return Popover.DEFAULTS
  29. }
  30. Popover.prototype.setContent = function () {
  31. var $tip = this.tip()
  32. var title = this.getTitle()
  33. var content = this.getContent()
  34. $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
  35. $tip.find('.popover-content').children().detach().end()[ // we use append for html objects to maintain js events
  36. this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text'
  37. ](content)
  38. $tip.removeClass('fade top bottom left right in')
  39. // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
  40. // this manually by checking the contents.
  41. if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
  42. }
  43. Popover.prototype.hasContent = function () {
  44. return this.getTitle() || this.getContent()
  45. }
  46. Popover.prototype.getContent = function () {
  47. var $e = this.$element
  48. var o = this.options
  49. return $e.attr('data-content')
  50. || (typeof o.content == 'function' ?
  51. o.content.call($e[0]) :
  52. o.content)
  53. }
  54. Popover.prototype.arrow = function () {
  55. return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
  56. }
  57. Popover.prototype.tip = function () {
  58. if (!this.$tip) this.$tip = $(this.options.template)
  59. return this.$tip
  60. }
  61. // POPOVER PLUGIN DEFINITION
  62. // =========================
  63. function Plugin(option) {
  64. return this.each(function () {
  65. var $this = $(this)
  66. var data = $this.data('bs.popover')
  67. var options = typeof option == 'object' && option
  68. if (!data && option == 'destroy') return
  69. if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
  70. if (typeof option == 'string') data[option]()
  71. })
  72. }
  73. var old = $.fn.popover
  74. $.fn.popover = Plugin
  75. $.fn.popover.Constructor = Popover
  76. // POPOVER NO CONFLICT
  77. // ===================
  78. $.fn.popover.noConflict = function () {
  79. $.fn.popover = old
  80. return this
  81. }
  82. }(jQuery);