Skip to content

Commit 940d1ca

Browse files
authored
Merge pull request #600 from gselderslaghs/datepicker-docked-plugin-implementation
feature(Datepicker) docked plugin implementation
2 parents 9bf221d + 4a64bef commit 940d1ca

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/datepicker.ts

+17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Utils } from './utils';
22
import { FormSelect } from './select';
33
import { BaseOptions, Component, I18nOptions, InitElements, MElement } from './component';
4+
import { DockedDisplayPlugin } from './plugin/dockedDisplayPlugin';
45

56
export interface DateI18nOptions extends I18nOptions {
67
previousMonth: string;
@@ -184,6 +185,14 @@ export interface DatepickerOptions extends BaseOptions {
184185
startRange?: Date;
185186
/** Field used for internal calculations DO NOT CHANGE IT */
186187
endRange?: Date;
188+
/**
189+
* Display plugin
190+
*/
191+
displayPlugin: string;
192+
/**
193+
* Configurable display plugin options
194+
*/
195+
displayPluginOptions: object;
187196
}
188197

189198
const _defaults: DatepickerOptions = {
@@ -281,6 +290,8 @@ const _defaults: DatepickerOptions = {
281290
onSelect: null,
282291
onDraw: null,
283292
onInputInteraction: null,
293+
displayPlugin: null,
294+
displayPluginOptions: null,
284295
onConfirm: null,
285296
onCancel: null,
286297
};
@@ -310,6 +321,7 @@ export class Datepicker extends Component<DatepickerOptions> {
310321
calendars: [{ month: number; year: number }];
311322
private _y: number;
312323
private _m: number;
324+
private displayPlugin: DockedDisplayPlugin;
313325
private footer: HTMLElement;
314326
static _template: string;
315327

@@ -368,6 +380,9 @@ export class Datepicker extends Component<DatepickerOptions> {
368380
this.dateEls = [];
369381
this.dateEls.push(el);
370382
}
383+
if (this.options.displayPlugin) {
384+
if (this.options.displayPlugin === 'docked') this.displayPlugin = DockedDisplayPlugin.init(this.el, this.containerEl, this.options.displayPluginOptions);
385+
}
371386
}
372387

373388
static get defaults() {
@@ -1191,6 +1206,7 @@ export class Datepicker extends Component<DatepickerOptions> {
11911206
this.setDateFromInput(e.target as HTMLInputElement);
11921207
this.draw();
11931208
this.gotoDate(<HTMLElement>e.target === this.el ? this.date : this.endDate);
1209+
if (this.displayPlugin) this.displayPlugin.show();
11941210
if (this.options.onInputInteraction) this.options.onInputInteraction.call(this);
11951211
};
11961212

@@ -1199,6 +1215,7 @@ export class Datepicker extends Component<DatepickerOptions> {
11991215
e.preventDefault();
12001216
this.setDateFromInput(e.target as HTMLInputElement);
12011217
this.draw();
1218+
if (this.displayPlugin) this.displayPlugin.show();
12021219
if (this.options.onInputInteraction) this.options.onInputInteraction.call(this);
12031220
}
12041221
};

0 commit comments

Comments
 (0)