Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
support tabindex on core-input and tabbing forwards
Browse files Browse the repository at this point in the history
  • Loading branch information
Yvonne Yip committed Jul 16, 2014
1 parent 759f149 commit 2149202
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions core-input.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,18 @@
-->
<link href="../polymer/polymer.html" rel="import">

<polymer-element name="core-input">
<polymer-element name="core-input" on-focus="{{focusAction}}">

<template>

<link href="core-input.css" rel="stylesheet">

<template if="{{multiline}}">
<textarea id="input" value="{{inputValue}}" rows="{{rows}}" fit?="{{rows === 'fit'}}" disabled?="{{disabled}}" placeholder="{{placeholder}}" required?="{{required}}" readonly?="{{readonly}}" aria-label="{{label || placeholder}}" aria-invalid="{{invalid}}" on-change="{{inputChangeAction}}" on-focus="{{focusAction}}" on-blur="{{blurAction}}"></textarea>
<textarea id="input" value="{{inputValue}}" rows="{{rows}}" fit?="{{rows === 'fit'}}" disabled?="{{disabled}}" placeholder="{{placeholder}}" required?="{{required}}" readonly?="{{readonly}}" aria-label="{{label || placeholder}}" aria-invalid="{{invalid}}" on-change="{{inputChangeAction}}" on-focus="{{inputFocusAction}}" on-blur="{{inputBlurAction}}"></textarea>
</template>

<template if="{{!multiline}}">
<input id="input" value="{{inputValue}}" disabled?="{{disabled}}" type="{{type}}" placeholder="{{placeholder}}" required?="{{required}}" readonly?="{{readonly}}" aria-label="{{label || placeholder}}" aria-invalid="{{invalid}}" on-change="{{inputChangeAction}}" on-focus="{{focusAction}}" on-blur="{{blurAction}}">
<input id="input" value="{{inputValue}}" disabled?="{{disabled}}" type="{{type}}" placeholder="{{placeholder}}" required?="{{required}}" readonly?="{{readonly}}" aria-label="{{label || placeholder}}" aria-invalid="{{invalid}}" on-change="{{inputChangeAction}}" on-focus="{{inputFocusAction}}" on-blur="{{inputBlurAction}}">
</template>

</template>
Expand Down Expand Up @@ -227,7 +227,11 @@
*/
invalid: false,
},


ready: function() {
this.tabindexChanged(this.getAttribute('tabindex'));
},

validateValue: function() {
var valid = true;

Expand Down Expand Up @@ -269,6 +273,20 @@
this.validateValue();
},

attributeChanged: function(attr, oldVal, curVal) {
if (attr === 'tabindex') {
this.tabindexChanged(curVal);
}
},

tabindexChanged: function(tabindex) {
if (tabindex > 0) {
this.$.input.setAttribute('tabindex', -1);
} else {
this.$.input.removeAttribute('tabindex');
}
},

/**
* Commits the inputValue to value.
*
Expand All @@ -287,11 +305,15 @@
},

focusAction: function() {
this.$.input.focus();
},

inputFocusAction: function() {
// re-fire non-bubbling event
this.fire('focus', null, this, false);
},

blurAction: function() {
inputBlurAction: function() {
// re-fire non-bubbling event
this.fire('blur', null, this, false);
}
Expand Down

0 comments on commit 2149202

Please sign in to comment.