Advertisement
Guest User

Untitled

a guest
Oct 10th, 2013
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*!
  2.  * jQuery ClassySocial
  3.  * http://www.class.pm/projects/jquery/classysocial
  4.  *
  5.  * Written by Marius Stanciu - Sergiu <marius@picozu.com>
  6.  * Licensed under the GPL Version 3 license.
  7.  * Version 2.0.0
  8.  *
  9.  */
  10.  
  11. var ClassySocial = function(e) {
  12.     var n = e, s = "bubble", o = "arc", u = 0, a = 180, f = 80, l = 70, c = "none", h = "picture", y = "default", r;
  13.     if ($(n).attr("data-networks")) {
  14.         r = $(n).attr("data-networks").toLowerCase().split(",");
  15.     }
  16.     if ($(n).attr("data-orientation")) {
  17.         o = $(n).attr("data-orientation").toLowerCase();
  18.     }
  19.     if ($(n).attr("data-arc-start")) {
  20.         u = parseInt($(n).attr("data-arc-start"));
  21.     }
  22.     if ($(n).attr("data-arc-length")) {
  23.         a = parseInt($(n).attr("data-arc-length"));
  24.     }
  25.     if ($(n).attr("data-radius")) {
  26.         f = parseInt($(n).attr("data-radius"));
  27.     }
  28.     if ($(n).attr("data-gap")) {
  29.         l = parseInt($(n).attr("data-gap"));
  30.     }
  31.     if ($(n).attr("data-picture")) {
  32.         c = $(n).attr("data-picture");
  33.     }
  34.     if ($(n).attr("data-image-type")) {
  35.         h = $(n).attr("data-image-type").toLowerCase();
  36.     }
  37.     if ($(n).attr("data-theme")) {
  38.         y = $(n).attr("data-theme").toLowerCase();
  39.     }
  40.     var initialize = function() {
  41.         $(n).addClass(s);
  42.         var template = data[s];
  43.         if (h === "facebook") {
  44.             c = "https://graph.facebook.com/" + c + "/picture?type=large";
  45.         }
  46.         $(n).html(template["holder"].replace(/\[IMAGE_URL\]/gi, c));
  47.         var e = $(n).find(".network_holder");
  48.         for (var t = 0; t < r.length; t++) {
  49.             var i = r[t], o = profiles[i], u;
  50.             if (o["profile_url"] && $(n).attr("data-" + i + "-handle")) {
  51.                 u = o["profile_url"].replace(/\[HANDLE\]/gi, $(n).attr("data-" + i + "-handle"));
  52.             }
  53.             else {
  54.                 continue;
  55.             }
  56.             var a = template["network_button"].replace(/\[URL\]/gi, u).replace(/\[NAME\]/gi, o["name"]).replace(/\[NETWORK\]/gi, i), f = $(a);
  57.             e.append(f);
  58.         }
  59.         if (bubbles[s]) {
  60.             bubbles[s](template);
  61.         }
  62.     };
  63.     var data = {
  64.         bubble: {
  65.             holder: '<a class="main" title="Find Me Here" alt="Find Me Here">' + '<img src="[IMAGE_URL]" title="Find Me Here" alt="Find Me Here"/>' + "</a>" + '<div class="network_holder ' + y + '"></div>',
  66.             network_button: '<a class="network_button [NETWORK]" target="_blank" href="[URL]" data-network="[NETWORK]">[NAME]</a>',
  67.             orientations: {
  68.                 arc: function() {
  69.                     if ($(this).hasClass("disabled")) {
  70.                         return;
  71.                     }
  72.                     var e = 250, t = 250, r = $(n).find(".network_button").length, i = e + (r - 1) * t, s = 0;
  73.                     var o = $(this).outerWidth(), l = $(this).outerHeight();
  74.                     var c = $(n).find(".network_button:eq(0)").outerWidth(), h = $(n).find(".network_button:eq(0)").outerHeight();
  75.                     var p = (o - c) / 2, d = (l - h) / 2;
  76.                     if (!$(this).hasClass("active")) {
  77.                         $(this).addClass("disabled").delay(i).queue(function(e) {
  78.                             $(this).removeClass("disabled").addClass("active");
  79.                             e();
  80.                         });
  81.                         var v = a / r, m = u + v / 2;
  82.                         $(n).find(".network_button").each(function() {
  83.                             var n = m / 180 * Math.PI, r = p + f * Math.cos(n), i = d + f * Math.sin(n);
  84.                             $(this).css({
  85.                                 display: "block",
  86.                                 left: p + "px",
  87.                                 top: d + "px"
  88.                             }).stop().delay(t * s).animate({
  89.                                 left: r + "px",
  90.                                 top: i + "px"
  91.                             }, e);
  92.                             m += v;
  93.                             s++;
  94.                         });
  95.                     }
  96.                     else {
  97.                         s = r - 1;
  98.                         $(this).addClass("disabled").delay(i).queue(function(e) {
  99.                             $(this).removeClass("disabled").removeClass("active");
  100.                             e();
  101.                         });
  102.                         $(n).find(".network_button").each(function() {
  103.                             $(this).stop().delay(t * s).animate({
  104.                                 left: p,
  105.                                 top: d
  106.                             }, e);
  107.                             s--;
  108.                         });
  109.                     }
  110.                 },
  111.                 line: function() {
  112.                     if ($(this).hasClass("disabled")) {
  113.                         return;
  114.                     }
  115.                     var e = 500, t = 250, r = $(n).find(".network_button").length, i = l, s = e + (r - 1) * t, o = 1;
  116.                     var a = $(this).outerWidth(), f = $(this).outerHeight();
  117.                     var c = $(n).find(".network_button:eq(0)").outerWidth(), h = $(n).find(".network_button:eq(0)").outerHeight();
  118.                     var p = (a - c) / 2, d = (f - h) / 2, v = u / 180 * Math.PI;
  119.                     if (!$(this).hasClass("active")) {
  120.                         $(this).addClass("disabled").delay(s).queue(function(e) {
  121.                             $(this).removeClass("disabled").addClass("active");
  122.                             e();
  123.                         });
  124.                         $(n).find(".network_button").each(function() {
  125.                             var n = p + (p + i * o) * Math.cos(v), r = d + (d + i * o) * Math.sin(v);
  126.                             $(this).css({
  127.                                 display: "block",
  128.                                 left: p + "px",
  129.                                 top: d + "px"
  130.                             }).stop().delay(t * o).animate({
  131.                                 left: n + "px",
  132.                                 top: r + "px"
  133.                             }, e);
  134.                             o++;
  135.                         });
  136.                     }
  137.                     else {
  138.                         o = r;
  139.                         $(this).addClass("disabled").delay(s).queue(function(e) {
  140.                             $(this).removeClass("disabled").removeClass("active");
  141.                             e();
  142.                         });
  143.                         $(n).find(".network_button").each(function() {
  144.                             $(this).stop().delay(t * o).animate({
  145.                                 left: p,
  146.                                 top: d
  147.                             }, e);
  148.                             o--;
  149.                         });
  150.                     }
  151.                 }
  152.             }
  153.         }
  154.     };
  155.     var bubbles = {
  156.         bubble: function(e) {
  157.             var t = e["orientations"]["arc"];
  158.             if (e["orientations"][o]) {
  159.                 t = e["orientations"][o];
  160.             }
  161.             $(n).find(".main").click(t);
  162.         }
  163.     };
  164.     var profiles = {
  165.         facebook: {
  166.             profile_url: "https://www.facebook.com/sharer/sharer.php?u=[HANDLE]",
  167.             name: "Facebook"
  168.         },
  169.         google: {
  170.             profile_url: "https://plus.google.com/[HANDLE]",
  171.             name: "Google Plus"
  172.         },
  173.         twitter: {
  174.             profile_url: "https://twitter.com/[HANDLE]",
  175.             name: "Twitter"
  176.         },
  177.         pinterest: {
  178.             profile_url: "http://pinterest.com/[HANDLE]",
  179.             name: "Pinterest"
  180.         },
  181.         linkedin: {
  182.             profile_url: "http://www.linkedin.com/profile/view?id=[HANDLE]",
  183.             name: "LinkedIn"
  184.         },
  185.         dribbble: {
  186.             profile_url: "http://dribbble.com/[HANDLE]",
  187.             name: "Dribbble"
  188.         },
  189.         email: {
  190.             profile_url: "mailto:[HANDLE]",
  191.             name: "Email"
  192.         },
  193.         socl: {
  194.             profile_url: "http://www.so.cl/#/profile/[HANDLE]",
  195.             name: "Socl"
  196.         },
  197.         instagram: {
  198.             profile_url: "http://instagram.com/[HANDLE]",
  199.             name: "Instagram"
  200.         },
  201.         vimeo: {
  202.             profile_url: "http://vimeo.com/[HANDLE]",
  203.             name: "Vimeo"
  204.         },
  205.         youtube: {
  206.             profile_url: "http://www.youtube.com/user/[HANDLE]",
  207.             name: "YouTube"
  208.         },
  209.         github: {
  210.             profile_url: "https://www.github.com/[HANDLE]",
  211.             name: "GitHub"
  212.         },
  213.         blogger: {
  214.             profile_url: "http://www.blogger.com/profile/[HANDLE]",
  215.             name: "Blogger"
  216.         },
  217.         deviantart: {
  218.             profile_url: "https://[HANDLE].deviantart.com",
  219.             name: "DeviantArt"
  220.         },
  221.         flickr: {
  222.             profile_url: "http://www.flickr.com/photos/[HANDLE]",
  223.             name: "Flickr"
  224.         },
  225.         skype: {
  226.             profile_url: "skype:[HANDLE]?userinfo",
  227.             name: "Skype"
  228.         },
  229.         steam: {
  230.             profile_url: "http://steamcommunity.com/profiles/[HANDLE]",
  231.             name: "Steam"
  232.         },
  233.         wordpress: {
  234.             profile_url: "http://[HANDLE].wordpress.com",
  235.             name: "Wordpress"
  236.         },
  237.         yahoo: {
  238.             profile_url: "http://profile.yahoo.com/y/pulse/[HANDLE]",
  239.             name: "Yahoo"
  240.         }
  241.     };
  242.     initialize();
  243. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement