Changeset 66487 in spip-zone


Ignore:
Timestamp:
Oct 4, 2012, 5:11:42 PM (7 years ago)
Author:
brunobergot@…
Message:

comme d'habitude il faut un fix pour IE, on intègre une alternative à matchMedia un peu à l'arrache...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • _plugins_/legendes/javascript/jquery.annotate.js

    r44715 r66487  
    482482
    483483})(jQuery);
     484
     485/*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */
     486/*! source https://github.com/paulirish/matchMedia.js */
     487
     488window.matchMedia = window.matchMedia || (function( doc, undefined ) {
     489
     490  "use strict";
     491
     492  var bool,
     493      docElem = doc.documentElement,
     494      refNode = docElem.firstElementChild || docElem.firstChild,
     495      // fakeBody required for <FF4 when executed in <head>
     496      fakeBody = doc.createElement( "body" ),
     497      div = doc.createElement( "div" );
     498
     499  div.id = "mq-test-1";
     500  div.style.cssText = "position:absolute;top:-100em";
     501  fakeBody.style.background = "none";
     502  fakeBody.appendChild(div);
     503
     504  return function(q){
     505
     506    div.innerHTML = "&shy;<style media=\"" + q + "\"> #mq-test-1 { width: 42px; }</style>";
     507
     508    docElem.insertBefore( fakeBody, refNode );
     509    bool = div.offsetWidth === 42;
     510    docElem.removeChild( fakeBody );
     511
     512    return {
     513      matches: bool,
     514      media: q
     515    };
     516
     517  };
     518
     519}( document ));
Note: See TracChangeset for help on using the changeset viewer.