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

@ -10915,6 +10915,9 @@ The `aria-labelledby` attribute will be set to the header element, if one exists
created: function() {
this._bindFilterItem = this._filterItem.bind(this);
this._selection = new Polymer.IronSelection(this._applySelection.bind(this));
// TODO(cdata): When polymer/polymer#2535 lands, we do not need to do this
// book keeping anymore:
this.__listeningForActivate = false;
},
attached: function() {
@ -10923,6 +10926,7 @@ The `aria-labelledby` attribute will be set to the header element, if one exists
if (!this.selectedItem && this.selected) {
this._updateSelected(this.attrForSelected,this.selected)
}
this._addListener(this.activateEvent);
},
detached: function() {
@ -10989,11 +10993,17 @@ The `aria-labelledby` attribute will be set to the header element, if one exists
},
_addListener: function(eventName) {
if (!this.isAttached || this.__listeningForActivate) {
return;
}
this.__listeningForActivate = true;
this.listen(this, eventName, '_activateHandler');
},
_removeListener: function(eventName) {
this.unlisten(this, eventName, '_activateHandler');
this.__listeningForActivate = false;
},
_activateEventChanged: function(eventName, old) {
@ -11174,23 +11184,47 @@ The `aria-labelledby` attribute will be set to the header element, if one exists
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);
},