website/themes/LoveIt/assets/lib/sharer/sharer.min.js

1 line
7.2 KiB
JavaScript
Raw Normal View History

2022-12-01 17:30:08 +01:00
(function(m,r){"use strict";var s=function(t){this.elem=t};s.init=function(){var t=r.querySelectorAll("[data-sharer]"),e,a=t.length;for(e=0;e<a;e++){t[e].addEventListener("click",s.add)}};s.add=function(t){var e=t.currentTarget||t.srcElement;var a=new s(e);a.share()};s.prototype={constructor:s,getValue:function(t){var e=this.elem.getAttribute("data-"+t);if(e&&t==="hashtag"){if(!e.startsWith("#")){e="#"+e}}return e===null?"":e},share:function(){var t=this.getValue("sharer").toLowerCase(),e={facebook:{shareUrl:"https://www.facebook.com/sharer/sharer.php",params:{u:this.getValue("url"),hashtag:this.getValue("hashtag"),quote:this.getValue("quote")}},linkedin:{shareUrl:"https://www.linkedin.com/shareArticle",params:{url:this.getValue("url"),mini:true}},twitter:{shareUrl:"https://twitter.com/intent/tweet/",params:{text:this.getValue("title"),url:this.getValue("url"),hashtags:this.getValue("hashtags"),via:this.getValue("via")}},email:{shareUrl:"mailto:"+this.getValue("to"),params:{subject:this.getValue("subject"),body:this.getValue("title")+"\n"+this.getValue("url")}},whatsapp:{shareUrl:this.getValue("web")==="true"?"https://web.whatsapp.com/send":"https://wa.me/",params:{phone:this.getValue("to"),text:this.getValue("title")+" "+this.getValue("url")}},telegram:{shareUrl:"https://t.me/share",params:{text:this.getValue("title"),url:this.getValue("url")}},viber:{shareUrl:"viber://forward",params:{text:this.getValue("title")+" "+this.getValue("url")}},line:{shareUrl:"http://line.me/R/msg/text/?"+encodeURIComponent(this.getValue("title")+" "+this.getValue("url"))},pinterest:{shareUrl:"https://www.pinterest.com/pin/create/button/",params:{url:this.getValue("url"),media:this.getValue("image"),description:this.getValue("description")}},tumblr:{shareUrl:"http://tumblr.com/widgets/share/tool",params:{canonicalUrl:this.getValue("url"),content:this.getValue("url"),posttype:"link",title:this.getValue("title"),caption:this.getValue("caption"),tags:this.getValue("tags")}},hackernews:{shareUrl:"https://news.ycombinator.com/submitlink",params:{u:this.getValue("url"),t:this.getValue("title")}},reddit:{shareUrl:"https://www.reddit.com/submit",params:{url:this.getValue("url"),title:this.getValue("title")}},vk:{shareUrl:"http://vk.com/share.php",params:{url:this.getValue("url"),title:this.getValue("title"),description:this.getValue("caption"),image:this.getValue("image")}},xing:{shareUrl:"https://www.xing.com/social/share/spi",params:{url:this.getValue("url")}},buffer:{shareUrl:"https://buffer.com/add",params:{url:this.getValue("url"),title:this.getValue("title"),via:this.getValue("via"),picture:this.getValue("picture")}},instapaper:{shareUrl:"http://www.instapaper.com/edit",params:{url:this.getValue("url"),title:this.getValue("title"),description:this.getValue("description")}},pocket:{shareUrl:"https://getpocket.com/save",params:{url:this.getValue("url")}},mashable:{shareUrl:"https://mashable.com/submit",params:{url:this.getValue("url"),title:this.getValue("title")}},mix:{shareUrl:"https://mix.com/add",params:{url:this.getValue("url")}},flipboard:{shareUrl:"https://share.flipboard.com/bookmarklet/popout",params:{v:2,title:this.getValue("title"),url:this.getValue("url"),t:Date.now()}},weibo:{shareUrl:"http://service.weibo.com/share/share.php",params:{url:this.getValue("url"),title:this.getValue("title"),pic:this.getValue("image"),appkey:this.getValue("appkey"),ralateUid:this.getValue("ralateuid"),language:"zh_cn"}},blogger:{shareUrl:"https://www.blogger.com/blog-this.g",params:{u:this.getValue("url"),n:this.getValue("title"),t:this.getValue("description")}},baidu:{shareUrl:"http://cang.baidu.com/do/add",params:{it:this.getValue("title"),iu:this.getValue("url")}},douban:{shareUrl:"https://www.douban.com/share/service",params:{name:this.getValue("name"),href:this.getValue("url"),image:this.getValue("image"),comment:this.getValue("description")}},okru:{shareUrl:"https://connect.ok.ru/dk",params:{"st.cmd":"WidgetSharePreview","st.shareUrl":this.getValue("url"),title:this.getValue("title")}},mailru:{shareUrl:"http://connect.mail.ru/share",params:{share