论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: Windows | Word2007 | Excel2007 | PowerPoint2007 | Dreamweaver 8 | Fireworks 8 | Flash 8 | Photoshop cs | CorelDraw 12
编程视频: C语言视频教程 | HTML | Div+Css布局 | Javascript | Access数据库 | Asp | Sql Server数据库Asp.net  | Flash AS
当前位置 > 文字教程 > Javascript教程
Tag:验证,特效,入门,实例,验证,表单,特效,正则表达式,跑马灯,document,函数,代码,getElementByID,菜单,图片,视频教程

Javascript教程_发个自己个人的 JavaScript库

文章类别:Javascript | 发表日期:2010-5-4 9:48:13

  1. /*!
  2. * JSFunction JavaScript Library v1.2.0
  3. * https://dl.dropbox.com/u/590596/index.html
  4. *
  5. * Copyright 2010, Poppy
  6. *
  7. */
  8. /**
  9. * 函数绑定this和参数
  10. * @param {Object} $1 新函数的this指向$1
  11. * $2... 加动态参数 即成为新函数的参数
  12. */
  13. Function.prototype.bind = function(){
  14.     var a = Array.prototype.slice.call(arguments), m = this, o = a.shift();
  15.     return function(){
  16.         return m.apply(o || this, a.concat(Array.prototype.slice.call(arguments)));
  17.     }
  18. };
  19. /**
  20. * 扩展 function 方法等
  21. * @param {String|Object} k
  22. * @param {Object} v
  23. */
  24. Function.prototype.extra = function(k, v){
  25.     if (typeof k == "string")
  26.         this[k] = v;
  27.     else
  28.         for(var n in k)
  29.             this[n] = k[n];
  30.     return this;
  31. };
  32. /**
  33. * 延时执行 闭包 函数
  34. */
  35. Function.prototype.exe = function(){
  36.     //=====================================================================核心 绝对私有函数 开始
  37.     var _version = "1.2.0",
  38.   /**
  39.      * 将字符串中_以及后面的字母转换_后面字符的大写形式
  40.      * @param {String} s
  41.      */
  42.     _toUpper = function(s){
  43.         return s.replace(/\-(\w)/g, function($1){
  44.             return $1.toUpperCase();
  45.         }).replace(/-/g, "");
  46.     },
  47.   /**
  48.      * 非IE下设置某些特殊属性 转义
  49.      */
  50.     _ExAttNams = {
  51.         className: "class"
  52.     },
  53.   /**
  54.      * 给Dom属性赋值
  55.      * @param {String} k 赋值的键
  56.      * @param {Object} v 赋值的值
  57.      */
  58.     _ExAttr = function(k, v){
  59.     var d = this;
  60.         if (k == "style") {
  61.             _.isStr(v) ? d.style.cssText = v : _.Ex.css.call(d, v);
  62.             return;
  63.         }
  64.         if (_.IE == 0 && _ExAttNams[k])
  65.             k = _ExAttNams[k];
  66.         if (_.isFn(v) || k == "className")
  67.             d[k] = v;
  68.         else
  69.             if (v === false || v === null || v === undefined)
  70.                 d.removeAttribute(k);
  71.             else
  72.                 if (v === true)
  73.                     d.setAttribute(k, k);
  74.                 else
  75.                     d.setAttribute(k, v);
  76.     },
  77.   /**
  78.      * dom的CSS属性赋值
  79.      * @param {String} k 赋值CSS属性的键
  80.      * @param {Object} v 赋值CSS属性的值
  81.      */
  82.     _ExCss = function(k, v){
  83.     var d = this;
  84.     if(k=="opacity" && _.IE){
  85.       if(d.filters && d.filters["alpha"])
  86.         if(v=="")
  87.           d.style.filter = d.style.filter.replace(/alpha\(Opacity=[\d.]+\)/.test(d.style.filter)?/alpha\(Opacity=[\d.]+\)/g:/Opacity=[\d.]+/g,"");
  88.         else
  89.           d.filters["alpha"]["Opacity"] = (v||0)*100;
  90.       else
  91.         d.style.filter += ("alpha(Opacity="+v*100+")");
  92.       return ;
  93.     }
  94.     d.style[_toUpper(k)] = v;
  95.     },
  96.   /**
  97.      * Dom | Doms 筛选器
  98.      * @param {String} 筛选字段
  99.      */
  100.     _Choice = function(s){
  101.         var d = _(s);
  102.         if (d)
  103.             return d;
  104.         //多位 ID 筛选 数组
  105.         if (/^#(.*)\[([^\]]*)\](.*)$/.test(s)) {
  106.             var q = RegExp["$1"] ? RegExp["$1"] + "." : "",
  107.       h = RegExp["$3"] ? "." + RegExp["$3"] : "",
  108.       Rx = RegExp["$2"].split(/[ ]/g), r = [];
  109.             for(var i = 0; i < Rx.length; i += 1)
  110.                 r.push(_(q + Rx[i] + h));
  111.             return r;
  112.         }
  113.         //多位 ID 筛选 对象
  114.         if (/^#(.*)\{([^\]]*)\}(.*)$/.test(s)) {
  115.             var q = RegExp["$1"] ? RegExp["$1"] + "." : "",
  116.       h = RegExp["$3"] ? "." + RegExp["$3"] : "",
  117.       Rx = RegExp["$2"].split(/[ ]/g), r = {};
  118.             for(var i = 0; i < Rx.length; i += 1)
  119.                 r[Rx[i]] = _(q + Rx[i] + h);
  120.             return r;
  121.         }
  122.         //Name 筛选 数组
  123.         if (/^&(.*)$/.test(s))
  124.             return _.toArr(document.getElementsByName(RegExp["$1"]));
  125.         //Tag 筛选 数组
  126.         if (/^\*(.*)\[([^\]]*)\]$/.test(s)) {
  127.             var fa = RegExp["$1"] ? _(RegExp["$1"]) : document,
  128.       Rx = RegExp["$2"].split(/[ ]/g),
  129.       r = [];
  130.             for(var i = 0; i < Rx.length; i += 1)
  131.                 r = r.concat(_.toArr(fa.getElementsByTagName(Rx[i])));
  132.             return r;
  133.         }
  134.         return null;
  135.     },
  136.   /**
  137.    * 动画涉及的 自动可变项目
  138.    */
  139.   _aOpt = ["marginLeft","marginRight","paddingLeft","paddingRight","marginTop","marginBottom","paddingTop","paddingBottom"],
  140.   /**
  141.    * 动画涉及的 手动项目
  142.    */
  143.   _animes = {
  144.     def:["opacity","width","height"],
  145.     opacity:["opacity"],
  146.     oWidth:["opacity","width"],
  147.     oHeight:["opacity","height"],
  148.     width:["width"],
  149.     height:["height"]
  150.   },
  151.   /**
  152.    * 动画时长 预定义
  153.    */
  154.   _speed = {
  155.     slow:400,
  156.     fast:200
  157.   },
  158.   /**
  159.    * 动画统一的时钟
  160.    */
  161.   _clock = {
  162.     Itvs:{},
  163.     add:function(fn){
  164.       var k = Date.parse(new Date()) + parseInt(Math.random()*1000);
  165.       _clock.Itvs[k] = fn;
  166.       if(_clock.itv==null)
  167.         _clock.itv = setInterval(_clock.step,_.IE?13:35);
  168.       return k;
  169.     },
  170.     remove:function(k){
  171.       delete _clock.Itvs[k];
  172.     },
  173.     step:function(){
  174.       var i=0;
  175.       for(var n in _clock.Itvs){
  176.         i+=1;
  177.         _clock.Itvs[n]();
  178.       }
  179.       if(i==0){
  180.         clearInterval(_clock.itv);
  181.         _clock.itv = null;
  182.       }
  183.     }
  184.   },
  185.   /**
  186.    * 获得与1970-1-1的毫秒差
  187.    * @param {Date} d
  188.    */
  189.   _getMilliseconds = function(d){
  190.     if(!d)d = new Date();
  191.     return Date.parse(d) + d.getMilliseconds();
  192.   },
  193.   /**
  194.    * 动画效果函数
  195.    * @param {Element}   dom     节点
  196.    * @param {String}     type    类型
  197.    * @param {Number}     speed    速度
  198.    * @param {Function}   jsback    回调
  199.    * @param {Arrray}    anime    动画类型
  200.    */
  201.   _fxc = function(dom,type,speed,jsback,anime){
  202.     var arr = {},mx = {},unit = {},endTime = _getMilliseconds() + speed,count = 0,show = type=="show";
  203.     for(var i=0,n,o,v;i<_aOpt.length;i+=1){
  204.       n = _aOpt[i];
  205.       o = _.Ex.css.call(dom,n);
  206.       v = parseFloat(o) || 0;
  207.       if(v<=0) continue;
  208.       arr[n] = o;
  209.       mx[n] = v;
  210.       unit[n] = o.replace(/\d/g,"");
  211.       if(show)_.Ex.css.call(dom,0);
  212.     }
  213.     
  214.     var setAnime = {
  215.       //水平 滚动
  216.       width:function(){
  217.         arr.width = _.Ex.css.call(dom,"width");
  218.         unit.width = arr.width?arr.width.replace(/\d/g,""):"px";
  219.         mx.width = parseFloat(arr.width) || _.Ex.cssWidth.call(dom);
  220.         if(show)_.Ex.css.call(dom,"width","0px");
  221.       },
  222.       //垂直 滚动
  223.       height:function(){
  224.         arr.height = _.Ex.css.call(dom,"height");
  225.         unit.height = arr.height?arr.height.replace(/\d/g,""):"px";
  226.         mx.height = parseFloat(arr.height) ||_.Ex.cssHeight.call(dom);
  227.         if(show)_.Ex.css.call(dom,"height","0px");
  228.       },
  229.       //透明度
  230.       opacity:function(){
  231.         arr.opacity = _.Ex.css.call(dom,"opacity") || "";
  232.         unit.opacity = "";
  233.         mx.opacity = arr.opacity || 1;
  234.         if(show)_.Ex.css.call(dom,"opacity",0.001);
  235.       }
  236.     };
  237.     //每次滚动的 变换
  238.     function step(fg){
  239.       var p = (speed - endTime + _getMilliseconds())/speed, flg = fg || p>=1;
  240.       if(flg && !show)_.Ex.css.call(dom,"display","none");
  241.       for(var n in arr)
  242.         _.Ex.css.call(dom,n,flg?arr[n]:(parseFloat(mx[n]*((-Math.cos((show?p:1-p)*Math.PI)/2) + 0.5)) + unit[n]));
  243.       if(flg){
  244.         _.Ex.css.call(dom,"overflow",ov);
  245.         if(!fg && jsback)jsback();
  246.         clear();
  247.       }
  248.     };
  249.     //清楚计时器
  250.     function clear(){
  251.       dom.$fxcKey = null;
  252.       _clock.remove(Itv);
  253.       Itv = null;
  254.     };
  255.     
  256.     if(show)dom.style.display = dom.getAttribute("displayShow") || "block";
  257.     for(i=0;ilength;i+=1)
  258.       if(setAnime[anime[i]])setAnime[anime[i]]();
  259.     var ov = _.Ex.css.call(dom,"overflow");
  260.     _.Ex.css.call(dom,"overflow","hidden");
  261.     var Itv = _clock.add(step);
  262.     dom.$fxcKey = Itv;
  263.     return Itv;
  264.   };
  265.     //=====================================================================核心 绝对私有函数 结束 *** 隐藏方法开始========
  266.     /**
  267.      * 单个节点查找
  268.      * @param {Object} v
  269.      */
  270.     var _ = function(v){
  271.         return _.isStr(v) ? document.getElementById(v) : v;
  272.     }.extra({
  273.         /**
  274.          * IE版本号
  275.          */
  276.         IE: (window.attachEvent && window.ActiveXObject && !window.opera)?
  277.       parseInt(navigator.userAgent.toLowerCase().match(/msie ([\d.]+)/)[1]):0,
  278.     Opera:navigator.userAgent.indexOf("Opera")>=0,
  279.     /**
  280.        * 验证 v的类型是否和f相同
  281.        * @param {Object} v
  282.        * @param {Object} f
  283.        */
  284.       ckType: function(v, f){
  285.           if (v == null || v == window || v == document || v == f)
  286.               return v == f;
  287.       
  288.       var r = v.nodeName ? v.nodeType == 1 ? "Element" : v.nodeType == 3 ? "Text" : undefined : undefined;
  289.           if (v.constructor && v.constructor === f){
  290.         if(f===Object && _.Opera)return r==undefined;
  291.         return true;
  292.       }
  293.           
  294.           var r = v.nodeName ? v.nodeType == 1 ? "Element" : v.nodeType == 3 ? "Text" : undefined : undefined;
  295.           if (r)
  296.               return r == f;
  297.           r = _.trimStr(v.constructor.toString()).match(/^function\s*([\w$]*)/)[1];
  298.           return r == f;
  299.       },
  300.     /**
  301.      * 遍历 o
  302.      * @param {Object|Array} o
  303.      * @param {Function} f
  304.      */
  305.     each:function(o,f,self){
  306.       if(typeof o.length =="number")
  307.         for(var i=0;ilength;i+=1)self?f.call(self,i,o[i]):f(n,o[i]);
  308.       else
  309.         for(var n in o)self?f.call(self,n,o[n]):f(n,o[n]);
  310.       return self || this;
  311.     },
  312.         /**
  313.          * 去除两端空白字符
  314.          * @param {String} v
  315.          */
  316.         trimStr: function(v){
  317.             return (v || "").replace(/^\s+|\s+$/g, "");
  318.         },
  319.         /**
  320.          * 判断v是否是字符串
  321.          * @param {Object} v
  322.          * @param {Boolean} f 是否是严格类型的
  323.          */
  324.         isStr: function(v, f){
  325.             return f ? _.ckType(v, String) : typeof v == "string";
  326.         },
  327.         /**
  328.          * 判断v是否是 函数
  329.          * @param {Object} v
  330.          * @param {Boolean} f 是否是严格类型的
  331.          */
  332.         isFn: function(v, f){
  333.             return f ? _.ckType(v, Function) : typeof v == "function";
  334.         },
  335.         /**
  336.          * 判断v是否是 数组
  337.          * @param {Object} v
  338.          * @param {Boolean} f 是否是严格类型的
  339.          */
  340.         isArr: function(v, f){
  341.             return f ? _.ckType(v, Array) : Object.prototype.toString.call(v) == "[object Array]";
  342.         },
  343.         /**
  344.          * object 或者 array
  345.          * @param {Object} v
  346.          * @param {Object} f 是否是严格类型的
  347.          */
  348.         isAO: function(v, f){
  349.             return v && (_.isArr(v, f) || _.ckType(v, Object));
  350.         },
  351.         /**
  352.          * 将v强制转换成数组
  353.          * @param {Object} v
  354.          */
  355.         toArr: function(v){
  356.             if (_.isArr(v))
  357.                 return v;
  358.             if (v == null)
  359.                 return [];
  360.             var i = v.length;
  361.             if (i == null || _.isStr(v) || _.isFn(v) || v === window)
  362.                 return [v];
  363.             try {
  364.                 var r = Array.prototype.slice.call(v);
  365.             }catch(e){
  366.                 var r = [];
  367.                 while (i)r[--i] = v[i];
  368.             }
  369.             return r;
  370.         },
  371.         /**
  372.          * 将p格式化成url字符串
  373.          * @param {Object} p
  374.          * @param {Function} f 格式化函数
  375.          * @param {Object} l1 连接字符 =
  376.          * @param {Object} l2 连接字符 &
  377.          */
  378.         formatUrl: function(p, f, l1, l2){
  379.             var s = [];
  380.             if(p)
  381.                 for(var n in p)
  382.                     s.push(n + (l1 || "=") + (f || encodeURIComponent)(p[n]));
  383.             return s.join(l2 || "&");
  384.         },
  385.         /**
  386.          * 格式化 v 代码化
  387.          * @param {String} v
  388.          */
  389.         formatScript: function(v){
  390.             try {
  391.                 window.execScript(v);
  392.                 return true;
  393.             }catch(e){
  394.                 try {
  395.                     window.eval(v);
  396.                     return true;
  397.                 }catch(e){
  398.                     return false;
  399.                 }
  400.             }
  401.         },
  402.         /**
  403.          * 将XML格式的字符串 v 格式化为 XML
  404.          * @param {String} v
  405.          */
  406.         str2xml: function(v){
  407.             try {
  408.                 var X = new ActiveXObject("Microsoft.XMLDOM"), f = X.loadXML(v);
  409.                 return f ? X : null;
  410.             }catch (e) {
  411.                 try {
  412.                     var X = new DOMParser().parseFromString(v, "text/xml");
  413.                     return X.documentElement ? X : null;
  414.                 }catch (e) {
  415.                     return null;
  416.                 }
  417.             }
  418.         },
  419.         /**
  420.          * 将json格式字符串转换成 json
  421.          * @param {String} s
  422.          */
  423.         str2json: function(v){
  424.             try {
  425.                 return eval("(" + v + ")");
  426.             }catch (e) {
  427.                 return null;
  428.             }
  429.         },
  430.         /**
  431.          * 单点Dom处理对象 所有的this指向Element节点
  432.          */
  433.         Ex: {
  434.             /**
  435.              * 设置Element属性
  436.              * @param {Object|String} k
  437.              * @param {Object} v
  438.              */
  439.             attr: function(k, v){
  440.                 if (v === undefined && _.isStr(k))
  441.                     return this[k] === undefined ? this.getAttribute(k) : this[k];
  442.                 if (_.isStr(k))
  443.                     _ExAttr.call(this, k, v);
  444.                 else
  445.           _.each(k,_ExAttr,this);
  446.                 return this;
  447.             },
  448.       /**
  449.        * Dom上增加一个样式
  450.        * @param {String} v
  451.        */
  452.       addClass:function(v){
  453.         v =  _.trimStr(v);
  454.         if(!v)return this;
  455.         if(!this.className){
  456.           this.className = v;
  457.           return this;
  458.         }
  459.         
  460.         var cn = " " + _.trimStr(this.className).replace(/\s+/g," ") + " ";
  461.         _.each(v.split(/\s+/),function(){
  462.           if(cn.indexOf(" " + arguments[1] + " ")<0)cn += (arguments[1] + " ");
  463.         },this);
  464.         this.className = _.trimStr(cn);
  465.         return this;
  466.       },
  467.       /**
  468.        * Dom上移除一个样式
  469.        * @param {String} v
  470.        */
  471.       removeClass:function(v){
  472.         if(!this.className)return this;
  473.         v =  _.trimStr(v);
  474.         if(!v)return this;
  475.         
  476.         var cn = " " + _.trimStr(this.className).replace(/\s+/g," ") + " ";
  477.         _.each(v.split(/\s+/),function(){
  478.           if(cn.indexOf(" " + arguments[1] + " ")>=0)cn = cn.replace(" " + arguments[1] + " "," ");
  479.         },this);
  480.         this.className = _.trimStr(cn);
  481.         return this;
  482.       },
  483.             /**
  484.              * 设置Element样式属性
  485.              * @param {Object|String} k
  486.              * @param {Object} v
  487.              */
  488.             css: function(k, v){
  489.                 if (v === undefined && _.isStr(k)){
  490.           if(k=="opacity" && _.IE){
  491.             return this.filters["alpha"]?this.filters["alpha"]["Opacity"]/100 || "":"";
  492.           }
  493.           return this.style[_toUpper(k)];
  494.         }
  495.                 if (_.isStr(k))
  496.                     _ExCss.call(this, k, v);
  497.                 else
  498.           _.each(k,_ExCss,this);
  499.                 return this;
  500.             },
  501.       /**
  502.        * 获得Dom的CSS宽度 如果是自动 更具offset自动算出
  503.        */
  504.       cssWidth:function(){
  505.         var v = _.Ex.css.call(this,"width");
  506.         if(v)return v.replace(/^\d/g,"")*1;
  507.         v = this.offsetWidth;
  508.         if(v==0)return 0;
  509.         v -= parseFloat(_.Ex.css.call( this, "paddingLeft")) || 0;
  510.         v -= parseFloat(_.Ex.css.call( this, "paddingRight")) || 0;
  511.         v -= parseFloat(_.Ex.css.call( this, "borderLeftWidth")) || 0;
  512.         v -= parseFloat(_.Ex.css.call( this, "borderRightWidth")) || 0;
  513.         return v;
  514.       },
  515.       /**
  516.        * 获得Dom的CSS高度 如果是自动 更具offset自动算出
  517.        */
  518.       cssHeight:function(){
  519.         var v = _.Ex.css.call(this,"height");
  520.         if(v)return v.replace(/^\d/g,"")*1;
  521.         v = this.offsetHeight;
  522.         if(v==0)return 0;
  523.         v -= parseFloat(_.Ex.css.call( this, "paddingTop")) || 0;
  524.         v -= parseFloat(_.Ex.css.call( this, "paddingBottom")) || 0;
  525.         v -= parseFloat(_.Ex.css.call( this, "borderTopHeight")) || 0;
  526.         v -= parseFloat(_.Ex.css.call( this, "borderBottomHeight")) || 0;
  527.         return v;
  528.       },
  529.       /**
  530.        * 增加对本节点的 显示动画 的函数
  531.        * @param {String|Number} s 动画时长
  532.        * @param {Function} b 动画结束回调
  533.        * @param {Object} a 动画类型 width height def opacity
  534.        */
  535.       show: function(s,b,a){
  536.         if(this.$fxcKey)$.Fn.fxcStop(this.$fxcKey);
  537.         if(s)return _fxc(this,"show",_speed[s]?_speed[s]:s,b,_animes[a]?_animes[a]:_animes.def);
  538.         if(this.style.display == "none")this.style.display = this.getAttribute("displayShow") || "block";
  539.         return this;
  540.       },
  541.       /**
  542.        * 增加对本节点的 显示动画 的函数
  543.        * @param {String|Number} s 动画时长
  544.        * @param {Function} b 动画结束回调
  545.        * @param {Object} a 动画类型 width height def opacity
  546.        */
  547.       hide:function(s,b,a){
  548.         if(this.$fxcKey)$.Fn.fxcStop(this.$fxcKey);
  549.         if(s)return _fxc(this,"hide",_speed[s]?_speed[s]:s,b,_animes[a]?_animes[a]:_animes.def);
  550.         if(this.style.display != "none")this.style.display = "none";
  551.         return this;
  552.       },
  553.             /**
  554.              * 设置innerHTML属性 或者获得thi的innerHTML属性
  555.              * @param {String} v
  556.              */
  557.             html: function(v){
  558.                 if (v === undefined)
  559.                     return this.innerHTML;
  560.                 this.innerHTML = v;
  561.                 return this;
  562.             },
  563.             /**
  564.              * 设置innerTextL属性 或者获得thi的innerText属性
  565.              * @param {String} v
  566.              */
  567.             text: function(v){
  568.                 var k = _.IE ? "innerText" : "textContent";
  569.                 if (v === undefined)
  570.                     return this[k];
  571.                 this[k] = v;
  572.                 return this;
  573.             },
  574.       /**
  575.        * 清除this下的所有字节点
  576.        */
  577.       clear: function(){
  578.         while (this.childNodes.length)this.removeChild(this.lastChild);
  579.         return this;
  580.       },
  581.       /**
  582.        * 获得Element的 宽 高 左 顶部
  583.        * width height left top
  584.        */
  585.       getCoord: function(){
  586.         var l=0,t=0,e=this;
  587.         while(e.parentNode){
  588.           l += (e.offsetLeft - e.scrollLeft);
  589.           t += (e.offsetTop - e.scrollTop);
  590.           e = e.parentNode;
  591.         }
  592.         return {left:l,top:t,width:this.offsetWidth,height:this.offsetHeight};
  593.       },
  594.       /**
  595.        * 添加字节点
  596.        * @param {Element | Elements} v
  597.        */
  598.       append: function(v){
  599.         d = _Choice(v);
  600.         if (_.isAO(v))
  601.           for(var n in v)_.Ex.append.call(this, v[n]);
  602.         else
  603.           this.appendChild(v);
  604.         return this;
  605.       },
  606.       /**
  607.        * 将自己加入到目标节点中去
  608.        * @param {Object} d
  609.        */
  610.       appendTo: function(d){
  611.         _.Ex.append.call(_(d),this);
  612.         return this;
  613.       },
  614.       /**
  615.        * 添加事件
  616.        * @param {String} e
  617.        * @param {Function} f
  618.        */
  619.       addEvent: function(e,f){
  620.         if(this.attachEvent)
  621.           this.attachEvent("on" + e,f);
  622.         else if(this.addEventListener)
  623.           this.addEventListener(e, f, false);
  624.         else
  625.           this["on" + e] = f;
  626.         return this;
  627.       },
  628.       /**
  629.        * 移除事件
  630.        * @param {String} e
  631.        * @param {Function} f
  632.        */
  633.       removeEvent: function(e,f){
  634.         if(this.detachEvent)
  635.           this.detachEvent("on" + e,f);
  636.         else if(this.removeEventListener)
  637.           this.removeEventListener(e, f, false);
  638.         else
  639.           delete this["on" + e];
  640.         return this;
  641.       },
  642.       /**
  643.        * 设置input为空时提示信息
  644.        * @param {String} i
  645.        */
  646.       setIptCue: function(v){
  647.         this.value = v;
  648.         _.Ex.addEvent.call(this, "focus", function(){
  649.           if(_.trimStr(this.value)==v)this.value = "";
  650.         }.bind(this));
  651.         _.Ex.addEvent.call(this, "blur", function(){
  652.           if(_.trimStr(this.value)=="")this.value = v;
  653.         }.bind(this));
  654.         return this;
  655.       },
  656.       /**
  657.        * 设置回车提交 或者Ctrl回车提交
  658.        * @param {Function|Element} t
  659.        * @param {boolean} f 是否需要加入ctrl
  660.        */
  661.       setEnterDo: function(t,f){
  662.         _.Ex.addEvent.call(this, "keyup", function(ev){
  663.           ev = ev || window.event;
  664.           if(ev.keyCode*1==13 && (!f || ev.ctrlKey)){
  665.             try{t();}catch(e){_.Ex.doEvent.call(_(t),"click");}
  666.           };
  667.         });
  668.         return this;
  669.       },
  670.       /**
  671.        * 模拟事件执行
  672.        * @param {String} v
  673.        */
  674.       doEvent: function(v){
  675.         v = v || "click";
  676.         if(document.createEventObject)
  677.           this.fireEvent('on' + v);
  678.         else if(document.createEvent){
  679.           var o = document.createEvent('MouseEvents');
  680.           o.initEvent(v,true,false);
  681.           this.dispatchEvent(o);
  682.         }
  683.         else
  684.           this["on" + v]();
  685.         return this;
  686.       },
  687.       /**
  688.        * 设置Dom加载完毕时调用
  689.        * @param {Function} f
  690.        */
  691.       ready: function(f){
  692.         if(this.addEventListener)
  693.           this.addEventListener("DOMContentLoaded", f, false);
  694.         else if(this.attachEvent)
  695.           this.attachEvent("onreadystatechange", function(){
  696.             if (this.readyState == "complete" || this.readyState == "loaded")f();
  697.           }.bind(this));
  698.         else
  699.           f.exe(0);
  700.         return this;
  701.       }
  702.         },
  703.     /**
  704.        * 单个Dom操作 直接转多个Dom操作
  705.        * @param {String} k 操作函数
  706.        * @param {Boolean} f 是否需要分散参数
  707.        * @param {Object} n 定义的参数个数
  708.        * @param {Object} v 第v个参数确定 返回值
  709.        */
  710.       ExsBind: function(k, f, n, v){
  711.             return function(){
  712.                 var r = _.isArr(this) ? [] : {};
  713.                 var b = v > 0 ? arguments[v - 1] ? -1 : 0 : v;
  714.                 for(var m in this)
  715.                     r[m] = _.Ex[k].apply(this[m], f ? function(){
  716.                         for(var i = 0, a = []; i < n; i += 1)
  717.                             a.push(_.isAO(this[i]) ? this[i][m] : this[i]);
  718.                         return a;
  719.                     }.call(arguments) : arguments);
  720.                 return b ? this : r;
  721.           }
  722.       }
  723.     });
  724.     
  725.   /**
  726.    * 单点Dom集合处理对象
  727.    */
  728.   _.Exs = function(ks){
  729.     for(var i=0,v={};ilength;i+=1)v[ks[i][0]] = _.ExsBind.apply(null,ks[i]);
  730.     return v;
  731.   }([
  732.     ["attr",true,2,2],
  733.     ["css",true,2,2],
  734.     ["show",true,3,-1],
  735.     ["hide",true,3,-1],
  736.     ["html",true,1,1],
  737.     ["text",true,1,1],
  738.     ["appendTo",true,1,-1],
  739.     ["addEvent",true,2,-1],
  740.     ["removeEvent",true,2,-1],
  741.     ['setIptCue',false,1,-1],
  742.     ['setEnterDo',true,2,-1],
  743.     ['doEvent',true,1,-1]
  744.   ]);
  745.   /**
  746.    * 某个显示
  747.    * @param {Object} k 显示的对象
  748.    * @param {Object} d 显示时 display赋的值
  749.    */
  750.   _.Exs.oneShow = function(k,d){
  751.     d = d || "";
  752.     for(var n in this)this[n].style.display = (n==k || this[n]==k)?d:"none";
  753.     return this;
  754.   };
  755.   /**
  756.    * 某个特殊显示
  757.    * @param {Object} k
  758.    * @param {Object} s 特殊样式
  759.    * @param {Object} d 一般样式
  760.    */
  761.   _.Exs.oneSe = function(k,s,d){
  762.     if(!s)return this;
  763.     d = d || "";
  764.     var v;
  765.     for(var n in this){
  766.       v = (n == k || this[n] == k) ? s : _.isAO(d)?d[n] || "":d;
  767.       _.isStr(v)?this[n].className = v:_.Ex.css.call(this[n], v);
  768.     }
  769.     return this;
  770.   };
  771.   /**
  772.    * 取得radio的值
  773.    */
  774.   _.Exs.radioValue = function(){
  775.     for(var n in this)if(this[n].checked)return this[n].value;
  776.     return null;
  777.   };
  778.   /**
  779.    * 所有类的构建函数
  780.    */
  781.   var _newClass = function(){
  782.     return function(a){
  783.       //初始化函数
  784.       if(a !== _C)
  785.         this.onInit.apply(this, arguments);
  786.     };
  787.   },
  788.   /**
  789.    * 所有扩展类的基类
  790.    */
  791.   _C = _newClass();
  792.   /**
  793.    * 用户扩展基于本类的新类
  794.    * @param {Object} e
  795.    */
  796.   _C.extend = function(e){
  797.     var c = _newClass(),p = new this(this),s = this.prototype;
  798.       for(var n in e){
  799.           if(_.isFn(e[n]) && s[n])e[n].superset = s[n];//设置 此方法的 父方法 此方法的 superset 属性指向父方法的 执行
  800.           p[n] = e[n];
  801.       };
  802.       c.prototype = p;
  803.     //设置新的类的constructor 指向 自己
  804.     c.prototype.constructor = c;
  805.       //赋给这个新的子类同样的静态extend方法
  806.       c.extend = this.extend;
  807.       return c;
  808.   };
  809.   /**
  810.    * 设置 constructor 执行自身
  811.    */
  812.   _C.prototype.constructor = _C;
  813.   /**
  814.    * 默认 初始化
  815.    */
  816.   _C.prototype.onInit = function(){};
  817.   /**
  818.    * 通用方法 扩展Object
  819.    */
  820.   _C.prototype.extra = function(){
  821.     Function.prototype.extra.apply(this, arguments);
  822.     return this;
  823.   };
  824.   /**
  825.    * 通用方法 设置参数 设定所有参数的前缀为 $
  826.    * @param {Object} k
  827.    * @param {Object} v
  828.    */
  829.   _C.prototype.setAtt = function(k, v){
  830.     this["$" + k] = v;
  831.     return this;
  832.   };
  833.     //=====================================================================隐藏方法 结束  ** 全局量开始
  834.   var $ = function(v,f){
  835.     if(v==null)
  836.       return null;
  837.     if(_.isStr(v))
  838.       v = _Choice(v);
  839.     if(!v)
  840.       return null;
  841.     if(f===true)
  842.       return new (_.isAO(v)?$.ElementCollect:$.Element)(v);
  843.     if(_.isStr(f) || _.isFn(f))
  844.       return (_.isFn(f)?f:(_.isAO(v)?_.Exs:_.Ex)[f]).apply(v,Array.prototype.slice.call(arguments,2));
  845.     return v;
  846.   }.extra({
  847.     /**
  848.      * Joo版本
  849.      */
  850.     $version:_version,
  851.     /**
  852.      * 所有新类的基类
  853.      */
  854.     Class:_C,
  855.     /**
  856.      * Collect 集合类 基于 _C
  857.      */
  858.     Collect:_C.extend({
  859.       /**
  860.        * 初始化 设置数据
  861.        * @param {Object} v
  862.        */
  863.       onInit:function(v){
  864.         this.$data = v;
  865.       },
  866.       /**
  867.        * 获取指定路径数值
  868.        * @param {String} k
  869.        */
  870.       get:function(k){
  871.         return k===undefined?this.$data:this.$data[k];
  872.       },
  873.       /**
  874.        * 设置指定路径的数值
  875.        * @param {String} k
  876.        * @param {Object} v
  877.        */
  878.       set:function(k,v){
  879.         this.$data[k] = v;
  880.         return this;
  881.       },
  882.       /**
  883.        * 循环指定路径数值
  884.        * @param {Function} f
  885.        */
  886.       each:function(f){
  887.         _.each(this.$data,f,this);
  888.         return this;
  889.       },
  890.       /**
  891.        * 所有 $data 的键集合
  892.        */
  893.       keys:function(){
  894.         var v = [];
  895.         for(var n in this.$data)v.push(n);
  896.         return v;
  897.       },
  898.       /**
  899.        * 所有 $data 值集合
  900.        */
  901.       values:function(){
  902.         var v = [];
  903.         for(var n in this.$data)v.push(this.$data[n]);
  904.       },
  905.       /**
  906.        * 合并 其他的 数组或者对象
  907.        * @param {Array|Object} o
  908.        */
  909.       accept:function(o){
  910.         Function.prototype.extra.call(this.$data,o);
  911.         return ;
  912.       }
  913.     })
  914.   });
  915.     //=============================================================================节点对象
  916.   /**
  917.    * Element 或者 ElementCollect 附加原型方法是用的同意函数
  918.    * @param {Object} v
  919.    */
  920.   var _newEC = function(v){
  921.     return function(){
  922.       var t = v.apply(this.$data,arguments);
  923.       return t==this.$data?this:t;
  924.     };
  925.   },
  926.   /**
  927.      * 动态创建Dom时使用的缓存
  928.      */
  929.     _ElementCashe = {};
  930.   
  931.   /**
  932.    * Element 单节点对象
  933.    */
  934.   $.Element = _C.extend(function(){
  935.     //集合类
  936.     var r = {};
  937.     //循环 _.Ex 中的方法 作为Element的方法
  938.     for(var n in _.Ex)
  939.       r[n] = _newEC(_.Ex[n]);
  940.     //增加 初始化函数
  941.     r.onInit = function(s){
  942.       this.$data = _(s);
  943.       return this;
  944.     };
  945.     //增加 获得对象中的节点的方法
  946.     r.get = function(){
  947.       return this.$data;
  948.     };
  949.     return r;
  950.   }());
  951.   /**
  952.    * 为Element 和 _.Ex类添加方法 用户开发插件
  953.    * @param {String|Object} k
  954.    * @param {Function} v
  955.    */
  956.   $.Element.add = function(k,v){
  957.     var o = _.isStr(k)?k = Function.prototype.extra.call({},k,v):k;
  958.     for(var n in o){
  959.       _.Ex[n] = o[n];
  960.       $.Element.prototype[n] = _newEC(o[n]);
  961.     }
  962.     return this;
  963.   };
  964.   /**
  965.    * 动态创建Element
  966.    * @param {String} t 节点类型 div span 等
  967.    * @param {Object|text} 节点属性 text 为t创建文本节点
  968.    * @param {Object} h innerHTML属性
  969.    * @param {Object} y 加入某个数组或者节点
  970.    */
  971.   $.Element.create = function(t,b,h,y){
  972.     if(b=="text")return document.createTextNode(t);
  973.     //制造节点
  974.     b = b || {},t = t.toLowerCase();
  975.     //IE中的只读属性
  976.     if(_.IE && (b.name || b.checked || b.hidefocus)){
  977.       t = '<' + t;
  978.       if(b.name){
  979.         t = t + ' name="' + b.name + '"';
  980.         delete b.name;
  981.       }
  982.       if(b.checked){
  983.         t = t + ' checked="checked"';
  984.         delete b.checked;
  985.       }
  986.       if(b.hidefocus){
  987.         t = t + ' hidefocus="true"';
  988.         delete b.hidefocus;
  989.       }
  990.       t = t + " >";
  991.     }
  992.     if (!_ElementCashe[t])_ElementCashe[t] = document.createElement(t);
  993.     var e = _ElementCashe[t].cloneNode(false);
  994.     if(_.isStr(h) || typeof h == "number")e.innerHTML = h;
  995.     
  996.     //设置属性
  997.     _.Ex.attr.call(e,b);
  998.     //封装
  999.     if(_.isArr(y))y.push(e);
  1000.     else if(_.ckType(y,"Element") || _.isStr(y))_.Ex.appendTo.call(e,y);
  1001.     return e;
  1002.   };
  1003.   
  1004.   /**
  1005.    * ElementCollect 复节点对象
  1006.    */
  1007.   $.ElementCollect = $.Collect.extend(function(){
  1008.     var r = {};
  1009.     for(var n in _.Exs)r[n] = _newEC(_.Exs[n]);
  1010.     r.onInit = function(s){
  1011.       this.$data = _Choice(s);
  1012.       return this;
  1013.     };
  1014.     r.get = function(k,f){
  1015.       return this.$data[k]?f?new $.Element(this.$data[k]):this.$data[k]:this.$data;
  1016.     };
  1017.     return r;
  1018.   }());
  1019.   /**
  1020.    * 为ElementCollect 和 _.Exs类添加方法 用户开发插件
  1021.    * @param {String|Object} k
  1022.    * @param {Function} v
  1023.    */
  1024.   $.ElementCollect.add = function(k,v){
  1025.     var o = _.isStr(k)?k = Function.prototype.extra.call({},k,v):k;
  1026.     for(var n in o){
  1027.       _.Exs[n] = o[n];
  1028.       $.ElementCollect.prototype[n] = _newEC(o[n]);
  1029.     }
  1030.     return this;
  1031.   };
  1032.   
  1033.   /**
  1034.    * 创建有结构的节点群体
  1035.    * @param {Object} t
  1036.    * @param {Object} y
  1037.    */
  1038.   $.ElementCollect.create = function(t,y){
  1039.     if(_.isStr(t[0])){
  1040.       var rv = $.Element.create(t[0],t[1],t[2],(t[3] && _.isArr(t[3]))?t[3]:undefined);
  1041.       if(_.isArr(t[2]))_.Ex.append.call(rv,$.ElementCollect.create(t[2]));
  1042.     }
  1043.     else
  1044.       for(var i=0,rv = [];ilength;i+=1)rv.push(_.isArr(t[i])?$.ElementCollect.create(t[i]):t[i]);
  1045.     if(_.isStr(y) || _.ckType(y,"Element"))_.Ex.appendTo.call(rv,y);
  1046.     return rv;
  1047.   };
  1048.   
  1049.   //========================================================================Ajax对象
  1050.   /**
  1051.      * 创建Http对象
  1052.      */
  1053.    var _createHttp = function(){
  1054.         try {
  1055.             return new ActiveXObject("Msxml2.XMLHTTP");
  1056.         }catch (e) {
  1057.             try {
  1058.                 return new ActiveXObject("Microsoft.XMLHTTP");
  1059.             }catch (e) {
  1060.                 try {
  1061.                     return new XMLHttpRequest();
  1062.                 }catch (e) {
  1063.                     return null;
  1064.                 }
  1065.             }
  1066.         }
  1067.     },
  1068.   _getURl = function(u,p){
  1069.     return u + (p?(u.indexOf("?") > -1 ? "&" : "?") + p:"")
  1070.   },
  1071.   /**
  1072.    * Ajax Send 方式
  1073.    * @param {Boolean} async
  1074.    * @param {Object} pre
  1075.    * @param {Boolean} flag
  1076.    */
  1077.   _ajaxSend = function(async,pre,flag){
  1078.     if(this.$_opening){
  1079.       if(!flag)return;
  1080.       //强制中止现有的请求 执行新的请求
  1081.       _ajaxBlur.call(this,true);
  1082.     }
  1083.   
  1084.     this.$_opening = true;
  1085.     
  1086.     this.$HO = _createHttp();
  1087.     if(!this.$HO){
  1088.       try{this.onNoHttp();}catch(e){};
  1089.       return ;
  1090.     }
  1091.     var preStr = _.formatUrl(Function.prototype.extra.call(Function.prototype.extra.call({},this.$pre),pre));
  1092.     //Loading....
  1093.     try{this.onLoading();}catch(e){};
  1094.     _ajaxSetHead.call(this);
  1095.     if(this.$mType == "GET"){
  1096.       this.$HO.open(this.$mType, _getURl(this.$url,preStr), async);
  1097.       preStr = null;
  1098.     }
  1099.     else {
  1100.       this.$HO.open(this.$mType, this.$url, async);
  1101.       this.$HO.setRequestHeader("Method", this.$mType+" "+this.$url+" HTTP/1.1");
  1102.       this.$HO.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  1103.       preStr = preStr.replace(/[\x00-\x08\x11-\x12\x14-\x20]/g, "*");
  1104.     }
  1105.   
  1106.     //超时自动 中止
  1107.     if(this.$ovTime && this.$ovTime>0)this.$_blurer = setTimeout(_ajaxBlur.bind(this),this.$ovTime);
  1108.     if(async){
  1109.       this.$HO.onreadystatechange = _ajaxChange.bind(this);
  1110.       this.$HO.send(preStr);
  1111.       return this;
  1112.     }
  1113.     else{
  1114.       this.$HO.send(preStr);
  1115.       return _ajaxReady.call(this);
  1116.     }
  1117.   },
  1118.   /**
  1119.    * Ajax 状态改变时接收
  1120.    */
  1121.   _ajaxChange = function(){
  1122.     if(this.$HO && this.$HO.readyState==4)_ajaxReady.call(this);
  1123.   };
  1124.   /**
  1125.    * Ajax 请求结束
  1126.    */
  1127.   _ajaxReady = function(){
  1128.     //请求结束
  1129.     this.$_opening = false;
  1130.     _ajaxClearBlur.call(this);
  1131.     try{this.onComplete();}catch(e){};
  1132.     if(this.$HO.status !=200){
  1133.       if(this.$_blurFlag)return null;
  1134.       this.$data = null;
  1135.       try{this.onFail(this.$unusual);}catch(e){};
  1136.       _ajaxDestroy.call(this);
  1137.       return null;
  1138.     }
  1139.     
  1140.     //请求成功
  1141.     _ajaxBack[this.$bType].call(this);
  1142.     _ajaxDestroy.call(this);
  1143.     return this.$data;
  1144.   },
  1145.   /**
  1146.    * Ajax 中止
  1147.    * @param {Boolean} f
  1148.    */
  1149.   _ajaxBlur = function(f){
  1150.     _ajaxClearBlur.call(this);
  1151.     this.$_opening = false;
  1152.     this.$_blurFlag = f;
  1153.     try{
  1154.       this.$HO.abort();
  1155.     }catch(e){
  1156.       _scriptHODestroy.call(this,true);
  1157.     }
  1158.     //调用中止方法
  1159.     this.$data = null;
  1160.     if(f)try{this.onAbort();}catch(e){};
  1161.     this.$_blurFlag = null;
  1162.   },
  1163.   /**
  1164.    * 清楚超时 中止数据
  1165.    */
  1166.   _ajaxClearBlur = function(){
  1167.     if(!this.$_blurer)return;
  1168.     clearTimeout(this.$_blurer);
  1169.     this.$_blurer = null;
  1170.   },
  1171.   /**
  1172.    * Ajax 销毁
  1173.    */
  1174.   _ajaxDestroy = function(){
  1175.     if(!this.$HO)return ;
  1176.     setTimeout(function(){
  1177.       if(this.$_opening)return;
  1178.       try{
  1179.         _scriptHODestroy.call(this);
  1180.       }catch(e){
  1181.         this.$HO = null;
  1182.         delete this.$HO;
  1183.       }
  1184.     }.bind(this));
  1185.   },
  1186.   /**
  1187.    * 设置Ajax请求头
  1188.    */
  1189.   _ajaxSetHead = function(){
  1190.     if(!this.$HO || !this.$head)return ;
  1191.     if(this.$head)_.each(this.$head,this.$HO.setRequestHeader,this);
  1192.   },
  1193.   /**
  1194.    * jsonp Send 方好似
  1195.    * @param {Object} async
  1196.    * @param {Object} pre
  1197.    * @param {Object} flag
  1198.    */
  1199.   _scriptSend = function(async,pre,flag){
  1200.     if(this.$_opening){
  1201.       if(!flag)return;
  1202.       //强制中止现有的请求 执行新的请求
  1203.       _ajaxBlur.call(this,true);
  1204.     }
  1205.     
  1206.     this.$_opening = true;
  1207.     var o = Function.prototype.extra.call(Function.prototype.extra.call({},this.$pre),pre);
  1208.     o[this.$jsonpBackKey] = this.$jsonpBackValue = "__jsonp_" + Date.parse(new Date()) + "__";
  1209.     window[this.$jsonpBackValue] = _scriptBack.bind(this);
  1210.     var preStr = _.formatUrl(o);
  1211.     //Loading....
  1212.     try{this.onLoading();}catch(e){};
  1213.     
  1214.     //超时自动 中止
  1215.     if(this.$ovTime && this.$ovTime>0)this.$_blurer = setTimeout(_scriptBlur.bind(this),this.$ovTime);
  1216.     
  1217.     this.$data = null;
  1218.     this.$HO = _createScript.call(this,_getURl(this.$url,preStr));
  1219.     
  1220.     return this;
  1221.   },
  1222.   /**
  1223.    * 创建动态的Stript标签
  1224.    * @param {String} url
  1225.    */
  1226.   _createScript = function(url){
  1227.     var v = $.Element.create("script",{type:"text/javascript"});
  1228.     v.onreadystatechange = v.onload = _scriptChange.bind(this);
  1229.     v.src = url;
  1230.     document.getElementsByTagName("head")[0].appendChild(v);
  1231.     return v;
  1232.   },
  1233.   /**
  1234.    * 回调 设置Ajax对象的值
  1235.    * @param {Object} o
  1236.    */
  1237.   _scriptBack = function(o){
  1238.     this.$data = o;
  1239.   },
  1240.   /**
  1241.    * 销毁 script 标签
  1242.    */
  1243.   _scriptHODestroy = function(){
  1244.     this.$HO.onreadystatechange = this.$HO.onload = null;
  1245.     this.$HO.removeNode(true);
  1246.     this.$HO = null;
  1247.     window[this.$jsonpBackValue] = null;
  1248.   },
  1249.   /**
  1250.    * script 请求的请求状态
  1251.    */
  1252.   _scriptChange = function(){
  1253.     if(!this.$HO.readyState || this.$HO.readyState == 'loaded' || this.$HO.readyState == 'complete'){
  1254.       if(this.$data)this.$HO.status = 200;
  1255.       _ajaxReady.call(this);
  1256.     }
  1257.   },
  1258.   /**
  1259.    * Ajax 返回类型验证
  1260.    */
  1261.   _ajaxBack = {
  1262.     auto:function(){
  1263.       //xml
  1264.       var d = _.str2xml(this.$HO.responseText);
  1265.       if(d){
  1266.         _ajaxBack.xml.call(this,d);
  1267.         return ;
  1268.       };
  1269.       //json
  1270.       d = _.str2json("(" + this.$HO.responseText + ")");
  1271.       if(d){
  1272.         _ajaxBack.json.call(this,d);
  1273.         return ;
  1274.       };
  1275.       //script
  1276.       d = _.formatScript(this.$HO.responseText);
  1277.       if(d){
  1278.         _ajaxBack.script.call(this,d);
  1279.         return ;
  1280.       };
  1281.       //text
  1282.       _ajaxBack.text.call(this);
  1283.     },
  1284.     text:function(){
  1285.       this.$data =  this.$HO.responseText;
  1286.       try{this.onSucc("text");}catch(e){};
  1287.     },
  1288.     xml:function(xml){
  1289.       this.$data = xml || _.str2xml(this.$HO.responseText);
  1290.       var ret = this.chkXML();
  1291.       try{ret==true?this.onSucc("xml"):this.onFail(ret)}catch(e){};
  1292.     },
  1293.     json:function(json){
  1294.       if(json || this.$HO.responseText)this.$data = json || _.str2json("(" + this.$HO.responseText + ")");
  1295.       var ret = this.chkJson();
  1296.       try{ret==true?this.onSucc("json"):this.onFail(ret)}catch(e){};
  1297.     },
  1298.     script:function(f){
  1299.       this.$data = null;
  1300.       try{f || _.formatScript(this.$HO.responseText)?this.onSucc("script"):this.onFail(this.$unusual)}catch(e){};
  1301.     }
  1302.   };
  1303.   
  1304.   /**
  1305.    * Ajax对类 支持GET jsonp数据
  1306.    */
  1307.   $.Ajax = _C.extend({
  1308.     /**
  1309.      * 初始化 url type param overtime
  1310.      * @param {String} u  url
  1311.      * @param {String} m  type
  1312.      * @param {Object} p  param
  1313.      * @param {Number} t  overtime 毫秒
  1314.      */
  1315.     onInit:function(u,m,p,t){
  1316.       if(arguments.length==0)return ;
  1317.       this.$url = u;                        //请求URL
  1318.       this.$pre = p || {};                    //默认参数
  1319.       var t = m?m.split(/:/g):["GET","auto"];
  1320.       this.$mType = t[0].toUpperCase();              //请求方式 POST GET PUT DELETE JSONP
  1321.       if(this.$mType=="JSONP"){                  //跨域请求数据 请用这个
  1322.         this.$jsonpBackKey = t[1] || "jsback";
  1323.         t[1] = "json";
  1324.       }
  1325.       //临时更改 把 PUT DELETE 等方式转为POST
  1326.       if(this.$mType!="POST" && this.$mType!="GET" && this.$mType!="JSONP"){
  1327.         this.$pre._method = this.$mType;
  1328.         this.$mType = "POST";
  1329.       }
  1330.       this.$bType = _ajaxBack[t[1]]?t[1] : "auto";        //服务端返回值
  1331.       this.$ovTime = t || 0;                    //请求超时
  1332.       this.$data = null;
  1333.       return this;
  1334.     },
  1335.     /**
  1336.      * 设置默认的参数
  1337.      */
  1338.     setPre:function(){
  1339.       Function.prototype.extra.apply(this.$pre,arguments);
  1340.       return this;
  1341.     },
  1342.     /**
  1343.      * 设置http的请求头
  1344.      */
  1345.     setHead:function(){
  1346.       if(!this.$head)this.$head = {};
  1347.       Function.prototype.extra.apply(this.$head,arguments);
  1348.       return this;
  1349.     },
  1350.     /**
  1351.      * 同步请求
  1352.      * @param {Object} pre
  1353.      * @param {Boolean} f 是否需要销毁当前正在的请求,继续新的请求
  1354.      */
  1355.     syncAsk:function(p,f){
  1356.       if(this.$mType=="JSONP")return ;  //jsonp 只支持异步传输
  1357.       return _ajaxSend.call(this,false,p,f);
  1358.     },
  1359.     /**
  1360.      * 异步请求
  1361.      * @param {Object} p
  1362.      * @param {Boolean} f 是否需要销毁当前正在的请求,继续新的请求
  1363.      */
  1364.     asyncAsk:function(p,f){
  1365.       if(this.$mType=="JSONP")return _scriptSend.call(this,true,p,f);
  1366.       return _ajaxSend.call(this,true,p,f);
  1367.     },
  1368.     $unusual: "返回数据有问题,请稍后再试试..."
  1369.   });
  1370.   
  1371.   /**
  1372.    * 常用方法 集合
  1373.    */
  1374.   var _F = $.Fn = {
  1375.     /**
  1376.      * 获取 下划线或者下划线中的方法
  1377.      * @param {Object} k
  1378.      */
  1379.     get:function(k){
  1380.       return k?_[k]:_;
  1381.     },
  1382.     /**
  1383.      * 动画效果停止
  1384.      * @param {Number} show或者hide时返回的句柄
  1385.      */
  1386.     fxcStop:function(n){
  1387.       if(_clock.Itvs[n])
  1388.         _clock.Itvs[n](true);
  1389.     }
  1390.   };
  1391.   
  1392.   /**
  1393.    * Joo核心方法
  1394.    * @param {Object} p
  1395.    */
  1396.     return function(p){
  1397.         if (p === undefined)
  1398.             return this.call($, _);
  1399.         if (p < 0) {
  1400.             _.Ex.ready.call(document, this);
  1401.             return p == -1 ? $ : _;
  1402.         };
  1403.         return setTimeout(this, p);
  1404.     };
  1405. }();
视频教程列表
文章教程搜索
 
Javascript推荐教程
Javascript热门教程
看全部视频教程
购买方式/价格
购买视频教程: 咨询客服
tel:15972130058