Skip to content

Add iron-form support and bug fixes #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"paper-listbox": "polymerelements/paper-listbox#^1.1.2",
"paper-input": "PolymerElements/paper-input#^1.1.23",
"iron-flex-layout": "PolymerElements/iron-flex-layout#^1.3.2",
"paper-styles": "PolymerElements/paper-styles#^1.1.5"
"paper-styles": "PolymerElements/paper-styles#^1.1.5",
"iron-form-element-behavior": "PolymerElements/iron-form-element-behavior#^1.0.7",
"iron-validatable-behavior": "PolymerElements/iron-validatable-behavior#^1.1.2"
},
"devDependencies": {
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
Expand Down
22 changes: 14 additions & 8 deletions paper-time-input.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<link rel="import" href="../paper-dropdown-menu/paper-dropdown-menu.html">
<link rel="import" href="../paper-styles/typography.html">
<link rel="import" href="../iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="../iron-validatable-behavior/iron-validatable-behavior.html">
<link rel="import" href="../iron-form-element-behavior/iron-form-element-behavior.html">

<!--
`<paper-time-input>` Polymer element to accept a time with paper-input & paper-dropdown-menu
Expand All @@ -30,7 +32,7 @@
<style>
:host {
display: block;
@apply(--paper-font-common-base);
@apply --paper-font-common-base;
}

paper-input{
Expand Down Expand Up @@ -66,7 +68,7 @@
};
--paper-input-container-input: {
text-align: center;
@apply(--paper-font-button);
@apply --paper-font-button;
padding-left: 5px;
};
--paper-input-container-underline: {
Expand All @@ -86,11 +88,11 @@
}

label{
@apply(--paper-font-caption);
@apply --paper-font-caption;
}
.time-input-wrap{
@apply(--layout-horizontal);
@apply(--layout-no-wrap);
@apply --layout-horizontal;
@apply --layout-no-wrap;
}

[hidden]{
Expand Down Expand Up @@ -149,6 +151,10 @@
<script>
Polymer({
is: 'paper-time-input',
behaviors: [
Polymer.IronFormElementBehavior,
Polymer.IronValidatableBehavior
],
properties: {
/**
* Label for the input
Expand Down Expand Up @@ -221,7 +227,7 @@
* Validate the inputs
* @return {boolean}
*/
validate: function(){
_getValidity: function(){
if(this.$.hour.validate() & this.$.min.validate()){
return true;
}
Expand All @@ -232,8 +238,8 @@
*/
_computeTime: function(min, hour, amPm){
// No ampm on 24 hr time
if (this.format == 24) {
amPm = "";
if (this.format == 24 && hour && min) {
return hour + ":" + min;
}
if (hour && min) {
return hour + ":" + min + " " + amPm;
Expand Down