Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MINOR Updated jquery-entwine

  • Loading branch information...
commit 340f2ce5e89b585b41f4f701c91fcb4ad046080f 1 parent 5b63bac
@chillu chillu authored
View
2  thirdparty/jquery-entwine/.piston.yml
@@ -1,7 +1,7 @@
---
format: 1
handler:
- commit: b0b8d4f3417db927eae24510f9a45dfe38bb7d37
+ commit: dd1b1d3c0958aa12990cba80a9b9d429a7e89bee
branch: master
lock: false
repository_class: Piston::Git::Repository
View
2  thirdparty/jquery-entwine/build.sh
@@ -29,6 +29,8 @@ do \
echo >> $FILE
done
+cp $FILE "dist/jquery.concrete-dist.js"
+
# cp LICENSE /tmp/
# cp $FILE /tmp/
View
161 thirdparty/jquery-entwine/dist/jquery.entwine-dist.js
@@ -749,7 +749,12 @@ Sizzle is good for finding elements for a selector, but not so good for telling
/* src/jquery.entwine.js */
-var console;
+try {
+ console.log;
+}
+catch (e) {
+ window.console = undefined;
+}
(function($) {
@@ -1186,10 +1191,24 @@ var console;
(function($) {
- /* If we are any browser other than IE or Safari, we don't have to do anything special to handle
- * onchange delegation */
- $.support.bubblingChange = !($.browser.msie || $.browser.safari);
-
+ /** Taken from jQuery 1.5.2 for backwards compatibility */
+ if ($.support.changeBubbles == undefined) {
+ $.support.changeBubbles = true;
+
+ var el = document.createElement("div");
+ eventName = "onchange";
+
+ if (el.attachEvent) {
+ var isSupported = (eventName in el);
+ if (!isSupported) {
+ el.setAttribute(eventName, "return;");
+ isSupported = typeof el[eventName] === "function";
+ }
+
+ $.support.changeBubbles = isSupported;
+ }
+ }
+
/* Return true if node b is the same as, or is a descendant of, node a */
if (document.compareDocumentPosition) {
var is_or_contains = function(a, b) {
@@ -1250,46 +1269,104 @@ var console;
build_change_proxy: function(name) {
var one = this.one(name, 'func');
-
- var prxy = function(e) {
- var el = e.target;
- // If this is a keydown event, only worry about the enter key, since browsers only trigger onchange on enter or focus loss
- if (e.type === 'keydown' && e.keyCode !== 13) return;
- // Make sure this is event is for an input type we're interested in
- if (el.tagName !== 'INPUT' && el.tagName !== 'TEXTAREA' && el.tagName !== 'SELECT') return;
-
- var $el = $(el), nowVal, oldVal = $el.data('changeVal');
-
- // Detect changes on checkboxes & radiobuttons, which have different value logic. We don't use el.value, since el is part
- // of a set, and we only want to raise onchange once for a single user action.
- if (el.type == 'checkbox' || el.type == 'radio') {
- if (!el.disabled && e.type === 'click') {
- nowVal = el.checked;
- // If radio, we get two changes - the activation, and the deactivation. We only want to fire one change though
- if ((el.type === 'checkbox' || nowVal === true) && oldVal !== nowVal) e.type = 'change';
+
+ /*
+ This change bubble emulation code is taken mostly from jQuery 1.6 - unfortunately we can't easily reuse any of
+ it without duplication, so we'll have to re-migrate any bugfixes
+ */
+
+ // Get the value of an item. Isn't supposed to be interpretable, just stable for some value, and different
+ // once the value changes
+ var getVal = function( elem ) {
+ var type = elem.type, val = elem.value;
+
+ if (type === "radio" || type === "checkbox") {
+ val = elem.checked;
+ }
+ else if (type === "select-multiple") {
+ val = "";
+ if (elem.selectedIndex > -1) {
+ val = jQuery.map(elem.options, function(elem){ return elem.selected; }).join("-");
}
}
- // Detect changes on other input types. In this case value is OK.
- else {
- nowVal = el.value;
- if (oldVal !== undefined && oldVal !== nowVal) e.type = 'change';
+ else if (jQuery.nodeName(elem, "select")) {
+ val = elem.selectedIndex;
}
-
- // Save the current value for next time
- if (nowVal !== undefined) $el.data('changeVal', nowVal);
-
- // And if we decided that a change happened, do the actual triggering
- if (e.type == 'change') {
- while (el && el.nodeType == 1 && !e.isPropagationStopped()) {
- var ret = one(el, arguments);
+
+ return val;
+ };
+
+ // Test if a node name is a form input
+ var rformElems = /^(?:textarea|input|select)$/i;
+
+ // Check if this event is a change, and bubble the change event if it is
+ var testChange = function(e) {
+ var elem = e.target, data, val;
+
+ if (!rformElems.test(elem.nodeName) || elem.readOnly) return;
+
+ data = jQuery.data(elem, "_entwine_change_data");
+ val = getVal(elem);
+
+ // the current data will be also retrieved by beforeactivate
+ if (e.type !== "focusout" || elem.type !== "radio") {
+ jQuery.data(elem, "_entwine_change_data", val);
+ }
+
+ if (data === undefined || val === data) return;
+
+ if (data != null || val) {
+ e.type = "change";
+
+ while (elem && elem.nodeType == 1 && !e.isPropagationStopped()) {
+ var ret = one(elem, arguments);
if (ret !== undefined) e.result = ret;
if (ret === false) { e.preventDefault(); e.stopPropagation(); }
-
- el = el.parentNode;
+
+ elem = elem.parentNode;
}
}
};
-
+
+ // The actual proxy - responds to several events, some of which triger a change check, some
+ // of which just store the value for future change checks
+ var prxy = function(e) {
+ var event = e.type, elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
+
+ switch (event) {
+ case 'focusout':
+ case 'beforedeactivate':
+ testChange.apply(this, arguments);
+ break;
+
+ case 'click':
+ if ( type === "radio" || type === "checkbox" || jQuery.nodeName( elem, "select" ) ) {
+ testChange.apply(this, arguments);
+ }
+ break;
+
+ // Change has to be called before submit
+ // Keydown will be called before keypress, which is used in submit-event delegation
+ case 'keydown':
+ if (
+ (e.keyCode === 13 && !jQuery.nodeName( elem, "textarea" ) ) ||
+ (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
+ type === "select-multiple"
+ ) {
+ testChange.apply(this, arguments);
+ }
+ break;
+
+ // Beforeactivate happens also before the previous element is blurred
+ // with this event you can't trigger a change event, but you can store
+ // information
+ case 'focusin':
+ case 'beforeactivate':
+ jQuery.data( elem, "_entwine_change_data", getVal(elem) );
+ break;
+ }
+ }
+
return prxy;
},
@@ -1310,9 +1387,9 @@ var console;
event = 'mouseout';
break;
case 'onchange':
- if (!$.support.bubblingChange) {
+ if (!$.support.changeBubbles) {
proxies[name] = this.build_change_proxy(name);
- event = 'click focusin focusout keydown';
+ event = 'click keydown focusin focusout beforeactivate beforedeactivate';
}
break;
case 'onsubmit':
@@ -1325,8 +1402,8 @@ var console;
// If none of the special handlers created a proxy, use the generic proxy
if (!proxies[name]) proxies[name] = this.build_event_proxy(name);
-
- $(document).bind(event+'.entwine', proxies[name]);
+
+ $(document).bind(event.replace(/(\s+|$)/g, '.entwine$1'), proxies[name]);
}
}
});
@@ -1550,7 +1627,7 @@ var console;
var getterName = 'get'+k;
var setterName = 'set'+k;
- this.bind_proxy(selector, getterName, function() { return this.entwineData(k) || v ; });
+ this.bind_proxy(selector, getterName, function() { var r = this.entwineData(k); return r === undefined ? v : r; });
this.bind_proxy(selector, setterName, function(v){ return this.entwineData(k, v); });
// Get the get and set proxies we just created
View
56 thirdparty/jquery-entwine/spec/SpecRunner.html
@@ -2,15 +2,31 @@
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
- <title>Jasmine Test Runner</title>
- <link rel="stylesheet" type="text/css" href="../vendor/jasmine-1.0.1/jasmine.css">
- <script type="text/javascript" src="../vendor/jasmine-1.0.1/jasmine.js"></script>
- <script type="text/javascript" src="../vendor/jasmine-1.0.1/jasmine-html.js"></script>
+ <title>Jasmine Test Runner</title>
+ <link rel="stylesheet" type="text/css" href="../vendor/jasmine-1.0.1/jasmine.css">
+
+ <script type="text/javascript" src="../vendor/jasmine-1.0.1/jasmine.js"></script>
+ <script type="text/javascript" src="../vendor/jasmine-1.0.1/jasmine-html.js"></script>
<script type="text/javascript" src="../vendor/jasmine-dom/jasmine-dom-matchers.js"></script>
<script type="text/javascript" src="../vendor/jasmine-dom/jasmine-dom-fixtures.js"></script>
<!-- include source files here... -->
- <script src="../vendor/jquery-1.5.js"></script>
+ <script type="text/javascript">
+ versionarg = window.location.search.match(/version=([^&]+)/);
+ jQueryVersion = versionarg ? versionarg[1] : '1.6';
+ jQuerySource = 'local';
+
+ var jQuery;
+ document.write('<'+'script src="../vendor/jquery-'+jQueryVersion+'.js"'+'><'+'/script'+'>');
+ </script>
+
+ <script type="text/javascript">
+ if (!jQuery) {
+ jQuerySource = 'Google CDN';
+ document.write('<'+'script src="http://ajax.googleapis.com/ajax/libs/jquery/'+jQueryVersion+'/jquery.min.js"'+'><'+'/script'+'>');
+ }
+ </script>
+
<script src="../vendor/jquery.selector/jquery.class.js"></script>
<script src="../vendor/jquery.selector/jquery.selector.js"></script>
<script src="../vendor/jquery.selector/jquery.selector.specifity.js"></script>
@@ -22,22 +38,40 @@
<script src="../src/jquery.entwine.ctors.js"></script>
<script src="../src/jquery.entwine.properties.js"></script>
- <!-- include spec files here... -->
- <script type="text/javascript" src="spec.entwine.basics.js"></script>
- <script type="text/javascript" src="spec.entwine.ctors.js"></script>
+ <!-- include spec files here... -->
+ <script type="text/javascript" src="spec.entwine.basics.js"></script>
+ <script type="text/javascript" src="spec.entwine.ctors.js"></script>
<script type="text/javascript" src="spec.entwine.events.js"></script>
<script type="text/javascript" src="spec.entwine.namespaces.js"></script>
<script type="text/javascript" src="spec.entwine.properties.js"></script>
<script type="text/javascript" src="spec.entwine.super.js"></script>
<script type="text/javascript" src="spec.entwine.synchronous.js"></script>
+ <style type="text/css">
+ #jqver {
+ margin: 0;
+ padding: 4px 15px;
+ }
+ #jqver.error {
+ padding: 4px 13px;
+ border: 2px solid red;
+ }
+ </style>
+
</head>
<body>
+</body>
<script type="text/javascript">
- jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
- jasmine.getEnv().execute();
+ if (!jQuery) {
+ document.body.innerHTML = '<h4 id="jqver" class="error">jQuery version '+jQueryVersion+' not found</h4>';
+ }
+ else {
+ document.body.innerHTML = '<h4 id="jqver">jQuery version '+jQueryVersion+' ('+jQuerySource+')</h4>';
+
+ jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
+ jasmine.getEnv().execute();
+ }
</script>
-</body>
</html>
View
48 thirdparty/jquery-entwine/spec/spec.entwine.events.js
@@ -110,7 +110,53 @@ describe( 'Entwine', function() {
expect(data.cheese).toEqual( 'burger');
});
});
-
+
+ describe( 'calls onchange on checkboxes properly', function() {
+ beforeEach(function() {
+ $('#dom_test').html('<input id="i" type="checkbox" name="test_input_i" value="i" />');
+ });
+
+ it( 'calls onchange', function() {
+ var a = 0;
+
+ $('#i').entwine({onchange: function(){ a += 1; }});
+
+ // Can't just "click()" - it's not the same as an actual click event
+ $('#i').trigger('focusin'); $('#i')[0].click();
+ expect(a).toEqual(1);
+ });
+
+ it( 'calls onchange only once per change', function() {
+ var a = 0;
+
+ $('#i').entwine({onchange: function(){ a += 1; }});
+
+ $('#i').trigger('focusin'); $('#i')[0].click();
+ expect(a).toEqual(1);
+
+ $('#i').trigger('focusout'); $('#i').trigger('focusin'); $('#i').trigger('focusout');
+ expect(a).toEqual(1);
+
+ $('#i')[0].click();
+ expect(a).toEqual(2);
+
+ });
+
+ it( 'calls onchange even if checked attribute altered in mean time', function() {
+ var a = 0;
+
+ $('#i').entwine({onchange: function(){ a += 1; }});
+
+ $('#i').trigger('focusin'); $('#i')[0].click();
+ expect(a).toEqual(1);
+
+ $('#i').removeAttr('checked');
+
+ $('#i').trigger('focusin'); $('#i')[0].click();
+ expect(a).toEqual(2);
+ });
+ });
+
});
});
View
10 thirdparty/jquery-entwine/spec/spec.entwine.properties.js
@@ -33,6 +33,16 @@ describe('Entwine', function() {
});
expect($('.a').getFoo()).toEqual(1);
});
+ it('can override a default value with a true-ish value', function() {
+ $('#a').entwine({ Foo: 1 });
+ $('#a').setFoo(2);
+ expect($('.a').getFoo()).toEqual(2);
+ });
+ it('can override a default value with a false-ish value', function() {
+ $('#a').entwine({ Foo: 1 });
+ $('#a').setFoo(0);
+ expect($('.a').getFoo()).toEqual(0);
+ });
it('should manage proprties in namespaces without clashing', function() {
$('#a').entwine({
Foo: 1
View
152 thirdparty/jquery-entwine/src/jquery.entwine.events.js
@@ -1,9 +1,23 @@
(function($) {
- /* If we are any browser other than IE or Safari, we don't have to do anything special to handle
- * onchange delegation */
- $.support.bubblingChange = !($.browser.msie || $.browser.safari);
-
+ /** Taken from jQuery 1.5.2 for backwards compatibility */
+ if ($.support.changeBubbles == undefined) {
+ $.support.changeBubbles = true;
+
+ var el = document.createElement("div");
+ eventName = "onchange";
+
+ if (el.attachEvent) {
+ var isSupported = (eventName in el);
+ if (!isSupported) {
+ el.setAttribute(eventName, "return;");
+ isSupported = typeof el[eventName] === "function";
+ }
+
+ $.support.changeBubbles = isSupported;
+ }
+ }
+
/* Return true if node b is the same as, or is a descendant of, node a */
if (document.compareDocumentPosition) {
var is_or_contains = function(a, b) {
@@ -64,46 +78,104 @@
build_change_proxy: function(name) {
var one = this.one(name, 'func');
-
- var prxy = function(e) {
- var el = e.target;
- // If this is a keydown event, only worry about the enter key, since browsers only trigger onchange on enter or focus loss
- if (e.type === 'keydown' && e.keyCode !== 13) return;
- // Make sure this is event is for an input type we're interested in
- if (el.tagName !== 'INPUT' && el.tagName !== 'TEXTAREA' && el.tagName !== 'SELECT') return;
-
- var $el = $(el), nowVal, oldVal = $el.data('changeVal');
-
- // Detect changes on checkboxes & radiobuttons, which have different value logic. We don't use el.value, since el is part
- // of a set, and we only want to raise onchange once for a single user action.
- if (el.type == 'checkbox' || el.type == 'radio') {
- if (!el.disabled && e.type === 'click') {
- nowVal = el.checked;
- // If radio, we get two changes - the activation, and the deactivation. We only want to fire one change though
- if ((el.type === 'checkbox' || nowVal === true) && oldVal !== nowVal) e.type = 'change';
+
+ /*
+ This change bubble emulation code is taken mostly from jQuery 1.6 - unfortunately we can't easily reuse any of
+ it without duplication, so we'll have to re-migrate any bugfixes
+ */
+
+ // Get the value of an item. Isn't supposed to be interpretable, just stable for some value, and different
+ // once the value changes
+ var getVal = function( elem ) {
+ var type = elem.type, val = elem.value;
+
+ if (type === "radio" || type === "checkbox") {
+ val = elem.checked;
+ }
+ else if (type === "select-multiple") {
+ val = "";
+ if (elem.selectedIndex > -1) {
+ val = jQuery.map(elem.options, function(elem){ return elem.selected; }).join("-");
}
}
- // Detect changes on other input types. In this case value is OK.
- else {
- nowVal = el.value;
- if (oldVal !== undefined && oldVal !== nowVal) e.type = 'change';
+ else if (jQuery.nodeName(elem, "select")) {
+ val = elem.selectedIndex;
}
-
- // Save the current value for next time
- if (nowVal !== undefined) $el.data('changeVal', nowVal);
-
- // And if we decided that a change happened, do the actual triggering
- if (e.type == 'change') {
- while (el && el.nodeType == 1 && !e.isPropagationStopped()) {
- var ret = one(el, arguments);
+
+ return val;
+ };
+
+ // Test if a node name is a form input
+ var rformElems = /^(?:textarea|input|select)$/i;
+
+ // Check if this event is a change, and bubble the change event if it is
+ var testChange = function(e) {
+ var elem = e.target, data, val;
+
+ if (!rformElems.test(elem.nodeName) || elem.readOnly) return;
+
+ data = jQuery.data(elem, "_entwine_change_data");
+ val = getVal(elem);
+
+ // the current data will be also retrieved by beforeactivate
+ if (e.type !== "focusout" || elem.type !== "radio") {
+ jQuery.data(elem, "_entwine_change_data", val);
+ }
+
+ if (data === undefined || val === data) return;
+
+ if (data != null || val) {
+ e.type = "change";
+
+ while (elem && elem.nodeType == 1 && !e.isPropagationStopped()) {
+ var ret = one(elem, arguments);
if (ret !== undefined) e.result = ret;
if (ret === false) { e.preventDefault(); e.stopPropagation(); }
-
- el = el.parentNode;
+
+ elem = elem.parentNode;
}
}
};
-
+
+ // The actual proxy - responds to several events, some of which triger a change check, some
+ // of which just store the value for future change checks
+ var prxy = function(e) {
+ var event = e.type, elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
+
+ switch (event) {
+ case 'focusout':
+ case 'beforedeactivate':
+ testChange.apply(this, arguments);
+ break;
+
+ case 'click':
+ if ( type === "radio" || type === "checkbox" || jQuery.nodeName( elem, "select" ) ) {
+ testChange.apply(this, arguments);
+ }
+ break;
+
+ // Change has to be called before submit
+ // Keydown will be called before keypress, which is used in submit-event delegation
+ case 'keydown':
+ if (
+ (e.keyCode === 13 && !jQuery.nodeName( elem, "textarea" ) ) ||
+ (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
+ type === "select-multiple"
+ ) {
+ testChange.apply(this, arguments);
+ }
+ break;
+
+ // Beforeactivate happens also before the previous element is blurred
+ // with this event you can't trigger a change event, but you can store
+ // information
+ case 'focusin':
+ case 'beforeactivate':
+ jQuery.data( elem, "_entwine_change_data", getVal(elem) );
+ break;
+ }
+ }
+
return prxy;
},
@@ -124,9 +196,9 @@
event = 'mouseout';
break;
case 'onchange':
- if (!$.support.bubblingChange) {
+ if (!$.support.changeBubbles) {
proxies[name] = this.build_change_proxy(name);
- event = 'click focusin focusout keydown';
+ event = 'click keydown focusin focusout beforeactivate beforedeactivate';
}
break;
case 'onsubmit':
@@ -139,8 +211,8 @@
// If none of the special handlers created a proxy, use the generic proxy
if (!proxies[name]) proxies[name] = this.build_event_proxy(name);
-
- $(document).bind(event+'.entwine', proxies[name]);
+
+ $(document).bind(event.replace(/(\s+|$)/g, '.entwine$1'), proxies[name]);
}
}
});
View
7 thirdparty/jquery-entwine/src/jquery.entwine.js
@@ -1,4 +1,9 @@
-var console;
+try {
+ console.log;
+}
+catch (e) {
+ window.console = undefined;
+}
(function($) {
View
2  thirdparty/jquery-entwine/src/jquery.entwine.properties.js
@@ -58,7 +58,7 @@
var getterName = 'get'+k;
var setterName = 'set'+k;
- this.bind_proxy(selector, getterName, function() { return this.entwineData(k) || v ; });
+ this.bind_proxy(selector, getterName, function() { var r = this.entwineData(k); return r === undefined ? v : r; });
this.bind_proxy(selector, setterName, function(v){ return this.entwineData(k, v); });
// Get the get and set proxies we just created
View
1,342 ...party/jquery-entwine/vendor/jquery-1.5.js → ...rty/jquery-entwine/vendor/jquery-1.5.2.js
@@ -1,5 +1,5 @@
/*!
- * jQuery JavaScript Library v1.5
+ * jQuery JavaScript Library v1.5.2
* http://jquery.com/
*
* Copyright 2011, John Resig
@@ -11,7 +11,7 @@
* Copyright 2011, The Dojo Foundation
* Released under the MIT, BSD, and GPL Licenses.
*
- * Date: Mon Jan 31 08:31:29 2011 -0500
+ * Date: Thu Mar 31 15:28:23 2011 -0400
*/
(function( window, undefined ) {
@@ -69,15 +69,9 @@ var jQuery = function( selector, context ) {
// For matching the engine and version of the browser
browserMatch,
- // Has the ready events already been bound?
- readyBound = false,
-
// The deferred used on DOM ready
readyList,
- // Promise methods
- promiseMethods = "then done fail isResolved isRejected promise".split( " " ),
-
// The ready event handler
DOMContentLoaded,
@@ -202,7 +196,7 @@ jQuery.fn = jQuery.prototype = {
selector: "",
// The current version of jQuery being used
- jquery: "1.5",
+ jquery: "1.5.2",
// The default length of a jQuery object is 0
length: 0,
@@ -313,7 +307,7 @@ jQuery.fn = jQuery.prototype = {
jQuery.fn.init.prototype = jQuery.fn;
jQuery.extend = jQuery.fn.extend = function() {
- var options, name, src, copy, copyIsArray, clone,
+ var options, name, src, copy, copyIsArray, clone,
target = arguments[0] || {},
i = 1,
length = arguments.length,
@@ -427,11 +421,11 @@ jQuery.extend({
},
bindReady: function() {
- if ( readyBound ) {
+ if ( readyList ) {
return;
}
- readyBound = true;
+ readyList = jQuery._Deferred();
// Catch cases where $(document).ready() is called after the
// browser event has already occurred.
@@ -585,10 +579,8 @@ jQuery.extend({
if ( data && rnotwhite.test(data) ) {
// Inspired by code by Andrea Giammarchi
// http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
- var head = document.getElementsByTagName("head")[0] || document.documentElement,
- script = document.createElement("script");
-
- script.type = "text/javascript";
+ var head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement,
+ script = document.createElement( "script" );
if ( jQuery.support.scriptEval() ) {
script.appendChild( document.createTextNode( data ) );
@@ -813,6 +805,123 @@ jQuery.extend({
return (new Date()).getTime();
},
+ // Use of jQuery.browser is frowned upon.
+ // More details: http://docs.jquery.com/Utilities/jQuery.browser
+ uaMatch: function( ua ) {
+ ua = ua.toLowerCase();
+
+ var match = rwebkit.exec( ua ) ||
+ ropera.exec( ua ) ||
+ rmsie.exec( ua ) ||
+ ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
+ [];
+
+ return { browser: match[1] || "", version: match[2] || "0" };
+ },
+
+ sub: function() {
+ function jQuerySubclass( selector, context ) {
+ return new jQuerySubclass.fn.init( selector, context );
+ }
+ jQuery.extend( true, jQuerySubclass, this );
+ jQuerySubclass.superclass = this;
+ jQuerySubclass.fn = jQuerySubclass.prototype = this();
+ jQuerySubclass.fn.constructor = jQuerySubclass;
+ jQuerySubclass.subclass = this.subclass;
+ jQuerySubclass.fn.init = function init( selector, context ) {
+ if ( context && context instanceof jQuery && !(context instanceof jQuerySubclass) ) {
+ context = jQuerySubclass(context);
+ }
+
+ return jQuery.fn.init.call( this, selector, context, rootjQuerySubclass );
+ };
+ jQuerySubclass.fn.init.prototype = jQuerySubclass.fn;
+ var rootjQuerySubclass = jQuerySubclass(document);
+ return jQuerySubclass;
+ },
+
+ browser: {}
+});
+
+// Populate the class2type map
+jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
+ class2type[ "[object " + name + "]" ] = name.toLowerCase();
+});
+
+browserMatch = jQuery.uaMatch( userAgent );
+if ( browserMatch.browser ) {
+ jQuery.browser[ browserMatch.browser ] = true;
+ jQuery.browser.version = browserMatch.version;
+}
+
+// Deprecated, use jQuery.browser.webkit instead
+if ( jQuery.browser.webkit ) {
+ jQuery.browser.safari = true;
+}
+
+if ( indexOf ) {
+ jQuery.inArray = function( elem, array ) {
+ return indexOf.call( array, elem );
+ };
+}
+
+// IE doesn't match non-breaking spaces with \s
+if ( rnotwhite.test( "\xA0" ) ) {
+ trimLeft = /^[\s\xA0]+/;
+ trimRight = /[\s\xA0]+$/;
+}
+
+// All jQuery objects should point back to these
+rootjQuery = jQuery(document);
+
+// Cleanup functions for the document ready method
+if ( document.addEventListener ) {
+ DOMContentLoaded = function() {
+ document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+ jQuery.ready();
+ };
+
+} else if ( document.attachEvent ) {
+ DOMContentLoaded = function() {
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( document.readyState === "complete" ) {
+ document.detachEvent( "onreadystatechange", DOMContentLoaded );
+ jQuery.ready();
+ }
+ };
+}
+
+// The DOM ready check for Internet Explorer
+function doScrollCheck() {
+ if ( jQuery.isReady ) {
+ return;
+ }
+
+ try {
+ // If IE is used, use the trick by Diego Perini
+ // http://javascript.nwbox.com/IEContentLoaded/
+ document.documentElement.doScroll("left");
+ } catch(e) {
+ setTimeout( doScrollCheck, 1 );
+ return;
+ }
+
+ // and execute any waiting functions
+ jQuery.ready();
+}
+
+// Expose jQuery to the global object
+return jQuery;
+
+})();
+
+
+var // Promise methods
+ promiseMethods = "then done fail isResolved isRejected promise".split( " " ),
+ // Static reference to slice
+ sliceDeferred = [].slice;
+
+jQuery.extend({
// Create a simple deferred (one callbacks list)
_Deferred: function() {
var // callbacks list
@@ -858,6 +967,8 @@ jQuery.extend({
// 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 ] ) {
@@ -874,7 +985,7 @@ jQuery.extend({
// resolve with this as context and given arguments
resolve: function() {
- deferred.resolveWith( jQuery.isFunction( this.promise ) ? this.promise() : this, arguments );
+ deferred.resolveWith( this, arguments );
return this;
},
@@ -911,22 +1022,22 @@ jQuery.extend({
isRejected: failDeferred.isResolved,
// Get a promise for this deferred
// If obj is provided, the promise aspect is added to the object
- promise: function( obj , i /* internal */ ) {
+ promise: function( obj ) {
if ( obj == null ) {
if ( promise ) {
return promise;
}
promise = obj = {};
}
- i = promiseMethods.length;
+ var i = promiseMethods.length;
while( i-- ) {
- obj[ promiseMethods[ i ] ] = deferred[ promiseMethods[ i ] ];
+ obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ];
}
return obj;
}
} );
// Make sure only one callback list will be used
- deferred.then( failDeferred.cancel, deferred.cancel );
+ deferred.done( failDeferred.cancel ).fail( deferred.cancel );
// Unexpose cancel
delete deferred.cancel;
// Call given func if any
@@ -937,143 +1048,44 @@ jQuery.extend({
},
// Deferred helper
- when: function( object ) {
+ when: function( firstParam ) {
var args = arguments,
+ i = 0,
length = args.length,
- deferred = length <= 1 && object && jQuery.isFunction( object.promise ) ?
- object :
- jQuery.Deferred(),
- promise = deferred.promise(),
- resolveArray;
-
- if ( length > 1 ) {
- resolveArray = new Array( length );
- jQuery.each( args, function( index, element ) {
- jQuery.when( element ).then( function( value ) {
- resolveArray[ index ] = arguments.length > 1 ? slice.call( arguments, 0 ) : value;
- if( ! --length ) {
- deferred.resolveWith( promise, resolveArray );
- }
- }, deferred.reject );
- } );
- } else if ( deferred !== object ) {
- deferred.resolve( object );
- }
- return promise;
- },
-
- // Use of jQuery.browser is frowned upon.
- // More details: http://docs.jquery.com/Utilities/jQuery.browser
- uaMatch: function( ua ) {
- ua = ua.toLowerCase();
-
- var match = rwebkit.exec( ua ) ||
- ropera.exec( ua ) ||
- rmsie.exec( ua ) ||
- ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
- [];
-
- return { browser: match[1] || "", version: match[2] || "0" };
- },
-
- sub: function() {
- function jQuerySubclass( selector, context ) {
- return new jQuerySubclass.fn.init( selector, context );
+ count = length,
+ deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
+ firstParam :
+ jQuery.Deferred();
+ function resolveFunc( i ) {
+ return function( value ) {
+ args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
+ if ( !( --count ) ) {
+ // Strange bug in FF4:
+ // 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 ) );
+ }
+ };
}
- jQuery.extend( true, jQuerySubclass, this );
- jQuerySubclass.superclass = this;
- jQuerySubclass.fn = jQuerySubclass.prototype = this();
- jQuerySubclass.fn.constructor = jQuerySubclass;
- jQuerySubclass.subclass = this.subclass;
- jQuerySubclass.fn.init = function init( selector, context ) {
- if ( context && context instanceof jQuery && !(context instanceof jQuerySubclass) ) {
- context = jQuerySubclass(context);
+ if ( length > 1 ) {
+ for( ; i < length; i++ ) {
+ if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) {
+ args[ i ].promise().then( resolveFunc(i), deferred.reject );
+ } else {
+ --count;
+ }
}
-
- return jQuery.fn.init.call( this, selector, context, rootjQuerySubclass );
- };
- jQuerySubclass.fn.init.prototype = jQuerySubclass.fn;
- var rootjQuerySubclass = jQuerySubclass(document);
- return jQuerySubclass;
- },
-
- browser: {}
-});
-
-// Create readyList deferred
-readyList = jQuery._Deferred();
-
-// Populate the class2type map
-jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
- class2type[ "[object " + name + "]" ] = name.toLowerCase();
-});
-
-browserMatch = jQuery.uaMatch( userAgent );
-if ( browserMatch.browser ) {
- jQuery.browser[ browserMatch.browser ] = true;
- jQuery.browser.version = browserMatch.version;
-}
-
-// Deprecated, use jQuery.browser.webkit instead
-if ( jQuery.browser.webkit ) {
- jQuery.browser.safari = true;
-}
-
-if ( indexOf ) {
- jQuery.inArray = function( elem, array ) {
- return indexOf.call( array, elem );
- };
-}
-
-// IE doesn't match non-breaking spaces with \s
-if ( rnotwhite.test( "\xA0" ) ) {
- trimLeft = /^[\s\xA0]+/;
- trimRight = /[\s\xA0]+$/;
-}
-
-// All jQuery objects should point back to these
-rootjQuery = jQuery(document);
-
-// Cleanup functions for the document ready method
-if ( document.addEventListener ) {
- DOMContentLoaded = function() {
- document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
- jQuery.ready();
- };
-
-} else if ( document.attachEvent ) {
- DOMContentLoaded = function() {
- // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
- if ( document.readyState === "complete" ) {
- document.detachEvent( "onreadystatechange", DOMContentLoaded );
- jQuery.ready();
+ if ( !count ) {
+ deferred.resolveWith( deferred, args );
+ }
+ } else if ( deferred !== firstParam ) {
+ deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
}
- };
-}
-
-// The DOM ready check for Internet Explorer
-function doScrollCheck() {
- if ( jQuery.isReady ) {
- return;
+ return deferred.promise();
}
+});
- try {
- // If IE is used, use the trick by Diego Perini
- // http://javascript.nwbox.com/IEContentLoaded/
- document.documentElement.doScroll("left");
- } catch(e) {
- setTimeout( doScrollCheck, 1 );
- return;
- }
-
- // and execute any waiting functions
- jQuery.ready();
-}
-
-// Expose jQuery to the global object
-return (window.jQuery = window.$ = jQuery);
-})();
(function() {
@@ -1088,7 +1100,8 @@ return (window.jQuery = window.$ = jQuery);
var all = div.getElementsByTagName("*"),
a = div.getElementsByTagName("a")[0],
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
if ( !all || !all.length || !a ) {
@@ -1127,7 +1140,7 @@ return (window.jQuery = window.$ = jQuery);
// Make sure that if no value is specified for a checkbox
// that it defaults to "on".
// (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.
// (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
@@ -1137,48 +1150,50 @@ return (window.jQuery = window.$ = jQuery);
deleteExpando: true,
optDisabled: false,
checkClone: false,
- _scriptEval: null,
noCloneEvent: true,
+ noCloneChecked: true,
boxModel: null,
inlineBlockNeedsLayout: false,
shrinkWrapBlocks: false,
- reliableHiddenOffsets: true
+ reliableHiddenOffsets: true,
+ reliableMarginRight: true
};
+ input.checked = true;
+ jQuery.support.noCloneChecked = input.cloneNode( true ).checked;
+
// Make sure that the options inside disabled selects aren't marked as disabled
// (WebKit marks them as diabled)
select.disabled = true;
jQuery.support.optDisabled = !opt.disabled;
+ var _scriptEval = null;
jQuery.support.scriptEval = function() {
- if ( jQuery.support._scriptEval === null ) {
+ if ( _scriptEval === null ) {
var root = document.documentElement,
script = document.createElement("script"),
id = "script" + jQuery.now();
- script.type = "text/javascript";
+ // Make sure that the execution of code works by injecting a script
+ // tag with appendChild/createTextNode
+ // (IE doesn't support this, fails, and uses .text instead)
try {
script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
} catch(e) {}
root.insertBefore( script, root.firstChild );
- // Make sure that the execution of code works by injecting a script
- // tag with appendChild/createTextNode
- // (IE doesn't support this, fails, and uses .text instead)
if ( window[ id ] ) {
- jQuery.support._scriptEval = true;
+ _scriptEval = true;
delete window[ id ];
} else {
- jQuery.support._scriptEval = false;
+ _scriptEval = false;
}
root.removeChild( script );
- // release memory in IE
- root = script = id = null;
}
- return jQuery.support._scriptEval;
+ return _scriptEval;
};
// Test to see if it's possible to delete an expando from an element
@@ -1190,7 +1205,7 @@ return (window.jQuery = window.$ = jQuery);
jQuery.support.deleteExpando = false;
}
- if ( div.attachEvent && div.fireEvent ) {
+ if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
div.attachEvent("onclick", function click() {
// Cloning a node shouldn't copy over any
// bound event handlers (IE does this)
@@ -1260,6 +1275,17 @@ return (window.jQuery = window.$ = jQuery);
jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0;
div.innerHTML = "";
+ // Check if div with explicit width and no margin-right incorrectly
+ // gets computed margin-right based on width of container. For more
+ // info see bug #3333
+ // Fails in WebKit before Feb 2011 nightlies
+ // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
+ if ( document.defaultView && document.defaultView.getComputedStyle ) {
+ div.style.width = "1px";
+ div.style.marginRight = "0";
+ jQuery.support.reliableMarginRight = ( parseInt(document.defaultView.getComputedStyle(div, null).marginRight, 10) || 0 ) === 0;
+ }
+
body.removeChild( div ).style.display = "none";
div = tds = null;
});
@@ -1283,8 +1309,6 @@ return (window.jQuery = window.$ = jQuery);
el.setAttribute(eventName, "return;");
isSupported = typeof el[eventName] === "function";
}
- el = null;
-
return isSupported;
};
@@ -1321,7 +1345,7 @@ jQuery.extend({
hasData: function( elem ) {
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 */ ) {
@@ -1361,11 +1385,18 @@ jQuery.extend({
if ( !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
// shallow copied over onto the existing cache
- if ( typeof name === "object" ) {
+ if ( typeof name === "object" || typeof name === "function" ) {
if ( pvt ) {
cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
} else {
@@ -1427,7 +1458,7 @@ jQuery.extend({
// If there is no data left in the cache, we want to continue
// and let the cache object itself get destroyed
- if ( !jQuery.isEmptyObject(thisCache) ) {
+ if ( !isEmptyDataObject(thisCache) ) {
return;
}
}
@@ -1439,7 +1470,7 @@ jQuery.extend({
// Don't destroy the parent cache unless the internal data object
// had been the only thing left in it
- if ( !jQuery.isEmptyObject(cache[ id ]) ) {
+ if ( !isEmptyDataObject(cache[ id ]) ) {
return;
}
}
@@ -1460,6 +1491,13 @@ jQuery.extend({
// data if it existed
if ( internalCache ) {
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;
// Otherwise, we need to eliminate the expando on the node to avoid
@@ -1588,6 +1626,19 @@ function dataAttr( elem, key, 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;
+}
+
@@ -1888,6 +1939,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;
}
@@ -2081,8 +2137,7 @@ var rnamespaces = /\.(.*)$/,
rescape = /[^\w\s.|`]/g,
fcleanup = function( nm ) {
return nm.replace(rescape, "\\$&");
- },
- eventKey = "events";
+ };
/*
* A number of helper functions used for managing events.
@@ -2098,17 +2153,22 @@ jQuery.event = {
return;
}
- // For whatever reason, IE has trouble passing the window object
- // around, causing it to be cloned in the process
- if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
- elem = window;
+ // 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
+ // around, causing it to be cloned in the process
+ if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
+ elem = window;
+ }
}
+ catch ( e ) {}
if ( handler === false ) {
handler = returnFalse;
} else if ( !handler ) {
// Fixes bug #7229. Fix recommended by jdalton
- return;
+ return;
}
var handleObjIn, handleObj;
@@ -2132,31 +2192,18 @@ jQuery.event = {
return;
}
- var events = elemData[ eventKey ],
+ var events = elemData.events,
eventHandle = elemData.handle;
- if ( typeof events === "function" ) {
- // 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(){};
- }
-
+ if ( !events ) {
elemData.events = events = {};
}
if ( !eventHandle ) {
- elemData.handle = eventHandle = function() {
+ elemData.handle = eventHandle = function( e ) {
// Handle the second event of a trigger and when
// an event is called after a page has unloaded
- return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
+ return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
jQuery.event.handle.apply( eventHandle.elem, arguments ) :
undefined;
};
@@ -2249,17 +2296,12 @@ jQuery.event = {
var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
- events = elemData && elemData[ eventKey ];
+ events = elemData && elemData.events;
if ( !elemData || !events ) {
return;
}
- if ( typeof events === "function" ) {
- elemData = events;
- events = events.events;
- }
-
// types is actually an event object here
if ( types && types.type ) {
handler = types.handler;
@@ -2359,10 +2401,7 @@ jQuery.event = {
delete elemData.events;
delete elemData.handle;
- if ( typeof elemData === "function" ) {
- jQuery.removeData( elem, eventKey, true );
-
- } else if ( jQuery.isEmptyObject( elemData ) ) {
+ if ( jQuery.isEmptyObject( elemData ) ) {
jQuery.removeData( elem, undefined, true );
}
}
@@ -2403,7 +2442,7 @@ jQuery.event = {
// points to jQuery.expando
var internalKey = jQuery.expando,
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 );
}
});
@@ -2429,9 +2468,7 @@ jQuery.event = {
event.currentTarget = elem;
// Trigger the event, it is assumed that "handle" is a function
- var handle = elem.nodeType ?
- jQuery._data( elem, "handle" ) :
- (jQuery._data( elem, eventKey ) || {}).handle;
+ var handle = jQuery._data( elem, "handle" );
if ( handle ) {
handle.apply( elem, data );
@@ -2473,7 +2510,7 @@ jQuery.event = {
target[ "on" + targetType ] = null;
}
- jQuery.event.triggered = true;
+ jQuery.event.triggered = event.type;
target[ targetType ]();
}
@@ -2484,7 +2521,7 @@ jQuery.event = {
target[ "on" + targetType ] = old;
}
- jQuery.event.triggered = false;
+ jQuery.event.triggered = undefined;
}
}
},
@@ -2509,11 +2546,7 @@ jQuery.event = {
event.namespace = event.namespace || namespace_sort.join(".");
- events = jQuery._data(this, eventKey);
-
- if ( typeof events === "function" ) {
- events = events.events;
- }
+ events = jQuery._data(this, "events");
handlers = (events || {})[ event.type ];
@@ -2680,7 +2713,7 @@ jQuery.Event = function( src ) {
// Events bubbling up the document may have been marked as prevented
// by a handler lower down the tree; reflect the correct value.
- this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
+ this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
// Event type
@@ -2755,6 +2788,12 @@ var withinElement = function( event ) {
// Firefox sometimes assigns relatedTarget a XUL element
// which we cannot access the parentNode property of
try {
+
+ // Chrome does something similar, the parentNode property
+ // can be accessed but is null.
+ if ( parent && parent !== document && !parent.parentNode ) {
+ return;
+ }
// Traverse up the tree
while ( parent && parent !== this ) {
parent = parent.parentNode;
@@ -2805,8 +2844,7 @@ if ( !jQuery.support.submitBubbles ) {
type = elem.type;
if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
- e.liveFired = undefined;
- return trigger( "submit", this, arguments );
+ trigger( "submit", this, arguments );
}
});
@@ -2815,8 +2853,7 @@ if ( !jQuery.support.submitBubbles ) {
type = elem.type;
if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
- e.liveFired = undefined;
- return trigger( "submit", this, arguments );
+ trigger( "submit", this, arguments );
}
});
@@ -2879,7 +2916,7 @@ if ( !jQuery.support.changeBubbles ) {
if ( data != null || val ) {
e.type = "change";
e.liveFired = undefined;
- return jQuery.event.trigger( e, arguments[1], elem );
+ jQuery.event.trigger( e, arguments[1], elem );
}
};
@@ -2893,7 +2930,7 @@ if ( !jQuery.support.changeBubbles ) {
var elem = e.target, type = elem.type;
if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
- return testChange.call( this, e );
+ testChange.call( this, e );
}
},
@@ -2905,7 +2942,7 @@ if ( !jQuery.support.changeBubbles ) {
if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
(e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
type === "select-multiple" ) {
- return testChange.call( this, e );
+ testChange.call( this, e );
}
},
@@ -2944,26 +2981,50 @@ if ( !jQuery.support.changeBubbles ) {
}
function trigger( type, elem, args ) {
- args[0].type = type;
- return jQuery.event.handle.apply( elem, args );
+ // Piggyback on a donor event to simulate a different one.
+ // 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
if ( document.addEventListener ) {
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
+
+ // Attach a single capturing handler while someone wants focusin/focusout
+ var attaches = 0;
+
jQuery.event.special[ fix ] = {
setup: function() {
- this.addEventListener( orig, handler, true );
- },
- teardown: function() {
- this.removeEventListener( orig, handler, true );
+ if ( attaches++ === 0 ) {
+ document.addEventListener( orig, handler, true );
+ }
+ },
+ teardown: function() {
+ if ( --attaches === 0 ) {
+ document.removeEventListener( orig, handler, true );
+ }
}
};
- function handler( e ) {
- e = jQuery.event.fix( e );
+ function handler( donor ) {
+ // Donor event is always a native one; fix it and switch its type.
+ // Let focusin/out handler cancel the donor focus/blur event.
+ var e = jQuery.event.fix( donor );
e.type = fix;
- return jQuery.event.handle.call( this, e );
+ e.originalEvent = {};
+ jQuery.event.trigger( e, null, e.target );
+ if ( e.isDefaultPrevented() ) {
+ donor.preventDefault();
+ }
}
});
}
@@ -3148,11 +3209,7 @@ function liveHandler( event ) {
var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
elems = [],
selectors = [],
- events = jQuery._data( this, eventKey );
-
- if ( typeof events === "function" ) {
- events = events.events;
- }
+ events = jQuery._data( this, "events" );
// 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" ) {
@@ -3186,7 +3243,7 @@ function liveHandler( event ) {
for ( j = 0; j < live.length; 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;
related = null;
@@ -3269,7 +3326,9 @@ var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[
done = 0,
toString = Object.prototype.toString,
hasDuplicate = false,
- baseHasDuplicate = true;
+ baseHasDuplicate = true,
+ rBackslash = /\\/g,
+ rNonWord = /\W/;
// Here we check if the JavaScript engine is using some sort of
// optimization where it does not always call our comparision
@@ -3468,7 +3527,7 @@ Sizzle.find = function( expr, context, isXML ) {
match.splice( 1, 1 );
if ( left.substr( left.length - 1 ) !== "\\" ) {
- match[1] = (match[1] || "").replace(/\\/g, "");
+ match[1] = (match[1] || "").replace( rBackslash, "" );
set = Expr.find[ type ]( match, context, isXML );
if ( set != null ) {
@@ -3607,13 +3666,16 @@ var Expr = Sizzle.selectors = {
attrHandle: {
href: function( elem ) {
return elem.getAttribute( "href" );
+ },
+ type: function( elem ) {
+ return elem.getAttribute( "type" );
}
},
relative: {
"+": function(checkSet, part){
var isPartStr = typeof part === "string",
- isTag = isPartStr && !/\W/.test( part ),
+ isTag = isPartStr && !rNonWord.test( part ),
isPartStrNotTag = isPartStr && !isTag;
if ( isTag ) {
@@ -3641,7 +3703,7 @@ var Expr = Sizzle.selectors = {
i = 0,
l = checkSet.length;
- if ( isPartStr && !/\W/.test( part ) ) {
+ if ( isPartStr && !rNonWord.test( part ) ) {
part = part.toLowerCase();
for ( ; i < l; i++ ) {
@@ -3675,7 +3737,7 @@ var Expr = Sizzle.selectors = {
doneName = done++,
checkFn = dirCheck;
- if ( typeof part === "string" && !/\W/.test(part) ) {
+ if ( typeof part === "string" && !rNonWord.test( part ) ) {
part = part.toLowerCase();
nodeCheck = part;
checkFn = dirNodeCheck;
@@ -3689,7 +3751,7 @@ var Expr = Sizzle.selectors = {
doneName = done++,
checkFn = dirCheck;
- if ( typeof part === "string" && !/\W/.test( part ) ) {
+ if ( typeof part === "string" && !rNonWord.test( part ) ) {
part = part.toLowerCase();
nodeCheck = part;
checkFn = dirNodeCheck;
@@ -3732,7 +3794,7 @@ var Expr = Sizzle.selectors = {
},
preFilter: {
CLASS: function( match, curLoop, inplace, result, not, isXML ) {
- match = " " + match[1].replace(/\\/g, "") + " ";
+ match = " " + match[1].replace( rBackslash, "" ) + " ";
if ( isXML ) {
return match;
@@ -3755,11 +3817,11 @@ var Expr = Sizzle.selectors = {
},
ID: function( match ) {
- return match[1].replace(/\\/g, "");
+ return match[1].replace( rBackslash, "" );
},
TAG: function( match, curLoop ) {
- return match[1].toLowerCase();
+ return match[1].replace( rBackslash, "" ).toLowerCase();
},
CHILD: function( match ) {
@@ -3790,14 +3852,14 @@ var Expr = Sizzle.selectors = {
},
ATTR: function( match, curLoop, inplace, result, not, isXML ) {
- var name = match[1] = match[1].replace(/\\/g, "");
+ var name = match[1] = match[1].replace( rBackslash, "" );
if ( !isXML && Expr.attrMap[name] ) {
match[1] = Expr.attrMap[name];
}
// Handle if an un-quoted value was used
- match[4] = ( match[4] || match[5] || "" ).replace(/\\/g, "");
+ match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
if ( match[2] === "~=" ) {
match[4] = " " + match[4] + " ";
@@ -3852,7 +3914,9 @@ var Expr = Sizzle.selectors = {
selected: function( elem ) {
// Accessing this property makes selected-by-default
// options in Safari work properly
- elem.parentNode.selectedIndex;
+ if ( elem.parentNode ) {
+ elem.parentNode.selectedIndex;
+ }
return elem.selected === true;
},
@@ -3874,8 +3938,12 @@ var Expr = Sizzle.selectors = {
},
text: function( elem ) {
- return "text" === elem.type;
+ var attr = elem.getAttribute( "type" ), type = elem.type;
+ // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
+ // use getAttribute instead to test this case
+ return "text" === type && ( attr === type || attr === null );
},
+
radio: function( elem ) {
return "radio" === elem.type;
},
@@ -4407,7 +4475,8 @@ if ( document.querySelectorAll ) {
// and working up from there (Thanks to Andrew Dupont for the technique)
// IE 8 doesn't work on object elements
} else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
- var old = context.getAttribute( "id" ),
+ var oldContext = context,
+ old = context.getAttribute( "id" ),
nid = old || id,
hasParent = context.parentNode,
relativeHierarchySelector = /^\s*[+~]/.test( query );
@@ -4429,7 +4498,7 @@ if ( document.querySelectorAll ) {
} catch(pseudoError) {
} finally {
if ( !old ) {
- context.removeAttribute( "id" );
+ oldContext.removeAttribute( "id" );
}
}
}
@@ -4449,19 +4518,23 @@ if ( document.querySelectorAll ) {
(function(){
var html = document.documentElement,
- matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector,
- pseudoWorks = false;
+ matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;
- try {
- // This should fail with an exception
- // Gecko does not error, returns false instead
- matches.call( document.documentElement, "[test!='']:sizzle" );
+ if ( matches ) {
+ // Check to see if it's possible to do matchesSelector
+ // on a disconnected node (IE 9 fails this)
+ var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ),
+ pseudoWorks = false;
+
+ try {
+ // This should fail with an exception
+ // Gecko does not error, returns false instead
+ matches.call( document.documentElement, "[test!='']:sizzle" );
- } catch( pseudoError ) {
- pseudoWorks = true;
- }
+ } catch( pseudoError ) {
+ pseudoWorks = true;
+ }
- if ( matches ) {
Sizzle.matchesSelector = function( node, expr ) {
// Make sure that attribute selectors are quoted
expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
@@ -4469,7 +4542,15 @@ if ( document.querySelectorAll ) {
if ( !Sizzle.isXML( node ) ) {
try {
if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
- return matches.call( node, expr );
+ var ret = matches.call( node, expr );
+
+ // IE 9's matchesSelector returns false on disconnected nodes
+ if ( ret || !disconnectedMatch ||
+ // As well, disconnected nodes are said to be in a document
+ // fragment in IE 9, so check for that
+ node.document && node.document.nodeType !== 11 ) {
+ return ret;
+ }
}
} catch(e) {}
}
@@ -4845,11 +4926,11 @@ jQuery.each({
}, function( name, fn ) {
jQuery.fn[ name ] = function( until, selector ) {
var ret = jQuery.map( this, fn, until ),
- // The variable 'args' was introduced in
- // https://github.com/jquery/jquery/commit/52a0238
- // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
- // http://code.google.com/p/v8/issues/detail?id=1050
- args = slice.call(arguments);
+ // The variable 'args' was introduced in
+ // https://github.com/jquery/jquery/commit/52a0238
+ // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
+ // http://code.google.com/p/v8/issues/detail?id=1050
+ args = slice.call(arguments);
if ( !runtil.test( name ) ) {
selector = until;
@@ -4959,7 +5040,7 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
rtbody = /<tbody/i,
rhtml = /<|&#?\w+;/,
rnocache = /<(?:script|object|embed|option|style)/i,
- // checked="checked" or checked (html5)
+ // checked="checked" or checked
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
wrapMap = {
option: [ 1, "<select multiple='multiple'>", "</select>" ],
@@ -5111,7 +5192,7 @@ jQuery.fn.extend({
}
if ( elem.parentNode ) {
- elem.parentNode.removeChild( elem );
+ elem.parentNode.removeChild( elem );
}
}
}
@@ -5136,7 +5217,7 @@ jQuery.fn.extend({
},
clone: function( dataAndEvents, deepDataAndEvents ) {
- dataAndEvents = dataAndEvents == null ? true : dataAndEvents;
+ dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
return this.map( function () {
@@ -5213,7 +5294,9 @@ jQuery.fn.extend({
}
});
} else {
- return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value );
+ return this.length ?
+ this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
+ this;
}
},
@@ -5305,8 +5388,8 @@ function cloneCopyEvent( src, dest ) {
}
var internalKey = jQuery.expando,
- oldData = jQuery.data( src ),
- curData = jQuery.data( dest, oldData );
+ oldData = jQuery.data( src ),
+ curData = jQuery.data( dest, oldData );
// Switch to use the internal data object, if it exists, for the next
// stage of data copying
@@ -5320,7 +5403,7 @@ function cloneCopyEvent( src, dest ) {
for ( var type in events ) {
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 );
}
}
}
@@ -5441,6 +5524,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({
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
var clone = elem.cloneNode(true),
@@ -5448,17 +5543,20 @@ jQuery.extend({
destElements,
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.
// Calling detachEvent on the clone will also remove the events
// from the original. In order to get around this, we use some
// proprietary methods to clear the events. Thanks to MooTools
// guys for this hotness.
+ cloneFixAttributes( elem, clone );
+
// Using Sizzle here is crazy slow, so we use getElementsByTagName
// instead
- srcElements = elem.getElementsByTagName("*");
- destElements = clone.getElementsByTagName("*");
+ srcElements = getAll( elem );
+ destElements = getAll( clone );
// Weird iteration because IE will replace the length property
// with an element if you are cloning the body and one of the
@@ -5466,30 +5564,25 @@ jQuery.extend({
for ( i = 0; srcElements[i]; ++i ) {
cloneFixAttributes( srcElements[i], destElements[i] );
}
-
- cloneFixAttributes( elem, clone );
}
// Copy the events from the original to the clone
if ( dataAndEvents ) {
-
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 ) {
- cloneCopyEvent( srcElements[i], destElements[i] );
- }
+ for ( i = 0; srcElements[i]; ++i ) {
+ cloneCopyEvent( srcElements[i], destElements[i] );
}
}
}
+
// Return the cloned set
return clone;
- },
+},
clean: function( elems, context, fragment, scripts ) {
context = context || document;
@@ -5650,7 +5743,8 @@ function evalScript( i, elem ) {
var ralpha = /alpha\([^)]*\)/i,
ropacity = /opacity=([^)]*)/,
rdashAlpha = /-([a-z])/ig,
- rupper = /([A-Z])/g,
+ // fixed for IE9, see #8346
+ rupper = /([A-Z]|^ms)/g,
rnumpx = /^-?\d+(?:px)?$/i,
rnum = /^-?\d/,
@@ -5887,6 +5981,28 @@ if ( !jQuery.support.opacity ) {
};
}
+jQuery(function() {
+ // This hook cannot be added until DOM ready because the support test
+ // for it is not run until after DOM ready
+ if ( !jQuery.support.reliableMarginRight ) {
+ jQuery.cssHooks.marginRight = {
+ get: function( elem, computed ) {
+ // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
+ // Work around by temporarily setting element display to inline-block
+ var ret;
+ jQuery.swap( elem, { "display": "inline-block" }, function() {
+ if ( computed ) {
+ ret = curCSS( elem, "margin-right", "marginRight" );
+ } else {
+ ret = elem.style.marginRight;
+ }
+ });
+ return ret;
+ }
+ };
+ }
+});
+
if ( document.defaultView && document.defaultView.getComputedStyle ) {
getComputedStyle = function( elem, newName, name ) {
var ret, defaultView, computedStyle;
@@ -5910,7 +6026,7 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) {
if ( document.documentElement.currentStyle ) {
currentStyle = function( elem, name ) {
- var left,
+ var left,
ret = elem.currentStyle && elem.currentStyle[ name ],
rsLeft = elem.runtimeStyle && elem.runtimeStyle[ name ],
style = elem.style;
@@ -5988,8 +6104,10 @@ var r20 = /%20/g,
rbracket = /\[\]$/,
rCRLF = /\r?\n/g,
rhash = /#.*$/,
- rheaders = /^(.*?):\s*(.*?)\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|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
+ // #7653, #8125, #8152: local protocol detection
+ rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|widget):$/,
rnoContent = /^(?:GET|HEAD)$/,
rprotocol = /^\/\//,
rquery = /\?/,
@@ -5997,7 +6115,11 @@ var r20 = /%20/g,
rselectTextarea = /^(?:select|textarea)/i,
rspacesAjax = /\s+/,
rts = /([?&])_=[^&]*/,
- rurl = /^(\w+:)\/\/([^\/?#:]+)(?::(\d+))?/,
+ rucHeaders = /(^|\-)([a-z])/g,
+ rucHeadersFunc = function( _, $1, $2 ) {
+ return $1 + $2.toUpperCase();
+ },
+ rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,
// Keep a copy of the old load method
_load = jQuery.fn.load,
@@ -6018,7 +6140,28 @@ var r20 = /%20/g,
* 2) the catchall symbol "*" can be used
* 3) selection will start with transport dataType and THEN go to "*" if needed
*/
- transports = {};
+ transports = {},
+
+ // Document location
+ ajaxLocation,
+
+ // Document location segments
+ ajaxLocParts;
+
+// #8138, IE may throw an exception when accessing
+// a field from document.location if document.domain has been set
+try {
+ ajaxLocation = document.location.href;
+} catch( e ) {
+ // Use the href attribute of an A element
+ // since IE will modify it given document.location
+ ajaxLocation = document.createElement( "a" );
+ ajaxLocation.href = "";
+ ajaxLocation = ajaxLocation.href;
+}
+
+// Segment location into parts
+ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
function addToPrefiltersOrTransports( structure ) {
@@ -6057,7 +6200,7 @@ function addToPrefiltersOrTransports( structure ) {
}
//Base inspection function for prefilters and transports
-function inspectPrefiltersOrTransports( structure, options, originalOptions, jXHR,
+function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
dataType /* internal */, inspected /* internal */ ) {
dataType = dataType || options.dataTypes[ 0 ];
@@ -6072,16 +6215,16 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jXH
selection;
for(; i < length && ( executeOnly || !selection ); i++ ) {
- selection = list[ i ]( options, originalOptions, jXHR );
+ selection = list[ i ]( options, originalOptions, jqXHR );
// If we got redirected to another dataType
- // we try there if not done already
+ // we try there if executing only and not done already
if ( typeof selection === "string" ) {
- if ( inspected[ selection ] ) {
+ if ( !executeOnly || inspected[ selection ] ) {
selection = undefined;
} else {
options.dataTypes.unshift( selection );
selection = inspectPrefiltersOrTransports(
- structure, options, originalOptions, jXHR, selection, inspected );
+ structure, options, originalOptions, jqXHR, selection, inspected );
}
}
}
@@ -6089,7 +6232,7 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jXH
// we try the catchall dataType if not done already
if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
selection = inspectPrefiltersOrTransports(
- structure, options, originalOptions, jXHR, "*", inspected );
+ structure, options, originalOptions, jqXHR, "*", inspected );
}
// unnecessary when only executing (prefilters)
// but it'll be ignored by the caller in that case
@@ -6121,7 +6264,7 @@ jQuery.fn.extend({
if ( jQuery.isFunction( params ) ) {
// We assume that it's the callback
callback = params;
- params = null;
+ params = undefined;
// Otherwise, build a param string
} else if ( typeof params === "object" ) {
@@ -6139,14 +6282,14 @@ jQuery.fn.extend({
dataType: "html",
data: params,
// Complete callback (responseText is used internally)
- complete: function( jXHR, status, responseText ) {
- // Store the response as specified by the jXHR object
- responseText = jXHR.responseText;
+ complete: function( jqXHR, status, responseText ) {
+ // Store the response as specified by the jqXHR object
+ responseText = jqXHR.responseText;
// If successful, inject the HTML into all the matched elements
- if ( jXHR.isResolved() ) {
+ if ( jqXHR.isResolved() ) {
// #4825: Get the actual response in case
// a dataFilter is present in ajaxSettings
- jXHR.done(function( r ) {