diff options
author | Timmy Willison <timmywillisn@gmail.com> | 2013-08-15 14:15:49 -0400 |
---|---|---|
committer | Timmy Willison <timmywillisn@gmail.com> | 2013-08-15 14:15:49 -0400 |
commit | 6318ae6ab90d4b450dfadf32ab95fe52ed6331cb (patch) | |
tree | 50b247fed8569e909e380b281e9145bd1458a39e /src/css | |
parent | 7627b8b6d9ef6e57dbd20a55b946bd1991c1223e (diff) | |
download | jquery-6318ae6ab90d4b450dfadf32ab95fe52ed6331cb.tar.gz jquery-6318ae6ab90d4b450dfadf32ab95fe52ed6331cb.zip |
AMD-ify jQuery sourcegit s! Woo! Fixes #14113, #14163.
Diffstat (limited to 'src/css')
-rw-r--r-- | src/css/defaultDisplay.js | 58 | ||||
-rw-r--r-- | src/css/hidden-visible-selectors.js | 15 | ||||
-rw-r--r-- | src/css/var/cssExpand.js | 3 | ||||
-rw-r--r-- | src/css/var/isHidden.js | 13 |
4 files changed, 89 insertions, 0 deletions
diff --git a/src/css/defaultDisplay.js b/src/css/defaultDisplay.js new file mode 100644 index 000000000..78acb2bcd --- /dev/null +++ b/src/css/defaultDisplay.js @@ -0,0 +1,58 @@ +define([ + "../core", + "../manipulation" // appendTo +], function( jQuery ) { + +var iframe, + elemdisplay = { BODY: "block" }; + +/** + * Retrieve the actual display of a element + * @param {String} name nodeName of the element + * @param {Object} doc Document object + */ +function actualDisplay( name, doc ) { + var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ), + display = jQuery.css( elem[0], "display" ); + elem.remove(); + return display; +} + +/** + * Try to determine the default display value of an element + * @param {String} nodeName + */ +function defaultDisplay( nodeName ) { + var doc = document, + display = elemdisplay[ nodeName ]; + + if ( !display ) { + display = actualDisplay( nodeName, doc ); + + // If the simple way fails, read from inside an iframe + if ( display === "none" || !display ) { + // Use the already-created iframe if possible + iframe = ( iframe || + jQuery("<iframe frameborder='0' width='0' height='0'/>") + .css( "cssText", "display:block !important" ) + ).appendTo( doc.documentElement ); + + // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse + doc = ( iframe[0].contentWindow || iframe[0].contentDocument ).document; + doc.write("<!doctype html><html><body>"); + doc.close(); + + display = actualDisplay( nodeName, doc ); + iframe.detach(); + } + + // Store the correct default display + elemdisplay[ nodeName ] = display; + } + + return display; +} + +return defaultDisplay; + +}); diff --git a/src/css/hidden-visible-selectors.js b/src/css/hidden-visible-selectors.js new file mode 100644 index 000000000..c7f1c7ee7 --- /dev/null +++ b/src/css/hidden-visible-selectors.js @@ -0,0 +1,15 @@ +define([ + "../core", + "../selector" +], function( jQuery ) { + +jQuery.expr.filters.hidden = function( elem ) { + // Support: Opera <= 12.12 + // Opera reports offsetWidths and offsetHeights less than zero on some elements + return elem.offsetWidth <= 0 && elem.offsetHeight <= 0; +}; +jQuery.expr.filters.visible = function( elem ) { + return !jQuery.expr.filters.hidden( elem ); +}; + +}); diff --git a/src/css/var/cssExpand.js b/src/css/var/cssExpand.js new file mode 100644 index 000000000..5bb6e8f85 --- /dev/null +++ b/src/css/var/cssExpand.js @@ -0,0 +1,3 @@ +define(function() { + return [ "Top", "Right", "Bottom", "Left" ]; +});
\ No newline at end of file diff --git a/src/css/var/isHidden.js b/src/css/var/isHidden.js new file mode 100644 index 000000000..085833db0 --- /dev/null +++ b/src/css/var/isHidden.js @@ -0,0 +1,13 @@ +define([ + "../../core", + "../../selector" + // css is assumed +], function( jQuery ) { + + return function( elem, el ) { + // isHidden might be called from jQuery#filter function; + // in that case, element will be second argument + elem = el || elem; + return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem ); + }; +});
\ No newline at end of file |