diff --git a/examples/example1.html b/examples/example1.html new file mode 100644 index 0000000..12a9e02 --- /dev/null +++ b/examples/example1.html @@ -0,0 +1,31 @@ + + +
+ ++ This tipsy example covers the usage of .tipsy("visible") +
+ Example Target (click me to toggle tipsy) ++ + +
+ + \ No newline at end of file diff --git a/src/javascripts/jquery.tipsy.js b/src/javascripts/jquery.tipsy.js index f95c063..6050f63 100644 --- a/src/javascripts/jquery.tipsy.js +++ b/src/javascripts/jquery.tipsy.js @@ -88,6 +88,16 @@ } }, + visible: function() { + if (typeof this.$tip == 'undefined') { + return false; + } + + return this.$tip.css('opacity') != 0 + && this.$tip.height() + && this.$tip.width(); + }, + fixTitle: function() { var $e = this.$element; if ($e.attr('title') || typeof($e.attr('original-title')) != 'string') { @@ -131,10 +141,12 @@ $.fn.tipsy = function(options) { + var tipsy = this.data('tipsy'); if (options === true) { - return this.data('tipsy'); + return tipsy; + } else if (options == ':visible') { + return tipsy.visible(); } else if (typeof options == 'string') { - var tipsy = this.data('tipsy'); if (tipsy) tipsy[options](); return this; }