forked from fluxio/io-value
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_io-base.html
65 lines (63 loc) · 1.84 KB
/
_io-base.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!--
Base for io-value input elements
@element io-base
@homepage https://github.com/arodic/io-value
@demo http://akirodic.com/components/io-value/demo.html
@blurb Base for generic io-value input elements
@status alpha
-->
<link rel="import" href="../polymer/polymer.html">
<polymer-element name="io-base">
<script>
Polymer({
publish: {
/**
* Element value.
*
* @attribute value
* @type any
* @default null
*/
value: null,
/**
* Determines if the input can be focused and edited by user action.
*
* @attribute disabled
* @type boolean
* @default false
*/
disabled: {value: false, reflect: true},
},
/**
* Helper method used used to fire 'value-set' event.
*
* @method fireValueSet
*/
setValue: function(value) {
if (value === this.value) return;
var oldValue = this.value;
this.value = value;
/**
* Fired when an value attribute is set by user action.
* This method should only be invoked from functions triggered by user action.
*
* @event value-set
* @param {Object} detail
* @param {Object} detail.element the input element where value was set.
* @param {Object} detail.value new value.
* @param {Object} detail.oldValue old value.
*/
this.fire('value-set', {element: this, value: this.value, oldValue: oldValue});
},
disabledChanged: function() {
if (this.disabled) {
this.$.value.removeAttribute('tabindex');
this.setAttribute('aria-disabled', '');
} else {
this.$.value.setAttribute('tabindex', 0);
this.removeAttribute('aria-disabled');
}
}
});
</script>
</polymer-element>