-
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.
feat(datepicker): added bsConfig input, locales and color themes with…
… containerClass (#2549)
- Loading branch information
Showing
40 changed files
with
1,492 additions
and
97 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
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
33 changes: 33 additions & 0 deletions
33
demo/src/app/components/+datepicker/demos/change-locale/change-locale.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,33 @@ | ||
<div class="row"> | ||
<div class="col-xs-6 col-sm-3"> | ||
<select | ||
class="custom-select form-control " | ||
[(ngModel)]="locale" (ngModelChange)="applyLocale(dp);"> | ||
<option *ngFor="let loc of locales" [value]="loc">{{ loc }}</option> | ||
</select> | ||
</div> | ||
<input type="button" | ||
class="btn btn-success" | ||
value="Date Picker" | ||
bsDatepicker | ||
#dp="bsDatepicker" | ||
[bsConfig]="bsConfig"/> | ||
</div> | ||
<br> | ||
|
||
<div class="row"> | ||
<div class="col-xs-6 col-sm-3"> | ||
<select | ||
class="custom-select form-control " | ||
[(ngModel)]="locale" (ngModelChange)="applyLocale(dpr);"> | ||
<option *ngFor="let loc of locales" [value]="loc">{{ loc }}</option> | ||
</select> | ||
</div> | ||
<input type="button" | ||
class="btn btn-success" | ||
value="Date Range Picker" | ||
bsDaterangepicker | ||
#dpr="bsDaterangepicker" | ||
[bsConfig]="bsConfig"/> | ||
</div> | ||
|
23 changes: 23 additions & 0 deletions
23
demo/src/app/components/+datepicker/demos/change-locale/change-locale.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,23 @@ | ||
import { Component } from '@angular/core'; | ||
import { BsDatepickerConfig } from 'ngx-bootstrap/datepicker'; | ||
import { listLocales } from 'ngx-bootstrap/bs-moment'; | ||
|
||
@Component({ | ||
selector: 'demo-datepicker-change-locale', | ||
templateUrl: './change-locale.html' | ||
}) | ||
export class DemoDatepickerChangeLocaleComponent { | ||
locale = 'en'; | ||
locales = listLocales(); | ||
bsConfig: Partial<BsDatepickerConfig>; | ||
|
||
applyLocale(pop: any) { | ||
// create new object on each property change | ||
// so Angular can catch object reference change | ||
this.bsConfig = Object.assign({}, {locale: this.locale}); | ||
setTimeout(() => { | ||
pop.hide(); | ||
pop.show(); | ||
}); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
demo/src/app/components/+datepicker/demos/color-theming/color-theming.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,47 @@ | ||
<div class="row"> | ||
<div class="col-xs-6 col-sm-3"> | ||
<select | ||
class="custom-select form-control " | ||
[(ngModel)]="colorTheme" (ngModelChange)="applyTheme(dp);"> | ||
<option value="theme-default">default</option> | ||
<option value="theme-green">green</option> | ||
<option value="theme-blue">blue</option> | ||
<option value="theme-dark-blue">dark-blue</option> | ||
<option value="theme-red">red</option> | ||
<option value="theme-orange">orange</option> | ||
</select> | ||
</div> | ||
<div class="col-xs-6 col-sm-9"> | ||
<input type="button" | ||
class="btn btn-success" | ||
value="Date Picker" | ||
bsDatepicker | ||
#dp="bsDatepicker" | ||
[bsConfig]="bsConfig"/> | ||
</div> | ||
</div> | ||
<br> | ||
|
||
<div class="row"> | ||
<div class="col-xs-6 col-sm-3"> | ||
<select | ||
class="custom-select form-control " | ||
[(ngModel)]="colorTheme" (ngModelChange)="applyTheme(dpr);"> | ||
<option value="theme-default">default</option> | ||
<option value="theme-green">green</option> | ||
<option value="theme-blue">blue</option> | ||
<option value="theme-dark-blue">dark-blue</option> | ||
<option value="theme-red">red</option> | ||
<option value="theme-orange">orange</option> | ||
</select> | ||
</div> | ||
<div class="col-xs-6 col-sm-9"> | ||
<input type="button" | ||
class="btn btn-success" | ||
value="Date Range Picker" | ||
bsDaterangepicker | ||
#dpr="bsDaterangepicker" | ||
[bsConfig]="bsConfig"/> | ||
</div> | ||
</div> | ||
|
21 changes: 21 additions & 0 deletions
21
demo/src/app/components/+datepicker/demos/color-theming/color-theming.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,21 @@ | ||
import { Component } from '@angular/core'; | ||
import { BsDatepickerConfig } from 'ngx-bootstrap/datepicker'; | ||
|
||
@Component({ | ||
selector: 'demo-datepicker-color-theming', | ||
templateUrl: './color-theming.html' | ||
}) | ||
export class DemoDatepickerColorThemingComponent { | ||
colorTheme = 'theme-green'; | ||
|
||
bsConfig: Partial<BsDatepickerConfig>; | ||
|
||
applyTheme(pop: any) { | ||
// create new object on each property change | ||
// so Angular can catch object reference change | ||
this.bsConfig = Object.assign({}, {containerClass: this.colorTheme}); | ||
setTimeout(() => { | ||
pop.show(); | ||
}); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// moment.js locale configuration | ||
// locale : German [de] | ||
// author : lluchs : https://github.com/lluchs | ||
// author: Menelion Elensúle: https://github.com/Oire | ||
// author : Mikolaj Dadela : https://github.com/mik01aj | ||
|
||
import { LocaleData } from '../locale/locale.class'; | ||
|
||
function processRelativeTime(num: number, withoutSuffix: boolean, key: string, isFuture: boolean): string { | ||
const str = num.toString(); | ||
|
||
const format: any = { | ||
m: ['eine Minute', 'einer Minute'], | ||
h: ['eine Stunde', 'einer Stunde'], | ||
d: ['ein Tag', 'einem Tag'], | ||
dd: [`${str} Tage`, `${str} Tagen`], | ||
M: ['ein Monat', 'einem Monat'], | ||
MM: [`${str} Monate`, `${str} Monaten`], | ||
y: ['ein Jahr', 'einem Jahr'], | ||
yy: [`${str} Jahre`, `${str} Jahren`] | ||
}; | ||
|
||
return withoutSuffix ? format[key][0] : format[key][1]; | ||
} | ||
|
||
export const de: LocaleData = { | ||
abbr: 'de', | ||
months: 'Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'), | ||
monthsShort: 'Jan._Feb._März_Apr._Mai_Juni_Juli_Aug._Sep._Okt._Nov._Dez.'.split('_'), | ||
monthsParseExact: true, | ||
weekdays: 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'), | ||
weekdaysShort: 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'), | ||
weekdaysMin: 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'), | ||
weekdaysParseExact: true, | ||
longDateFormat: { | ||
LT: 'HH:mm', | ||
LTS: 'HH:mm:ss', | ||
L: 'DD.MM.YYYY', | ||
LL: 'D. MMMM YYYY', | ||
LLL: 'D. MMMM YYYY HH:mm', | ||
LLLL: 'dddd, D. MMMM YYYY HH:mm' | ||
}, | ||
calendar: { | ||
sameDay: '[heute um] LT [Uhr]', | ||
sameElse: 'L', | ||
nextDay: '[morgen um] LT [Uhr]', | ||
nextWeek: 'dddd [um] LT [Uhr]', | ||
lastDay: '[gestern um] LT [Uhr]', | ||
lastWeek: '[letzten] dddd [um] LT [Uhr]' | ||
}, | ||
relativeTime: { | ||
future: 'in %s', | ||
past: 'vor %s', | ||
s: 'ein paar Sekunden', | ||
m: processRelativeTime, | ||
mm: '%d Minuten', | ||
h: processRelativeTime, | ||
hh: '%d Stunden', | ||
d: processRelativeTime, | ||
dd: processRelativeTime, | ||
M: processRelativeTime, | ||
MM: processRelativeTime, | ||
y: processRelativeTime, | ||
yy: processRelativeTime | ||
}, | ||
dayOfMonthOrdinalParse: /\d{1,2}\./, | ||
ordinal(num: number, token?: string): string { return `${num}.`; }, | ||
week: { | ||
dow: 1, // Monday is the first day of the week. | ||
doy: 4 // The week that contains Jan 4th is the first week of the year. | ||
} | ||
}; |
Oops, something went wrong.