Skip to content

Instantly share code, notes, and snippets.

View zhuzhuaicoding's full-sized avatar

zhuzhu_coder zhuzhuaicoding

View GitHub Profile
/** @inner Event对象兼容处理 */
fix: function (event) {
if (event.target) return event;
var event2 = {
target: event.srcElement || document,
preventDefault: function () {event.returnValue = false},
stopPropagation: function () {event.cancelBubble = true}
};
// IE6/7/8 在原生window.event对象写入数据会导致内存无法回收,应当采用拷贝
var baseElement = h.getElementsByTagName('base')[0];
node = document.createElement('script');
node.charset = this._charset || 'utf-8';
node.onload = node.onreadystatechange = function () {
if (!node.readyState || node.readyState == 'complete' || node.readyState == 'loaded') {
node.onload = node.onreadystatechange = null;
if (node.parentNode) {
h.removeChild(node);
}
callback();
optmz = function (st) {
return function (fns, tm) {
var aargs;
if (typeof fns == 'string') {
return st(fns, tm);
} else {
aargs = Array.prototype.slice.call(arguments, 2);
return st(function () {
fns.apply(null, aargs);
}, tm);
getRealLen: function (s, isUTF8) {
if (typeof(s) != 'string') {
return 0;
}
if (!isUTF8) {
return s.replace(QZFL.string.RegExps.getRealLen.r0, "**").length;
} else {
var cc = s.replace(QZFL.string.RegExps.getRealLen.r1, "");
return(s.length - cc.length) + (encodeURI(cc).length / 3);
}
var _Queue = function (key, queue) {
if (this instanceof arguments.callee) {
this._qz_queuekey = key;
return this;
}
if (_o.getType(queue = queue || []) == "array") {
_queue[key] = queue;
}
return new _Queue(key);
};
var url = node.hasAttribute ? // non-IE6/7
node.src :
// see http://msdn.microsoft.com/en-us/library/ms536429(VS.85).aspx
node.getAttribute('src', 4);
(function () {
var timer = null;
$(window).resize(function () {
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(function () {
$(window).trigger('windowResize');
timer = null;
}, 100);
getRelatedTarget: function (ev) {
ev = QZFL.event.getEvent(ev);
var t = ev.relatedTarget;
if (!t)if (ev.type == "mouseout")t = ev.toElement; else if (ev.type == "mouseover")t = ev.fromElement; else;
return t
}, onDomReady: function (fn) {
var _s = QZFL.event.onDomReady;
QZFL.event._bindReady();
_s.pool.push(fn)
}, _bindReady: function () {
LIB.setTimeout = function (callback, timeout, context, args) {
return setTimeout(function () {
callback.apply(context, args || [])
}, timeout)
};
baidu.sio._createScriptTag = function (b, a, c) {
b.setAttribute("type", "text/javascript");
c && b.setAttribute("charset", c);
b.setAttribute("src", a);
document.getElementsByTagName("head")[0].appendChild(b)
};
baidu.sio._removeScriptTag = function (b) {
if (b.clearAttributes) {
b.clearAttributes()
} else {