PageSourceSearch

https://mehr-edv.com/wp-content/themes/sixten/assets/vendors/js/sharer.js?ver=1.0.0

js mehr-edv.com collected 2026-10-05 02:25:13 UTC 14,638 bytes, 481 lines download raw bytes

vendor: 14,638 bytes, lines 1-481
1/**
2 * @preserve
3 * Sharer.js
4 *
5 * @description Create your own social share buttons
6 * @version 0.5.1
7 * @author Ellison Leao <[email protected]>
8 * @license MIT
9 *
10 */
11
12(function (window, document) {
13  'use strict';
14  /**
15   * @constructor
16   */
17  var Sharer = function (elem) {
18    this.elem = elem;
19  };
20
21  /**
22   *  @function init
23   *  @description bind the events for multiple sharer elements
24   *  @returns {Empty}
25   */
26  Sharer.init = function () {
27    var elems = document.querySelectorAll('[data-sharer]'),
28      i,
29      l = elems.length;
30
31    for (i = 0; i < l; i++) {
32      elems[i].addEventListener('click', Sharer.add);
33    }
34  };
35
36  /**
37   *  @function add
38   *  @description bind the share event for a single dom element
39   *  @returns {Empty}
40   */
41  Sharer.add = function (elem) {
42    var target = elem.currentTarget || elem.srcElement;
43    var sharer = new Sharer(target);
44    sharer.share();
45  };
46
47  // instance methods
48  Sharer.prototype = {
49    constructor: Sharer,
50    /**
51     *  @function getValue
52     *  @description Helper to get the attribute of a DOM element
53     *  @param {String} attr DOM element attribute
54     *  @returns {String|Empty} returns the attr value or empty string
55     */
56    getValue: function (attr) {
57      var val = this.elem.getAttribute('data-' + attr);
58      // handing facebook hashtag attribute
59      if (val && attr === 'hashtag') {
60        if (!val.startsWith('#')) {
61          val = '#' + val;
62        }
63      }
64      return val === null ? '' : val;
65    },
66
67    /**
68     * @event share
69     * @description Main share event. Will pop a window or redirect to a link
70     * based on the data-sharer attribute.
71     */
72    share: function () {
73      var sharer = this.getValue('sharer').toLowerCase(),
74        sharers = {
75          facebook: {
76            shareUrl: 'https://www.facebook.com/sharer/sharer.php',
77            params: {
78              u: this.getValue('url'),
79              hashtag: this.getValue('hashtag'),
80              quote: this.getValue('quote'),
81            },
82          },
83          linkedin: {
84            shareUrl: 'https://www.linkedin.com/shareArticle',
85            params: {
86              url: this.getValue('url'),
87              mini: true,
88            },
89          },
90          twitter: {
91            shareUrl: 'https://twitter.com/intent/tweet/',
92            params: {
93              text: this.getValue('title'),
94              url: this.getValue('url'),
95              hashtags: this.getValue('hashtags'),
96              via: this.getValue('via'),
97            },
98          },
99          email: {
100            shareUrl: 'mailto:' + this.getValue('to'),
101            params: {
102              subject: this.getValue('subject'),
103              body: this.getValue('title') + '\n' + this.getValue('url'),
104            },
105          },
106          whatsapp: {
107            shareUrl: this.getValue('web') === 'true' ? 'https://web.whatsapp.com/send' : 'https://wa.me/',
108            params: {
109              phone: this.getValue('to'),
110              text: this.getValue('title') + ' ' + this.getValue('url'),
111            },
112          },
113          telegram: {
114            shareUrl: 'https://t.me/share',
115            params: {
116              text: this.getValue('title'),
117              url: this.getValue('url'),
118            },
119          },
120          viber: {
121            shareUrl: 'viber://forward',
122            params: {
123              text: this.getValue('title') + ' ' + this.getValue('url'),
124            },
125          },
126          line: {
127            shareUrl:
128              'http://line.me/R/msg/text/?' + encodeURIComponent(this.getValue('title') + ' ' + this.getValue('url')),
129          },
130          pinterest: {
131            shareUrl: 'https://www.pinterest.com/pin/create/button/',
132            params: {
133              url: this.getValue('url'),
134              media: this.getValue('image'),
135              description: this.getValue('description'),
136            },
137          },
138          tumblr: {
139            shareUrl: 'http://tumblr.com/widgets/share/tool',
140            params: {
141              canonicalUrl: this.getValue('url'),
142              content: this.getValue('url'),
143              posttype: 'link',
144              title: this.getValue('title'),
145              caption: this.getValue('caption'),
146              tags: this.getValue('tags'),
147            },
148          },
149          hackernews: {
150            shareUrl: 'https://news.ycombinator.com/submitlink',
151            params: {
152              u: this.getValue('url'),
153              t: this.getValue('title'),
154            },
155          },
156          reddit: {
157            shareUrl: 'https://www.reddit.com/submit',
158            params: { url: this.getValue('url'), title: this.getValue('title') },
159          },
160          vk: {
161            shareUrl: 'http://vk.com/share.php',
162            params: {
163              url: this.getValue('url'),
164              title: this.getValue('title'),
165              description: this.getValue('caption'),
166              image: this.getValue('image'),
167            },
168          },
169          xing: {
170            shareUrl: 'https://www.xing.com/social/share/spi',
171            params: {
172              url: this.getValue('url'),
173            },
174          },
175          buffer: {
176            shareUrl: 'https://buffer.com/add',
177            params: {
178              url: this.getValue('url'),
179              title: this.getValue('title'),
180              via: this.getValue('via'),
181              picture: this.getValue('picture'),
182            },
183          },
184          instapaper: {
185            shareUrl: 'http://www.instapaper.com/edit',
186            params: {
187              url: this.getValue('url'),
188              title: this.getValue('title'),
189              description: this.getValue('description'),
190            },
191          },
192          pocket: {
193            shareUrl: 'https://getpocket.com/save',
194            params: {
195              url: this.getValue('url'),
196            },
197          },
198          mashable: {
199            shareUrl: 'https://mashable.com/submit',
200            params: {
201              url: this.getValue('url'),
202              title: this.getValue('title'),
203            },
204          },
205          mix: {
206            shareUrl: 'https://mix.com/add',
207            params: {
208              url: this.getValue('url'),
209            },
210          },
211          flipboard: {
212            shareUrl: 'https://share.flipboard.com/bookmarklet/popout',
213            params: {
214              v: 2,
215              title: this.getValue('title'),
216              url: this.getValue('url'),
217              t: Date.now(),
218            },
219          },
220          weibo: {
221            shareUrl: 'http://service.weibo.com/share/share.php',
222            params: {
223              url: this.getValue('url'),
224              title: this.getValue('title'),
225              pic: this.getValue('image'),
226              appkey: this.getValue('appkey'),
227              ralateUid: this.getValue('ralateuid'),
228              language: 'zh_cn',
229            },
230          },
231          blogger: {
232            shareUrl: 'https://www.blogger.com/blog-this.g',
233            params: {
234              u: this.getValue('url'),
235              n: this.getValue('title'),
236              t: this.getValue('description'),
237            },
238          },
239          baidu: {
240            shareUrl: 'http://cang.baidu.com/do/add',
241            params: {
242              it: this.getValue('title'),
243              iu: this.getValue('url'),
244            },
245          },
246          douban: {
247            shareUrl: 'https://www.douban.com/share/service',
248            params: {
249              name: this.getValue('name'),
250              href: this.getValue('url'),
251              image: this.getValue('image'),
252              comment: this.getValue('description'),
253            },
254          },
255          okru: {
256            shareUrl: 'https://connect.ok.ru/dk',
257            params: {
258              'st.cmd': 'WidgetSharePreview',
259              'st.shareUrl': this.getValue('url'),
260              title: this.getValue('title'),
261            },
262          },
263          mailru: {
264            shareUrl: 'http://connect.mail.ru/share',
265            params: {
266              share_url: this.getValue('url'),
267              linkname: this.getValue('title'),
268              linknote: this.getValue('description'),
269              type: 'page',
270            },
271          },
272          evernote: {
273            shareUrl: 'https://www.evernote.com/clip.action',
274            params: {
275              url: this.getValue('url'),
276              title: this.getValue('title'),
277            },
278          },
279          skype: {
280            shareUrl: 'https://web.skype.com/share',
281            params: {
282              url: this.getValue('url'),
283              title: this.getValue('title'),
284            },
285          },
286          delicious: {
287            shareUrl: 'https://del.icio.us/post',
288            params: {
289              url: this.getValue('url'),
290              title: this.getValue('title'),
291            },
292          },
293          sms: {
294            shareUrl: 'sms://',
295            params: {
296              body: this.getValue('body'),
297            },
298          },
299          trello: {
300            shareUrl: 'https://trello.com/add-card',
301            params: {
302              url: this.getValue('url'),
303              name: this.getValue('title'),
304              desc: this.getValue('description'),
305              mode: 'popup',
306            },
307          },
308          messenger: {
309            shareUrl: 'fb-messenger://share',
310            params: {
311              link: this.getValue('url'),
312            },
313          },
314          odnoklassniki: {
315            shareUrl: 'https://connect.ok.ru/dk',
316            params: {
317              st: {
318                cmd: 'WidgetSharePreview',
319                deprecated: 1,
320                shareUrl: this.getValue('url'),
321              },
322            },
323          },
324          meneame: {
325            shareUrl: 'https://www.meneame.net/submit',
326            params: {
327              url: this.getValue('url'),
328            },
329          },
330          diaspora: {
331            shareUrl: 'https://share.diasporafoundation.org',
332            params: {
333              title: this.getValue('title'),
334              url: this.getValue('url'),
335            },
336          },
337          googlebookmarks: {
338            shareUrl: 'https://www.google.com/bookmarks/mark',
339            params: {
340              op: 'edit',
341              bkmk: this.getValue('url'),
342              title: this.getValue('title'),
343            },
344          },
345          qzone: {
346            shareUrl: 'https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey',
347            params: {
348              url: this.getValue('url'),
349            },
350          },
351          refind: {
352            shareUrl: 'https://refind.com',
353            params: {
354              url: this.getValue('url'),
355            },
356          },
357          surfingbird: {
358            shareUrl: 'https://surfingbird.ru/share',
359            params: {
360              url: this.getValue('url'),
361              title: this.getValue('title'),
362              description: this.getValue('description'),
363            },
364          },
365          yahoomail: {
366            shareUrl: 'http://compose.mail.yahoo.com',
367            params: {
368              to: this.getValue('to'),
369              subject: this.getValue('subject'),
370              body: this.getValue('body'),
371            },
372          },
373          wordpress: {
374            shareUrl: 'https://wordpress.com/wp-admin/press-this.php',
375            params: {
376              u: this.getValue('url'),
377              t: this.getValue('title'),
378              s: this.getValue('title'),
379            },
380          },
381          amazon: {
382            shareUrl: 'https://www.amazon.com/gp/wishlist/static-add',
383            params: {
384              u: this.getValue('url'),
385              t: this.getValue('title'),
386            },
387          },
388          pinboard: {
389            shareUrl: 'https://pinboard.in/add',
390            params: {
391              url: this.getValue('url'),
392              title: this.getValue('title'),
393              description: this.getValue('description'),
394            },
395          },
396          threema: {
397            shareUrl: 'threema://compose',
398            params: {
399              text: this.getValue('text'),
400              id: this.getValue('id'),
401            },
402          },
403          kakaostory: {
404            shareUrl: 'https://story.kakao.com/share',
405            params: {
406              url: this.getValue('url'),
407            },
408          },
409          yummly: {
410            shareUrl: 'http://www.yummly.com/urb/verify',
411            params: {
412              url: this.getValue('url'),
413              title: this.getValue('title'),
414              yumtype: 'button',
415            },
416          },
417        },
418        s = sharers[sharer];
419
420      // custom popups sizes
421      if (s) {
422        s.width = this.getValue('width');
423        s.height = this.getValue('height');
424      }
425      return s !== undefined ? this.urlSharer(s) : false;
426    },
427    /**
428     * @event urlSharer
429     * @param {Object} sharer
430     */
431    urlSharer: function (sharer) {
432      var p = sharer.params || {},
433        keys = Object.keys(p),
434        i,
435        str = keys.length > 0 ? '?' : '';
436      for (i = 0; i < keys.length; i++) {
437        if (str !== '?') {
438          str += '&';
439        }
440        if (p[keys[i]]) {
441          str += keys[i] + '=' + encodeURIComponent(p[keys[i]]);
442        }
443      }
444      sharer.shareUrl += str;
445
446      var isLink = this.getValue('link') === 'true';
447      var isBlank = this.getValue('blank') === 'true';
448
449      if (isLink) {
450        if (isBlank) {
451          window.open(sharer.shareUrl, '_blank');
452        } else {
453          window.location.href = sharer.shareUrl;
454        }
455      } else {
456        console.log(sharer.shareUrl);
457        // defaults to popup if no data-link is provided
458        var popWidth = sharer.width || 600,
459          popHeight = sharer.height || 480,
460          left = window.innerWidth / 2 - popWidth / 2 + window.screenX,
461          top = window.innerHeight / 2 - popHeight / 2 + window.screenY,
462          popParams = 'scrollbars=no, width=' + popWidth + ', height=' + popHeight + ', top=' + top + ', left=' + left,
463          newWindow = window.open(sharer.shareUrl, '', popParams);
464
465        if (window.focus) {
466          newWindow.focus();
467        }
468      }
469    },
470  };
471
472  // adding sharer events on domcontentload
473  if (document.readyState === 'complete' || document.readyState !== 'loading') {
474    Sharer.init();
475  } else {
476    document.addEventListener('DOMContentLoaded', Sharer.init);
477  }
478
479  // exporting sharer for external usage
480  window.Sharer = Sharer;
481})(window, document);

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.