-
-
Save choyer/4350480 to your computer and use it in GitHub Desktop.
Fixed to address popover changes introduced in Bootstrap 2.2.2 as per changes in commit https://github.com/twitter/bootstrap/commit/32d425967a981838cb2e66701c0e814aeee8ab9c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!function ($) { | |
"use strict"; // jshint ;_; | |
/* POPOVER PUBLIC CLASS DEFINITION | |
* =============================== */ | |
var StatefulPopover = function ( element, options ) { | |
this.contentWasSet = false | |
this.init('statefulpopover', element, options) | |
} | |
/* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js | |
========================================== */ | |
StatefulPopover.prototype = $.extend({}, $.fn.popover.Constructor.prototype, { | |
constructor: StatefulPopover | |
, setContent: function () { | |
var $tip = this.tip() | |
, title = this.getTitle() | |
, content = this.getContent() | |
if(this.contentWasSet !== false) { | |
return; | |
} | |
this.contentWasSet = true; | |
$tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title) | |
$tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content) | |
$tip.removeClass('fade top bottom left right in') | |
} | |
}) | |
/* POPOVER PLUGIN DEFINITION | |
* ======================= */ | |
$.fn.statefulpopover = function (option) { | |
return this.each(function () { | |
var $this = $(this) | |
, data = $this.data('statefulpopover') | |
, options = typeof option == 'object' && option | |
if (!data) $this.data('statefulpopover', (data = new StatefulPopover(this, options))) | |
if (typeof option == 'string') data[option]() | |
}) | |
} | |
$.fn.statefulpopover.Constructor = StatefulPopover | |
$.fn.statefulpopover.defaults = $.extend({} , $.fn.popover.defaults, { | |
placement: 'right' | |
, content: '' | |
, template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"></div></div></div>' | |
}) | |
}(window.jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment