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