Changeset 5357
- Timestamp:
- 04/29/08 23:34:50 (3 months ago)
- Location:
- trunk/jquery/src
- Files:
-
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/jquery/src/ajax.js
r5282 r5357 92 92 }); 93 93 94 var jsc = (new Date).getTime();94 var jsc = now(); 95 95 96 96 jQuery.extend({ … … 212 212 213 213 if ( s.cache === false && s.type.toLowerCase() == "get" ) { 214 var ts = (new Date()).getTime();214 var ts = now(); 215 215 // try replacing _= if it is there 216 216 var ret = s.url.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts + "$2"); … … 449 449 450 450 httpData: function( r, type ) { 451 var ct = r.getResponseHeader("content-type") ;452 var xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0;453 vardata = xml ? r.responseXML : r.responseText;451 var ct = r.getResponseHeader("content-type"), 452 xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0, 453 data = xml ? r.responseXML : r.responseText; 454 454 455 455 if ( xml && data.documentElement.tagName == "parsererror" ) -
trunk/jquery/src/core.js
r5349 r5357 11 11 12 12 // Map over jQuery in case of overwrite 13 if ( window.jQuery ) 14 var _jQuery = window.jQuery; 15 16 var jQuery = window.jQuery = function( selector, context ) { 13 var _jQuery = window.jQuery, 14 // Map over the $ in case of overwrite 15 _$ = window.$; 16 17 var jQuery = window.jQuery = window.$ = function( selector, context ) { 17 18 // The jQuery object is actually just the init constructor 'enhanced' 18 return new jQuery. prototype.init( selector, context );19 return new jQuery.fn.init( selector, context ); 19 20 }; 20 21 // Map over the $ in case of overwrite22 if ( window.$ )23 var _$ = window.$;24 25 // Map the jQuery namespace to the '$' one26 window.$ = jQuery;27 21 28 22 // A simple way to check for HTML strings or ID strings 29 23 // (both of which we optimize for) 30 var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/ ;24 var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/, 31 25 32 26 // Is it a simple selector 33 varisSimple = /^.[^:#\[\.]*$/;27 isSimple = /^.[^:#\[\.]*$/; 34 28 35 29 jQuery.fn = jQuery.prototype = { … … 360 354 361 355 is: function( selector ) { 362 return selector ? 363 jQuery.multiFilter( selector, this ).length > 0 : 364 false; 356 return !!selector && jQuery.multiFilter( selector, this ).length > 0; 365 357 }, 366 358 … … 537 529 538 530 // Give the init function the jQuery prototype for later instantiation 539 jQuery. prototype.init.prototype = jQuery.prototype;531 jQuery.fn.init.prototype = jQuery.fn; 540 532 541 533 function evalScript( i, elem ) { … … 552 544 if ( elem.parentNode ) 553 545 elem.parentNode.removeChild( elem ); 546 } 547 548 function now(){ 549 return +new Date; 554 550 } 555 551 … … 599 595 }; 600 596 601 var expando = "jQuery" + (new Date()).getTime(), uuid = 0, windowData = {};597 var expando = "jQuery" + now(), uuid = 0, windowData = {}, 602 598 603 599 // exclude the following css properties to add px 604 var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i; 600 exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, 605 601 // cache getComputedStyle 606 vargetComputedStyle = document.defaultView && document.defaultView.getComputedStyle;602 getComputedStyle = document.defaultView && document.defaultView.getComputedStyle; 607 603 608 604 jQuery.extend({ … … 875 871 // then some display: none elements are involved 876 872 else { 877 var swap = [], stack = [] ;873 var swap = [], stack = [], a = elem, i = 0; 878 874 879 875 // Locate all of the parent display: none elements 880 for ( var a = elem; a && color(a); a = a.parentNode )876 for ( ; a && color(a); a = a.parentNode ) 881 877 stack.unshift(a); 882 878 883 879 // Go through and make them visible, but in reverse 884 880 // (It would be better if we knew the exact display type that they had) 885 for ( var i = 0; i < stack.length; i++ )881 for ( ; i < stack.length; i++ ) 886 882 if ( color( stack[ i ] ) ) { 887 883 swap[ i ] = stack[ i ].style.display; … … 896 892 897 893 // Finally, revert the display styles back 898 for ( vari = 0; i < swap.length; i++ )894 for ( i = 0; i < swap.length; i++ ) 899 895 if ( swap[ i ] != null ) 900 896 stack[ i ].style.display = swap[ i ]; … … 947 943 948 944 if ( elem.constructor == Number ) 949 elem = elem.toString();945 elem += ''; 950 946 951 947 // Convert html string into DOM nodes -
trunk/jquery/src/event.js
r5352 r5357 14 14 // For whatever reason, IE has trouble passing the window object 15 15 // around, causing it to be cloned in the process 16 if ( jQuery.browser.msie && elem.setInterval != undefined)16 if ( jQuery.browser.msie && elem.setInterval ) 17 17 elem = window; 18 18 … … 52 52 handle.elem = elem; 53 53 54 // Handle multiple events seperated by a space 55 // jQuery(...).bind("mouseover mouseout", fn); 56 jQuery.each(types.split(/\s+/), function(index, type) { 57 // Namespaced event handlers 58 var parts = type.split("."); 59 type = parts[0]; 60 handler.type = parts[1]; 61 62 // Get the current list of functions bound to this event 63 var handlers = events[type]; 64 65 // Init the event handler queue 66 if (!handlers) { 67 handlers = events[type] = {}; 68 69 // Check for a special event handler 70 // Only use addEventListener/attachEvent if the special 71 // events handler returns false 72 if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem) === false ) { 73 // Bind the global event handler to the element 74 if (elem.addEventListener) 75 elem.addEventListener(type, handle, false); 76 else if (elem.attachEvent) 77 elem.attachEvent("on" + type, handle); 78 } 54 // Handle multiple events separated by a space 55 // jQuery(...).bind("mouseover mouseout", fn); 56 jQuery.each(types.split(/\s+/), function(index, type) { 57 // Namespaced event handlers 58 var parts = type.split("."); 59 type = parts[0]; 60 handler.type = parts[1]; 61 62 // Get the current list of functions bound to this event 63 var handlers = events[type]; 64 65 // Init the event handler queue 66 if (!handlers) { 67 handlers = events[type] = {}; 68 69 // Check for a special event handler 70 // Only use addEventListener/attachEvent if the special 71 // events handler returns false 72 if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem) === false ) { 73 // Bind the global event handler to the element 74 if (elem.addEventListener) 75 elem.addEventListener(type, handle, false); 76 else if (elem.attachEvent) 77 elem.attachEvent("on" + type, handle); 79 78 } 80 81 // Add the function to the element's handler list 82 handlers[handler.guid] = handler; 83 84 // Keep track of which events have been used, for global triggering 85 jQuery.event.global[type] = true; 86 }); 79 } 80 81 // Add the function to the element's handler list 82 handlers[handler.guid] = handler; 83 84 // Keep track of which events have been used, for global triggering 85 jQuery.event.global[type] = true; 86 }); 87 87 88 88 // Nullify elem to prevent memory leaks in IE … … 191 191 preventDefault: function(){}, 192 192 stopPropagation: function(){}, 193 timeStamp: +new Date193 timeStamp: now() 194 194 }); 195 195 data[0][expando] = true; // no need to fix fake event … … 310 310 311 311 // Fix timeStamp 312 event.timeStamp = event.timeStamp || +new Date;312 event.timeStamp = event.timeStamp || now(); 313 313 314 314 // Fix target property, if necessary … … 381 381 if ( withinElement(event, this) ) return true; 382 382 // Execute the right handlers by setting the event type to mouseenter 383 arguments[0].type = "mouseenter";383 event.type = "mouseenter"; 384 384 return jQuery.event.handle.apply(this, arguments); 385 385 } … … 403 403 if ( withinElement(event, this) ) return true; 404 404 // Execute the right handlers by setting the event type to mouseleave 405 arguments[0].type = "mouseleave";405 event.type = "mouseleave"; 406 406 return jQuery.event.handle.apply(this, arguments); 407 407 } … … 440 440 441 441 triggerHandler: function( type, data, fn ) { 442 if ( this[0] ) 443 return jQuery.event.trigger( type, data, this[0], false, fn ); 444 return undefined; 442 return this[0] && jQuery.event.trigger( type, data, this[0], false, fn ); 445 443 }, 446 444 -
trunk/jquery/src/fx.js
r5350 r5357 77 77 return false; 78 78 79 var opt = jQuery.extend({}, optall) ;80 varhidden = jQuery(this).is(":hidden"), self = this;79 var opt = jQuery.extend({}, optall), p, 80 hidden = jQuery(this).is(":hidden"), self = this; 81 81 82 for ( varp in prop ) {82 for ( p in prop ) { 83 83 if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden ) 84 84 return jQuery.isFunction(opt.complete) && opt.complete.apply(this); … … 181 181 182 182 var queue = function( elem, type, array ) { 183 if ( !elem )184 return undefined;185 186 type = type || "fx";187 188 var q = jQuery.data( elem, type + "queue" );189 190 if ( !q || array )191 q = jQuery.data( elem, type + "queue", jQuery.makeArray(array) ); 192 183 if ( elem ){ 184 185 type = type || "fx"; 186 187 var q = jQuery.data( elem, type + "queue" ); 188 189 if ( !q || array ) 190 q = jQuery.data( elem, type + "queue", jQuery.makeArray(array) ); 191 192 } 193 193 return q; 194 194 }; … … 219 219 opt.duration = (opt.duration && opt.duration.constructor == Number ? 220 220 opt.duration : 221 { slow: 600, fast: 200 }[opt.duration]) || 400;221 jQuery.fx.speeds[opt.duration]) || 400; 222 222 223 223 // Queueing … … 281 281 // Start an animation from one number to another 282 282 custom: function(from, to, unit){ 283 this.startTime = (new Date()).getTime();283 this.startTime = now(); 284 284 this.start = from; 285 285 this.end = to; … … 344 344 // Each step of an animation 345 345 step: function(gotoEnd){ 346 var t = (new Date()).getTime();346 var t = now(); 347 347 348 348 if ( gotoEnd || t > this.options.duration + this.startTime ) { … … 402 402 }; 403 403 404 jQuery.fx.step = { 405 scrollLeft: function(fx){ 406 fx.elem.scrollLeft = fx.now; 407 }, 408 409 scrollTop: function(fx){ 410 fx.elem.scrollTop = fx.now; 411 }, 412 413 opacity: function(fx){ 414 jQuery.attr(fx.elem.style, "opacity", fx.now); 415 }, 416 417 _default: function(fx){ 418 fx.elem.style[ fx.prop ] = fx.now + fx.unit; 404 jQuery.extend( jQuery.fx, { 405 speeds:{ 406 slow: 600, 407 fast: 200 408 }, 409 step: { 410 scrollLeft: function(fx){ 411 fx.elem.scrollLeft = fx.now; 412 }, 413 414 scrollTop: function(fx){ 415 fx.elem.scrollTop = fx.now; 416 }, 417 418 opacity: function(fx){ 419 jQuery.attr(fx.elem.style, "opacity", fx.now); 420 }, 421 422 _default: function(fx){ 423 fx.elem.style[ fx.prop ] = fx.now + fx.unit; 424 } 419 425 } 420 } ;426 }); -
trunk/jquery/src/selector.js
r5354 r5357 115 115 t = jQuery.trim(t); 116 116 117 var foundToken = false ;117 var foundToken = false, 118 118 119 119 // An attempt at speeding up child selectors that 120 120 // point to a specific element tag 121 var re = quickChild; 122 var m = re.exec(t); 121 re = quickChild, 122 123 m = re.exec(t); 123 124 124 125 if ( m ) { … … 417 418 418 419 dir: function( elem, dir ){ 419 var matched = [] ;420 varcur = elem[dir];420 var matched = [], 421 cur = elem[dir]; 421 422 while ( cur && cur != document ) { 422 423 if ( cur.nodeType == 1 ) … … 450 451 }); 451 452 453