Compare commits
40 commits
master
...
1.7/callba
Author | SHA1 | Date | |
---|---|---|---|
|
a745ac8c03 | ||
|
9d0b361458 | ||
|
950da8ae7f | ||
|
0c9c9fb3cf | ||
|
b136d9cc7a | ||
|
13c330a0f8 | ||
|
1f084d024d | ||
|
57634a2c15 | ||
|
4f3f0e1d4e | ||
|
a3a657cb2c | ||
|
05ae8f37b8 | ||
|
ebb39c2774 | ||
|
8dcf7ec1ce | ||
|
946a9204a1 | ||
|
3a6b759d3c | ||
|
198290a9a7 | ||
|
03c4fe9da9 | ||
|
142ae3e08a | ||
|
5ee68d6b13 | ||
|
a31195fd5a | ||
|
3e7c04ec94 | ||
|
55df216125 | ||
|
4dce543ee6 | ||
|
8c39fc855e | ||
|
96b0089c9c | ||
|
9edc3d4f39 | ||
|
1ed70e056d | ||
|
d65b27810b | ||
|
5f9dff6587 | ||
|
bf04081b6c | ||
|
d54ae84f80 | ||
|
38aea727ec | ||
|
f392f8fcbc | ||
|
0de05611bb | ||
|
f8d08561f1 | ||
|
b3d176d2cf | ||
|
13734b729f | ||
|
593fee1841 | ||
|
e79fdebcee | ||
|
114846d38d |
39 changed files with 1071 additions and 613 deletions
2
Makefile
2
Makefile
|
@ -10,6 +10,8 @@ COMPILER = ${JS_ENGINE} ${BUILD_DIR}/uglify.js --unsafe
|
||||||
POST_COMPILER = ${JS_ENGINE} ${BUILD_DIR}/post-compile.js
|
POST_COMPILER = ${JS_ENGINE} ${BUILD_DIR}/post-compile.js
|
||||||
|
|
||||||
BASE_FILES = ${SRC_DIR}/core.js\
|
BASE_FILES = ${SRC_DIR}/core.js\
|
||||||
|
${SRC_DIR}/callbacks.js\
|
||||||
|
${SRC_DIR}/topic.js\
|
||||||
${SRC_DIR}/deferred.js\
|
${SRC_DIR}/deferred.js\
|
||||||
${SRC_DIR}/support.js\
|
${SRC_DIR}/support.js\
|
||||||
${SRC_DIR}/data.js\
|
${SRC_DIR}/data.js\
|
||||||
|
|
|
@ -9,9 +9,9 @@ var fs = require("fs"),
|
||||||
extract = /<a href="\/ticket\/(\d+)" title="View ticket">(.*?)<[^"]+"component">\s*(\S+)/g;
|
extract = /<a href="\/ticket\/(\d+)" title="View ticket">(.*?)<[^"]+"component">\s*(\S+)/g;
|
||||||
|
|
||||||
var opts = {
|
var opts = {
|
||||||
version: "1.6.2 RC 1",
|
version: "1.6.1 RC 1",
|
||||||
short_version: "1.6.2rc1",
|
short_version: "1.6rc1",
|
||||||
final_version: "1.6.2",
|
final_version: "1.6.1",
|
||||||
categories: []
|
categories: []
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
14
src/ajax.js
14
src/ajax.js
|
@ -5,9 +5,9 @@ var r20 = /%20/g,
|
||||||
rCRLF = /\r?\n/g,
|
rCRLF = /\r?\n/g,
|
||||||
rhash = /#.*$/,
|
rhash = /#.*$/,
|
||||||
rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
|
rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
|
||||||
rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
|
rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
|
||||||
// #7653, #8125, #8152: local protocol detection
|
// #7653, #8125, #8152: local protocol detection
|
||||||
rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
|
rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|widget):$/,
|
||||||
rnoContent = /^(?:GET|HEAD)$/,
|
rnoContent = /^(?:GET|HEAD)$/,
|
||||||
rprotocol = /^\/\//,
|
rprotocol = /^\/\//,
|
||||||
rquery = /\?/,
|
rquery = /\?/,
|
||||||
|
@ -382,7 +382,7 @@ jQuery.extend({
|
||||||
jQuery( callbackContext ) : jQuery.event,
|
jQuery( callbackContext ) : jQuery.event,
|
||||||
// Deferreds
|
// Deferreds
|
||||||
deferred = jQuery.Deferred(),
|
deferred = jQuery.Deferred(),
|
||||||
completeDeferred = jQuery._Deferred(),
|
completeCallbacks = jQuery.Callbacks( "once memory" ),
|
||||||
// Status-dependent callbacks
|
// Status-dependent callbacks
|
||||||
statusCode = s.statusCode || {},
|
statusCode = s.statusCode || {},
|
||||||
// ifModified key
|
// ifModified key
|
||||||
|
@ -560,7 +560,7 @@ jQuery.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
// Complete
|
// Complete
|
||||||
completeDeferred.resolveWith( callbackContext, [ jqXHR, statusText ] );
|
completeCallbacks.fireWith( callbackContext, [ jqXHR, statusText ] );
|
||||||
|
|
||||||
if ( fireGlobals ) {
|
if ( fireGlobals ) {
|
||||||
globalEventContext.trigger( "ajaxComplete", [ jqXHR, s] );
|
globalEventContext.trigger( "ajaxComplete", [ jqXHR, s] );
|
||||||
|
@ -575,7 +575,7 @@ jQuery.extend({
|
||||||
deferred.promise( jqXHR );
|
deferred.promise( jqXHR );
|
||||||
jqXHR.success = jqXHR.done;
|
jqXHR.success = jqXHR.done;
|
||||||
jqXHR.error = jqXHR.fail;
|
jqXHR.error = jqXHR.fail;
|
||||||
jqXHR.complete = completeDeferred.done;
|
jqXHR.complete = completeCallbacks.add;
|
||||||
|
|
||||||
// Status-dependent callbacks
|
// Status-dependent callbacks
|
||||||
jqXHR.statusCode = function( map ) {
|
jqXHR.statusCode = function( map ) {
|
||||||
|
@ -644,8 +644,6 @@ jQuery.extend({
|
||||||
// If data is available, append data to url
|
// If data is available, append data to url
|
||||||
if ( s.data ) {
|
if ( s.data ) {
|
||||||
s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
|
s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
|
||||||
// #9682: remove data so that it's not used in an eventual retry
|
|
||||||
delete s.data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get ifModifiedKey before adding the anti-cache parameter
|
// Get ifModifiedKey before adding the anti-cache parameter
|
||||||
|
@ -729,7 +727,7 @@ jQuery.extend({
|
||||||
transport.send( requestHeaders, done );
|
transport.send( requestHeaders, done );
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Propagate exception as error if not done
|
// Propagate exception as error if not done
|
||||||
if ( state < 2 ) {
|
if ( status < 2 ) {
|
||||||
done( -1, e );
|
done( -1, e );
|
||||||
// Simply rethrow otherwise
|
// Simply rethrow otherwise
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -37,31 +37,30 @@ jQuery.fn.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
addClass: function( value ) {
|
addClass: function( value ) {
|
||||||
var classNames, i, l, elem,
|
|
||||||
setClass, c, cl;
|
|
||||||
|
|
||||||
if ( jQuery.isFunction( value ) ) {
|
if ( jQuery.isFunction( value ) ) {
|
||||||
return this.each(function( j ) {
|
return this.each(function(i) {
|
||||||
jQuery( this ).addClass( value.call(this, j, this.className) );
|
var self = jQuery(this);
|
||||||
|
self.addClass( value.call(this, i, self.attr("class") || "") );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( value && typeof value === "string" ) {
|
if ( value && typeof value === "string" ) {
|
||||||
classNames = value.split( rspace );
|
var classNames = (value || "").split( rspace );
|
||||||
|
|
||||||
for ( i = 0, l = this.length; i < l; i++ ) {
|
for ( var i = 0, l = this.length; i < l; i++ ) {
|
||||||
elem = this[ i ];
|
var elem = this[i];
|
||||||
|
|
||||||
if ( elem.nodeType === 1 ) {
|
if ( elem.nodeType === 1 ) {
|
||||||
if ( !elem.className && classNames.length === 1 ) {
|
if ( !elem.className ) {
|
||||||
elem.className = value;
|
elem.className = value;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
setClass = " " + elem.className + " ";
|
var className = " " + elem.className + " ",
|
||||||
|
setClass = elem.className;
|
||||||
|
|
||||||
for ( c = 0, cl = classNames.length; c < cl; c++ ) {
|
for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
|
||||||
if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
|
if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
|
||||||
setClass += classNames[ c ] + " ";
|
setClass += " " + classNames[c];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elem.className = jQuery.trim( setClass );
|
elem.className = jQuery.trim( setClass );
|
||||||
|
@ -74,24 +73,23 @@ jQuery.fn.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
removeClass: function( value ) {
|
removeClass: function( value ) {
|
||||||
var classNames, i, l, elem, className, c, cl;
|
|
||||||
|
|
||||||
if ( jQuery.isFunction(value) ) {
|
if ( jQuery.isFunction(value) ) {
|
||||||
return this.each(function( j ) {
|
return this.each(function(i) {
|
||||||
jQuery( this ).removeClass( value.call(this, j, this.className) );
|
var self = jQuery(this);
|
||||||
|
self.removeClass( value.call(this, i, self.attr("class")) );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (value && typeof value === "string") || value === undefined ) {
|
if ( (value && typeof value === "string") || value === undefined ) {
|
||||||
classNames = (value || "").split( rspace );
|
var classNames = (value || "").split( rspace );
|
||||||
|
|
||||||
for ( i = 0, l = this.length; i < l; i++ ) {
|
for ( var i = 0, l = this.length; i < l; i++ ) {
|
||||||
elem = this[ i ];
|
var elem = this[i];
|
||||||
|
|
||||||
if ( elem.nodeType === 1 && elem.className ) {
|
if ( elem.nodeType === 1 && elem.className ) {
|
||||||
if ( value ) {
|
if ( value ) {
|
||||||
className = (" " + elem.className + " ").replace( rclass, " " );
|
var className = (" " + elem.className + " ").replace(rclass, " ");
|
||||||
for ( c = 0, cl = classNames.length; c < cl; c++ ) {
|
for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
|
||||||
className = className.replace(" " + classNames[c] + " ", " ");
|
className = className.replace(" " + classNames[c] + " ", " ");
|
||||||
}
|
}
|
||||||
elem.className = jQuery.trim( className );
|
elem.className = jQuery.trim( className );
|
||||||
|
@ -112,7 +110,8 @@ jQuery.fn.extend({
|
||||||
|
|
||||||
if ( jQuery.isFunction( value ) ) {
|
if ( jQuery.isFunction( value ) ) {
|
||||||
return this.each(function(i) {
|
return this.each(function(i) {
|
||||||
jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
|
var self = jQuery(this);
|
||||||
|
self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,8 +317,7 @@ jQuery.extend({
|
||||||
notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
|
notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
|
||||||
|
|
||||||
// Normalize the name if needed
|
// Normalize the name if needed
|
||||||
if ( notxml ) {
|
name = notxml && jQuery.attrFix[ name ] || name;
|
||||||
name = jQuery.attrFix[ name ] || name;
|
|
||||||
|
|
||||||
hooks = jQuery.attrHooks[ name ];
|
hooks = jQuery.attrHooks[ name ];
|
||||||
|
|
||||||
|
@ -336,7 +334,6 @@ jQuery.extend({
|
||||||
hooks = formHook;
|
hooks = formHook;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( value !== undefined ) {
|
if ( value !== undefined ) {
|
||||||
|
|
||||||
|
@ -417,25 +414,6 @@ jQuery.extend({
|
||||||
0 :
|
0 :
|
||||||
undefined;
|
undefined;
|
||||||
}
|
}
|
||||||
},
|
|
||||||
// Use the value property for back compat
|
|
||||||
// Use the formHook for button elements in IE6/7 (#1954)
|
|
||||||
value: {
|
|
||||||
get: function( elem, name ) {
|
|
||||||
if ( formHook && jQuery.nodeName( elem, "button" ) ) {
|
|
||||||
return formHook.get( elem, name );
|
|
||||||
}
|
|
||||||
return name in elem ?
|
|
||||||
elem.value :
|
|
||||||
null;
|
|
||||||
},
|
|
||||||
set: function( elem, value, name ) {
|
|
||||||
if ( formHook && jQuery.nodeName( elem, "button" ) ) {
|
|
||||||
return formHook.set( elem, value, name );
|
|
||||||
}
|
|
||||||
// Does not return so that setAttribute is also used
|
|
||||||
elem.value = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -465,11 +443,10 @@ jQuery.extend({
|
||||||
var ret, hooks,
|
var ret, hooks,
|
||||||
notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
|
notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
|
||||||
|
|
||||||
if ( notxml ) {
|
// Try to normalize/fix the name
|
||||||
// Fix name and attach hooks
|
name = notxml && jQuery.propFix[ name ] || name;
|
||||||
name = jQuery.propFix[ name ] || name;
|
|
||||||
hooks = jQuery.propHooks[ name ];
|
hooks = jQuery.propHooks[ name ];
|
||||||
}
|
|
||||||
|
|
||||||
if ( value !== undefined ) {
|
if ( value !== undefined ) {
|
||||||
if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
|
if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
|
||||||
|
@ -520,6 +497,26 @@ boolHook = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Use the value property for back compat
|
||||||
|
// Use the formHook for button elements in IE6/7 (#1954)
|
||||||
|
jQuery.attrHooks.value = {
|
||||||
|
get: function( elem, name ) {
|
||||||
|
if ( formHook && jQuery.nodeName( elem, "button" ) ) {
|
||||||
|
return formHook.get( elem, name );
|
||||||
|
}
|
||||||
|
return name in elem ?
|
||||||
|
elem.value :
|
||||||
|
null;
|
||||||
|
},
|
||||||
|
set: function( elem, value, name ) {
|
||||||
|
if ( formHook && jQuery.nodeName( elem, "button" ) ) {
|
||||||
|
return formHook.set( elem, value, name );
|
||||||
|
}
|
||||||
|
// Does not return so that setAttribute is also used
|
||||||
|
elem.value = value;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// IE6/7 do not support getting/setting some attributes with get/setAttribute
|
// IE6/7 do not support getting/setting some attributes with get/setAttribute
|
||||||
if ( !jQuery.support.getSetAttribute ) {
|
if ( !jQuery.support.getSetAttribute ) {
|
||||||
|
|
||||||
|
|
257
src/callbacks.js
Normal file
257
src/callbacks.js
Normal file
|
@ -0,0 +1,257 @@
|
||||||
|
(function( jQuery ) {
|
||||||
|
|
||||||
|
// String to Object flags format cache
|
||||||
|
var flagsCache = {};
|
||||||
|
|
||||||
|
// Convert String-formatted flags into Object-formatted ones and store in cache
|
||||||
|
function createFlags( flags ) {
|
||||||
|
var object = flagsCache[ flags ] = {},
|
||||||
|
i, length;
|
||||||
|
flags = flags.split( /\s+/ );
|
||||||
|
for ( i = 0, length = flags.length; i < length; i++ ) {
|
||||||
|
object[ flags[i] ] = true;
|
||||||
|
}
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a callback list using the following parameters:
|
||||||
|
*
|
||||||
|
* flags: an optional list of space-separated flags that will change how
|
||||||
|
* the callback list behaves
|
||||||
|
*
|
||||||
|
* filter: an optional function that will be applied to each added callbacks,
|
||||||
|
* what filter returns will then be added provided it is not falsy.
|
||||||
|
*
|
||||||
|
* By default a callback list will act like an event callback list and can be
|
||||||
|
* "fired" multiple times.
|
||||||
|
*
|
||||||
|
* Possible flags:
|
||||||
|
*
|
||||||
|
* once: will ensure the callback list can only be fired once (like a Deferred)
|
||||||
|
*
|
||||||
|
* memory: will keep track of previous values and will call any callback added
|
||||||
|
* after the list has been fired right away with the latest "memorized"
|
||||||
|
* values (like a Deferred)
|
||||||
|
*
|
||||||
|
* queue: only first callback in the list is called each time the list is fired
|
||||||
|
* (cannot be used in conjunction with memory)
|
||||||
|
*
|
||||||
|
* unique: will ensure a callback can only be added once (no duplicate in the list)
|
||||||
|
*
|
||||||
|
* relocate: like "unique" but will relocate the callback at the end of the list
|
||||||
|
*
|
||||||
|
* stopOnFalse: interrupt callings when a callback returns false
|
||||||
|
*
|
||||||
|
* addAfterFire: if callbacks are added while firing, then they are not executed until after
|
||||||
|
* the next call to fire/fireWith
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
jQuery.Callbacks = function( flags, filter ) {
|
||||||
|
|
||||||
|
// flags are optional
|
||||||
|
if ( typeof flags !== "string" ) {
|
||||||
|
filter = flags;
|
||||||
|
flags = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert flags from String-formatted to Object-formatted
|
||||||
|
// (we check in cache first)
|
||||||
|
flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {};
|
||||||
|
|
||||||
|
var // Actual callback list
|
||||||
|
list = [],
|
||||||
|
// Stack of fire calls for repeatable lists
|
||||||
|
stack = [],
|
||||||
|
// Last fire value (for non-forgettable lists)
|
||||||
|
memory,
|
||||||
|
// Flag to know if list is currently firing
|
||||||
|
firing,
|
||||||
|
// First callback to fire (used internally by add and fireWith)
|
||||||
|
firingStart,
|
||||||
|
// End of the loop when firing
|
||||||
|
firingLength,
|
||||||
|
// Index of currently firing callback (modified by remove if needed)
|
||||||
|
firingIndex,
|
||||||
|
// Add one or several callbacks to the list
|
||||||
|
add = function( args ) {
|
||||||
|
var i,
|
||||||
|
length,
|
||||||
|
elem,
|
||||||
|
type,
|
||||||
|
actual;
|
||||||
|
for ( i = 0, length = args.length; i < length; i++ ) {
|
||||||
|
elem = args[ i ];
|
||||||
|
type = jQuery.type( elem );
|
||||||
|
if ( type === "array" ) {
|
||||||
|
// Inspect recursively
|
||||||
|
add( elem );
|
||||||
|
} else if ( type === "function" ) {
|
||||||
|
// If we have to relocate, we remove the callback
|
||||||
|
// if it already exists
|
||||||
|
if ( flags.relocate ) {
|
||||||
|
self.remove( elem );
|
||||||
|
// Skip if we're in unique mode and callback is already in
|
||||||
|
} else if ( flags.unique && self.has( elem ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Get the filtered function if needs be
|
||||||
|
actual = filter ? filter( elem ) : elem;
|
||||||
|
if ( actual ) {
|
||||||
|
list.push( [ elem, actual ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// Fire callbacks
|
||||||
|
fire = function( context, args ) {
|
||||||
|
args = args || [];
|
||||||
|
memory = !flags.memory || [ context, args ];
|
||||||
|
firing = true;
|
||||||
|
firingIndex = firingStart || 0;
|
||||||
|
firingStart = 0;
|
||||||
|
firingLength = list.length;
|
||||||
|
for ( ; list && firingIndex < firingLength; firingIndex++ ) {
|
||||||
|
if ( list[ firingIndex ][ 1 ].apply( context, args ) === false && flags.stopOnFalse ) {
|
||||||
|
memory = true; // Mark as halted
|
||||||
|
break;
|
||||||
|
} else if ( flags.queue ) {
|
||||||
|
list.splice( firingIndex, 1 );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
firing = false;
|
||||||
|
if ( list ) {
|
||||||
|
if ( !flags.once ) {
|
||||||
|
if ( stack && stack.length ) {
|
||||||
|
memory = stack.shift();
|
||||||
|
self.fireWith( memory[ 0 ], memory[ 1 ] );
|
||||||
|
}
|
||||||
|
} else if ( memory === true ) {
|
||||||
|
self.disable();
|
||||||
|
} else {
|
||||||
|
list = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// Actual Callbacks object
|
||||||
|
self = {
|
||||||
|
// Add a callback or a collection of callbacks to the list
|
||||||
|
add: function() {
|
||||||
|
if ( list ) {
|
||||||
|
var length = list.length;
|
||||||
|
add( arguments );
|
||||||
|
// Do we need to add the callbacks to the
|
||||||
|
// current firing batch?
|
||||||
|
if ( firing ) {
|
||||||
|
if ( !flags.addAfterFire ) {
|
||||||
|
firingLength = list.length;
|
||||||
|
}
|
||||||
|
// With memory, if we're not firing then
|
||||||
|
// we should call right away, unless previous
|
||||||
|
// firing was halted (stopOnFalse)
|
||||||
|
} else if ( memory && memory !== true ) {
|
||||||
|
firingStart = length;
|
||||||
|
fire( memory[ 0 ], memory[ 1 ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
// Remove a callback from the list
|
||||||
|
remove: function() {
|
||||||
|
if ( list ) {
|
||||||
|
var args = arguments,
|
||||||
|
argIndex = 0,
|
||||||
|
argLength = args.length;
|
||||||
|
for ( ; argIndex < argLength ; argIndex++ ) {
|
||||||
|
for ( var i = 0; i < list.length; i++ ) {
|
||||||
|
if ( args[ argIndex ] === list[ i ][ 0 ] ) {
|
||||||
|
// Handle firingIndex and firingLength
|
||||||
|
if ( firing ) {
|
||||||
|
if ( i <= firingLength ) {
|
||||||
|
firingLength--;
|
||||||
|
if ( i <= firingIndex ) {
|
||||||
|
firingIndex--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Remove the element
|
||||||
|
list.splice( i--, 1 );
|
||||||
|
// If we have some unicity property then
|
||||||
|
// we only need to do this once
|
||||||
|
if ( flags.unique || flags.relocate ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
// Control if a given callback is in the list
|
||||||
|
has: function( fn ) {
|
||||||
|
if ( list ) {
|
||||||
|
var i = 0,
|
||||||
|
length = list.length;
|
||||||
|
for ( ; i < length; i++ ) {
|
||||||
|
if ( fn === list[ i ][ 0 ] ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
// Remove all callbacks from the list
|
||||||
|
empty: function() {
|
||||||
|
list = [];
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
// Have the list do nothing anymore
|
||||||
|
disable: function() {
|
||||||
|
list = stack = memory = undefined;
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
// Is it disabled?
|
||||||
|
disabled: function() {
|
||||||
|
return !list;
|
||||||
|
},
|
||||||
|
// Lock the list in its current state
|
||||||
|
lock: function() {
|
||||||
|
stack = undefined;
|
||||||
|
if ( !memory || memory === true ) {
|
||||||
|
self.disable();
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
// Is it locked?
|
||||||
|
locked: function() {
|
||||||
|
return !stack;
|
||||||
|
},
|
||||||
|
// Call all callbacks with the given context and arguments
|
||||||
|
fireWith: function( context, args ) {
|
||||||
|
if ( stack ) {
|
||||||
|
if ( firing ) {
|
||||||
|
if ( !flags.once ) {
|
||||||
|
stack.push( [ context, args ] );
|
||||||
|
}
|
||||||
|
} else if ( !( flags.once && memory ) ) {
|
||||||
|
fire( context, args );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
// Call all the callbacks with the given arguments
|
||||||
|
fire: function() {
|
||||||
|
self.fireWith( this, arguments );
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
// To know if the callbacks have already been called at least once
|
||||||
|
fired: function() {
|
||||||
|
return !!memory;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return self;
|
||||||
|
};
|
||||||
|
|
||||||
|
})( jQuery );
|
11
src/core.js
11
src/core.js
|
@ -58,7 +58,7 @@ var jQuery = function( selector, context ) {
|
||||||
// For matching the engine and version of the browser
|
// For matching the engine and version of the browser
|
||||||
browserMatch,
|
browserMatch,
|
||||||
|
|
||||||
// The deferred used on DOM ready
|
// The callback list used on DOM ready
|
||||||
readyList,
|
readyList,
|
||||||
|
|
||||||
// The ready event handler
|
// The ready event handler
|
||||||
|
@ -257,7 +257,7 @@ jQuery.fn = jQuery.prototype = {
|
||||||
jQuery.bindReady();
|
jQuery.bindReady();
|
||||||
|
|
||||||
// Add the callback
|
// Add the callback
|
||||||
readyList.done( fn );
|
readyList.add( fn );
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
@ -412,7 +412,7 @@ jQuery.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there are functions bound, to execute
|
// If there are functions bound, to execute
|
||||||
readyList.resolveWith( document, [ jQuery ] );
|
readyList.fireWith( document, [ jQuery ] );
|
||||||
|
|
||||||
// Trigger any bound ready events
|
// Trigger any bound ready events
|
||||||
if ( jQuery.fn.trigger ) {
|
if ( jQuery.fn.trigger ) {
|
||||||
|
@ -426,7 +426,7 @@ jQuery.extend({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
readyList = jQuery._Deferred();
|
readyList = jQuery.Callbacks( "once memory" );
|
||||||
|
|
||||||
// Catch cases where $(document).ready() is called after the
|
// Catch cases where $(document).ready() is called after the
|
||||||
// browser event has already occurred.
|
// browser event has already occurred.
|
||||||
|
@ -792,7 +792,7 @@ jQuery.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
// Mutifunctional method to get and set values to a collection
|
// Mutifunctional method to get and set values to a collection
|
||||||
// The value/s can optionally be executed if it's a function
|
// The value/s can be optionally by executed if its a function
|
||||||
access: function( elems, key, value, exec, fn, pass ) {
|
access: function( elems, key, value, exec, fn, pass ) {
|
||||||
var length = elems.length;
|
var length = elems.length;
|
||||||
|
|
||||||
|
@ -923,6 +923,7 @@ function doScrollCheck() {
|
||||||
jQuery.ready();
|
jQuery.ready();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Expose jQuery to the global object
|
||||||
return jQuery;
|
return jQuery;
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
80
src/css.js
80
src/css.js
|
@ -50,14 +50,13 @@ jQuery.extend({
|
||||||
|
|
||||||
// Exclude the following css properties to add px
|
// Exclude the following css properties to add px
|
||||||
cssNumber: {
|
cssNumber: {
|
||||||
"fillOpacity": true,
|
|
||||||
"fontWeight": true,
|
|
||||||
"lineHeight": true,
|
|
||||||
"opacity": true,
|
|
||||||
"orphans": true,
|
|
||||||
"widows": true,
|
|
||||||
"zIndex": true,
|
"zIndex": true,
|
||||||
"zoom": true
|
"fontWeight": true,
|
||||||
|
"opacity": true,
|
||||||
|
"zoom": true,
|
||||||
|
"lineHeight": true,
|
||||||
|
"widows": true,
|
||||||
|
"orphans": true
|
||||||
},
|
},
|
||||||
|
|
||||||
// Add in properties whose names you wish to fix before
|
// Add in properties whose names you wish to fix before
|
||||||
|
@ -173,14 +172,36 @@ jQuery.each(["height", "width"], function( i, name ) {
|
||||||
|
|
||||||
if ( computed ) {
|
if ( computed ) {
|
||||||
if ( elem.offsetWidth !== 0 ) {
|
if ( elem.offsetWidth !== 0 ) {
|
||||||
return getWH( elem, name, extra );
|
val = getWH( elem, name, extra );
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
jQuery.swap( elem, cssShow, function() {
|
jQuery.swap( elem, cssShow, function() {
|
||||||
val = getWH( elem, name, extra );
|
val = getWH( elem, name, extra );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return val;
|
if ( val <= 0 ) {
|
||||||
|
val = curCSS( elem, name, name );
|
||||||
|
|
||||||
|
if ( val === "0px" && currentStyle ) {
|
||||||
|
val = currentStyle( elem, name, name );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( val != null ) {
|
||||||
|
// Should return "auto" instead of 0, use 0 for
|
||||||
|
// temporary backwards-compat
|
||||||
|
return val === "" || val === "auto" ? "0px" : val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( val < 0 || val == null ) {
|
||||||
|
val = elem.style[ name ];
|
||||||
|
// Should return "auto" instead of 0, use 0 for
|
||||||
|
// temporary backwards-compat
|
||||||
|
return val === "" || val === "auto" ? "0px" : val;
|
||||||
|
}
|
||||||
|
|
||||||
|
return typeof val === "string" ? val : val + "px";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -310,50 +331,27 @@ if ( document.documentElement.currentStyle ) {
|
||||||
curCSS = getComputedStyle || currentStyle;
|
curCSS = getComputedStyle || currentStyle;
|
||||||
|
|
||||||
function getWH( elem, name, extra ) {
|
function getWH( elem, name, extra ) {
|
||||||
|
var which = name === "width" ? cssWidth : cssHeight,
|
||||||
|
val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
|
||||||
|
|
||||||
// Start with offset property
|
if ( extra === "border" ) {
|
||||||
var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
|
return val;
|
||||||
which = name === "width" ? cssWidth : cssHeight;
|
}
|
||||||
|
|
||||||
if ( val > 0 ) {
|
|
||||||
if ( extra !== "border" ) {
|
|
||||||
jQuery.each( which, function() {
|
jQuery.each( which, function() {
|
||||||
if ( !extra ) {
|
if ( !extra ) {
|
||||||
val -= parseFloat(jQuery.css( elem, "padding" + this )) || 0;
|
val -= parseFloat(jQuery.css( elem, "padding" + this )) || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( extra === "margin" ) {
|
if ( extra === "margin" ) {
|
||||||
val += parseFloat( jQuery.css( elem, extra + this ) ) || 0;
|
val += parseFloat(jQuery.css( elem, "margin" + this )) || 0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
val -= parseFloat(jQuery.css( elem, "border" + this + "Width" )) || 0;
|
val -= parseFloat(jQuery.css( elem, "border" + this + "Width" )) || 0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
return val + "px";
|
return val;
|
||||||
}
|
|
||||||
|
|
||||||
// Fall back to computed then uncomputed css if necessary
|
|
||||||
val = curCSS( elem, name, name );
|
|
||||||
if ( val < 0 || val == null ) {
|
|
||||||
val = elem.style[ name ] || 0;
|
|
||||||
}
|
|
||||||
// Normalize "", auto, and prepare for extra
|
|
||||||
val = parseFloat( val ) || 0;
|
|
||||||
|
|
||||||
// Add padding, border, margin
|
|
||||||
if ( extra ) {
|
|
||||||
jQuery.each( which, function() {
|
|
||||||
val += parseFloat( jQuery.css( elem, "padding" + this ) ) || 0;
|
|
||||||
if ( extra !== "padding" ) {
|
|
||||||
val += parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0;
|
|
||||||
}
|
|
||||||
if ( extra === "margin" ) {
|
|
||||||
val += parseFloat( jQuery.css( elem, extra + this ) ) || 0;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return val + "px";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( jQuery.expr && jQuery.expr.filters ) {
|
if ( jQuery.expr && jQuery.expr.filters ) {
|
||||||
|
|
|
@ -108,10 +108,7 @@ jQuery.extend({
|
||||||
return thisCache[ internalKey ] && thisCache[ internalKey ].events;
|
return thisCache[ internalKey ] && thisCache[ internalKey ].events;
|
||||||
}
|
}
|
||||||
|
|
||||||
return getByName ?
|
return getByName ? thisCache[ jQuery.camelCase( name ) ] : thisCache;
|
||||||
// Check for both converted-to-camel and non-converted data property names
|
|
||||||
thisCache[ jQuery.camelCase( name ) ] || thisCache[ name ] :
|
|
||||||
thisCache;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
removeData: function( elem, name, pvt /* Internal Use Only */ ) {
|
removeData: function( elem, name, pvt /* Internal Use Only */ ) {
|
||||||
|
|
166
src/deferred.js
166
src/deferred.js
|
@ -1,117 +1,48 @@
|
||||||
(function( jQuery ) {
|
(function( jQuery ) {
|
||||||
|
|
||||||
var // Promise methods
|
var // Promise methods
|
||||||
promiseMethods = "done fail isResolved isRejected promise then always pipe".split( " " ),
|
promiseMethods = "done removeDone fail removeFail progress removeProgress isResolved isRejected promise then always pipe".split( " " ),
|
||||||
// Static reference to slice
|
// Static reference to slice
|
||||||
sliceDeferred = [].slice;
|
sliceDeferred = [].slice;
|
||||||
|
|
||||||
jQuery.extend({
|
jQuery.extend({
|
||||||
// Create a simple deferred (one callbacks list)
|
|
||||||
_Deferred: function() {
|
|
||||||
var // callbacks list
|
|
||||||
callbacks = [],
|
|
||||||
// stored [ context , args ]
|
|
||||||
fired,
|
|
||||||
// to avoid firing when already doing so
|
|
||||||
firing,
|
|
||||||
// flag to know if the deferred has been cancelled
|
|
||||||
cancelled,
|
|
||||||
// the deferred itself
|
|
||||||
deferred = {
|
|
||||||
|
|
||||||
// done( f1, f2, ...)
|
|
||||||
done: function() {
|
|
||||||
if ( !cancelled ) {
|
|
||||||
var args = arguments,
|
|
||||||
i,
|
|
||||||
length,
|
|
||||||
elem,
|
|
||||||
type,
|
|
||||||
_fired;
|
|
||||||
if ( fired ) {
|
|
||||||
_fired = fired;
|
|
||||||
fired = 0;
|
|
||||||
}
|
|
||||||
for ( i = 0, length = args.length; i < length; i++ ) {
|
|
||||||
elem = args[ i ];
|
|
||||||
type = jQuery.type( elem );
|
|
||||||
if ( type === "array" ) {
|
|
||||||
deferred.done.apply( deferred, elem );
|
|
||||||
} else if ( type === "function" ) {
|
|
||||||
callbacks.push( elem );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( _fired ) {
|
|
||||||
deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
},
|
|
||||||
|
|
||||||
// resolve with given context and args
|
|
||||||
resolveWith: function( context, args ) {
|
|
||||||
if ( !cancelled && !fired && !firing ) {
|
|
||||||
// make sure args are available (#8421)
|
|
||||||
args = args || [];
|
|
||||||
firing = 1;
|
|
||||||
try {
|
|
||||||
while( callbacks[ 0 ] ) {
|
|
||||||
callbacks.shift().apply( context, args );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
fired = [ context, args ];
|
|
||||||
firing = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
},
|
|
||||||
|
|
||||||
// resolve with this as context and given arguments
|
|
||||||
resolve: function() {
|
|
||||||
deferred.resolveWith( this, arguments );
|
|
||||||
return this;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Has this deferred been resolved?
|
|
||||||
isResolved: function() {
|
|
||||||
return !!( firing || fired );
|
|
||||||
},
|
|
||||||
|
|
||||||
// Cancel
|
|
||||||
cancel: function() {
|
|
||||||
cancelled = 1;
|
|
||||||
callbacks = [];
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return deferred;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Full fledged deferred (two callbacks list)
|
|
||||||
Deferred: function( func ) {
|
Deferred: function( func ) {
|
||||||
var deferred = jQuery._Deferred(),
|
var doneList = jQuery.Callbacks( "once memory" ),
|
||||||
failDeferred = jQuery._Deferred(),
|
failList = jQuery.Callbacks( "once memory" ),
|
||||||
promise;
|
progressList = jQuery.Callbacks( "memory" ),
|
||||||
// Add errorDeferred methods, then and promise
|
promise,
|
||||||
jQuery.extend( deferred, {
|
deferred = {
|
||||||
then: function( doneCallbacks, failCallbacks ) {
|
// Copy existing methods from lists
|
||||||
deferred.done( doneCallbacks ).fail( failCallbacks );
|
done: doneList.add,
|
||||||
|
removeDone: doneList.remove,
|
||||||
|
fail: failList.add,
|
||||||
|
removeFail: failList.remove,
|
||||||
|
progress: progressList.add,
|
||||||
|
removeProgress: progressList.remove,
|
||||||
|
resolve: doneList.fire,
|
||||||
|
resolveWith: doneList.fireWith,
|
||||||
|
reject: failList.fire,
|
||||||
|
rejectWith: failList.fireWith,
|
||||||
|
ping: progressList.fire,
|
||||||
|
pingWith: progressList.fireWith,
|
||||||
|
isResolved: doneList.fired,
|
||||||
|
isRejected: failList.fired,
|
||||||
|
|
||||||
|
// Create Deferred-specific methods
|
||||||
|
then: function( doneCallbacks, failCallbacks, progressCallbacks ) {
|
||||||
|
deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks );
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
always: function() {
|
always: function() {
|
||||||
return deferred.done.apply( deferred, arguments ).fail.apply( this, arguments );
|
return deferred.done.apply( deferred, arguments ).fail.apply( this, arguments );
|
||||||
},
|
},
|
||||||
fail: failDeferred.done,
|
pipe: function( fnDone, fnFail, fnProgress ) {
|
||||||
rejectWith: failDeferred.resolveWith,
|
|
||||||
reject: failDeferred.resolve,
|
|
||||||
isRejected: failDeferred.isResolved,
|
|
||||||
pipe: function( fnDone, fnFail ) {
|
|
||||||
return jQuery.Deferred(function( newDefer ) {
|
return jQuery.Deferred(function( newDefer ) {
|
||||||
jQuery.each( {
|
jQuery.each( {
|
||||||
done: [ fnDone, "resolve" ],
|
done: [ fnDone, "resolve" ],
|
||||||
fail: [ fnFail, "reject" ]
|
fail: [ fnFail, "reject" ],
|
||||||
|
progress: [ fnProgress, "ping" ]
|
||||||
}, function( handler, data ) {
|
}, function( handler, data ) {
|
||||||
var fn = data[ 0 ],
|
var fn = data[ 0 ],
|
||||||
action = data[ 1 ],
|
action = data[ 1 ],
|
||||||
|
@ -120,9 +51,9 @@ jQuery.extend({
|
||||||
deferred[ handler ](function() {
|
deferred[ handler ](function() {
|
||||||
returned = fn.apply( this, arguments );
|
returned = fn.apply( this, arguments );
|
||||||
if ( returned && jQuery.isFunction( returned.promise ) ) {
|
if ( returned && jQuery.isFunction( returned.promise ) ) {
|
||||||
returned.promise().then( newDefer.resolve, newDefer.reject );
|
returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.ping );
|
||||||
} else {
|
} else {
|
||||||
newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
|
newDefer[ action ]( returned );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -146,42 +77,51 @@ jQuery.extend({
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
// Make sure only one callback list will be used
|
|
||||||
deferred.done( failDeferred.cancel ).fail( deferred.cancel );
|
// Handle lists exclusiveness
|
||||||
// Unexpose cancel
|
deferred.done( failList.disable, progressList.lock )
|
||||||
delete deferred.cancel;
|
.fail( doneList.disable, progressList.lock );
|
||||||
|
|
||||||
// Call given func if any
|
// Call given func if any
|
||||||
if ( func ) {
|
if ( func ) {
|
||||||
func.call( deferred, deferred );
|
func.call( deferred, deferred );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// All done!
|
||||||
return deferred;
|
return deferred;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Deferred helper
|
// Deferred helper
|
||||||
when: function( firstParam ) {
|
when: function( firstParam ) {
|
||||||
var args = arguments,
|
var args = sliceDeferred.call( arguments, 0 ),
|
||||||
i = 0,
|
i = 0,
|
||||||
length = args.length,
|
length = args.length,
|
||||||
|
pValues = new Array( length ),
|
||||||
count = length,
|
count = length,
|
||||||
|
pCount = length,
|
||||||
deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
|
deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
|
||||||
firstParam :
|
firstParam :
|
||||||
jQuery.Deferred();
|
jQuery.Deferred(),
|
||||||
|
promise = deferred.promise();
|
||||||
function resolveFunc( i ) {
|
function resolveFunc( i ) {
|
||||||
return function( value ) {
|
return function( value ) {
|
||||||
args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
|
args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
|
||||||
if ( !( --count ) ) {
|
if ( !( --count ) ) {
|
||||||
// Strange bug in FF4:
|
deferred.resolveWith( deferred, args );
|
||||||
// Values changed onto the arguments object sometimes end up as undefined values
|
|
||||||
// outside the $.when method. Cloning the object into a fresh array solves the issue
|
|
||||||
deferred.resolveWith( deferred, sliceDeferred.call( args, 0 ) );
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
function progressFunc( i ) {
|
||||||
|
return function( value ) {
|
||||||
|
pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
|
||||||
|
deferred.pingWith( promise, pValues );
|
||||||
|
};
|
||||||
|
}
|
||||||
if ( length > 1 ) {
|
if ( length > 1 ) {
|
||||||
for( ; i < length; i++ ) {
|
for( ; i < length; i++ ) {
|
||||||
if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) {
|
if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) {
|
||||||
args[ i ].promise().then( resolveFunc(i), deferred.reject );
|
args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) );
|
||||||
} else {
|
} else {
|
||||||
--count;
|
--count;
|
||||||
}
|
}
|
||||||
|
@ -192,7 +132,7 @@ jQuery.extend({
|
||||||
} else if ( deferred !== firstParam ) {
|
} else if ( deferred !== firstParam ) {
|
||||||
deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
|
deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
|
||||||
}
|
}
|
||||||
return deferred.promise();
|
return promise;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
(function( jQuery ) {
|
(function( jQuery ) {
|
||||||
|
|
||||||
// Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods
|
// Create innerHeight, innerWidth, outerHeight and outerWidth methods
|
||||||
jQuery.each([ "Height", "Width" ], function( i, name ) {
|
jQuery.each([ "Height", "Width" ], function( i, name ) {
|
||||||
|
|
||||||
var type = name.toLowerCase();
|
var type = name.toLowerCase();
|
||||||
|
|
2
src/effects.js
vendored
2
src/effects.js
vendored
|
@ -411,7 +411,7 @@ jQuery.fx.prototype = {
|
||||||
if ( t() && jQuery.timers.push(t) && !timerId ) {
|
if ( t() && jQuery.timers.push(t) && !timerId ) {
|
||||||
// Use requestAnimationFrame instead of setInterval if available
|
// Use requestAnimationFrame instead of setInterval if available
|
||||||
if ( requestAnimationFrame ) {
|
if ( requestAnimationFrame ) {
|
||||||
timerId = true;
|
timerId = 1;
|
||||||
raf = function() {
|
raf = function() {
|
||||||
// When timerId gets set to null at any point, this stops
|
// When timerId gets set to null at any point, this stops
|
||||||
if ( timerId ) {
|
if ( timerId ) {
|
||||||
|
|
32
src/event.js
32
src/event.js
|
@ -1,6 +1,7 @@
|
||||||
(function( jQuery ) {
|
(function( jQuery ) {
|
||||||
|
|
||||||
var rnamespaces = /\.(.*)$/,
|
var hasOwn = Object.prototype.hasOwnProperty,
|
||||||
|
rnamespaces = /\.(.*)$/,
|
||||||
rformElems = /^(?:textarea|input|select)$/i,
|
rformElems = /^(?:textarea|input|select)$/i,
|
||||||
rperiod = /\./g,
|
rperiod = /\./g,
|
||||||
rspaces = / /g,
|
rspaces = / /g,
|
||||||
|
@ -650,27 +651,34 @@ jQuery.Event.prototype = {
|
||||||
// Checks if an event happened on an element within another element
|
// Checks if an event happened on an element within another element
|
||||||
// Used in jQuery.event.special.mouseenter and mouseleave handlers
|
// Used in jQuery.event.special.mouseenter and mouseleave handlers
|
||||||
var withinElement = function( event ) {
|
var withinElement = function( event ) {
|
||||||
|
|
||||||
// Check if mouse(over|out) are still within the same parent element
|
// Check if mouse(over|out) are still within the same parent element
|
||||||
var related = event.relatedTarget,
|
var parent = event.relatedTarget;
|
||||||
inside = false,
|
|
||||||
eventType = event.type;
|
|
||||||
|
|
||||||
|
// set the correct event type
|
||||||
event.type = event.data;
|
event.type = event.data;
|
||||||
|
|
||||||
if ( related !== this ) {
|
// Firefox sometimes assigns relatedTarget a XUL element
|
||||||
|
// which we cannot access the parentNode property of
|
||||||
|
try {
|
||||||
|
|
||||||
if ( related ) {
|
// Chrome does something similar, the parentNode property
|
||||||
inside = jQuery.contains( this, related );
|
// can be accessed but is null.
|
||||||
|
if ( parent && parent !== document && !parent.parentNode ) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !inside ) {
|
// Traverse up the tree
|
||||||
|
while ( parent && parent !== this ) {
|
||||||
|
parent = parent.parentNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( parent !== this ) {
|
||||||
|
// handle event if we actually just moused on to a non sub-element
|
||||||
jQuery.event.handle.apply( this, arguments );
|
jQuery.event.handle.apply( this, arguments );
|
||||||
|
}
|
||||||
|
|
||||||
event.type = eventType;
|
// assuming we've left the element since we most likely mousedover a xul element
|
||||||
}
|
} catch(e) { }
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// In case of event delegation, we only need to rename the event.type,
|
// In case of event delegation, we only need to rename the event.type,
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
// Expose jQuery to the global object
|
|
||||||
window.jQuery = window.$ = jQuery;
|
window.jQuery = window.$ = jQuery;
|
||||||
})(window);
|
})(window);
|
||||||
|
|
16
src/queue.js
16
src/queue.js
|
@ -1,7 +1,7 @@
|
||||||
(function( jQuery ) {
|
(function( jQuery ) {
|
||||||
|
|
||||||
function handleQueueMarkDefer( elem, type, src ) {
|
function handleCBList( elem, type, src ) {
|
||||||
var deferDataKey = type + "defer",
|
var deferDataKey = type + "cblst",
|
||||||
queueDataKey = type + "queue",
|
queueDataKey = type + "queue",
|
||||||
markDataKey = type + "mark",
|
markDataKey = type + "mark",
|
||||||
defer = jQuery.data( elem, deferDataKey, undefined, true );
|
defer = jQuery.data( elem, deferDataKey, undefined, true );
|
||||||
|
@ -14,7 +14,7 @@ function handleQueueMarkDefer( elem, type, src ) {
|
||||||
if ( !jQuery.data( elem, queueDataKey, undefined, true ) &&
|
if ( !jQuery.data( elem, queueDataKey, undefined, true ) &&
|
||||||
!jQuery.data( elem, markDataKey, undefined, true ) ) {
|
!jQuery.data( elem, markDataKey, undefined, true ) ) {
|
||||||
jQuery.removeData( elem, deferDataKey, true );
|
jQuery.removeData( elem, deferDataKey, true );
|
||||||
defer.resolve();
|
defer.fireWith();
|
||||||
}
|
}
|
||||||
}, 0 );
|
}, 0 );
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ jQuery.extend({
|
||||||
jQuery.data( elem, key, count, true );
|
jQuery.data( elem, key, count, true );
|
||||||
} else {
|
} else {
|
||||||
jQuery.removeData( elem, key, true );
|
jQuery.removeData( elem, key, true );
|
||||||
handleQueueMarkDefer( elem, type, "mark" );
|
handleCBList( elem, type, "mark" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -90,7 +90,7 @@ jQuery.extend({
|
||||||
|
|
||||||
if ( !queue.length ) {
|
if ( !queue.length ) {
|
||||||
jQuery.removeData( elem, type + "queue", true );
|
jQuery.removeData( elem, type + "queue", true );
|
||||||
handleQueueMarkDefer( elem, type, "queue" );
|
handleCBList( elem, type, "queue" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -146,7 +146,7 @@ jQuery.fn.extend({
|
||||||
elements = this,
|
elements = this,
|
||||||
i = elements.length,
|
i = elements.length,
|
||||||
count = 1,
|
count = 1,
|
||||||
deferDataKey = type + "defer",
|
deferDataKey = type + "cblst",
|
||||||
queueDataKey = type + "queue",
|
queueDataKey = type + "queue",
|
||||||
markDataKey = type + "mark",
|
markDataKey = type + "mark",
|
||||||
tmp;
|
tmp;
|
||||||
|
@ -159,9 +159,9 @@ jQuery.fn.extend({
|
||||||
if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
|
if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
|
||||||
( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
|
( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
|
||||||
jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
|
jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
|
||||||
jQuery.data( elements[ i ], deferDataKey, jQuery._Deferred(), true ) )) {
|
jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) {
|
||||||
count++;
|
count++;
|
||||||
tmp.done( resolve );
|
tmp.add( resolve );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
|
|
|
@ -245,7 +245,7 @@ jQuery.support = (function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Null connected elements to avoid leaks in IE
|
// Null connected elements to avoid leaks in IE
|
||||||
testElement = fragment = select = opt = body = marginDiv = div = input = null;
|
marginDiv = div = input = null;
|
||||||
|
|
||||||
return support;
|
return support;
|
||||||
})();
|
})();
|
||||||
|
|
45
src/topic.js
Normal file
45
src/topic.js
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
(function( jQuery ) {
|
||||||
|
|
||||||
|
var topics = {},
|
||||||
|
sliceTopic = [].slice;
|
||||||
|
|
||||||
|
jQuery.Topic = function( id ) {
|
||||||
|
var callbacks,
|
||||||
|
method,
|
||||||
|
topic = id && topics[ id ];
|
||||||
|
if ( !topic ) {
|
||||||
|
callbacks = jQuery.Callbacks();
|
||||||
|
topic = {
|
||||||
|
publish: callbacks.fire,
|
||||||
|
subscribe: callbacks.add,
|
||||||
|
unsubscribe: callbacks.remove
|
||||||
|
};
|
||||||
|
if ( id ) {
|
||||||
|
topics[ id ] = topic;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return topic;
|
||||||
|
};
|
||||||
|
|
||||||
|
jQuery.extend({
|
||||||
|
subscribe: function( id ) {
|
||||||
|
var topic = jQuery.Topic( id ),
|
||||||
|
args = sliceTopic.call( arguments, 1 );
|
||||||
|
topic.subscribe.apply( topic, args );
|
||||||
|
return {
|
||||||
|
topic: topic,
|
||||||
|
args: args
|
||||||
|
};
|
||||||
|
},
|
||||||
|
unsubscribe: function( id ) {
|
||||||
|
var topic = id && id.topic || jQuery.Topic( id );
|
||||||
|
topic.unsubscribe.apply( topic, id && id.args ||
|
||||||
|
sliceTopic.call( arguments, 1 ) );
|
||||||
|
},
|
||||||
|
publish: function( id ) {
|
||||||
|
var topic = jQuery.Topic( id );
|
||||||
|
topic.publish.apply( topic, sliceTopic.call( arguments, 1 ) );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
})( jQuery );
|
114
test/abortonunload.php
Normal file
114
test/abortonunload.php
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
<?php sleep(3) ?><!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>
|
||||||
|
jQuery Abort-On-Unload Test
|
||||||
|
</title>
|
||||||
|
<style>
|
||||||
|
div { margin-top: 10px; }
|
||||||
|
.alphalist { list-style-type: upper-alpha; }
|
||||||
|
</style>
|
||||||
|
<script src="../src/core.js"></script>
|
||||||
|
<script src="../src/deferred.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">
|
||||||
|
$( function() {
|
||||||
|
var done = true,
|
||||||
|
button = $( "button" );
|
||||||
|
button.click(function() {
|
||||||
|
jQuery.ajax({
|
||||||
|
url: "data/name.php?wait=10",
|
||||||
|
cache: false,
|
||||||
|
beforeSend: function() {
|
||||||
|
button.attr( "disabled" , true );
|
||||||
|
done = false;
|
||||||
|
},
|
||||||
|
success: function() {
|
||||||
|
console.log( "success", arguments );
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
console.log( "error", arguments );
|
||||||
|
alert( "error" );
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
button.attr( "disabled" , false );
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
document.location = document.location.href;
|
||||||
|
});
|
||||||
|
jQuery( window ).bind( "beforeunload", function( evt ) {
|
||||||
|
if ( !done ) {
|
||||||
|
return evt.returnValue = "Fire unload?";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>
|
||||||
|
jQuery Abort-On-Unload Test
|
||||||
|
</h1>
|
||||||
|
<div>
|
||||||
|
This page tests a fix that will abort requests on abort so that Internet Explorer
|
||||||
|
does not keep connections alive.
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
In this situation, no callback should be triggered.
|
||||||
|
</div>
|
||||||
|
<div>Take the following steps:</div>
|
||||||
|
<ol>
|
||||||
|
<li>
|
||||||
|
open the console,
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
set it to persistent mode if available,
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
click this
|
||||||
|
<button>
|
||||||
|
button
|
||||||
|
</button>
|
||||||
|
to make a request and trigger the beforeunload event,
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
then either:
|
||||||
|
<ol class="alphalist">
|
||||||
|
<li>
|
||||||
|
wait for the request to complete then cancel unload,
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
fire unload (you have 10 seconds to do so).
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
<div>
|
||||||
|
Test passes if:
|
||||||
|
<ol class="alphalist">
|
||||||
|
<li>
|
||||||
|
you get a "success" logged,
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
you get no "error" log and no alert.
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<dashboard>
|
<dashboard>
|
||||||
<locations class="foo">
|
<locations class="foo">
|
||||||
<location for="bar" checked="different">
|
<location for="bar">
|
||||||
<infowindowtab>
|
<infowindowtab>
|
||||||
<tab title="Location"><![CDATA[blabla]]></tab>
|
<tab title="Location"><![CDATA[blabla]]></tab>
|
||||||
<tab title="Users"><![CDATA[blublu]]></tab>
|
<tab title="Users"><![CDATA[blublu]]></tab>
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#positionTest { position: absolute; }
|
#positionTest { position: absolute; }
|
||||||
</style>
|
</style>
|
||||||
<script src="../../../src/core.js"></script>
|
<script src="../../../src/core.js"></script>
|
||||||
<script src="../../../src/deferred.js"></script>
|
<script src="../../../src/callbacks.js"></script>
|
||||||
<script src="../../../src/support.js"></script>
|
<script src="../../../src/support.js"></script>
|
||||||
<script src="../../../src/sizzle/sizzle.js"></script>
|
<script src="../../../src/sizzle/sizzle.js"></script>
|
||||||
<script src="../../../src/sizzle-jquery.js"></script>
|
<script src="../../../src/sizzle-jquery.js"></script>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
|
#marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
|
||||||
</style>
|
</style>
|
||||||
<script src="../../../src/core.js"></script>
|
<script src="../../../src/core.js"></script>
|
||||||
<script src="../../../src/deferred.js"></script>
|
<script src="../../../src/callbacks.js"></script>
|
||||||
<script src="../../../src/support.js"></script>
|
<script src="../../../src/support.js"></script>
|
||||||
<script src="../../../src/sizzle/sizzle.js"></script>
|
<script src="../../../src/sizzle/sizzle.js"></script>
|
||||||
<script src="../../../src/sizzle-jquery.js"></script>
|
<script src="../../../src/sizzle-jquery.js"></script>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
|
#marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
|
||||||
</style>
|
</style>
|
||||||
<script src="../../../src/core.js"></script>
|
<script src="../../../src/core.js"></script>
|
||||||
<script src="../../../src/deferred.js"></script>
|
<script src="../../../src/callbacks.js"></script>
|
||||||
<script src="../../../src/support.js"></script>
|
<script src="../../../src/support.js"></script>
|
||||||
<script src="../../../src/sizzle/sizzle.js"></script>
|
<script src="../../../src/sizzle/sizzle.js"></script>
|
||||||
<script src="../../../src/sizzle-jquery.js"></script>
|
<script src="../../../src/sizzle-jquery.js"></script>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
|
#marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
|
||||||
</style>
|
</style>
|
||||||
<script src="../../../src/core.js"></script>
|
<script src="../../../src/core.js"></script>
|
||||||
<script src="../../../src/deferred.js"></script>
|
<script src="../../../src/callbacks.js"></script>
|
||||||
<script src="../../../src/support.js"></script>
|
<script src="../../../src/support.js"></script>
|
||||||
<script src="../../../src/sizzle/sizzle.js"></script>
|
<script src="../../../src/sizzle/sizzle.js"></script>
|
||||||
<script src="../../../src/sizzle-jquery.js"></script>
|
<script src="../../../src/sizzle-jquery.js"></script>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
|
#marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
|
||||||
</style>
|
</style>
|
||||||
<script src="../../../src/core.js"></script>
|
<script src="../../../src/core.js"></script>
|
||||||
<script src="../../../src/deferred.js"></script>
|
<script src="../../../src/callbacks.js"></script>
|
||||||
<script src="../../../src/support.js"></script>
|
<script src="../../../src/support.js"></script>
|
||||||
<script src="../../../src/sizzle/sizzle.js"></script>
|
<script src="../../../src/sizzle/sizzle.js"></script>
|
||||||
<script src="../../../src/sizzle-jquery.js"></script>
|
<script src="../../../src/sizzle-jquery.js"></script>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
|
#marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
|
||||||
</style>
|
</style>
|
||||||
<script src="../../../src/core.js"></script>
|
<script src="../../../src/core.js"></script>
|
||||||
<script src="../../../src/deferred.js"></script>
|
<script src="../../../src/callbacks.js"></script>
|
||||||
<script src="../../../src/support.js"></script>
|
<script src="../../../src/support.js"></script>
|
||||||
<script src="../../../src/sizzle/sizzle.js"></script>
|
<script src="../../../src/sizzle/sizzle.js"></script>
|
||||||
<script src="../../../src/sizzle-jquery.js"></script>
|
<script src="../../../src/sizzle-jquery.js"></script>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
|
#marker { position: absolute; border: 2px solid #000; width: 50px; height: 50px; background: #ccc; }
|
||||||
</style>
|
</style>
|
||||||
<script src="../../../src/core.js"></script>
|
<script src="../../../src/core.js"></script>
|
||||||
<script src="../../../src/deferred.js"></script>
|
<script src="../../../src/callbacks.js"></script>
|
||||||
<script src="../../../src/support.js"></script>
|
<script src="../../../src/support.js"></script>
|
||||||
<script src="../../../src/sizzle/sizzle.js"></script>
|
<script src="../../../src/sizzle/sizzle.js"></script>
|
||||||
<script src="../../../src/sizzle-jquery.js"></script>
|
<script src="../../../src/sizzle-jquery.js"></script>
|
||||||
|
|
|
@ -119,5 +119,5 @@ sup { display: none; }
|
||||||
dfn { display: none; }
|
dfn { display: none; }
|
||||||
|
|
||||||
/* #9239 Attach a background to the body( avoid crashes in removing the test element in support ) */
|
/* #9239 Attach a background to the body( avoid crashes in removing the test element in support ) */
|
||||||
body, div { background: url(http://static.jquery.com/files/rocker/images/logo_jquery_215x53.gif) no-repeat -1000px 0; }
|
body, div { background: url(http://www.ctemploymentlawblog.com/test.jpg) no-repeat -1000px 0; }
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
<script src="data/testinit.js"></script>
|
<script src="data/testinit.js"></script>
|
||||||
|
|
||||||
<script src="../src/core.js"></script>
|
<script src="../src/core.js"></script>
|
||||||
|
<script src="../src/callbacks.js"></script>
|
||||||
|
<script src="../src/topic.js"></script>
|
||||||
<script src="../src/deferred.js"></script>
|
<script src="../src/deferred.js"></script>
|
||||||
<script src="../src/support.js"></script>
|
<script src="../src/support.js"></script>
|
||||||
<script src="../src/data.js"></script>
|
<script src="../src/data.js"></script>
|
||||||
|
@ -34,8 +36,10 @@
|
||||||
<script src="data/testrunner.js"></script>
|
<script src="data/testrunner.js"></script>
|
||||||
|
|
||||||
<script src="unit/core.js"></script>
|
<script src="unit/core.js"></script>
|
||||||
<script src="unit/support.js"></script>
|
<script src="unit/callbacks.js"></script>
|
||||||
|
<script src="unit/topic.js"></script>
|
||||||
<script src="unit/deferred.js"></script>
|
<script src="unit/deferred.js"></script>
|
||||||
|
<script src="unit/support.js"></script>
|
||||||
<script src="unit/data.js"></script>
|
<script src="unit/data.js"></script>
|
||||||
<script src="unit/queue.js"></script>
|
<script src="unit/queue.js"></script>
|
||||||
<script src="unit/attributes.js"></script>
|
<script src="unit/attributes.js"></script>
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit d4f23f8a882d13b71768503e2db9fa33ef169ba0
|
Subproject commit d97b37ec322136406790e75d03333559f38bbecb
|
|
@ -321,40 +321,25 @@ test("jQuery.ajax() - responseText on error", function() {
|
||||||
|
|
||||||
test(".ajax() - retry with jQuery.ajax( this )", function() {
|
test(".ajax() - retry with jQuery.ajax( this )", function() {
|
||||||
|
|
||||||
expect( 2 );
|
expect( 1 );
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
var firstTime = true,
|
var firstTime = 1;
|
||||||
previousUrl;
|
|
||||||
|
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: url("data/errorWithText.php"),
|
url: url("data/errorWithText.php"),
|
||||||
error: function() {
|
error: function() {
|
||||||
if ( firstTime ) {
|
if ( firstTime ) {
|
||||||
firstTime = false;
|
firstTime = 0;
|
||||||
jQuery.ajax( this );
|
jQuery.ajax( this );
|
||||||
} else {
|
} else {
|
||||||
ok( true , "Test retrying with jQuery.ajax(this) works" );
|
ok( true , "Test retrying with jQuery.ajax(this) works" );
|
||||||
jQuery.ajax({
|
|
||||||
url: url("data/errorWithText.php"),
|
|
||||||
data: { x: 1 },
|
|
||||||
beforeSend: function() {
|
|
||||||
if ( !previousUrl ) {
|
|
||||||
previousUrl = this.url;
|
|
||||||
} else {
|
|
||||||
strictEqual( this.url , previousUrl, "url parameters are not re-appended" );
|
|
||||||
start();
|
start();
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function() {
|
|
||||||
jQuery.ajax( this );
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test(".ajax() - headers" , function() {
|
test(".ajax() - headers" , function() {
|
||||||
|
|
|
@ -132,12 +132,11 @@ test("attr(String)", function() {
|
||||||
|
|
||||||
if ( !isLocal ) {
|
if ( !isLocal ) {
|
||||||
test("attr(String) in XML Files", function() {
|
test("attr(String) in XML Files", function() {
|
||||||
expect(3);
|
expect(2);
|
||||||
stop();
|
stop();
|
||||||
jQuery.get("data/dashboard.xml", function( xml ) {
|
jQuery.get("data/dashboard.xml", function( xml ) {
|
||||||
equal( jQuery( "locations", xml ).attr("class"), "foo", "Check class attribute in XML document" );
|
equals( jQuery( "locations", xml ).attr("class"), "foo", "Check class attribute in XML document" );
|
||||||
equal( jQuery( "location", xml ).attr("for"), "bar", "Check for attribute in XML document" );
|
equals( jQuery( "location", xml ).attr("for"), "bar", "Check for attribute in XML document" );
|
||||||
equal( jQuery( "location", xml ).attr("checked"), "different", "Check that hooks are not attached in XML document" );
|
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -762,15 +761,12 @@ test("val(select) after form.reset() (Bug #2551)", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
var testAddClass = function(valueObj) {
|
var testAddClass = function(valueObj) {
|
||||||
expect(9);
|
expect(5);
|
||||||
|
|
||||||
var div = jQuery("div");
|
var div = jQuery("div");
|
||||||
div.addClass( valueObj("test") );
|
div.addClass( valueObj("test") );
|
||||||
var pass = true;
|
var pass = true;
|
||||||
for ( var i = 0; i < div.size(); i++ ) {
|
for ( var i = 0; i < div.size(); i++ ) {
|
||||||
if ( !~div.get(i).className.indexOf("test") ) {
|
if ( div.get(i).className.indexOf("test") == -1 ) pass = false;
|
||||||
pass = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ok( pass, "Add Class" );
|
ok( pass, "Add Class" );
|
||||||
|
|
||||||
|
@ -791,19 +787,6 @@ var testAddClass = function(valueObj) {
|
||||||
div.attr("class", "foo");
|
div.attr("class", "foo");
|
||||||
div.addClass( valueObj("bar baz") );
|
div.addClass( valueObj("bar baz") );
|
||||||
equals( div.attr("class"), "foo bar baz", "Make sure there isn't too much trimming." );
|
equals( div.attr("class"), "foo bar baz", "Make sure there isn't too much trimming." );
|
||||||
|
|
||||||
div.removeClass();
|
|
||||||
div.addClass( valueObj("foo") ).addClass( valueObj("foo") )
|
|
||||||
equal( div.attr("class"), "foo", "Do not add the same class twice in separate calls." );
|
|
||||||
|
|
||||||
div.addClass( valueObj("fo") );
|
|
||||||
equal( div.attr("class"), "foo fo", "Adding a similar class does not get interrupted." );
|
|
||||||
div.removeClass().addClass("wrap2");
|
|
||||||
ok( div.addClass("wrap").hasClass("wrap"), "Can add similarly named classes");
|
|
||||||
|
|
||||||
div.removeClass();
|
|
||||||
div.addClass( valueObj("bar bar") );
|
|
||||||
equal( div.attr("class"), "bar", "Do not add the same class twice in the same call." );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
test("addClass(String)", function() {
|
test("addClass(String)", function() {
|
||||||
|
@ -966,7 +949,7 @@ test("toggleClass(Function[, boolean])", function() {
|
||||||
test("toggleClass(Fucntion[, boolean]) with incoming value", function() {
|
test("toggleClass(Fucntion[, boolean]) with incoming value", function() {
|
||||||
expect(14);
|
expect(14);
|
||||||
|
|
||||||
var e = jQuery("#firstp"), old = e.attr("class") || "";
|
var e = jQuery("#firstp"), old = e.attr("class");
|
||||||
ok( !e.is(".test"), "Assert class not present" );
|
ok( !e.is(".test"), "Assert class not present" );
|
||||||
|
|
||||||
e.toggleClass(function(i, val) {
|
e.toggleClass(function(i, val) {
|
||||||
|
|
194
test/unit/callbacks.js
Normal file
194
test/unit/callbacks.js
Normal file
|
@ -0,0 +1,194 @@
|
||||||
|
module("callbacks", { teardown: moduleTeardown });
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
|
||||||
|
var output,
|
||||||
|
addToOutput = function( string ) {
|
||||||
|
return function() {
|
||||||
|
output += string;
|
||||||
|
};
|
||||||
|
},
|
||||||
|
outputA = addToOutput( "A" ),
|
||||||
|
outputB = addToOutput( "B" ),
|
||||||
|
outputC = addToOutput( "C" ),
|
||||||
|
tests = {
|
||||||
|
"": "XABC X XABCABCC X XBB X XABA X",
|
||||||
|
"once": "XABC X X X X X XABA X",
|
||||||
|
"memory": "XABC XABC XABCABCCC XA XBB XB XABA XC",
|
||||||
|
"unique": "XABC X XABCA X XBB X XAB X",
|
||||||
|
"relocate": "XABC X XAABC X XBB X XBA X",
|
||||||
|
"stopOnFalse": "XABC X XABCABCC X XBB X XA X",
|
||||||
|
"addAfterFire": "XAB X XABCAB X XBB X XABA X",
|
||||||
|
"queue": "XA X XB X XB X XA X",
|
||||||
|
"once memory": "XABC XABC X XA X XA XABA XC",
|
||||||
|
"once unique": "XABC X X X X X XAB X",
|
||||||
|
"once relocate": "XABC X X X X X XBA X",
|
||||||
|
"once stopOnFalse": "XABC X X X X X XA X",
|
||||||
|
"once addAfterFire": "XAB X X X X X XABA X",
|
||||||
|
"memory unique": "XABC XA XABCA XA XBB XB XAB XC",
|
||||||
|
"memory relocate": "XABC XB XAABC XA XBB XB XBA XC",
|
||||||
|
"memory stopOnFalse": "XABC XABC XABCABCCC XA XBB XB XA X",
|
||||||
|
"memory addAfterFire": "XAB XAB XABCABC XA XBB XB XABA XC",
|
||||||
|
"unique relocate": "XABC X XAABC X XBB X XBA X",
|
||||||
|
"unique stopOnFalse": "XABC X XABCA X XBB X XA X",
|
||||||
|
"unique addAfterFire": "XAB X XABCA X XBB X XAB X",
|
||||||
|
"relocate stopOnFalse": "XABC X XAABC X XBB X X X",
|
||||||
|
"relocate addAfterFire": "XAB X XAA X XBB X XBA X",
|
||||||
|
"stopOnFalse addAfterFire": "XAB X XABCAB X XBB X XA X"
|
||||||
|
},
|
||||||
|
filters = {
|
||||||
|
"no filter": undefined,
|
||||||
|
"filter": function( fn ) {
|
||||||
|
return function() {
|
||||||
|
return fn.apply( this, arguments );
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
jQuery.each( tests, function( flags, resultString ) {
|
||||||
|
|
||||||
|
jQuery.each( filters, function( filterLabel, filter ) {
|
||||||
|
|
||||||
|
test( "jQuery.Callbacks( \"" + flags + "\" ) - " + filterLabel, function() {
|
||||||
|
|
||||||
|
expect( 19 );
|
||||||
|
|
||||||
|
// Give qunit a little breathing room
|
||||||
|
stop();
|
||||||
|
setTimeout( start, 0 );
|
||||||
|
|
||||||
|
var cblist;
|
||||||
|
results = resultString.split( /\s+/ );
|
||||||
|
|
||||||
|
// Basic binding and firing
|
||||||
|
output = "X";
|
||||||
|
cblist = jQuery.Callbacks( flags );
|
||||||
|
cblist.add(function( str ) {
|
||||||
|
output += str;
|
||||||
|
});
|
||||||
|
cblist.fire( "A" );
|
||||||
|
strictEqual( output, "XA", "Basic binding and firing" );
|
||||||
|
output = "X";
|
||||||
|
cblist.disable();
|
||||||
|
cblist.add(function( str ) {
|
||||||
|
output += str;
|
||||||
|
});
|
||||||
|
strictEqual( output, "X", "Adding a callback after disabling" );
|
||||||
|
cblist.fire( "A" );
|
||||||
|
strictEqual( output, "X", "Firing after disabling" );
|
||||||
|
|
||||||
|
// Basic binding and firing (context, arguments)
|
||||||
|
output = "X";
|
||||||
|
cblist = jQuery.Callbacks( flags );
|
||||||
|
cblist.add(function() {
|
||||||
|
equals( this, window, "Basic binding and firing (context)" );
|
||||||
|
output += Array.prototype.join.call( arguments, "" );
|
||||||
|
});
|
||||||
|
cblist.fireWith( window, [ "A", "B" ] );
|
||||||
|
strictEqual( output, "XAB", "Basic binding and firing (arguments)" );
|
||||||
|
|
||||||
|
// fireWith with no arguments
|
||||||
|
output = "";
|
||||||
|
cblist = jQuery.Callbacks( flags );
|
||||||
|
cblist.add(function() {
|
||||||
|
equals( this, window, "fireWith with no arguments (context is window)" );
|
||||||
|
strictEqual( arguments.length, 0, "fireWith with no arguments (no arguments)" );
|
||||||
|
});
|
||||||
|
cblist.fireWith();
|
||||||
|
|
||||||
|
// Basic binding, removing and firing
|
||||||
|
output = "X";
|
||||||
|
cblist = jQuery.Callbacks( flags );
|
||||||
|
cblist.add( outputA, outputB, outputC );
|
||||||
|
cblist.remove( outputB, outputC );
|
||||||
|
cblist.fire();
|
||||||
|
strictEqual( output, "XA", "Basic binding, removing and firing" );
|
||||||
|
|
||||||
|
// Empty
|
||||||
|
output = "X";
|
||||||
|
cblist = jQuery.Callbacks( flags );
|
||||||
|
cblist.add( outputA );
|
||||||
|
cblist.add( outputB );
|
||||||
|
cblist.add( outputC );
|
||||||
|
cblist.empty();
|
||||||
|
cblist.fire();
|
||||||
|
strictEqual( output, "X", "Empty" );
|
||||||
|
|
||||||
|
// Locking
|
||||||
|
output = "X";
|
||||||
|
cblist = jQuery.Callbacks( flags );
|
||||||
|
cblist.add( function( str ) {
|
||||||
|
output += str;
|
||||||
|
});
|
||||||
|
cblist.lock();
|
||||||
|
cblist.add( function( str ) {
|
||||||
|
output += str;
|
||||||
|
});
|
||||||
|
cblist.fire( "A" );
|
||||||
|
cblist.add( function( str ) {
|
||||||
|
output += str;
|
||||||
|
});
|
||||||
|
strictEqual( output, "X", "Lock early" );
|
||||||
|
|
||||||
|
// Ordering
|
||||||
|
output = "X";
|
||||||
|
cblist = jQuery.Callbacks( flags );
|
||||||
|
cblist.add( function() {
|
||||||
|
cblist.add( outputC );
|
||||||
|
outputA();
|
||||||
|
}, outputB );
|
||||||
|
cblist.fire();
|
||||||
|
strictEqual( output, results.shift(), "Proper ordering" );
|
||||||
|
|
||||||
|
// Add and fire again
|
||||||
|
output = "X";
|
||||||
|
cblist.add( function() {
|
||||||
|
cblist.add( outputC );
|
||||||
|
outputA();
|
||||||
|
}, outputB );
|
||||||
|
strictEqual( output, results.shift(), "Add after fire" );
|
||||||
|
|
||||||
|
output = "X";
|
||||||
|
cblist.fire();
|
||||||
|
strictEqual( output, results.shift(), "Fire again" );
|
||||||
|
|
||||||
|
// Multiple fire
|
||||||
|
output = "X";
|
||||||
|
cblist = jQuery.Callbacks( flags );
|
||||||
|
cblist.add( function( str ) {
|
||||||
|
output += str;
|
||||||
|
} );
|
||||||
|
cblist.fire( "A" );
|
||||||
|
strictEqual( output, "XA", "Multiple fire (first fire)" );
|
||||||
|
output = "X";
|
||||||
|
cblist.add( function( str ) {
|
||||||
|
output += str;
|
||||||
|
} );
|
||||||
|
strictEqual( output, results.shift(), "Multiple fire (first new callback)" );
|
||||||
|
output = "X";
|
||||||
|
cblist.fire( "B" );
|
||||||
|
strictEqual( output, results.shift(), "Multiple fire (second fire)" );
|
||||||
|
output = "X";
|
||||||
|
cblist.add( function( str ) {
|
||||||
|
output += str;
|
||||||
|
} );
|
||||||
|
strictEqual( output, results.shift(), "Multiple fire (second new callback)" );
|
||||||
|
|
||||||
|
// Return false
|
||||||
|
output = "X";
|
||||||
|
cblist = jQuery.Callbacks( flags );
|
||||||
|
cblist.add( outputA, function() { return false; }, outputB );
|
||||||
|
cblist.add( outputA );
|
||||||
|
cblist.fire();
|
||||||
|
strictEqual( output, results.shift(), "Callback returning false" );
|
||||||
|
|
||||||
|
// Add another callback (to control lists with memory do not fire anymore)
|
||||||
|
output = "X";
|
||||||
|
cblist.add( outputC );
|
||||||
|
strictEqual( output, results.shift(), "Adding a callback after one returned false" );
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
})();
|
|
@ -475,13 +475,3 @@ test("widows & orphans #8936", function () {
|
||||||
|
|
||||||
$p.remove();
|
$p.remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Do not append px to 'fill-opacity' #9548", 1, function() {
|
|
||||||
|
|
||||||
var $div = jQuery("<div>").appendTo("#qunit-fixture");
|
|
||||||
|
|
||||||
$div.css("fill-opacity", 0).animate({ "fill-opacity": 1.0 }, 0, function () {
|
|
||||||
equal( jQuery(this).css("fill-opacity"), 1, "Do not append px to 'fill-opacity'");
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
|
@ -508,20 +508,3 @@ test("jQuery.data should follow html5 specification regarding camel casing", fun
|
||||||
|
|
||||||
div.remove();
|
div.remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("jQuery.data should not miss data with preset hyphenated property names", function() {
|
|
||||||
|
|
||||||
expect(2);
|
|
||||||
|
|
||||||
var div = jQuery("<div/>", { id: "hyphened" }).appendTo("#qunit-fixture"),
|
|
||||||
test = {
|
|
||||||
"camelBar": "camelBar",
|
|
||||||
"hyphen-foo": "hyphen-foo"
|
|
||||||
};
|
|
||||||
|
|
||||||
div.data( test );
|
|
||||||
|
|
||||||
jQuery.each( test , function(i, k) {
|
|
||||||
equal( div.data(k), k, "data with property '"+k+"' was correctly found");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
|
@ -1,111 +1,5 @@
|
||||||
module("deferred", { teardown: moduleTeardown });
|
module("deferred", { teardown: moduleTeardown });
|
||||||
|
|
||||||
jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
|
|
||||||
|
|
||||||
function createDeferred() {
|
|
||||||
return withNew ? new jQuery._Deferred() : jQuery._Deferred();
|
|
||||||
}
|
|
||||||
|
|
||||||
test("jQuery._Deferred" + withNew, function() {
|
|
||||||
|
|
||||||
expect( 11 );
|
|
||||||
|
|
||||||
var deferred,
|
|
||||||
object,
|
|
||||||
test;
|
|
||||||
|
|
||||||
deferred = createDeferred();
|
|
||||||
|
|
||||||
test = false;
|
|
||||||
|
|
||||||
deferred.done( function( value ) {
|
|
||||||
equals( value , "value" , "Test pre-resolve callback" );
|
|
||||||
test = true;
|
|
||||||
} );
|
|
||||||
|
|
||||||
deferred.resolve( "value" );
|
|
||||||
|
|
||||||
ok( test , "Test pre-resolve callbacks called right away" );
|
|
||||||
|
|
||||||
test = false;
|
|
||||||
|
|
||||||
deferred.done( function( value ) {
|
|
||||||
equals( value , "value" , "Test post-resolve callback" );
|
|
||||||
test = true;
|
|
||||||
} );
|
|
||||||
|
|
||||||
ok( test , "Test post-resolve callbacks called right away" );
|
|
||||||
|
|
||||||
deferred.cancel();
|
|
||||||
|
|
||||||
test = true;
|
|
||||||
|
|
||||||
deferred.done( function() {
|
|
||||||
ok( false , "Cancel was ignored" );
|
|
||||||
test = false;
|
|
||||||
} );
|
|
||||||
|
|
||||||
ok( test , "Test cancel" );
|
|
||||||
|
|
||||||
deferred = createDeferred().resolve();
|
|
||||||
|
|
||||||
try {
|
|
||||||
deferred.done( function() {
|
|
||||||
throw "Error";
|
|
||||||
} , function() {
|
|
||||||
ok( true , "Test deferred do not cancel on exception" );
|
|
||||||
} );
|
|
||||||
} catch( e ) {
|
|
||||||
strictEqual( e , "Error" , "Test deferred propagates exceptions");
|
|
||||||
deferred.done();
|
|
||||||
}
|
|
||||||
|
|
||||||
test = "";
|
|
||||||
deferred = createDeferred().done( function() {
|
|
||||||
|
|
||||||
test += "A";
|
|
||||||
|
|
||||||
}, function() {
|
|
||||||
|
|
||||||
test += "B";
|
|
||||||
|
|
||||||
} ).resolve();
|
|
||||||
|
|
||||||
strictEqual( test , "AB" , "Test multiple done parameters" );
|
|
||||||
|
|
||||||
test = "";
|
|
||||||
|
|
||||||
deferred.done( function() {
|
|
||||||
|
|
||||||
deferred.done( function() {
|
|
||||||
|
|
||||||
test += "C";
|
|
||||||
|
|
||||||
} );
|
|
||||||
|
|
||||||
test += "A";
|
|
||||||
|
|
||||||
}, function() {
|
|
||||||
|
|
||||||
test += "B";
|
|
||||||
} );
|
|
||||||
|
|
||||||
strictEqual( test , "ABC" , "Test done callbacks order" );
|
|
||||||
|
|
||||||
deferred = createDeferred();
|
|
||||||
|
|
||||||
deferred.resolveWith( jQuery , [ document ] ).done( function( doc ) {
|
|
||||||
ok( this === jQuery && arguments.length === 1 && doc === document , "Test fire context & args" );
|
|
||||||
});
|
|
||||||
|
|
||||||
// #8421
|
|
||||||
deferred = createDeferred();
|
|
||||||
deferred.resolveWith().done(function() {
|
|
||||||
ok( true, "Test resolveWith can be called with no argument" );
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} );
|
|
||||||
|
|
||||||
jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
|
jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
|
||||||
|
|
||||||
function createDeferred( fn ) {
|
function createDeferred( fn ) {
|
||||||
|
@ -114,7 +8,7 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
|
||||||
|
|
||||||
test("jQuery.Deferred" + withNew, function() {
|
test("jQuery.Deferred" + withNew, function() {
|
||||||
|
|
||||||
expect( 8 );
|
expect( 14 );
|
||||||
|
|
||||||
createDeferred().resolve().then( function() {
|
createDeferred().resolve().then( function() {
|
||||||
ok( true , "Success on resolve" );
|
ok( true , "Success on resolve" );
|
||||||
|
@ -140,6 +34,20 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
|
||||||
}).then( function( value ) {
|
}).then( function( value ) {
|
||||||
strictEqual( value , "done" , "Passed function executed" );
|
strictEqual( value , "done" , "Passed function executed" );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
jQuery.each( "resolve reject".split( " " ), function( _, change ) {
|
||||||
|
createDeferred( function( defer ) {
|
||||||
|
var checked = 0;
|
||||||
|
defer.progress(function( value ) {
|
||||||
|
strictEqual( value, checked, "Progress: right value (" + value + ") received" );
|
||||||
|
});
|
||||||
|
for( checked = 0; checked < 3 ; checked++ ) {
|
||||||
|
defer.ping( checked );
|
||||||
|
}
|
||||||
|
defer[ change ]();
|
||||||
|
defer.ping();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
@ -215,6 +123,34 @@ test( "jQuery.Deferred.pipe - filtering (fail)", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test( "jQuery.Deferred.pipe - filtering (progress)", function() {
|
||||||
|
|
||||||
|
expect(3);
|
||||||
|
|
||||||
|
var defer = jQuery.Deferred(),
|
||||||
|
piped = defer.pipe( null, null, function( a, b ) {
|
||||||
|
return a * b;
|
||||||
|
} ),
|
||||||
|
value1,
|
||||||
|
value2,
|
||||||
|
value3;
|
||||||
|
|
||||||
|
piped.progress(function( result ) {
|
||||||
|
value3 = result;
|
||||||
|
});
|
||||||
|
|
||||||
|
defer.progress(function( a, b ) {
|
||||||
|
value1 = a;
|
||||||
|
value2 = b;
|
||||||
|
});
|
||||||
|
|
||||||
|
defer.ping( 2, 3 );
|
||||||
|
|
||||||
|
strictEqual( value1, 2, "first progress value ok" );
|
||||||
|
strictEqual( value2, 3, "second progress value ok" );
|
||||||
|
strictEqual( value3, 6, "result of filter ok" );
|
||||||
|
});
|
||||||
|
|
||||||
test( "jQuery.Deferred.pipe - deferred (done)", function() {
|
test( "jQuery.Deferred.pipe - deferred (done)", function() {
|
||||||
|
|
||||||
expect(3);
|
expect(3);
|
||||||
|
@ -275,32 +211,35 @@ test( "jQuery.Deferred.pipe - deferred (fail)", function() {
|
||||||
strictEqual( value3, 6, "result of filter ok" );
|
strictEqual( value3, 6, "result of filter ok" );
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "jQuery.Deferred.pipe - context", function() {
|
test( "jQuery.Deferred.pipe - deferred (progress)", function() {
|
||||||
|
|
||||||
expect(4);
|
expect(3);
|
||||||
|
|
||||||
var context = {};
|
|
||||||
|
|
||||||
jQuery.Deferred().resolveWith( context, [ 2 ] ).pipe(function( value ) {
|
|
||||||
return value * 3;
|
|
||||||
}).done(function( value ) {
|
|
||||||
strictEqual( this, context, "custom context correctly propagated" );
|
|
||||||
strictEqual( value, 6, "proper value received" );
|
|
||||||
});
|
|
||||||
|
|
||||||
var defer = jQuery.Deferred(),
|
var defer = jQuery.Deferred(),
|
||||||
piped = defer.pipe(function( value ) {
|
piped = defer.pipe( null, null, function( a, b ) {
|
||||||
return value * 3;
|
return jQuery.Deferred(function( defer ) {
|
||||||
|
defer.resolve( a * b );
|
||||||
|
});
|
||||||
|
} ),
|
||||||
|
value1,
|
||||||
|
value2,
|
||||||
|
value3;
|
||||||
|
|
||||||
|
piped.done(function( result ) {
|
||||||
|
value3 = result;
|
||||||
});
|
});
|
||||||
|
|
||||||
defer.resolve( 2 );
|
defer.progress(function( a, b ) {
|
||||||
|
value1 = a;
|
||||||
piped.done(function( value ) {
|
value2 = b;
|
||||||
strictEqual( this.promise(), piped, "default context gets updated to latest defer in the chain" );
|
|
||||||
strictEqual( value, 6, "proper value received" );
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
defer.ping( 2, 3 );
|
||||||
|
|
||||||
|
strictEqual( value1, 2, "first progress value ok" );
|
||||||
|
strictEqual( value2, 3, "second progress value ok" );
|
||||||
|
strictEqual( value3, 6, "result of filter ok" );
|
||||||
|
});
|
||||||
|
|
||||||
test( "jQuery.when" , function() {
|
test( "jQuery.when" , function() {
|
||||||
|
|
||||||
|
@ -345,36 +284,54 @@ test( "jQuery.when" , function() {
|
||||||
|
|
||||||
test("jQuery.when - joined", function() {
|
test("jQuery.when - joined", function() {
|
||||||
|
|
||||||
expect(25);
|
expect(53);
|
||||||
|
|
||||||
var deferreds = {
|
var deferreds = {
|
||||||
value: 1,
|
value: 1,
|
||||||
success: jQuery.Deferred().resolve( 1 ),
|
success: jQuery.Deferred().resolve( 1 ),
|
||||||
error: jQuery.Deferred().reject( 0 ),
|
error: jQuery.Deferred().reject( 0 ),
|
||||||
futureSuccess: jQuery.Deferred(),
|
futureSuccess: jQuery.Deferred().ping( true ),
|
||||||
futureError: jQuery.Deferred()
|
futureError: jQuery.Deferred().ping( true ),
|
||||||
|
ping: jQuery.Deferred().ping( true )
|
||||||
},
|
},
|
||||||
willSucceed = {
|
willSucceed = {
|
||||||
value: true,
|
value: true,
|
||||||
success: true,
|
success: true,
|
||||||
error: false,
|
futureSuccess: true
|
||||||
|
},
|
||||||
|
willError = {
|
||||||
|
error: true,
|
||||||
|
futureError: true
|
||||||
|
},
|
||||||
|
willPing = {
|
||||||
futureSuccess: true,
|
futureSuccess: true,
|
||||||
futureError: false
|
futureError: true,
|
||||||
|
ping: true
|
||||||
};
|
};
|
||||||
|
|
||||||
jQuery.each( deferreds, function( id1, defer1 ) {
|
jQuery.each( deferreds, function( id1, defer1 ) {
|
||||||
jQuery.each( deferreds, function( id2, defer2 ) {
|
jQuery.each( deferreds, function( id2, defer2 ) {
|
||||||
var shouldResolve = willSucceed[ id1 ] && willSucceed[ id2 ],
|
var shouldResolve = willSucceed[ id1 ] && willSucceed[ id2 ],
|
||||||
|
shouldError = willError[ id1 ] || willError[ id2 ],
|
||||||
|
shouldPing = willPing[ id1 ] || willPing[ id2 ],
|
||||||
expected = shouldResolve ? [ 1, 1 ] : [ 0, undefined ],
|
expected = shouldResolve ? [ 1, 1 ] : [ 0, undefined ],
|
||||||
|
expectedPing = shouldPing && [ willPing[ id1 ], willPing[ id2 ] ],
|
||||||
code = id1 + "/" + id2;
|
code = id1 + "/" + id2;
|
||||||
jQuery.when( defer1, defer2 ).done(function( a, b ) {
|
|
||||||
|
var promise = jQuery.when( defer1, defer2 ).done(function( a, b ) {
|
||||||
if ( shouldResolve ) {
|
if ( shouldResolve ) {
|
||||||
same( [ a, b ], expected, code + " => resolve" );
|
same( [ a, b ], expected, code + " => resolve" );
|
||||||
|
} else {
|
||||||
|
ok( false , code + " => resolve" );
|
||||||
}
|
}
|
||||||
}).fail(function( a, b ) {
|
}).fail(function( a, b ) {
|
||||||
if ( !shouldResolve ) {
|
if ( shouldError ) {
|
||||||
same( [ a, b ], expected, code + " => resolve" );
|
same( [ a, b ], expected, code + " => reject" );
|
||||||
|
} else {
|
||||||
|
ok( false , code + " => reject" );
|
||||||
}
|
}
|
||||||
|
}).progress(function progress( a, b ) {
|
||||||
|
same( [ a, b ], expectedPing, code + " => progress" );
|
||||||
});
|
});
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -211,31 +211,6 @@ test("outerWidth()", function() {
|
||||||
jQuery.removeData($div[0], "olddisplay", true);
|
jQuery.removeData($div[0], "olddisplay", true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("child of a hidden elem has accurate inner/outer/Width()/Height() see #9441 #9300", function() {
|
|
||||||
expect(8);
|
|
||||||
|
|
||||||
// setup html
|
|
||||||
var $divNormal = jQuery("<div>").css({ width: "100px", height: "100px", border: "10px solid white", padding: "2px", margin: "3px" }),
|
|
||||||
$divChild = $divNormal.clone(),
|
|
||||||
$divHiddenParent = jQuery("<div>").css( "display", "none" ).append( $divChild ).appendTo("body");
|
|
||||||
$divNormal.appendTo("body");
|
|
||||||
|
|
||||||
// tests that child div of a hidden div works the same as a normal div
|
|
||||||
equals( $divChild.width(), $divNormal.width(), "child of a hidden element width() is wrong see #9441" );
|
|
||||||
equals( $divChild.innerWidth(), $divNormal.innerWidth(), "child of a hidden element innerWidth() is wrong see #9441" );
|
|
||||||
equals( $divChild.outerWidth(), $divNormal.outerWidth(), "child of a hidden element outerWidth() is wrong see #9441" );
|
|
||||||
equals( $divChild.outerWidth(true), $divNormal.outerWidth( true ), "child of a hidden element outerWidth( true ) is wrong see #9300" );
|
|
||||||
|
|
||||||
equals( $divChild.height(), $divNormal.height(), "child of a hidden element height() is wrong see #9441" );
|
|
||||||
equals( $divChild.innerHeight(), $divNormal.innerHeight(), "child of a hidden element innerHeight() is wrong see #9441" );
|
|
||||||
equals( $divChild.outerHeight(), $divNormal.outerHeight(), "child of a hidden element outerHeight() is wrong see #9441" );
|
|
||||||
equals( $divChild.outerHeight(true), $divNormal.outerHeight( true ), "child of a hidden element outerHeight( true ) is wrong see #9300" );
|
|
||||||
|
|
||||||
// teardown html
|
|
||||||
$divHiddenParent.remove();
|
|
||||||
$divNormal.remove();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("outerHeight()", function() {
|
test("outerHeight()", function() {
|
||||||
expect(11);
|
expect(11);
|
||||||
|
|
||||||
|
|
|
@ -780,43 +780,6 @@ test("mouseover triggers mouseenter", function() {
|
||||||
elem.remove();
|
elem.remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("withinElement implemented with jQuery.contains()", function() {
|
|
||||||
|
|
||||||
expect(1);
|
|
||||||
|
|
||||||
jQuery("#qunit-fixture").append('<div id="jc-outer"><div id="jc-inner"></div></div>');
|
|
||||||
|
|
||||||
jQuery("#jc-outer").bind("mouseenter mouseleave", function( event ) {
|
|
||||||
|
|
||||||
equal( this.id, "jc-outer", this.id + " " + event.type );
|
|
||||||
|
|
||||||
}).trigger("mouseenter");
|
|
||||||
|
|
||||||
jQuery("#jc-inner").trigger("mousenter");
|
|
||||||
|
|
||||||
jQuery("#jc-outer").unbind("mouseenter mouseleave").remove();
|
|
||||||
jQuery("#jc-inner").remove();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
test("mouseenter, mouseleave don't catch exceptions", function() {
|
|
||||||
expect(2);
|
|
||||||
|
|
||||||
var elem = jQuery("#firstp").hover(function() { throw "an Exception"; });
|
|
||||||
|
|
||||||
try {
|
|
||||||
elem.mouseenter();
|
|
||||||
} catch (e) {
|
|
||||||
equals( e, "an Exception", "mouseenter doesn't catch exceptions" );
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
elem.mouseleave();
|
|
||||||
} catch (e) {
|
|
||||||
equals( e, "an Exception", "mouseleave doesn't catch exceptions" );
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
test("trigger() shortcuts", function() {
|
test("trigger() shortcuts", function() {
|
||||||
expect(6);
|
expect(6);
|
||||||
|
|
||||||
|
|
68
test/unit/topic.js
Normal file
68
test/unit/topic.js
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
module("topic", { teardown: moduleTeardown });
|
||||||
|
|
||||||
|
test( "jQuery.Topic - Anonymous Topic", function() {
|
||||||
|
|
||||||
|
expect( 4 );
|
||||||
|
|
||||||
|
var topic = jQuery.Topic(),
|
||||||
|
count = 0;
|
||||||
|
|
||||||
|
function firstCallback( value ) {
|
||||||
|
strictEqual( count, 1, "Callback called when needed" );
|
||||||
|
strictEqual( value, "test", "Published value received" );
|
||||||
|
}
|
||||||
|
|
||||||
|
count++;
|
||||||
|
topic.subscribe( firstCallback );
|
||||||
|
topic.publish( "test" );
|
||||||
|
topic.unsubscribe( firstCallback );
|
||||||
|
count++;
|
||||||
|
topic.subscribe(function( value ) {
|
||||||
|
strictEqual( count, 2, "Callback called when needed" );
|
||||||
|
strictEqual( value, "test", "Published value received" );
|
||||||
|
});
|
||||||
|
topic.publish( "test" );
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
test( "jQuery.Topic - Named Topic", function() {
|
||||||
|
|
||||||
|
expect( 2 );
|
||||||
|
|
||||||
|
function callback( value ) {
|
||||||
|
ok( true, "Callback called" );
|
||||||
|
strictEqual( value, "test", "Proper value received" );
|
||||||
|
}
|
||||||
|
|
||||||
|
jQuery.Topic( "test" ).subscribe( callback );
|
||||||
|
jQuery.Topic( "test" ).publish( "test" );
|
||||||
|
jQuery.Topic( "test" ).unsubscribe( callback );
|
||||||
|
jQuery.Topic( "test" ).publish( "test" );
|
||||||
|
});
|
||||||
|
|
||||||
|
test( "jQuery.Topic - Helpers", function() {
|
||||||
|
|
||||||
|
expect( 4 );
|
||||||
|
|
||||||
|
function callback( value ) {
|
||||||
|
ok( true, "Callback called" );
|
||||||
|
strictEqual( value, "test", "Proper value received" );
|
||||||
|
}
|
||||||
|
|
||||||
|
jQuery.subscribe( "test", callback );
|
||||||
|
jQuery.publish( "test" , "test" );
|
||||||
|
jQuery.unsubscribe( "test", callback );
|
||||||
|
jQuery.publish( "test" , "test" );
|
||||||
|
|
||||||
|
|
||||||
|
var test = true,
|
||||||
|
subscription = jQuery.subscribe( "test", function() {
|
||||||
|
ok( test, "first callback called" );
|
||||||
|
}, function() {
|
||||||
|
ok( test, "second callback called" );
|
||||||
|
});
|
||||||
|
jQuery.publish( "test" );
|
||||||
|
test = false;
|
||||||
|
jQuery.unsubscribe( subscription );
|
||||||
|
jQuery.publish( "test" );
|
||||||
|
});
|
|
@ -1 +1 @@
|
||||||
1.6.3pre
|
1.6.2pre
|
Loading…
Reference in a new issue