UNPKG

dzxstatic

Version:

The static files of Discuz! X

1 lines 2.56 kB
var _share_tencent_weibo=function(){var share_btn=function(e){if(e[0])return e[0];var t=document.createElement("a"),n="width:92px;height:22px;background:url(http://open.t.qq.com/apps/qshare/images/icon.gif) no-repeat #f00;position:absolute;display:none;";return t.setAttribute("style",n),t.style.cssText=n,t.setAttribute("href","javascript:;"),document.body.insertBefore(t,document.body.childNodes[0]),t}(arguments),share_area=(_arr=arguments,_arr[1]?"object"==typeof _arr[1]&&_arr[1].length||_arr[1].constructor==Array?_arr[1]:[_arr[1]]:[document.body]),_arr,current_area=share_area[0],_site=arguments[2]?arguments[2]:"",_appkey=encodeURI(arguments[3]?arguments[3]:""),_web={name:arguments[4]||"",href:location.href,hash:location.hash},_pic=function(e){for(var t=e.getElementsByTagName("img"),n=[],r=0;r<t.length;r++)n.push(t[r].src);return n.join("|")},_u="http://v.t.qq.com/share/share.php?url=$url$&appkey="+_appkey+"&site="+_site+"&title=$title$&pic=$pic$",_select=function(){return(document.selection?document.selection.createRange().text:document.getSelection()).toString().replace(/[\s\n]+/g," ")};window.find&&(HTMLElement.prototype.contains=function(e){return this.compareDocumentPosition(e)-19>0}),String.prototype.elength=function(){return this.replace(/[^\u0000-\u00ff]/g,"aa").length},document.onmouseup=function(e){e=e||window.event;for(var o=e.target||e.srcElement,i=0;i<share_area.length;i++)if(share_area[i].contains(o)||share_area[i]==o){var _e={x:e.clientX,y:e.clientY},_o={w:share_btn.clientWidth,h:share_btn.clientHeight},_d=window.pageYOffset||(document.documentElement||document.body).scrollTop||0,x=_e.x-_o.w<0?_e.x+_o.w:_e.x-_o.w,y=_e.y-_o.h<0?_e.y+_d-_o.h:_e.y+_d-_o.h+(-[1]?10:0);if(_select()&&_select().length>=10){with(share_btn.style)display="inline-block",left=x-5+"px",top=y+"px",position="absolute",zIndex="999999";current_area=share_area[i];break}share_btn.style.display="none"}else share_btn.style.display="none"},share_btn.onclick=function(){var e=_select(),t=280-("我来自于腾讯微博开放平台 "+_web.name).elength(),n="";if(e.elength()>t){for(var r=(t-=3)>>1;r<=t&&!(e.slice(0,r).elength()>t);r++)n=e.slice(0,r);n+="..."}else n=e;if(e){var a=_u.replace("$title$",encodeURIComponent(n+" "+_web.name)).replace("$pic$",_pic(current_area));a=a.replace("$url$",encodeURIComponent(_web.href.replace(_web.hash,"")+"#"+(current_area.name||current_area.id||""))),-[1]||(a=a.substr(0,2048)),window.open(a,"null","width=700,height=680,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,location=yes,resizable=no,status=no")}}};