Add ICU message format support
[chromium-blink-merge.git] / third_party / polymer / v1_0 / components-chromium / iron-behaviors / iron-control-state-extracted.js
blobd84e4eeda12c65b8e070b4578d315059b27a1e72
3 /**
4 * @demo demo/index.html
5 * @polymerBehavior
6 */
7 Polymer.IronControlState = {
9 properties: {
11 /**
12 * If true, the element currently has focus.
14 focused: {
15 type: Boolean,
16 value: false,
17 notify: true,
18 readOnly: true,
19 reflectToAttribute: true
22 /**
23 * If true, the user cannot interact with this element.
25 disabled: {
26 type: Boolean,
27 value: false,
28 notify: true,
29 observer: '_disabledChanged',
30 reflectToAttribute: true
33 _oldTabIndex: {
34 type: Number
37 _boundFocusBlurHandler: {
38 type: Function,
39 value: function() {
40 return this._focusBlurHandler.bind(this);
46 observers: [
47 '_changedControlState(focused, disabled)'
50 ready: function() {
51 // TODO(sjmiles): ensure read-only property is valued so the compound
52 // observer will fire
53 if (this.focused === undefined) {
54 this._setFocused(false);
56 this.addEventListener('focus', this._boundFocusBlurHandler, true);
57 this.addEventListener('blur', this._boundFocusBlurHandler, true);
60 _focusBlurHandler: function(event) {
61 var target = event.path ? event.path[0] : event.target;
62 if (target === this) {
63 var focused = event.type === 'focus';
64 this._setFocused(focused);
65 } else if (!this.shadowRoot) {
66 event.stopPropagation();
67 this.fire(event.type, {sourceEvent: event}, {
68 node: this,
69 bubbles: event.bubbles,
70 cancelable: event.cancelable
71 });
75 _disabledChanged: function(disabled, old) {
76 this.setAttribute('aria-disabled', disabled ? 'true' : 'false');
77 this.style.pointerEvents = disabled ? 'none' : '';
78 if (disabled) {
79 this._oldTabIndex = this.tabIndex;
80 this.focused = false;
81 this.tabIndex = -1;
82 } else if (this._oldTabIndex !== undefined) {
83 this.tabIndex = this._oldTabIndex;
87 _changedControlState: function() {
88 // _controlStateChanged is abstract, follow-on behaviors may implement it
89 if (this._controlStateChanged) {
90 this._controlStateChanged();