diff options
Diffstat (limited to 'js/bootstrap-popover.js')
| -rw-r--r-- | js/bootstrap-popover.js | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/js/bootstrap-popover.js b/js/bootstrap-popover.js index 890f6efc0..a0495ce69 100644 --- a/js/bootstrap-popover.js +++ b/js/bootstrap-popover.js @@ -23,10 +23,7 @@ "use strict" var Popover = function ( element, options ) { - this.$element = $(element) - this.options = options - this.enabled = true - this.fixTitle() + this.init('popover', element, options) } /* NOTE: POPOVER EXTENDS BOOTSTRAP-TWIPSY.js @@ -53,14 +50,13 @@ , getContent: function () { var content - , $e = this.$element - , o = this.options + , $e = this.$element + , o = this.options - if (typeof this.options.content == 'string') { - content = $e.attr(this.options.content) - } else if (typeof this.options.content == 'function') { - content = this.options.content.call(this.$element[0]) - } + content = $e.attr('data-content') + || (typeof o.content == 'function' ? o.content.call($e[0]) : o.content) + + content = content.toString().replace(/(^\s*|\s*$)/, "") return content } @@ -79,18 +75,22 @@ /* POPOVER PLUGIN DEFINITION * ======================= */ - $.fn.popover = function (options) { - if (typeof options == 'object') options = $.extend({}, $.fn.popover.defaults, options) - $.fn.twipsy.initWith.call(this, options, Popover, 'popover') - return this + $.fn.popover = function ( option ) { + return this.each(function () { + var $this = $(this) + , data = $this.data('popover') + , options = typeof option == 'object' && option + if (!data) $this.data('popover', (data = new Popover(this, options))) + if (typeof option == 'string') data[option]() + }) } + $.fn.popover.Popover = Popover + $.fn.popover.defaults = $.extend({} , $.fn.twipsy.defaults, { placement: 'right' - , content: 'data-content' + , content: '' , template: '<div class="arrow"></div><div class="inner"><h3 class="title"></h3><div class="content"><p></p></div></div>' }) - $.fn.twipsy.rejectAttrOptions.push( 'content' ) - -}( window.jQuery || window.ender )
\ No newline at end of file +}( window.jQuery )
\ No newline at end of file |
