'a'
mh-two-thousand-and-two
2024-04-12 44d2c92345cd156a59fc327b3060292a282d2893
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var Emitter = require('./Emitter');
exports = Emitter.extend({
    className: 'MediaQuery',
    initialize: function(query) {
        var _this = this;
        this.callSuper(Emitter, 'initialize');
        this._listener = function() {
            _this.emit(_this.isMatch() ? 'match' : 'unmatch');
        };
        this.setQuery(query);
    },
    setQuery: function(query) {
        if (this._mql) {
            this._mql.removeListener(this._listener);
        }
        this._mql = window.matchMedia(query);
        this._mql.addListener(this._listener);
    },
    isMatch: function() {
        return this._mql.matches;
    }
});
 
module.exports = exports;