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

📄 jquery.js

📁 Piwik#Opensourcewebanalytics一款可以和GOOGLE媲美的开源统计系统,运用AJAX.功能强大.无色提示:按照需要PHP5.1以上和MySQL数据库支持。
💻 JS
📖 第 1 页 / 共 5 页
字号:
			// Remember where we started, so that we can go back to it later			elem.orig[prop] = jQuery.attr( elem.style, prop );			options.show = true;			// Begin the animation			z.custom(0, this.cur());			// Make sure that we start at a small width/height to avoid any			// flash of content			if ( prop != "opacity" )				y[prop] = "1px";						// Start by showing the element			jQuery(elem).show();		};		// Simple 'hide' function		z.hide = function(){			if ( !elem.orig ) elem.orig = {};			// Remember where we started, so that we can go back to it later			elem.orig[prop] = jQuery.attr( elem.style, prop );			options.hide = true;			// Begin the animation			z.custom(this.cur(), 0);		};		// Each step of an animation		z.step = function(firstNum, lastNum){			var t = (new Date()).getTime();			if (t > options.duration + z.startTime) {				z.now = lastNum;				z.a();				if (elem.curAnim) elem.curAnim[ prop ] = true;				var done = true;				for ( var i in elem.curAnim )					if ( elem.curAnim[i] !== true )						done = false;				if ( done ) {					if ( oldDisplay != null ) {						// Reset the overflow						y.overflow = oldOverflow;											// Reset the display						y.display = oldDisplay;						if ( jQuery.css(elem, "display") == "none" )							y.display = "block";					}					// Hide the element if the "hide" operation was done					if ( options.hide )						y.display = "none";					// Reset the properties, if the item has been hidden or shown					if ( options.hide || options.show )						for ( var p in elem.curAnim )							jQuery.attr(y, p, elem.orig[p]);				}				// If a callback was provided, execute it				if ( done && jQuery.isFunction( options.complete ) )					// Execute the complete function					options.complete.apply( elem );				return false;			} else {				var n = t - this.startTime;				// Figure out where in the animation we are and set the number				var p = n / options.duration;								// Perform the easing function, defaults to swing				z.now = jQuery.easing[options.easing](p, n, firstNum, (lastNum-firstNum), options.duration);				// Perform the next step of the animation				z.a();			}			return true;		};		}});jQuery.fn.extend({	loadIfModified: function( url, params, callback ) {		this.load( url, params, callback, 1 );	},	load: function( url, params, callback, ifModified ) {		if ( jQuery.isFunction( url ) )			return this.bind("load", url);		callback = callback || function(){};		// Default to a GET request		var type = "GET";		// If the second parameter was provided		if ( params )			// If it's a function			if ( jQuery.isFunction( params ) ) {				// We assume that it's the callback				callback = params;				params = null;			// Otherwise, build a param string			} else {				params = jQuery.param( params );				type = "POST";			}		var self = this;		// Request the remote document		jQuery.ajax({			url: url,			type: type,			data: params,			ifModified: ifModified,			complete: function(res, status){				if ( status == "success" || !ifModified && status == "notmodified" )					// Inject the HTML into all the matched elements					self.attr("innerHTML", res.responseText)					  // Execute all the scripts inside of the newly-injected HTML					  .evalScripts()					  // Execute callback					  .each( callback, [res.responseText, status, res] );				else					callback.apply( self, [res.responseText, status, res] );			}		});		return this;	},	serialize: function() {		return jQuery.param( this );	},	evalScripts: function() {		return this.find("script").each(function(){			if ( this.src )				jQuery.getScript( this.src );			else				jQuery.globalEval( this.text || this.textContent || this.innerHTML || "" );		}).end();	}});// Attach a bunch of functions for handling common AJAX eventsjQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i,o){	jQuery.fn[o] = function(f){		return this.bind(o, f);	};});jQuery.extend({	get: function( url, data, callback, type, ifModified ) {		// shift arguments if data argument was ommited		if ( jQuery.isFunction( data ) ) {			callback = data;			data = null;		}				return jQuery.ajax({			type: "GET",			url: url,			data: data,			success: callback,			dataType: type,			ifModified: ifModified		});	},	getIfModified: function( url, data, callback, type ) {		return jQuery.get(url, data, callback, type, 1);	},	getScript: function( url, callback ) {		return jQuery.get(url, null, callback, "script");	},	getJSON: function( url, data, callback ) {		return jQuery.get(url, data, callback, "json");	},	post: function( url, data, callback, type ) {		if ( jQuery.isFunction( data ) ) {			callback = data;			data = {};		}		return jQuery.ajax({			type: "POST",			url: url,			data: data,			success: callback,			dataType: type		});	},	ajaxTimeout: function( timeout ) {		jQuery.ajaxSettings.timeout = timeout;	},	ajaxSetup: function( settings ) {		jQuery.extend( jQuery.ajaxSettings, settings );	},	ajaxSettings: {		global: true,		type: "GET",		timeout: 0,		contentType: "application/x-www-form-urlencoded",		processData: true,		async: true,		data: null	},		// Last-Modified header cache for next request	lastModified: {},	ajax: function( s ) {		// TODO introduce global settings, allowing the client to modify them for all requests, not only timeout		s = jQuery.extend({}, jQuery.ajaxSettings, s);		// if data available		if ( s.data ) {			// convert data if not already a string			if (s.processData && typeof s.data != "string")    			s.data = jQuery.param(s.data);			// append data to url for get requests			if( s.type.toLowerCase() == "get" ) {				// "?" + data or "&" + data (in case there are already params)				s.url += ((s.url.indexOf("?") > -1) ? "&" : "?") + s.data;				// IE likes to send both get and post data, prevent this				s.data = null;			}		}		// Watch for a new set of requests		if ( s.global && ! jQuery.active++ )			jQuery.event.trigger( "ajaxStart" );		var requestDone = false;		// Create the request object; Microsoft failed to properly		// implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available		var xml = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();		// Open the socket		xml.open(s.type, s.url, s.async);		// Set the correct header, if data is being sent		if ( s.data )			xml.setRequestHeader("Content-Type", s.contentType);		// Set the If-Modified-Since header, if ifModified mode.		if ( s.ifModified )			xml.setRequestHeader("If-Modified-Since",				jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" );		// Set header so the called script knows that it's an XMLHttpRequest		xml.setRequestHeader("X-Requested-With", "XMLHttpRequest");		// Allow custom headers/mimetypes		if( s.beforeSend )			s.beforeSend(xml);					if ( s.global )		    jQuery.event.trigger("ajaxSend", [xml, s]);		// Wait for a response to come back		var onreadystatechange = function(isTimeout){			// The transfer is complete and the data is available, or the request timed out			if ( xml && (xml.readyState == 4 || isTimeout == "timeout") ) {				requestDone = true;								// clear poll interval				if (ival) {					clearInterval(ival);					ival = null;				}								var status;				try {					status = jQuery.httpSuccess( xml ) && isTimeout != "timeout" ?						s.ifModified && jQuery.httpNotModified( xml, s.url ) ? "notmodified" : "success" : "error";					// Make sure that the request was successful or notmodified					if ( status != "error" ) {						// Cache Last-Modified header, if ifModified mode.						var modRes;						try {							modRes = xml.getResponseHeader("Last-Modified");						} catch(e) {} // swallow exception thrown by FF if header is not available							if ( s.ifModified && modRes )							jQuery.lastModified[s.url] = modRes;							// process the data (runs the xml through httpData regardless of callback)						var data = jQuery.httpData( xml, s.dataType );							// If a local callback was specified, fire it and pass it the data						if ( s.success )							s.success( data, status );							// Fire the global callback						if( s.global )							jQuery.event.trigger( "ajaxSuccess", [xml, s] );					} else						jQuery.handleError(s, xml, status);				} catch(e) {					status = "error";					jQuery.handleError(s, xml, status, e);				}				// The request was completed				if( s.global )					jQuery.event.trigger( "ajaxComplete", [xml, s] );				// Handle the global AJAX counter				if ( s.global && ! --jQuery.active )					jQuery.event.trigger( "ajaxStop" );				// Process result				if ( s.complete )					s.complete(xml, status);				// Stop memory leaks				if(s.async)					xml = null;			}		};				// don't attach the handler to the request, just poll it instead		var ival = setInterval(onreadystatechange, 13); 		// Timeout checker		if ( s.timeout > 0 )			setTimeout(function(){				// Check to see if the request is still happening				if ( xml ) {					// Cancel the request					xml.abort();					if( !requestDone )						onreadystatechange( "timeout" );				}			}, s.timeout);					// Send the data		try {			xml.send(s.data);		} catch(e) {			jQuery.handleError(s, xml, null, e);		}				// firefox 1.5 doesn't fire statechange for sync requests		if ( !s.async )			onreadystatechange();				// return XMLHttpRequest to allow aborting the request etc.		return xml;	},	handleError: function( s, xml, status, e ) {		// If a local callback was specified, fire it		if ( s.error ) s.error( xml, status, e );		// Fire the global callback		if ( s.global )			jQuery.event.trigger( "ajaxError", [xml, s, e] );	},	// Counter for holding the number of active queries	active: 0,	// Determines if an XMLHttpRequest was successful or not	httpSuccess: function( r ) {		try {			return !r.status && location.protocol == "file:" ||				( r.status >= 200 && r.status < 300 ) || r.status == 304 ||				jQuery.browser.safari && r.status == undefined;		} catch(e){}		return false;	},	// Determines if an XMLHttpRequest returns NotModified	httpNotModified: function( xml, url ) {		try {			var xmlRes = xml.getResponseHeader("Last-Modified");			// Firefox always returns 200. check Last-Modified date			return xml.status == 304 || xmlRes == jQuery.lastModified[url] ||				jQuery.browser.safari && xml.status == undefined;		} catch(e){}		return false;	},	/* Get the data out of an XMLHttpRequest.	 * Return parsed XML if content-type header is "xml" and type is "xml" or omitted,	 * otherwise return plain text.	 * (String) data - The type of data that you're expecting back,	 * (e.g. "xml", "html", "script")	 */	httpData: function( r, type ) {		var ct = r.getResponseHeader("content-type");		var data = !type && ct && ct.indexOf("xml") >= 0;		data = type == "xml" || data ? r.responseXML : r.responseText;		// If the type is "script", eval it in global context		if ( type == "script" )			jQuery.globalEval( data );		// Get the JavaScript object, if JSON is used.		if ( type == "json" )			data = eval("(" + data + ")");		// evaluate scripts within html		if ( type == "html" )			jQuery("<div>").html(data).evalScripts();		return data;	},	// Serialize an array of form elements or a set of	// key/values into a query string	param: function( a ) {		var s = [];		// If an array was passed in, assume that it is an array		// of form elements		if ( a.constructor == Array || a.jquery )			// Serialize the form elements			jQuery.each( a, function(){				s.push( encodeURIComponent(this.name) + "=" + encodeURIComponent( this.value ) );			});		// Otherwise, assume that it's an object of key/value pairs		else			// Serialize the key/values			for ( var j in a )				// If the value is an array then the key names need to be repeated				if ( a[j] && a[j].constructor == Array )					jQuery.each( a[j], function(){						s.push( encodeURIComponent(j) + "=" + encodeURIComponent( this ) );					});				else					s.push( encodeURIComponent(j) + "=" + encodeURIComponent( a[j] ) );		// Return the resulting serialization		return s.join("&");	},		// evalulates a script in global context	// not reliable for safari	globalEval: function( data ) {		if ( window.execScript )			window.execScript( data );		else if ( jQuery.browser.safari )			// safari doesn't provide a synchronous global eval			window.setTimeout( data, 0 );		else			eval.call( window, data );	}});}

⌨️ 快捷键说明

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