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

📄 jquery.js

📁 Piwik#Opensourcewebanalytics一款可以和GOOGLE媲美的开源统计系统,运用AJAX.功能强大.无色提示:按照需要PHP5.1以上和MySQL数据库支持。
💻 JS
📖 第 1 页 / 共 5 页
字号:
		// store a copy of the original event object 		// and clone to set read-only properties		var originalEvent = event;		event = jQuery.extend({}, originalEvent);				// add preventDefault and stopPropagation since 		// they will not work on the clone		event.preventDefault = function() {			// if preventDefault exists run it on the original event			if (originalEvent.preventDefault)				return originalEvent.preventDefault();			// otherwise set the returnValue property of the original event to false (IE)			originalEvent.returnValue = false;		};		event.stopPropagation = function() {			// if stopPropagation exists run it on the original event			if (originalEvent.stopPropagation)				return originalEvent.stopPropagation();			// otherwise set the cancelBubble property of the original event to true (IE)			originalEvent.cancelBubble = true;		};				// Fix target property, if necessary		if ( !event.target && event.srcElement )			event.target = event.srcElement;						// check if target is a textnode (safari)		if (jQuery.browser.safari && event.target.nodeType == 3)			event.target = originalEvent.target.parentNode;		// Add relatedTarget, if necessary		if ( !event.relatedTarget && event.fromElement )			event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement;		// Calculate pageX/Y if missing and clientX/Y available		if ( event.pageX == null && event.clientX != null ) {			var e = document.documentElement, b = document.body;			event.pageX = event.clientX + (e && e.scrollLeft || b.scrollLeft);			event.pageY = event.clientY + (e && e.scrollTop || b.scrollTop);		}					// Add which for key events		if ( !event.which && (event.charCode || event.keyCode) )			event.which = event.charCode || event.keyCode;				// Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)		if ( !event.metaKey && event.ctrlKey )			event.metaKey = event.ctrlKey;		// Add which for click: 1 == left; 2 == middle; 3 == right		// Note: button is not normalized, so don't use it		if ( !event.which && event.button )			event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));					return event;	}};jQuery.fn.extend({	bind: function( type, data, fn ) {		return type == "unload" ? this.one(type, data, fn) : this.each(function(){			jQuery.event.add( this, type, fn || data, fn && data );		});	},	one: function( type, data, fn ) {		return this.each(function(){			jQuery.event.add( this, type, function(event) {				jQuery(this).unbind(event);				return (fn || data).apply( this, arguments);			}, fn && data);		});	},	unbind: function( type, fn ) {		return this.each(function(){			jQuery.event.remove( this, type, fn );		});	},	trigger: function( type, data ) {		return this.each(function(){			jQuery.event.trigger( type, data, this );		});	},	toggle: function() {		// Save reference to arguments for access in closure		var a = arguments;		return this.click(function(e) {			// Figure out which function to execute			this.lastToggle = 0 == this.lastToggle ? 1 : 0;						// Make sure that clicks stop			e.preventDefault();						// and execute the function			return a[this.lastToggle].apply( this, [e] ) || false;		});	},	hover: function(f,g) {				// A private function for handling mouse 'hovering'		function handleHover(e) {			// Check if mouse(over|out) are still within the same parent element			var p = e.relatedTarget;				// Traverse up the tree			while ( p && p != this ) try { p = p.parentNode } catch(e) { p = this; };						// If we actually just moused on to a sub-element, ignore it			if ( p == this ) return false;						// Execute the right function			return (e.type == "mouseover" ? f : g).apply(this, [e]);		}				// Bind the function to the two event listeners		return this.mouseover(handleHover).mouseout(handleHover);	},	ready: function(f) {		// If the DOM is already ready		if ( jQuery.isReady )			// Execute the function immediately			f.apply( document, [jQuery] );					// Otherwise, remember the function for later		else			// Add the function to the wait list			jQuery.readyList.push( function() { return f.apply(this, [jQuery]) } );			return this;	}});jQuery.extend({	/*	 * All the code that makes DOM Ready work nicely.	 */	isReady: false,	readyList: [],		// Handle when the DOM is ready	ready: function() {		// Make sure that the DOM is not already loaded		if ( !jQuery.isReady ) {			// Remember that the DOM is ready			jQuery.isReady = true;						// If there are functions bound, to execute			if ( jQuery.readyList ) {				// Execute all of them				jQuery.each( jQuery.readyList, function(){					this.apply( document );				});								// Reset the list of functions				jQuery.readyList = null;			}			// Remove event listener to avoid memory leak			if ( jQuery.browser.mozilla || jQuery.browser.opera )				document.removeEventListener( "DOMContentLoaded", jQuery.ready, false );						// Remove script element used by IE hack			if( !window.frames.length ) // don't remove if frames are present (#1187)				jQuery(window).load(function(){ jQuery("#__ie_init").remove(); });		}	}});new function(){	jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +		"mousedown,mouseup,mousemove,mouseover,mouseout,change,select," + 		"submit,keydown,keypress,keyup,error").split(","), function(i,o){				// Handle event binding		jQuery.fn[o] = function(f){			return f ? this.bind(o, f) : this.trigger(o);		};				});		// If Mozilla is used	if ( jQuery.browser.mozilla || jQuery.browser.opera )		// Use the handy event callback		document.addEventListener( "DOMContentLoaded", jQuery.ready, false );		// If IE is used, use the excellent hack by Matthias Miller	// http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited	else if ( jQuery.browser.msie ) {			// Only works if you document.write() it		document.write("<scr" + "ipt id=__ie_init defer=true " + 			"src=//:><\/script>");			// Use the defer script hack		var script = document.getElementById("__ie_init");				// script does not exist if jQuery is loaded dynamically		if ( script ) 			script.onreadystatechange = function() {				if ( this.readyState != "complete" ) return;				jQuery.ready();			};			// Clear from memory		script = null;		// If Safari  is used	} else if ( jQuery.browser.safari )		// Continually check to see if the document.readyState is valid		jQuery.safariTimer = setInterval(function(){			// loaded and complete are both valid states			if ( document.readyState == "loaded" || 				document.readyState == "complete" ) {					// If either one are found, remove the timer				clearInterval( jQuery.safariTimer );				jQuery.safariTimer = null;					// and execute any waiting functions				jQuery.ready();			}		}, 10); 	// A fallback to window.onload, that will always work	jQuery.event.add( window, "load", jQuery.ready );	};// Clean up after IE to avoid memory leaksif (jQuery.browser.msie)	jQuery(window).one("unload", function() {		var global = jQuery.event.global;		for ( var type in global ) {			var els = global[type], i = els.length;			if ( i && type != 'unload' )				do					els[i-1] && jQuery.event.remove(els[i-1], type);				while (--i);		}	});jQuery.fn.extend({	show: function(speed,callback){		return speed ?			this.animate({				height: "show", width: "show", opacity: "show"			}, speed, callback) :						this.filter(":hidden").each(function(){				this.style.display = this.oldblock ? this.oldblock : "";				if ( jQuery.css(this,"display") == "none" )					this.style.display = "block";			}).end();	},	hide: function(speed,callback){		return speed ?			this.animate({				height: "hide", width: "hide", opacity: "hide"			}, speed, callback) :						this.filter(":visible").each(function(){				this.oldblock = this.oldblock || jQuery.css(this,"display");				if ( this.oldblock == "none" )					this.oldblock = "block";				this.style.display = "none";			}).end();	},	// Save the old toggle function	_toggle: jQuery.fn.toggle,	toggle: function( fn, fn2 ){		return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?			this._toggle( fn, fn2 ) :			fn ?				this.animate({					height: "toggle", width: "toggle", opacity: "toggle"				}, fn, fn2) :				this.each(function(){					jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();				});	},	slideDown: function(speed,callback){		return this.animate({height: "show"}, speed, callback);	},	slideUp: function(speed,callback){		return this.animate({height: "hide"}, speed, callback);	},	slideToggle: function(speed, callback){		return this.animate({height: "toggle"}, speed, callback);	},	fadeIn: function(speed, callback){		return this.animate({opacity: "show"}, speed, callback);	},	fadeOut: function(speed, callback){		return this.animate({opacity: "hide"}, speed, callback);	},	fadeTo: function(speed,to,callback){		return this.animate({opacity: to}, speed, callback);	},	animate: function( prop, speed, easing, callback ) {		return this.queue(function(){			var hidden = jQuery(this).is(":hidden"),				opt = jQuery.speed(speed, easing, callback),				self = this;						for ( var p in prop )				if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )					return jQuery.isFunction(opt.complete) && opt.complete.apply(this);			this.curAnim = jQuery.extend({}, prop);						jQuery.each( prop, function(name, val){				var e = new jQuery.fx( self, opt, name );				if ( val.constructor == Number )					e.custom( e.cur(), val );				else					e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );			});		});	},	queue: function(type,fn){		if ( !fn ) {			fn = type;			type = "fx";		}			return this.each(function(){			if ( !this.queue )				this.queue = {};				if ( !this.queue[type] )				this.queue[type] = [];				this.queue[type].push( fn );					if ( this.queue[type].length == 1 )				fn.apply(this);		});	}});jQuery.extend({		speed: function(speed, easing, fn) {		var opt = speed && speed.constructor == Object ? speed : {			complete: fn || !fn && easing || 				jQuery.isFunction( speed ) && speed,			duration: speed,			easing: fn && easing || easing && easing.constructor != Function && easing || (jQuery.easing.swing ? "swing" : "linear")		};		opt.duration = (opt.duration && opt.duration.constructor == Number ? 			opt.duration : 			{ slow: 600, fast: 200 }[opt.duration]) || 400;			// Queueing		opt.old = opt.complete;		opt.complete = function(){			jQuery.dequeue(this, "fx");			if ( jQuery.isFunction( opt.old ) )				opt.old.apply( this );		};			return opt;	},		easing: {		linear: function( p, n, firstNum, diff ) {			return firstNum + diff * p;		},		swing: function( p, n, firstNum, diff ) {			return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;		}	},		queue: {},		dequeue: function(elem,type){		type = type || "fx";			if ( elem.queue && elem.queue[type] ) {			// Remove self			elem.queue[type].shift();				// Get next function			var f = elem.queue[type][0];					if ( f ) f.apply( elem );		}	},	timers: [],	/*	 * I originally wrote fx() as a clone of moo.fx and in the process	 * of making it small in size the code became illegible to sane	 * people. You've been warned.	 */		fx: function( elem, options, prop ){		var z = this;		// The styles		var y = elem.style;				if ( prop == "height" || prop == "width" ) {			// Store display property			var oldDisplay = jQuery.css(elem, "display");			// Make sure that nothing sneaks out			var oldOverflow = y.overflow;			y.overflow = "hidden";		}		// Simple function for setting a style value		z.a = function(){			if ( options.step )				options.step.apply( elem, [ z.now ] );			if ( prop == "opacity" )				jQuery.attr(y, "opacity", z.now); // Let attr handle opacity			else {				y[prop] = parseInt(z.now) + "px";				y.display = "block"; // Set display property to block for animation			}		};		// Figure out the maximum number to run to		z.max = function(){			return parseFloat( jQuery.css(elem,prop) );		};		// Get the current size		z.cur = function(){			var r = parseFloat( jQuery.curCSS(elem, prop) );			return r && r > -10000 ? r : z.max();		};		// Start an animation from one number to another		z.custom = function(from,to){			z.startTime = (new Date()).getTime();			z.now = from;			z.a();			jQuery.timers.push(function(){				return z.step(from, to);			});			if ( jQuery.timers.length == 1 ) {				var timer = setInterval(function(){					var timers = jQuery.timers;										for ( var i = 0; i < timers.length; i++ )						if ( !timers[i]() )							timers.splice(i--, 1);					if ( !timers.length )						clearInterval( timer );				}, 13);			}		};		// Simple 'show' function		z.show = function(){			if ( !elem.orig ) elem.orig = {};

⌨️ 快捷键说明

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