You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
989B

  1. define( [
  2. "../data/var/dataPriv"
  3. ], function( dataPriv ) {
  4. function showHide( elements, show ) {
  5. var display, elem,
  6. values = [],
  7. index = 0,
  8. length = elements.length;
  9. // Determine new display value for elements that need to change
  10. for ( ; index < length; index++ ) {
  11. elem = elements[ index ];
  12. if ( !elem.style ) {
  13. continue;
  14. }
  15. display = elem.style.display;
  16. if ( show ) {
  17. if ( display === "none" ) {
  18. // Restore a pre-hide() value if we have one
  19. values[ index ] = dataPriv.get( elem, "display" ) || "";
  20. }
  21. } else {
  22. if ( display !== "none" ) {
  23. values[ index ] = "none";
  24. // Remember the value we're replacing
  25. dataPriv.set( elem, "display", display );
  26. }
  27. }
  28. }
  29. // Set the display of the elements in a second loop
  30. // to avoid the constant reflow
  31. for ( index = 0; index < length; index++ ) {
  32. if ( values[ index ] != null ) {
  33. elements[ index ].style.display = values[ index ];
  34. }
  35. }
  36. return elements;
  37. }
  38. return showHide;
  39. } );