1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/bower_components/paper-checkbox/paper-checkbox.html
2015-08-24 23:13:04 -04:00

147 lines
4.6 KiB
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
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../paper-ripple/paper-ripple.html">
<link rel="import" href="../paper-styles/default-theme.html">
<link rel="import" href="../paper-styles/color.html">
<link rel="import" href="../paper-behaviors/paper-inky-focus-behavior.html">
<link rel="import" href="../iron-checked-element-behavior/iron-checked-element-behavior.html">
<!--
`paper-checkbox` is a button that can be either checked or unchecked. User
can tap the checkbox to check or uncheck it. Usually you use checkboxes
to allow user to select multiple options from a set. If you have a single
ON/OFF option, avoid using a single checkbox and use `paper-toggle-button`
instead.
Example:
<paper-checkbox>label</paper-checkbox>
<paper-checkbox checked> label</paper-checkbox>
### Styling
The following custom properties and mixins are available for styling:
Custom property | Description | Default
----------------|-------------|----------
`--paper-checkbox-unchecked-background-color` | Checkbox background color when the input is not checked | `transparent`
`--paper-checkbox-unchecked-color` | Checkbox border color when the input is not checked | `--primary-text-color`
`--paper-checkbox-unchecked-ink-color` | Selected/focus ripple color when the input is not checked | `--primary-text-color`
`--paper-checkbox-checked-color` | Checkbox color when the input is checked | `--default-primary-color`
`--paper-checkbox-checked-ink-color` | Selected/focus ripple color when the input is checked | `--default-primary-color`
`--paper-checkbox-checkmark-color` | Checkmark color | `white`
`--paper-checkbox-label-color` | Label color | `--primary-text-color`
`--paper-checkbox-error-color` | Checkbox color when invalid | `--google-red-500`
@demo demo/index.html
-->
<dom-module id="paper-checkbox">
<link rel="import" type="css" href="paper-checkbox.css">
<template>
<div id="checkboxContainer">
<paper-ripple id="ink" class="circle" center checked$="[[checked]]"></paper-ripple>
<div id="checkbox" class$="[[_computeCheckboxClass(checked, invalid)]]">
<div id="checkmark" class$="[[_computeCheckmarkClass(checked)]]"></div>
</div>
</div>
<div id="checkboxLabel" aria-hidden="true"><content></content></div>
</template>
<script>
Polymer({
is: 'paper-checkbox',
behaviors: [
Polymer.PaperInkyFocusBehavior,
Polymer.IronCheckedElementBehavior
],
hostAttributes: {
role: 'checkbox',
'aria-checked': false,
tabindex: 0
},
properties: {
/**
* Fired when the checked state changes due to user interaction.
*
* @event change
*/
/**
* Fired when the checked state changes.
*
* @event iron-change
*/
ariaActiveAttribute: {
value: 'aria-checked'
}
},
attached: function() {
this._isReady = true;
// Don't stomp over a user-set aria-label.
if (!this.getAttribute('aria-label')) {
this.updateAriaLabel();
}
},
/**
* Update the checkbox aria-label. This is a temporary workaround not
* being able to observe changes in <content>
* (see: https://github.com/Polymer/polymer/issues/1773)
*
* Call this if you manually change the contents of the checkbox
* and want the aria-label to match the new contents.
*/
updateAriaLabel: function() {
this.setAttribute('aria-label', Polymer.dom(this).textContent.trim());
},
// button-behavior hook
_buttonStateChanged: function() {
if (this.disabled) {
return;
}
if (this._isReady) {
this.checked = this.active;
}
},
_computeCheckboxClass: function(checked, invalid) {
var className = '';
if (checked) {
className += 'checked ';
}
if (invalid) {
className += 'invalid';
}
return className;
},
_computeCheckmarkClass: function(checked) {
return checked ? '' : 'hidden';
}
})
</script>
</dom-module>