Commit 9e5ec378 authored by timmywil's avatar timmywil

Merge branch 'master' of git://github.com/jquery/jquery into bug_2773

parents ed48787e 71bd828d
...@@ -9,6 +9,7 @@ DIST_DIR = ${PREFIX}/dist ...@@ -9,6 +9,7 @@ DIST_DIR = ${PREFIX}/dist
JS_ENGINE ?= `which node nodejs` JS_ENGINE ?= `which node nodejs`
COMPILER = ${JS_ENGINE} ${BUILD_DIR}/uglify.js --unsafe COMPILER = ${JS_ENGINE} ${BUILD_DIR}/uglify.js --unsafe
POST_COMPILER = ${JS_ENGINE} ${BUILD_DIR}/post-compile.js
BASE_FILES = ${SRC_DIR}/core.js\ BASE_FILES = ${SRC_DIR}/core.js\
${SRC_DIR}/support.js\ ${SRC_DIR}/support.js\
...@@ -43,7 +44,7 @@ VER = sed "s/@VERSION/${JQ_VER}/" ...@@ -43,7 +44,7 @@ VER = sed "s/@VERSION/${JQ_VER}/"
DATE=$(shell git log -1 --pretty=format:%ad) DATE=$(shell git log -1 --pretty=format:%ad)
all: init jquery min lint all: jquery min lint
@@echo "jQuery build complete." @@echo "jQuery build complete."
${DIST_DIR}: ${DIST_DIR}:
...@@ -68,12 +69,16 @@ define clone_or_pull ...@@ -68,12 +69,16 @@ define clone_or_pull
endef endef
init: ${QUNIT_DIR}:
$(call clone_or_pull, ${QUNIT_DIR}, git://github.com/jquery/qunit.git) $(call clone_or_pull, ${QUNIT_DIR}, git://github.com/jquery/qunit.git)
${SIZZLE_DIR}:
$(call clone_or_pull, ${SIZZLE_DIR}, git://github.com/jeresig/sizzle.git) $(call clone_or_pull, ${SIZZLE_DIR}, git://github.com/jeresig/sizzle.git)
jquery: ${JQ} init: ${QUNIT_DIR} ${SIZZLE_DIR}
jq: ${JQ}
jquery: init ${JQ}
jq: init ${JQ}
${JQ}: ${MODULES} | ${DIST_DIR} ${JQ}: ${MODULES} | ${DIST_DIR}
@@echo "Building" ${JQ} @@echo "Building" ${JQ}
...@@ -88,18 +93,26 @@ ${SRC_DIR}/selector.js: ${SIZZLE_DIR}/sizzle.js ...@@ -88,18 +93,26 @@ ${SRC_DIR}/selector.js: ${SIZZLE_DIR}/sizzle.js
@@echo "Building selector code from Sizzle" @@echo "Building selector code from Sizzle"
@@sed '/EXPOSE/r src/sizzle-jquery.js' ${SIZZLE_DIR}/sizzle.js | grep -v window.Sizzle > ${SRC_DIR}/selector.js @@sed '/EXPOSE/r src/sizzle-jquery.js' ${SIZZLE_DIR}/sizzle.js | grep -v window.Sizzle > ${SRC_DIR}/selector.js
lint: ${JQ} lint: jquery
@@echo "Checking jQuery against JSLint..." @@if test ! -z ${JS_ENGINE}; then \
@@${JS_ENGINE} build/jslint-check.js echo "Checking jQuery against JSLint..."; \
${JS_ENGINE} build/jslint-check.js; \
else \
echo "You must have NodeJS installed in order to test jQuery against JSLint."; \
fi
min: ${JQ_MIN} min: ${JQ_MIN}
${JQ_MIN}: ${JQ} ${JQ_MIN}: jquery
@@echo "Building" ${JQ_MIN} @@if test ! -z ${JS_ENGINE}; then \
@@${COMPILER} ${JQ} > ${JQ_MIN}.tmp echo "Minifying jQuery" ${JQ_MIN}; \
@@echo ";" >> ${JQ_MIN}.tmp ${COMPILER} ${JQ} > ${JQ_MIN}.tmp; \
@@sed 's/\*\/(/*\/ʩ(/' ${JQ_MIN}.tmp | tr "ʩ" "\n" > ${JQ_MIN} ${POST_COMPILER} ${JQ_MIN}.tmp > ${JQ_MIN}; \
@@rm -rf ${JQ_MIN}.tmp rm -f ${JQ_MIN}.tmp; \
else \
echo "You must have NodeJS installed in order to minify jQuery."; \
fi
clean: clean:
@@echo "Removing Distribution directory:" ${DIST_DIR} @@echo "Removing Distribution directory:" ${DIST_DIR}
......
#!/usr/bin/env node
var print = require("sys").print,
src = require("fs").readFileSync(process.argv[2], "utf8");
// Previously done in sed but reimplemented here due to portability issues
print(src.replace(/^(\s*\*\/)(.+)/m, "$1\n$2;"));
...@@ -524,11 +524,9 @@ jQuery.extend({ ...@@ -524,11 +524,9 @@ jQuery.extend({
if ( data && rnotwhite.test(data) ) { if ( data && rnotwhite.test(data) ) {
// Inspired by code by Andrea Giammarchi // Inspired by code by Andrea Giammarchi
// http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
var head = document.getElementsByTagName("head")[0] || document.documentElement, var head = document.head || document.getElementsByTagName("head")[0] || document.documentElement,
script = document.createElement("script"); script = document.createElement("script");
script.type = "text/javascript";
if ( jQuery.support.scriptEval ) { if ( jQuery.support.scriptEval ) {
script.appendChild( document.createTextNode( data ) ); script.appendChild( document.createTextNode( data ) );
} else { } else {
...@@ -5060,7 +5058,7 @@ jQuery.extend({ ...@@ -5060,7 +5058,7 @@ jQuery.extend({
// If we're requesting a remote document // If we're requesting a remote document
// and trying to load JSON or Script with a GET // and trying to load JSON or Script with a GET
if ( s.dataType === "script" && type === "GET" && remote ) { if ( s.dataType === "script" && type === "GET" && remote ) {
var head = document.getElementsByTagName("head")[0] || document.documentElement; var head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
var script = document.createElement("script"); var script = document.createElement("script");
script.src = s.url; script.src = s.url;
if ( s.scriptCharset ) { if ( s.scriptCharset ) {
......
This diff is collapsed.
(function( jQuery ) { (function( jQuery ) {
var jsc = jQuery.now(), var jsc = jQuery.now(),
jsre = /(\=)(?:\?|%3F)(&|$)|()(?:\?\?|%3F%3F)()/i; jsre = /(\=)\?(&|$)|\?\?/i;
// Default jsonp settings // Default jsonp settings
jQuery.ajaxSetup({ jQuery.ajaxSetup({
jsonp: "callback", jsonp: "callback",
jsonpCallback: function() { jsonpCallback: function() {
return "jsonp" + jsc++; return jQuery.expando + "_" + ( jsc++ );
} }
}); });
// Detect, normalize options and install callbacks for jsonp requests // Detect, normalize options and install callbacks for jsonp requests
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, dataIsString /* internal */ ) { jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
dataIsString = ( typeof s.data === "string" ); var dataIsString = ( typeof s.data === "string" );
if ( s.dataTypes[ 0 ] === "jsonp" || if ( s.dataTypes[ 0 ] === "jsonp" ||
originalSettings.jsonpCallback || originalSettings.jsonpCallback ||
...@@ -28,7 +28,15 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, dataIsString ...@@ -28,7 +28,15 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, dataIsString
previous = window[ jsonpCallback ], previous = window[ jsonpCallback ],
url = s.url, url = s.url,
data = s.data, data = s.data,
replace = "$1" + jsonpCallback + "$2"; replace = "$1" + jsonpCallback + "$2",
cleanUp = function() {
// Set callback back to previous value
window[ jsonpCallback ] = previous;
// Call if it was a function and we have a response
if ( responseContainer && jQuery.isFunction( previous ) ) {
window[ jsonpCallback ]( responseContainer[ 0 ] );
}
};
if ( s.jsonp !== false ) { if ( s.jsonp !== false ) {
url = url.replace( jsre, replace ); url = url.replace( jsre, replace );
...@@ -46,32 +54,17 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, dataIsString ...@@ -46,32 +54,17 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, dataIsString
s.url = url; s.url = url;
s.data = data; s.data = data;
// Install callback
window[ jsonpCallback ] = function( response ) { window[ jsonpCallback ] = function( response ) {
responseContainer = [ response ]; responseContainer = [ response ];
}; };
s.complete = [ function() { // Install cleanUp function
jqXHR.then( cleanUp, cleanUp );
// Set callback back to previous value
window[ jsonpCallback ] = previous;
// Call if it was a function and we have a response
if ( previous) {
if ( responseContainer && jQuery.isFunction( previous ) ) {
window[ jsonpCallback ] ( responseContainer[ 0 ] );
}
} else {
// else, more memory leak avoidance
try{
delete window[ jsonpCallback ];
} catch( e ) {}
}
}, s.complete ];
// Use data converter to retrieve json after script execution // Use data converter to retrieve json after script execution
s.converters["script json"] = function() { s.converters["script json"] = function() {
if ( ! responseContainer ) { if ( !responseContainer ) {
jQuery.error( jsonpCallback + " was not called" ); jQuery.error( jsonpCallback + " was not called" );
} }
return responseContainer[ 0 ]; return responseContainer[ 0 ];
......
...@@ -3,13 +3,16 @@ ...@@ -3,13 +3,16 @@
// Install script dataType // Install script dataType
jQuery.ajaxSetup({ jQuery.ajaxSetup({
accepts: { accepts: {
script: "text/javascript, application/javascript" script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
}, },
contents: { contents: {
script: /javascript/ script: /javascript|ecmascript/
}, },
converters: { converters: {
"text script": jQuery.globalEval "text script": function( text ) {
jQuery.globalEval( text );
return text;
}
} }
}); });
...@@ -31,7 +34,7 @@ jQuery.ajaxTransport( "script", function(s) { ...@@ -31,7 +34,7 @@ jQuery.ajaxTransport( "script", function(s) {
if ( s.crossDomain ) { if ( s.crossDomain ) {
var script, var script,
head = document.getElementsByTagName( "head" )[ 0 ] || document.documentElement; head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
return { return {
......
(function( jQuery ) { (function( jQuery ) {
var // Next active xhr id var // #5280: next active xhr id and list of active xhrs' callbacks
xhrId = jQuery.now(), xhrId = jQuery.now(),
xhrCallbacks,
// active xhrs
xhrs = {},
// #5280: see below
xhrUnloadAbortInstalled,
// XHR used to determine supports properties // XHR used to determine supports properties
testXHR; testXHR;
// #5280: Internet Explorer will keep connections alive if we don't abort on unload
function xhrOnUnloadAbort() {
jQuery( window ).unload(function() {
// Abort all pending requests
for ( var key in xhrCallbacks ) {
xhrCallbacks[ key ]( 0, 1 );
}
});
}
// Functions to create xhrs
function createStandardXHR() {
try {
return new window.XMLHttpRequest();
} catch( e ) {}
}
function createActiveXHR() {
try {
return new window.ActiveXObject( "Microsoft.XMLHTTP" );
} catch( e ) {}
}
// Create the request object // Create the request object
// (This is still attached to ajaxSettings for backward compatibility) // (This is still attached to ajaxSettings for backward compatibility)
jQuery.ajaxSettings.xhr = window.ActiveXObject ? jQuery.ajaxSettings.xhr = window.ActiveXObject ?
...@@ -22,27 +40,13 @@ jQuery.ajaxSettings.xhr = window.ActiveXObject ? ...@@ -22,27 +40,13 @@ jQuery.ajaxSettings.xhr = window.ActiveXObject ?
* we need a fallback. * we need a fallback.
*/ */
function() { function() {
if ( window.location.protocol !== "file:" ) { return !this.isLocal && createStandardXHR() || createActiveXHR();
try {
return new window.XMLHttpRequest();
} catch( xhrError ) {}
}
try {
return new window.ActiveXObject("Microsoft.XMLHTTP");
} catch( activeError ) {}
} : } :
// For all other browsers, use the standard XMLHttpRequest object // For all other browsers, use the standard XMLHttpRequest object
function() { createStandardXHR;
return new window.XMLHttpRequest();
};
// Test if we can create an xhr object // Test if we can create an xhr object
try { testXHR = jQuery.ajaxSettings.xhr();
testXHR = jQuery.ajaxSettings.xhr();
} catch( xhrCreationException ) {}
//Does this browser support XHR requests?
jQuery.support.ajax = !!testXHR; jQuery.support.ajax = !!testXHR;
// Does this browser support crossDomain XHR requests // Does this browser support crossDomain XHR requests
...@@ -63,26 +67,10 @@ if ( jQuery.support.ajax ) { ...@@ -63,26 +67,10 @@ if ( jQuery.support.ajax ) {
return { return {
send: function( headers, complete ) { send: function( headers, complete ) {
// #5280: we need to abort on unload or IE will keep connections alive
if ( !xhrUnloadAbortInstalled ) {
xhrUnloadAbortInstalled = 1;
jQuery(window).bind( "unload", function() {
// Abort all pending requests
jQuery.each( xhrs, function( _, xhr ) {
if ( xhr.onreadystatechange ) {
xhr.onreadystatechange( 1 );
}
} );
} );
}
// Get a new xhr // Get a new xhr
var xhr = s.xhr(), var xhr = s.xhr(),
handle; handle,
i;
// Open the socket // Open the socket
// Passing null username, generates a login popup on Opera (#2865) // Passing null username, generates a login popup on Opera (#2865)
...@@ -92,42 +80,62 @@ if ( jQuery.support.ajax ) { ...@@ -92,42 +80,62 @@ if ( jQuery.support.ajax ) {
xhr.open( s.type, s.url, s.async ); xhr.open( s.type, s.url, s.async );
} }
// Apply custom fields if provided
if ( s.xhrFields ) {
for ( i in s.xhrFields ) {
xhr[ i ] = s.xhrFields[ i ];
}
}
// Override mime type if needed
if ( s.mimeType && xhr.overrideMimeType ) {
xhr.overrideMimeType( s.mimeType );
}
// Requested-With header // Requested-With header
// Not set for crossDomain requests with no content // Not set for crossDomain requests with no content
// (see why at http://trac.dojotoolkit.org/ticket/9486) // (see why at http://trac.dojotoolkit.org/ticket/9486)
// Won't change header if already provided // Won't change header if already provided
if ( !( s.crossDomain && !s.hasContent ) && !headers["x-requested-with"] ) { if ( !( s.crossDomain && !s.hasContent ) && !headers["X-Requested-With"] ) {
headers[ "x-requested-with" ] = "XMLHttpRequest"; headers[ "X-Requested-With" ] = "XMLHttpRequest";
} }
// Need an extra try/catch for cross domain requests in Firefox 3 // Need an extra try/catch for cross domain requests in Firefox 3
try { try {
jQuery.each( headers, function( key, value ) { for ( i in headers ) {
xhr.setRequestHeader( key, value ); xhr.setRequestHeader( i, headers[ i ] );
} ); }
} catch( _ ) {} } catch( _ ) {}
// Do send the request // Do send the request
try { // This may raise an exception which is actually
// handled in jQuery.ajax (so no try/catch here)
xhr.send( ( s.hasContent && s.data ) || null ); xhr.send( ( s.hasContent && s.data ) || null );
} catch( e ) {
complete( 0, "error", "" + e );
return;
}
// Listener // Listener
callback = function( _, isAbort ) { callback = function( _, isAbort ) {
var status,
statusText,
responseHeaders,
responses,
xml;
// Firefox throws exceptions when accessing properties
// of an xhr when a network error occured
// http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
try {
// Was never called and is aborted or complete // Was never called and is aborted or complete
if ( callback && ( isAbort || xhr.readyState === 4 ) ) { if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
// Only called once // Only called once
callback = 0; callback = undefined;
// Do not keep as active anymore // Do not keep as active anymore
if ( handle ) { if ( handle ) {
xhr.onreadystatechange = jQuery.noop; xhr.onreadystatechange = jQuery.noop;
delete xhrs[ handle ]; delete xhrCallbacks[ handle ];
} }
// If it's an abort // If it's an abort
...@@ -137,11 +145,9 @@ if ( jQuery.support.ajax ) { ...@@ -137,11 +145,9 @@ if ( jQuery.support.ajax ) {
xhr.abort(); xhr.abort();
} }
} else { } else {
// Get info status = xhr.status;
var status = xhr.status, responseHeaders = xhr.getAllResponseHeaders();
statusText, responses = {};
responseHeaders = xhr.getAllResponseHeaders(),
responses = {},
xml = xhr.responseXML; xml = xhr.responseXML;
// Construct response list // Construct response list
...@@ -159,34 +165,29 @@ if ( jQuery.support.ajax ) { ...@@ -159,34 +165,29 @@ if ( jQuery.support.ajax ) {
statusText = ""; statusText = "";
} }
// Filter status for non standard behaviours // Filter status for non standard behaviors
status =
// Opera returns 0 when it should be 304 // If the request is local and we have data: assume a success
// Webkit returns 0 for failing cross-domain no matter the real status // (success with no data won't get notified, that's the best we
status === 0 ? // can do given current implementations)
( if ( !status && s.isLocal && !s.crossDomain ) {
// Webkit, Firefox: filter out faulty cross-domain requests status = responses.text ? 200 : 404;
!s.crossDomain || statusText ? // IE - #1450: sometimes returns 1223 when it should be 204
( } else if ( status === 1223 ) {
// Opera: filter out real aborts #6060 status = 204;
responseHeaders ? }
304 :
0
) :
// We assume 302 but could be anything cross-domain related
302
) :
(
// IE sometimes returns 1223 when it should be 204 (see #1450)
status == 1223 ?
204 :
status
);
// Call complete
complete( status, statusText, responses, responseHeaders );
} }
} }
} catch( firefoxAccessException ) {
if ( !isAbort ) {
complete( -1, firefoxAccessException );
}
}
// Call complete if needed
if ( responses ) {
complete( status, statusText, responses, responseHeaders );
}
}; };
// if we're in sync mode or it's in cache // if we're in sync mode or it's in cache
...@@ -195,10 +196,15 @@ if ( jQuery.support.ajax ) { ...@@ -195,10 +196,15 @@ if ( jQuery.support.ajax ) {
if ( !s.async || xhr.readyState === 4 ) { if ( !s.async || xhr.readyState === 4 ) {
callback(); callback();
} else { } else {
// Add to list of active xhrs // Create the active xhrs callbacks list if needed
// and attach the unload handler
if ( !xhrCallbacks ) {
xhrCallbacks = {};
xhrOnUnloadAbort();
}
// Add to list of active xhrs callbacks
handle = xhrId++; handle = xhrId++;
xhrs[ handle ] = xhr; xhr.onreadystatechange = xhrCallbacks[ handle ] = callback;
xhr.onreadystatechange = callback;
} }
}, },
......
...@@ -198,6 +198,11 @@ jQuery.fn.extend({ ...@@ -198,6 +198,11 @@ jQuery.fn.extend({
} }
} }
// Fixes Bug #2551 -- select.val() broken in IE after form.reset()
if ( one && !values.length && options.length ) {
return jQuery( options[ index ] ).val();
}
return values; return values;
} }
......
...@@ -26,9 +26,6 @@ var jQuery = function( selector, context ) { ...@@ -26,9 +26,6 @@ var jQuery = function( selector, context ) {
trimLeft = /^\s+/, trimLeft = /^\s+/,
trimRight = /\s+$/, trimRight = /\s+$/,
// Check for non-word characters
rnonword = /\W/,
// Check for digits // Check for digits
rdigit = /\d/, rdigit = /\d/,
...@@ -569,10 +566,8 @@ jQuery.extend({ ...@@ -569,10 +566,8 @@ jQuery.extend({
if ( data && rnotwhite.test(data) ) { if ( data && rnotwhite.test(data) ) {
// Inspired by code by Andrea Giammarchi // Inspired by code by Andrea Giammarchi
// http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
var head = document.getElementsByTagName("head")[0] || document.documentElement, var head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement,
script = document.createElement("script"); script = document.createElement( "script" );
script.type = "text/javascript";
if ( jQuery.support.scriptEval() ) { if ( jQuery.support.scriptEval() ) {
script.appendChild( document.createTextNode( data ) ); script.appendChild( document.createTextNode( data ) );
...@@ -895,22 +890,22 @@ jQuery.extend({ ...@@ -895,22 +890,22 @@ jQuery.extend({
isRejected: failDeferred.isResolved, isRejected: failDeferred.isResolved,
// Get a promise for this deferred // Get a promise for this deferred
// If obj is provided, the promise aspect is added to the object // If obj is provided, the promise aspect is added to the object
promise: function( obj , i /* internal */ ) { promise: function( obj ) {
if ( obj == null ) { if ( obj == null ) {
if ( promise ) { if ( promise ) {
return promise; return promise;
} }
promise = obj = {}; promise = obj = {};
} }
i = promiseMethods.length; var i = promiseMethods.length;
while( i-- ) { while( i-- ) {
obj[ promiseMethods[ i ] ] = deferred[ promiseMethods[ i ] ]; obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ];
} }
return obj; return obj;
} }
} ); } );
// Make sure only one callback list will be used // Make sure only one callback list will be used
deferred.then( failDeferred.cancel, deferred.cancel ); deferred.done( failDeferred.cancel ).fail( deferred.cancel );
// Unexpose cancel // Unexpose cancel
delete deferred.cancel; delete deferred.cancel;
// Call given func if any // Call given func if any
...@@ -922,25 +917,34 @@ jQuery.extend({ ...@@ -922,25 +917,34 @@ jQuery.extend({
// Deferred helper // Deferred helper
when: function( object ) { when: function( object ) {
var args = arguments, var lastIndex = arguments.length,
length = args.length, deferred = lastIndex <= 1 && object && jQuery.isFunction( object.promise ) ?
deferred = length <= 1 && object && jQuery.isFunction( object.promise ) ?
object : object :
jQuery.Deferred(), jQuery.Deferred(),
promise = deferred.promise(), promise = deferred.promise();
resolveArray;
if ( lastIndex > 1 ) {
if ( length > 1 ) { var array = slice.call( arguments, 0 ),
resolveArray = new Array( length ); count = lastIndex,
jQuery.each( args, function( index, element, args ) { iCallback = function( index ) {
jQuery.when( element ).then( function( value ) { return function( value ) {
args = arguments; array[ index ] = arguments.length > 1 ? slice.call( arguments, 0 ) : value;
resolveArray[ index ] = args.length > 1 ? slice.call( args, 0 ) : value; if ( !( --count ) ) {
if( ! --length ) { deferred.resolveWith( promise, array );
deferred.resolveWith( promise, resolveArray ); }
} };
}, deferred.reject ); };
} ); while( ( lastIndex-- ) ) {
object = array[ lastIndex ];
if ( object && jQuery.isFunction( object.promise ) ) {
object.promise().then( iCallback(lastIndex), deferred.reject );
} else {
--count;
}
}
if ( !count ) {
deferred.resolveWith( promise, array );
}
} else if ( deferred !== object ) { } else if ( deferred !== object ) {
deferred.resolve( object ); deferred.resolve( object );
} }
...@@ -961,18 +965,20 @@ jQuery.extend({ ...@@ -961,18 +965,20 @@ jQuery.extend({
return { browser: match[1] || "", version: match[2] || "0" }; return { browser: match[1] || "", version: match[2] || "0" };
}, },
subclass: function(){ sub: function() {
function jQuerySubclass( selector, context ) { function jQuerySubclass( selector, context ) {
return new jQuerySubclass.fn.init( selector, context ); return new jQuerySubclass.fn.init( selector, context );
} }
jQuery.extend( true, jQuerySubclass, this );
jQuerySubclass.superclass = this; jQuerySubclass.superclass = this;
jQuerySubclass.fn = jQuerySubclass.prototype = this(); jQuerySubclass.fn = jQuerySubclass.prototype = this();
jQuerySubclass.fn.constructor = jQuerySubclass; jQuerySubclass.fn.constructor = jQuerySubclass;
jQuerySubclass.subclass = this.subclass; jQuerySubclass.subclass = this.subclass;
jQuerySubclass.fn.init = function init( selector, context ) { jQuerySubclass.fn.init = function init( selector, context ) {
if (context && context instanceof jQuery && !(context instanceof jQuerySubclass)){ if ( context && context instanceof jQuery && !(context instanceof jQuerySubclass) ) {
context = jQuerySubclass(context); context = jQuerySubclass(context);
} }
return jQuery.fn.init.call( this, selector, context, rootjQuerySubclass ); return jQuery.fn.init.call( this, selector, context, rootjQuerySubclass );
}; };
jQuerySubclass.fn.init.prototype = jQuerySubclass.fn; jQuerySubclass.fn.init.prototype = jQuerySubclass.fn;
...@@ -1054,6 +1060,6 @@ function doScrollCheck() { ...@@ -1054,6 +1060,6 @@ function doScrollCheck() {
} }
// Expose jQuery to the global object // Expose jQuery to the global object
return (window.jQuery = window.$ = jQuery); return jQuery;
})(); })();
...@@ -24,7 +24,7 @@ jQuery.extend({ ...@@ -24,7 +24,7 @@ jQuery.extend({
hasData: function( elem ) { hasData: function( elem ) {
elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
return !!elem && !jQuery.isEmptyObject(elem); return !!elem && !isEmptyDataObject( elem );
}, },
data: function( elem, name, data, pvt /* Internal Use Only */ ) { data: function( elem, name, data, pvt /* Internal Use Only */ ) {
...@@ -64,11 +64,18 @@ jQuery.extend({ ...@@ -64,11 +64,18 @@ jQuery.extend({
if ( !cache[ id ] ) { if ( !cache[ id ] ) {
cache[ id ] = {}; cache[ id ] = {};
// TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
// metadata on plain JS objects when the object is serialized using
// JSON.stringify
if ( !isNode ) {
cache[ id ].toJSON = jQuery.noop;
}
} }
// An object can be passed to jQuery.data instead of a key/value pair; this gets // An object can be passed to jQuery.data instead of a key/value pair; this gets
// shallow copied over onto the existing cache // shallow copied over onto the existing cache
if ( typeof name === "object" ) { if ( typeof name === "object" || typeof name === "function" ) {
if ( pvt ) { if ( pvt ) {
cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name); cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
} else { } else {
...@@ -130,7 +137,7 @@ jQuery.extend({ ...@@ -130,7 +137,7 @@ jQuery.extend({
// If there is no data left in the cache, we want to continue // If there is no data left in the cache, we want to continue
// and let the cache object itself get destroyed // and let the cache object itself get destroyed
if ( !jQuery.isEmptyObject(thisCache) ) { if ( !isEmptyDataObject(thisCache) ) {
return; return;
} }
} }
...@@ -142,7 +149,7 @@ jQuery.extend({ ...@@ -142,7 +149,7 @@ jQuery.extend({
// Don't destroy the parent cache unless the internal data object // Don't destroy the parent cache unless the internal data object
// had been the only thing left in it // had been the only thing left in it
if ( !jQuery.isEmptyObject(cache[ id ]) ) { if ( !isEmptyDataObject(cache[ id ]) ) {
return; return;
} }
} }
...@@ -163,6 +170,13 @@ jQuery.extend({ ...@@ -163,6 +170,13 @@ jQuery.extend({
// data if it existed // data if it existed
if ( internalCache ) { if ( internalCache ) {
cache[ id ] = {}; cache[ id ] = {};
// TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
// metadata on plain JS objects when the object is serialized using
// JSON.stringify
if ( !isNode ) {
cache[ id ].toJSON = jQuery.noop;
}
cache[ id ][ internalKey ] = internalCache; cache[ id ][ internalKey ] = internalCache;
// Otherwise, we need to eliminate the expando on the node to avoid // Otherwise, we need to eliminate the expando on the node to avoid
...@@ -291,4 +305,17 @@ function dataAttr( elem, key, data ) { ...@@ -291,4 +305,17 @@ function dataAttr( elem, key, data ) {
return data; return data;
} }
// TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON
// property to be considered empty objects; this property always exists in
// order to make sure JSON.stringify does not expose internal metadata
function isEmptyDataObject( obj ) {
for ( var name in obj ) {
if ( name !== "toJSON" ) {
return false;
}
}
return true;
}
})( jQuery ); })( jQuery );
...@@ -185,11 +185,11 @@ jQuery.fn.extend({ ...@@ -185,11 +185,11 @@ jQuery.fn.extend({
} else { } else {
var parts = rfxnum.exec(val), var parts = rfxnum.exec(val),
start = e.cur() || 0; start = e.cur();
if ( parts ) { if ( parts ) {
var end = parseFloat( parts[2] ), var end = parseFloat( parts[2] ),
unit = parts[3] || "px"; unit = parts[3] || ( jQuery.cssNumber[ name ] ? "" : "px" );
// We need to compute starting value // We need to compute starting value
if ( unit !== "px" ) { if ( unit !== "px" ) {
...@@ -336,8 +336,12 @@ jQuery.fx.prototype = { ...@@ -336,8 +336,12 @@ jQuery.fx.prototype = {
return this.elem[ this.prop ]; return this.elem[ this.prop ];
} }
var r = parseFloat( jQuery.css( this.elem, this.prop ) ); var parsed,
return r || 0; r = jQuery.css( this.elem, this.prop );
// Empty strings, null, undefined and "auto" are converted to 0,
// complex values such as "rotate(1rad)" are returned as is,
// simple values such as "10px" are parsed to Float.
return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed;
}, },
// Start an animation from one number to another // Start an animation from one number to another
...@@ -348,7 +352,7 @@ jQuery.fx.prototype = { ...@@ -348,7 +352,7 @@ jQuery.fx.prototype = {
this.startTime = jQuery.now(); this.startTime = jQuery.now();
this.start = from; this.start = from;
this.end = to; this.end = to;
this.unit = unit || this.unit || "px"; this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
this.now = this.start; this.now = this.start;
this.pos = this.state = 0; this.pos = this.state = 0;
......
...@@ -7,8 +7,7 @@ var rnamespaces = /\.(.*)$/, ...@@ -7,8 +7,7 @@ var rnamespaces = /\.(.*)$/,
rescape = /[^\w\s.|`]/g, rescape = /[^\w\s.|`]/g,
fcleanup = function( nm ) { fcleanup = function( nm ) {
return nm.replace(rescape, "\\$&"); return nm.replace(rescape, "\\$&");
}, };
eventKey = "events";
/* /*
* A number of helper functions used for managing events. * A number of helper functions used for managing events.
...@@ -24,11 +23,16 @@ jQuery.event = { ...@@ -24,11 +23,16 @@ jQuery.event = {
return; return;
} }
// TODO :: Use a try/catch until it's safe to pull this out (likely 1.6)
// Minor release fix for bug #8018
try {
// For whatever reason, IE has trouble passing the window object // For whatever reason, IE has trouble passing the window object
// around, causing it to be cloned in the process // around, causing it to be cloned in the process
if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) { if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
elem = window; elem = window;
} }
}
catch ( e ) {}
if ( handler === false ) { if ( handler === false ) {
handler = returnFalse; handler = returnFalse;
...@@ -58,23 +62,10 @@ jQuery.event = { ...@@ -58,23 +62,10 @@ jQuery.event = {
return; return;
} }
var events = elemData[ eventKey ], var events = elemData.events,
eventHandle = elemData.handle; eventHandle = elemData.handle;
if ( typeof events === "function" ) { if ( !events ) {
// On plain objects events is a fn that holds the the data
// which prevents this data from being JSON serialized
// the function does not need to be called, it just contains the data
eventHandle = events.handle;
events = events.events;
} else if ( !events ) {
if ( !elem.nodeType ) {
// On plain objects, create a fn that acts as the holder
// of the values to avoid JSON serialization of event data
elemData[ eventKey ] = elemData = function(){};
}
elemData.events = events = {}; elemData.events = events = {};
} }
...@@ -175,17 +166,12 @@ jQuery.event = { ...@@ -175,17 +166,12 @@ jQuery.event = {
var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType, var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
elemData = jQuery.hasData( elem ) && jQuery._data( elem ), elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
events = elemData && elemData[ eventKey ]; events = elemData && elemData.events;
if ( !elemData || !events ) { if ( !elemData || !events ) {
return; return;
} }
if ( typeof events === "function" ) {
elemData = events;
events = events.events;
}
// types is actually an event object here // types is actually an event object here
if ( types && types.type ) { if ( types && types.type ) {
handler = types.handler; handler = types.handler;
...@@ -285,10 +271,7 @@ jQuery.event = { ...@@ -285,10 +271,7 @@ jQuery.event = {
delete elemData.events; delete elemData.events;
delete elemData.handle; delete elemData.handle;
if ( typeof elemData === "function" ) { if ( jQuery.isEmptyObject( elemData ) ) {
jQuery.removeData( elem, eventKey, true );
} else if ( jQuery.isEmptyObject( elemData ) ) {
jQuery.removeData( elem, undefined, true ); jQuery.removeData( elem, undefined, true );
} }
} }
...@@ -329,7 +312,7 @@ jQuery.event = { ...@@ -329,7 +312,7 @@ jQuery.event = {
// points to jQuery.expando // points to jQuery.expando
var internalKey = jQuery.expando, var internalKey = jQuery.expando,
internalCache = this[ internalKey ]; internalCache = this[ internalKey ];
if ( internalCache && internalCache.events && internalCache.events[type] ) { if ( internalCache && internalCache.events && internalCache.events[ type ] ) {
jQuery.event.trigger( event, data, internalCache.handle.elem ); jQuery.event.trigger( event, data, internalCache.handle.elem );
} }
}); });
...@@ -355,9 +338,7 @@ jQuery.event = { ...@@ -355,9 +338,7 @@ jQuery.event = {
event.currentTarget = elem; event.currentTarget = elem;
// Trigger the event, it is assumed that "handle" is a function // Trigger the event, it is assumed that "handle" is a function
var handle = elem.nodeType ? var handle = jQuery._data( elem, "handle" );
jQuery._data( elem, "handle" ) :
(jQuery._data( elem, eventKey ) || {}).handle;
if ( handle ) { if ( handle ) {
handle.apply( elem, data ); handle.apply( elem, data );
...@@ -435,11 +416,7 @@ jQuery.event = { ...@@ -435,11 +416,7 @@ jQuery.event = {
event.namespace = event.namespace || namespace_sort.join("."); event.namespace = event.namespace || namespace_sort.join(".");
events = jQuery._data(this, eventKey); events = jQuery._data(this, "events");
if ( typeof events === "function" ) {
events = events.events;
}
handlers = (events || {})[ event.type ]; handlers = (events || {})[ event.type ];
...@@ -681,6 +658,12 @@ var withinElement = function( event ) { ...@@ -681,6 +658,12 @@ var withinElement = function( event ) {
// Firefox sometimes assigns relatedTarget a XUL element // Firefox sometimes assigns relatedTarget a XUL element
// which we cannot access the parentNode property of // which we cannot access the parentNode property of
try { try {
// Chrome does something similar, the parentNode property
// can be accessed but is null.
if ( parent !== document && !parent.parentNode ) {
return;
}
// Traverse up the tree // Traverse up the tree
while ( parent && parent !== this ) { while ( parent && parent !== this ) {
parent = parent.parentNode; parent = parent.parentNode;
...@@ -731,8 +714,7 @@ if ( !jQuery.support.submitBubbles ) { ...@@ -731,8 +714,7 @@ if ( !jQuery.support.submitBubbles ) {
type = elem.type; type = elem.type;
if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) { if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
e.liveFired = undefined; trigger( "submit", this, arguments );
return trigger( "submit", this, arguments );
} }
}); });
...@@ -741,8 +723,7 @@ if ( !jQuery.support.submitBubbles ) { ...@@ -741,8 +723,7 @@ if ( !jQuery.support.submitBubbles ) {
type = elem.type; type = elem.type;
if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) { if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
e.liveFired = undefined; trigger( "submit", this, arguments );
return trigger( "submit", this, arguments );
} }
}); });
...@@ -805,7 +786,7 @@ if ( !jQuery.support.changeBubbles ) { ...@@ -805,7 +786,7 @@ if ( !jQuery.support.changeBubbles ) {
if ( data != null || val ) { if ( data != null || val ) {
e.type = "change"; e.type = "change";
e.liveFired = undefined; e.liveFired = undefined;
return jQuery.event.trigger( e, arguments[1], elem ); jQuery.event.trigger( e, arguments[1], elem );
} }
}; };
...@@ -819,7 +800,7 @@ if ( !jQuery.support.changeBubbles ) { ...@@ -819,7 +800,7 @@ if ( !jQuery.support.changeBubbles ) {
var elem = e.target, type = elem.type; var elem = e.target, type = elem.type;
if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) { if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
return testChange.call( this, e ); testChange.call( this, e );
} }
}, },
...@@ -831,7 +812,7 @@ if ( !jQuery.support.changeBubbles ) { ...@@ -831,7 +812,7 @@ if ( !jQuery.support.changeBubbles ) {
if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") || if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
(e.keyCode === 32 && (type === "checkbox" || type === "radio")) || (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
type === "select-multiple" ) { type === "select-multiple" ) {
return testChange.call( this, e ); testChange.call( this, e );
} }
}, },
...@@ -870,8 +851,18 @@ if ( !jQuery.support.changeBubbles ) { ...@@ -870,8 +851,18 @@ if ( !jQuery.support.changeBubbles ) {
} }
function trigger( type, elem, args ) { function trigger( type, elem, args ) {
args[0].type = type; // Piggyback on a donor event to simulate a different one.
return jQuery.event.handle.apply( elem, args ); // Fake originalEvent to avoid donor's stopPropagation, but if the
// simulated event prevents default then we do the same on the donor.
// Don't pass args or remember liveFired; they apply to the donor event.
var event = jQuery.extend( {}, args[ 0 ] );
event.type = type;
event.originalEvent = {};
event.liveFired = undefined;
jQuery.event.handle.call( elem, event );
if ( event.isDefaultPrevented() ) {
args[ 0 ].preventDefault();
}
} }
// Create "bubbling" focus and blur events // Create "bubbling" focus and blur events
...@@ -1074,11 +1065,7 @@ function liveHandler( event ) { ...@@ -1074,11 +1065,7 @@ function liveHandler( event ) {
var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret, var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
elems = [], elems = [],
selectors = [], selectors = [],
events = jQuery._data( this, eventKey ); events = jQuery._data( this, "events" );
if ( typeof events === "function" ) {
events = events.events;
}
// Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911) // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911)
if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) { if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) {
...@@ -1112,7 +1099,7 @@ function liveHandler( event ) { ...@@ -1112,7 +1099,7 @@ function liveHandler( event ) {
for ( j = 0; j < live.length; j++ ) { for ( j = 0; j < live.length; j++ ) {
handleObj = live[j]; handleObj = live[j];
if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) ) { if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) {
elem = close.elem; elem = close.elem;
related = null; related = null;
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
* jQuery JavaScript Library v@VERSION * jQuery JavaScript Library v@VERSION
* http://jquery.com/ * http://jquery.com/
* *
* Copyright 2010, John Resig * Copyright 2011, John Resig
* Dual licensed under the MIT or GPL Version 2 licenses. * Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license * http://jquery.org/license
* *
* Includes Sizzle.js * Includes Sizzle.js
* http://sizzlejs.com/ * http://sizzlejs.com/
* Copyright 2010, The Dojo Foundation * Copyright 2011, The Dojo Foundation
* Released under the MIT, BSD, and GPL Licenses. * Released under the MIT, BSD, and GPL Licenses.
* *
* Date: @DATE * Date: @DATE
......
...@@ -7,7 +7,7 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, ...@@ -7,7 +7,7 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
rtbody = /<tbody/i, rtbody = /<tbody/i,
rhtml = /<|&#?\w+;/, rhtml = /<|&#?\w+;/,
rnocache = /<(?:script|object|embed|option|style)/i, rnocache = /<(?:script|object|embed|option|style)/i,
// checked="checked" or checked (html5) // checked="checked" or checked
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
wrapMap = { wrapMap = {
option: [ 1, "<select multiple='multiple'>", "</select>" ], option: [ 1, "<select multiple='multiple'>", "</select>" ],
...@@ -184,7 +184,7 @@ jQuery.fn.extend({ ...@@ -184,7 +184,7 @@ jQuery.fn.extend({
}, },
clone: function( dataAndEvents, deepDataAndEvents ) { clone: function( dataAndEvents, deepDataAndEvents ) {
dataAndEvents = dataAndEvents == null ? true : dataAndEvents; dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
return this.map( function () { return this.map( function () {
...@@ -311,12 +311,19 @@ jQuery.fn.extend({ ...@@ -311,12 +311,19 @@ jQuery.fn.extend({
if ( first ) { if ( first ) {
table = table && jQuery.nodeName( first, "tr" ); table = table && jQuery.nodeName( first, "tr" );
for ( var i = 0, l = this.length; i < l; i++ ) { for ( var i = 0, l = this.length, lastIndex = l - 1; i < l; i++ ) {
callback.call( callback.call(
table ? table ?
root(this[i], first) : root(this[i], first) :
this[i], this[i],
i > 0 || results.cacheable || (this.length > 1 && i > 0) ? // Make sure that we do not leak memory by inadvertently discarding
// the original fragment (which might have attached data) instead of
// using it; in addition, use the original fragment object for the last
// item instead of first because it can end up being emptied incorrectly
// in certain situations (Bug #8070).
// Fragments from the fragment cache must always be cloned and never used
// in place.
results.cacheable || (l > 1 && i < lastIndex) ?
jQuery.clone( fragment, true, true ) : jQuery.clone( fragment, true, true ) :
fragment fragment
); );
...@@ -361,7 +368,7 @@ function cloneCopyEvent( src, dest ) { ...@@ -361,7 +368,7 @@ function cloneCopyEvent( src, dest ) {
for ( var type in events ) { for ( var type in events ) {
for ( var i = 0, l = events[ type ].length; i < l; i++ ) { for ( var i = 0, l = events[ type ].length; i < l; i++ ) {
jQuery.event.add( dest, type, events[ type ][ i ], events[ type ][ i ].data ); jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data );
} }
} }
} }
...@@ -482,6 +489,18 @@ jQuery.each({ ...@@ -482,6 +489,18 @@ jQuery.each({
}; };
}); });
function getAll( elem ) {
if ( "getElementsByTagName" in elem ) {
return elem.getElementsByTagName( "*" );
} else if ( "querySelectorAll" in elem ) {
return elem.querySelectorAll( "*" );
} else {
return [];
}
}
jQuery.extend({ jQuery.extend({
clone: function( elem, dataAndEvents, deepDataAndEvents ) { clone: function( elem, dataAndEvents, deepDataAndEvents ) {
var clone = elem.cloneNode(true), var clone = elem.cloneNode(true),
...@@ -489,17 +508,20 @@ jQuery.extend({ ...@@ -489,17 +508,20 @@ jQuery.extend({
destElements, destElements,
i; i;
if ( !jQuery.support.noCloneEvent && (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
(elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
// IE copies events bound via attachEvent when using cloneNode. // IE copies events bound via attachEvent when using cloneNode.
// Calling detachEvent on the clone will also remove the events // Calling detachEvent on the clone will also remove the events
// from the original. In order to get around this, we use some // from the original. In order to get around this, we use some
// proprietary methods to clear the events. Thanks to MooTools // proprietary methods to clear the events. Thanks to MooTools
// guys for this hotness. // guys for this hotness.
cloneFixAttributes( elem, clone );
// Using Sizzle here is crazy slow, so we use getElementsByTagName // Using Sizzle here is crazy slow, so we use getElementsByTagName
// instead // instead
srcElements = elem.getElementsByTagName("*"); srcElements = getAll( elem );
destElements = clone.getElementsByTagName("*"); destElements = getAll( clone );
// Weird iteration because IE will replace the length property // Weird iteration because IE will replace the length property
// with an element if you are cloning the body and one of the // with an element if you are cloning the body and one of the
...@@ -507,30 +529,25 @@ jQuery.extend({ ...@@ -507,30 +529,25 @@ jQuery.extend({
for ( i = 0; srcElements[i]; ++i ) { for ( i = 0; srcElements[i]; ++i ) {
cloneFixAttributes( srcElements[i], destElements[i] ); cloneFixAttributes( srcElements[i], destElements[i] );
} }
cloneFixAttributes( elem, clone );
} }
// Copy the events from the original to the clone // Copy the events from the original to the clone
if ( dataAndEvents ) { if ( dataAndEvents ) {
cloneCopyEvent( elem, clone ); cloneCopyEvent( elem, clone );
if ( deepDataAndEvents && "getElementsByTagName" in elem ) { if ( deepDataAndEvents ) {
srcElements = getAll( elem );
destElements = getAll( clone );
srcElements = elem.getElementsByTagName("*");
destElements = clone.getElementsByTagName("*");
if ( srcElements.length ) {
for ( i = 0; srcElements[i]; ++i ) { for ( i = 0; srcElements[i]; ++i ) {
cloneCopyEvent( srcElements[i], destElements[i] ); cloneCopyEvent( srcElements[i], destElements[i] );
} }
} }
} }
}
// Return the cloned set // Return the cloned set
return clone; return clone;
}, },
clean: function( elems, context, fragment, scripts ) { clean: function( elems, context, fragment, scripts ) {
context = context || document; context = context || document;
......
window.jQuery = window.$ = jQuery;
})(window); })(window);
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
var all = div.getElementsByTagName("*"), var all = div.getElementsByTagName("*"),
a = div.getElementsByTagName("a")[0], a = div.getElementsByTagName("a")[0],
select = document.createElement("select"), select = document.createElement("select"),
opt = select.appendChild( document.createElement("option") ); opt = select.appendChild( document.createElement("option") ),
input = div.getElementsByTagName("input")[0];
// Can't get basic test support // Can't get basic test support
if ( !all || !all.length || !a ) { if ( !all || !all.length || !a ) {
...@@ -51,7 +52,7 @@ ...@@ -51,7 +52,7 @@
// Make sure that if no value is specified for a checkbox // Make sure that if no value is specified for a checkbox
// that it defaults to "on". // that it defaults to "on".
// (WebKit defaults to "" instead) // (WebKit defaults to "" instead)
checkOn: div.getElementsByTagName("input")[0].value === "on", checkOn: input.value === "on",
// Make sure that a selected-by-default option has a working selected property. // Make sure that a selected-by-default option has a working selected property.
// (WebKit defaults to false instead of true, IE too, if it's in an optgroup) // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
...@@ -61,26 +62,29 @@ ...@@ -61,26 +62,29 @@
deleteExpando: true, deleteExpando: true,
optDisabled: false, optDisabled: false,
checkClone: false, checkClone: false,
_scriptEval: null,
noCloneEvent: true, noCloneEvent: true,
noCloneChecked: true,
boxModel: null, boxModel: null,
inlineBlockNeedsLayout: false, inlineBlockNeedsLayout: false,
shrinkWrapBlocks: false, shrinkWrapBlocks: false,
reliableHiddenOffsets: true reliableHiddenOffsets: true
}; };
input.checked = true;
jQuery.support.noCloneChecked = input.cloneNode( true ).checked;
// Make sure that the options inside disabled selects aren't marked as disabled // Make sure that the options inside disabled selects aren't marked as disabled
// (WebKit marks them as diabled) // (WebKit marks them as diabled)
select.disabled = true; select.disabled = true;
jQuery.support.optDisabled = !opt.disabled; jQuery.support.optDisabled = !opt.disabled;
var _scriptEval = null;
jQuery.support.scriptEval = function() { jQuery.support.scriptEval = function() {
if ( jQuery.support._scriptEval === null ) { if ( _scriptEval === null ) {
var root = document.documentElement, var root = document.documentElement,
script = document.createElement("script"), script = document.createElement("script"),
id = "script" + jQuery.now(); id = "script" + jQuery.now();
script.type = "text/javascript";
try { try {
script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
} catch(e) {} } catch(e) {}
...@@ -91,10 +95,10 @@ ...@@ -91,10 +95,10 @@
// tag with appendChild/createTextNode // tag with appendChild/createTextNode
// (IE doesn't support this, fails, and uses .text instead) // (IE doesn't support this, fails, and uses .text instead)
if ( window[ id ] ) { if ( window[ id ] ) {
jQuery.support._scriptEval = true; _scriptEval = true;
delete window[ id ]; delete window[ id ];
} else { } else {
jQuery.support._scriptEval = false; _scriptEval = false;
} }
root.removeChild( script ); root.removeChild( script );
...@@ -102,7 +106,7 @@ ...@@ -102,7 +106,7 @@
root = script = id = null; root = script = id = null;
} }
return jQuery.support._scriptEval; return _scriptEval;
}; };
// Test to see if it's possible to delete an expando from an element // Test to see if it's possible to delete an expando from an element
...@@ -114,7 +118,7 @@ ...@@ -114,7 +118,7 @@
jQuery.support.deleteExpando = false; jQuery.support.deleteExpando = false;
} }
if ( div.attachEvent && div.fireEvent ) { if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
div.attachEvent("onclick", function click() { div.attachEvent("onclick", function click() {
// Cloning a node shouldn't copy over any // Cloning a node shouldn't copy over any
// bound event handlers (IE does this) // bound event handlers (IE does this)
......
<?php
error_reporting(0);
$id = isset ( $_REQUEST['id'] ) ? $_REQUEST['id'] : null;
$wait = isset( $_REQUEST['wait'] ) ? $_REQUEST['wait'] : null;
if ( $wait ) sleep( $wait );
header("Content-type: text/css");
if ( $id ) {
?>
div#<?= $id ?> { margin-left: 27px }
<?php
}
?>
\ No newline at end of file
<?php <?php
header( "Sample-Header: Hello World" ); header( "Sample-Header: Hello World" );
header( "Empty-Header: " );
header( "Sample-Header2: Hello World 2" );
$headers = array(); $headers = array();
......
json_assigned_obj = { "test" : "worked" };
...@@ -19,11 +19,6 @@ if($name == 'foo') { ...@@ -19,11 +19,6 @@ if($name == 'foo') {
echo "pan"; echo "pan";
die(); die();
} }
$request = apache_request_headers();
$request = $request['X-Custom-Header'];
if(strlen($request) > 0) {
echo $request;
die();
}
echo 'ERROR <script type="text/javascript">ok( true, "name.php executed" );</script>'; echo 'ERROR <script type="text/javascript">ok( true, "name.php executed" );</script>';
?> ?>
\ No newline at end of file
<?php header('HTTP/1.0 304 Not Modified'); exit; ?>
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<script src="../../../src/offset.js"></script> <script src="../../../src/offset.js"></script>
<script type="text/javascript" src="../../../dist/jquery.js"></script> <script type="text/javascript" src="../../../dist/jquery.js"></script>
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
$(function() { jQuery(function($) {
$('.absolute').click(function() { $('.absolute').click(function() {
$('#marker').css( $(this).offset() ); $('#marker').css( $(this).offset() );
var pos = $(this).position(); var pos = $(this).position();
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<script src="../../../src/css.js"></script> <script src="../../../src/css.js"></script>
<script src="../../../src/offset.js"></script> <script src="../../../src/offset.js"></script>
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
$(function() { jQuery(function($) {
$('body').click(function() { $('body').click(function() {
$('#marker').css( $(this).offset() ); $('#marker').css( $(this).offset() );
return false; return false;
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<script src="../../../src/css.js"></script> <script src="../../../src/css.js"></script>
<script src="../../../src/offset.js"></script> <script src="../../../src/offset.js"></script>
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
$(function() { jQuery(function($) {
window.scrollTo(1000,1000); window.scrollTo(1000,1000);
$('.fixed').click(function() { $('.fixed').click(function() {
$('#marker').css( $(this).offset() ); $('#marker').css( $(this).offset() );
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<script src="../../../src/css.js"></script> <script src="../../../src/css.js"></script>
<script src="../../../src/offset.js"></script> <script src="../../../src/offset.js"></script>
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
$(function() { jQuery(function($) {
$('.relative').click(function() { $('.relative').click(function() {
$('#marker').css( $(this).offset() ); $('#marker').css( $(this).offset() );
var pos = $(this).position(); var pos = $(this).position();
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<script src="../../../src/css.js"></script> <script src="../../../src/css.js"></script>
<script src="../../../src/offset.js"></script> <script src="../../../src/offset.js"></script>
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
$(function() { jQuery(function($) {
window.scrollTo(1000,1000); window.scrollTo(1000,1000);
$('#scroll-1')[0].scrollLeft = 5; $('#scroll-1')[0].scrollLeft = 5;
$('#scroll-1')[0].scrollTop = 5; $('#scroll-1')[0].scrollTop = 5;
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<script src="../../../src/css.js"></script> <script src="../../../src/css.js"></script>
<script src="../../../src/offset.js"></script> <script src="../../../src/offset.js"></script>
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
$(function() { jQuery(function($) {
$('.static').click(function() { $('.static').click(function() {
$('#marker').css( $(this).offset() ); $('#marker').css( $(this).offset() );
var pos = $(this).position(); var pos = $(this).position();
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<script src="../../../src/css.js"></script> <script src="../../../src/css.js"></script>
<script src="../../../src/offset.js"></script> <script src="../../../src/offset.js"></script>
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
$(function() { jQuery(function($) {
$('table, th, td').click(function() { $('table, th, td').click(function() {
$('#marker').css( $(this).offset() ); $('#marker').css( $(this).offset() );
return false; return false;
......
var delayedMessage = "It worked!";
// Simple script loader that uses jQuery.readyWait
//Hold on jQuery!
jQuery.readyWait++;
var readyRegExp = /^(complete|loaded)$/;
function assetLoaded( evt ){
var node = evt.currentTarget || evt.srcElement;
if ( evt.type === "load" || readyRegExp.test(node.readyState) ) {
jQuery.ready(true);
}
}
setTimeout( function() {
var script = document.createElement("script");
script.type = "text/javascript";
if ( script.addEventListener ) {
script.addEventListener( "load", assetLoaded, false );
} else {
script.attachEvent( "onreadystatechange", assetLoaded );
}
script.src = "data/readywaitasset.js";
document.getElementsByTagName("head")[0].appendChild(script);
}, 2000 );
<?php <?php
error_reporting(0); error_reporting(0);
if ( $_REQUEST['header'] ) { if ( $_REQUEST['header'] ) {
if ( $_REQUEST['header'] == "ecma" ) {
header("Content-type: application/ecmascript");
} else {
header("Content-type: text/javascript"); header("Content-type: text/javascript");
}
} }
?> ?>
ok( true, "Script executed correctly." ); ok( true, "Script executed correctly." );
...@@ -38,17 +38,21 @@ ...@@ -38,17 +38,21 @@
<input type="checkbox" class="checkbox_test" name="mycheckbox" id="checkbox1"/> <input type="checkbox" class="checkbox_test" name="mycheckbox" id="checkbox1"/>
<label for="checkbox1">Checkbox 1</label><br/> <label for="checkbox1">Checkbox 1</label><br/>
<input type="checkbox" class="checkbox_test" name="mycheckbox" id="checkbox2"/> <input type="checkbox" class="checkbox_test" name="mycheckbox" id="checkbox2"/>
<label for="checkbox2">Checkbox 2</label> <label for="checkbox2">Checkbox 2</label><br />
<input type="checkbox" class="checkbox_test" name="mycheckbox" id="checkbox3" disabled="disabled"/> <input type="checkbox" class="checkbox_test" name="mycheckbox" id="checkbox3" disabled="disabled"/>
<label for="checkbox3">Checkbox 3</label> <label for="checkbox3">Checkbox 3</label>
</td> </td>
</td> <td>
<button class="button_test" name="mybutton1" id="button1">Button</button><br />
<button class="button_test" name="mybutton1" id="button1"><span>Button w/ child</span></button><br />
<button class="button_test" name="mybutton1" id="button1" disabled="disabled">Button Disabled</button><br />
<button class="button_test" name="mybutton1" id="button1" disabled="disabled"><span disabled="disabled">Button w/ child Dis.</span></button><br />
</td> </td>
<td> <td>
<input type="radio" class="radio_test" name="myradio" id="radio1"/> <input type="radio" class="radio_test" name="myradio" id="radio1"/>
<label for="radio1">Radio1</label><br/> <label for="radio1">Radio1</label><br/>
<input type="radio" class="radio_test" name="myradio" id="radio2"/> <input type="radio" class="radio_test" name="myradio" id="radio2"/>
<label for="radio2">Radio2</label> <label for="radio2">Radio2</label><br />
<input type="radio" class="radio_test" name="myradio" id="radio3" disabled="disabled"/> <input type="radio" class="radio_test" name="myradio" id="radio3" disabled="disabled"/>
<label for="radio3">Radio3</label> <label for="radio3">Radio3</label>
</td> </td>
...@@ -61,13 +65,17 @@ ...@@ -61,13 +65,17 @@
<td> <td>
<textarea rows='2'></textarea> <textarea rows='2'></textarea>
</td> </td>
<td>$(document).bind('change')</td> </td>
<td>$(document).bind('change')<br />
$(document).bind('click')
</td>
</tr> </tr>
<tr> <tr>
<td>Live:</td> <td>Live:</td>
<td id='select' class="red">SELECT</td> <td id='select' class="red">SELECT</td>
<td id='mselect' class="red">MULTI</td> <td id='mselect' class="red">MULTI</td>
<td id='checkbox' class="red">CHECKBOX</td> <td id='checkbox' class="red">CHECKBOX</td>
<td id='button' class="red">BUTTON</td>
<td id='radio' class="red">RADIO</td> <td id='radio' class="red">RADIO</td>
<td id='file' class="red">FILE</td> <td id='file' class="red">FILE</td>
<td id='text' class="red">TEXT</td> <td id='text' class="red">TEXT</td>
...@@ -79,6 +87,7 @@ ...@@ -79,6 +87,7 @@
<td id='selectbind' class="red">SELECT</td> <td id='selectbind' class="red">SELECT</td>
<td id='mselectbind' class="red">MULTI</td> <td id='mselectbind' class="red">MULTI</td>
<td id='checkboxbind' class="red">CHECKBOX</td> <td id='checkboxbind' class="red">CHECKBOX</td>
<td id='buttonbind' class="red">BUTTON</td>
<td id='radiobind' class="red">RADIO</td> <td id='radiobind' class="red">RADIO</td>
<td id='filebind' class="red">FILE</td> <td id='filebind' class="red">FILE</td>
<td id='textbind' class="red">TEXT</td> <td id='textbind' class="red">TEXT</td>
...@@ -89,6 +98,7 @@ ...@@ -89,6 +98,7 @@
<td id='selectfocus' class="red">SELECT</td> <td id='selectfocus' class="red">SELECT</td>
<td id='mselectfocus' class="red">MULTI</td> <td id='mselectfocus' class="red">MULTI</td>
<td id='checkboxfocus' class="red">CHECKBOX</td> <td id='checkboxfocus' class="red">CHECKBOX</td>
<td id='buttonfocus' class="red">BUTTON</td>
<td id='radiofocus' class="red">RADIO</td> <td id='radiofocus' class="red">RADIO</td>
<td id='filefocus' class="red">FILE</td> <td id='filefocus' class="red">FILE</td>
<td id='textfocus' class="red">TEXT</td> <td id='textfocus' class="red">TEXT</td>
...@@ -100,6 +110,7 @@ ...@@ -100,6 +110,7 @@
<td id='selectblur' class="red">SELECT</td> <td id='selectblur' class="red">SELECT</td>
<td id='mselectblur' class="red">MULTI</td> <td id='mselectblur' class="red">MULTI</td>
<td id='checkboxblur' class="red">CHECKBOX</td> <td id='checkboxblur' class="red">CHECKBOX</td>
<td id='buttonblur' class="red">BUTTON</td>
<td id='radioblur' class="red">RADIO</td> <td id='radioblur' class="red">RADIO</td>
<td id='fileblur' class="red">FILE</td> <td id='fileblur' class="red">FILE</td>
<td id='textblur' class="red">TEXT</td> <td id='textblur' class="red">TEXT</td>
...@@ -111,6 +122,7 @@ ...@@ -111,6 +122,7 @@
<td id='selectlfocus' class="red">SELECT</td> <td id='selectlfocus' class="red">SELECT</td>
<td id='mselectlfocus' class="red">MULTI</td> <td id='mselectlfocus' class="red">MULTI</td>
<td id='checkboxlfocus' class="red">CHECKBOX</td> <td id='checkboxlfocus' class="red">CHECKBOX</td>
<td id='buttonlfocus' class="red">BUTTON</td>
<td id='radiolfocus' class="red">RADIO</td> <td id='radiolfocus' class="red">RADIO</td>
<td id='filelfocus' class="red">FILE</td> <td id='filelfocus' class="red">FILE</td>
<td id='textlfocus' class="red">TEXT</td> <td id='textlfocus' class="red">TEXT</td>
...@@ -121,11 +133,24 @@ ...@@ -121,11 +133,24 @@
<td id='selectlblur' class="red">SELECT</td> <td id='selectlblur' class="red">SELECT</td>
<td id='mselectlblur' class="red">MULTI</td> <td id='mselectlblur' class="red">MULTI</td>
<td id='checkboxlblur' class="red">CHECKBOX</td> <td id='checkboxlblur' class="red">CHECKBOX</td>
<td id='buttonlblur' class="red">BUTTON</td>
<td id='radiolblur' class="red">RADIO</td> <td id='radiolblur' class="red">RADIO</td>
<td id='filelblur' class="red">FILE</td> <td id='filelblur' class="red">FILE</td>
<td id='textlblur' class="red">TEXT</td> <td id='textlblur' class="red">TEXT</td>
<td id='textarealblur' class="red">TEXTAREA</td> <td id='textarealblur' class="red">TEXTAREA</td>
</tr> </tr>
<tr>
<td>Live Click:</td>
<td id='selectlclick' class="red">SELECT</td>
<td id='mselectlclick' class="red">MULTI</td>
<td id='checkboxlclick' class="red">CHECKBOX</td>
<td id='buttonlclick' class="red">BUTTON</td>
<td id='radiolclick' class="red">RADIO</td>
<td id='filelclick' class="red">FILE</td>
<td id='textlclick' class="red">TEXT</td>
<td id='textarealclick' class="red">TEXTAREA</td>
<td id='boundClick' class="red">DOCUMENT</td>
</tr>
</table> </table>
<h2>Submit Tests</h2> <h2>Submit Tests</h2>
<table> <table>
...@@ -162,7 +187,7 @@ ...@@ -162,7 +187,7 @@
<ul id="log"></ul> <ul id="log"></ul>
<script type='text/javascript'> <script type='text/javascript'>
jQuery.fn.addChangeTest = function( id, prevent ) { jQuery.fn.addChangeClickTest = function( id, prevent ) {
this.bind("focusin", function(){ this.bind("focusin", function(){
jQuery(id + "focus").blink(); jQuery(id + "focus").blink();
}).bind("focusout", function(){ }).bind("focusout", function(){
...@@ -183,9 +208,12 @@ ...@@ -183,9 +208,12 @@
} }
jQuery(id).blink(); jQuery(id).blink();
}).live("click", function(e){
jQuery(id + "lclick").blink();
}); });
}; };
jQuery.fn.addSubmitTest = function( id, prevent ) { jQuery.fn.addSubmitTest = function( id, prevent ) {
return this.live("submit", function(e){ return this.live("submit", function(e){
if ( prevent ) { if ( prevent ) {
...@@ -211,6 +239,10 @@ ...@@ -211,6 +239,10 @@
jQuery("#boundBlur").blink(); jQuery("#boundBlur").blink();
}); });
$(document).bind("click", function() {
jQuery("#boundClick").blink();
});
$("td.red").live("hover", function(e) { $("td.red").live("hover", function(e) {
if ( e.type === "mouseenter" ) { if ( e.type === "mouseenter" ) {
$(this).css("backgroundColor","green"); $(this).css("backgroundColor","green");
...@@ -219,13 +251,14 @@ ...@@ -219,13 +251,14 @@
} }
}); });
$(".select_test").addChangeTest("#select"); $(".select_test").addChangeClickTest("#select");
$(".mselect_test").addChangeTest("#mselect"); $(".mselect_test").addChangeClickTest("#mselect");
$(".checkbox_test").addChangeTest("#checkbox"); $(".checkbox_test").addChangeClickTest("#checkbox");
$(".radio_test").addChangeTest("#radio"); $(".radio_test").addChangeClickTest("#radio");
$(".file_test").addChangeTest("#file"); $(".file_test").addChangeClickTest("#file");
$('textarea').addChangeTest("#textarea"); $('textarea').addChangeClickTest("#textarea");
$('#input').addChangeTest("#text"); $('#input').addChangeClickTest("#text");
$('button').addChangeClickTest("#button");
$(document).bind("change", function(){ $(document).bind("change", function(){
jQuery("#boundChange").blink(); jQuery("#boundChange").blink();
}); });
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<script src="unit/queue.js"></script> <script src="unit/queue.js"></script>
<script src="unit/attributes.js"></script> <script src="unit/attributes.js"></script>
<script src="unit/event.js"></script> <script src="unit/event.js"></script>
<script src="unit/selector.js"></script> <script src="../src/sizzle/test/unit/selector.js"></script>
<script src="unit/traversing.js"></script> <script src="unit/traversing.js"></script>
<script src="unit/manipulation.js"></script> <script src="unit/manipulation.js"></script>
<script src="unit/css.js"></script> <script src="unit/css.js"></script>
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr" id="html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery Local File Test</title>
<!-- Includes -->
<script src="../src/core.js"></script>
<script src="../src/support.js"></script>
<script src="../src/data.js"></script>
<script src="../src/queue.js"></script>
<script src="../src/attributes.js"></script>
<script src="../src/event.js"></script>
<script src="../src/sizzle/sizzle.js"></script>
<script src="../src/sizzle-jquery.js"></script>
<script src="../src/traversing.js"></script>
<script src="../src/manipulation.js"></script>
<script src="../src/css.js"></script>
<script src="../src/ajax.js"></script>
<script src="../src/ajax/jsonp.js"></script>
<script src="../src/ajax/script.js"></script>
<script src="../src/ajax/xhr.js"></script>
<script src="../src/effects.js"></script>
<script src="../src/offset.js"></script>
<script src="../src/dimensions.js"></script>
<style>
.error { color: red; }
.success { color: green; }
</style>
</head>
<body>
<h1>jQuery Local File Test</h1>
<h2>
Introduction
</h2>
<ul>
<li>
Access this file using the "file:" protocol,
</li>
<li>
two green "OK" strings must appear below,
</li>
<li>
Empty local files will issue errors, it's a known limitation.
</li>
</ul>
<h2>
Results
</h2>
<ul>
<li>
Success:
<span id="success">
</span>
</li>
<li>
Error:
<span id="error">
</span>
</li>
</ul>
<h2>
Logs:
</h2>
<ul id="log">
</ul>
<script>
var logUL = jQuery( "#log" );
function doLog( message, args ) {
jQuery( "<li />").appendTo( logUL ).text( message + ': "' + Array.prototype.join.call( args, '" - "' ) + '"' );
}
jQuery.ajax( "./data/badjson.js" , {
context: jQuery( "#success" ),
dataType: "text"
}).success(function( data, _, xhr ) {
doLog( "Success (" + xhr.status + ")" , arguments );
this.addClass( data ? "success" : "error" ).text( "OK" );
}).error(function( xhr ) {
doLog( "Success (" + xhr.status + ")" , arguments );
this.addClass( "error" ).text( "FAIL" );
});
jQuery.ajax( "./data/doesnotexist.ext" , {
context: jQuery( "#error" ),
dataType: "text"
}).error(function( xhr ) {
doLog( "Error (" + xhr.status + ")" , arguments );
this.addClass( "success" ).text( "OK" );
}).success(function( data, _, xhr ) {
doLog( "Error (" + xhr.status + ")" , arguments );
this.addClass( "error" ).text( "FAIL" );
});
</script>
</body>
\ No newline at end of file
<!DOCTYPE html>
<html>
<!--
Test for #8135
Thanks John Firebaugh for this test page based on his gist
https://gist.github.com/807090
Access this page through a web server, then stop said server and click the button.
-->
<head>
<title>
jQuery Network Error Test for Firefox
</title>
<style>
div { margin-top: 10px; }
</style>
<script src="../src/core.js"></script>
<script src="../src/support.js"></script>
<script src="../src/data.js"></script>
<script src="../src/queue.js"></script>
<script src="../src/attributes.js"></script>
<script src="../src/event.js"></script>
<script src="../src/sizzle/sizzle.js"></script>
<script src="../src/sizzle-jquery.js"></script>
<script src="../src/traversing.js"></script>
<script src="../src/manipulation.js"></script>
<script src="../src/css.js"></script>
<script src="../src/ajax.js"></script>
<script src="../src/ajax/jsonp.js"></script>
<script src="../src/ajax/script.js"></script>
<script src="../src/ajax/xhr.js"></script>
<script src="../src/effects.js"></script>
<script src="../src/offset.js"></script>
<script src="../src/dimensions.js"></script>
<script type="text/javascript">
$('button').live('click', function () {
$.ajax({
url: '/',
error: function() {
console.log( "abort", arguments );
}
}).abort();
$.ajax({
url: '/',
error: function() {
console.log( "complete", arguments );
}
});
return false;
})
</script>
</head>
<body>
<h1>
jQuery Network Error Test for Firefox
</h1>
<div>
This is a test page for
<a href="http://bugs.jquery.com/ticket/8135">
#8135
</a>
which was reported in Firefox when accessing properties
of an XMLHttpRequest object after a network error occured.
</div>
<div>Take the following steps:</div>
<ol>
<li>
make sure you accessed this page through a web server,
</li>
<li>
stop the web server,
</li>
<li>
open the console,
</li>
<li>
click this
<button>button</button>
,
</li>
<li>
wait for both requests to fail.
</li>
</ol>
<div>
Test passes if you get two log lines:
<ul>
<li>
the first starting with "abort",
</li>
<li>
the second starting with "complete",
</li>
</ul>
</div>
<div>
Test fails if the browser notifies an exception.
</div>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
// script.aculo.us builder.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/
var Builder = {
NODEMAP: {
AREA: 'map',
CAPTION: 'table',
COL: 'table',
COLGROUP: 'table',
LEGEND: 'fieldset',
OPTGROUP: 'select',
OPTION: 'select',
PARAM: 'object',
TBODY: 'table',
TD: 'table',
TFOOT: 'table',
TH: 'table',
THEAD: 'table',
TR: 'table'
},
// note: For Firefox < 1.5, OPTION and OPTGROUP tags are currently broken,
// due to a Firefox bug
node: function(elementName) {
elementName = elementName.toUpperCase();
// try innerHTML approach
var parentTag = this.NODEMAP[elementName] || 'div';
var parentElement = document.createElement(parentTag);
try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
parentElement.innerHTML = "<" + elementName + "></" + elementName + ">";
} catch(e) {}
var element = parentElement.firstChild || null;
// see if browser added wrapping tags
if(element && (element.tagName.toUpperCase() != elementName))
element = element.getElementsByTagName(elementName)[0];
// fallback to createElement approach
if(!element) element = document.createElement(elementName);
// abort if nothing could be created
if(!element) return;
// attributes (or text)
if(arguments[1])
if(this._isStringOrNumber(arguments[1]) ||
(arguments[1] instanceof Array)) {
this._children(element, arguments[1]);
} else {
var attrs = this._attributes(arguments[1]);
if(attrs.length) {
try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
parentElement.innerHTML = "<" +elementName + " " +
attrs + "></" + elementName + ">";
} catch(e) {}
element = parentElement.firstChild || null;
// workaround firefox 1.0.X bug
if(!element) {
element = document.createElement(elementName);
for(attr in arguments[1])
element[attr == 'class' ? 'className' : attr] = arguments[1][attr];
}
if(element.tagName.toUpperCase() != elementName)
element = parentElement.getElementsByTagName(elementName)[0];
}
}
// text, or array of children
if(arguments[2])
this._children(element, arguments[2]);
return element;
},
_text: function(text) {
return document.createTextNode(text);
},
ATTR_MAP: {
'className': 'class',
'htmlFor': 'for'
},
_attributes: function(attributes) {
var attrs = [];
for(attribute in attributes)
attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) +
'="' + attributes[attribute].toString().escapeHTML() + '"');
return attrs.join(" ");
},
_children: function(element, children) {
if(typeof children=='object') { // array can hold nodes and text
children.flatten().each( function(e) {
if(typeof e=='object')
element.appendChild(e)
else
if(Builder._isStringOrNumber(e))
element.appendChild(Builder._text(e));
});
} else
if(Builder._isStringOrNumber(children))
element.appendChild(Builder._text(children));
},
_isStringOrNumber: function(param) {
return(typeof param=='string' || typeof param=='number');
},
build: function(html) {
var element = this.node('div');
$(element).update(html.strip());
return element.down();
},
dump: function(scope) {
if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope
var tags = ("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY " +
"BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET " +
"FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+
"KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+
"PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+
"TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/);
tags.each( function(tag){
scope[tag] = function() {
return Builder.node.apply(Builder, [tag].concat($A(arguments)));
}
});
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
// script.aculo.us scriptaculous.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// For details, see the script.aculo.us web site: http://script.aculo.us/
var Scriptaculous = {
Version: '1.7.0',
require: function(libraryName) {
// inserting via DOM fails in Safari 2.0, so brute force approach
document.write('<script type="text/javascript" src="'+libraryName+'"></script>');
},
load: function() {
if((typeof Prototype=='undefined') ||
(typeof Element == 'undefined') ||
(typeof Element.Methods=='undefined') ||
parseFloat(Prototype.Version.split(".")[0] + "." +
Prototype.Version.split(".")[1]) < 1.5)
throw("script.aculo.us requires the Prototype JavaScript framework >= 1.5.0");
$A(document.getElementsByTagName("script")).findAll( function(s) {
return (s.src && s.src.match(/scriptaculous\.js(\?.*)?$/))
}).each( function(s) {
var path = s.src.replace(/scriptaculous\.js(\?.*)?$/,'');
var includes = s.src.match(/\?.*load=([a-z,]*)/);
(includes ? includes[1] : 'builder,effects,dragdrop,controls,slider').split(',').each(
function(include) { Scriptaculous.require(path+include+'.js') });
});
}
}
Scriptaculous.load();
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
// script.aculo.us scriptaculous.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// For details, see the script.aculo.us web site: http://script.aculo.us/
var Scriptaculous = {
Version: '1.8.1',
require: function(libraryName) {
// inserting via DOM fails in Safari 2.0, so brute force approach
document.write('<script type="text/javascript" src="'+libraryName+'"><\/script>');
},
REQUIRED_PROTOTYPE: '1.6.0',
load: function() {
function convertVersionString(versionString){
var r = versionString.split('.');
return parseInt(r[0])*100000 + parseInt(r[1])*1000 + parseInt(r[2]);
}
if((typeof Prototype=='undefined') ||
(typeof Element == 'undefined') ||
(typeof Element.Methods=='undefined') ||
(convertVersionString(Prototype.Version) <
convertVersionString(Scriptaculous.REQUIRED_PROTOTYPE)))
throw("script.aculo.us requires the Prototype JavaScript framework >= " +
Scriptaculous.REQUIRED_PROTOTYPE);
$A(document.getElementsByTagName("script")).findAll( function(s) {
return (s.src && s.src.match(/scriptaculous\.js(\?.*)?$/))
}).each( function(s) {
var path = s.src.replace(/scriptaculous\.js(\?.*)?$/,'');
var includes = s.src.match(/\?.*load=([a-z,]*)/);
(includes ? includes[1] : 'builder,effects,dragdrop,controls,slider,sound').split(',').each(
function(include) { Scriptaculous.require(path+include+'.js') });
});
}
}
Scriptaculous.load();
\ No newline at end of file
This diff is collapsed.
// script.aculo.us sound.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
//
// Based on code created by Jules Gravinese (http://www.webveteran.com/)
//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/
Sound = {
tracks: {},
_enabled: true,
template:
new Template('<embed style="height:0" id="sound_#{track}_#{id}" src="#{url}" loop="false" autostart="true" hidden="true"/>'),
enable: function(){
Sound._enabled = true;
},
disable: function(){
Sound._enabled = false;
},
play: function(url){
if(!Sound._enabled) return;
var options = Object.extend({
track: 'global', url: url, replace: false
}, arguments[1] || {});
if(options.replace && this.tracks[options.track]) {
$R(0, this.tracks[options.track].id).each(function(id){
var sound = $('sound_'+options.track+'_'+id);
sound.Stop && sound.Stop();
sound.remove();
})
this.tracks[options.track] = null;
}
if(!this.tracks[options.track])
this.tracks[options.track] = { id: 0 }
else
this.tracks[options.track].id++;
options.id = this.tracks[options.track].id;
$$('body')[0].insert(
Prototype.Browser.IE ? new Element('bgsound',{
id: 'sound_'+options.track+'_'+options.id,
src: options.url, loop: 1, autostart: true
}) : Sound.template.evaluate(options));
}
};
if(Prototype.Browser.Gecko && navigator.userAgent.indexOf("Win") > 0){
if(navigator.plugins && $A(navigator.plugins).detect(function(p){ return p.name.indexOf('QuickTime') != -1 }))
Sound.template = new Template('<object id="sound_#{track}_#{id}" width="0" height="0" type="audio/mpeg" data="#{url}"/>')
else
Sound.play = function(){}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment