-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(timepicker): create documentation for timepicker (#1481)
- Loading branch information
1 parent
8072960
commit 8e18733
Showing
17 changed files
with
215 additions
and
78 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<timepicker [(ngModel)]="mytime"></timepicker> | ||
<pre class="alert alert-info">Time is: {{mytime}}</pre> |
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,9 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'demo-timepicker-basic', | ||
templateUrl: './basic.html' | ||
}) | ||
export class DemoTimepickerBasicComponent { | ||
public mytime: Date = new Date(); | ||
} |
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,2 @@ | ||
<timepicker [(ngModel)]="mytime"></timepicker> | ||
<pre class="alert alert-info">Time is: {{mytime}}</pre> |
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 @@ | ||
import { Component } from '@angular/core'; | ||
import { TimepickerConfig } from 'ng2-bootstrap'; | ||
|
||
// such override allows to keep some initial values | ||
|
||
export function getTimepickerConfig(): TimepickerConfig { | ||
return Object.assign(new TimepickerConfig(), { | ||
hourStep: 2, | ||
minuteStep: 10, | ||
showMeridian: false, | ||
readonlyInput: false, | ||
mousewheel: true | ||
}); | ||
} | ||
|
||
@Component({ | ||
selector: 'demo-timepicker-config', | ||
templateUrl: './config.html', | ||
providers: [{provide: TimepickerConfig, useFactory: getTimepickerConfig}] | ||
}) | ||
export class DemoTimepickerConfigComponent { | ||
} |
18 changes: 18 additions & 0 deletions
18
demo/src/app/components/timepicker/demos/custom/custom.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,18 @@ | ||
<timepicker [(ngModel)]="mytime" [hourStep]="hstep" [minuteStep]="mstep"></timepicker> | ||
|
||
<pre class="alert alert-info">Time is: {{mytime}}</pre> | ||
|
||
<div class="row"> | ||
<div class="col-xs-6"> | ||
Hours step is: | ||
<select class="form-control" [(ngModel)]="hstep"> | ||
<option *ngFor="let opt of options.hstep" [value]="opt">{{opt}}</option> | ||
</select> | ||
</div> | ||
<div class="col-xs-6"> | ||
Minutes step is: | ||
<select class="form-control" [(ngModel)]="mstep"> | ||
<option *ngFor="let opt of options.mstep" [value]="opt">{{opt}}</option> | ||
</select> | ||
</div> | ||
</div> |
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,16 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'demo-timepicker-custom', | ||
templateUrl: './custom.html' | ||
}) | ||
export class DemoTimepickerCustomComponent { | ||
public hstep: number = 1; | ||
public mstep: number = 15; | ||
|
||
public mytime: Date = new Date(); | ||
public options: any = { | ||
hstep: [1, 2, 3], | ||
mstep: [1, 5, 10, 15, 25, 30] | ||
}; | ||
} |
5 changes: 5 additions & 0 deletions
5
demo/src/app/components/timepicker/demos/disabled/disabled.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,5 @@ | ||
<timepicker [(ngModel)]="mytime" [showMeridian]="ismeridian" [readonlyInput]="!isEnabled"></timepicker> | ||
<hr> | ||
|
||
<button type="button" class="btn btn-info" (click)="isEnabled=!isEnabled">Enable / Disable input</button> | ||
|
12 changes: 12 additions & 0 deletions
12
demo/src/app/components/timepicker/demos/disabled/disabled.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,12 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'demo-timepicker-disabled', | ||
templateUrl: './disabled.html' | ||
}) | ||
export class DemoTimepickerDisabledComponent { | ||
public ismeridian: boolean = false; | ||
public isEnabled: boolean = true; | ||
public mytime: Date = new Date(); | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
demo/src/app/components/timepicker/demos/dynamic/dynamic.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,6 @@ | ||
<timepicker [(ngModel)]="mytime" (change)="changed()"></timepicker> | ||
|
||
<pre class="alert alert-info">Time is: {{mytime}}</pre> | ||
|
||
<button type="button" class="btn btn-primary" (click)="update()">Set to 14:00</button> | ||
<button type="button" class="btn btn-danger" (click)="clear()">Clear</button> |
25 changes: 25 additions & 0 deletions
25
demo/src/app/components/timepicker/demos/dynamic/dynamic.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,25 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'demo-timepicker-dynamic', | ||
templateUrl: './dynamic.html' | ||
}) | ||
export class DemoTimepickerDynamicComponent { | ||
|
||
public mytime: Date = new Date(); | ||
|
||
public update(): void { | ||
let d = new Date(); | ||
d.setHours(14); | ||
d.setMinutes(0); | ||
this.mytime = d; | ||
} | ||
|
||
public changed(): void { | ||
console.log('Time changed to: ' + this.mytime); | ||
} | ||
|
||
public clear(): void { | ||
this.mytime = void 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,38 @@ | ||
import { TimepickerDemoComponent } from './timepicker-demo.component'; | ||
import { DemoTimepickerBasicComponent } from './basic/basic'; | ||
import { DemoTimepickerConfigComponent } from './config/config'; | ||
import { DemoTimepickerMeridianComponent } from './meridian/meridian'; | ||
import { DemoTimepickerDisabledComponent } from './disabled/disabled'; | ||
import { DemoTimepickerCustomComponent } from './custom/custom'; | ||
import { DemoTimepickerDynamicComponent } from './dynamic/dynamic'; | ||
|
||
export const DEMO_COMPONENTS = [ | ||
TimepickerDemoComponent | ||
DemoTimepickerBasicComponent, DemoTimepickerConfigComponent, DemoTimepickerMeridianComponent, | ||
DemoTimepickerDisabledComponent, DemoTimepickerCustomComponent, DemoTimepickerDynamicComponent | ||
]; | ||
|
||
export const DEMOS = { | ||
old: { | ||
component: require('!!raw?lang=typescript!./timepicker-demo.component'), | ||
html: require('!!raw?lang=markup!./timepicker-demo.component.html') | ||
basic: { | ||
component: require('!!raw?lang=typescript!./basic/basic'), | ||
html: require('!!raw?lang=markup!./basic/basic.html') | ||
}, | ||
meridian: { | ||
component: require('!!raw?lang=typescript!./meridian/meridian'), | ||
html: require('!!raw?lang=markup!./meridian/meridian.html') | ||
}, | ||
disabled: { | ||
component: require('!!raw?lang=typescript!./disabled/disabled'), | ||
html: require('!!raw?lang=markup!./disabled/disabled.html') | ||
}, | ||
custom: { | ||
component: require('!!raw?lang=typescript!./custom/custom'), | ||
html: require('!!raw?lang=markup!./custom/custom.html') | ||
}, | ||
dynamic: { | ||
component: require('!!raw?lang=typescript!./dynamic/dynamic'), | ||
html: require('!!raw?lang=markup!./dynamic/dynamic.html') | ||
}, | ||
config: { | ||
component: require('!!raw?lang=typescript!./config/config'), | ||
html: require('!!raw?lang=markup!./config/config.html') | ||
} | ||
}; |
8 changes: 8 additions & 0 deletions
8
demo/src/app/components/timepicker/demos/meridian/meridian.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,8 @@ | ||
<timepicker [(ngModel)]="mytime" (change)="changed()" [showMeridian]="ismeridian"></timepicker> | ||
|
||
<pre class="alert alert-info">Time is: {{mytime}}</pre> | ||
|
||
<hr> | ||
|
||
<button type="button" class="btn btn-info" (click)="toggleMode()">12H / 24H</button> | ||
|
16 changes: 16 additions & 0 deletions
16
demo/src/app/components/timepicker/demos/meridian/meridian.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,16 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'demo-timepicker-meridian', | ||
templateUrl: './meridian.html' | ||
}) | ||
export class DemoTimepickerMeridianComponent { | ||
public ismeridian:boolean = true; | ||
|
||
public mytime:Date = new Date(); | ||
|
||
public toggleMode():void { | ||
this.ismeridian = !this.ismeridian; | ||
} | ||
|
||
} |
27 changes: 0 additions & 27 deletions
27
demo/src/app/components/timepicker/demos/timepicker-demo.component.html
This file was deleted.
Oops, something went wrong.
37 changes: 0 additions & 37 deletions
37
demo/src/app/components/timepicker/demos/timepicker-demo.component.ts
This file was deleted.
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
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