From 640fd15464306238de99a3391888a95156e27995 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sat, 29 Oct 2011 19:27:02 -0700 Subject: [PATCH] allow the use of data attributes to define popover options --- docs/javascript.html | 6 +++++- js/bootstrap-popover.js | 4 ++-- js/bootstrap-twipsy.js | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/javascript.html b/docs/javascript.html index 47edf2b751..3aac2a82f8 100644 --- a/docs/javascript.html +++ b/docs/javascript.html @@ -555,6 +555,8 @@ $('#.tabs').bind('change', function (e) { +

Notice Individual twipsy instance options can alternatively be specified through the use of data attributes.

+
<a href="#" data-placement="below" rel='twipsy' title='Some title text'>text</a>

Methods

$().twipsy(options)

Attaches a twipsy handler to an element collection.

@@ -669,7 +671,7 @@ $('#.tabs').bind('change', function (e) { content string, function 'data-content' - attribute or method for retrieving content text + a string or method for retrieving content text. if none are provided, content will be sourced from a data-content attribute. trigger @@ -679,6 +681,8 @@ $('#.tabs').bind('change', function (e) { +

Notice Individual popover instance options can alternatively be specified through the use of data attributes.

+
<a data-placement="below" href="#" class="btn danger" rel="popover">text</a>

Methods

$().popover(options)

Initializes popovers for an element collection.

diff --git a/js/bootstrap-popover.js b/js/bootstrap-popover.js index a8a1d8e7bb..e8f4ce096b 100644 --- a/js/bootstrap-popover.js +++ b/js/bootstrap-popover.js @@ -47,7 +47,7 @@ , o = this.options if (typeof this.options.content == 'string') { - content = $e.attr(o.content) + content = this.options.content } else if (typeof this.options.content == 'function') { content = this.options.content.call(this.$element[0]) } @@ -74,6 +74,6 @@ return this } - $.fn.popover.defaults = $.extend({} , $.fn.twipsy.defaults, { content: 'data-content', placement: 'right'}) + $.fn.popover.defaults = $.extend({} , $.fn.twipsy.defaults, { placement: 'right'}) }( window.jQuery || window.ender ); \ No newline at end of file diff --git a/js/bootstrap-twipsy.js b/js/bootstrap-twipsy.js index ad2938a1a8..f0e5b1b90d 100644 --- a/js/bootstrap-twipsy.js +++ b/js/bootstrap-twipsy.js @@ -299,7 +299,7 @@ } $.fn.twipsy.elementOptions = function(ele, options) { - return $.metadata ? $.extend({}, options, $(ele).metadata()) : options + return $.extend({}, options, $(ele).data()) } }( window.jQuery || window.ender ); \ No newline at end of file