📄 jquery.js
字号:
handle: function(event) { if ( typeof jQuery == "undefined" ) return; event = event || jQuery.event.fix( window.event ); // If no correct event was found, fail if ( !event ) return; var returnValue = true; var c = this.events[event.type]; var args = [].slice.call( arguments, 1 ); args.unshift( event ); for ( var j in c ) { if ( c[j].apply( this, args ) === false ) { event.preventDefault(); event.stopPropagation(); returnValue = false; } } return returnValue; }, fix: function(event) { if ( event ) { event.preventDefault = function() { this.returnValue = false; }; event.stopPropagation = function() { this.cancelBubble = true; }; } return event; } }});new function() { var b = navigator.userAgent.toLowerCase(); // Figure out what browser is being used jQuery.browser = { 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.macros = { to: { appendTo: "append", prependTo: "prepend", insertBefore: "before", insertAfter: "after" }, css: "width,height,top,left,position,float,overflow,color,background".split(","), filter: [ "eq", "lt", "gt", "contains" ], attr: { val: "value", html: "innerHTML", id: null, title: null, name: null, href: null, src: null, rel: null }, axis: { parent: "a.parentNode", ancestors: jQuery.parents, parents: jQuery.parents, next: "jQuery.sibling(a).next", prev: "jQuery.sibling(a).prev", siblings: "jQuery.sibling(a, null, true)", children: "jQuery.sibling(a.firstChild)" }, each: { removeAttr: function( key ) { this.removeAttribute( key ); }, show: function(){ this.style.display = this.oldblock ? this.oldblock : ""; if ( jQuery.css(this,"display") == "none" ) this.style.display = "block"; }, hide: function(){ this.oldblock = this.oldblock || jQuery.css(this,"display"); if ( this.oldblock == "none" ) this.oldblock = "block"; this.style.display = "none"; }, toggle: function(){ jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ].apply( jQuery(this), arguments ); }, 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 ) this.parentNode.removeChild( this ); }, empty: function(){ while ( this.firstChild ) this.removeChild( this.firstChild ); }, bind: function( type, fn ) { if ( fn.constructor == String ) fn = new Function("e", ( !fn.indexOf(".") ? "jQuery(this)" : "return " ) + fn); jQuery.event.add( this, type, fn ); }, unbind: function( type, fn ) { jQuery.event.remove( this, type, fn ); }, trigger: function( type, data ) { jQuery.event.trigger( type, data, this ); } }};jQuery.init();jQuery.fn.extend({ // We're overriding the old toggle function, so // remember it for later _toggle: jQuery.fn.toggle, toggle: function(a,b) { // If two functions are passed in, we're // toggling on a click return a && b && a.constructor == Function && b.constructor == Function ? this.click(function(e){ // Figure out which function to execute this.last = this.last == a ? b : a; // Make sure that clicks stop e.preventDefault(); // and execute the function return this.last.apply( this, [e] ) || false; }) : // Otherwise, execute the old toggle function this._toggle.apply( this, arguments ); }, hover: function(f,g) { // A private function for haandling mouse 'hovering' function handleHover(e) { // Check if mouse(over|out) are still within the same parent element var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || 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 ); // Otherwise, remember the function for later else { // Add the function to the wait list jQuery.readyList.push( f ); } 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 for ( var i = 0; i < jQuery.readyList.length; i++ ) jQuery.readyList[i].apply( document ); // Reset the list of functions jQuery.readyList = null; } // Remove event lisenter to avoid memory leak if ( jQuery.browser.mozilla || jQuery.browser.opera ) document.removeEventListener( "DOMContentLoaded", jQuery.ready, false ); } }});new function(){ var e = ("blur,focus,load,resize,scroll,unload,click,dblclick," + "mousedown,mouseup,mousemove,mouseover,mouseout,change,reset,select," + "submit,keydown,keypress,keyup,error").split(","); // Go through all the event names, but make sure that // it is enclosed properly for ( var i = 0; i < e.length; i++ ) new function(){ var o = e[i]; // Handle event binding jQuery.fn[o] = function(f){ return f ? this.bind(o, f) : this.trigger(o); }; // Handle event unbinding jQuery.fn["un"+o] = function(f){ return this.unbind(o, f); }; // Finally, handle events that only fire once jQuery.fn["one"+o] = function(f){ // Attach the event listener return this.each(function(){ var count = 0; // Add the event jQuery.event.add( this, o, function(e){ // If this function has already been executed, stop if ( count++ ) return; // And execute the bound function return f.apply(this, [e]); }); }); }; }; // 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.onreadystatechange = function() { if ( this.readyState != "complete" ) return; this.parentNode.removeChild( this ); 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).unload(function() { var event = jQuery.event, global = event.global; for (var type in global) { var els = global[type], i = els.length; if (i>0) do if (type != 'unload') event.remove(els[i-1], type); while (--i); }});jQuery.fn.extend({ // overwrite the old show method _show: jQuery.fn.show, show: function(speed,callback){ return speed ? this.animate({ height: "show", width: "show", opacity: "show" }, speed, callback) : this._show(); }, // Overwrite the old hide method _hide: jQuery.fn.hide, hide: function(speed,callback){ return speed ? this.animate({ height: "hide", width: "hide", opacity: "hide" }, speed, callback) : this._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.each(function(){ var state = jQuery(this).is(":hidden") ? "show" : "hide"; jQuery(this).animate({height: state}, 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,callback) { return this.queue(function(){ this.curAnim = prop; for ( var p in prop ) { var e = new jQuery.fx( this, jQuery.speed(speed,callback), p ); if ( prop[p].constructor == Number ) e.custom( e.cur(), prop[p] ); else e[ prop[p] ]( 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({ setAuto: function(e,p) { if ( e.notAuto ) return; if ( p == "height" && e.scrollHeight != parseInt(jQuery.curCSS(e,p)) ) return; if ( p == "width" && e.scrollWidth != parseInt(jQuery.curCSS(e,p)) ) return; // Remember the original height var a = e.style[p]; // Figure out the size of the height right now var o = jQuery.curCSS(e,p,1); if ( p == "height" && e.scrollHeight != o || p == "width" && e.scrollWidth != o ) return; // Set the height to auto e.style[p] = e.currentStyle ? "" : "auto"; // See what the size of "auto" is var n = jQuery.curCSS(e,p,1); // Revert back to the original size if ( o != n && n != "auto" ) { e.style[p] = a; e.notAuto = true; } }, speed: function(s,o) { o = o || {}; if ( o.constructor == Function ) o = { complete: o }; var ss = { slow: 600, fast: 200 }; o.duration = (s && s.constructor == Number ? s : ss[s]) || 400; // Queueing o.oldComplete = o.complete; o.complete = function(){ jQuery.dequeue(this, "fx"); if ( o.oldComplete && o.oldComplete.constructor == Function ) o.oldComplete.apply( this ); }; return o; }, queue: {}, dequeue: function(elem,type){ type = type || "fx"; if ( elem.queue && elem.queue[type] ) { // Remove self elem.queue[type].shift();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -