mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
switch polymer to bower
This commit is contained in:
parent
b9598ffaa1
commit
8f6cbe8de2
348 changed files with 40895 additions and 310 deletions
41
dashboard-ui/bower_components/iron-selector/.bower.json
vendored
Normal file
41
dashboard-ui/bower_components/iron-selector/.bower.json
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"name": "iron-selector",
|
||||
"version": "1.0.2",
|
||||
"description": "Manages a set of elements that can be selected",
|
||||
"private": true,
|
||||
"license": "http://polymer.github.io/LICENSE.txt",
|
||||
"main": [
|
||||
"iron-selector.html"
|
||||
],
|
||||
"authors": [
|
||||
"The Polymer Authors"
|
||||
],
|
||||
"keywords": [
|
||||
"web-components",
|
||||
"polymer",
|
||||
"selector"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/PolymerElements/iron-selector.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"polymer": "Polymer/polymer#^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
|
||||
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
|
||||
"web-component-tester": "*",
|
||||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
|
||||
},
|
||||
"homepage": "https://github.com/PolymerElements/iron-selector",
|
||||
"_release": "1.0.2",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v1.0.2",
|
||||
"commit": "ea22d91d11ba6f72c01faa952d5e600f9d1773cf"
|
||||
},
|
||||
"_source": "git://github.com/PolymerElements/iron-selector.git",
|
||||
"_target": "^1.0.0",
|
||||
"_originalSource": "PolymerElements/iron-selector"
|
||||
}
|
2
dashboard-ui/bower_components/iron-selector/.gitignore
vendored
Normal file
2
dashboard-ui/bower_components/iron-selector/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
bower_components
|
||||
.DS_Store
|
31
dashboard-ui/bower_components/iron-selector/bower.json
vendored
Normal file
31
dashboard-ui/bower_components/iron-selector/bower.json
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"name": "iron-selector",
|
||||
"version": "1.0.2",
|
||||
"description": "Manages a set of elements that can be selected",
|
||||
"private": true,
|
||||
"license": "http://polymer.github.io/LICENSE.txt",
|
||||
"main": [
|
||||
"iron-selector.html"
|
||||
],
|
||||
"authors": [
|
||||
"The Polymer Authors"
|
||||
],
|
||||
"keywords": [
|
||||
"web-components",
|
||||
"polymer",
|
||||
"selector"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/PolymerElements/iron-selector.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"polymer": "Polymer/polymer#^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
|
||||
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
|
||||
"web-component-tester": "*",
|
||||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
|
||||
}
|
||||
}
|
66
dashboard-ui/bower_components/iron-selector/demo/index.html
vendored
Normal file
66
dashboard-ui/bower_components/iron-selector/demo/index.html
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
<!doctype html>
|
||||
<!--
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<title>iron-selector</title>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<link rel="import" href="../iron-selector.html">
|
||||
|
||||
<style>
|
||||
|
||||
iron-selector > * {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.iron-selected {
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h3>Basic</h3>
|
||||
|
||||
<iron-selector selected="0">
|
||||
<div>Item 0</div>
|
||||
<div>Item 1</div>
|
||||
<div>Item 2</div>
|
||||
<div>Item 3</div>
|
||||
<div>Item 4</div>
|
||||
</iron-selector>
|
||||
|
||||
<h3>Multi-select</h3>
|
||||
|
||||
<iron-selector multi selected-values='[0,2]'>
|
||||
<div>Item 0</div>
|
||||
<div>Item 1</div>
|
||||
<div>Item 2</div>
|
||||
<div>Item 3</div>
|
||||
<div>Item 4</div>
|
||||
</iron-selector>
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
<iron-selector selected="foo" attr-for-selected="name">
|
||||
<div name="foo">Foo</div>
|
||||
<div name="bar">Bar</div>
|
||||
<div name="zot">Zot</div>
|
||||
</iron-selector>
|
||||
|
||||
</body>
|
||||
</html>
|
28
dashboard-ui/bower_components/iron-selector/index.html
vendored
Normal file
28
dashboard-ui/bower_components/iron-selector/index.html
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
<!doctype html>
|
||||
<!--
|
||||
@license
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<title>iron-selector</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<script src="../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<link rel="import" href="../iron-component-page/iron-component-page.html">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<iron-component-page></iron-component-page>
|
||||
|
||||
</body>
|
||||
</html>
|
120
dashboard-ui/bower_components/iron-selector/iron-multi-selectable.html
vendored
Normal file
120
dashboard-ui/bower_components/iron-selector/iron-multi-selectable.html
vendored
Normal file
|
@ -0,0 +1,120 @@
|
|||
<!--
|
||||
@license
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<link rel="import" href="../polymer/polymer.html">
|
||||
<link rel="import" href="iron-selectable.html">
|
||||
|
||||
<script>
|
||||
/** @polymerBehavior Polymer.IronMultiSelectableBehavior */
|
||||
Polymer.IronMultiSelectableBehaviorImpl = {
|
||||
properties: {
|
||||
|
||||
/**
|
||||
* If true, multiple selections are allowed.
|
||||
*/
|
||||
multi: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
observer: 'multiChanged'
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets or sets the selected elements. This is used instead of `selected` when `multi`
|
||||
* is true.
|
||||
*/
|
||||
selectedValues: {
|
||||
type: Array,
|
||||
notify: true
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an array of currently selected items.
|
||||
*/
|
||||
selectedItems: {
|
||||
type: Array,
|
||||
readOnly: true,
|
||||
notify: true
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
observers: [
|
||||
'_updateSelected(attrForSelected, selectedValues)'
|
||||
],
|
||||
|
||||
/**
|
||||
* Selects the given value. If the `multi` property is true, then the selected state of the
|
||||
* `value` will be toggled; otherwise the `value` will be selected.
|
||||
*
|
||||
* @method select
|
||||
* @param {string} value the value to select.
|
||||
*/
|
||||
select: function(value) {
|
||||
if (this.multi) {
|
||||
if (this.selectedValues) {
|
||||
this._toggleSelected(value);
|
||||
} else {
|
||||
this.selectedValues = [value];
|
||||
}
|
||||
} else {
|
||||
this.selected = value;
|
||||
}
|
||||
},
|
||||
|
||||
multiChanged: function(multi) {
|
||||
this._selection.multi = multi;
|
||||
},
|
||||
|
||||
_updateSelected: function() {
|
||||
if (this.multi) {
|
||||
this._selectMulti(this.selectedValues);
|
||||
} else {
|
||||
this._selectSelected(this.selected);
|
||||
}
|
||||
},
|
||||
|
||||
_selectMulti: function(values) {
|
||||
this._selection.clear();
|
||||
if (values) {
|
||||
for (var i = 0; i < values.length; i++) {
|
||||
this._selection.setItemSelected(this._valueToItem(values[i]), true);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_selectionChange: function() {
|
||||
var s = this._selection.get();
|
||||
if (this.multi) {
|
||||
this._setSelectedItems(s);
|
||||
} else {
|
||||
this._setSelectedItems([s]);
|
||||
this._setSelectedItem(s);
|
||||
}
|
||||
},
|
||||
|
||||
_toggleSelected: function(value) {
|
||||
var i = this.selectedValues.indexOf(value);
|
||||
var unselected = i < 0;
|
||||
if (unselected) {
|
||||
this.selectedValues.push(value);
|
||||
} else {
|
||||
this.selectedValues.splice(i, 1);
|
||||
}
|
||||
this._selection.setItemSelected(this._valueToItem(value), unselected);
|
||||
}
|
||||
};
|
||||
|
||||
/** @polymerBehavior */
|
||||
Polymer.IronMultiSelectableBehavior = [
|
||||
Polymer.IronSelectableBehavior,
|
||||
Polymer.IronMultiSelectableBehaviorImpl
|
||||
];
|
||||
|
||||
</script>
|
307
dashboard-ui/bower_components/iron-selector/iron-selectable.html
vendored
Normal file
307
dashboard-ui/bower_components/iron-selector/iron-selectable.html
vendored
Normal file
|
@ -0,0 +1,307 @@
|
|||
<!--
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<link rel="import" href="../polymer/polymer.html">
|
||||
<link rel="import" href="iron-selection.html">
|
||||
|
||||
<script>
|
||||
|
||||
/** @polymerBehavior */
|
||||
Polymer.IronSelectableBehavior = {
|
||||
|
||||
properties: {
|
||||
|
||||
/**
|
||||
* If you want to use the attribute value of an element for `selected` instead of the index,
|
||||
* set this to the name of the attribute.
|
||||
*
|
||||
* @attribute attrForSelected
|
||||
* @type {string}
|
||||
*/
|
||||
attrForSelected: {
|
||||
type: String,
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets or sets the selected element. The default is to use the index of the item.
|
||||
*
|
||||
* @attribute selected
|
||||
* @type {string}
|
||||
*/
|
||||
selected: {
|
||||
type: String,
|
||||
notify: true
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the currently selected item.
|
||||
*
|
||||
* @attribute selectedItem
|
||||
* @type {Object}
|
||||
*/
|
||||
selectedItem: {
|
||||
type: Object,
|
||||
readOnly: true,
|
||||
notify: true
|
||||
},
|
||||
|
||||
/**
|
||||
* The event that fires from items when they are selected. Selectable
|
||||
* will listen for this event from items and update the selection state.
|
||||
* Set to empty string to listen to no events.
|
||||
*
|
||||
* @attribute activateEvent
|
||||
* @type {string}
|
||||
* @default 'tap'
|
||||
*/
|
||||
activateEvent: {
|
||||
type: String,
|
||||
value: 'tap',
|
||||
observer: '_activateEventChanged'
|
||||
},
|
||||
|
||||
/**
|
||||
* This is a CSS selector sting. If this is set, only items that matches the CSS selector
|
||||
* are selectable.
|
||||
*
|
||||
* @attribute selectable
|
||||
* @type {string}
|
||||
*/
|
||||
selectable: String,
|
||||
|
||||
/**
|
||||
* The class to set on elements when selected.
|
||||
*
|
||||
* @attribute selectedClass
|
||||
* @type {string}
|
||||
*/
|
||||
selectedClass: {
|
||||
type: String,
|
||||
value: 'iron-selected'
|
||||
},
|
||||
|
||||
/**
|
||||
* The attribute to set on elements when selected.
|
||||
*
|
||||
* @attribute selectedAttribute
|
||||
* @type {string}
|
||||
*/
|
||||
selectedAttribute: {
|
||||
type: String,
|
||||
value: null
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
observers: [
|
||||
'_updateSelected(attrForSelected, selected)'
|
||||
],
|
||||
|
||||
excludedLocalNames: {
|
||||
'template': 1
|
||||
},
|
||||
|
||||
created: function() {
|
||||
this._bindFilterItem = this._filterItem.bind(this);
|
||||
this._selection = new Polymer.IronSelection(this._applySelection.bind(this));
|
||||
},
|
||||
|
||||
attached: function() {
|
||||
this._observer = this._observeItems(this);
|
||||
this._contentObserver = this._observeContent(this);
|
||||
},
|
||||
|
||||
detached: function() {
|
||||
if (this._observer) {
|
||||
this._observer.disconnect();
|
||||
}
|
||||
if (this._contentObserver) {
|
||||
this._contentObserver.disconnect();
|
||||
}
|
||||
this._removeListener(this.activateEvent);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an array of selectable items.
|
||||
*
|
||||
* @property items
|
||||
* @type Array
|
||||
*/
|
||||
get items() {
|
||||
var nodes = Polymer.dom(this).queryDistributedElements(this.selectable || '*');
|
||||
return Array.prototype.filter.call(nodes, this._bindFilterItem);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the index of the given item.
|
||||
*
|
||||
* @method indexOf
|
||||
* @param {Object} item
|
||||
* @returns Returns the index of the item
|
||||
*/
|
||||
indexOf: function(item) {
|
||||
return this.items.indexOf(item);
|
||||
},
|
||||
|
||||
/**
|
||||
* Selects the given value.
|
||||
*
|
||||
* @method select
|
||||
* @param {string} value the value to select.
|
||||
*/
|
||||
select: function(value) {
|
||||
this.selected = value;
|
||||
},
|
||||
|
||||
/**
|
||||
* Selects the previous item.
|
||||
*
|
||||
* @method selectPrevious
|
||||
*/
|
||||
selectPrevious: function() {
|
||||
var length = this.items.length;
|
||||
var index = (Number(this._valueToIndex(this.selected)) - 1 + length) % length;
|
||||
this.selected = this._indexToValue(index);
|
||||
},
|
||||
|
||||
/**
|
||||
* Selects the next item.
|
||||
*
|
||||
* @method selectNext
|
||||
*/
|
||||
selectNext: function() {
|
||||
var index = (Number(this._valueToIndex(this.selected)) + 1) % this.items.length;
|
||||
this.selected = this._indexToValue(index);
|
||||
},
|
||||
|
||||
_addListener: function(eventName) {
|
||||
this.listen(this, eventName, '_activateHandler');
|
||||
},
|
||||
|
||||
_removeListener: function(eventName) {
|
||||
// There is no unlisten yet...
|
||||
// https://github.com/Polymer/polymer/issues/1639
|
||||
//this.removeEventListener(eventName, this._bindActivateHandler);
|
||||
},
|
||||
|
||||
_activateEventChanged: function(eventName, old) {
|
||||
this._removeListener(old);
|
||||
this._addListener(eventName);
|
||||
},
|
||||
|
||||
_updateSelected: function() {
|
||||
this._selectSelected(this.selected);
|
||||
},
|
||||
|
||||
_selectSelected: function(selected) {
|
||||
this._selection.select(this._valueToItem(this.selected));
|
||||
},
|
||||
|
||||
_filterItem: function(node) {
|
||||
return !this.excludedLocalNames[node.localName];
|
||||
},
|
||||
|
||||
_valueToItem: function(value) {
|
||||
return (value == null) ? null : this.items[this._valueToIndex(value)];
|
||||
},
|
||||
|
||||
_valueToIndex: function(value) {
|
||||
if (this.attrForSelected) {
|
||||
for (var i = 0, item; item = this.items[i]; i++) {
|
||||
if (this._valueForItem(item) == value) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return Number(value);
|
||||
}
|
||||
},
|
||||
|
||||
_indexToValue: function(index) {
|
||||
if (this.attrForSelected) {
|
||||
var item = this.items[index];
|
||||
if (item) {
|
||||
return this._valueForItem(item);
|
||||
}
|
||||
} else {
|
||||
return index;
|
||||
}
|
||||
},
|
||||
|
||||
_valueForItem: function(item) {
|
||||
return item[this.attrForSelected] || item.getAttribute(this.attrForSelected);
|
||||
},
|
||||
|
||||
_applySelection: function(item, isSelected) {
|
||||
if (this.selectedClass) {
|
||||
this.toggleClass(this.selectedClass, isSelected, item);
|
||||
}
|
||||
if (this.selectedAttribute) {
|
||||
this.toggleAttribute(this.selectedAttribute, isSelected, item);
|
||||
}
|
||||
this._selectionChange();
|
||||
this.fire('iron-' + (isSelected ? 'select' : 'deselect'), {item: item});
|
||||
},
|
||||
|
||||
_selectionChange: function() {
|
||||
this._setSelectedItem(this._selection.get());
|
||||
},
|
||||
|
||||
// observe content changes under the given node.
|
||||
_observeContent: function(node) {
|
||||
var content = node.querySelector('content');
|
||||
if (content && content.parentElement === node) {
|
||||
return this._observeItems(node.domHost);
|
||||
}
|
||||
},
|
||||
|
||||
// observe items change under the given node.
|
||||
_observeItems: function(node) {
|
||||
var observer = new MutationObserver(function() {
|
||||
if (this.selected != null) {
|
||||
this._updateSelected();
|
||||
}
|
||||
}.bind(this));
|
||||
observer.observe(node, {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
return observer;
|
||||
},
|
||||
|
||||
_activateHandler: function(e) {
|
||||
// TODO: remove this when https://github.com/Polymer/polymer/issues/1639 is fixed so we
|
||||
// can just remove the old event listener.
|
||||
if (e.type !== this.activateEvent) {
|
||||
return;
|
||||
}
|
||||
var t = e.target;
|
||||
var items = this.items;
|
||||
while (t && t != this) {
|
||||
var i = items.indexOf(t);
|
||||
if (i >= 0) {
|
||||
var value = this._indexToValue(i);
|
||||
this._itemActivate(value, t);
|
||||
return;
|
||||
}
|
||||
t = t.parentNode;
|
||||
}
|
||||
},
|
||||
|
||||
_itemActivate: function(value, item) {
|
||||
if (!this.fire('iron-activate',
|
||||
{selected: value, item: item}, {cancelable: true}).defaultPrevented) {
|
||||
this.select(value);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
</script>
|
115
dashboard-ui/bower_components/iron-selector/iron-selection.html
vendored
Normal file
115
dashboard-ui/bower_components/iron-selector/iron-selection.html
vendored
Normal file
|
@ -0,0 +1,115 @@
|
|||
|
||||
<!--
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<link rel="import" href="../polymer/polymer.html">
|
||||
|
||||
<script>
|
||||
|
||||
/**
|
||||
* @param {!Function} selectCallback
|
||||
* @constructor
|
||||
*/
|
||||
Polymer.IronSelection = function(selectCallback) {
|
||||
this.selection = [];
|
||||
this.selectCallback = selectCallback;
|
||||
};
|
||||
|
||||
Polymer.IronSelection.prototype = {
|
||||
|
||||
/**
|
||||
* Retrieves the selected item(s).
|
||||
*
|
||||
* @method get
|
||||
* @returns Returns the selected item(s). If the multi property is true,
|
||||
* `get` will return an array, otherwise it will return
|
||||
* the selected item or undefined if there is no selection.
|
||||
*/
|
||||
get: function() {
|
||||
return this.multi ? this.selection : this.selection[0];
|
||||
},
|
||||
|
||||
/**
|
||||
* Clears all the selection except the ones indicated.
|
||||
*
|
||||
* @method clear
|
||||
* @param {Array} excludes items to be excluded.
|
||||
*/
|
||||
clear: function(excludes) {
|
||||
this.selection.slice().forEach(function(item) {
|
||||
if (!excludes || excludes.indexOf(item) < 0) {
|
||||
this.setItemSelected(item, false);
|
||||
}
|
||||
}, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Indicates if a given item is selected.
|
||||
*
|
||||
* @method isSelected
|
||||
* @param {*} item The item whose selection state should be checked.
|
||||
* @returns Returns true if `item` is selected.
|
||||
*/
|
||||
isSelected: function(item) {
|
||||
return this.selection.indexOf(item) >= 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the selection state for a given item to either selected or deselected.
|
||||
*
|
||||
* @method setItemSelected
|
||||
* @param {*} item The item to select.
|
||||
* @param {boolean} isSelected True for selected, false for deselected.
|
||||
*/
|
||||
setItemSelected: function(item, isSelected) {
|
||||
if (item != null) {
|
||||
if (isSelected) {
|
||||
this.selection.push(item);
|
||||
} else {
|
||||
var i = this.selection.indexOf(item);
|
||||
if (i >= 0) {
|
||||
this.selection.splice(i, 1);
|
||||
}
|
||||
}
|
||||
if (this.selectCallback) {
|
||||
this.selectCallback(item, isSelected);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the selection state for a given item. If the `multi` property
|
||||
* is true, then the selected state of `item` will be toggled; otherwise
|
||||
* the `item` will be selected.
|
||||
*
|
||||
* @method select
|
||||
* @param {*} item The item to select.
|
||||
*/
|
||||
select: function(item) {
|
||||
if (this.multi) {
|
||||
this.toggle(item);
|
||||
} else if (this.get() !== item) {
|
||||
this.setItemSelected(this.get(), false);
|
||||
this.setItemSelected(item, true);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggles the selection state for `item`.
|
||||
*
|
||||
* @method toggle
|
||||
* @param {*} item The item to toggle.
|
||||
*/
|
||||
toggle: function(item) {
|
||||
this.setItemSelected(item, !this.isSelected(item));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
</script>
|
71
dashboard-ui/bower_components/iron-selector/iron-selector.html
vendored
Normal file
71
dashboard-ui/bower_components/iron-selector/iron-selector.html
vendored
Normal file
|
@ -0,0 +1,71 @@
|
|||
<!--
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
|
||||
<link rel="import" href="../polymer/polymer.html">
|
||||
<link rel="import" href="iron-multi-selectable.html">
|
||||
|
||||
<script>
|
||||
/**
|
||||
`iron-selector` is an element which can be used to manage a list of elements
|
||||
that can be selected. Tapping on the item will make the item selected. The `selected` indicates
|
||||
which item is being selected. The default is to use the index of the item.
|
||||
|
||||
Example:
|
||||
|
||||
<iron-selector selected="0">
|
||||
<div>Item 1</div>
|
||||
<div>Item 2</div>
|
||||
<div>Item 3</div>
|
||||
</iron-selector>
|
||||
|
||||
If you want to use the attribute value of an element for `selected` instead of the index,
|
||||
set `attrForSelected` to the name of the attribute. For example, if you want to select item by
|
||||
`name`, set `attrForSelected` to `name`.
|
||||
|
||||
Example:
|
||||
|
||||
<iron-selector attr-for-selected="name" selected="foo">
|
||||
<div name="foo">Foo</div>
|
||||
<div name="bar">Bar</div>
|
||||
<div name="zot">Zot</div>
|
||||
</iron-selector>
|
||||
|
||||
`iron-selector` is not styled. Use the `iron-selected` CSS class to style the selected element.
|
||||
|
||||
Example:
|
||||
|
||||
<style>
|
||||
.iron-selected {
|
||||
background: #eee;
|
||||
}
|
||||
</style>
|
||||
|
||||
...
|
||||
|
||||
<iron-selector selected="0">
|
||||
<div>Item 1</div>
|
||||
<div>Item 2</div>
|
||||
<div>Item 3</div>
|
||||
</iron-selector>
|
||||
|
||||
@demo demo/index.html
|
||||
*/
|
||||
|
||||
Polymer({
|
||||
|
||||
is: 'iron-selector',
|
||||
|
||||
behaviors: [
|
||||
Polymer.IronMultiSelectableBehavior
|
||||
]
|
||||
|
||||
});
|
||||
|
||||
</script>
|
138
dashboard-ui/bower_components/iron-selector/test/activate-event.html
vendored
Normal file
138
dashboard-ui/bower_components/iron-selector/test/activate-event.html
vendored
Normal file
|
@ -0,0 +1,138 @@
|
|||
<!doctype html>
|
||||
<!--
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<title>iron-selector-activate-event</title>
|
||||
<meta charset="UTF-8">
|
||||
|
||||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<script src="../../web-component-tester/browser.js"></script>
|
||||
<script src="../../test-fixture/test-fixture-mocha.js"></script>
|
||||
|
||||
<link rel="import" href="../../test-fixture/test-fixture.html">
|
||||
<link rel="import" href="../iron-selector.html">
|
||||
|
||||
<style>
|
||||
.iron-selected {
|
||||
background: #ccc;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<test-fixture id="test">
|
||||
<template>
|
||||
<iron-selector id="selector" selected="0">
|
||||
<div>Item 0</div>
|
||||
<div>Item 1</div>
|
||||
<div>Item 2</div>
|
||||
<div>Item 3</div>
|
||||
<div>Item 4</div>
|
||||
</iron-selector>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
|
||||
suite('activate event', function() {
|
||||
|
||||
var s;
|
||||
|
||||
setup(function () {
|
||||
s = fixture('test');
|
||||
});
|
||||
|
||||
test('activates on tap', function() {
|
||||
assert.equal(s.selected, '0');
|
||||
|
||||
// select Item 1
|
||||
s.children[1].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
|
||||
assert.equal(s.selected, '1');
|
||||
});
|
||||
|
||||
test('activates on tap and fires iron-activate', function(done) {
|
||||
assert.equal(s.selected, '0');
|
||||
|
||||
// attach iron-activate listener
|
||||
s.addEventListener("iron-activate", function(event) {
|
||||
assert.equal(event.detail.selected, '1');
|
||||
assert.equal(event.detail.item, s.children[1]);
|
||||
done();
|
||||
});
|
||||
|
||||
// select Item 1
|
||||
s.children[1].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
|
||||
});
|
||||
|
||||
test('tap on already selected and fires iron-activate', function(done) {
|
||||
assert.equal(s.selected, '0');
|
||||
|
||||
// attach iron-activate listener
|
||||
s.addEventListener("iron-activate", function(event) {
|
||||
assert.equal(event.detail.selected, '0');
|
||||
assert.equal(event.detail.item, s.children[0]);
|
||||
done();
|
||||
});
|
||||
|
||||
// select Item 0
|
||||
s.children[0].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
|
||||
});
|
||||
|
||||
test('activates on mousedown', function() {
|
||||
// set activateEvent to mousedown
|
||||
s.activateEvent = 'mousedown';
|
||||
// select Item 2
|
||||
s.children[2].dispatchEvent(new CustomEvent('mousedown', {bubbles: true}));
|
||||
assert.equal(s.selected, '2');
|
||||
});
|
||||
|
||||
test('activates on mousedown and fires iron-activate', function(done) {
|
||||
// attach iron-activate listener
|
||||
s.addEventListener("iron-activate", function(event) {
|
||||
assert.equal(event.detail.selected, '2');
|
||||
assert.equal(event.detail.item, s.children[2]);
|
||||
done();
|
||||
});
|
||||
|
||||
// set activateEvent to mousedown
|
||||
s.activateEvent = 'mousedown';
|
||||
// select Item 2
|
||||
s.children[2].dispatchEvent(new CustomEvent('mousedown', {bubbles: true}));
|
||||
});
|
||||
|
||||
test('no activation', function() {
|
||||
assert.equal(s.selected, '0');
|
||||
// set activateEvent to null
|
||||
s.activateEvent = null;
|
||||
// select Item 2
|
||||
s.children[2].dispatchEvent(new CustomEvent('mousedown', {bubbles: true}));
|
||||
assert.equal(s.selected, '0');
|
||||
});
|
||||
|
||||
test('activates on tap and preventDefault', function() {
|
||||
// attach iron-activate listener
|
||||
s.addEventListener("iron-activate", function(event) {
|
||||
event.preventDefault();
|
||||
});
|
||||
// select Item 2
|
||||
s.children[2].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
|
||||
// shouldn't got selected since we preventDefault in iron-activate
|
||||
assert.equal(s.selected, '0');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
150
dashboard-ui/bower_components/iron-selector/test/basic.html
vendored
Normal file
150
dashboard-ui/bower_components/iron-selector/test/basic.html
vendored
Normal file
|
@ -0,0 +1,150 @@
|
|||
<!doctype html>
|
||||
<!--
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<title>iron-selector-basic</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
||||
|
||||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<script src="../../web-component-tester/browser.js"></script>
|
||||
<script src="../../test-fixture/test-fixture-mocha.js"></script>
|
||||
|
||||
<link rel="import" href="../../test-fixture/test-fixture.html">
|
||||
<link rel="import" href="../iron-selector.html">
|
||||
|
||||
<style>
|
||||
.iron-selected {
|
||||
background: #ccc;
|
||||
}
|
||||
|
||||
.my-selected {
|
||||
background: red;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<test-fixture id="defaults">
|
||||
<template>
|
||||
<iron-selector>
|
||||
<div>Item 0</div>
|
||||
<div>Item 1</div>
|
||||
<div>Item 2</div>
|
||||
<div>Item 3</div>
|
||||
<div>Item 4</div>
|
||||
</iron-selector>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<br><br>
|
||||
|
||||
<test-fixture id="basic">
|
||||
<template>
|
||||
<iron-selector selected="item2" attr-for-selected="id">
|
||||
<div id="item0">Item 0</div>
|
||||
<div id="item1">Item 1</div>
|
||||
<div id="item2">Item 2</div>
|
||||
<div id="item3">Item 3</div>
|
||||
<div id="item4">Item 4</div>
|
||||
</iron-selector>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
|
||||
suite('defaults', function() {
|
||||
|
||||
var s1;
|
||||
|
||||
setup(function () {
|
||||
s1 = fixture('defaults');
|
||||
});
|
||||
|
||||
test('to nothing selected', function() {
|
||||
assert.equal(s1.selected, null);
|
||||
});
|
||||
|
||||
test('to iron-selected as selectedClass', function() {
|
||||
assert.equal(s1.selectedClass, 'iron-selected');
|
||||
});
|
||||
|
||||
test('to false as multi', function() {
|
||||
assert.isFalse(s1.multi);
|
||||
});
|
||||
|
||||
test('to tap as activateEvent', function() {
|
||||
assert.equal(s1.activateEvent, 'tap');
|
||||
});
|
||||
|
||||
test('to nothing as attrForSelected', function() {
|
||||
assert.equal(s1.attrForSelected, null);
|
||||
});
|
||||
|
||||
test('as many items as children', function() {
|
||||
assert.equal(s1.items.length, s1.querySelectorAll('div').length);
|
||||
});
|
||||
});
|
||||
|
||||
suite('basic', function() {
|
||||
|
||||
var s2;
|
||||
|
||||
setup(function () {
|
||||
s2 = fixture('basic');
|
||||
});
|
||||
|
||||
test('honors the attrForSelected attribute', function() {
|
||||
assert.equal(s2.attrForSelected, 'id');
|
||||
assert.equal(s2.selected, 'item2');
|
||||
assert.equal(s2.selectedItem, document.querySelector('#item2'));
|
||||
});
|
||||
|
||||
test('allows assignment to selected', function() {
|
||||
// set selected
|
||||
s2.selected = 'item4';
|
||||
// check selected class
|
||||
assert.isTrue(s2.children[4].classList.contains('iron-selected'));
|
||||
// check item
|
||||
assert.equal(s2.selectedItem, s2.children[4]);
|
||||
});
|
||||
|
||||
test('fire iron-select when selected is set', function() {
|
||||
// setup listener for iron-select event
|
||||
var selectedEventCounter = 0;
|
||||
s2.addEventListener('iron-select', function(e) {
|
||||
selectedEventCounter++;
|
||||
});
|
||||
// set selected
|
||||
s2.selected = 'item4';
|
||||
// check iron-select event
|
||||
assert.equal(selectedEventCounter, 1);
|
||||
});
|
||||
|
||||
test('set selected to old value', function() {
|
||||
// setup listener for iron-select event
|
||||
var selectedEventCounter = 0;
|
||||
s2.addEventListener('iron-select', function(e) {
|
||||
selectedEventCounter++;
|
||||
});
|
||||
// selecting the same value shouldn't fire iron-select
|
||||
s2.selected = 'item2';
|
||||
assert.equal(selectedEventCounter, 0);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
43
dashboard-ui/bower_components/iron-selector/test/content-element.html
vendored
Normal file
43
dashboard-ui/bower_components/iron-selector/test/content-element.html
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
<!--
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<link rel="import" href="../iron-selector.html">
|
||||
|
||||
<dom-module id="test-content-element">
|
||||
|
||||
<template>
|
||||
|
||||
<iron-selector id="selector" selected="{{selected}}" selectable="[[selectable]]" attr-for-selected="id">
|
||||
<content></content>
|
||||
</iron-selector>
|
||||
|
||||
</template>
|
||||
|
||||
</dom-module>
|
||||
|
||||
<script>
|
||||
|
||||
Polymer({
|
||||
|
||||
is: 'test-content-element',
|
||||
|
||||
properties: {
|
||||
|
||||
selectable: String,
|
||||
|
||||
selected: {
|
||||
type: String,
|
||||
notify: true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
</script>
|
168
dashboard-ui/bower_components/iron-selector/test/content.html
vendored
Normal file
168
dashboard-ui/bower_components/iron-selector/test/content.html
vendored
Normal file
|
@ -0,0 +1,168 @@
|
|||
<!doctype html>
|
||||
<!--
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<title>iron-selector-content</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
||||
|
||||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<script src="../../web-component-tester/browser.js"></script>
|
||||
<script src="../../test-fixture/test-fixture-mocha.js"></script>
|
||||
|
||||
<link rel="import" href="../../test-fixture/test-fixture.html">
|
||||
<link rel="import" href="content-element.html">
|
||||
|
||||
<style>
|
||||
.iron-selected {
|
||||
background: #ccc;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<test-content-element id="selector1" selected="item0">
|
||||
<div id="item0">item0</div>
|
||||
<div id="item1">item1</div>
|
||||
<div id="item2">item2</div>
|
||||
<div id="item3">item3</div>
|
||||
</test-content-element>
|
||||
|
||||
<test-content-element id="selector2" selected="item0" selectable="item">
|
||||
<item id="item0">item0</item>
|
||||
<hr>
|
||||
<item id="item1">item1</item>
|
||||
<item id="item2">item2</item>
|
||||
<hr>
|
||||
<item id="item3">item3</item>
|
||||
</test-content-element>
|
||||
|
||||
<test-content-element id="selector3" selected="item0">
|
||||
<template is="dom-repeat" id="t">
|
||||
<div id$="[[item.name]]">[[item.name]]</div>
|
||||
</template>
|
||||
</test-content-element>
|
||||
|
||||
<script>
|
||||
|
||||
var s1 = document.querySelector('#selector1');
|
||||
var s2 = document.querySelector('#selector2');
|
||||
var s3 = document.querySelector('#selector3');
|
||||
|
||||
var t = document.querySelector('#t');
|
||||
|
||||
suite('content', function() {
|
||||
|
||||
test('attribute selected', function() {
|
||||
// check selected class
|
||||
assert.isTrue(s1.querySelector('#item0').classList.contains('iron-selected'));
|
||||
});
|
||||
|
||||
test('set selected', function() {
|
||||
// set selected
|
||||
s1.selected = 'item1';
|
||||
// check selected class
|
||||
assert.isTrue(s1.querySelector('#item1').classList.contains('iron-selected'));
|
||||
});
|
||||
|
||||
test('get items', function() {
|
||||
assert.equal(s1.$.selector.items.length, 4);
|
||||
});
|
||||
|
||||
test('activate event', function() {
|
||||
var item = s1.querySelector('#item2');
|
||||
item.dispatchEvent(new CustomEvent('tap', {bubbles: true}));
|
||||
// check selected class
|
||||
assert.isTrue(item.classList.contains('iron-selected'));
|
||||
});
|
||||
|
||||
test('add item dynamically', function() {
|
||||
var item = document.createElement('div');
|
||||
item.id = 'item4';
|
||||
item.textContent = 'item4';
|
||||
Polymer.dom(s1).appendChild(item);
|
||||
Polymer.dom.flush();
|
||||
// set selected
|
||||
s1.selected = 'item4';
|
||||
// check items length
|
||||
assert.equal(s1.$.selector.items.length, 5);
|
||||
// check selected class
|
||||
assert.isTrue(s1.querySelector('#item4').classList.contains('iron-selected'));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
suite('content with selectable', function() {
|
||||
|
||||
test('attribute selected', function() {
|
||||
// check selected class
|
||||
assert.isTrue(s2.querySelector('#item0').classList.contains('iron-selected'));
|
||||
});
|
||||
|
||||
test('set selected', function() {
|
||||
// set selected
|
||||
s2.selected = 'item1';
|
||||
// check selected class
|
||||
assert.isTrue(s2.querySelector('#item1').classList.contains('iron-selected'));
|
||||
});
|
||||
|
||||
test('get items', function() {
|
||||
assert.equal(s2.$.selector.items.length, 4);
|
||||
});
|
||||
|
||||
test('activate event', function() {
|
||||
var item = s2.querySelector('#item2');
|
||||
item.dispatchEvent(new CustomEvent('tap', {bubbles: true}));
|
||||
// check selected class
|
||||
assert.isTrue(item.classList.contains('iron-selected'));
|
||||
});
|
||||
|
||||
test('add item dynamically', function() {
|
||||
var item = document.createElement('item');
|
||||
item.id = 'item4';
|
||||
item.textContent = 'item4';
|
||||
Polymer.dom(s2).appendChild(item);
|
||||
Polymer.dom.flush();
|
||||
// set selected
|
||||
s2.selected = 'item4';
|
||||
// check items length
|
||||
assert.equal(s2.$.selector.items.length, 5);
|
||||
// check selected class
|
||||
assert.isTrue(s2.querySelector('#item4').classList.contains('iron-selected'));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
suite('content with dom-repeat', function() {
|
||||
|
||||
test('supports repeated children', function(done) {
|
||||
t.items = [{name:'item0'}, {name: 'item1'}, {name: 'item2'}, {name: 'item3'}];
|
||||
setTimeout(function() {
|
||||
// check selected
|
||||
assert.equal(s3.selected, 'item0');
|
||||
// check selected class
|
||||
assert.isTrue(s3.querySelector('#item0').classList.contains('iron-selected'));
|
||||
// set selected
|
||||
s3.selected = 'item2';
|
||||
// check selected class
|
||||
assert.isTrue(s3.querySelector('#item2').classList.contains('iron-selected'));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
36
dashboard-ui/bower_components/iron-selector/test/index.html
vendored
Normal file
36
dashboard-ui/bower_components/iron-selector/test/index.html
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
<!doctype html>
|
||||
<!--
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<title>Tests</title>
|
||||
<script src="../../web-component-tester/browser.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script>
|
||||
|
||||
WCT.loadSuites([
|
||||
'activate-event.html',
|
||||
'basic.html',
|
||||
'multi.html',
|
||||
'next-previous.html',
|
||||
'selected-attribute.html',
|
||||
'template-repeat.html',
|
||||
'content.html'
|
||||
]);
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
135
dashboard-ui/bower_components/iron-selector/test/multi.html
vendored
Normal file
135
dashboard-ui/bower_components/iron-selector/test/multi.html
vendored
Normal file
|
@ -0,0 +1,135 @@
|
|||
<!doctype html>
|
||||
<!--
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<title>iron-selector-multi</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
||||
|
||||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<script src="../../web-component-tester/browser.js"></script>
|
||||
<script src="../../test-fixture/test-fixture-mocha.js"></script>
|
||||
|
||||
<link rel="import" href="../../test-fixture/test-fixture.html">
|
||||
<link rel="import" href="../iron-selector.html">
|
||||
|
||||
<style>
|
||||
.iron-selected {
|
||||
background: #ccc;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<test-fixture id="test">
|
||||
<template>
|
||||
<iron-selector multi>
|
||||
<div>Item 0</div>
|
||||
<div>Item 1</div>
|
||||
<div>Item 2</div>
|
||||
<div>Item 3</div>
|
||||
<div>Item 4</div>
|
||||
</iron-selector>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
|
||||
suite('multi', function() {
|
||||
|
||||
var s;
|
||||
|
||||
setup(function () {
|
||||
s = fixture('test');
|
||||
});
|
||||
|
||||
test('honors the multi attribute', function() {
|
||||
assert.isTrue(s.multi);
|
||||
});
|
||||
|
||||
test('has sane defaults', function() {
|
||||
assert.equal(s.selectedValues, undefined);
|
||||
assert.equal(s.selectedClass, 'iron-selected');
|
||||
assert.equal(s.items.length, 5);
|
||||
});
|
||||
|
||||
test('set multi-selection via selected property', function() {
|
||||
// set selectedValues
|
||||
s.selectedValues = [0, 2];
|
||||
// check selected class
|
||||
assert.isTrue(s.children[0].classList.contains('iron-selected'));
|
||||
assert.isTrue(s.children[2].classList.contains('iron-selected'));
|
||||
// check selectedItems
|
||||
assert.equal(s.selectedItems.length, 2);
|
||||
assert.equal(s.selectedItems[0], s.children[0]);
|
||||
assert.equal(s.selectedItems[1], s.children[2]);
|
||||
});
|
||||
|
||||
test('set multi-selection via tap', function() {
|
||||
// set selectedValues
|
||||
s.children[0].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
|
||||
s.children[2].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
|
||||
// check selected class
|
||||
assert.isTrue(s.children[0].classList.contains('iron-selected'));
|
||||
assert.isTrue(s.children[2].classList.contains('iron-selected'));
|
||||
// check selectedItems
|
||||
assert.equal(s.selectedItems.length, 2);
|
||||
assert.equal(s.selectedItems[0], s.children[0]);
|
||||
assert.equal(s.selectedItems[1], s.children[2]);
|
||||
});
|
||||
|
||||
test('fire iron-select/deselect events', function() {
|
||||
// setup listener for iron-select event
|
||||
var selectEventCounter = 0;
|
||||
s.addEventListener('iron-select', function(e) {
|
||||
selectEventCounter++;
|
||||
});
|
||||
// setup listener for core-deselect event
|
||||
var deselectEventCounter = 0;
|
||||
s.addEventListener('iron-deselect', function(e) {
|
||||
deselectEventCounter++;
|
||||
});
|
||||
// tap to select an item
|
||||
s.children[0].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
|
||||
// check events
|
||||
assert.equal(selectEventCounter, 1);
|
||||
assert.equal(deselectEventCounter, 0);
|
||||
// tap on already selected item should deselect it
|
||||
s.children[0].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
|
||||
// check selectedValues
|
||||
assert.equal(s.selectedValues.length, 0);
|
||||
// check class
|
||||
assert.isFalse(s.children[0].classList.contains('iron-selected'));
|
||||
// check events
|
||||
assert.equal(selectEventCounter, 1);
|
||||
assert.equal(deselectEventCounter, 1);
|
||||
});
|
||||
|
||||
/* test('toggle multi from true to false', function() {
|
||||
// set selected
|
||||
s.selected = [0, 2];
|
||||
var first = s.selected[0];
|
||||
// set mutli to false, so to make it single-selection
|
||||
s.multi = false;
|
||||
// selected should not be an array
|
||||
assert.isNotArray(s.selected);
|
||||
// selected should be the first value from the old array
|
||||
assert.equal(s.selected, first);
|
||||
}); */
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
134
dashboard-ui/bower_components/iron-selector/test/next-previous.html
vendored
Normal file
134
dashboard-ui/bower_components/iron-selector/test/next-previous.html
vendored
Normal file
|
@ -0,0 +1,134 @@
|
|||
<!doctype html>
|
||||
<!--
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<title>iron-selector-next-previous</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
||||
|
||||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<script src="../../web-component-tester/browser.js"></script>
|
||||
<script src="../../test-fixture/test-fixture-mocha.js"></script>
|
||||
|
||||
<link rel="import" href="../../test-fixture/test-fixture.html">
|
||||
<link rel="import" href="../iron-selector.html">
|
||||
|
||||
<style>
|
||||
.iron-selected {
|
||||
background: #ccc;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<test-fixture id="test1">
|
||||
<template>
|
||||
<iron-selector selected="0">
|
||||
<div>Item 0</div>
|
||||
<div>Item 1</div>
|
||||
<div>Item 2</div>
|
||||
</iron-selector>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="test2">
|
||||
<template>
|
||||
<iron-selector selected="foo" attr-for-selected="name">
|
||||
<div name="foo">Item Foo</div>
|
||||
<div name="bar">Item Bar</div>
|
||||
<div name="zot">Item Zot</div>
|
||||
</iron-selector>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
|
||||
var s;
|
||||
|
||||
function assertAndSelect(method, expectedIndex) {
|
||||
assert.equal(s.selected, expectedIndex);
|
||||
s[method]();
|
||||
}
|
||||
|
||||
suite('next/previous', function() {
|
||||
|
||||
setup(function () {
|
||||
s = fixture('test1');
|
||||
});
|
||||
|
||||
test('selectNext', function() {
|
||||
assert.equal(s.selected, 0);
|
||||
assertAndSelect('selectNext', 0);
|
||||
assertAndSelect('selectNext', 1);
|
||||
assertAndSelect('selectNext', 2);
|
||||
assert.equal(s.selected, 0);
|
||||
});
|
||||
|
||||
test('selectPrevious', function() {
|
||||
assert.equal(s.selected, 0);
|
||||
assertAndSelect('selectPrevious', 0);
|
||||
assertAndSelect('selectPrevious', 2);
|
||||
assertAndSelect('selectPrevious', 1);
|
||||
assert.equal(s.selected, 0);
|
||||
});
|
||||
|
||||
test('selectNext/Previous', function() {
|
||||
assert.equal(s.selected, 0);
|
||||
assertAndSelect('selectNext', 0);
|
||||
assertAndSelect('selectNext', 1);
|
||||
assertAndSelect('selectPrevious', 2);
|
||||
assertAndSelect('selectNext', 1);
|
||||
assertAndSelect('selectPrevious', 2);
|
||||
assert.equal(s.selected, 1);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
suite('next/previous attrForSelected', function() {
|
||||
|
||||
setup(function () {
|
||||
s = fixture('test2');
|
||||
});
|
||||
|
||||
test('selectNext', function() {
|
||||
assert.equal(s.selected, 'foo');
|
||||
assertAndSelect('selectNext', 'foo');
|
||||
assertAndSelect('selectNext', 'bar');
|
||||
assertAndSelect('selectNext', 'zot');
|
||||
assert.equal(s.selected, 'foo');
|
||||
});
|
||||
|
||||
test('selectPrevious', function() {
|
||||
assert.equal(s.selected, 'foo');
|
||||
assertAndSelect('selectPrevious', 'foo');
|
||||
assertAndSelect('selectPrevious', 'zot');
|
||||
assertAndSelect('selectPrevious', 'bar');
|
||||
assert.equal(s.selected, 'foo');
|
||||
});
|
||||
|
||||
test('selectNext/Previous', function() {
|
||||
assert.equal(s.selected, 'foo');
|
||||
assertAndSelect('selectNext', 'foo');
|
||||
assertAndSelect('selectNext', 'bar');
|
||||
assertAndSelect('selectPrevious', 'zot');
|
||||
assertAndSelect('selectNext', 'bar');
|
||||
assertAndSelect('selectPrevious', 'zot');
|
||||
assert.equal(s.selected, 'bar');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
72
dashboard-ui/bower_components/iron-selector/test/selected-attribute.html
vendored
Normal file
72
dashboard-ui/bower_components/iron-selector/test/selected-attribute.html
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
<!doctype html>
|
||||
<!--
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<title>iron-selector-selected-attribute</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
||||
|
||||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<script src="../../web-component-tester/browser.js"></script>
|
||||
<script src="../../test-fixture/test-fixture-mocha.js"></script>
|
||||
|
||||
<link rel="import" href="../../test-fixture/test-fixture.html">
|
||||
<link rel="import" href="../iron-selector.html">
|
||||
|
||||
<style>
|
||||
.iron-selected {
|
||||
background: #ccc;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<test-fixture id="test">
|
||||
<template>
|
||||
<iron-selector id="selector">
|
||||
<div>Item 0</div>
|
||||
<div>Item 1</div>
|
||||
<div>Item 2</div>
|
||||
<div>Item 3</div>
|
||||
<div>Item 4</div>
|
||||
</iron-selector>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
|
||||
suite('selected attributes', function() {
|
||||
|
||||
var s;
|
||||
|
||||
setup(function () {
|
||||
s = fixture('test');
|
||||
});
|
||||
|
||||
test('custom selectedAttribute', function() {
|
||||
// set selectedAttribute
|
||||
s.selectedAttribute = 'myattr';
|
||||
// check selected attribute (should not be there)
|
||||
assert.isFalse(s.children[4].hasAttribute('myattr'));
|
||||
// set selected
|
||||
s.selected = 4;
|
||||
// now selected attribute should be there
|
||||
assert.isTrue(s.children[4].hasAttribute('myattr'));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
110
dashboard-ui/bower_components/iron-selector/test/template-repeat.html
vendored
Normal file
110
dashboard-ui/bower_components/iron-selector/test/template-repeat.html
vendored
Normal file
|
@ -0,0 +1,110 @@
|
|||
<!doctype html>
|
||||
<!--
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<title>iron-selector-template-repeat</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
||||
|
||||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
||||
<script src="../../web-component-tester/browser.js"></script>
|
||||
|
||||
<link rel="import" href="../iron-selector.html">
|
||||
|
||||
<style>
|
||||
.iron-selected {
|
||||
background: #ccc;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<template is="dom-bind">
|
||||
<iron-selector id="selector" selected="1">
|
||||
<template id="t" is="dom-repeat">
|
||||
<div id$="[[item.name]]">{{item.name}}</div>
|
||||
</template>
|
||||
</iron-selector>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
suite('dom-repeat', function() {
|
||||
|
||||
var scope, s, t;
|
||||
|
||||
setup(function() {
|
||||
scope = document.querySelector('template[is="dom-bind"]');
|
||||
s = scope.$.selector;
|
||||
t = scope.$.t;
|
||||
t.items = [{name:'item0'}, {name: 'item1'}, {name: 'item2'}, {name: 'item3'}];
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
t.items = [];
|
||||
});
|
||||
|
||||
test('supports repeated items', function(done) {
|
||||
setTimeout(function() {
|
||||
// check items
|
||||
assert.equal(s.items.length, 4);
|
||||
// check selected
|
||||
assert.equal(s.selected, 1);
|
||||
// check selected item
|
||||
var item = s.selectedItem;
|
||||
assert.equal(s.items[1], item);
|
||||
// check selected class
|
||||
assert.isTrue(item.classList.contains('iron-selected'));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('update items', function(done) {
|
||||
setTimeout(function() {
|
||||
// check items
|
||||
assert.equal(s.items.length, 4);
|
||||
// check selected
|
||||
assert.equal(s.selected, 1);
|
||||
// update items
|
||||
t.items = [{name:'foo'}, {name: 'bar'}];
|
||||
setTimeout(function() {
|
||||
// check items
|
||||
assert.equal(s.items.length, 2);
|
||||
// check selected (should still honor the selected)
|
||||
assert.equal(s.selected, 1);
|
||||
// check selected class
|
||||
assert.isTrue(s.querySelector('#bar').classList.contains('iron-selected'));
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('set selected to something else', function(done) {
|
||||
setTimeout(function() {
|
||||
// set selected to something else
|
||||
s.selected = 3;
|
||||
// check selected item
|
||||
var item = s.selectedItem;
|
||||
assert.equal(s.items[3], item);
|
||||
// check selected class
|
||||
assert.isTrue(item.classList.contains('iron-selected'));
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue