Skip to content

Commit 6344b38

Browse files
committed
fixing 359
1 parent 3bd7160 commit 6344b38

File tree

8 files changed

+31
-146
lines changed

8 files changed

+31
-146
lines changed

CHANGELOG.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4-
<a name="2.7.4"></a>
5-
# [2.7.4] (???)
4+
<a name="2.7.5"></a>
5+
# [2.7.5] (???)
66
### Bug Fixes
7-
- Fixing disabled dates when selecting past/future time from current day ([18db1ca](https://github.com/vlio20/angular-datepicker/commit/18db1ca)) closes [#340](https://github.com/vlio20/angular-datepicker/issues/340)
7+
- Fixing `inputElementContainer` which did not work on directive + added to docs ([???](https://github.com/vlio20/angular-datepicker/commit/???)) closes [#359](https://github.com/vlio20/angular-datepicker/issues/359)
8+
- Fixing Not able to bind to moment, getting TypeError: `(value || "").split is not a function` ([19cee2d](https://github.com/vlio20/angular-datepicker/commit/19cee2d)) closes [#355](https://github.com/vlio20/angular-datepicker/issues/355)
89

9-
<a name="2.7.3"></a>
10-
# [2.7.3] (2018-01-13)
10+
<a name="2.7.4"></a>
11+
# [2.7.4] (2018-01-13)
12+
- Fixing disabled dates when selecting past/future time from current day ([18db1ca](https://github.com/vlio20/angular-datepicker/commit/18db1ca)) closes [#340](https://github.com/vlio20/angular-datepicker/issues/340)
1113

1214
### Features
1315
- Navigation events are now dispatched from all relevant components ([2552889](https://github.com/vlio20/angular-datepicker/commit/2552889)) closes [#329](https://github.com/vlio20/angular-datepicker/issues/329)

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ Here are the available configurations:
122122
| multipleYearsNavigateBy | `number` | `10` | `day\|month\|daytime` | Number of years to navigate when showMultipleYearsNavigation is `true` |
123123
| returnedValueType | `ECalendarValue` | `Moment` | All | The returned value type (`Moment`, `Moment[]`, `string`, `string[]` |
124124
| unSelectOnClick | `boolean` | true | `day\|month` | Will allow disallow/unselect to selected date by clicking on the selected date |
125+
| inputElementContainer | `string\|HTMLElement` | `undefined` | ALL | Will place picker popup relative to the provided elemenr (if string provided will used as a selector) |
125126

126127
### API:
127128
In order to use the date-picker api user the `@ViewChild` annotation in the date-picker containing component class, take at the example below:

build-helpers/index-maker.js

-18
This file was deleted.

build-helpers/inliner.js

-118
This file was deleted.

src/app/common/services/utils/utils.service.ts

+10
Original file line numberDiff line numberDiff line change
@@ -328,4 +328,14 @@ export class UtilsService {
328328

329329
return false;
330330
}
331+
332+
getNativeElement(elem: HTMLElement | string): HTMLElement {
333+
if (!elem) {
334+
return null;
335+
} else if (typeof elem === 'string') {
336+
return <HTMLElement>document.querySelector(elem);
337+
} else {
338+
return elem;
339+
}
340+
}
331341
}

src/app/date-picker/date-picker-config.model.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface IConfig {
1111
onOpenDelay?: number;
1212
disableKeypress?: boolean;
1313
appendTo?: string | HTMLElement;
14-
inputElementContainer?: HTMLElement;
14+
inputElementContainer?: HTMLElement | string;
1515
drops?: TDrops;
1616
opens?: TOpens;
1717
hideInputContainer?: boolean;

src/app/date-picker/date-picker-directive.service.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,18 @@ export class DatePickerDirectiveService {
2323
const _config: IDatePickerDirectiveConfig = {...config};
2424
_config.hideInputContainer = true;
2525

26-
if (baseElement) {
26+
let native;
27+
28+
if (config.inputElementContainer) {
29+
native = this.utilsService.getNativeElement(config.inputElementContainer);
30+
} else {
31+
native = baseElement ? baseElement.nativeElement : null;
32+
}
33+
34+
if (native) {
2735
_config.inputElementContainer = attachTo
28-
? this.convertToHTMLElement(attachTo, baseElement.nativeElement)
29-
: baseElement.nativeElement;
36+
? this.convertToHTMLElement(attachTo, native)
37+
: native;
3038
}
3139

3240
return _config;

src/app/date-picker/date-picker.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ export class DatePickerComponent implements OnChanges,
335335
}
336336

337337
setInputElementContainer() {
338-
this.inputElementContainer = this.componentConfig.inputElementContainer
338+
this.inputElementContainer = this.utilsService.getNativeElement(this.componentConfig.inputElementContainer)
339339
|| this.elemRef.nativeElement.querySelector('.dp-input-container')
340340
|| document.body;
341341
}

0 commit comments

Comments
 (0)