-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
431 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
.../app/documentation/component-docs/list/examples/list-checkbox-form-example.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<form [formGroup]="customForm"> | ||
<ul fd-list> | ||
<li fd-list-item> | ||
<fd-list-checkbox formControlName="listItem1">List Item 1</fd-list-checkbox> | ||
</li> | ||
<li fd-list-item> | ||
<fd-list-checkbox formControlName="listItem2">List Item 2</fd-list-checkbox> | ||
</li> | ||
<li fd-list-item> | ||
<fd-list-checkbox formControlName="listItem3">List Item 3</fd-list-checkbox> | ||
</li> | ||
<li fd-list-item> | ||
<fd-list-checkbox formControlName="listItem4">List Item 4</fd-list-checkbox> | ||
</li> | ||
</ul> | ||
</form> | ||
<br /> | ||
|
||
List Item 1: {{ customForm.controls.listItem1.value }} <br /> | ||
List Item 2: {{ customForm.controls.listItem2.value }} <br /> | ||
List Item 3: {{ customForm.controls.listItem3.value }} <br /> | ||
List Item 4: {{ customForm.controls.listItem4.value }} |
15 changes: 15 additions & 0 deletions
15
docs/app/documentation/component-docs/list/examples/list-checkbox-form-example.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Component } from '@angular/core'; | ||
import { FormGroup, FormControl } from '@angular/forms'; | ||
|
||
@Component({ | ||
selector: 'fd-list-checkbox-form-example', | ||
templateUrl: './list-checkbox-form-example.component.html' | ||
}) | ||
export class ListCheckboxFormExampleComponent { | ||
customForm = new FormGroup({ | ||
listItem1: new FormControl(false), | ||
listItem2: new FormControl(false), | ||
listItem3: new FormControl(false), | ||
listItem4: new FormControl(false) | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...on/component-docs/time-picker/examples/time-picker-other-delimiter-example.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<fd-time-picker [allowNull]="false" | ||
[(ngModel)]="timeObject"></fd-time-picker> | ||
<br /> | ||
Selected Time: {{timeObject.hour}}h {{timeObject.minute}}m {{timeObject.second}}s |
148 changes: 148 additions & 0 deletions
148
...tion/component-docs/time-picker/examples/time-picker-other-delimiter-example.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
import { Component, Injectable } from '@angular/core'; | ||
import { TimeFormatParser } from '../../../../../../library/src/lib/time-picker/format/time-parser'; | ||
import { TimeObject } from '../../../../../../library/src/lib/time/time-object'; | ||
|
||
|
||
@Injectable() | ||
export class TimeFormatDashes extends TimeFormatParser { | ||
|
||
public parse(value: string, displaySeconds: boolean = true, meridian?: boolean): TimeObject { | ||
const time = new TimeObject(); | ||
let regexp; | ||
if (!meridian) { | ||
if (displaySeconds) { | ||
regexp = new RegExp( | ||
'\^([0-1]?[0-9]|2[0-3])' + | ||
'h' + | ||
'([0-5][0-9])(' + | ||
'm' + | ||
'[0-5][0-9])' + | ||
's\$' | ||
); | ||
} else { | ||
regexp = new RegExp('\^([0-1]?[0-9]|2[0-3])' + | ||
'h' + | ||
'([0-5][0-9])(' + | ||
'm\$' | ||
); | ||
} | ||
if (regexp.test(value)) { | ||
const minutes = value.split('h')[1].split('m')[0]; | ||
time.hour = parseInt(value.split('h')[0], 10); | ||
time.minute = parseInt(minutes, 10); | ||
if (displaySeconds) { | ||
time.second = parseInt(value.split('m')[1], 10); | ||
} | ||
return time; | ||
} else { | ||
return null; | ||
} | ||
} else if (meridian) { | ||
if (displaySeconds) { | ||
|
||
|
||
regexp = new RegExp( | ||
'\^([0-1]?[0-9]|2[0-3])' + | ||
'h' + | ||
'([0-5][0-9])(' + | ||
'm' + | ||
'[0-5][0-9])' + | ||
's' + | ||
' [APap][mM]\$' | ||
); | ||
} else { | ||
regexp = new RegExp('\^([0-1]?[0-9]|2[0-3])' + | ||
'h' + | ||
'([0-5][0-9])(' + | ||
'm' + | ||
' [APap][mM]\$' | ||
); | ||
} | ||
if (regexp.test(value)) { | ||
const period = value.split(' ')[1]; | ||
const _time = value.split(' ')[0]; | ||
|
||
const minutes = _time.split('h')[1].split('m')[0]; | ||
time.hour = parseInt(_time.split('h')[0], 10); | ||
time.minute = parseInt(minutes, 10); | ||
if (displaySeconds) { | ||
time.second = parseInt(_time.split('m')[1], 10); | ||
} | ||
if (( period === 'pm' || period === 'PM' ) && time.hour < 12) { | ||
time.hour = time.hour + 12; | ||
} else if ( (period === 'am' || period === 'AM') && time.hour === 12 ) { | ||
time.hour = 0; | ||
} | ||
return time; | ||
} else { | ||
return null; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Takes in a time object and returns the string representation. | ||
* @param time TimeObject to convert to a string. | ||
* @param meridian boolean to define if TimeObject should be treated as a meridian. | ||
*/ | ||
public format(time: TimeObject, meridian?: boolean): string { | ||
let formattedHour, formattedMinute, formattedSecond; | ||
let formattedTime; | ||
let formattedMeridian; | ||
if (time.hour !== null) { | ||
if (meridian) { | ||
if (time.hour === 0) { | ||
formattedHour = 12; | ||
formattedMeridian = 'am'; | ||
} else if (time.hour > 12) { | ||
formattedHour = time.hour - 12; | ||
formattedMeridian = 'pm'; | ||
} else if (time.hour === 12) { | ||
formattedHour = 12; | ||
formattedMeridian = 'pm'; | ||
} else { | ||
formattedHour = time.hour; | ||
formattedMeridian = 'am'; | ||
} | ||
} else { | ||
formattedHour = time.hour; | ||
} | ||
} | ||
if (time.minute !== null) { | ||
formattedMinute = time.minute < 10 ? '0' + time.minute : time.minute; | ||
} | ||
|
||
if (time.second !== null) { | ||
formattedSecond = time.second < 10 ? '0' + time.second : time.second; | ||
} | ||
if (formattedHour || formattedHour === 0) { | ||
formattedTime = formattedHour + 'h'; | ||
if (formattedMinute || formattedMinute === '00') { | ||
formattedTime = formattedTime + formattedMinute + 'm'; | ||
if (formattedSecond || formattedSecond === '00') { | ||
formattedTime = formattedTime + formattedSecond + 's'; | ||
} | ||
} | ||
} | ||
if (formattedMeridian && formattedTime) { | ||
formattedTime += ' ' + formattedMeridian | ||
} | ||
|
||
return formattedTime; | ||
} | ||
} | ||
|
||
|
||
@Component({ | ||
selector: 'fd-time-picker-other-delimiter-example', | ||
templateUrl: './time-picker-other-delimiter-example.component.html', | ||
providers: [ | ||
{ | ||
provide: TimeFormatParser, | ||
useClass: TimeFormatDashes | ||
} | ||
] | ||
}) | ||
export class TimePickerOtherDelimiterExampleComponent { | ||
timeObject = { hour: 12, minute: 0, second: 0 }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.