PageSourceSearch

http://chinesetoday.com/static/js/iShare.js

js chinesetoday.com collected 2026-10-02 10:42:08 UTC 24,911 bytes, 823 lines download raw bytes

1/**
2 * iShare.js
3 * @author singsong
4 * @email	[email protected]
5 * @date 2016.3.6
6 */
7;
8(function (root, factory) {
9	if (typeof define === 'function' && define.amd) {
10		define([], factory(root));
11	} else if (typeof exports === 'object') {
12		module.exports = factory(root);
13	} else {
14		root.iShare = factory(root);
15	}
16})(typeof global !== 'undefined' ? global : this.window || this.global, function (root) {
17	/**
18	 * 严格模式
19	 */
20	'use strict';
21
22	/**
23	 * Util 单例工具类
24	 */
25	var Util = {
26		/**
27		 * event 事件注册与注销
28		 * addEvent 注册事件
29		 * removeEvent 注销事件
30		 */
31		event: {
32			addEvent: function (element, type, handler) {
33				if (element.addEventListener) {
34					element.addEventListener(type, handler, false);
35				} else if (element.attachEvent) {
36					element.attachEvent('on' + type, handler);
37				} else {
38					element['on' + type] = handler;
39				}
40			},
41			removeEvent: function (element, type, handler) {
42				if (element.removeEventListener) {
43					element.removeEventListener(type, handler, false);
44				} else if (element.detachEvent) {
45					element.detachEvent('on' + type, handler);
46				} else {
47					element['on' + type] = null;
48				}
49			},
50			stopPropagation: function (event) {
51				if (event.stopPropagation) {
52					event.stopPropagation();
53				} else {
54					event.cancelBubble = true;
55				}
56			},
57			preventDefault: function (event) {
58				if (event.preventDefault) {
59					event.preventDefault();
60				} else {
61					event.returnValue = false;
62				}
63			}
64		},
65		/**
66		 * trim 		
67		 * @param  {String} str 字符串
68		 * @return {String}    
69		 */
70		trim: function (str) {
71			if (String.prototype.trim) {
72				return str.trim();
73			}
74			return str.replace(/^\s+|s+$/g, '');
75		},
76
77		/**
78		 * indexOf 
79		 * @param  {Array} 	arr  数组
80		 * @param  {Object} item 项
81		 * @return {Number}      索引
82		 */
83		indexOf: function (arr, item) {
84			if (!this.isArray(arr)) {
85				throw new Error(arr.toString() + ' is a non-Array!');
86			}
87			if (Array.prototype.indexOf) {
88				return arr.indexOf(item);
89			}
90			for (var i = 0, len = arr.length; i < len; i++) {
91				if (arr[i] === item) {
92					return i;
93				}
94			}
95		},
96
97		/**
98		 * isArray 判断是否是数组
99		 * @param  {Ojbect}  arr 被判断对象
100		 * @return {Boolean}     
101		 */
102		isArray: function (arr) {
103			if (Array.isArray) {
104				return Array.isArray(arr);
105			}
106			return Object.prototype.toString.call(arr) === '[object Array]';
107		},
108
109		/**
110		 * validate 验证用户输入的有效性
111		 * @param  {Object} ref 参考对象
112		 * @param  {Object} o   验证对象
113		 * @return {Array}     	错误队列
114		 */
115		validate: function (ref, o) {
116			var _key,
117				_result = [];
118
119			if (this.isArray(o)) {
120				for (var i = 0, item; item = o[i++];) {
121					if (this.indexOf(ref, item) < 0) {
122						_result.push(item);
123					}
124				}
125			} else {
126				for (_key in o) {
127					if (!(_key in ref)) {
128						_result.push(_key);
129					}
130				}
131			}
132			if (_result.length !== 0) {
133				throw new Error('there is such no property: ' + _result.join(', '));
134			}
135		},
136
137		/**
138		 * getElementTop 获取元素的offsetTop
139		 * @param  {DOMObject} element 元素
140		 * @return {Number}    offsetTop值
141		 */
142		getElementTop: function (element) {
143			var _actualTop = element.offsetTop,
144				_current = element.offsetParent;
145			while (_current !== null) {
146				_actualTop += _current.offsetTop;
147				_current = _current.offsetParent;
148			}
149			return _actualTop;
150		},
151
152		/**
153		 * getElementLeft 获取元素的offsetLeft
154		 * @param  {DOMObject} element 元素
155		 * @return {Number}    offsetLeft值
156		 */
157		getElementLeft: function (element) {
158			var _actualTop = element.offsetLeft,
159				_current = element.offsetParent;
160			while (_current !== null) {
161				_actualTop += _current.offsetLeft;
162				_current = _current.offsetParent;
163			}
164			return _actualTop;
165		},
166		/**
167		 * handleParameters 处理URL参数
168		 * @param  {Object} options 配置项
169		 * @return {String}  
170		 */
171		handleParameters: function (options) {
172			var _str = '';
173			for (var key in options) {
174				_str = _str + key + '=' + encodeURIComponent(options[key]) + '&';
175			}
176			return _str;
177		},
178
179		/**
180		 * extend mix-in
181		 * @return {Ojbect} 
182		 */
183		extend: function () {
184			var _arg,
185				_prop,
186				_child = {};
187			for (_arg = 0; _arg < arguments.length; _arg++) {
188				for (_prop in arguments[_arg]) {
189					if (arguments[_arg].hasOwnProperty(_prop)) {
190
191						_child[_prop] = arguments[_arg][_prop];
192					}
193				}
194			}
195			return _child;
196		},
197
198		/**
199		 * each 遍历数组
200		 * @param  {Array}   	o       		数组
201		 * @param  {Function} callback		回调函数
202		 * @return {Object}
203		 */
204		each: function (o, callback) {
205			if (!o) {
206				return;
207			}
208			var _r;
209			for (var i = 0, l = o.length; i < l; i++) {
210				_r = callback.call(o[i], i, o[i]);
211			}
212			return _r;
213		},
214
215		/**
216		 * getElementByclassN 通过class获取元素
217		 * @param  {String} classNameStr 类名
218		 * @param  {Node} parent 父元素
219		 * @return {DOMObject}
220		 *
221		 * @example
222		 * getElementByclassN('.test');
223		 */
224		getElementByclassN: function (classNameStr, parent) {
225			if (!classNameStr) {
226				return;
227			}
228			var _result = [];
229
230			if (!parent && document.querySelectorAll) {
231				_result = document.querySelectorAll(classNameStr);
232				if (_result.length > 0) {
233					return _result;
234				}
235			}
236			var _cnArr = classNameStr.split('.'),
237				_prefix = _cnArr[0] || '*',
238				_suffix = _cnArr[1],
239				_parent = parent ? parent : document.body,
240				_elements = _parent.getElementsByTagName(_prefix),
241				_classNames,
242				_target;
243			var _me = this;
244			this.each(_elements, function (index, item) {
245				if (item.nodeType === 1) {
246					_classNames = item.className.split(/\s+/g);
247					_target = item;
248					_me.each(_classNames, function (cindex, citem) {
249						if ((citem + '') === _suffix) {
250							_result.push(_target);
251						}
252					});
253				}
254			});
255			return _result;
256		},
257
258		/**
259		 * getmeta 通过name获取对应meta的content值
260		 * @param  {String} name meta的name
261		 * @return {String}
262		 */
263		getmeta: function (name) {
264			var _metas = document.getElementsByTagName('meta');
265			for (var i = 0, _item; _item = _metas[i++];) {
266				if (_item.getAttribute('name') && _item.getAttribute('name').toLowerCase() === name) {
267					return _item.content;
268				}
269			}
270		},
271
272		/**
273		 * getimg 获取页面中第一张图片的URL
274		 * @return {String}
275		 */
276		getimg: function () {
277			var _imgs = this.convertToArray(document.body.getElementsByTagName('img'));
278			if (_imgs.length === 0) {
279				return;
280			}
281			return encodeURIComponent(_imgs[0].src);
282		},
283
284		/**
285		 * getElement 获取指定元素
286		 * @param {String}  selector 选择器(仅支持class和id)
287		 */
288		getElement: function (selector) {
289			var _node;
290			if (selector.charAt(0) === '#') {
291				_node = document.getElementById(selector);
292			} else {
293				_node = this.getElementByclassN(selector)[0];
294			}
295			return _node;
296		},
297
298		/**
299		 * parseUrl 解析URL
300		 * @param  {Object}	tpl  模板
301		 * @param  {Object} data 数据 
302		 * @return {Object}
303		 */
304		parseUrl: function (tpl, data) {
305			var _tplStr = {};
306			for (var _name in tpl) {
307				_tplStr[_name] = tpl[_name].replace(/{{([A-Z]*)}}/g, function (match, p1) {
308					var _key = p1.toLowerCase();
309					if (data[_key]) {
310						return encodeURIComponent(data[_key]);
311					} else {
312						return '';
313					}
314				});
315			}
316			return _tplStr;
317		},
318
319		/**
320		 * isWeixinBrowser 判断是否在微信中
321		 * @return {Boolean}
322		 */
323		isWeixinBrowser: function () {
324			var _ua = navigator.userAgent.toLowerCase();
325			return (/micromessenger/.test(_ua)) ? true : false;
326		},
327
328		/**
329		 * convertToArray 转换为数组
330		 * @param  {NodeList} nodes Nodes数组
331		 * @return {Array}      
332		 */
333		convertToArray: function (nodes) {
334			var _array = null;
335			try {
336				_array = Array.prototype.slice.call(nodes, 0);
337			} catch (ex) {
338				// 针对IE8及之前版本
339				_array = new Array();
340				for (var i = 0, len = nodes.length; i < len; i++) {
341					_array.push(nodes[i]);
342				}
343			}
344			return _array;
345		},
346
347		/**
348		 * parseClassName 解析类名
349		 * @param  {String} className 类名
350		 * @param  {Object} tpl       模板数据
351		 * @return {String}           
352		 */
353		parseClassName: function (className, tpl) {
354			var _result = null;
355			var _arr = className.split(/\s+/);
356			for (var i = 0, item; item = _arr[i++];) {
357				if (item in tpl) {
358					return tpl[item];
359				}
360			}
361		},
362
363		/**
364		 * getWinDimension 获取可视页面的尺寸
365		 * @return {Object} 
366		 */
367		getWinDimension: function () {
368			var _pageWidth = window.innerWidth,
369				_pageHeight = window.innerHeight;
370			if (typeof _pageWidth !== 'number') {
371				if (document.compatMode === 'CSS1Compat') {
372					_pageWidth = document.documentElement.clientWidth;
373					_pageHeight = document.documentElement.clientHeight;
374				} else {
375					_pageWidth = document.body.clientWidth;
376					_pageHeight = document.body.clientHeight;
377				}
378			}
379			return { pageWidth: _pageWidth, pageHeight: _pageHeight };
380		},
381		/**
382		 * throttle 节流优化
383		 * @param  {Function} fn    回调函数
384		 * @param  {Number}   delay 时间间隔
385		 */
386		throttle: function (fn, delay) {
387			var timer = null;
388			return function () {
389				var context = this, args = arguments;
390				clearTimeout(timer);
391				timer = setTimeout(function () {
392					fn.apply(context, args);
393				}, delay);
394			};
395		},
396		/**
397		 * loadjs 加载js文件
398		 * @param {String} url 路径
399		 * @param {Function} callback 回调函数
400		 */
401		loadjs: function () {
402			var ready = false,
403				cb = [];
404			return function (url, callback) {
405				var head = document.getElementsByTagName('head')[0],
406					node = document.createElement('script'),
407					isLoaded = document.getElementById('loaded'),
408					W3C = document.dispatchEvent;
409				cb.push(callback);
410				if (!ready) {
411					node.setAttribute('type', 'text/javascript');
412					node.setAttribute('id', 'loaded');
413					node.setAttribute('src', url);
414
415					node[W3C ? 'onload' : 'onreadystatechange'] = function () {
416						if (ready) {
417							return;
418						}
419						if (W3C || /loaded|complete/i.test(node.readyState)) {
420							ready = true;
421							var temp;
422							while (temp = cb.pop()) {
423								temp();
424							}
425						}
426					};
427					(!isLoaded) && (head.appendChild(node));
428				} else {
429					if (callback) {
430						callback();
431					}
432				}
433			}
434		}()
435	};
436
437	/**
438	 * WX 微信类
439	 * @param {DOMObject} element 微信按钮节点
440	 * @param {object} 		options 配置项
441	 * 
442	 */
443	function WX(element, URL, options) {
444		this.element = element;
445		this.wxbox = document.createElement('div');
446		// 配置项
447		this.URL = URL;
448		this.settings = options;
449		this.style = options.style;
450		this.bgcolor = options.bgcolor;
451		this.evenType = options.evenType || 'mouseover'; // 默认触发方式
452		this.isTitleVisibility = (options.isTitleVisibility === void (0)) ? true : options.isTitleVisibility; // 是否有标题
453		this.title = options.title || '分享到微信';
454		this.isTipVisibility = (options.isTipVisibility === void (0)) ? true : options.isTipVisibility; // 是否有提示
455		this.tip = options.tip || '“扫一扫” 即可将网页分享到朋友圈。';
456		this.upDownFlag = '';// 保存up|down
457		this.status = false; // 保存状态
458		this.visibility = false;// 保存可见性
459		this.qrcode = null; // 保存二维码
460	}
461	WX.prototype.qrcode = null;// 保存二维码
462	WX.prototype = function () {
463		return {
464			constructor: WX,
465			init: function () {
466				//this.render();
467				this.init = this.show;
468				this.bindEvent();
469			},
470			loadQrcode: function () {
471				// 加载qrcode库
472				var js = document.scripts;
473				var path = "";
474				var c = js.length;
475				for (var i = 0; i < c; i++) {
476					var it = js[i];
477					var src = it.src;
478					if (src.indexOf("iShare") >= 0) {
479						path = src.substring(0, src.lastIndexOf('/') + 1)
480					}
481				}
482				Util.loadjs(path + 'qrcode.min.js', this.startQR());
483			},
484			render: function () {
485				var _upFlag = '',
486					_downFlag = '',
487					// _widthStyle = (!this.isTitleVisibility || !this.isTipVisibility) ? 'width: 110px;' : 'width : 150px;',
488					_imgStyle = '',//待定
489					_titleStyle = '',//待定
490					_tipStyle = '', //待定
491					_bgcolor = this.bgcolor ? this.bgcolor : '#ddd',
492					_radius = '';
493
494				// 判断上下
495				if (Util.getWinDimension().pageHeight / 2 < Util.getElementTop(this.element)) {
496					_downFlag = '';
497					_upFlag = 'display:none;';
498					this.upDownFlag = 'down';
499					_radius = 'border-bottom-left-radius: 0;';
500				} else {
501					_downFlag = 'display:none;';
502					_upFlag = '';
503					this.upDownFlag = 'up';
504					_radius = 'border-top-left-radius: 0;';
505				}
506
507				var _containerHTML = '<div style="text-align: center;background-color: ' + _bgcolor + ';box-shadow: 1px 1px 4px #888888;padding: 8px 8px 4px;border-radius: 4px;' + _radius + '">',
508					_titleHTML = this.isTitleVisibility ? '<p class="tt" style="line-height:30px;margin:0; text-shadow: 1px 1px rgba(0,0,0,0.1);font-weight: 700;margin-bottom: 4px;' + _titleStyle + '">' + this.title + '</p>' : '',
509					_imgHTML = '<div class="qrcode" style="width:' + this.settings.qrcodeW + 'px; height:' + this.settings.qrcodeH + 'px; overflow:hidden;"></div>',
510					_tipHTML = this.isTipVisibility ? '<p style="line-height:20px;font-size: 12px; margin: 4px auto;width: 120px;' + _tipStyle + '">' + this.tip + '</p>' : '',
511					_upArrowHTML = '<div style="' + _upFlag + 'position: relative;height: 0;width: 0;border-style: solid;border-width: 12px;border-color: transparent;border-bottom-color: ' + _bgcolor + ';border-top: none;"></div>',
512					_downArrowHTML = '</div><div style="' + _downFlag + 'position: relative;height: 0;width: 0;border-style: solid;border-width: 12px;border-color: transparent;border-top-color: ' + _bgcolor + ';border-bottom: none;"></div>';
513				// 拼接WXHTML
514				var WXSTR = _upArrowHTML + _containerHTML + _titleHTML + _imgHTML + _tipHTML + _downArrowHTML;
515
516				this.wxbox.innerHTML = WXSTR;
517				this.wxbox.style.cssText = 'position:absolute; left: -99999px;';
518				this.element.appendChild(this.wxbox);
519				this.loadQrcode();
520			},
521			setLocation: function (flag) {
522				var _boxH = this.wxbox.offsetHeight,
523					_eW = this.element.offsetWidth,
524					_eH = this.element.offsetHeight,
525					_boxStyle = 'position:absolute; color: #000;z-index: 99999;';
526				_boxStyle = _boxStyle + 'left: ' + (_eW / 2 - 12) + 'px;';
527				if (this.upDownFlag === 'down') {
528					_boxStyle = _boxStyle + 'bottom: ' + (_eH) + 'px;';
529				} else {
530					_boxStyle = _boxStyle + 'top: ' + (_eH) + 'px;';
531				}
532				this.wxbox.style.cssText = _boxStyle + this.style;
533				flag && (this.hide());
534			},
535			bindEvent: function () {
536				var _me = this;
537				if (this.evenType === 'click') {
538					Util.event.addEvent(this.element, 'click', function (e) {
539						var event = e || window.event;
540						Util.event.stopPropagation(event);
541						Util.event.preventDefault(event);
542						if (!_me.visibility) {
543							_me.show();
544						} else {
545							_me.hide();
546						}
547					});
548				} else {
549					Util.event.addEvent(this.element, 'mouseover', function (e) {
550						var event = e || window.event;
551						// Util.event.stopPropagation(event);
552						_me.show();
553					});
554					Util.event.addEvent(this.element, 'mouseout', function (e) {
555						var event = e || window.event;
556						// Util.event.stopPropagation(event);
557						_me.hide();
558					});
559				}
560			},
561			startQR: function () {
562				var me = this;
563				return function () {
564					if (!me.qrcode) {
565						me.qrcode = new QRCode(Util.getElementByclassN('.qrcode', me.wxbox)[0], {
566							text: me.URL,
567							width: me.settings.qrcodeW,
568							height: me.settings.qrcodeH,
569							colorDark: me.settings.qrcodeFgc,
570							colorLight: me.settings.qrcodeBgc
571						});
572					}
573				}
574			},
575			show: function () {
576				this.status = true;
577				this.render();
578				this.setLocation(true);
579				this.wxbox.style.display = 'block';
580				this.visibility = true;
581				this.show = function () {
582					this.wxbox.style.display = 'block';
583					this.visibility = true;
584				}
585			},
586			hide: function () {
587				this.wxbox.style.display = 'none';
588				this.visibility = false;
589			}
590		};
591	}();
592
593
594	/**
595	 * iShare 分享
596	 * @param  {Object} options 配置项
597	 * @property container
598	 * @property config
599	 *
600	 * @description 提供两种初始化方式
601	 * #1 单例模式
602	 * #2 实例化模式 
603	 */
604	function iShare(options) {
605		var defaults = {
606			title: document.title,
607			url: location.href,
608			host: location.origin || '',
609			description: Util.getmeta('description'),
610			image: Util.getimg(),
611			sites: ['iShare_weibo', 'iShare_qq', 'iShare_wechat', 'iShare_tencent', 'iShare_douban', 'iShare_qzone', 'iShare_renren', 'iShare_youdaonote', 'iShare_facebook', 'iShare_linkedin', 'iShare_twitter', 'iShare_googleplus', 'iShare_tumblr', 'iShare_pinterest'],
612			initialized: true,
613			isTitle: true,
614			isAbroad: false,
615			WXoptions: {
616				qrcodeW: 120,
617				qrcodeH: 120,
618				qrcodeBgc: '#fff',
619				qrcodeFgc: '#000',
620				bgcolor: '#2BAD13'
621			}
622		};
623
624		var configuration = options || window.iShare_config;
625		if (configuration) {
626			if (configuration.container) {
627				if (Util.getElement(configuration.container)) {
628					this.container = Util.getElement(configuration.container);
629				} else {
630					throw new Error('there is such no className|id: "' + configuration.container + '".');
631				}
632			} else {
633				throw new Error('container property is required.');
634			}
635		} else {
636			throw new Error('container property is required.');
637		}
638
639		var dataSites = this.container.getAttribute('data-sites'),
640			dataSitesArr = dataSites ? dataSites.split(/\s*,\s*/g) : null;
641
642		/* 验证用户输入的有效性 */
643		(dataSitesArr) && (Util.validate(defaults.sites, dataSitesArr));
644		(configuration.config) && (Util.validate(defaults, configuration.config));
645		(configuration.config.sites) && (Util.validate(defaults.sites, configuration.config.sites));
646
647		/* WX */
648		this.wx = null;
649
650		/* 保存defaults */
651		this.defaults = defaults;
652		this.dataSites = dataSitesArr ? { sites: dataSitesArr } : {};
653		this.config = configuration.config ? configuration.config : {};
654
655		// 处理isAbroad
656		if ((this.config.isAbroad === void (0))) {
657			this.config.sites = this.defaults.sites; // 默认
658		} else {
659			if (this.config.isAbroad) {
660				this.config.sites = defaults.sites.slice(8); // 国外
661			} else {
662				this.config.sites = defaults.sites.slice(0, 8); // 国内
663			}
664		}
665
666		/* 验证是否在微信中 */
667		if (Util.isWeixinBrowser()) {
668			(this.defaults.indexOf('iShare_wechat') > -1) && (this.defaults.splice(this.defaults.indexOf('iShare_wechat'), 1));
669			(this.dataSites.indexOf('iShare_wechat') > -1) && (this.dataSites.splice(this.dataSites.indexOf('iShare_wechat'), 1));
670			(this.config.indexOf('iShare_wechat') > -1) && (this.config.splice(this.config.indexOf('iShare_wechat'), 1));
671		}
672
673		this.settings = Util.extend(defaults, this.config, this.dataSites);
674		this.settings.WXoptions = Util.extend(defaults.WXoptions, this.config.WXoptions);
675		this.init();
676	}
677	iShare.prototype = (function () {
678		// 接口模板
679		var _templates = {
680			iShare_qq: 'http://connect.qq.com/widget/shareqq/index.html?url={{URL}}&title={{TITLE}}&desc={{DESCRIPTION}}&summary=&pics={{IMAGE}}',
681			iShare_qzone: 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url={{URL}}&title={{TITLE}}&summary={{DESCRIPTION}}&pics={{IMAGE}}&desc=&site=',
682			iShare_tencent: 'http://share.v.t.qq.com/index.php?c=share&a=index&title={{TITLE}}&url={{URL}}&pic={{IMAGE}}',
683			iShare_weibo: 'http://service.weibo.com/share/share.php?url={{URL}}&title={{TITLE}}&pic={{IMAGE}}',
684			iShare_wechat: '',
685			iShare_douban: 'http://shuo.douban.com/!service/share?href={{URL}}&name={{TITLE}}&text={{DESCRIPTION}}&image={{IMAGE}}',
686			iShare_renren: 'http://widget.renren.com/dialog/share?resourceUrl={{URL}}&title={{TITLE}}&pic={{IMAGE}}&description={{DESCRIPTION}}',
687			iShare_youdaonote: 'http://note.youdao.com/memory/?title={{TITLE}}&pic={{IMAGE}}&summary={{DESCRIPTION}}&url={{URL}}',
688			iShare_linkedin: 'http://www.linkedin.com/shareArticle?mini=true&ro=true&title={{TITLE}}&url={{URL}}&summary={{DESCRIPTION}}&armin=armin',
689			iShare_facebook: 'https://www.facebook.com/sharer/sharer.php?s=100&p[title]={{TITLE}}p[summary]={{DESCRIPTION}}&p[url]={{URL}}&p[images]={{IMAGE}}',
690			iShare_twitter: 'https://twitter.com/intent/tweet?text={{TITLE}}&url={{URL}}',
691			iShare_googleplus: 'https://plus.google.com/share?url={{URL}}&t={{TITLE}}',
692			iShare_pinterest: 'https://www.pinterest.com/pin/create/button/?url={{URL}}&description={{DESCRIPTION}}&media={{IMAGE}}',
693			iShare_tumblr: 'https://www.tumblr.com/widgets/share/tool?shareSource=legacy&canonicalUrl=&url={{URL}}&title={{TITLE}}'
694		},
695			_names = {
696				iShare_qq: 'QQ好友',
697				iShare_qzone: 'QQ空间',
698				iShare_tencent: '腾讯微博',
699				iShare_weibo: '新浪微博',
700				iShare_wechat: '微信',
701				iShare_douban: '豆瓣',
702				iShare_renren: '人人',
703				iShare_youdaonote: '有道笔记',
704				iShare_linkedin: 'Linkedin',
705				iShare_facebook: 'Facebook',
706				iShare_twitter: 'Twitter',
707				iShare_googleplus: 'Google+',
708				iShare_pinterest: 'Pinterest',
709				iShare_tumblr: 'Tumblr'
710			},
711			_icons = {
712				iShare_qq: '<i class="iconfont qq">&#xe60f;</i>',
713				iShare_qzone: '<i class="iconfont qzone">&#xe610;</i>',
714				iShare_tencent: '<i class="iconfont tencent" style="vertical-align: -2px;">&#xe608;</i>',
715				iShare_weibo: '<i class="iconfont weibo">&#xe609;</i>',
716				iShare_wechat: '<i class="iconfont wechat" style="vertical-align: -2px;">&#xe613;</i>',
717				iShare_douban: '<i class="iconfont douban" style="vertical-align: -2px;">&#xe612;</i>',
718				iShare_renren: '<i class="iconfont renren">&#xe603;</i>',
719				iShare_youdaonote: '<i class="iconfont youdaonote" style="vertical-align: -2px;">&#xe604;</i>',
720				iShare_linkedin: '<i class="iconfont linkedin" style="vertical-align: 1px;">&#xe607;</i>',
721				iShare_facebook: '<i class="iconfont facebook" style="vertical-align: 1px;">&#xe601;</i>',
722				iShare_twitter: '<i class="iconfont twitter" style="vertical-align: 1px;">&#xe60a;</i>',
723				iShare_googleplus: '<i class="iconfont googleplus" style="vertical-align: -2px;">&#xe60b;</i>',
724				iShare_pinterest: '<i class="iconfont pinterest" style="vertical-align: -2px;">&#xe60c;</i>',
725				iShare_tumblr: '<i class="iconfont tumblr" style="vertical-align: 0px;">&#xe600;</i>'
726			};
727    /**
728     * _updateUrl 更新添加分享的A标签
729     */
730		function _updateUrl() {
731			if (!this.container.hasChildNodes()) {
732				return;
733			}
734			var _children = this.container.childNodes,
735				_tempURL;
736
737			for (var i = 0, item; item = _children[i++];) {
738				if (item.nodeType === 1) {
739					_tempURL = Util.parseClassName(item.className, Util.parseUrl(_templates, this.settings));
740					if ((item.className).indexOf('iShare_wechat') > -1) {
741						// this.wx = new WX(item, _tempURL, this.settings.WXoptions);
742						this.wx = new WX(item, this.settings.url, this.settings.WXoptions);
743					} else {
744						_tempURL && (item.href = _tempURL);
745						item.target = '_blank';
746					}
747				}
748			}
749		}
750		/**
751		 * _createShareElements 创建分享元素
752		 * @param  {String}  url      分享接口
753		 * @param  {String}  item     key
754		 * @param  {Boolean} isWechat 是否是微信
755		 * @return {DOMObject}           
756		 */
757		function _createShareElements(url, item, isWechat) {
758			var _e = document.createElement('a');
759			_e.innerHTML = _icons[item];
760			if (this.settings.isTitle) {
761				_e.title = _names[item];
762			}
763			if (isWechat) {
764				this.wx = new WX(_e, url, this.settings.WXoptions);
765				_e.href = 'javascript:void(0);';
766			} else {
767				_e.href = url;
768				_e.target = '_blank';
769			}
770			return _e;
771		}
772		/**
773		 * _autoUpdate 动态创建分享
774		 */
775		function _autoUpdate() {
776			var _docfrag = document.createDocumentFragment(),
777				_tpls = Util.parseUrl(_templates, this.settings),
778				_element,
779				_me = this;
780
781			Util.each(_me.settings.sites, function (index, item) {
782				if (item === 'iShare_wechat') {
783					// _element = _createShareElements.call(_me, _tpls[item], item, true);
784					_element = _createShareElements.call(_me, _me.settings.url, item, true);
785				} else {
786					_element = _createShareElements.call(_me, _tpls[item], item);
787				}
788				_docfrag.appendChild(_element);
789			});
790			this.container.innerHTML = '';
791			this.container.appendChild(_docfrag);
792		}
793
794		//prototype
795		return {
796			constructor: iShare,
797			init: function () {
798				if (this.settings.initialized) {
799					_autoUpdate.call(this);
800				} else {
801					_updateUrl.call(this);
802				}
803				if (this.wx) {
804					this.bindEvent();
805					this.wx.init();
806				}
807			},
808			bindEvent: function () {
809				var me = this;
810				// 只绑定一次,进行初始化
811				function mouseenterCB() {
812					Util.event.removeEvent(me.container, 'mouseover', mouseenterCB);
813				}
814				Util.event.addEvent(this.container, 'mouseover', mouseenterCB);
815			}
816		}
817	})();
818	if (window.iShare_config) {
819		return (new iShare());
820	} else {
821		return iShare;
822	}
823});

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.