⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jquery.js

📁 Piwik#Opensourcewebanalytics一款可以和GOOGLE媲美的开源统计系统,运用AJAX.功能强大.无色提示:按照需要PHP5.1以上和MySQL数据库支持。
💻 JS
📖 第 1 页 / 共 5 页
字号:
		var r = [];		doc = doc || document;		jQuery.each( a, function(i,arg){			if ( !arg ) return;			if ( arg.constructor == Number )				arg = arg.toString();						// Convert html string into DOM nodes			if ( typeof arg == "string" ) {				// Trim whitespace, otherwise indexOf won't work as expected				var s = jQuery.trim(arg).toLowerCase(), div = doc.createElement("div"), tb = [];				var wrap =					// option or optgroup					!s.indexOf("<opt") &&					[1, "<select>", "</select>"] ||										!s.indexOf("<leg") &&					[1, "<fieldset>", "</fieldset>"] ||										(!s.indexOf("<thead") || !s.indexOf("<tbody") || !s.indexOf("<tfoot") || !s.indexOf("<colg")) &&					[1, "<table>", "</table>"] ||										!s.indexOf("<tr") &&					[2, "<table><tbody>", "</tbody></table>"] ||									 	// <thead> matched above					(!s.indexOf("<td") || !s.indexOf("<th")) &&					[3, "<table><tbody><tr>", "</tr></tbody></table>"] ||										!s.indexOf("<col") &&					[2, "<table><colgroup>", "</colgroup></table>"] ||										[0,"",""];				// Go to html and back, then peel off extra wrappers				div.innerHTML = wrap[1] + arg + wrap[2];								// Move to the right depth				while ( wrap[0]-- )					div = div.firstChild;								// Remove IE's autoinserted <tbody> from table fragments				if ( jQuery.browser.msie ) {										// String was a <table>, *may* have spurious <tbody>					if ( !s.indexOf("<table") && s.indexOf("<tbody") < 0 ) 						tb = div.firstChild && div.firstChild.childNodes;											// String was a bare <thead> or <tfoot>					else if ( wrap[1] == "<table>" && s.indexOf("<tbody") < 0 )						tb = div.childNodes;					for ( var n = tb.length-1; n >= 0 ; --n )						if ( jQuery.nodeName(tb[n], "tbody") && !tb[n].childNodes.length )							tb[n].parentNode.removeChild(tb[n]);									}								arg = jQuery.makeArray( div.childNodes );			}			if ( 0 === arg.length && (!jQuery.nodeName(arg, "form") && !jQuery.nodeName(arg, "select")) )				return;			if ( arg[0] == undefined || jQuery.nodeName(arg, "form") || arg.options )				r.push( arg );			else				r = jQuery.merge( r, arg );		});		return r;	},		attr: function(elem, name, value){		var fix = jQuery.isXMLDoc(elem) ? {} : jQuery.props;				// Certain attributes only work when accessed via the old DOM 0 way		if ( fix[name] ) {			if ( value != undefined ) elem[fix[name]] = value;			return elem[fix[name]];		} else if ( value == undefined && jQuery.browser.msie && jQuery.nodeName(elem, "form") && (name == "action" || name == "method") )			return elem.getAttributeNode(name).nodeValue;		// IE elem.getAttribute passes even for style		else if ( elem.tagName ) {						if ( value != undefined ) elem.setAttribute( name, value );			if ( jQuery.browser.msie && /href|src/.test(name) && !jQuery.isXMLDoc(elem) ) 				return elem.getAttribute( name, 2 );			return elem.getAttribute( name );		// elem is actually elem.style ... set the style		} else {			// IE actually uses filters for opacity			if ( name == "opacity" && jQuery.browser.msie ) {				if ( value != undefined ) {					// IE has trouble with opacity if it does not have layout					// Force it by setting the zoom level					elem.zoom = 1; 						// Set the alpha filter to set the opacity					elem.filter = (elem.filter || "").replace(/alpha\([^)]*\)/,"") +						(parseFloat(value).toString() == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");				}					return elem.filter ? 					(parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100).toString() : "";			}			name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});			if ( value != undefined ) elem[name] = value;			return elem[name];		}	},	trim: function(t){		return t.replace(/^\s+|\s+$/g, "");	},	makeArray: function( a ) {		var r = [];		// Need to use typeof to fight Safari childNodes crashes		if ( typeof a != "array" )			for ( var i = 0, al = a.length; i < al; i++ )				r.push( a[i] );		else			r = a.slice( 0 );		return r;	},	inArray: function( b, a ) {		for ( var i = 0, al = a.length; i < al; i++ )			if ( a[i] == b )				return i;		return -1;	},	merge: function(first, second) {		// We have to loop this way because IE & Opera overwrite the length		// expando of getElementsByTagName		for ( var i = 0; second[i]; i++ )			first.push(second[i]);		return first;	},	unique: function(first) {		var r = [], num = jQuery.mergeNum++;		for ( var i = 0, fl = first.length; i < fl; i++ )			if ( num != first[i].mergeNum ) {				first[i].mergeNum = num;				r.push(first[i]);			}		return r;	},	mergeNum: 0,	grep: function(elems, fn, inv) {		// If a string is passed in for the function, make a function		// for it (a handy shortcut)		if ( typeof fn == "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, el = elems.length; i < el; 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 ( typeof fn == "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, el = elems.length; i < el; i++ ) {			var val = fn(elems[i],i);			if ( val !== null && val != undefined ) {				if ( val.constructor != Array ) val = [val];				result = result.concat( val );			}		}		return result;	}}); /* * Whether the W3C compliant box model is being used. * * @property * @name $.boxModel * @type Boolean * @cat JavaScript */new function() {	var b = navigator.userAgent.toLowerCase();	// Figure out what browser is being used	jQuery.browser = {		version: (b.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1],		safari: /webkit/.test(b),		opera: /opera/.test(b),		msie: /msie/.test(b) && !/opera/.test(b),		mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b)	};	// Check to see if the W3C box model is being used	jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat";	jQuery.styleFloat = jQuery.browser.msie ? "styleFloat" : "cssFloat",	jQuery.props = {		"for": "htmlFor",		"class": "className",		"float": jQuery.styleFloat,		cssFloat: jQuery.styleFloat,		styleFloat: jQuery.styleFloat,		innerHTML: "innerHTML",		className: "className",		value: "value",		disabled: "disabled",		checked: "checked",		readonly: "readOnly",		selected: "selected",		maxlength: "maxLength"	};};jQuery.each({	parent: "a.parentNode",	parents: "jQuery.parents(a)",	next: "jQuery.nth(a,2,'nextSibling')",	prev: "jQuery.nth(a,2,'previousSibling')",	siblings: "jQuery.sibling(a.parentNode.firstChild,a)",	children: "jQuery.sibling(a.firstChild)"}, function(i,n){	jQuery.fn[ i ] = function(a) {		var ret = jQuery.map(this,n);		if ( a && typeof a == "string" )			ret = jQuery.multiFilter(a,ret);		return this.pushStack( ret );	};});jQuery.each({	appendTo: "append",	prependTo: "prepend",	insertBefore: "before",	insertAfter: "after"}, function(i,n){	jQuery.fn[ i ] = function(){		var a = arguments;		return this.each(function(){			for ( var j = 0, al = a.length; j < al; j++ )				jQuery(a[j])[n]( this );		});	};});jQuery.each( {	removeAttr: function( key ) {		jQuery.attr( this, key, "" );		this.removeAttribute( key );	},	addClass: function(c){		jQuery.className.add(this,c);	},	removeClass: function(c){		jQuery.className.remove(this,c);	},	toggleClass: function( c ){		jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this, c);	},	remove: function(a){		if ( !a || jQuery.filter( a, [this] ).r.length )			this.parentNode.removeChild( this );	},	empty: function() {		while ( this.firstChild )			this.removeChild( this.firstChild );	}}, function(i,n){	jQuery.fn[ i ] = function() {		return this.each( n, arguments );	};});jQuery.each( [ "eq", "lt", "gt", "contains" ], function(i,n){	jQuery.fn[ n ] = function(num,fn) {		return this.filter( ":" + n + "(" + num + ")", fn );	};});jQuery.each( [ "height", "width" ], function(i,n){	jQuery.fn[ n ] = function(h) {		return h == undefined ?			( this.length ? jQuery.css( this[0], n ) : null ) :			this.css( n, h.constructor == String ? h : h + "px" );	};});jQuery.extend({	expr: {		"": "m[2]=='*'||jQuery.nodeName(a,m[2])",		"#": "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			"first-child": "a.parentNode.getElementsByTagName('*')[0]==a",			"last-child": "jQuery.nth(a.parentNode.lastChild,1,'previousSibling')==a",			"only-child": "!jQuery.nth(a.parentNode.lastChild,2,'previousSibling')",			// Parent Checks			parent: "a.firstChild",			empty: "!a.firstChild",			// Text Check			contains: "(a.textContent||a.innerText||'').indexOf(m[3])>=0",			// Visibility			visible: '"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden"',			hidden: '"hidden"==a.type||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: "'text'==a.type",			radio: "'radio'==a.type",			checkbox: "'checkbox'==a.type",			file: "'file'==a.type",			password: "'password'==a.type",			submit: "'submit'==a.type",			image: "'image'==a.type",			reset: "'reset'==a.type",			button: '"button"==a.type||jQuery.nodeName(a,"button")',			input: "/input|select|textarea|button/i.test(a.nodeName)"		},		"[": "jQuery.find(m[2],a).length"	},		// The regular expressions that power the parsing engine	parse: [		// Match: [@value='test'], [@foo]		/^\[ *(@)([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,		// Match: [div], [div p]		/^(\[)\s*(.*?(\[.*?\])?[^[]*?)\s*\]/,		// Match: :contains('foo')		/^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,		// Match: :even, :last-chlid, #id, .class		new RegExp("^([:.#]*)(" + 			( jQuery.chars = jQuery.browser.safari && jQuery.browser.version < "3.0.0" ? "\\w" : "(?:[\\w\u0128-\uFFFF*_-]|\\\\.)" ) + "+)")	],	multiFilter: function( expr, elems, not ) {		var old, cur = [];		while ( expr && expr != old ) {			old = expr;			var f = jQuery.filter( expr, elems, not );			expr = f.t.replace(/^\s*,\s*/, "" );			cur = not ? elems = f.r : jQuery.merge( cur, f.r );		}		return cur;	},	find: function( t, context ) {		// Quickly handle non-string expressions		if ( typeof t != "string" )			return [ t ];		// Make sure that the context is a DOM Element		if ( context && !context.nodeType )			context = null;		// Set the correct context (if none is provided)		context = context || document;		// Handle the common XPath // expression		if ( !t.indexOf("//") ) {			context = context.documentElement;			t = t.substr(2,t.length);		// And the / root expression		} else if ( !t.indexOf("/") && !context.ownerDocument ) {			context = context.documentElement;			t = t.substr(1,t.length);			if ( t.indexOf("/") >= 1 )				t = t.substr(t.indexOf("/"),t.length);		}		// Initialize the search		var ret = [context], done = [], last;		// Continue while a selector expression exists, and while		// we're no longer looping upon ourselves		while ( t && last != t ) {			var r = [];			last = t;			t = jQuery.trim(t).replace( /^\/\//, "" );			var foundToken = false;			// An attempt at speeding up child selectors that			// point to a specific element tag			var re = new RegExp("^[/>]\\s*(" + jQuery.chars + "+)");			var m = re.exec(t);			if ( m ) {				var nodeName = m[1].toUpperCase();				// Perform our own iteration and filter				for ( var i = 0; ret[i]; i++ )					for ( var c = ret[i].firstChild; c; c = c.nextSibling )						if ( c.nodeType == 1 && (nodeName == "*" || c.nodeName == nodeName.toUpperCase()) )							r.push( c );				ret = r;				t = t.replace( re, "" );				if ( t.indexOf(" ") == 0 ) continue;				foundToken = true;			} else {				re = /^((\/?\.\.)|([>\/+~]))\s*([a-z]*)/i;				if ( (m = re.exec(t)) != null ) {					r = [];					var nodeName = m[4], mergeNum = jQuery.mergeNum++;					m = m[1];					for ( var j = 0, rl = ret.length; j < rl; j++ )						if ( m.indexOf("..") < 0 ) {							var n = m == "~" || m == "+" ? ret[j].nextSibling : ret[j].firstChild;							for ( ; n; n = n.nextSibling )								if ( n.nodeType == 1 ) {									if ( m == "~" && n.mergeNum == mergeNum ) break;																		if (!nodeName || n.nodeName == nodeName.toUpperCase() ) {										if ( m == "~" ) n.mergeNum = mergeNum;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -