MCPcopy Index your code
hub / github.com/JsAaron/jQuery / showHide

Function showHide

2.0.3/Css.js:65–117  ·  view source on GitHub ↗
(elements, show)

Source from the content-addressed store, hash-verified

63 }
64
65 function showHide(elements, show) {
66 var display, elem, hidden,
67 values = [],
68 index = 0,
69 length = elements.length;
70
71 for (; index < length; index++) {
72 elem = elements[index];
73 if (!elem.style) {
74 continue;
75 }
76
77 values[index] = data_priv.get(elem, "olddisplay");
78 display = elem.style.display;
79 if (show) {
80 // Reset the inline display of this element to learn if it is
81 // being hidden by cascaded rules or not
82 if (!values[index] && display === "none") {
83 elem.style.display = "";
84 }
85
86 // Set elements which have been overridden with display: none
87 // in a stylesheet to whatever the default browser style is
88 // for such an element
89 if (elem.style.display === "" && isHidden(elem)) {
90 values[index] = data_priv.access(elem, "olddisplay", css_defaultDisplay(elem.nodeName));
91 }
92 } else {
93
94 if (!values[index]) {
95 hidden = isHidden(elem);
96
97 if (display && display !== "none" || !hidden) {
98 data_priv.set(elem, "olddisplay", hidden ? display : jQuery.css(elem, "display"));
99 }
100 }
101 }
102 }
103
104 // Set the display of most of the elements in a second loop
105 // to avoid the constant reflow
106 for (index = 0; index < length; index++) {
107 elem = elements[index];
108 if (!elem.style) {
109 continue;
110 }
111 if (!show || elem.style.display === "none" || elem.style.display === "") {
112 elem.style.display = show ? values[index] || "" : "none";
113 }
114 }
115
116 return elements;
117 }
118
119 jQuery.fn.extend({
120 css: function(name, value) {

Callers 1

Css.jsFile · 0.70

Calls 2

isHiddenFunction · 0.70
css_defaultDisplayFunction · 0.70

Tested by

no test coverage detected