Skip to content

Instantly share code, notes, and snippets.

@simon-lang
Created July 27, 2012 02:02
Show Gist options
  • Select an option

  • Save simon-lang/3185777 to your computer and use it in GitHub Desktop.

Select an option

Save simon-lang/3185777 to your computer and use it in GitHub Desktop.
tooltips.js
/*!
* ProjectName Tooltips
* @requires jQuery v1.7.2+
* @requires bootstrap-tooltip.js
*
* Simple wrapper for the Bootstrap Tooltip module
*
* @author Digicon http://www.digicon.com.au/
*/
;(function($) {
window.ProjectName.Tooltip = window.ProjectName.Tooltip || window.ProjectName.Module(function() {
var _selector = '.has-tooltip';
var _options = {
animation: true,
placement: 'bottom'
};
return {
init: function() {
this.ify($(_selector));
},
ify: function($el, additionalOptions) {
if (additionalOptions) {
_options = $.extend(_options, additionalOptions);
}
$el.find(_selector).tooltip(_options);
}
}
}());
})(jQuery);
// Reason for the .ify method... (Ajax!)
ProjectName.SearchForm = {
doSearch: function() {
$('.results').load(function() {
// $(this) == $('.results') (more or less)
ProjectName.Tooltip.ify($(this), {
placement: 'left'
});
});
}
}
ProjectName.SearchForm.doSearch();
@simon-lang
Copy link
Author

Untested!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment