update collection menus

This commit is contained in:
Luke Pulverenti 2015-10-07 17:42:29 -04:00
parent 65442321a0
commit 8119b930e4
17 changed files with 183 additions and 52 deletions

View file

@ -48,23 +48,47 @@ Example:
query: {
type: String,
observer: 'queryChanged'
},
_boundMQHandler: {
value: function() {
return this.queryHandler.bind(this);
}
}
},
created: function() {
this._mqHandler = this.queryHandler.bind(this);
attached: function() {
this.queryChanged();
},
queryChanged: function(query) {
detached: function() {
this._remove();
},
_add: function() {
if (this._mq) {
this._mq.removeListener(this._mqHandler);
this._mq.addListener(this._boundMQHandler);
}
},
_remove: function() {
if (this._mq) {
this._mq.removeListener(this._boundMQHandler);
}
this._mq = null;
},
queryChanged: function() {
this._remove();
var query = this.query;
if (!query) {
return;
}
if (query[0] !== '(') {
query = '(' + query + ')';
}
this._mq = window.matchMedia(query);
this._mq.addListener(this._mqHandler);
this._add();
this.queryHandler(this._mq);
},