| OLD | NEW |
| 1 | 1 |
| 2 (function() { | 2 (function() { |
| 3 | 3 |
| 4 Polymer({ | 4 Polymer({ |
| 5 | 5 |
| 6 is: 'paper-input-container', | 6 is: 'paper-input-container', |
| 7 | 7 |
| 8 properties: { | 8 properties: { |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 /** | 53 /** |
| 54 * True if the input has focus. | 54 * True if the input has focus. |
| 55 */ | 55 */ |
| 56 focused: { | 56 focused: { |
| 57 readOnly: true, | 57 readOnly: true, |
| 58 type: Boolean, | 58 type: Boolean, |
| 59 value: false | 59 value: false |
| 60 }, | 60 }, |
| 61 | 61 |
| 62 _addons: { | 62 _addons: { |
| 63 type: Array, | 63 type: Array |
| 64 value: function() { | 64 // do not set a default value here intentionally - it will be initialize
d lazily when a |
| 65 return []; | 65 // distributed child is attached, which may occur before configuration f
or this element |
| 66 } | 66 // in polyfill. |
| 67 }, | 67 }, |
| 68 | 68 |
| 69 _inputHasContent: { | 69 _inputHasContent: { |
| 70 type: Boolean, | 70 type: Boolean, |
| 71 value: false | 71 value: false |
| 72 }, | 72 }, |
| 73 | 73 |
| 74 _inputSelector: { | 74 _inputSelector: { |
| 75 type: String, | 75 type: String, |
| 76 value: 'input,textarea,.paper-input-input' | 76 value: 'input,textarea,.paper-input-input' |
| 77 }, | 77 }, |
| 78 | 78 |
| 79 _boundOnFocus: { | 79 _boundOnFocus: { |
| 80 type: Function, | 80 type: Function, |
| 81 value: function() { | 81 value: function() { |
| 82 return this._onFocus.bind(this); | 82 return this._onFocus.bind(this); |
| 83 } | 83 } |
| 84 }, | 84 }, |
| 85 | 85 |
| 86 _boundOnBlur: { | 86 _boundOnBlur: { |
| 87 type: Function, | 87 type: Function, |
| 88 value: function() { | 88 value: function() { |
| 89 return this._onBlur.bind(this); | 89 return this._onBlur.bind(this); |
| 90 } | 90 } |
| 91 }, | 91 }, |
| 92 | 92 |
| 93 _boundOnInput: { | 93 _boundOnInput: { |
| 94 type: Function, | 94 type: Function, |
| 95 value: function() { | 95 value: function() { |
| 96 this._onInput.bind(this) | 96 return this._onInput.bind(this); |
| 97 } | 97 } |
| 98 }, | 98 }, |
| 99 | 99 |
| 100 _boundValueChanged: { | 100 _boundValueChanged: { |
| 101 type: Function, | 101 type: Function, |
| 102 value: function() { | 102 value: function() { |
| 103 return this._onValueChanged.bind(this); | 103 return this._onValueChanged.bind(this); |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 | 106 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 117 | 117 |
| 118 get _propertyForValue() { | 118 get _propertyForValue() { |
| 119 return Polymer.CaseMap.dashToCamelCase(this.attrForValue); | 119 return Polymer.CaseMap.dashToCamelCase(this.attrForValue); |
| 120 }, | 120 }, |
| 121 | 121 |
| 122 get _inputElement() { | 122 get _inputElement() { |
| 123 return Polymer.dom(this).querySelector(this._inputSelector); | 123 return Polymer.dom(this).querySelector(this._inputSelector); |
| 124 }, | 124 }, |
| 125 | 125 |
| 126 ready: function() { | 126 ready: function() { |
| 127 if (!this._addons) { |
| 128 this._addons = []; |
| 129 } |
| 127 this.addEventListener('focus', this._boundOnFocus, true); | 130 this.addEventListener('focus', this._boundOnFocus, true); |
| 128 this.addEventListener('blur', this._boundOnBlur, true); | 131 this.addEventListener('blur', this._boundOnBlur, true); |
| 129 if (this.attrForValue) { | 132 if (this.attrForValue) { |
| 130 this._inputElement.addEventListener(this._valueChangedEvent, this._bound
ValueChanged); | 133 this._inputElement.addEventListener(this._valueChangedEvent, this._bound
ValueChanged); |
| 131 } else { | 134 } else { |
| 132 this.addEventListener('input', this._onInput); | 135 this.addEventListener('input', this._onInput); |
| 133 } | 136 } |
| 134 }, | 137 }, |
| 135 | 138 |
| 136 attached: function() { | 139 attached: function() { |
| 137 this._handleValue(this._inputElement); | 140 this._handleValue(this._inputElement); |
| 138 }, | 141 }, |
| 139 | 142 |
| 140 _onAddonAttached: function(event) { | 143 _onAddonAttached: function(event) { |
| 141 this._addons.push(event.target); | 144 if (!this._addons) { |
| 142 this._handleValue(this._inputElement); | 145 this._addons = []; |
| 146 } |
| 147 var target = event.target; |
| 148 if (this._addons.indexOf(target) === -1) { |
| 149 this._addons.push(target); |
| 150 if (this.isAttached) { |
| 151 this._handleValue(this._inputElement); |
| 152 } |
| 153 } |
| 143 }, | 154 }, |
| 144 | 155 |
| 145 _onFocus: function() { | 156 _onFocus: function() { |
| 146 this._setFocused(true); | 157 this._setFocused(true); |
| 147 }, | 158 }, |
| 148 | 159 |
| 149 _onBlur: function() { | 160 _onBlur: function() { |
| 150 this._setFocused(false); | 161 this._setFocused(false); |
| 151 }, | 162 }, |
| 152 | 163 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 cls += ' is-invalid'; | 251 cls += ' is-invalid'; |
| 241 } else if (focused) { | 252 } else if (focused) { |
| 242 cls += ' is-highlighted' | 253 cls += ' is-highlighted' |
| 243 } | 254 } |
| 244 return cls; | 255 return cls; |
| 245 } | 256 } |
| 246 | 257 |
| 247 }); | 258 }); |
| 248 | 259 |
| 249 })(); | 260 })(); |
| OLD | NEW |