Skip to content

Commit b15e24e

Browse files
committed
don't include data-content/data-title as specifications for options in twipsy/popover
1 parent c3c700f commit b15e24e

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

docs/javascript.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ <h3>Options</h3>
677677
<td>content</td>
678678
<td>string, function</td>
679679
<td>'data-content'</td>
680-
<td>a string or method for retrieving content text. if none are provided, content will be sourced from a data-content attribute.</td>
680+
<td>attribute or method for retrieving content text.</td>
681681
</tr>
682682
<tr>
683683
<td>trigger</td>

js/bootstrap-popover.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@
5151
, o = this.options
5252

5353
if (typeof this.options.content == 'string') {
54-
content = this.options.content
54+
content = $e.attr(this.options.content)
5555
} else if (typeof this.options.content == 'function') {
5656
content = this.options.content.call(this.$element[0])
5757
}
58+
5859
return content
5960
}
6061

@@ -80,7 +81,10 @@
8081

8182
$.fn.popover.defaults = $.extend({} , $.fn.twipsy.defaults, {
8283
placement: 'right'
84+
, content: 'data-content'
8385
, template: '<div class="arrow"></div><div class="inner"><h3 class="title"></h3><div class="content"><p></p></div></div>'
8486
})
8587

88+
$.fn.twipsy.rejectAttrOptions.push( 'content' )
89+
8690
}( window.jQuery || window.ender );

js/bootstrap-twipsy.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,18 @@
304304
, template: '<div class="twipsy-arrow"></div><div class="twipsy-inner"></div>'
305305
}
306306

307+
$.fn.twipsy.rejectAttrOptions = [ 'title' ]
308+
307309
$.fn.twipsy.elementOptions = function(ele, options) {
308-
return $.extend({}, options, $(ele).data())
310+
var data = $(ele).data()
311+
, rejects = $.fn.twipsy.rejectAttrOptions
312+
, i = rejects.length
313+
314+
while (i--) {
315+
delete data[rejects[i]]
316+
}
317+
318+
return $.extend({}, options, data)
309319
}
310320

311321
}( window.jQuery || window.ender );

0 commit comments

Comments
 (0)