1/* 2 * @Description: å享æä»¶ 3 */ 4; 5(function($, window, document, undefined) { 6 //æä»¶åå§å 7 function init(target, options) { 8 var settings = $.extend({}, $.fn.socialShare.defaults, options); 9 //åå§åå个ç»ä»¶ 10 var $social_group = "<div class='social_group share_icons'>" 11 + "<a target='_blank' class='msb_network_button weixin a-icon weixin-icon'></a>" 12 + "<a target='_blank' class='msb_network_button sina a-icon sina-icon'></a>" 13 + "<a target='_blank' class='msb_network_button tQQ a-icon qq-icon'></a>" 14 + "</div>" 15 + "<div class='fr'>å享å°ï¼</div>"; 16 $(target).append($social_group); 17 $(target).addClass("socialShare"); 18 19 //æ·»å è ¾è®¯å¾®åå享äºä»¶ 20 $(document).on("click", ".msb_network_button.tQQ", function() { 21 tQQ(this, settings); 22 }); 23 //æ·»å QQ空é´å享äºä»¶ 24 $(document).on("click", ".msb_network_button.qZone", function() { 25 qZone(this, settings); 26 }); 27 //æ·»å æ°æµªå¾®åå享äºä»¶ 28 $(document).on("click", ".msb_network_button.sina", function() { 29 sinaWeibo(this, settings); 30 }); 31 //æ·»å è±ç£å享äºä»¶ 32 $(document).on("click", ".msb_network_button.douban", function() { 33 doubanShare(this, settings); 34 }); 35 //æ·»å 微信å享äºä»¶ 36 $(document).on("click", ".msb_network_button.weixin", function() { 37 weixinShare(this, settings); 38 }); 39 } 40 41 function replaceAPI(api, options) { 42 api = api.replace('{url}', options.url); 43 api = api.replace('{title}', options.title); 44 api = api.replace('{content}', options.content); 45 api = api.replace('{pic}', options.pic); 46 return api; 47 } 48 49 function OPenWindow(URL) { 50 var openUrl = URL; //å¼¹åºçªå£çurl 51 var iWidth = 630; //å¼¹åºçªå£ç宽度; 52 var iHeight = 580; //å¼¹åºçªå£çé«åº¦; 53 var iTop = (window.screen.availHeight - 30 - iHeight) / 2; //è·å¾çªå£çåç´ä½ç½®; 54 var iLeft = (window.screen.availWidth - 10 - iWidth) / 2; //è·å¾çªå£çæ°´å¹³ä½ç½®; 55 window.open(openUrl, "", "height=" + iHeight + ", width=" + iWidth + ", top=" + iTop + ", left=" + iLeft + "" + ",toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no"); 56 //window.open('page.html', 'newwindow', 'height=580, width=650, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no'); 57 } 58 59 function tQQ(target, options) { 60 var options = $.extend({}, $.fn.socialShare.defaults, options); 61 OPenWindow(replaceAPI(tqq, options)); 62 // window.open(replaceAPI(tqq, options)); 63 } 64 65 function qZone(target, options) { 66 var options = $.extend({}, $.fn.socialShare.defaults, options); 67 OPenWindow(replaceAPI(qzone, options)); 68 // window.open(replaceAPI(qzone, options)); 69 } 70 71 function sinaWeibo(target, options) { 72 var options = $.extend({}, $.fn.socialShare.defaults, options); 73 OPenWindow(replaceAPI(sina, options)); 74 // window.open(replaceAPI(sina, options)); 75 } 76 77 function doubanShare(target, options) { 78 var options = $.extend({}, $.fn.socialShare.defaults, options); 79 OPenWindow(replaceAPI(douban, options)); 80 // window.open(replaceAPI(douban, )); 81 } 82 83 function weixinShare(target, options) { 84 var options = $.extend({}, $.fn.socialShare.defaults, options); 85 console.log(options); 86 showWX(replaceAPI(weixin, options)); 87 88 // window.open(replaceAPI(weixin, )); 89 } 90 91 function autocenter() { 92 var bodyW = parseInt(document.documentElement.clientWidth); 93 var bodyH = parseInt(document.documentElement.clientHeight); 94 var elW = $("#weixin").width(); 95 var elH = $("#weixin").height(); 96 console.log((bodyW - elW) / 2); 97 $("#weixin").css("left", (bodyW - elW) / 2); 98 $("#weixin").css("top", (bodyH - elH) / 2); 99 } 100 101 function showWX(url) { 102 var weixing = '<div id="weixin">' + 103 '<div class="bd_weixin_popup_head">' + 104 '<span>å享å°å¾®ä¿¡æåå</span>' + 105 '<a id="close" class="bd_weixin_popup_close">Ã</a>' + 106 '</div>' + 107 '<div class="erweima">' + 108 '<img class="erweimas" src="" />' + 109 '</div>' + 110 '<p class="msgs">æå¼å¾®ä¿¡ï¼ç¹å»å³ä¸è§ç + ï¼<br/> 使ç¨âæ«ä¸æ«âå³å¯å°ç½é¡µåäº«è³æååã</p>' + 111 '</div>'; 112 $("body").append(weixing); 113 $(".erweimas").attr('src', url); 114 autocenter(); 115 $("#weixin").show(); 116 } 117 $(document).on('click', "#close", function() { 118 $("#weixin").hide(); 119 });
120 $.fn.socialShare = function(options, param) { 121 if(typeof options == 'string') { 122 var method = $.fn.socialShare.methods[options]; 123 if(method) 124 return method(this, param); 125 } else 126 init(this, options); 127 } 128 129 //æä»¶é»è®¤åæ° 130 $.fn.socialShare.defaults = { 131 url: window.location.href, 132 title: document.title, 133 content: '', 134 pic: '' 135 } 136 137 //æä»¶æ¹æ³ 138 $.fn.socialShare.methods = { 139 //åå§åæ¹æ³ 140 init: function(jq, options) { 141 return jq.each(function() { 142 init(this, options); 143 }); 144 }, 145 tQQ: function(jq, options) { 146 return jq.each(function() { 147 tQQ(this, options); 148 }) 149 }, 150 qZone: function(jq, options) { 151 return jq.each(function() { 152 qZone(this, options); 153 }) 154 }, 155 sinaWeibo: function(jq, options) { 156 return jq.each(function() { 157 sinaWeibo(this, options); 158 }); 159 }, 160 doubanShare: function(jq, options) { 161 return jq.each(function() { 162 doubanShare(this, options); 163 }); 164 }, 165 weixinShare: function(jq, options) { 166 return jq.each(function() { 167 weixinShare(this, options); 168 }); 169 } 170 } 171 172 //å享å°å 173 var qzone = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url={url}&title={title}&pics={pic}&summary={content}'; 174 var sina = 'http://service.weibo.com/share/share.php?url={url}&title={title}&pic={pic}&searchPic=false'; 175 var tqq = 'http://share.v.t.qq.com/index.php?c=share&a=index&url={url}&title={title}&appkey=801cf76d3cfc44ada52ec13114e84a96'; 176 var douban = 'http://www.douban.com/share/service?href={url}&name={title}&text={content}&image={pic}'; 177 var weixin = 'http://qr.liantu.com/api.php?text={url}'; //æ¥åURLè¿åå¾ç 178 179})(jQuery, 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.