( elements, show )
| 4831 | } |
| 4832 | |
| 4833 | function showHide( elements, show ) { |
| 4834 | var display, elem, |
| 4835 | values = [], |
| 4836 | index = 0, |
| 4837 | length = elements.length; |
| 4838 | |
| 4839 | // Determine new display value for elements that need to change |
| 4840 | for ( ; index < length; index++ ) { |
| 4841 | elem = elements[ index ]; |
| 4842 | if ( !elem.style ) { |
| 4843 | continue; |
| 4844 | } |
| 4845 | |
| 4846 | display = elem.style.display; |
| 4847 | if ( show ) { |
| 4848 | |
| 4849 | // Since we force visibility upon cascade-hidden elements, an immediate (and slow) |
| 4850 | // check is required in this first loop unless we have a nonempty display value (either |
| 4851 | // inline or about-to-be-restored) |
| 4852 | if ( display === "none" ) { |
| 4853 | values[ index ] = dataPriv.get( elem, "display" ) || null; |
| 4854 | if ( !values[ index ] ) { |
| 4855 | elem.style.display = ""; |
| 4856 | } |
| 4857 | } |
| 4858 | if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) { |
| 4859 | values[ index ] = getDefaultDisplay( elem ); |
| 4860 | } |
| 4861 | } else { |
| 4862 | if ( display !== "none" ) { |
| 4863 | values[ index ] = "none"; |
| 4864 | |
| 4865 | // Remember what we're overwriting |
| 4866 | dataPriv.set( elem, "display", display ); |
| 4867 | } |
| 4868 | } |
| 4869 | } |
| 4870 | |
| 4871 | // Set the display of the elements in a second loop to avoid constant reflow |
| 4872 | for ( index = 0; index < length; index++ ) { |
| 4873 | if ( values[ index ] != null ) { |
| 4874 | elements[ index ].style.display = values[ index ]; |
| 4875 | } |
| 4876 | } |
| 4877 | |
| 4878 | return elements; |
| 4879 | } |
| 4880 | |
| 4881 | jQuery.fn.extend( { |
| 4882 | show: function() { |
no test coverage detected