Skip to content

Commit

Permalink
don't include data-content/data-title as specifications for options i…
Browse files Browse the repository at this point in the history
…n twipsy/popover
  • Loading branch information
fat committed Nov 6, 2011
1 parent c3c700f commit b15e24e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/javascript.html
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ <h3>Options</h3>
<td>content</td>
<td>string, function</td>
<td>'data-content'</td>
<td>a string or method for retrieving content text. if none are provided, content will be sourced from a data-content attribute.</td>
<td>attribute or method for retrieving content text.</td>
</tr>
<tr>
<td>trigger</td>
Expand Down
6 changes: 5 additions & 1 deletion js/bootstrap-popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@
, o = this.options

if (typeof this.options.content == 'string') {
content = this.options.content
content = $e.attr(this.options.content)
} else if (typeof this.options.content == 'function') {
content = this.options.content.call(this.$element[0])
}

return content
}

Expand All @@ -80,7 +81,10 @@

$.fn.popover.defaults = $.extend({} , $.fn.twipsy.defaults, {
placement: 'right'
, content: 'data-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 );
12 changes: 11 additions & 1 deletion js/bootstrap-twipsy.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,18 @@
, template: '<div class="twipsy-arrow"></div><div class="twipsy-inner"></div>'
}

$.fn.twipsy.rejectAttrOptions = [ 'title' ]

$.fn.twipsy.elementOptions = function(ele, options) {
return $.extend({}, options, $(ele).data())
var data = $(ele).data()
, rejects = $.fn.twipsy.rejectAttrOptions
, i = rejects.length

while (i--) {
delete data[rejects[i]]
}

return $.extend({}, options, data)
}

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

0 comments on commit b15e24e

Please sign in to comment.