<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Polymer match media</title>
  <script type="text/javascript" src="../../polymer/polymer.js"></script>
  <link rel="import" href="polymer-media-query.html" />
</head>
<body>

  <polymer-element name="match-example">
    <template>
      <polymer-media-query query="{{query}}" queryMatches="{{matches}}"></polymer-media-query>
      My query of "{{query}}" {{matches ? "matches" : "doesn't match"}}
    </template>
    <script>
      Polymer('match-example', {
        query: 'min-width: 600px'
      });
    </script>
  </polymer-element>

  <match-example id="me"></match-example>
  <pre id="output">
  Log of 'mediachange' events on document, from polymer-match-media:
  </pre>

  <script>
    var output = document.querySelector('#output');
    // on-mediachange would give true or false as second param to the handler
    document.addEventListener('polymer-mediachange', function(e) {
      output.textContent += '\nevent: ' + e.type + ' query: ' + e.detail.media + ' matches: ' + e.detail.matches;
    });
  </script>
</body>
</html>
