(function (a) { a.fn.hovercard = function (b) { var c = { width: 300, openOnLeft: false, cardImgSrc: "", detailsHTML: "", twitterScreenName: "", showTwitterCard: false, facebookUserName: "", showFacebookCard: false, background: "#66e275", onHoverIn: function () { }, onHoverOut: function () { } }; var b = a.extend(c, b); if (a("#css-hovercard").length <= 0) { var d = '<style id="css-hovercard" type="text/css">' + ".hc-preview { position: relative; display:inline; }" + ".hc-name { font-weight:bold; position:relative; display:inline-block; }" + ".hc-details { color:#008110; line-height:1.5em; border:solid 1px #008110; position:absolute;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;top:-10px;z-index:50;padding:2em 10px 10px;-moz-box-shadow:5px 5px 5px #008110;-webkit-box-shadow:5px 5px 5px #008110;box-shadow:5px 5px 5px #008110;display:none;}" + ".hc-pic { width:70px; margin-top:-1em; }" + ".hc-details-open-right {left:-10px; margin-right:80px; text-align:left; } " + ".hc-details-open-right > .hc-pic { float:right; }" + ".hc-details-open-left { right:-10px; text-align:right; margin-left:80px; } " + ".hc-details-open-left > .hc-pic { float:left; } " + ".hc-details .s-action{ position: absolute; top:8px; right:5px; } " + ".hc-details .s-card{ border-top: solid 1px #eee; margin-top:10px; padding-top:10px; overflow:hidden; } " + ".hc-details .s-card .s-strong{ font-weight:bold; color: #555; } " + ".hc-details .s-img{ float: left; margin-right: 10px;} " + ".hc-details .s-name{ color:#222; font-weight:bold;} " + ".hc-details .s-loc{ float:left;} " + ".hc-details .s-href{ clear:both; float:left;} " + ".hc-details .s-desc{ float:left; font-family: Georgia; font-style: italic; margin-top:5px;width:100%;} " + ".hc-details .s-username{ text-decoration:none;} " + ".hc-details .s-stats { display:block; float:left; margin-top:5px; clear:both; padding:0px;}" + ".hc-details .s-stats li{ list-style:none; float:left; display:block; padding:0px 10px; border-left:solid 1px #eaeaea;} " + ".hc-details .s-stats li:first-child{ border:none; padding-left:0;} " + ".hc-details .s-count { font-weight: bold;} " + '.</style>")'; a(d).appendTo("head") } return this.each(function () { function g(b, c, d) { var e, f, g, h, i; switch (b) { case "twitter": { f = "http://api.twitter.com/1/users/lookup.json?screen_name=" + c; e = function (a) { a = a[0]; return '<div class="s-card">' + (a.profile_image_url ? '<img class="s-img" src="' + a.profile_image_url + '" />' : "") + (a.name ? '<label class="s-name">' + a.name + " </label>" : "") + (a.screen_name ? '(<a class="s-username" title="Visit Twitter profile for "' + a.name + '" href="http://twitter.com/' + a.screen_name + '">@' + a.screen_name + "</a>)<br/>" : "") + (a.location ? '<label class="s-loc">' + a.location + "</label>" : "") + (a.description ? '<p class="s-desc">' + a.description + "</p>" : "") + (a.url ? '<a class="s-href" href="' + a.url + '">' + a.url + "</a><br/>" : "") + '<ul class="s-stats">' + (a.statuses_count ? '<li>Tweets<br /><span class="s-count">' + a.statuses_count + "</span></li>" : "") + (a.friends_count ? '<li>Following<br /><span class="s-count">' + a.friends_count + "</span></li>" : "") + (a.followers_count ? '<li>Followers<br /><span class="s-count">' + a.followers_count + "</span></li>" : "") + "</ul>" + "</div>" }; h = "Contacting Twitter..."; i = "Invalid username or you have exceeded Twitter request limit.<br/><small>Please note, Twitter only allows 150 requests per hour.</small>"; g = function () { }; if (a("#t-follow-script").length <= 0) { var j = document.createElement("script"); j.type = "text/javascript"; j.src = "//platform.twitter.com/widgets.js"; j.id = "t-follow-script"; a("body").append(j) } d.append('<span class="s-action"><a href="https://twitter.com/' + c + '" data-show-count="false" data-button="grey" data-width="65px" class="twitter-follow-button">Follow</a></span>') } break; case "facebook": { f = "https://graph.facebook.com/" + c, e = function (a) { return '<div class="s-card">' + '<img class="s-img" src="http://graph.facebook.com/' + a.id + '/picture" />' + '<label class="s-name">' + a.name + " </label><br/>" + (a.link ? '<a class="s-loc" href="' + a.link + '">' + a.link + "</a><br/>" : "") + (a.likes ? '<label class="s-loc">Liked by </span> ' + a.likes + "</label><br/>" : "") + (a.description ? '<p class="s-desc">' + a.description + "</p>" : "") + (a.start_time ? '<p class="s-desc"><span class="s-strong">Start Time:</span><br/>' + a.start_time + "</p>" : "") + (a.end_time ? '<p class="s-desc"><span class="s-strong">End Time:<br/>' + a.end_time + "</p>" : "") + (a.founded ? '<p class="s-desc"><span class="s-strong">Founded:</span><br/>' + a.founded + "</p>" : "") + (a.mission ? '<p class="s-desc"><span class="s-strong">Mission:</span><br/>' + a.mission + "</p>" : "") + (a.company_overview ? '<p class="s-desc"><span class="s-strong">Overview:</span><br/>' + a.company_overview + "</p>" : "") + (a.products ? '<p class="s-desc"><span class="s-strong">Products:</span><br/>' + a.products + "</p>" : "") + (a.website ? '<p class="s-desc"><span class="s-strong">Web:</span><br/><a href="' + a.website + '">' + a.website + "</a></p>" : "") + (a.email ? '<p class="s-desc"><span class="s-strong">Email:</span><br/><a href="' + a.email + '">' + a.email + "</a></p>" : "") + "</div>" }; h = "Contacting Facebook..."; i = "The requested user, page, or event could not be found. Please try a different one."; g = function (b) { if (a("#fb-like-script").length <= 0) { var c = document.createElement("script"); c.type = "text/javascript"; c.text = "(function(d, s, id) {" + "var js, fjs = d.getElementsByTagName(s)[0];" + "if (d.getElementById(id)) {return;}" + "js = d.createElement(s); js.id = id;" + 'js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=140270912730552";' + "fjs.parentNode.insertBefore(js, fjs);" + '}(document, "script", "facebook-jssdk"));'; c.id = "fb-like-script"; a("body").prepend(c); a("body").prepend('<div id="fb-root"></div>') } d.append('<span class="s-action"><div class="fb-like" data-href="' + b.link + '" data-send="false" data-layout="button_count" data-width="90" data-show-faces="false"></div></span>') } } break; default: { } break } a.ajax({ url: f, type: "GET", dataType: "jsonp", timeout: 4e3, beforeSend: function () { d.find(".s-message").remove(); d.append('<p class="s-message">' + h + "</p>") }, success: function (a) { if (a.length <= 0) { d.find(".s-message").html(i) } else { d.find(".s-message").remove(); d.prepend(e(a)); g(a) } }, error: function (a, b, c) { d.find(".s-message").html(i) } }) } var c = a(this); c.wrap('<div class="hc-preview" />'); c.addClass("hc-name"); var d = ""; if (b.cardImgSrc.length > 0) { d = '<img class="hc-pic" src="' + b.cardImgSrc + '" />' } var e = '<div class="hc-details" >' + d + b.detailsHTML + "</div>"; c.after(e); c.siblings(".hc-details").eq(0).css({ width: b.width, background: b.background }); var f = window.innerWidth ? window.innerWidth : a(window).width(); if (jQuery.browser.msie && parseInt(jQuery.browser.version) == 7) { f -= 3 } c.closest(".hc-preview").hover(function () { c.css("zIndex", "100"); var d = a(this); var e = 0; e = d.offset().left + b.width + 10; var h = d.find(".hc-details").eq(0); if (e > f || b.openOnLeft) { h.removeClass("hc-details-open-right").addClass("hc-details-open-left").stop(true, true).fadeIn() } else { h.removeClass("hc-details-open-left").addClass("hc-details-open-right").stop(true, true).fadeIn() } if (typeof b.onHoverIn == "function") { if (b.showTwitterCard && h.find(".s-card").length <= 0) { var i = b.twitterScreenName.length > 0 ? b.twitterScreenName : c.text(); g("twitter", i, h) } if (b.showFacebookCard && h.find(".s-card").length <= 0) { var j = b.facebookUserName.length > 0 ? b.facebookUserName : c.text(); g("facebook", j, h) } b.onHoverIn.call(this) } }, function () { c.css("zIndex", "0"); a(this).find(".hc-details").eq(0).stop(true, true).fadeOut(300, function () { if (typeof b.onHoverOut == "function") { b.onHoverOut.call(this) } }) }); }) } })(jQuery)
