diff --git a/README b/README deleted file mode 100644 index 3f6c4c8..0000000 --- a/README +++ /dev/null @@ -1,18 +0,0 @@ -hovercard -Author: Prahsant Chaudhary (http://designwithpc.com) -Plugin Demos & Documentation: http://designwithpc.com/Plugins/Hovercard - -About this plugin: -A free light weight jQuery plugin that enables you to display related information with the hovered label, link, or any html element of your choice. - -Features include: - -Smoothly fades the name into a hovered card (in place). -Uses minimum css and no external stylesheets to download. -Full control over html to be displayed. -Comes with built in Twitter and Facebook hovercard. -Supports callback functions on hover in and hover out. -Auto adjust on the edges of viewport. - -When should you use hovercard: -A hovercard comes handy when displaying Person bio, Book author and price, Loading related information with Ajax, Editing in place, and what not! Check out the following demos to see some of this stuff in action :) \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..5e94bbe --- /dev/null +++ b/README.md @@ -0,0 +1,88 @@ +Hovercard +========= + +A free light weight jQuery plugin that enables you to display information +related with the hovered label, link, or any html element of your choice. + +See the [project page][1] for documentation, demonstration and examples. Released under the [MIT license][2]. + +Changelog: +---------- + +###Version 2.4 - 2012/04/12 +* **Added Options:** +* `autoAdjust` The plugin's default functionality to auto adjust to the viewport edges can now be overridden. + +###Version 2.3 - 2011/12/15 +* Enhancement: The plugin now auto adjust on the edges of visible window/viewport! +* **Added Options:** +* `openOnTop`: Set 'openOnTop' to true if you want the hovercard to always open on left. +* `customCardJSON`: Provide a local json data with showCustomCard. Inherits plugin's social card format/styles. +* `delay`: Delay the hovercard appearance on hover. + +###Version 2.2 - 2011/12/09 +* Bug Fixes: zindex issue with IE7. + +###Version 2.1 - 2011/11/22 +* Enhancement: attribute 'data-hovercard'. You may now use data-hovercard attribute with your label/link etc to set the twitter or facebook usernames. +* **Added Options:** +* `showCustomCard`: You may now add your own custom data source and display the profile data using existing card format. + +###Version 2.0 - 2011/11/08 +* Bug Fixes: zindex issue. +* Enhancements: Supercool built in social profile cards like Twitter and Facebook! +* **Added Options:** +* `showTwitterCard`: displays a built in twitter card format for a twitter screenname. Maximum 150 twitter lookup per hour. +* `twitterScreenName`: twitter screen name for the hovercard. If no username/screenname is provided, hovercard attempts to look up for hovered text. +* `showFacebookCard`: displays a built in facebook card format for a facebook username/pages/events etc. Works best with Facebook pages. +* `facebookUserName`: facebook username/pages/events/groups for the hovercard. If no username is provided, hovercard attempts to look up for hovered text. + +###Version 1.2 - 2011/09/30 +* Enhancement: The hovercard now adjust (either open on left or right) in accordance to the view port. +* **Added Options:** +* `openOnLeft`: force hovercard to open on left. (eg: if the hovered name appear in the end of sentence) + +###Version 1.1 - 2011/09/29 +* Bug fixed: When using hovercard in hovercard, the inner hovercard shows up as well when parent hovercard opens. + +###Version 1.0 - 2011/08/31 +* Initial Release. + +Installation: +------------- + +```sh +git clone https://github.com/prashantchaudhary/hovercard.git +cd hovercard +``` +You're ready yo use the **Hovercard**. + +Features: +--------- + - Smoothly fades the name into a hovered card (in place). + - Uses minimum `CSS` and no external Stylesheets to download. + - Full control over `HTML` to be displayed. + - Comes with built in Twitter and Facebook Hovercard. + - Supports callback functions on hover in and hover out. + - Auto adjust on the edges of viewport. + +Usage: +------ +Hovercard comes handy while displaying: + + - Person Biography. + - Author and Price of a Book. + - Loading related information with `AJAX`. + - In Place Editing and more... + +Author & Credits: +----------------- +[Prahsant Chaudhary][3] + +An Entrepreneur, Web Developer and Co-founder [MrRightIndia][4] and [Kaaryaa][5]. + + [1]: http://designwithpc.com/Plugins/Hovercard + [2]: http://www.opensource.org/licenses/mit-license.php + [3]: https://twitter.com/chaudharyp + [4]: http://mrright.in + [5]: http://kaaryaa.com diff --git a/jquery.hovercard.js b/jquery.hovercard.js index 2801eb0..c0bb1aa 100644 --- a/jquery.hovercard.js +++ b/jquery.hovercard.js @@ -1,51 +1,12 @@ -//Title: Hovercard plugin by PC -//Documentation: http://designwithpc.com/Plugins/Hovercard -//Author: PC -//Website: http://designwithpc.com -//Twitter: @chaudharyp -// -//Version 1.0 Aug 31st 2011 -First Release. -//Version 1.1 Sep 29th 2011 -//Bug fixed: When using hovercard in hovercard, the inner hovercard shows up as well when parent hovercard opens. -// -//Version 1.2 Sep 30th 2011 -//Enhancement: The hovercard now adjust (either open on left or right) in accordance to the view port. -//Added options: -//openOnLeft: force hovercard to open on left. (eg: if the hovered name appear in the end of sentence) -// -//Version 2.0 Nov 8th 2011 -//Bug Fixes: zindex issue. -//Enhancements: Supercool built in social profile cards like Twitter and Facebook! -//Added options: -//showTwitterCard: displays a built in twitter card format for a twitter screenname. Maximum 150 twitter lookup per hour. -//twitterScreenName: twitter screen name for the hovercard. If no username/screenname is provided, hovercard attempts to look up for hovered text. -//showFacebookCard: displays a built in facebook card format for a facebook username/pages/events etc. Works best with Facebook pages. -//facebookUserName: facebook username/pages/events/groups for the hovercard. If no username is provided, hovercard attempts to look up for hovered text. -// -//Version 2.1 Nov 22nd 2011 -//Enhancement: attribute 'data-hovercard'. You may now use data-hovercard attribute with your label/link etc to set the twitter or facebook usernames. -//Added options: -//showCustomCard: You may now add your own custom data source and display the profile data using existing card format. -// -//Version 2.2 Dec 9th 2011 -//Bug Fixes: zindex issue with IE7. -// -//Version 2.3 Dec 15th 2011 -//Enhancement: The plugin now auto adjust on the edges of visible window/viewport! -//Added options: -//openOnTop: Set 'openOnTop' to true if you want the hovercard to always open on left. -//customCardJSON: Provide a local json data with showCustomCard. Inherits plugin's social card format/styles. -//delay: Delay the hovercard appearance on hover. -// -//Version 2.4 Apr 12th 2012 -//Added options: -//autoAdjust: The plugin's default functionality to auto adjust to the viewport edges can now be overridden. - - -(function ($) { - $.fn.hovercard = function (options) { - - //Set defauls for the control +/*! + Version v2.4 - 2012/04/12 + jQuery hovercard plugin + (c) 2014 Prahsant Chaudhary - http:// designwithpc.com/Plugins/Hovercard + license: http:// www.opensource.org/licenses/mit-license.php +*/ +(function($) { + $.fn.hovercard = function(options) { + // Set defauls for the control var defaults = { width: 300, openOnLeft: false, @@ -62,154 +23,127 @@ background: "#ffffff", delay: 0, autoAdjust: true, - onHoverIn: function () { }, - onHoverOut: function () { } + onHoverIn: function() {}, + onHoverOut: function() {} }; - //Update unset options with defaults if needed + // Update unset options with defaults if needed var options = $.extend(defaults, options); - - //CSS for hover card. Change per your need, and move these styles to your stylesheet (recommended). + // CSS for hover card. Change per your need, and move these styles to your stylesheet (recommended). if ($('#css-hovercard').length <= 0) { var hovercardTempCSS = '")'; - + '.hc-preview { position: relative; display:inline; }' + + '.hc-name { font-weight:bold; position:relative; display:inline-block; }' + + '.hc-details { left:-10px; margin-right:80px; text-align:left; font-family:Sans-serif !important; font-size:12px !important; color:#666 !important; line-height:1.5em; border:solid 1px #ddd; position:absolute;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;top:-10px;padding:2em 10px 10px;-moz-box-shadow:5px 5px 5px #888;-webkit-box-shadow:5px 5px 5px #888;box-shadow:5px 5px 5px #888;display:none;}' + + '.hc-pic { width:70px; margin-top:-1em; float:right; }' + + '.hc-details-open-left { left: auto; right:-10px; text-align:right; margin-left:80px; margin-right:0; } ' + + '.hc-details-open-left > .hc-pic { float:left; } ' + + '.hc-details-open-top { bottom:-10px; top:auto; padding: 10px 10px 2em;} ' + + '.hc-details-open-top > .hc-pic { margin-top:10px; float:right; }' + + '.hc-details .s-action{ position: absolute; top:8px; right:5px; } ' + + '.hc-details .s-card-pad{ border-top: solid 1px #eee; margin-top:10px; padding-top:10px; overflow:hidden; } ' + + '.hc-details-open-top .s-card-pad { border:none; border-bottom: solid 1px #eee; margin-top:0;padding-top:0; margin-bottom:10px;padding-bottom:10px; }' + + '.hc-details .s-card .s-strong{ font-weight:bold; color: #555; } ' + + '.hc-details .s-img{ float: left; margin-right: 10px; max-width: 70px;} ' + + '.hc-details .s-name{ color:#222; font-weight:bold;} ' + + '.hc-details .s-loc{ float:left;}' + + '.hc-details-open-left .s-loc{ float:right;} ' + + '.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 ul.s-stats li{ list-style:none; float:left; display:block; padding:0px 10px !important; border-left:solid 1px #eaeaea;} ' + + '.hc-details ul.s-stats li:first-child{ border:none; padding-left:0 !important;} ' + + '.hc-details .s-count { font-weight: bold;} ' + + '.")'; $(hovercardTempCSS).appendTo('head'); } - //Executing functionality on all selected elements - return this.each(function () { + // Executing functionality on all selected elements + return this.each(function() { var obj = $(this); - - //wrap a parent span to the selected element + // wrap a parent span to the selected element obj.wrap('
'); - - //add a relatively positioned class to the selected element + // add a relatively positioned class to the selected element obj.addClass("hc-name"); - - //if card image src provided then generate the image elementk + // if card image src provided then generate the image elementk var hcImg = ''; if (options.cardImgSrc.length > 0) { hcImg = ''; } - - //generate details span with html provided by the user + // generate details span with html provided by the user var hcDetails = '
' + hcImg + options.detailsHTML + '
'; - - //append this detail after the selected element + // append this detail after the selected element obj.after(hcDetails); - obj.siblings(".hc-details").eq(0).css({ 'width': options.width, 'background': options.background }); - - //toggle hover card details on hover - obj.closest(".hc-preview").hover(function () { - + obj.siblings(".hc-details").eq(0).css({ + 'width': options.width, + 'background': options.background + }); + // toggle hover card details on hover + obj.closest(".hc-preview").hover(function() { var $this = $(this); adjustToViewPort($this); - - //Up the z indiex for the .hc-name to overlay on .hc-details + // Up the z indiex for the .hc-name to overlay on .hc-details $this.css("zIndex", "200"); obj.css("zIndex", "100").find('.hc-details').css("zIndex", "50"); - var curHCDetails = $this.find(".hc-details").eq(0); curHCDetails.stop(true, true).delay(options.delay).fadeIn(); - - - //Default functionality on hoverin, and also allows callback + // Default functionality on hoverin, and also allows callback if (typeof options.onHoverIn == 'function') { - - //check for custom profile. If already loaded don't load again + // check for custom profile. If already loaded don't load again if (options.showCustomCard && curHCDetails.find('.s-card').length <= 0) { - - //Read data-hovercard url from the hovered element, otherwise look in the options. For custom card, complete url is required than just username. + // Read data-hovercard url from the hovered element, otherwise look in the options. For custom card, complete url is required than just username. var dataUrl = options.customDataUrl; if (typeof obj.attr('data-hovercard') == 'undefined') { - //do nothing. detecting typeof obj.attr('data-hovercard') != 'undefined' didn't work as expected. + // do nothing. detecting typeof obj.attr('data-hovercard') != 'undefined' didn't work as expected. } else if (obj.attr('data-hovercard').length > 0) { dataUrl = obj.attr('data-hovercard'); } - LoadSocialProfile("custom", dataUrl, curHCDetails, options.customCardJSON); } - - //check for twitter profile. If already loaded don't load again + // check for twitter profile. If already loaded don't load again if (options.showTwitterCard && curHCDetails.find('.s-card').length <= 0) { - - //Look for twitter screen name in data-hovercard first, then in options, otherwise try with the hovered text + // Look for twitter screen name in data-hovercard first, then in options, otherwise try with the hovered text var tUsername = options.twitterScreenName.length > 0 ? options.twitterScreenName : obj.text(); if (typeof obj.attr('data-hovercard') == 'undefined') { - //do nothing. detecting typeof obj.attr('data-hovercard') != 'undefined' didn't work as expected. + // do nothing. detecting typeof obj.attr('data-hovercard') != 'undefined' didn't work as expected. } else if (obj.attr('data-hovercard').length > 0) { tUsername = obj.attr('data-hovercard'); } - LoadSocialProfile("twitter", tUsername, curHCDetails); } - - //check for facebook profile. If already loaded don't load again + // check for facebook profile. If already loaded don't load again if (options.showFacebookCard && curHCDetails.find('.s-card').length <= 0) { - - //Look for twitter screen name in data-hovercard first, then in options, otherwise try with the hovered text + // Look for twitter screen name in data-hovercard first, then in options, otherwise try with the hovered text var fbUsername = options.facebookUserName.length > 0 ? options.facebookUserName : obj.text(); if (typeof obj.attr('data-hovercard') == 'undefined') { - //do nothing. detecting typeof obj.attr('data-hovercard') != 'undefined' didn't work as expected. + // do nothing. detecting typeof obj.attr('data-hovercard') != 'undefined' didn't work as expected. } else if (obj.attr('data-hovercard').length > 0) { fbUsername = obj.attr('data-hovercard'); } - LoadSocialProfile("facebook", fbUsername, curHCDetails); } - - //Callback function + // Callback function options.onHoverIn.call(this); } - - }, function () { - //Undo the z indices + }, function() { + // Undo the z indices $this = $(this); - - $this.find(".hc-details").eq(0).stop(true, true).fadeOut(300, function () { + $this.find(".hc-details").eq(0).stop(true, true).fadeOut(300, function() { $this.css("zIndex", "0"); obj.css("zIndex", "0").find('.hc-details').css("zIndex", "0"); - if (typeof options.onHoverOut == 'function') { options.onHoverOut.call(this); } }); }); - - //Opening Directions adjustment + // Opening Directions adjustment function adjustToViewPort(hcPreview) { - var hcDetails = hcPreview.find('.hc-details').eq(0); var hcPreviewRect = hcPreview[0].getBoundingClientRect(); - - var hcdTop = hcPreviewRect.top - 20; //Subtracting 20px of padding; - var hcdRight = hcPreviewRect.left + 35 + hcDetails.width(); //Adding 35px of padding; - var hcdBottom = hcPreviewRect.top + 35 + hcDetails.height(); //Adding 35px of padding; - var hcdLeft = hcPreviewRect.top - 10; //Subtracting 10px of padding; - - //Check for forced open directions, or if need to be autoadjusted + var hcdTop = hcPreviewRect.top - 20; // Subtracting 20px of padding; + var hcdRight = hcPreviewRect.left + 35 + hcDetails.width(); // Adding 35px of padding; + var hcdBottom = hcPreviewRect.top + 35 + hcDetails.height(); // Adding 35px of padding; + var hcdLeft = hcPreviewRect.top - 10; // Subtracting 10px of padding; + // Check for forced open directions, or if need to be autoadjusted if (options.openOnLeft || (options.autoAdjust && (hcdRight > window.innerWidth))) { hcDetails.addClass("hc-details-open-left"); } else { @@ -221,82 +155,77 @@ hcDetails.removeClass("hc-details-open-top"); } } - - //Private base function to load any social profile + // Private base function to load any social profile function LoadSocialProfile(type, username, curHCDetails, customCardJSON) { var cardHTML, urlToRequest, customCallback, loadingHTML, errorHTML; - switch (type) { case "twitter": { - urlToRequest = 'http://api.twitter.com/1/users/lookup.json?screen_name=' + username; - cardHTML = function (profileData) { + urlToRequest = 'http:// api.twitter.com/1/users/lookup.json?screen_name=' + username; + cardHTML = function(profileData) { profileData = profileData[0]; return '
' + - (profileData.profile_image_url ? ('') : '') + - (profileData.name ? ('') : '') + - (profileData.screen_name ? ('(@' + profileData.screen_name + ')
') : '') + - (profileData.location ? ('') : '') + - (profileData.description ? ('

' + profileData.description + '

') : '') + - (profileData.url ? ('' + profileData.url + '
') : '') + - - '' + - '
'; + (profileData.profile_image_url ? ('') : '') + + (profileData.name ? ('') : '') + + (profileData.screen_name ? ('(@' + profileData.screen_name + ')
') : '') + + (profileData.location ? ('') : '') + + (profileData.description ? ('

' + profileData.description + '

') : '') + + (profileData.url ? ('' + profileData.url + '
') : '') + + '' + + '
'; }; loadingHTML = 'Contacting Twitter...'; errorHTML = 'Invalid username or you have exceeded Twitter request limit.
Please note, Twitter only allows 150 requests per hour.'; - customCallback = function () { }; - - //Append the twitter script to the document to add a follow button + customCallback = function() {}; + // Append the twitter script to the document to add a follow button if ($('#t-follow-script').length <= 0) { var script = document.createElement('script'); script.type = 'text/javascript'; - script.src = '//platform.twitter.com/widgets.js'; + script.src = '// platform.twitter.com/widgets.js'; script.id = 't-follow-script'; $('body').append(script); } - curHCDetails.append('Follow'); - + curHCDetails.append('Follow'); } break; case "facebook": { - urlToRequest = 'https://graph.facebook.com/' + username, - cardHTML = function (profileData) { + urlToRequest = 'https:// graph.facebook.com/' + username, + cardHTML = function(profileData) { return '
' + - '' + - '
' + - (profileData.link ? ('' + profileData.link + '
') : '') + - (profileData.likes ? ('
') : '') + - (profileData.description ? ('

' + profileData.description + '

') : '') + - (profileData.start_time ? ('

Start Time:
' + profileData.start_time + '

') : '') + - (profileData.end_time ? ('

End Time:
' + profileData.end_time + '

') : '') + - (profileData.founded ? ('

Founded:
' + profileData.founded + '

') : '') + - (profileData.mission ? ('

Mission:
' + profileData.mission + '

') : '') + - (profileData.company_overview ? ('

Overview:
' + profileData.company_overview + '

') : '') + - (profileData.products ? ('

Products:
' + profileData.products + '

') : '') + - (profileData.website ? ('

Web:
' + profileData.website + '

') : '') + - (profileData.email ? ('

Email:
' + profileData.email + '

') : '') + - '
'; + '' + + '
' + + (profileData.link ? ('' + profileData.link + '
') : '') + + (profileData.likes ? ('
') : '') + + (profileData.description ? ('

' + profileData.description + '

') : '') + + (profileData.start_time ? ('

Start Time:
' + profileData.start_time + '

') : '') + + (profileData.end_time ? ('

End Time:
' + profileData.end_time + '

') : '') + + (profileData.founded ? ('

Founded:
' + profileData.founded + '

') : '') + + (profileData.mission ? ('

Mission:
' + profileData.mission + '

') : '') + + (profileData.company_overview ? ('

Overview:
' + profileData.company_overview + '

') : '') + + (profileData.products ? ('

Products:
' + profileData.products + '

') : '') + + (profileData.website ? ('

Web:
' + profileData.website + '

') : '') + + (profileData.email ? ('

Email:
' + profileData.email + '

') : '') + + ''; }; loadingHTML = "Contacting Facebook..."; errorHTML = "The requested user, page, or event could not be found. Please try a different one."; - customCallback = function (profileData) { - //Append the twitter script to the document to add a follow button + customCallback = function(profileData) { + // Append the twitter script to the document to add a follow button if ($('#fb-like-script').length <= 0) { var script = document.createElement('script'); script.type = 'text/javascript'; script.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"));'; + '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"));'; script.id = 'fb-like-script'; $('body').prepend(script); $('body').prepend('
'); @@ -308,39 +237,39 @@ case "custom": { urlToRequest = username, - cardHTML = function (profileData) { + cardHTML = function(profileData) { return '
' + - (profileData.image ? ('') : '') + - (profileData.name ? ('
') : '') + - (profileData.link ? ('' + profileData.link + '
') : '') + - (profileData.bio ? ('

' + profileData.bio + '

') : '') + - (profileData.website ? ('

Web:
' + profileData.website + '

') : '') + - (profileData.email ? ('

Email:
' + profileData.email + '

') : '') + - '
'; + (profileData.image ? ('') : '') + + (profileData.name ? ('
') : '') + + (profileData.link ? ('' + profileData.link + '
') : '') + + (profileData.bio ? ('

' + profileData.bio + '

') : '') + + (profileData.website ? ('

Web:
' + profileData.website + '

') : '') + + (profileData.email ? ('

Email:
' + profileData.email + '

') : '') + + ''; }; loadingHTML = "Loading..."; errorHTML = "Sorry, no data found."; - customCallback = function () { }; + customCallback = function() {}; } break; - default: { } break; + default: + {} + break; } - if ($.isEmptyObject(customCardJSON)) { $.ajax({ url: urlToRequest, type: 'GET', - dataType: 'jsonp', //jsonp for cross domain request - timeout: 4000, //timeout if cross domain request didn't respond, or failed silently - beforeSend: function () { + dataType: 'jsonp', // jsonp for cross domain request + timeout: 4000, // timeout if cross domain request didn't respond, or failed silently + beforeSend: function() { curHCDetails.find('.s-message').remove(); curHCDetails.append('

' + loadingHTML + '

'); }, - success: function (data) { + success: function(data) { if (data.length <= 0) { curHCDetails.find('.s-message').html(errorHTML); - } - else { + } else { curHCDetails.find('.s-message').remove(); curHCDetails.prepend(cardHTML(data)); adjustToViewPort(curHCDetails.closest('.hc-preview')); @@ -348,16 +277,14 @@ customCallback(data); } }, - error: function (jqXHR, textStatus, errorThrown) { + error: function(jqXHR, textStatus, errorThrown) { curHCDetails.find('.s-message').html(errorHTML); } }); - } - else { + } else { curHCDetails.prepend(cardHTML(customCardJSON)); } }; }); - }; -})(jQuery); \ No newline at end of file +})(jQuery); diff --git a/jquery.hovercard.min.js b/jquery.hovercard.min.js index 474ec62..72fdd6d 100644 --- a/jquery.hovercard.min.js +++ b/jquery.hovercard.min.js @@ -1 +1,7 @@ -(function (a) { a.fn.hovercard = function (b) { var c = { width: 300, openOnLeft: false, openOnTop: false, cardImgSrc: "", detailsHTML: "", twitterScreenName: "", showTwitterCard: false, facebookUserName: "", showFacebookCard: false, showCustomCard: false, customCardJSON: {}, customDataUrl: "", background: "#ffffff", delay: 0, autoAdjust: true, onHoverIn: function () { }, onHoverOut: function () { } }; var b = a.extend(c, b); if (a("#css-hovercard").length <= 0) { var d = '")'; a(d).appendTo("head") } return this.each(function () { function g(c, d, e, g) { var h, i, j, k, l; switch (c) { case "twitter": { i = "http://api.twitter.com/1/users/lookup.json?screen_name=" + d; h = function (a) { a = a[0]; return '
' + (a.profile_image_url ? '' : "") + (a.name ? '" : "") + (a.screen_name ? '(@' + a.screen_name + ")
" : "") + (a.location ? '" : "") + (a.description ? '

' + a.description + "

" : "") + (a.url ? '' + a.url + "
" : "") + '" + "
" }; k = "Contacting Twitter..."; l = "Invalid username or you have exceeded Twitter request limit.
Please note, Twitter only allows 150 requests per hour."; j = function () { }; if (a("#t-follow-script").length <= 0) { var m = document.createElement("script"); m.type = "text/javascript"; m.src = "//platform.twitter.com/widgets.js"; m.id = "t-follow-script"; a("body").append(m) } e.append('Follow') } break; case "facebook": { i = "https://graph.facebook.com/" + d, h = function (a) { return '
' + '' + '
" + (a.link ? '' + a.link + "
" : "") + (a.likes ? '
" : "") + (a.description ? '

' + a.description + "

" : "") + (a.start_time ? '

Start Time:
' + a.start_time + "

" : "") + (a.end_time ? '

End Time:
' + a.end_time + "

" : "") + (a.founded ? '

Founded:
' + a.founded + "

" : "") + (a.mission ? '

Mission:
' + a.mission + "

" : "") + (a.company_overview ? '

Overview:
' + a.company_overview + "

" : "") + (a.products ? '

Products:
' + a.products + "

" : "") + (a.website ? '

Web:
' + a.website + "

" : "") + (a.email ? '

Email:
' + a.email + "

" : "") + "
" }; k = "Contacting Facebook..."; l = "The requested user, page, or event could not be found. Please try a different one."; j = 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('
') } e.append('
') } } break; case "custom": { i = d, h = function (a) { return '
' + (a.image ? '' + a.name + "
" : "") + (a.link ? '' + a.link + "
" : "") + (a.bio ? '

' + a.bio + "

" : "") + (a.website ? '

Web:
' + a.website + "

" : "") + (a.email ? '

Email:
' + a.email + "

" : "") + "
" }; k = "Loading..."; l = "Sorry, no data found."; j = function () { } } break; default: { } break } if (a.isEmptyObject(g)) { a.ajax({ url: i, type: "GET", dataType: "jsonp", timeout: 4e3, beforeSend: function () { e.find(".s-message").remove(); e.append('

' + k + "

") }, success: function (a) { if (a.length <= 0) { e.find(".s-message").html(l) } else { e.find(".s-message").remove(); e.prepend(h(a)); f(e.closest(".hc-preview")); e.stop(true, true).delay(b.delay).fadeIn(); j(a) } }, error: function (a, b, c) { e.find(".s-message").html(l) } }) } else { e.prepend(h(g)) } } function f(a) { var c = a.find(".hc-details").eq(0); var d = a[0].getBoundingClientRect(); var e = d.top - 20; var f = d.left + 35 + c.width(); var g = d.top + 35 + c.height(); var h = d.top - 10; if (b.openOnLeft || b.autoAdjust && f > window.innerWidth) { c.addClass("hc-details-open-left") } else { c.removeClass("hc-details-open-left") } if (b.openOnTop || b.autoAdjust && g > window.innerHeight) { c.addClass("hc-details-open-top") } else { c.removeClass("hc-details-open-top") } } var c = a(this); c.wrap('
'); c.addClass("hc-name"); var d = ""; if (b.cardImgSrc.length > 0) { d = '' } var e = '
' + d + b.detailsHTML + "
"; c.after(e); c.siblings(".hc-details").eq(0).css({ width: b.width, background: b.background }); c.closest(".hc-preview").hover(function () { var d = a(this); f(d); d.css("zIndex", "200"); c.css("zIndex", "100").find(".hc-details").css("zIndex", "50"); var e = d.find(".hc-details").eq(0); e.stop(true, true).delay(b.delay).fadeIn(); if (typeof b.onHoverIn == "function") { if (b.showCustomCard && e.find(".s-card").length <= 0) { var h = b.customDataUrl; if (typeof c.attr("data-hovercard") == "undefined") { } else if (c.attr("data-hovercard").length > 0) { h = c.attr("data-hovercard") } g("custom", h, e, b.customCardJSON) } if (b.showTwitterCard && e.find(".s-card").length <= 0) { var i = b.twitterScreenName.length > 0 ? b.twitterScreenName : c.text(); if (typeof c.attr("data-hovercard") == "undefined") { } else if (c.attr("data-hovercard").length > 0) { i = c.attr("data-hovercard") } g("twitter", i, e) } if (b.showFacebookCard && e.find(".s-card").length <= 0) { var j = b.facebookUserName.length > 0 ? b.facebookUserName : c.text(); if (typeof c.attr("data-hovercard") == "undefined") { } else if (c.attr("data-hovercard").length > 0) { j = c.attr("data-hovercard") } g("facebook", j, e) } b.onHoverIn.call(this) } }, function () { $this = a(this); $this.find(".hc-details").eq(0).stop(true, true).fadeOut(300, function () { $this.css("zIndex", "0"); c.css("zIndex", "0").find(".hc-details").css("zIndex", "0"); if (typeof b.onHoverOut == "function") { b.onHoverOut.call(this) } }) }); }) } })(jQuery) \ No newline at end of file +/*! + Version v2.4 - 2012/04/12 + jQuery hovercard plugin + (c) 2014 Prahsant Chaudhary - http:// designwithpc.com/Plugins/Hovercard + license: http:// www.opensource.org/licenses/mit-license.php +*/ +(function (a) { a.fn.hovercard = function (b) { var c = { width: 300, openOnLeft: false, openOnTop: false, cardImgSrc: "", detailsHTML: "", twitterScreenName: "", showTwitterCard: false, facebookUserName: "", showFacebookCard: false, showCustomCard: false, customCardJSON: {}, customDataUrl: "", background: "#ffffff", delay: 0, autoAdjust: true, onHoverIn: function () { }, onHoverOut: function () { } }; var b = a.extend(c, b); if (a("#css-hovercard").length <= 0) { var d = '")'; a(d).appendTo("head") } return this.each(function () { function g(c, d, e, g) { var h, i, j, k, l; switch (c) { case "twitter": { i = "http://api.twitter.com/1/users/lookup.json?screen_name=" + d; h = function (a) { a = a[0]; return '
' + (a.profile_image_url ? '' : "") + (a.name ? '" : "") + (a.screen_name ? '(@' + a.screen_name + ")
" : "") + (a.location ? '" : "") + (a.description ? '

' + a.description + "

" : "") + (a.url ? '' + a.url + "
" : "") + '" + "
" }; k = "Contacting Twitter..."; l = "Invalid username or you have exceeded Twitter request limit.
Please note, Twitter only allows 150 requests per hour."; j = function () { }; if (a("#t-follow-script").length <= 0) { var m = document.createElement("script"); m.type = "text/javascript"; m.src = "//platform.twitter.com/widgets.js"; m.id = "t-follow-script"; a("body").append(m) } e.append('') } break; case "facebook": { i = "https://graph.facebook.com/" + d, h = function (a) { return '
' + '' + '
" + (a.link ? '' + a.link + "
" : "") + (a.likes ? '
" : "") + (a.description ? '

' + a.description + "

" : "") + (a.start_time ? '

Start Time:
' + a.start_time + "

" : "") + (a.end_time ? '

End Time:
' + a.end_time + "

" : "") + (a.founded ? '

Founded:
' + a.founded + "

" : "") + (a.mission ? '

Mission:
' + a.mission + "

" : "") + (a.company_overview ? '

Overview:
' + a.company_overview + "

" : "") + (a.products ? '

Products:
' + a.products + "

" : "") + (a.website ? '

Web:
' + a.website + "

" : "") + (a.email ? '

Email:
' + a.email + "

" : "") + "
" }; k = "Contacting Facebook..."; l = "The requested user, page, or event could not be found. Please try a different one."; j = 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('
') } e.append('
') } } break; case "custom": { i = d, h = function (a) { return '
' + (a.image ? '' + a.name + "
" : "") + (a.link ? '' + a.link + "
" : "") + (a.bio ? '

' + a.bio + "

" : "") + (a.website ? '

Web:
' + a.website + "

" : "") + (a.email ? '

Email:
' + a.email + "

" : "") + "
" }; k = "Loading..."; l = "Sorry, no data found."; j = function () { } } break; default: { } break } if (a.isEmptyObject(g)) { a.ajax({ url: i, type: "GET", dataType: "jsonp", timeout: 4e3, beforeSend: function () { e.find(".s-message").remove(); e.append('

' + k + "

") }, success: function (a) { if (a.length <= 0) { e.find(".s-message").html(l) } else { e.find(".s-message").remove(); e.prepend(h(a)); f(e.closest(".hc-preview")); e.stop(true, true).delay(b.delay).fadeIn(); j(a) } }, error: function (a, b, c) { e.find(".s-message").html(l) } }) } else { e.prepend(h(g)) } } function f(a) { var c = a.find(".hc-details").eq(0); var d = a[0].getBoundingClientRect(); var e = d.top - 20; var f = d.left + 35 + c.width(); var g = d.top + 35 + c.height(); var h = d.top - 10; if (b.openOnLeft || b.autoAdjust && f > window.innerWidth) { c.addClass("hc-details-open-left") } else { c.removeClass("hc-details-open-left") } if (b.openOnTop || b.autoAdjust && g > window.innerHeight) { c.addClass("hc-details-open-top") } else { c.removeClass("hc-details-open-top") } } var c = a(this); c.wrap('
'); c.addClass("hc-name"); var d = ""; if (b.cardImgSrc.length > 0) { d = '' } var e = '
' + d + b.detailsHTML + "
"; c.after(e); c.siblings(".hc-details").eq(0).css({ width: b.width, background: b.background }); c.closest(".hc-preview").hover(function () { var d = a(this); f(d); d.css("zIndex", "200"); c.css("zIndex", "100").find(".hc-details").css("zIndex", "50"); var e = d.find(".hc-details").eq(0); e.stop(true, true).delay(b.delay).fadeIn(); if (typeof b.onHoverIn == "function") { if (b.showCustomCard && e.find(".s-card").length <= 0) { var h = b.customDataUrl; if (typeof c.attr("data-hovercard") == "undefined") { } else if (c.attr("data-hovercard").length > 0) { h = c.attr("data-hovercard") } g("custom", h, e, b.customCardJSON) } if (b.showTwitterCard && e.find(".s-card").length <= 0) { var i = b.twitterScreenName.length > 0 ? b.twitterScreenName : c.text(); if (typeof c.attr("data-hovercard") == "undefined") { } else if (c.attr("data-hovercard").length > 0) { i = c.attr("data-hovercard") } g("twitter", i, e) } if (b.showFacebookCard && e.find(".s-card").length <= 0) { var j = b.facebookUserName.length > 0 ? b.facebookUserName : c.text(); if (typeof c.attr("data-hovercard") == "undefined") { } else if (c.attr("data-hovercard").length > 0) { j = c.attr("data-hovercard") } g("facebook", j, e) } b.onHoverIn.call(this) } }, function () { $this = a(this); $this.find(".hc-details").eq(0).stop(true, true).fadeOut(300, function () { $this.css("zIndex", "0"); c.css("zIndex", "0").find(".hc-details").css("zIndex", "0"); if (typeof b.onHoverOut == "function") { b.onHoverOut.call(this) } }) }); }) } })(jQuery)