Sha256: a6fef45b3ed59ddc2b6a34b897f6d58928f15d20b54890abe4031e526ae0bd66

Contents?: true

Size: 969 Bytes

Versions: 5

Compression:

Stored size: 969 Bytes

Contents

/*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */

window.matchMedia = window.matchMedia || (function( doc, undefined ) {

  "use strict";

  var bool,
      docElem = doc.documentElement,
      refNode = docElem.firstElementChild || docElem.firstChild,
      // fakeBody required for <FF4 when executed in <head>
      fakeBody = doc.createElement( "body" ),
      div = doc.createElement( "div" );

  div.id = "mq-test-1";
  div.style.cssText = "position:absolute;top:-100em";
  fakeBody.style.background = "none";
  fakeBody.appendChild(div);

  return function(q){

    div.innerHTML = "&shy;<style media=\"" + q + "\"> #mq-test-1 { width: 42px; }</style>";

    docElem.insertBefore( fakeBody, refNode );
    bool = div.offsetWidth === 42;
    docElem.removeChild( fakeBody );

    return {
      matches: bool,
      media: q
    };

  };

}( document ));

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
picturefill-0.1.3 vendor/assets/javascripts/matchmedia.js
picturefill-0.1.2 vendor/assets/javascripts/matchmedia.js
picturefill-0.1.1 vendor/assets/javascripts/matchmedia.js
picturefill-0.1.0 vendor/assets/javascripts/matchmedia.js
picturefill-0.0.1 vendor/assets/javascripts/matchmedia.js