|
|
|
|
/*! jQuery v1.8.3 jquery.com | jquery.org/license */
|
|
|
|
|
(function(e,t){function _(e){var t=M[e]={};return v.each(e.split(y),function(e,n){t[n]=!0}),t}function H(e,n,r){if(r===t&&e.nodeType===1){var i="data-"+n.replace(P,"-$1").toLowerCase();r=e.getAttribute(i);if(typeof r=="string"){try{r=r==="true"?!0:r==="false"?!1:r==="null"?null:+r+""===r?+r:D.test(r)?v.parseJSON(r):r}catch(s){}v.data(e,n,r)}else r=t}return r}function B(e){var t;for(t in e){if(t==="data"&&v.isEmptyObject(e[t]))continue;if(t!=="toJSON")return!1}return!0}function et(){return!1}function tt(){return!0}function ut(e){return!e||!e.parentNode||e.parentNode.nodeType===11}function at(e,t){do e=e[t];while(e&&e.nodeType!==1);return e}function ft(e,t,n){t=t||0;if(v.isFunction(t))return v.grep(e,function(e,r){var i=!!t.call(e,r,e);return i===n});if(t.nodeType)return v.grep(e,function(e,r){return e===t===n});if(typeof t=="string"){var r=v.grep(e,function(e){return e.nodeType===1});if(it.test(t))return v.filter(t,r,!n);t=v.filter(t,r)}return v.grep(e,function(e,r){return v.inArray(e,t)>=0===n})}function lt(e){var t=ct.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}function Lt(e,t){return e.getElementsByTagName(t)[0]||e.appendChild(e.ownerDocument.createElement(t))}function At(e,t){if(t.nodeType!==1||!v.hasData(e))return;var n,r,i,s=v._data(e),o=v._data(t,s),u=s.events;if(u){delete o.handle,o.events={};for(n in u)for(r=0,i=u[n].length;r<i;r++)v.event.add(t,n,u[n][r])}o.data&&(o.data=v.extend({},o.data))}function Ot(e,t){var n;if(t.nodeType!==1)return;t.clearAttributes&&t.clearAttributes(),t.mergeAttributes&&t.mergeAttributes(e),n=t.nodeName.toLowerCase(),n==="object"?(t.parentNode&&(t.outerHTML=e.outerHTML),v.support.html5Clone&&e.innerHTML&&!v.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):n==="input"&&Et.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):n==="option"?t.selected=e.defaultSelected:n==="input"||n==="textarea"?t.defaultValue=e.defaultValue:n==="script"&&t.text!==e.text&&(t.text=e.text),t.removeAttribute(v.expando)}function Mt(e){return typeof e.getElementsByTagName!="undefined"?e.getElementsByTagName("*"):typeof e.querySelectorAll!="undefined"?e.querySelectorAll("*"):[]}function _t(e){Et.test(e.type)&&(e.defaultChecked=e.checked)}function Qt(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=Jt.length;while(i--){t=Jt[i]+n;if(t in e)return t}return r}function Gt(e,t){return e=t||e,v.css(e,"display")==="none"||!v.contains(e.ownerDocument,e)}function Yt(e,t){var n,r,i=[],s=0,o=e.length;for(;s<o;s++){n=e[s];if(!n.style)continue;i[s]=v._data(n,"olddisplay"),t?(!i[s]&&n.style.display==="none"&&(n.style.display=""),n.style.display===""&&Gt(n)&&(i[s]=v._data(n,"olddisplay",nn(n.nodeName)))):(r=Dt(n,"display"),!i[s]&&r!=="none"&&v._data(n,"olddisplay",r))}for(s=0;s<o;s++){n=e[s];if(!n.style)continue;if(!t||n.style.display==="none"||n.style.display==="")n.style.display=t?i[s]||"":"none"}return e}function Zt(e,t,n){var r=Rt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function en(e,t,n,r){var i=n===(r?"border":"content")?4:t==="width"?1:0,s=0;for(;i<4;i+=2)n==="margin"&&(s+=v.css(e,n+$t[i],!0)),r?(n==="content"&&(s-=parseFloat(Dt(e,"padding"+$t[i]))||0),n!=="margin"&&(s-=parseFloat(Dt(e,"border"+$t[i]+"Width"))||0)):(s+=parseFloat(Dt(e,"padding"+$t[i]))||0,n!=="padding"&&(s+=parseFloat(Dt(e,"border"+$t[i]+"Width"))||0));return s}function tn(e,t,n){var r=t==="width"?e.offsetWidth:e.offsetHeight,i=!0,s=v.support.boxSizing&&v.css(e,"boxSizing")==="border-box";if(r<=0||r==null){r=Dt(e,t);if(r<0||r==null)r=e.style[t];if(Ut.test(r))return r;i=s&&(v.support.boxSizingReliable||r===e.style[t]),r=parseFloat(r)||0}return r+en(e,t,n||(s?"border":"content"),i)+"px"}function nn(e){if(Wt[e])return Wt[e];var t=v("<"+e+">").appendTo(i.body),n=t.css("display");t.remove();if(n==="none"||n===""){Pt=i.body.appendChild(Pt||v.extend(i.createElement("iframe"),{frameBorder:0,width:0,height:0}));if(!Ht||!Pt.createElement)Ht=(Pt.contentWindow||Pt.contentDocument).document,Ht.write("<!doctype html><html><body>"),Ht
|
|
|
|
|
;(function(win, doc) {
|
|
|
|
|
|
|
|
|
|
// 已加载模块
|
|
|
|
|
var loaded = {},
|
|
|
|
|
|
|
|
|
|
// 已加载列表
|
|
|
|
|
loadList = {},
|
|
|
|
|
|
|
|
|
|
// 加载中的模块
|
|
|
|
|
loadingFiles = {},
|
|
|
|
|
|
|
|
|
|
// 内部配置文件
|
|
|
|
|
config = {
|
|
|
|
|
// 是否自动加载核心库
|
|
|
|
|
autoLoad: true,
|
|
|
|
|
js_version: '',
|
|
|
|
|
css_version: '',
|
|
|
|
|
|
|
|
|
|
// 加载延迟
|
|
|
|
|
timeout: 6000,
|
|
|
|
|
|
|
|
|
|
// 核心库
|
|
|
|
|
coreLib: [],
|
|
|
|
|
|
|
|
|
|
/* 模块依赖
|
|
|
|
|
* {
|
|
|
|
|
* moduleName: {
|
|
|
|
|
* path: 'URL',
|
|
|
|
|
* type:'js|css',
|
|
|
|
|
* requires:['moduleName1', 'fileURL']
|
|
|
|
|
* }
|
|
|
|
|
* }
|
|
|
|
|
*/
|
|
|
|
|
mods: {}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
jsSelf = (function() {
|
|
|
|
|
var files = doc.getElementsByTagName('script');
|
|
|
|
|
return files[files.length - 1];
|
|
|
|
|
})(),
|
|
|
|
|
|
|
|
|
|
// 全局模块
|
|
|
|
|
globalList = [],
|
|
|
|
|
|
|
|
|
|
// 外部参数
|
|
|
|
|
extConfig,
|
|
|
|
|
|
|
|
|
|
// domready回调堆栈
|
|
|
|
|
readyList = [],
|
|
|
|
|
|
|
|
|
|
// DOM Ready
|
|
|
|
|
isReady = false,
|
|
|
|
|
|
|
|
|
|
// 模块间的公共数据
|
|
|
|
|
publicData = {},
|
|
|
|
|
|
|
|
|
|
// 公共数据回调堆栈
|
|
|
|
|
publicDataStack = {},
|
|
|
|
|
|
|
|
|
|
isArray = function(e) {
|
|
|
|
|
return e.constructor === Array;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getMod = function(e) {
|
|
|
|
|
var mods = config.mods,
|
|
|
|
|
mod;
|
|
|
|
|
if (typeof e === 'string') {
|
|
|
|
|
mod = (mods[e]) ? mods[e] : {
|
|
|
|
|
path: e.indexOf('.js') == -1 && e.indexOf('.css') == -1 ? (config.root + e + '.js' + (config.js_version)) : e
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
mod = e;
|
|
|
|
|
}
|
|
|
|
|
return mod;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
load = function(url, type, charset, cb) {
|
|
|
|
|
var wait, n, t, img,
|
|
|
|
|
|
|
|
|
|
done = function() {
|
|
|
|
|
loaded[url] = 1;
|
|
|
|
|
cb && cb(url);
|
|
|
|
|
cb = null;
|
|
|
|
|
win.clearTimeout(wait);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!url) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (loaded[url]) {
|
|
|
|
|
loadingFiles[url] = false;
|
|
|
|
|
if (cb) {
|
|
|
|
|
cb(url);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (loadingFiles[url]) {
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
load(url, type, charset, cb);
|
|
|
|
|
}, 10);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loadingFiles[url] = true;
|
|
|
|
|
|
|
|
|
|
wait = win.setTimeout(function() {
|
|
|
|
|
/* 目前延时回调处理,超时后如果有延时回调,执行回调,然后继续等
|
|
|
|
|
* 延时回调的意义是log延时长的URI,这个处理不属于加载器本身的功能移到外部
|
|
|
|
|
* 没有跳过是为了避免错误。
|
|
|
|
|
*/
|
|
|
|
|
if (config.timeoutCallback) {
|
|
|
|
|
try {
|
|
|
|
|
config.timeoutCallback(url);
|
|
|
|
|
} catch (ex) {}
|
|
|
|
|
}
|
|
|
|
|
}, config.timeout);
|
|
|
|
|
|
|
|
|
|
t = type || url.toLowerCase().split(/\./).pop().replace(/[\?#].*/, '');
|
|
|
|
|
|
|
|
|
|
if (t === 'js') {
|
|
|
|
|
n = doc.createElement('script');
|
|
|
|
|
n.setAttribute('type', 'text/javascript');
|
|
|
|
|
n.setAttribute('src', url);
|
|
|
|
|
n.setAttribute('async', true);
|
|
|
|
|
} else if (t === 'css') {
|
|
|
|
|
n = doc.createElement('link');
|
|
|
|
|
n.setAttribute('type', 'text/css');
|
|
|
|
|
n.setAttribute('rel', 'stylesheet');
|
|
|
|
|
n.setAttribute('href', url);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (charset) {
|
|
|
|
|
n.charset = charset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (t === 'css') {
|
|
|
|
|
// 暂不判断css错误
|
|
|
|
|
// img = new Image();
|
|
|
|
|
// img.onerror = function() {
|
|
|
|
|
// done();
|
|
|
|
|
// img.onerror = null;
|
|
|
|
|
// img = null;
|
|
|
|
|
// }
|
|
|
|
|
// img.src = url;
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
done();
|
|
|
|
|
}, 0);
|
|
|
|
|
} else {
|
|
|
|
|
//if (t === 'js') {
|
|
|
|
|
// firefox, safari, chrome, ie9下加载失败触发
|
|
|
|
|
// 如果文件是404, 会比timeout早触发onerror。目前不处理404,只处理超时
|
|
|
|
|
n.onerror = function() {
|
|
|
|
|
done();
|
|
|
|
|
n.onerror = null;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// ie6~8通过创建vbscript可以识别是否加载成功。
|
|
|
|
|
// 但这样需先测试性加载再加载影响性能。即使没成功加载而触发cb,顶多报错,没必要杜绝这种报错
|
|
|
|
|
// ie6~9下加载成功或失败,firefox, safari, opera下加载成功触发
|
|
|
|
|
n.onload = n.onreadystatechange = function() {
|
|
|
|
|
var url;
|
|
|
|
|
if (!this.readyState || this.readyState === 'loaded' || this.readyState === 'complete') {
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
done();
|
|
|
|
|
}, 0);
|
|
|
|
|
n.onload = n.onreadystatechange = null;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
jsSelf.parentNode.insertBefore(n, jsSelf);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 加载依赖论文件(顺序)
|
|
|
|
|
loadDeps = function(deps, cb) {
|
|
|
|
|
var mods = config.mods,
|
|
|
|
|
id, m, mod, i = 0,
|
|
|
|
|
len;
|
|
|
|
|
|
|
|
|
|
id = deps.join('');
|
|
|
|
|
len = deps.length;
|
|
|
|
|
|
|
|
|
|
if (loadList[id]) {
|
|
|
|
|
cb();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
function callback(mod) {
|
|
|
|
|
if (!--len) {
|
|
|
|
|
loadList[id] = 1;
|
|
|
|
|
cb();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (; m = deps[i++];) {
|
|
|
|
|
mod = getMod(m);
|
|
|
|
|
if (mod.requires) {
|
|
|
|
|
loadDeps(mod.requires, (function(mod) {
|
|
|
|
|
return function() {
|
|
|
|
|
load(mod.path, mod.type, mod.charset, function(){
|
|
|
|
|
mod && mod.init && mod.init();
|
|
|
|
|
return callback(mod);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
})(mod));
|
|
|
|
|
} else {
|
|
|
|
|
load(mod.path, mod.type, mod.charset, (function(mod) {
|
|
|
|
|
return function() {
|
|
|
|
|
mod && mod.init && mod.init();
|
|
|
|
|
return callback(mod);
|
|
|
|
|
}
|
|
|
|
|
})(mod));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// @win window reference
|
|
|
|
|
// @fn function reference
|
|
|
|
|
contentLoaded = function(fn) {
|
|
|
|
|
var done = false,
|
|
|
|
|
top = true,
|
|
|
|
|
doc = win.document,
|
|
|
|
|
root = doc.documentElement,
|
|
|
|
|
add = doc.addEventListener ? 'addEventListener' : 'attachEvent',
|
|
|
|
|
rem = doc.addEventListener ? 'removeEventListener' : 'detachEvent',
|
|
|
|
|
pre = doc.addEventListener ? '' : 'on',
|
|
|
|
|
|
|
|
|
|
init = function(e) {
|
|
|
|
|
if (e.type == 'readystatechange' && doc.readyState != 'complete') return;
|
|
|
|
|
(e.type == 'load' ? win : doc)[rem](pre + e.type, init, false);
|
|
|
|
|
if (!done && (done = true)) fn.call(win, e.type || e);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
poll = function() {
|
|
|
|
|
try {
|
|
|
|
|
root.doScroll('left');
|
|
|
|
|
} catch (e) {
|
|
|
|
|
setTimeout(poll, 50);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
init('poll');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (doc.readyState == 'complete') fn.call(win, 'lazy');
|
|
|
|
|
else {
|
|
|
|
|
if (doc.createEventObject && root.doScroll) {
|
|
|
|
|
try {
|
|
|
|
|
top = !win.frameElement;
|
|
|
|
|
} catch (e) {}
|
|
|
|
|
if (top) {
|
|
|
|
|
poll();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
doc[add](pre + 'DOMContentLoaded', init, false);
|
|
|
|
|
doc[add](pre + 'readystatechange', init, false);
|
|
|
|
|
win[add](pre + 'load', init, false);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
fireReadyList = function() {
|
|
|
|
|
var list;
|
|
|
|
|
while (list = readyList.shift()) {
|
|
|
|
|
d.apply(null, list);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
d = function() {
|
|
|
|
|
var args = [].slice.call(arguments),
|
|
|
|
|
fn, id;
|
|
|
|
|
var defer = $.Deferred();
|
|
|
|
|
|
|
|
|
|
// 加载核心库
|
|
|
|
|
if (config.autoLoad && config.coreLib.length && !loadList[config.coreLib.join('')]) {
|
|
|
|
|
loadDeps(config.coreLib, function() {
|
|
|
|
|
d.apply(null, args);
|
|
|
|
|
defer.resolve();
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 加载全局库
|
|
|
|
|
if (globalList.length && !loadList[globalList.join('')]) {
|
|
|
|
|
loadDeps(globalList, function() {
|
|
|
|
|
d.apply(null, args);
|
|
|
|
|
defer.resolve();
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (typeof args[args.length - 1] === 'function') {
|
|
|
|
|
fn = args.pop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
id = args.join('');
|
|
|
|
|
|
|
|
|
|
if ((args.length === 0 || loadList[id]) && fn) {
|
|
|
|
|
fn();
|
|
|
|
|
defer.resolve();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loadDeps(args, function() {
|
|
|
|
|
loadList[id] = 1;
|
|
|
|
|
fn && fn();
|
|
|
|
|
defer.resolve();
|
|
|
|
|
});
|
|
|
|
|
return defer.promise();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
d.add = d.define = function(sName, oConfig) {
|
|
|
|
|
if (!sName || !oConfig || !oConfig.path) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
config.mods[sName] = oConfig;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
d.delay = function() {
|
|
|
|
|
var args = [].slice.call(arguments),
|
|
|
|
|
delay = args.shift();
|
|
|
|
|
win.setTimeout(function() {
|
|
|
|
|
d.apply(this, args);
|
|
|
|
|
}, delay);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
d.global = function() {
|
|
|
|
|
var args = isArray(arguments[0]) ? arguments[0] : [].slice.call(arguments);
|
|
|
|
|
globalList = globalList.concat(args);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
d.ready = function() {
|
|
|
|
|
var args = [].slice.call(arguments);
|
|
|
|
|
if (isReady) {
|
|
|
|
|
return d.apply(this, args);
|
|
|
|
|
}
|
|
|
|
|
readyList.push(args);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
d.css = function(s) {
|
|
|
|
|
var css = doc.getElementById('do-inline-css');
|
|
|
|
|
if (!css) {
|
|
|
|
|
css = doc.createElement('style');
|
|
|
|
|
css.type = 'text/css';
|
|
|
|
|
css.id = 'do-inline-css';
|
|
|
|
|
jsSelf.parentNode.insertBefore(css, jsSelf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (css.styleSheet) {
|
|
|
|
|
css.styleSheet.cssText = css.styleSheet.cssText + s;
|
|
|
|
|
} else {
|
|
|
|
|
css.appendChild(doc.createTextNode(s));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
d.setData = d.setPublicData = function(prop, value) {
|
|
|
|
|
var cbStack = publicDataStack[prop];
|
|
|
|
|
|
|
|
|
|
publicData[prop] = value;
|
|
|
|
|
|
|
|
|
|
if (!cbStack) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (cbStack.length > 0) {
|
|
|
|
|
(cbStack.pop()).call(this, value);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
d.getData = d.getPublicData = function(prop, cb) {
|
|
|
|
|
if (publicData[prop]) {
|
|
|
|
|
cb(publicData[prop]);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!publicDataStack[prop]) {
|
|
|
|
|
publicDataStack[prop] = [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
publicDataStack[prop].push(function(value) {
|
|
|
|
|
cb(value);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
d.setConfig = function(n, v) {
|
|
|
|
|
config[n] = v;
|
|
|
|
|
return d;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
d.getConfig = function(n) {
|
|
|
|
|
return config[n];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 初始外部配置
|
|
|
|
|
extConfig = jsSelf.getAttribute('data-cfg-autoload');
|
|
|
|
|
if (extConfig) {
|
|
|
|
|
config.autoLoad = (extConfig.toLowerCase() === 'true') ? true : false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extConfig = jsSelf.getAttribute('data-cfg-corelib');
|
|
|
|
|
if (extConfig) {
|
|
|
|
|
config.coreLib = extConfig.split(',');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (typeof Do !== 'undefined') {
|
|
|
|
|
globalList = Do.global.mods;
|
|
|
|
|
config.mods = Do.mods;
|
|
|
|
|
//readyList = Do.actions;
|
|
|
|
|
var act;
|
|
|
|
|
if(Do.actions){
|
|
|
|
|
while (act = Do.actions.shift()) {
|
|
|
|
|
d.apply(null, act);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
delete Do;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
win.Do = d;
|
|
|
|
|
|
|
|
|
|
contentLoaded(function() {
|
|
|
|
|
isReady = true;
|
|
|
|
|
fireReadyList();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(window, document);
|