1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

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

@ -1,6 +1,6 @@
{
"name": "iron-media-query",
"version": "1.0.2",
"version": "1.0.3",
"description": "Lets you bind to a CSS media query",
"authors": [
"The Polymer Authors"
@ -28,11 +28,11 @@
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
},
"_release": "1.0.2",
"_release": "1.0.3",
"_resolution": {
"type": "version",
"tag": "v1.0.2",
"commit": "34abf0a3b8bf9e9e478352dbb3d9e6a76bf3669a"
"tag": "v1.0.3",
"commit": "80e921f58e7688a840a0cf29e9e2aaaee72a66b2"
},
"_source": "git://github.com/PolymerElements/iron-media-query.git",
"_target": "^1.0.0",

View file

@ -1,6 +1,6 @@
{
"name": "iron-media-query",
"version": "1.0.2",
"version": "1.0.3",
"description": "Lets you bind to a CSS media query",
"authors": [
"The Polymer Authors"

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);
},

View file

@ -61,6 +61,42 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
assert.equal(mq.queryMatches, true);
});
test('automatically wrap with parens', function() {
mq.query = 'min-width: 1px';
assert.equal(mq.queryMatches, true);
});
suite('query does not activate on empty string or null', function() {
test('empty string', function() {
mq.query = '';
assert.notOk(mq._mq);
});
test('null', function() {
mq.query = null;
assert.notOk(mq._mq);
});
});
test('media query destroys on detach', function() {
mq.query = '(max-width: 800px)';
mq.parentNode.removeChild(mq);
Polymer.dom.flush();
assert.notOk(mq._mq);
});
test('media query re-enables on attach', function() {
mq.query = '(max-width: 800px)';
var parent = mq.parentNode;
parent.removeChild(mq);
Polymer.dom.flush();
parent.appendChild(mq);
Polymer.dom.flush();
assert.ok(mq._mq);
});
});
});