Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

css-regions.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // CSS Regions
  2. // http://www.w3.org/TR/css3-regions/
  3. // By: Mihai Balan
  4. // We start with a CSS parser test then we check page geometry to see if it's affected by regions
  5. // Later we might be able to retire the second part, as WebKit builds with the false positives die out
  6. Modernizr.addTest('regions', function() {
  7. /* Get the 'flowFrom' property name available in the browser. Either default or vendor prefixed.
  8. If the property name can't be found we'll get Boolean 'false' and fail quickly */
  9. var flowFromProperty = Modernizr.prefixed("flowFrom"),
  10. flowIntoProperty = Modernizr.prefixed("flowInto");
  11. if (!flowFromProperty || !flowIntoProperty){
  12. return false;
  13. }
  14. /* If CSS parsing is there, try to determine if regions actually work. */
  15. var container = document.createElement('div'),
  16. content = document.createElement('div'),
  17. region = document.createElement('div'),
  18. /* we create a random, unlikely to be generated flow number to make sure we don't
  19. clash with anything more vanilla, like 'flow', or 'article', or 'f1' */
  20. flowName = 'modernizr_flow_for_regions_check';
  21. /* First create a div with two adjacent divs inside it. The first will be the
  22. content, the second will be the region. To be able to distinguish between the two,
  23. we'll give the region a particular padding */
  24. content.innerText = 'M';
  25. container.style.cssText = 'top: 150px; left: 150px; padding: 0px;';
  26. region.style.cssText = 'width: 50px; height: 50px; padding: 42px;';
  27. region.style[flowFromProperty] = flowName;
  28. container.appendChild(content);
  29. container.appendChild(region);
  30. document.documentElement.appendChild(container);
  31. /* Now compute the bounding client rect, before and after attempting to flow the
  32. content div in the region div. If regions are enabled, the after bounding rect
  33. should reflect the padding of the region div.*/
  34. var flowedRect, delta,
  35. plainRect = content.getBoundingClientRect();
  36. content.style[flowIntoProperty] = flowName;
  37. flowedRect = content.getBoundingClientRect();
  38. delta = flowedRect.left - plainRect.left;
  39. document.documentElement.removeChild(container);
  40. content = region = container = undefined;
  41. return (delta == 42);
  42. });