/**
 * social-share.js
 *
 * @author  52cik <fe.52cik@gmail.com>
 * @license MIT
 *
 * @example
 * <pre>
 * socialShare('.share-components');
 *
 * // or
 *
 * socialShare('.share-bar', {
 *     sites: ['qzone', 'qq', 'weibo','wechat'],
 *     // ...
 * });
 * </pre>
 */
!function(e,t,i){var n,r,a,o=Array.prototype.indexOf,c=Object.assign,s=/MicroMessenger/i.test(navigator.userAgent),l=t.documentElement.clientWidth<=768,u=(t.images[0]||0).src||"",d=v("site")||v("Site")||t.title,h=v("title")||v("Title")||t.title,f=v("description")||v("Description")||"",p={url:location.href,origin:location.origin,source:d,title:h,description:f,image:u,imageSelector:i,weiboKey:"",wechatQrcodeTitle:"微信扫一扫：分享",wechatQrcodeHelper:"<p>微信里点“发现”，扫一下</p><p>二维码便可将本文分享至朋友圈。</p>",wechatQrcodeSize:100,sites:["weibo","qq","wechat","douban","qzone","linkedin","facebook","twitter","google"],mobileSites:[],disabled:[],initialized:!1},m={qzone:"http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url={{URL}}&title={{TITLE}}&desc={{DESCRIPTION}}&summary={{SUMMARY}}&site={{SOURCE}}&pics={{IMAGE}}",qq:'http://connect.qq.com/widget/shareqq/index.html?url={{URL}}&title={{TITLE}}&source={{SOURCE}}&desc={{DESCRIPTION}}&pics={{IMAGE}}&summary="{{SUMMARY}}"',weibo:"https://service.weibo.com/share/share.php?url={{URL}}&title={{TITLE}}&pic={{IMAGE}}&appkey={{WEIBOKEY}}",wechat:"javascript:",douban:"http://shuo.douban.com/!service/share?href={{URL}}&name={{TITLE}}&text={{DESCRIPTION}}&image={{IMAGE}}&starid=0&aid=0&style=11",linkedin:"http://www.linkedin.com/shareArticle?mini=true&ro=true&title={{TITLE}}&url={{URL}}&summary={{SUMMARY}}&source={{SOURCE}}&armin=armin",facebook:"https://www.facebook.com/sharer/sharer.php?u={{URL}}",twitter:"https://twitter.com/intent/tweet?text={{TITLE}}&url={{URL}}&via={{ORIGIN}}",google:"https://plus.google.com/share?url={{URL}}"};function g(i){return(t.querySelectorAll||e.jQuery||e.Zepto||w).call(t,i)}function w(e){var i=[];return E(e.split(/\s*,\s*/),(function(n){var r=n.match(/([#.])(\w+)/);if(null===r)throw Error("Supports only simple single #ID or .CLASS selector.");if(r[1]){var a=t.getElementById(r[2]);a&&i.push(a)}i=i.concat(S(e))})),i}function v(e){return(t.getElementsByName(e)[0]||0).content}function S(e,t,i){if(e.getElementsByClassName)return e.getElementsByClassName(t);var n=[],r=e.getElementsByTagName(i||"*");return t=" "+t+" ",E(r,(function(e){(" "+(e.className||"")+" ").indexOf(t)>=0&&n.push(e)})),n}function y(e){var i=t.createElement("div");return i.innerHTML=e,i.childNodes}function E(e,t){var n=e.length;if(n===i){for(var r in e)if(e.hasOwnProperty(r)&&!1===t.call(e[r],e[r],r))break}else for(var a=0;a<n&&!1!==t.call(e[a],e[a],a);a++);}e.socialShare=function(e,t){(e="string"==typeof e?g(e):e).length===i&&(e=[e]),E(e,(function(e){e.initialized||function(e,t){var n=function(){var e=arguments;if(c)return c.apply(null,e);var t={};return E(e,(function(e){E(e,(function(e,i){t[i]=e}))})),e[0]=t}({},p,t||{},function(e){if(e.dataset)return JSON.parse(JSON.stringify(e.dataset));var t={};if(e.hasAttributes())return E(e.attributes,(function(e){var i=e.name;if(0!==i.indexOf("data-"))return!0;i=i.replace(/^data-/i,"").replace(/-(\w)/g,(function(e,t){return t.toUpperCase()})),t[i]=e.value})),t;return{}}(e));n.imageSelector&&(n.image=g(n.imageSelector).map((function(e){return e.src})).join("||"));(function(e,t){if(t&&"string"==typeof t){var i=(e.className+" "+t).split(/\s+/),n=" ";E(i,(function(e){n.indexOf(" "+e+" ")<0&&(n+=e+" ")})),e.className=n.slice(1,-1)}})(e,"share-component social-share"),function(e,t){var n=function(e){e.mobileSites.length||(e.mobileSites=e.sites);var t=(l?e.mobileSites:e.sites).slice(0),i=e.disabled;"string"==typeof t&&(t=t.split(/\s*,\s*/));"string"==typeof i&&(i=i.split(/\s*,\s*/));s&&i.push("wechat");return i.length&&E(i,(function(e){t.splice(function(e,t,i){var n;if(t){if(o)return o.call(t,e,i);for(n=t.length,i=i?i<0?Math.max(0,n+i):i:0;i<n;i++)if(i in t&&t[i]===e)return i}return-1}(e,t),1)})),t}(t),r="prepend"==t.mode;E(r?n.reverse():n,(function(n){var a=function(e,t){t.summary||(t.summary=t.description);return m[e].replace(/\{\{(\w)(\w*)\}\}/g,(function(n,r,a){var o=e+r+a.toLowerCase();return a=(r+a).toLowerCase(),encodeURIComponent((t[o]===i?t[a]:t[o])||"")}))}(n,t),o=t.initialized?S(e,"icon_"+n):y('<a class="social-share-icon icon-'+n+" iconfont icon_"+n+'"></a>');if(!o.length)return!0;o[0].href=a,"wechat"===n?o[0].tabindex=-1:o[0].target="_blank",t.initialized||(r?e.insertBefore(o[0],e.firstChild):e.appendChild(o[0]))}))}(e,n),function(e,t){var i=S(e,"icon_wechat","a");if(0===i.length)return!1;var n=y('<div class="wechat-qrcode"><h4>'+t.wechatQrcodeTitle+'</h4><div class="qrcode"></div><div class="help">'+t.wechatQrcodeHelper+"</div></div>"),r=S(n[0],"qrcode","div");new QRCode(r[0],{text:t.url,width:t.wechatQrcodeSize,height:t.wechatQrcodeSize}),i[0].appendChild(n[0])}(e,n),e.initialized=!0}(e,t)}))},n=function(){socialShare(".social-share, .share-component")},a=t[r="addEventListener"]?"":"on",~t.readyState.indexOf("m")?n():"load DOMContentLoaded readystatechange".replace(/\w+/g,(function(i,o){(o?t:e)[a?"attachEvent":r](a+i,(function(){n&&(o<6||~t.readyState.indexOf("m"))&&(n(),n=0)}),!1)}))}(window,document);