Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Helper function for call or return idiom

  • Loading branch information...
commit f5563566c1e8398e0fb7dd8b688fbb0f3715aae1 1 parent fa497c1
@jaz303 authored
Showing with 8 additions and 5 deletions.
  1. +8 −5 src/javascripts/jquery.tipsy.js
View
13 src/javascripts/jquery.tipsy.js
@@ -5,12 +5,16 @@
(function($) {
+ function maybeCall(thing, ctx) {
+ return (typeof thing == 'function') ? (thing.call(ctx)) : thing;
+ };
+
function Tipsy(element, options) {
this.$element = $(element);
this.options = options;
this.enabled = true;
this.fixTitle();
- }
+ };
Tipsy.prototype = {
show: function() {
@@ -27,10 +31,9 @@
height: this.$element[0].offsetHeight
});
- var actualWidth = $tip[0].offsetWidth, actualHeight = $tip[0].offsetHeight;
- var gravity = (typeof this.options.gravity == 'function')
- ? this.options.gravity.call(this.$element[0])
- : this.options.gravity;
+ var actualWidth = $tip[0].offsetWidth,
+ actualHeight = $tip[0].offsetHeight,
+ gravity = maybeCall(this.options.gravity, this.$element[0]);
var tp;
switch (gravity.charAt(0)) {
Please sign in to comment.
Something went wrong with that request. Please try again.