PageSourceSearch

https://gjepc.org/js/jquery-social-share-bar.js

js gjepc.org collected 2026-09-24 18:11:03 UTC 5,023 bytes, 129 lines download raw bytes

1/**
2 * jquery-social-share-bar
3 * Copyright: Jesse Nieminen, Viima Solutions Oy
4 * 
5 * License: MIT
6 * --------------------
7 * Modified from https://github.com/ewebdev/jquery-share
8 */
9
10(function ($, window, undefined) {
11  "use strict";
12
13  $.fn.share = function (method) {
14
15    var helpers = {
16      channels: {
17        facebook: {url: 'https://www.facebook.com/share.php?u=|u|'},
18        twitter: {url: 'https://twitter.com/share?url=|u|&text=|140|'},
19        linkedin: {url: 'https://www.linkedin.com/shareArticle?mini=true&url=|u|&title=|t|&summary=|d|'},
20        tumblr: {url: 'https://www.tumblr.com/share?v=3&u=|u|'},
21        digg: {url: 'https://digg.com/submit?url=|u|&title=|t|'},
22        googleplus: {url: 'https://plusone.google.com/_/+1/confirm?hl=en&url=|u|'},
23        reddit: {url: 'https://reddit.com/submit?url=|u|'},
24        pinterest: {url: 'https://pinterest.com/pin/create/button/?url=|u|&media=&description=|d|'},
25        stumbleupon: {url: 'https://www.stumbleupon.com/submit?url=|u|&title=|t|'},
26        email: {url: 'mailto:?subject=|t|&body=You might want to check this out: |u|'}
27      }
28    };
29
30    var methods = {
31
32      init: function (options) {
33        this.share.settings = $.extend({}, this.share.defaults, options);
34
35        var settings = this.share.settings,
36          pageTitle = settings.title || document.title || '',
37          pageUrl = settings.pageUrl || window.location.href,
38          pageDesc = settings.pageDesc || $('head > meta[name="description"]').attr("content") || '',
39          position = settings.position || 'left',
40          theme = settings.theme || 'circle',
41          animate = settings.animate === false ? false : true,
42          u = encodeURIComponent(pageUrl),
43          t = encodeURIComponent(pageTitle);
44
45        // Each instance of this plugin
46        return this.each(function () {
47          var $element = $(settings.containerTemplate(settings)).appendTo($(this)),
48            id = $element.attr("id"),
49            d = pageDesc.substring(0, 250),
50            href;
51
52          // Add class for positioning and animation of the widget
53          $(this).addClass(position);
54          if (animate) {
55            $(this).addClass('animate');
56          }
57
58          // Add class for theming the widget
59          $element.addClass(theme);
60
61          // Append HTML for each network button
62          for (var item in settings.channels) {
63            item = settings.channels[item];
64            href = helpers.channels[item].url;
65            href = href.replace('|u|', u).replace('|t|', t).replace('|d|', d)
66              .replace('|140|', t.substring(0, 130));
67            $(settings.itemTemplate({provider: item, href: href, itemTriggerClass: settings.itemTriggerClass})).appendTo($element);
68          }
69
70          // Bind click
71          $element.on('click', '.' + settings.itemTriggerClass, function (e) {
72            e.preventDefault();
73            var top = (screen.height / 2) - (settings.popupHeight / 2),
74              left = (screen.width / 2) - (settings.popupWidth / 2);
75            window.open($(this).data('href') || $(this).attr('href'), 't', 'toolbar=0,resizable=1,status=0,copyhistory=no,width=' + settings.popupWidth + ',height=' + settings.popupHeight + ',top=' + top + ',left=' + left);
76          });
77
78        });// End plugin instance
79
80      }
81    };
82
83    if (methods[method]) {
84      return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
85    } else if (typeof method === 'object' || !method) {
86      return methods.init.apply(this, arguments);
87    } else {
88      $.error('Method "' + method + '" does not exist in social plugin');
89    }
90
91  };
92
93  $.fn.share.defaults = {
94    popupWidth: 640,
95    popupHeight: 528,
96    channels: ['facebook', 'twitter', 'linkedin', 'googleplus', 'email'],
97    itemTriggerClass: 'js-share',
98    containerTemplate: function (props) {
99      return '<ul class="sharing-providers"></ul>';
100    },
101
102    itemTemplate: function (props) {
103      var iconClasses = {
104        'facebook': 'fa fa-facebook',
105        'twitter': 'fa fa-twitter',
106        'linkedin': 'fa fa-linkedin',
107        'googleplus': 'fa fa-google-plus',
108        'pinterest': 'fa fa-pinterest',
109        'tumblr': 'fa fa-tumblr',
110        'stumbleupon': 'fa fa-stumbleupon',
111        'reddit': 'fa fa-reddit-alien',
112        'digg': 'fa fa-digg',
113        'email': 'fa fa-envelope',
114      }
115
116      // Special handling for email and Google+
117      var providerName = props.provider === 'email' ? 'email' : props.provider === 'googleplus' ? 'Google+' : props.provider.charAt(0).toUpperCase() + props.provider.slice(1);
118
119      return '<li class="' + props.provider + '">' +
120        '<a href="#" data-href="' + props.href + '" title="Share this page ' + (props.provider === 'email' ? 'via ' : 'on ') + providerName + '" class=' + props.itemTriggerClass + ' ' + props.provider + '">' +
121        '<i class="' + iconClasses[props.provider] + '"></i>' +
122        '</a>' +
123        '</li>';
124    }
125  };
126
127  $.fn.share.settings = {};
128
129})(jQuery, window);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.