PageSourceSearch

https://www.ranisaonline.com/css/assets/plugins/pretty-social/jquery.prettySocial.min.js

js ranisaonline.com collected 2026-10-02 00:55:15 UTC 5,285 bytes, 148 lines download raw bytes

1/**
2 * jQuery prettySocial: Use custom social share buttons
3 * Author: Sonny T. <[email protected]>, sonnyt.com
4 */
5
6(function ($) {
7    'use strict';
8
9    $.fn.prettySocial = function () {
10        /**
11         * Supported social sites
12         * @type {Object}
13         */
14        var _sites = {
15                pinterest: {
16                    url: 'http://pinterest.com/pin/create/button/?url={{url}}&media={{media}}&description={{description}}',
17                    popup: {
18                        width: 685,
19                        height: 500
20                    }
21                },
22                facebook: {
23                    url: 'https://www.facebook.com/sharer/sharer.php?u={{url}}',
24                    popup: {
25                        width: 626,
26                        height: 436
27                    }
28                },
29                twitter: {
30                    url: 'https://x.com/share?url={{url}}&via={{via}}&text={{description}}',
31                    popup: {
32                        width: 685,
33                        height: 500
34                    }
35                },
36                googleplus: {
37                    url: 'https://plus.google.com/share?url={{url}}',
38                    popup: {
39                        width: 600,
40                        height: 600
41                    }
42                },
43                linkedin: {
44                    url: 'https://www.linkedin.com/shareArticle?mini=true&url={{url}}&title={{title}}&summary={{description}}+&source={{via}}',
45                    popup: {
46                        width: 600,
47                        height: 600
48                    }
49                }
50            },
51
52            /**
53             * Pop-up window
54             * This method is only used on desktop browsers
55             * @param  {Object} site Selected social site
56             * @param  {String} url  Fixed URL to open
57             */
58            _popup = function (site, url) {
59                // center window
60                var left = (window.innerWidth/2) - (site.popup.width/2),
61                    top = (window.innerHeight/2) - (site.popup.height/2);
62
63                return window.open(url, '', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + site.popup.width + ', height=' + site.popup.height + ', top=' + top + ', left=' + left);
64            },
65
66            /**
67             * Prepare link based on social sites
68             * @param  {Object} site Selected social site
69             * @param  {Object} link Link with variables
70             * @return {String}      Polished link based on the social site template
71             */
72            _linkFix = function (site, link) {
73                // replace template url
74                var url = site.url.replace(/{{url}}/g, encodeURIComponent(link.url))
75                                  .replace(/{{title}}/g, encodeURIComponent(link.title))
76                                  .replace(/{{description}}/g, encodeURIComponent(link.description))
77                                  .replace(/{{media}}/g, encodeURIComponent(link.media))
78                                  .replace(/{{via}}/g, encodeURIComponent(link.via));
79
80                return url;
81            };
82
83        return this.each(function() {
84
85            // declare $(this) as variable
86            var $this = $(this);
87
88            // link type
89            var type = $this.data('type'),
90
91                // set site
92                site = _sites[type] || null;
93
94            // check if social site is selected
95            if (!site) {
96                $.error('Social site is not set.');
97            }
98
99            // gather link info
100            var link = {
101                url: $this.data('url') || '',
102                title: $this.data('title') || '',
103                description: $this.data('description') || '',
104                media: $this.data('media') || '',
105                via: $this.data('via') || ''
106            };
107
108            // prepare link
109            var url = _linkFix(site, link);
110
111            // if not, set click trigger
112            if (navigator.userAgent.match(/Android|IEMobile|BlackBerry|iPhone|iPad|iPod|Opera Mini/i)) {
113                $this
114                .bind('touchstart', function (e) {
115                    if(e.originalEvent.touches.length > 1) {
116                        return;
117                    }
118
119                    $this.data('touchWithoutScroll', true);
120                })
121                .bind('touchmove', function () {
122                    $this.data('touchWithoutScroll', false);
123
124                    return;
125                }).bind('touchend', function (e) {
126                    e.preventDefault();
127
128                    var touchWithoutScroll = $this.data('touchWithoutScroll');
129
130                    if (e.originalEvent.touches.length > 1 || !touchWithoutScroll) {
131                        return;
132                    }
133
134                    // call popup window
135                    _popup(site, url);
136                });
137            } else {
138                $this.bind('click', function (e) {
139                    e.preventDefault();
140
141                    // call popup window
142                    _popup(site, url);
143                });
144            }
145        });
146    };
147
148})(jQuery);

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.