/src/js/core.js
JavaScript | 1933 lines | 1105 code | 198 blank | 630 comment | 340 complexity | 44514321500c3ecea7f9d230cdaa0246 MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- /**
- * @fileOverview ????????
- * @author wx
- * @version 1.0.0
- */
- // Inspired by base2 and Prototype
- (function(){
- var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\bbase\b/ : /.*/;
- // The base Class implementation (does nothing)
- this.Class = function(){};
-
- // Create a new Class that inherits from this class
- Class.extend = function(prop) {
- var base = this.prototype;
-
- // Instantiate a base class (but only create the instance,
- // don't run the init constructor)
- initializing = true;
- var prototype = new this();
- initializing = false;
-
- // Copy the properties over onto the new prototype
- for (var name in prop) {
- // Check if we're overwriting an existing function
- prototype[name] = typeof prop[name] == "function" &&
- typeof base[name] == "function" && fnTest.test(prop[name]) ?
- (function(name, fn){
- return function() {
- var tmp = this.base;
-
- // Add a new .base() method that is the same method
- // but on the super-class
- this.base = base[name];
-
- // The method only need to be bound temporarily, so we
- // remove it when we're done executing
- var ret = fn.apply(this, arguments);
- this.base = tmp;
-
- return ret;
- };
- })(name, prop[name]) :
- prop[name];
- }
-
- // The dummy class constructor
- function Class() {
- // All construction is actually done in the init method
- if ( !initializing && this.init )
- this.init.apply(this, arguments);
- }
-
- // Populate our constructed prototype object
- Class.prototype = prototype;
-
- // Enforce the constructor to be what we expect
- Class.constructor = Class;
-
- // And make this class extendable
- Class.extend = arguments.callee;
-
- return Class;
- };
- })();/**
- * @fileOverview ???????
- * @author lxl
- * @version 1.0.0
- */
- //string.js
- if (!String.prototype.trim)
- String.prototype.trim = function(sStr) {
- /// <summary>
- /// ????????????????
- /// </summary>
- /// <param name="sStr">
- /// ????????????????????????
- /// </param>
- var re;
- if (!sStr) re = /^\s+|\s+$/g;
- else re = RegExp("^(?:" + sStr + ")+|(?:" + sStr + ")+$", "g");
- return this.replace(re, "");
- };
-
- if (!String.prototype.leftTrim)
- String.prototype.leftTrim = function(sStr) {
- /// <summary>
- /// ???????????????
- /// </summary>
- /// <param name="sStr">
- /// ????????????????????????
- /// </param>
- var re;
- if (!sStr) re = /^\s+/;
- else re = new RegExp("^(?:" + sStr + ")+");
- return this.replace(re, "");
- };
-
- if (!String.prototype.rightTrim)
- String.prototype.rightTrim = function(sStr) {
- /// <summary>
- /// ???????????????
- /// </summary>
- /// <param name="sStr">
- /// ????????????????????????
- /// </param>
- var re;
- if (!sStr) re = /\s+$/;
- else re = new RegExp("(?:" + sStr + ")+$");
- return this.replace(re, "");
- };
-
- if (!String.prototype.startsWith)
- String.prototype.startsWith = function(sStr, bIgnoreCase) {
- /// <summary>
- /// ????????????????????????
- /// </summary>
- /// <param name="sStr">
- /// ????????
- /// </param>
- /// <param name="bIgnoreCase">
- /// ?????????????true??????????????false
- /// </param>
- var ignore = bIgnoreCase || false;
- if (ignore) {
- var oRegex = new RegExp('^' + sStr, 'i');
- return oRegex.test(this);
- }
- else
- return (this.substring(0, sStr.length) == sStr);
-
- };
-
- if (!String.prototype.endsWith)
- String.prototype.endsWith = function(sStr, bIgnoreCase) {
- /// <summary>
- /// ????????????????????????
- /// </summary>
- /// <param name="sStr">
- /// ????????
- /// </param>
- /// <param name="bIgnoreCase">
- /// ?????????????true??????????????false
- /// </param>
- var L1 = this.length;
- var L2 = sStr.length;
- var ignore = bIgnoreCase || false;
-
- if (L2 > L1)
- return false;
-
- if (ignore) {
- var oRegex = new RegExp(sStr + '$', 'i');
- return oRegex.test(this);
- }
- else
- return (L2 == 0 || this.substring(L1 - L2) == sStr);
- };
-
- //format???????????
- if (!String.prototype.format)
- String.prototype.format = function(aStr) {
- /// <summary>
- /// ??dot net??format?? ?????"{i}"??????????
- /// </summary>
- /// <param name="aStr">
- /// ?????["str1","str2"]????????"str1","str2"
- /// </param>
- aStr = arguments[0] && arguments[0].constructor === Array ? arguments[0] : Array.prototype.slice.call(arguments);
- if (aStr.length == 0) return this;
- for (var s = this, i = 0, j = aStr.length; i < j; i++){
- s = s.replace(new RegExp("\\{" + i + "\\}", "g"), aStr[i]);
- }
- return s;
- };
- /**
- * @fileOverview ??????
- * @author lxl
- * @version 1.0.0
- */
- //array.js
- Array.prototype.inArray = function(value) {
- /// <summary>
- /// ????????????????
- /// </summary>
- /// <param name="value">
- /// ??????
- /// </param>
- for (var i = 0; i < this.length; i++) {
- if (this[i] === value) {
- return true;
- }
- }
- return false;
- };
- /**
- *@fileOverview ????????????
- *@version 1.0.0
- *@author wx
- */
- //util.js
- (function() {
- //core.js?????
- var version = "0.3.4";
- var ua = navigator.userAgent.toLowerCase();
- //each by:john
- function each(object, callback, args) {
- /// <summary>
- /// ????
- /// </summary>
- /// <param name="object">
- /// ???????
- /// </param>
- /// <param name="callback">
- // ?????????
- /// </param>
- /// <param name="args">
- /// ??????
- /// </param>
- var name, i = 0, length = object.length;
- //???????
- if (args) {
- //?????length??(???? ??? ???)
- if (length == undefined) {
- //?????????
- for (name in object)
- //???????
- if (callback.apply(object[name], args) === false) break;
- //??length??
- } else
- //????????? ???????
- for (; i < length; )
- if (callback.apply(object[i++], args) === false) break;
-
- //????
- } else {
-
- if (length == undefined) {
-
- for (name in object)
- if (callback.call(object[name], name, object[name]) === false) break;
-
- } else
-
- for (var value = object[0]; i < length && callback.call(value, i, value) !== false; value = object[++i]) { }
-
- }
-
- return object;
- }
-
- function nameSpace(a, b) {
- /// <summary>
- /// ??????????
- /// util.nameSpace("ajax.get",fn);
- /// </summary>
- /// <param name="a">
- /// ????
- /// </param>
- /// <param name="b">
- /// ??
- /// </param>
- var c = a.split(/\./);
- var d = window;
- for (var e = 0; e < c.length - 1; e++) {
- //?????????????
- if (!d[c[e]]) {
- //??????
- d[c[e]] = {};
- }
- //?????
- d = d[c[e]];
- }
- //?????? ?????????????
- d[c[c.length - 1]] = b;
- }
-
- //??????????
- function toggle(obj, attr, v1, v2) {
- /// <summary>
- /// ???:??????????
- /// </summary>
- /// <param name="obj">
- /// ????
- /// </param>
- /// <param name="attr">
- // ????
- /// </param>
- /// <param name="v1">
- /// ??????
- /// </param>
- /// <param name="v2">
- /// ??????
- /// </param>
- return function() {
- obj[attr] = (obj[attr] != v2) ? v2 : v1;
- };
- }
-
- function setCookie(name, value, expires, path, domain, secure) {
- /// <summary>
- /// ??Cookie?
- /// </summary>
- /// <param name="name">
- /// Cookie?
- /// </param>
- /// <param name="value">
- /// Cookie?
- /// </param>
- var today = new Date();
- today.setTime(today.getTime());
- if (expires) {
- expires = expires * 1000 * 60 * 60 * 24;
- }
- var expires_date = new Date(today.getTime() + (expires));
- document.cookie = name + "=" + escape(value) +
- ((expires) ? ";expires=" + expires_date.toGMTString() : "") + //expires.toGMTString()
- ((path) ? ";path=" + path : "") +
- ((domain) ? ";domain=" + domain : "") +
- ((secure) ? ";secure" : "");
- }
-
- function getCookie(name) {
- /// <summary>
- /// ?????Cookie?
- /// </summary>
- /// <param name="name">
- /// Cookie?
- /// </param>
- var start = document.cookie.indexOf(name + "=");
- var len = start + name.length + 1;
- if ((!start) && (name != document.cookie.substring(0, name.length))) {
- return null;
- }
- if (start == -1) return null;
- var end = document.cookie.indexOf(";", len);
- if (end == -1) end = document.cookie.length;
- return unescape(document.cookie.substring(len, end));
- }
-
- function deleteCookie(name, path, domain) {
- /// <summary>
- /// ?????Cookie
- /// </summary>
- /// <param name="name">
- /// Cookie?
- /// </param>
- if (getCookie(name)) document.cookie = name + "=" +
- ((path) ? ";path=" + path : "") +
- ((domain) ? ";domain=" + domain : "") +
- ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
- }
-
- //??ie6??????
- if (/msie/.test(ua)) {
- try {
- document.execCommand("BackgroundImageCache", false, true);
- }
- catch (e) {
- }
- }
-
- //public
- each("each,nameSpace,toggle,setCookie,getCookie,deleteCookie".split(","), function() {
- nameSpace("tx.util." + this, eval("(" + this + ")"));
- });
-
- //??????
- each("each".split(","), function() {
- nameSpace("tx." + this, eval("(" + this + ")"));
- });
-
- tx.toString = function() {
- return "[object tx(version " + version + ")]";
- };
- })();
-
-
-
-
-
-
-
-
- /**
- * @fileOverview ??css????????
- * @author wx
- * @version 1.0.0
- */
- //style.js
- (function() {
- /**
- * Convert a CSS property to camel case (font-size to fontSize)
- * @param {String} str The property that requires conversion to camel case
- * @return {String} The camel cased property string
- */
- var toCamelCase = (function() {
- var cache = {};
- return function(str) {
- if (!cache[str]) {
- return cache[str] = str.replace(/-([a-z])/g, function($0, $1) {
- return $1.toUpperCase();
- });
- } else {
- return cache[str];
- }
- }
- })();
-
- //?????????oStyle??
- function toStyleObj(str) {
- // var aTemp = ['{"'];
- // aTemp.push(str.replace(/\:/gi, function() { return '":"'; }).replace(/\;$/, function() { return ""; }).replace(/\;/gi, function() { return '","' }));
- // aTemp.push('"}');
- // return aTemp.join("");
- //??"background : url(http://192.168.1.41:8099/img/template1/ImgConbj_1.png) no-repeat"???url??":"?? Edit: Kim Wang Date: 2009-6-18
- var aTemp = ['{"'];
- aTemp.push(str.replace(/[^\d]\:[^\/\/]/g, function(str) {
- return str.replace(/\:/, "\":\"");
- }).replace(/\;$/, function() { return ""; }).replace(/\;/gi, function() { return '","' }));
- aTemp.push('"}');
- return aTemp.join("");
- }
-
- function setStyle(elements, prop, val) {
- /// <summary>
- /// ???????
- /// </summary>
- /// <param name="elements">
- /// ????
- /// </param>
- /// <param name="prop">
- // css??
- /// </param>
- /// <param name="val">
- /// css???
- /// </param>
- var el = null;
- for (var i = 0, len = elements.length; i < len; i++) {
-
- el = (typeof elements[i] == "string") ? document.getElementById(elements[i]) : elements[i];
-
- if (prop == "opacity") {
- el.style.filter = "alpha(opacity=" + val * 100 + ")";
- el.style.opacity = val;
- continue;
- }
-
- if (prop == "float") {
- el.style.styleFloat = val; //IE
- el.style.cssFloat = val; //firefox and others explorer
- continue;
- }
-
- el.style[toCamelCase(prop)] = val;
- }
- }
-
- function setCSS(el, styles) {
- /// <summary>
- /// ???????
- /// </summary>
- /// <param name="el">
- /// ?????????
- /// </param>
- /// <param name="styles">
- /// css??json????css??
- /// </param>
- if (typeof styles == "string") styles = eval("(" + toStyleObj(styles) + ")");
- for (var prop in styles) {
- if (!styles.hasOwnProperty(prop)) continue;
- setStyle(el, prop.trim(), styles[prop].trim());
- }
- }
-
- function addClass(elem, classname) {
- /// <summary>
- /// ??????????
- /// </summary>
- /// <param name="elem">
- /// dom??
- /// </param>
- /// <param name="classname">
- // css??
- /// </param>
- if (typeof elem == "string") elem = document.getElementById(elem);
- elem.className += " " + classname;
- }
-
- function removeClass(elem, classname) {
- /// <summary>
- /// ??????????
- /// </summary>
- /// <param name="elem">
- /// dom??
- /// </param>
- /// <param name="classname">
- /// css??
- /// </param>
- if (typeof elem == "string") elem = document.getElementById(elem);
- elem.className = elem.className.replace(classname, " ");
- }
-
-
- tx.util.each("setCSS,setStyle,addClass,removeClass".split(","), function() {
- tx.util.nameSpace("tx.style." + this, eval("(" + this + ")"));
- });
-
- tx.util.each("setCSS,addClass,removeClass".split(","), function() {
- tx.util.nameSpace("tx." + this, eval("(" + this + ")"));
- });
- })();/**
- * @fileOverview ??dom???
- * @author lxl
- * @version 1.0.0
- */
- //dom.js
- (function() {
-
- function $() {
- /// <summary>
- /// ??id??????,??????????????
- /// </summary>
- /// <param name="id">
- /// ?????????id
- /// </param>
- var elements = [];
- for (var i = 0; i < arguments.length; i++) {
- var element = arguments[i];
- if (typeof element == 'string')
- element = document.getElementById(element);
- //?????????????
- if (arguments.length == 1)
- return element;
- elements.push(element);
- }
- return elements;
- }
-
-
- function tag(sTagName, oElem) {
- /// <summary>
- /// ??????????
- /// </summary>
- /// <param name="sTagName">
- /// ?????????
- /// </param>
- /// <param name="oElem">
- /// ?????????
- /// </param>
- return (oElem || document).getElementsByTagName(sTagName);
- }
-
- function byClass(sSearchClass, oNode, sTag) {
- /// <summary>
- /// ??class??????
- /// </summary>
- /// <param name="searchClass">
- /// ???????
- /// </param>
- /// <param name="node">
- /// ?????????
- /// </param>
- /// <param name="tag">
- /// ??????????????
- /// </param>
- var classElements = [];
- if (oNode == null)
- oNode = document;
- if (sTag == null)
- //???
- sTag = '*';
- var els = oNode.getElementsByTagName(tag);
- var pattern = new RegExp("(^|\\s)" + sSearchClass + "(\\s|$)");
- for (i = 0, j = 0; i < els.length; i++) {
- //??className?????????
- if (pattern.test(els[i].className)) {
- classElements[j] = els[i];
- j++;
- }
- }
- return classElements;
- }
-
-
- function prev(oElement) {
- ///<summary>
- ///??????????????
- ///</summary>
- ///<param name="oElement">
- ///??????
- ///</param>
- do {
- oElement = oElement.previousSibling;
- //???????????
- } while (oElement && oElement.nodeType != 1);
- return oElement;
- }
-
-
- function next(oElement) {
- ///<summary>
- ///??????????????
- ///</summary>
- ///<param name="oElement">
- ///??????
- ///</param>
- do {
- oElement = oElement.nextSibling;
- } while (oElement && oElement.nodeType != 1);
- return oElement;
- }
-
-
- function first(oElement) {
- ///<summary>
- ///???????????????
- ///</summary>
- ///<param name="oElement">
- ///??????
- ///</param>
- var oElement = oElement.firstChild;
- return (oElement && oElement.nodeType != 1) ? next(oElement) : oElement;
- }
-
-
- function last(oElement) {
- ///<summary>
- ///????????????????
- ///</summary>
- ///<param name="oElement">
- ///??????
- ///</param>
- var oElement = oElement.lastChild;
- return (oElement && oElement.nodeType != 1) ? prev(oElement) : oElement;
- }
-
-
- function getParent(oElement, iNum) {
- ///<summary>
- ///???????nNum??????
- ///</summary>
- ///<param name="oElement">
- ///??????
- ///</param>
- ///<param name="nNum">
- ///?????????
- ///</param>
- var iNum = iNum || 1;
- for (var i = 0; i < iNum; i++)
- if (oElement != null) oElement = oElement.parentNode;
- return oElement;
- }
-
-
- // function before(oParent, oCurrent, oElem) {
- // ///<summary>
- // ///?????????????????
- // ///</summary>
- // ///<param name="oParent">
- // ///??????????
- // ///</param>
- // ///<param name="oCurrent">
- // ///??????
- // ///</param>
- // ///<param name="elem">
- // ///???????????????????????
- // ///</param>
- // // Check to see if no parent node was provided
- // if (oElem == null) {
- // oElem = oCurrent;
- // oCurrent = oParent;
- // oParent = oCurrent.parentNode;
- // }
-
- // var elems = checkElem(oElem);
-
- // for (var i = elems.length - 1; i >= 0; i--) {
- // oParent.insertBefore(elems[i], oCurrent);
- // }
- // }
-
- function before(oCurrent, oElem) {
- ///<summary>
- ///???????????????????
- ///</summary>
- ///<param name="oCurrent">
- ///??????
- ///</param>
- ///<param name="elem">
- ///???????????????????????
- ///</param>
- // Check to see if no parent node was provided
- var oParent = oCurrent.parentNode;
- var elems = checkElem(oElem);
-
- for (var i = elems.length - 1; i >= 0; i--) {
- oParent.insertBefore(elems[i], oCurrent);
- }
- }// Des: ???????????????after?? Author: lxl; Date:2009-9-10
-
-
- function after(oCurrent, oElement) {
- ///<summary>
- ///???????????????????
- ///</summary>
- ///<param name="oCurrent">
- ///??????
- ///</param>
- ///<param name="oElement">
- ///???????????????????????
- ///</param>
- var elems = checkElem(oElement);
-
- for (var i = elems.length - 1; i >= 0; i--) {
- if (oCurrent.nextSibling)
- oCurrent.parentNode.insertBefore(elems[i], oCurrent.nextSibling);
- else
- oCurrent.parentNode.appendChild(elems[i]);
- }
- }
-
-
- function create(sTagName) {
- ///<summary>
- ///????????????
- ///</summary>
- ///<param name="sTagName">
- ///???????????
- ///</param>
- return document.createElementNS ?
- document.createElementNS('', sTagName) :
- document.createElement(sTagName);
- }
-
-
- function append(oParent, oElement) {
- ///<summary>
- ///??????????????
- ///</summary>
- ///<param name="oParent">
- ///??????
- ///</param>
- ///<param name="oElement">
- ///????????????????????????
- ///</param>
- var elems = checkElem(oElement);
- for (var i = 0; i < elems.length; i++) {
- oParent.appendChild(elems[i]);
- }
- }
-
-
- function remove(oElem) {
- ///<summary>
- ///??????
- ///</summary>
- ///<param name="elem">
- ///????????
- ///</param>
- if (oElem) oElem.parentNode.removeChild(oElem);
- }
-
-
- function empty(oElem) {
- ///<summary>
- ///???????????????
- ///</summary>
- ///<param name="elem">
- ///??????
- ///</param>
- while (oElem.firstChild)
- remove(oElem.firstChild);
- }
-
-
- function getAttr(oElement, sName) {
- ///<summary>
- ///?????????
- ///</summary>
- ///<param name="oElement">
- ///??????
- ///</param>
- ///<param name="sName">
- ///????????
- ///</param>
- return attr(oElement, sName);
- }
-
-
- function setAttr(oElement, sName, sValue) {
- ///<summary>
- ///????????????????
- ///</summary>
- ///<param name="oElement">
- ///??????
- ///</param>
- ///<param name="sName">
- ///????????
- ///</param>
- ///<param name="sValue">
- ///????
- ///</param>
- return attr(oElement, sName, sValue);
- }
-
- function attr(oElement, sName, sValue) {
- ///<summary>
- ///????????????????
- ///</summary>
- ///<param name="oElement">
- ///??????
- ///</param>
- ///<param name="sName">
- ///????????
- ///</param>
- ///<param name="sValue">
- ///????
- ///</param>
- //?????name???????
- if (!sName || sName.constructor != String) return "";
- //??name?????getter?setter ???js????
- //??????????? {}.for
- sName = { "for": "htmlFor", "class": "className"}[sName] || sName;
- //??????value??
- if (sValue != null) {
- //????????setter
- oElement[sName] = sValue;
- //setAttribute?????
- if (oElement.setAttribute)
- oElement.setAttribute(sName, sValue);
- }
- //getter || getAttribute
- return oElement[sName] || oElement.getAttribute(sName) || "";
- }
-
- //???????HTML??? ????? DOM?? DOM????
- //?HTML??????DOM??
- function checkElem(a) {
- var r = [];
- //???????? ??????? ???????
- if (a.constructor != Array) a = [a];
- for (var i = 0; i < a.length; i++) {
- //??????????
- if (a[i].constructor == String) {
- //??????????HTML
- var div = document.createElement("div");
- //??HTML ???DOM??div.childNodes[i]
- div.innerHTML = a[i];
- //div.childNodes.length????
- for (var j = 0; j < div.childNodes.length; j++)
- r[r.length] = div.childNodes[j];
- //???????????
- }else if (a[i].length) {
- //???DOM????
- for (var j = 0; j < a[i].length; j++)
- r[r.length] = a[i][j];
- }else {//?????DOM??
- r[r.length] = a[i];
- }
- }
- return r;
- }
-
- tx.util.each("$,byClass,tag,prev,next,first,last,getParent,before,after,create,append,remove,empty,getAttr,setAttr,attr".split(","), function() {
- tx.util.nameSpace("tx.dom." + this, eval("(" + this + ")"));
- });
- tx.util.each("$,byClass,tag".split(","), function() {
- tx.util.nameSpace("tx." + this, eval("(" + this + ")"));
- });
- })();/**
- *@fileOverview ??????????????????,dom???
- *@version 1.0.0
- *@author wx
- */
- //events.js
- (function() {
- // written by Dean Edwards, 2005
- // with input from Tino Zijdel, Matthias Miller, Diego Perini
-
- // http://dean.edwards.name/weblog/2005/10/add-event/
-
- function addEvent(element, type, handler) {
- /// <summary>
- /// ???????
- /// </summary>
- /// <param name="element">
- /// ??
- /// </param>
- /// <param name="type">
- // ????
- /// </param>
- /// <param name="handler">
- /// ??????
- /// </param>
- if (element.addEventListener) {
- element.addEventListener(type, handler, false);
- } else {
- // ?????????????????ID
- if (!handler.$$guid) handler.$$guid = addEvent.guid++;
- // ???????????????
- if (!element.events) element.events = {};
- // ?????/????????????????
- var handlers = element.events[type];
- if (!handlers) {
- handlers = element.events[type] = {};
- // ???????????(???????)
- if (element["on" + type]) {
- handlers[0] = element["on" + type];
- }
- }
- // ??????????????
- handlers[handler.$$guid] = handler;
- // ???????????????????
- element["on" + type] = handleEvent;
- }
- };
- // ????ID????
- addEvent.guid = 1;
-
- function removeEvent(element, type, handler) {
- /// <summary>
- /// ???????????
- /// </summary>
- /// <param name="element">
- /// ??
- /// </param>
- /// <param name="type">
- // ????
- /// </param>
- /// <param name="handler">
- /// ??????
- /// </param>
- if (element.removeEventListener) {
- element.removeEventListener(type, handler, false);
- } else {
- // ?????????????
- if (element.events && element.events[type]) {
- delete element.events[type][handler.$$guid];
- }
- }
- };
-
- function handleEvent(event) {
- var returnValue = true;
- // ?????? (IE ?????????)
- event = event || fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event);
- // ??????????????
- var handlers = this.events[event.type];
- // ????????????
- for (var i in handlers) {
- this.$$handleEvent = handlers[i];
- if (this.$$handleEvent(event) === false) {
- returnValue = false;
- }
- }
- return returnValue;
- };
- // ????IE?????????
- function fixEvent(event) {
- // ??W3C??????
- event.preventDefault = fixEvent.preventDefault;
- event.stopPropagation = fixEvent.stopPropagation;
- return event;
- };
- fixEvent.preventDefault = function() {
- this.returnValue = false;
- };
- fixEvent.stopPropagation = function() {
- this.cancelBubble = true;
- };
-
- /*
- domReady??
- */
- var isReady = false, readyList = [];
-
- function domReady(fn) {
- /// <summary>
- /// dom?????????
- /// </summary>
- /// <param name="fn">
- /// ???????
- /// </param>
- // ??????
- bindReady();
-
- // ??DOM????
- if (isReady)
- // ??????
- fn.call(document);
-
- // ?? ????
- else
- // ?????????
- readyList.push(fn);
-
- }
-
-
- function ready() {
-
- // ??DOM????
- if (!isReady) {
- // DOM ????
- isReady = true;
-
- // ??readyList????????
- if (readyList) {
- // ?????????
- tx.each(readyList, function() {
- this.call(document);
- });
-
- // ????????
- readyList = null;
- }
-
- }
- }
-
-
- var readyBound = false;
-
- function bindReady() {
- if (readyBound) return;
- readyBound = true;
-
- // ???Mozilla, Opera a?????????
- if (document.addEventListener) {
- // ????????
- document.addEventListener("DOMContentLoaded", function() {
- document.removeEventListener("DOMContentLoaded", arguments.callee, false);
- ready();
- }, false);
-
- // ??? IE ???
- } else if (document.attachEvent) {
- // ensure firing before onload,
- // maybe late but safe also for iframes
- document.attachEvent("onreadystatechange", function() {
- if (document.readyState === "complete") {
- document.detachEvent("onreadystatechange", arguments.callee);
- ready();
- }
- });
-
- // ?? IE ????? iframe
- // ????????????
- //!window.frameElement??window == window.top,window.frameElement????ie???
- if (document.documentElement.doScroll && window == window.top) (function() {
- if (isReady) return;
-
- try {
- // If IE is used, use the trick by Diego Perini
- // http://javascript.nwbox.com/IEContentLoaded/
- document.documentElement.doScroll("left");
- } catch (error) {
- setTimeout(arguments.callee, 0);
- return;
- }
-
- // ?????????
- ready();
- })();
- }
-
- // ??window.onload???????????
- addEvent(window, "load", ready);
- }
-
-
-
-
-
-
- tx.util.each("addEvent,removeEvent,domReady".split(","), function() {
- tx.util.nameSpace("tx.event." + this, eval("(" + this + ")"));
- });
-
- //????????
- tx.util.each("addEvent,removeEvent,domReady".split(","), function() {
- tx.util.nameSpace("tx." + this, eval("(" + this + ")"));
- });
- })();
- /**
- * @fileOverview ajax?????
- * @author wx
- * @version 1.0.0
- */
- //ajax.js
- (function() {
- var isIE6 = !(navigator.userAgent.toLowerCase().indexOf("opera") > -1) && ((document.all) ? true : false) && ([/MSIE (\d)\.0/i.exec(navigator.userAgent)][0][1] == 6);
-
- /**
- * ??ajax?
- * @module _private
- * @title fast ajax
- */
- //private
- var _ajax = {
- _objPool: [], //???
- async: true, //?????
- /**
- * ??XmlHttpRequest????
- * ????????????ajax????,???XMLHttpRequest???? ??????
- * @method _getInstance
- * @private
- */
- _getInstance: function() {
- for (var i = 0; i < this._objPool.length; i++) {
- if (this._objPool[i].readyState == 0 || this._objPool[i].readyState == 4) {
- return this._objPool[i];
- }
- }
- // IE5????push??
- this._objPool[this._objPool.length] = this._CreateXHR();
- return this._objPool[this._objPool.length - 1];
- },
-
- /**
- * ??XmlHttpRequest??
- * @method _CreateXHR
- * @private
- */
- _CreateXHR: function() {
- if (window.XMLHttpRequest) {
- var objXMLHttp = new XMLHttpRequest();
- }
- else {
- var MSXML = ['Msxml2.XMLHTTP.6.0', 'MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP'];
- for (var i = 0; i < MSXML.length; i++) {
- try {
- var objXMLHttp = new ActiveXObject(MSXML[i]);
- break;
- }
- catch (e) {
- }
- }
- }
- //mozilla??????readyState??,?????????
- if (objXMLHttp.readyState == null) {
- objXMLHttp.readyState = 0;
- //addEventListener?????true?capture false?bubbling
- objXMLHttp.addEventListener("load", function() {
- objXMLHttp.readyState = 4;
- if (typeof objXMLHttp.onreadystatechange == "function") {
- objXMLHttp.onreadystatechange();
- }
- }, false);
- }
- return objXMLHttp;
- },
-
- /**
- * ??????????json,object???????????????
- * @method _param
- * @param {String}/{Json}/{Object} data ??????????,
- * ???????POST.
- * @private
- */
- _param: function(data) {
- if (data == "null")
- return null;
- var s = [];
- if (data.constructor == Object) {
- for (var key in data) {
- s.push(encodeURIComponent(key.toString()) + "=" + encodeURIComponent(data[key]));
- }
- }
- else {
- var arr = data.split("&");
- for (var i = 0; i < arr.length; i++) {
- var temp = arr[i].split("=");
- s.push(encodeURIComponent(temp[0]) + "=" + encodeURIComponent(temp[1]));
- }
- }
- return s.join("&").replace(/%20/g, "+");
- },
-
- /**
- * ????ajax???
- *
- * @method _send
- * @static
- * @param {String} method ????[POST]?[GET]
- * @param {String} url ????
- * @param {String}/{Json}/{Object} data ??????????,
- * ???????POST.
- * @param {function} callback ???????????
- * ????XmlHttpRequest??
- * @return {none} ?????
- */
- _send: function(method, url, data, callback) {
- var objXMLHttp = this._getInstance();
- callback = callback || function() { };
- with (objXMLHttp) {
- try {
- // ????????
- if (url.indexOf("?") > 0) {
- url += "&randnum=" + Math.random();
- }
- else {
- url += "?randnum=" + Math.random();
- }
- open(method, url, true);
-
- // ????????
- setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
-
- send(this._param(data));
- onreadystatechange = function() {
- if (objXMLHttp.readyState == 4 && (objXMLHttp.status == 200 || objXMLHttp.status == 304)) {
- if (typeof callback == "function") {
- callback(objXMLHttp);
- }
- }
- }
- }
- catch (e) {
- alert(e);
- }
- }
- },
- /**
- * post??
- * @method post
- * @private
- */
- post: function(url, data, callback) {
- /// <summary>
- /// post????
- /// </summary>
- /// <param name="url">
- /// ????url
- /// </param>
- /// <param name="data">
- // ???????json?key=value
- /// </param>
- /// <param name="callback">
- /// ????
- /// </param>
-
- _ajax._send("POST", url, data, callback);
-
- },
-
- /**
- * get??
- * @method get
- * @private
- */
- get: function(url, callback) {
- /// <summary>
- /// get??????
- /// </summary>
- /// <param name="url">
- /// ????
- /// </param>
- /// <param name="callback">
- /// ????
- /// </param>
-
- //????
- if (!url.indexOf("http") || !url.indexOf("//")) {
- var _head = document.getElementsByTagName("head")[0];
- var _script = document.createElement("script");
- _script.src = url;
- _script.onload = _script.onreadystatechange = function() {
- if ((!_script.readyState ||
- _script.readyState == "loaded" || _script.readyState == "complete")) {
- (callback || function() { })();
- (!isIE6) && _head.removeChild(_script);
- }
- };
- _head.appendChild(_script);
- } else {
- _ajax._send("GET", url, "null", callback);
- }
- }
- };
-
- /*
- *??nameSpace??post?get??
- */
- tx.util.nameSpace("tx.ajax.post", _ajax.post);
- tx.util.nameSpace("tx.ajax.get", _ajax.get);
- })();
-
-
-
-
- /**
- * @fileoverview ??????????
- * @version 1.0.0
- * @author wx
- */
- (function() {
- window['tx'] = window['tx'] || {};
- window['tx']['loader'] = window['tx']['loader'] || {};
-
- tx.loader.ServiceBase = 'http://img.txooo.com/js';
- tx.loader.TxoooApisBase = 'http://img.txooo.com/js';
-
- //util ================================================================================
- function setLoad(obj, fn) {
- return obj.load = fn
- }
-
- var F = {};
- //???????
- function E(a) {
- //??
- if (a in F)
- return F[a];
- return F[a] = navigator.userAgent.toLowerCase().indexOf(a) != -1
- }
-
-
- //??
- function inherit(a, b) {
- var c = function() {
- };
- c.prototype = b.prototype;
- a.K = b.prototype;
- a.prototype = new c
- }
-
- function H(a, b) {
- var c = a.w || [];
- c = c.concat(Array.prototype.slice.call(arguments, 2));
- if (typeof a.r != "undefined")
- b = a.r;
- if (typeof a.q != "undefined")
- a = a.q;
- var d = function() {
- var g = c.concat(Array.prototype.slice.call(arguments));
- return a.apply(b, g)
- };
- d.w = c;
- d.r = b;
- d.q = a;
- return d
- }
-
- //error?
- function error(msg) {
- var temp = new Error(msg);
- temp.toString = function() {
- return this.message
- };
- return temp
- }
-
- //??????
- function nameSpace(a, b) {
- for (var c = a.split(/\./), d = window, g = 0; g < c.length - 1; g++) {
- d[c[g]] || (d[c[g]] = {});
- d = d[c[g]]
- }
- d[c[c.length - 1]] = b
- }
-
- function K(a, b, c) {
- a[b] = c
- }
-
- //tx.loader.? ================================================================================
-
- //tx.loader.callbacks
- if (!L)
- var L = nameSpace;
- if (!aa)
- var aa = K;
-
- tx.loader.callbacks = {};
- L("tx.loader.callbacks", tx.loader.callbacks);
-
- var Moudles = {}, N = {};
-
- tx.loader.eval = {};
- L("tx.loader.eval", tx.loader.eval);
-
-
- /*
- * ???????????
- */
- setLoad(tx, function(a, b, c) {
- var d = Moudles[":" + a];
- if (d) {
- if (c && !c.language && c.locale)
- c.language = c.locale;
- if (c && typeof c.callback == "string") {
- var g = c.callback;
- if (g.match(/^[[\]A-Za-z0-9._]+$/)) {
- g = window.eval(g);
- c.callback = g
- }
- }
- var l = c && c.callback != f;
- if (l && !d.p(b))
- throw error("Module: '" + a + "' must be loaded before DOM onLoad!");
- else
- if (l)
- d.k(b, c) ? window.setTimeout(c.callback, 0) : d.load(b, c);
- else
- d.k(b, c) || d.load(b, c)
- }
- else
- throw error("??: \"" + a + "\" ???!");
- });
- L("tx.load", tx.load);
-
- /**
- * ??????,??????????
- *
- *
- * @param {Function} fn ????
- */
- tx.setOnLoadCallback = function(fn) {
- var moudle = tx.loader["mname"];
- var a = moudle;
- Moudles[":" + a]["load"].setOnLoad(fn);
- //delete tx.loader["mname"];
- };
- L("tx.setOnLoadCallback", tx.setOnLoadCallback);
-
- tx.loader.writeLoadTag = function(a, b, c) {
- if (c) {
- var d;
- if (a == "script") {
- d = document.createElement("script");
- d.type = "text/javascript";
- d.src = b
- }
- else
- if (a == "css") {
- d = document.createElement("link");
- d.type = "text/css";
- d.href = b;
- d.rel = "stylesheet"
- }
- var g = document.getElementsByTagName("head")[0];
- g || (g = document.body.parentNode.appendChild(document.createElement("head")));
- g.appendChild(d)
- }
- else
- if (a == "script")
- document.write('<script src="' + b + '" type="text/javascript"><\/script>');
- else
- a == "css" && document.write('<link href="' + b + '" type="text/css" rel="stylesheet"></link>')
- };
- L("tx.loader.writeLoadTag", tx.loader.writeLoadTag);
-
-
- tx.loader.rfm = function(a) {
- N = a
- };
- L("tx.loader.rfm", tx.loader.rfm);
-
-
- tx.loader.rpl = function(a) {
- for (var b in a)
- if (typeof b == "string" && b && b.charAt(0) == ":" && !Moudles[b])
- Moudles[b] = new rpl(b.substring(1), a[b])
- };
- L("tx.loader.rpl", tx.loader.rpl);
-
-
- tx.loader.rm = function(a) {
- if ((a = a.specs) && a.length)
- for (var b = 0; b < a.length; ++b) {
- var c = a[b];
- if (typeof c == "string")
-
- Moudles[":" + c] = new U(c);
- else {
- var d = new V(c.name, c.baseSpec, c.customSpecs);
- Moudles[":" + d.name] = d
- }
- }
- };
- L("tx.loader.rm", tx.loader.rm);
-
-
- tx.loader.loaded = function(a) {
- Moudles[":" + a.module].i(a)
- };
- L("tx.loader.loaded", tx.loader.loaded);
-
- //Classes U W V rpl loadScript =========================================================
-
- //class U
- function U(a) {
- this.a = a;
- this.n = {};
- this.b = {};
- this.j = true;
- this.c = -1
- }
-
- U.prototype.f = function(a, b) {
- var c = "";
- if (b != undefined) {
- if (b.language != undefined)
- c += "&hl=" + encodeURIComponent(b.language);
- if (b.nocss != undefined)
- c += "&output=" + encodeURIComponent("nocss=" + b.nocss);
- if (b.nooldnames != undefined)
- c += "&nooldnames=" + encodeURIComponent(b.nooldnames);
- if (b.packages != undefined)
- c += "&packages=" + encodeURIComponent(b.packages);
- if (b.callback != f)
- c += "&async=2";
- if (b.other_params != undefined)
- c += "&" + b.other_params
- }
- if (!this.j) {
- if (k[this.a] && k[this.a].JSHash)
- c += "&sig=" + encodeURIComponent(k[this.a].JSHash);
- var d = [];
- for (var g in this.n)
- g.charAt(0) == ":" && d.push(g.substring(1));
- for (g in this.b)
- g.charAt(0) == ":" && d.push(g.substring(1));
- c += "&have=" + encodeURIComponent(d.join(","))
- }
- return tx.loader.ServiceBase +
- "/?file=" +
- this.a +
- "&v=" +
- a +
- tx.loader.AdditionalParams +
- c
- };
- U.prototype.u = function(a) {
- var b = f;
- if (a)
- b = a.packages;
- var c = f;
- if (b)
- if (typeof b == "string")
- c = [a.packages];
- else
- if (b.length) {
- c = [];
- for (var d = 0; d < b.length; d++)
- typeof b[d] == "string" && c.push(b[d].replace(/^\s*|\s*$/, "").toLowerCase())
- }
- c || (c = ["default"]);
- var g = [];
- for (d = 0; d < c.length; d++)
- this.n[":" + c[d]] || g.push(c[d]);
- return g
- };
- //U.prototype.load
- setLoad(U.prototype, function(a, b) {
- var c = this.u(b), d = b && b.callback != f;
- if (d)
- var g = new W(b.callback);
- for (var l = [], u = c.length - 1; u >= 0; u--) {
- var y = c[u];
- d && g.z(y);
- if (this.b[":" + y]) {
- c.splice(u, 1);
- d && this.b[":" + y].push(g)
- }
- else
- l.push(y)
- }
- if (c.length) {
- if (b && b.packages)
- b.packages = c.sort().join(",");
- if (!b && N[":" + this.a] != f && N[":" + this.a].versions[":" + a] != f && !tx.loader.AdditionalParams && this.j) {
- var z = N[":" + this.a];
- k[this.a] = k[this.a] ||
- {};
- for (var Q in z.properties)
- if (Q && Q.charAt(0) == ":")
- k[this.a][Q.substring(1)] = z.properties[Q];
-
- tx.loader.writeLoadTag("script", tx.loader.ServiceBase +
- z.path +
- z.js, d);
-
- z.css && tx.loader.writeLoadTag("css", tx.loader.ServiceBase + z.path + z.css, d)
- }
- else
- if (!b || !b.autoloaded)
- tx.loader.writeLoadTag("script", this.f(a, b), d);
- if (this.j) {
- this.j = false;
- this.c = (new Date).getTime();
- if (this.c % 100 != 1)
- this.c = -1
- }
- for (u = 0; u < l.length; u++) {
- y = l[u];
- this.b[":" + y] = [];
- d && this.b[":" + y].push(g)
- }
- }
- });
- U.prototype.i = function(a) {
- if (this.c != -1) {
- this.c = -1
- }
- for (var b = 0; b < a.components.length; b++) {
- this.n[":" + a.components[b]] = true;
- var c = this.b[":" + a.components[b]];
- if (c) {
- for (var d = 0; d < c.length; d++)
- c[d].C(a.components[b]);
- delete this.b[":" + a.components[b]]
- }
- }
- };
- U.prototype.k = function(a, b) {
- return this.u(b).length == 0
- };
- U.prototype.p = function() {
- return true
- };
-
-
- //class W
- function W(a) {
- this.B = a;
- this.l = {};
- this.o = 0
- }
-
- W.prototype.z = function(a) {
- this.o++;
- this.l[":" + a] = true
- };
- W.prototype.C = function(a) {
- if (this.l[":" + a]) {
- this.l[":" + a] = false;
- this.o--;
- this.o == 0 && window.setTimeout(this.B, 0)
- }
- };
-
-
- //class V
- function V(a, b, c) {
- this.name = a;
- this.A = b;
- this.m = c;
- this.t = this.g = false;
- this.h = [];
- tx.loader.callbacks[this.name] = H(this.i, this)
- }
-
- inherit(V, U);
-
- V.prototype.load = function(a, b) {
- var c = b && b.callback != f;
- if (c) {
- this.h.push(b.callback);
- b.callback = "tx.loader.callbacks." + this.name
- }
- else
- this.g = true;
- if (!b || !b.autoloaded) {
- var src = this.f(a, b);
- tx.loader["mname"] = this.name;
- Moudles[":" + this.name]["load"] = new loadScript(src);
- }
- };
- V.prototype.k = function(a, b) {
- return b && b.callback != f ? this.t : this.g
- };
- V.prototype.i = function() {
- this.t = true;
- for (var a = 0; a < this.h.length; a++)
- window.setTimeout(this.h[a], 0);
- this.h = []
- };
-
- // var Y = function(a, b) {
- // return a.string ? encodeURIComponent(a.string) + "=" + encodeURIComponent(b) : a.regex ? b.replace(/(^.*$)/, a.regex) : ""
- // };
-
- V.prototype.f = function(a, b) {
- return this.F(this.v(a), a, b)
- };
- V.prototype.F = function(a, b, c) {
- var d = "";
- // if (a.key)
- // d += "&" + Y(a.key, tx.loader.ApiKey);
- // if (a.version)
- // d += "&" + Y(a.version, b);
- var …
Large files files are truncated, but you can click here to view the full file