📄 jquery-1.0.2.js.svn-base
字号:
} for ( var j = 0; j < div.childNodes.length; j++ ) r.push( div.childNodes[j] ); } else if ( a[i].jquery || a[i].length && !a[i].nodeType ) for ( var k = 0; k < a[i].length; k++ ) r.push( a[i][k] ); else if ( a[i] !== null ) r.push( a[i].nodeType ? a[i] : document.createTextNode(a[i].toString()) ); } return r; }, expr: { "": "m[2]== '*'||a.nodeName.toUpperCase()==m[2].toUpperCase()", "#": "a.getAttribute('id')&&a.getAttribute('id')==m[2]", ":": { // Position Checks lt: "i<m[3]-0", gt: "i>m[3]-0", nth: "m[3]-0==i", eq: "m[3]-0==i", first: "i==0", last: "i==r.length-1", even: "i%2==0", odd: "i%2", // Child Checks "nth-child": "jQuery.sibling(a,m[3]).cur", "first-child": "jQuery.sibling(a,0).cur", "last-child": "jQuery.sibling(a,0).last", "only-child": "jQuery.sibling(a).length==1", // Parent Checks parent: "a.childNodes.length", empty: "!a.childNodes.length", // Text Check contains: "(a.innerText||a.innerHTML).indexOf(m[3])>=0", // Visibility visible: "a.type!='hidden'&&jQuery.css(a,'display')!='none'&&jQuery.css(a,'visibility')!='hidden'", hidden: "a.type=='hidden'||jQuery.css(a,'display')=='none'||jQuery.css(a,'visibility')=='hidden'", // Form attributes enabled: "!a.disabled", disabled: "a.disabled", checked: "a.checked", selected: "a.selected || jQuery.attr(a, 'selected')", // Form elements text: "a.type=='text'", radio: "a.type=='radio'", checkbox: "a.type=='checkbox'", file: "a.type=='file'", password: "a.type=='password'", submit: "a.type=='submit'", image: "a.type=='image'", reset: "a.type=='reset'", button: "a.type=='button'", input: "a.nodeName.toLowerCase().match(/input|select|textarea|button/)" }, ".": "jQuery.className.has(a,m[2])", "@": { "=": "z==m[4]", "!=": "z!=m[4]", "^=": "z && !z.indexOf(m[4])", "$=": "z && z.substr(z.length - m[4].length,m[4].length)==m[4]", "*=": "z && z.indexOf(m[4])>=0", "": "z" }, "[": "jQuery.find(m[2],a).length" }, token: [ "\\.\\.|/\\.\\.", "a.parentNode", ">|/", "jQuery.sibling(a.firstChild)", "\\+", "jQuery.sibling(a).next", "~", function(a){ var r = []; var s = jQuery.sibling(a); if ( s.n > 0 ) for ( var i = s.n; i < s.length; i++ ) r.push( s[i] ); return r; } ], find: function( t, context ) { // Make sure that the context is a DOM Element if ( context && context.nodeType == undefined ) context = null; // Set the correct context (if none is provided) context = context || jQuery.context || document; if ( t.constructor != String ) return [t]; if ( !t.indexOf("//") ) { context = context.documentElement; t = t.substr(2,t.length); } else if ( !t.indexOf("/") ) { context = context.documentElement; t = t.substr(1,t.length); // FIX Assume the root element is right :( if ( t.indexOf("/") >= 1 ) t = t.substr(t.indexOf("/"),t.length); } var ret = [context]; var done = []; var last = null; while ( t.length > 0 && last != t ) { var r = []; last = t; t = jQuery.trim(t).replace( /^\/\//i, "" ); var foundToken = false; for ( var i = 0; i < jQuery.token.length; i += 2 ) { if ( foundToken ) continue; var re = new RegExp("^(" + jQuery.token[i] + ")"); var m = re.exec(t); if ( m ) { r = ret = jQuery.map( ret, jQuery.token[i+1] ); t = jQuery.trim( t.replace( re, "" ) ); foundToken = true; } } if ( !foundToken ) { if ( !t.indexOf(",") || !t.indexOf("|") ) { if ( ret[0] == context ) ret.shift(); done = jQuery.merge( done, ret ); r = ret = [context]; t = " " + t.substr(1,t.length); } else { var re2 = /^([#.]?)([a-z0-9\\*_-]*)/i; var m = re2.exec(t); if ( m[1] == "#" ) { // Ummm, should make this work in all XML docs var oid = document.getElementById(m[2]); r = ret = oid ? [oid] : []; t = t.replace( re2, "" ); } else { if ( !m[2] || m[1] == "." ) m[2] = "*"; for ( var i = 0; i < ret.length; i++ ) r = jQuery.merge( r, m[2] == "*" ? jQuery.getAll(ret[i]) : ret[i].getElementsByTagName(m[2]) ); } } } if ( t ) { var val = jQuery.filter(t,r); ret = r = val.r; t = jQuery.trim(val.t); } } if ( ret && ret[0] == context ) ret.shift(); done = jQuery.merge( done, ret ); return done; }, getAll: function(o,r) { r = r || []; var s = o.childNodes; for ( var i = 0; i < s.length; i++ ) if ( s[i].nodeType == 1 ) { r.push( s[i] ); jQuery.getAll( s[i], r ); } return r; }, attr: function(elem, name, value){ var fix = { "for": "htmlFor", "class": "className", "float": "cssFloat", innerHTML: "innerHTML", className: "className", value: "value", disabled: "disabled", checked: "checked" }; // IE actually uses filters for opacity ... elem is actually elem.style if (name == "opacity" && jQuery.browser.msie && value != undefined) { // IE has trouble with opacity if it does not have layout // Would prefer to check element.hasLayout first but don't have access to the element here elem['zoom'] = 1; if (value == 1) // Remove filter to avoid more IE weirdness return elem["filter"] = elem["filter"].replace(/alpha\([^\)]*\)/gi,""); else return elem["filter"] = elem["filter"].replace(/alpha\([^\)]*\)/gi,"") + "alpha(opacity=" + value * 100 + ")"; } else if (name == "opacity" && jQuery.browser.msie) { return elem["filter"] ? parseFloat( elem["filter"].match(/alpha\(opacity=(.*)\)/)[1] )/100 : 1; } // Mozilla doesn't play well with opacity 1 if (name == "opacity" && jQuery.browser.mozilla && value == 1) value = 0.9999; if ( fix[name] ) { if ( value != undefined ) elem[fix[name]] = value; return elem[fix[name]]; } else if( value == undefined && jQuery.browser.msie && elem.nodeName && elem.nodeName.toUpperCase() == 'FORM' && (name == 'action' || name == 'method') ) { return elem.getAttributeNode(name).nodeValue; } else if ( elem.getAttribute != undefined ) { if ( value != undefined ) elem.setAttribute( name, value ); return elem.getAttribute( name, 2 ); } else { name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();}); if ( value != undefined ) elem[name] = value; return elem[name]; } }, // The regular expressions that power the parsing engine parse: [ // Match: [@value='test'], [@foo] "\\[ *(@)S *([!*$^=]*) *('?\"?)(.*?)\\4 *\\]", // Match: [div], [div p] "(\\[)\s*(.*?)\s*\\]", // Match: :contains('foo') "(:)S\\(\"?'?([^\\)]*?)\"?'?\\)", // Match: :even, :last-chlid "([:.#]*)S" ], filter: function(t,r,not) { // Figure out if we're doing regular, or inverse, filtering var g = not !== false ? jQuery.grep : function(a,f) {return jQuery.grep(a,f,true);}; while ( t && /^[a-z[({<*:.#]/i.test(t) ) { var p = jQuery.parse; for ( var i = 0; i < p.length; i++ ) { // Look for, and replace, string-like sequences // and finally build a regexp out of it var re = new RegExp( "^" + p[i].replace("S", "([a-z*_-][a-z0-9_-]*)"), "i" ); var m = re.exec( t ); if ( m ) { // Re-organize the first match if ( !i ) m = ["",m[1], m[3], m[2], m[5]]; // Remove what we just matched t = t.replace( re, "" ); break; } } // :not() is a special case that can be optimized by // keeping it out of the expression list if ( m[1] == ":" && m[2] == "not" ) r = jQuery.filter(m[3],r,false).r; // Otherwise, find the expression to execute else { var f = jQuery.expr[m[1]]; if ( f.constructor != String ) f = jQuery.expr[m[1]][m[2]]; // Build a custom macro to enclose it eval("f = function(a,i){" + ( m[1] == "@" ? "z=jQuery.attr(a,m[3]);" : "" ) + "return " + f + "}"); // Execute it against the current filter r = g( r, f ); } } // Return an array of filtered elements (r) // and the modified expression string (t) return { r: r, t: t }; }, trim: function(t){ return t.replace(/^\s+|\s+$/g, ""); }, parents: function( elem ){ var matched = []; var cur = elem.parentNode; while ( cur && cur != document ) { matched.push( cur ); cur = cur.parentNode; } return matched; }, sibling: function(elem, pos, not) { var elems = []; if(elem) { var siblings = elem.parentNode.childNodes; for ( var i = 0; i < siblings.length; i++ ) { if ( not === true && siblings[i] == elem ) continue; if ( siblings[i].nodeType == 1 ) elems.push( siblings[i] ); if ( siblings[i] == elem ) elems.n = elems.length - 1; } } return jQuery.extend( elems, { last: elems.n == elems.length - 1, cur: pos == "even" && elems.n % 2 == 0 || pos == "odd" && elems.n % 2 || elems[pos] == elem, prev: elems[elems.n - 1], next: elems[elems.n + 1] }); }, merge: function(first, second) { var result = []; // Move b over to the new array (this helps to avoid // StaticNodeList instances) for ( var k = 0; k < first.length; k++ ) result[k] = first[k]; // Now check for duplicates between a and b and only // add the unique items for ( var i = 0; i < second.length; i++ ) { var noCollision = true; // The collision-checking process for ( var j = 0; j < first.length; j++ ) if ( second[i] == first[j] ) noCollision = false; // If the item is unique, add it if ( noCollision ) result.push( second[i] ); } return result; }, grep: function(elems, fn, inv) { // If a string is passed in for the function, make a function // for it (a handy shortcut) if ( fn.constructor == String ) fn = new Function("a","i","return " + fn); var result = []; // Go through the array, only saving the items // that pass the validator function for ( var i = 0; i < elems.length; i++ ) if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) ) result.push( elems[i] ); return result; }, map: function(elems, fn) { // If a string is passed in for the function, make a function // for it (a handy shortcut) if ( fn.constructor == String ) fn = new Function("a","return " + fn); var result = []; // Go through the array, translating each of the items to their // new value (or values). for ( var i = 0; i < elems.length; i++ ) { var val = fn(elems[i],i); if ( val !== null && val != undefined ) { if ( val.constructor != Array ) val = [val]; result = jQuery.merge( result, val ); } } return result; }, /* * A number of helper functions used for managing events. * Many of the ideas behind this code orignated from Dean Edwards' addEvent library. */ event: { // Bind an event to an element // Original by Dean Edwards add: function(element, type, handler) { // For whatever reason, IE has trouble passing the window object // around, causing it to be cloned in the process if ( jQuery.browser.msie && element.setInterval != undefined ) element = window; // Make sure that the function being executed has a unique ID if ( !handler.guid ) handler.guid = this.guid++; // Init the element's event structure if (!element.events) element.events = {}; // Get the current list of functions bound to this event var handlers = element.events[type]; // If it hasn't been initialized yet if (!handlers) { // Init the event handler queue handlers = element.events[type] = {}; // Remember an existing handler, if it's already there if (element["on" + type]) handlers[0] = element["on" + type]; } // Add the function to the element's handler list handlers[handler.guid] = handler; // And bind the global event handler to the element element["on" + type] = this.handle; // Remember the function in a global list (for triggering) if (!this.global[type]) this.global[type] = []; this.global[type].push( element ); }, guid: 1, global: {}, // Detach an event or set of events from an element remove: function(element, type, handler) { if (element.events) if (type && element.events[type]) if ( handler ) delete element.events[type][handler.guid]; else for ( var i in element.events[type] ) delete element.events[type][i]; else for ( var j in element.events ) this.remove( element, j ); }, trigger: function(type,data,element) { // Touch up the incoming data data = data || []; // Handle a global trigger if ( !element ) { var g = this.global[type]; if ( g ) for ( var i = 0; i < g.length; i++ ) this.trigger( type, data, g[i] ); // Handle triggering a single element } else if ( element["on" + type] ) { // Pass along a fake event data.unshift( this.fix({ type: type, target: element }) ); // Trigger the event element["on" + type].apply( element, data ); } },
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -