2010-09-08 16:00:29 +00:00
|
|
|
|
(function( jQuery ) {
|
|
|
|
|
|
2011-04-07 04:51:37 +00:00
|
|
|
|
jQuery.support = (function() {
|
|
|
|
|
|
|
|
|
|
var div = document.createElement( "div" ),
|
2011-05-09 07:48:23 +00:00
|
|
|
|
documentElement = document.documentElement,
|
2011-04-07 04:51:37 +00:00
|
|
|
|
all,
|
|
|
|
|
a,
|
|
|
|
|
select,
|
|
|
|
|
opt,
|
|
|
|
|
input,
|
2011-04-12 03:59:12 +00:00
|
|
|
|
marginDiv,
|
2011-04-07 04:51:37 +00:00
|
|
|
|
support,
|
|
|
|
|
fragment,
|
|
|
|
|
body,
|
2011-05-13 15:43:32 +00:00
|
|
|
|
testElementParent,
|
|
|
|
|
testElement,
|
|
|
|
|
testElementStyle,
|
2011-04-07 04:51:37 +00:00
|
|
|
|
tds,
|
|
|
|
|
events,
|
|
|
|
|
eventName,
|
|
|
|
|
i,
|
2011-09-20 01:03:41 +00:00
|
|
|
|
isSupported,
|
|
|
|
|
offsetSupport;
|
2011-04-07 04:51:37 +00:00
|
|
|
|
|
|
|
|
|
// Preliminary tests
|
2011-04-10 21:08:18 +00:00
|
|
|
|
div.setAttribute("className", "t");
|
2011-09-19 20:42:36 +00:00
|
|
|
|
div.innerHTML = " <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/><nav></nav>";
|
2011-09-01 15:16:38 +00:00
|
|
|
|
|
2008-12-21 23:06:42 +00:00
|
|
|
|
|
2011-04-07 04:51:37 +00:00
|
|
|
|
all = div.getElementsByTagName( "*" );
|
|
|
|
|
a = div.getElementsByTagName( "a" )[ 0 ];
|
2008-12-21 23:06:42 +00:00
|
|
|
|
|
|
|
|
|
// Can't get basic test support
|
|
|
|
|
if ( !all || !all.length || !a ) {
|
2011-04-07 04:51:37 +00:00
|
|
|
|
return {};
|
2008-12-21 23:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-07 04:51:37 +00:00
|
|
|
|
// First batch of supports tests
|
|
|
|
|
select = document.createElement( "select" );
|
|
|
|
|
opt = select.appendChild( document.createElement("option") );
|
|
|
|
|
input = div.getElementsByTagName( "input" )[ 0 ];
|
|
|
|
|
|
|
|
|
|
support = {
|
2008-12-21 23:06:42 +00:00
|
|
|
|
// IE strips leading whitespace when .innerHTML is used
|
2011-04-07 04:51:37 +00:00
|
|
|
|
leadingWhitespace: ( div.firstChild.nodeType === 3 ),
|
2009-03-23 01:55:17 +00:00
|
|
|
|
|
2008-12-21 23:06:42 +00:00
|
|
|
|
// Make sure that tbody elements aren't automatically inserted
|
|
|
|
|
// IE will insert them into empty tables
|
2011-04-07 04:51:37 +00:00
|
|
|
|
tbody: !div.getElementsByTagName( "tbody" ).length,
|
2009-03-23 01:55:17 +00:00
|
|
|
|
|
2008-12-21 23:06:42 +00:00
|
|
|
|
// Make sure that link elements get serialized correctly by innerHTML
|
|
|
|
|
// This requires a wrapper element in IE
|
2011-04-07 04:51:37 +00:00
|
|
|
|
htmlSerialize: !!div.getElementsByTagName( "link" ).length,
|
2009-03-23 01:55:17 +00:00
|
|
|
|
|
2008-12-21 23:06:42 +00:00
|
|
|
|
// Get the style information from getAttribute
|
2011-04-07 04:51:37 +00:00
|
|
|
|
// (IE uses .cssText instead)
|
2011-04-10 21:08:18 +00:00
|
|
|
|
style: /top/.test( a.getAttribute("style") ),
|
2009-03-23 01:55:17 +00:00
|
|
|
|
|
2008-12-21 23:06:42 +00:00
|
|
|
|
// Make sure that URLs aren't manipulated
|
|
|
|
|
// (IE normalizes it by default)
|
2011-04-07 04:51:37 +00:00
|
|
|
|
hrefNormalized: ( a.getAttribute( "href" ) === "/a" ),
|
2009-03-23 01:55:17 +00:00
|
|
|
|
|
2008-12-21 23:06:42 +00:00
|
|
|
|
// Make sure that element opacity exists
|
|
|
|
|
// (IE uses filter instead)
|
2009-12-10 04:37:14 +00:00
|
|
|
|
// Use a regex to work around a WebKit issue. See #5145
|
2011-10-12 02:37:52 +00:00
|
|
|
|
opacity: /^0.55/.test( a.style.opacity ),
|
2009-03-23 01:55:17 +00:00
|
|
|
|
|
2008-12-21 23:06:42 +00:00
|
|
|
|
// Verify style float existence
|
|
|
|
|
// (IE uses styleFloat instead of cssFloat)
|
|
|
|
|
cssFloat: !!a.style.cssFloat,
|
|
|
|
|
|
2011-09-19 20:42:36 +00:00
|
|
|
|
// Make sure unknown elements (like HTML5 elems) are handled appropriately
|
|
|
|
|
unknownElems: !!div.getElementsByTagName( "nav" ).length,
|
|
|
|
|
|
2009-12-22 07:00:46 +00:00
|
|
|
|
// Make sure that if no value is specified for a checkbox
|
|
|
|
|
// that it defaults to "on".
|
|
|
|
|
// (WebKit defaults to "" instead)
|
2011-04-08 16:24:25 +00:00
|
|
|
|
checkOn: ( input.value === "on" ),
|
2009-12-22 07:00:46 +00:00
|
|
|
|
|
2009-12-22 20:46:54 +00:00
|
|
|
|
// 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)
|
2010-09-27 14:19:55 +00:00
|
|
|
|
optSelected: opt.selected,
|
2011-04-13 16:35:38 +00:00
|
|
|
|
|
2011-03-13 19:44:51 +00:00
|
|
|
|
// Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
|
2011-03-12 02:28:42 +00:00
|
|
|
|
getSetAttribute: div.className !== "t",
|
2009-12-22 20:46:54 +00:00
|
|
|
|
|
2011-10-22 20:03:57 +00:00
|
|
|
|
// Tests for enctype support on a form(#6743)
|
|
|
|
|
enctype: !!document.createElement("form").enctype,
|
|
|
|
|
|
2008-12-21 23:06:42 +00:00
|
|
|
|
// Will be defined later
|
2011-04-07 04:51:37 +00:00
|
|
|
|
submitBubbles: true,
|
|
|
|
|
changeBubbles: true,
|
2011-04-08 16:24:25 +00:00
|
|
|
|
focusinBubbles: false,
|
2010-10-17 14:56:01 +00:00
|
|
|
|
deleteExpando: true,
|
2009-01-11 16:17:20 +00:00
|
|
|
|
noCloneEvent: true,
|
2010-10-05 18:28:43 +00:00
|
|
|
|
inlineBlockNeedsLayout: false,
|
2010-10-05 19:53:35 +00:00
|
|
|
|
shrinkWrapBlocks: false,
|
2011-03-24 19:41:46 +00:00
|
|
|
|
reliableMarginRight: true
|
2008-12-21 23:06:42 +00:00
|
|
|
|
};
|
2009-03-23 01:55:17 +00:00
|
|
|
|
|
2011-04-07 04:51:37 +00:00
|
|
|
|
// Make sure checked status is properly cloned
|
2011-02-23 18:18:44 +00:00
|
|
|
|
input.checked = true;
|
2011-04-07 04:51:37 +00:00
|
|
|
|
support.noCloneChecked = input.cloneNode( true ).checked;
|
2011-02-23 18:18:44 +00:00
|
|
|
|
|
2010-09-27 14:19:55 +00:00
|
|
|
|
// Make sure that the options inside disabled selects aren't marked as disabled
|
2011-04-07 04:51:37 +00:00
|
|
|
|
// (WebKit marks them as disabled)
|
2010-09-27 14:19:55 +00:00
|
|
|
|
select.disabled = true;
|
2011-04-07 04:51:37 +00:00
|
|
|
|
support.optDisabled = !opt.disabled;
|
2008-12-21 23:06:42 +00:00
|
|
|
|
|
2010-10-17 14:56:01 +00:00
|
|
|
|
// Test to see if it's possible to delete an expando from an element
|
|
|
|
|
// Fails in Internet Explorer
|
|
|
|
|
try {
|
2011-01-17 21:31:12 +00:00
|
|
|
|
delete div.test;
|
2011-04-07 04:51:37 +00:00
|
|
|
|
} catch( e ) {
|
|
|
|
|
support.deleteExpando = false;
|
2010-10-17 14:56:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-02-07 16:56:48 +00:00
|
|
|
|
if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
|
2011-05-25 19:08:37 +00:00
|
|
|
|
div.attachEvent( "onclick", function() {
|
2008-12-21 23:06:42 +00:00
|
|
|
|
// Cloning a node shouldn't copy over any
|
|
|
|
|
// bound event handlers (IE does this)
|
2011-04-07 04:51:37 +00:00
|
|
|
|
support.noCloneEvent = false;
|
2011-04-08 15:41:14 +00:00
|
|
|
|
});
|
2011-04-07 04:51:37 +00:00
|
|
|
|
div.cloneNode( true ).fireEvent( "onclick" );
|
2008-12-21 23:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-09-20 15:23:01 +00:00
|
|
|
|
// Check if a radio maintains its value
|
2011-04-22 04:27:52 +00:00
|
|
|
|
// after being appended to the DOM
|
2011-04-22 01:33:09 +00:00
|
|
|
|
input = document.createElement("input");
|
|
|
|
|
input.value = "t";
|
|
|
|
|
input.setAttribute("type", "radio");
|
|
|
|
|
support.radioValue = input.value === "t";
|
|
|
|
|
|
2011-04-22 04:27:52 +00:00
|
|
|
|
input.setAttribute("checked", "checked");
|
|
|
|
|
div.appendChild( input );
|
2011-04-07 04:51:37 +00:00
|
|
|
|
fragment = document.createDocumentFragment();
|
2011-10-24 15:33:09 +00:00
|
|
|
|
fragment.appendChild( div.lastChild );
|
2010-01-25 23:43:33 +00:00
|
|
|
|
|
|
|
|
|
// WebKit doesn't clone checked state correctly in fragments
|
2011-04-07 04:51:37 +00:00
|
|
|
|
support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
|
2010-01-25 23:43:33 +00:00
|
|
|
|
|
2011-04-07 04:51:37 +00:00
|
|
|
|
div.innerHTML = "";
|
2009-01-11 16:17:20 +00:00
|
|
|
|
|
2011-04-07 04:51:37 +00:00
|
|
|
|
// Figure out if the W3C box model works as expected
|
|
|
|
|
div.style.width = div.style.paddingLeft = "1px";
|
|
|
|
|
|
2011-09-20 15:23:01 +00:00
|
|
|
|
// We don't want to do body-related feature tests on frameset
|
|
|
|
|
// documents, which lack a body. So we use
|
|
|
|
|
// document.getElementsByTagName("body")[0], which is undefined in
|
|
|
|
|
// frameset documents, while document.body isn’t. (7398)
|
|
|
|
|
body = document.getElementsByTagName("body")[ 0 ];
|
2011-05-13 15:43:32 +00:00
|
|
|
|
// We use our own, invisible, body unless the body is already present
|
|
|
|
|
// in which case we use a div (#9239)
|
|
|
|
|
testElement = document.createElement( body ? "div" : "body" );
|
|
|
|
|
testElementStyle = {
|
2011-04-07 04:51:37 +00:00
|
|
|
|
visibility: "hidden",
|
|
|
|
|
width: 0,
|
|
|
|
|
height: 0,
|
|
|
|
|
border: 0,
|
2011-08-04 22:41:34 +00:00
|
|
|
|
margin: 0,
|
|
|
|
|
background: "none"
|
2011-04-07 04:51:37 +00:00
|
|
|
|
};
|
2011-05-13 15:43:32 +00:00
|
|
|
|
if ( body ) {
|
|
|
|
|
jQuery.extend( testElementStyle, {
|
|
|
|
|
position: "absolute",
|
2011-09-20 15:23:01 +00:00
|
|
|
|
left: "-999px",
|
|
|
|
|
top: "-999px"
|
2011-05-13 15:43:32 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
for ( i in testElementStyle ) {
|
|
|
|
|
testElement.style[ i ] = testElementStyle[ i ];
|
2011-04-07 04:51:37 +00:00
|
|
|
|
}
|
2011-05-13 15:43:32 +00:00
|
|
|
|
testElement.appendChild( div );
|
|
|
|
|
testElementParent = body || documentElement;
|
|
|
|
|
testElementParent.insertBefore( testElement, testElementParent.firstChild );
|
2011-04-07 04:51:37 +00:00
|
|
|
|
|
2011-04-22 04:27:52 +00:00
|
|
|
|
// Check if a disconnected checkbox will retain its checked
|
|
|
|
|
// value of true after appended to the DOM (IE6/7)
|
|
|
|
|
support.appendChecked = input.checked;
|
|
|
|
|
|
2011-04-07 04:51:37 +00:00
|
|
|
|
support.boxModel = div.offsetWidth === 2;
|
|
|
|
|
|
|
|
|
|
if ( "zoom" in div.style ) {
|
|
|
|
|
// Check if natively block-level elements act like inline-block
|
|
|
|
|
// elements when setting their display to 'inline' and giving
|
|
|
|
|
// them layout
|
|
|
|
|
// (IE < 8 does this)
|
|
|
|
|
div.style.display = "inline";
|
|
|
|
|
div.style.zoom = 1;
|
|
|
|
|
support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 );
|
|
|
|
|
|
|
|
|
|
// Check if elements with layout shrink-wrap their children
|
|
|
|
|
// (IE 6 does this)
|
|
|
|
|
div.style.display = "";
|
|
|
|
|
div.innerHTML = "<div style='width:4px;'></div>";
|
|
|
|
|
support.shrinkWrapBlocks = ( div.offsetWidth !== 2 );
|
|
|
|
|
}
|
2010-10-05 18:28:43 +00:00
|
|
|
|
|
2011-09-01 15:16:38 +00:00
|
|
|
|
div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
|
2011-04-07 04:51:37 +00:00
|
|
|
|
tds = div.getElementsByTagName( "td" );
|
|
|
|
|
|
|
|
|
|
// Check if table cells still have offsetWidth/Height when they are set
|
|
|
|
|
// to display:none and there are still other visible table cells in a
|
|
|
|
|
// table row; if so, offsetWidth/Height are not reliable for use when
|
|
|
|
|
// determining if an element has been hidden directly using
|
|
|
|
|
// display:none (it is still safe to use offsets if a parent element is
|
|
|
|
|
// hidden; don safety goggles and see bug #4512 for more information).
|
|
|
|
|
// (only IE 8 fails this test)
|
|
|
|
|
isSupported = ( tds[ 0 ].offsetHeight === 0 );
|
|
|
|
|
|
|
|
|
|
tds[ 0 ].style.display = "";
|
|
|
|
|
tds[ 1 ].style.display = "none";
|
|
|
|
|
|
|
|
|
|
// Check if empty table cells still have offsetWidth/Height
|
|
|
|
|
// (IE < 8 fail this test)
|
|
|
|
|
support.reliableHiddenOffsets = isSupported && ( 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 ) {
|
2011-04-26 13:45:27 +00:00
|
|
|
|
marginDiv = document.createElement( "div" );
|
2011-04-12 03:59:12 +00:00
|
|
|
|
marginDiv.style.width = "0";
|
|
|
|
|
marginDiv.style.marginRight = "0";
|
|
|
|
|
div.appendChild( marginDiv );
|
2011-04-07 04:51:37 +00:00
|
|
|
|
support.reliableMarginRight =
|
2011-05-10 15:20:22 +00:00
|
|
|
|
( parseInt( ( document.defaultView.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
|
2011-04-07 04:51:37 +00:00
|
|
|
|
}
|
2011-03-24 19:41:46 +00:00
|
|
|
|
|
2011-04-07 04:51:37 +00:00
|
|
|
|
// Remove the body element we added
|
2011-05-13 15:43:32 +00:00
|
|
|
|
testElement.innerHTML = "";
|
2009-04-21 18:46:39 +00:00
|
|
|
|
|
2009-12-04 16:28:50 +00:00
|
|
|
|
// Technique from Juriy Zaytsev
|
2011-10-04 15:09:12 +00:00
|
|
|
|
// http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
|
2011-04-07 04:51:37 +00:00
|
|
|
|
// We only care about the case where non-standard event systems
|
|
|
|
|
// are used, namely in IE. Short-circuiting here helps us to
|
|
|
|
|
// avoid an eval call (in setAttribute) which can cause CSP
|
|
|
|
|
// to go haywire. See: https://developer.mozilla.org/en/Security/CSP
|
|
|
|
|
if ( div.attachEvent ) {
|
|
|
|
|
for( i in {
|
|
|
|
|
submit: 1,
|
|
|
|
|
change: 1,
|
|
|
|
|
focusin: 1
|
|
|
|
|
} ) {
|
|
|
|
|
eventName = "on" + i;
|
|
|
|
|
isSupported = ( eventName in div );
|
|
|
|
|
if ( !isSupported ) {
|
|
|
|
|
div.setAttribute( eventName, "return;" );
|
|
|
|
|
isSupported = ( typeof div[ eventName ] === "function" );
|
|
|
|
|
}
|
|
|
|
|
support[ i + "Bubbles" ] = isSupported;
|
2010-10-05 19:53:35 +00:00
|
|
|
|
}
|
2011-04-07 04:51:37 +00:00
|
|
|
|
}
|
2009-12-04 16:28:50 +00:00
|
|
|
|
|
2011-09-20 01:03:41 +00:00
|
|
|
|
// Determine fixed-position support early
|
2011-09-28 15:30:38 +00:00
|
|
|
|
testElement.style.position = "static";
|
|
|
|
|
testElement.style.top = "0px";
|
|
|
|
|
testElement.style.marginTop = "1px";
|
2011-09-20 01:03:41 +00:00
|
|
|
|
offsetSupport = (function( body, container ) {
|
|
|
|
|
|
|
|
|
|
var outer, inner, table, td, supports,
|
|
|
|
|
bodyMarginTop = parseFloat( body.style.marginTop ) || 0,
|
2011-09-28 15:30:38 +00:00
|
|
|
|
ptlm = "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;",
|
|
|
|
|
style = "style='" + ptlm + "border:5px solid #000;padding:0;'",
|
2011-09-20 01:03:41 +00:00
|
|
|
|
html = "<div " + style + "><div></div></div>" +
|
|
|
|
|
"<table " + style + " cellpadding='0' cellspacing='0'>" +
|
|
|
|
|
"<tr><td></td></tr></table>";
|
|
|
|
|
|
|
|
|
|
container.style.cssText = ptlm + "border:0;visibility:hidden";
|
|
|
|
|
|
|
|
|
|
container.innerHTML = html;
|
|
|
|
|
body.insertBefore( container, body.firstChild );
|
|
|
|
|
outer = container.firstChild;
|
|
|
|
|
inner = outer.firstChild;
|
|
|
|
|
td = outer.nextSibling.firstChild.firstChild;
|
|
|
|
|
|
|
|
|
|
supports = {
|
2011-10-27 19:34:42 +00:00
|
|
|
|
doesNotAddBorder: ( inner.offsetTop !== 5 ),
|
|
|
|
|
doesAddBorderForTableAndCells: ( td.offsetTop === 5 )
|
2011-09-20 03:25:02 +00:00
|
|
|
|
};
|
2011-09-20 01:03:41 +00:00
|
|
|
|
|
|
|
|
|
inner.style.position = "fixed";
|
|
|
|
|
inner.style.top = "20px";
|
|
|
|
|
|
|
|
|
|
// safari subtracts parent border width here which is 5px
|
2011-10-27 19:34:42 +00:00
|
|
|
|
supports.supportsFixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 );
|
2011-09-20 01:03:41 +00:00
|
|
|
|
inner.style.position = inner.style.top = "";
|
|
|
|
|
|
|
|
|
|
outer.style.overflow = "hidden";
|
|
|
|
|
outer.style.position = "relative";
|
|
|
|
|
|
2011-10-27 19:34:42 +00:00
|
|
|
|
supports.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 );
|
|
|
|
|
supports.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== bodyMarginTop );
|
2011-09-20 01:03:41 +00:00
|
|
|
|
|
|
|
|
|
return supports;
|
|
|
|
|
|
|
|
|
|
})( testElement, div );
|
|
|
|
|
|
|
|
|
|
jQuery.extend( support, offsetSupport );
|
2011-09-28 15:30:38 +00:00
|
|
|
|
testElementParent.removeChild( testElement );
|
2011-09-20 01:03:41 +00:00
|
|
|
|
|
2011-05-25 18:30:46 +00:00
|
|
|
|
// Null connected elements to avoid leaks in IE
|
2011-06-07 03:54:17 +00:00
|
|
|
|
testElement = fragment = select = opt = body = marginDiv = div = input = null;
|
2011-05-25 18:30:46 +00:00
|
|
|
|
|
2011-04-07 04:51:37 +00:00
|
|
|
|
return support;
|
2010-09-17 18:58:50 +00:00
|
|
|
|
})();
|
2011-04-07 04:51:37 +00:00
|
|
|
|
|
|
|
|
|
// Keep track of boxModel
|
|
|
|
|
jQuery.boxModel = jQuery.support.boxModel;
|
|
|
|
|
|
2010-09-08 16:00:29 +00:00
|
|
|
|
})( jQuery );
|