﻿
//Tipsy
(function(a) { a.fn.tipsy = function(e) { e = a.extend({}, a.fn.tipsy.defaults, e); return this.each(function() { var d = a.fn.tipsy.elementOptions(this, e); a(this).hover(function() { a.data(this, "cancel.tipsy", true); var c = a.data(this, "active.tipsy"); if (!c) { c = a('<div class="tipsy"><div class="tipsy-inner"/></div>'); c.css({ position: "absolute", zIndex: 1E5 }); a.data(this, "active.tipsy", c) } if (a(this).attr("title") || typeof a(this).attr("original-title") != "string") a(this).attr("original-title", a(this).attr("title") || "").removeAttr("title"); var b; if (typeof d.title == "string") b = a(this).attr(d.title == "title" ? "original-title" : d.title); else if (typeof d.title == "function") b = d.title.call(this); c.find(".tipsy-inner")[d.html ? "html" : "text"](b || d.fallback); b = a.extend({}, a(this).offset(), { width: this.offsetWidth, height: this.offsetHeight }); c.get(0).className = "tipsy"; c.remove().css({ top: 0, left: 0, visibility: "hidden", display: "block" }).appendTo(document.body); var f = c[0].offsetWidth, g = c[0].offsetHeight; switch ((typeof d.gravity == "function" ? d.gravity.call(this) : d.gravity).charAt(0)) { case "n": c.css({ top: b.top + b.height, left: b.left + b.width / 2 - f / 2 }).addClass("tipsy-north"); break; case "s": c.css({ top: b.top - g, left: b.left + b.width / 2 - f / 2 }).addClass("tipsy-south"); break; case "e": c.css({ top: b.top + b.height / 2 - g / 2, left: b.left - f }).addClass("tipsy-east"); break; case "w": c.css({ top: b.top + b.height / 2 - g / 2, left: b.left + b.width }).addClass("tipsy-west"); break } d.fade ? c.css({ opacity: 0, display: "block", visibility: "visible" }).animate({ opacity: 0.8 }) : c.css({ visibility: "visible" }) }, function() { a.data(this, "cancel.tipsy", false); var c = this; setTimeout(function() { if (!a.data(this, "cancel.tipsy")) { var b = a.data(c, "active.tipsy"); d.fade ? b.stop().fadeOut(function() { a(this).remove() }) : b.remove() } }, 100) }) }) }; a.fn.tipsy.elementOptions = function(e, d) { return a.metadata ? a.extend({}, d, a(e).metadata()) : d }; a.fn.tipsy.defaults = { fade: false, fallback: "", gravity: "n", html: false, title: "title" }; a.fn.tipsy.autoNS = function() { return a(this).offset().top > a(document).scrollTop() + a(window).height() / 2 ? "s" : "n" }; a.fn.tipsy.autoWE = function() { return a(this).offset().left > a(document).scrollLeft() + a(window).width() / 2 ? "e" : "w" } })(jQuery);
