Fixed #224 for Calendar

pull/227/head
cagataycivici 2020-03-04 14:32:15 +03:00
parent 16a3423174
commit e8c6eb324e
3 changed files with 33 additions and 1 deletions

View File

@ -53,6 +53,7 @@ export declare class Calendar extends Vue {
manualInput?: boolean;
locale?: LocaleSettings;
ariaLabelledBy?: string;
appendTo?: string;
$emit(eventName: 'show'): this;
$emit(eventName: 'hide'): this;
$emit(eventName: 'month-change', e: { month: number, year: number }): this;

View File

@ -316,6 +316,10 @@ export default {
ariaLabelledBy: {
type: String,
default: null
},
appendTo: {
type: String,
default: null
}
},
oldViewDate: null,
@ -344,6 +348,7 @@ export default {
this.mask = null;
}
this.restoreAppend();
this.unbindOutsideClickListener();
},
data() {
@ -530,6 +535,7 @@ export default {
if (this.autoZIndex) {
this.$refs.overlay.style.zIndex = String(this.baseZIndex + DomHandler.generateZIndex());
}
this.appendContainer();
this.alignOverlay();
this.$emit('show');
},
@ -648,7 +654,10 @@ export default {
this.enableModality();
}
else if (this.$refs.overlay) {
DomHandler.relativePosition(this.$refs.overlay, this.$el);
if (this.appendTo)
DomHandler.absolutePosition(this.$refs.overlay, this.$el);
else
DomHandler.relativePosition(this.$refs.overlay, this.$el);
}
},
onButtonClick() {
@ -1867,6 +1876,22 @@ export default {
//Noop
break;
}
},
appendContainer() {
if (this.appendTo) {
if (this.appendTo === 'body')
document.body.appendChild(this.$refs.overlay);
else
document.getElementById(this.appendTo).appendChild(this.$refs.overlay);
}
},
restoreAppend() {
if (this.$refs.overlay && this.appendTo) {
if (this.appendTo === 'body')
document.body.removeChild(this.$refs.overlay);
else
document.getElementById(this.appendTo).removeChild(this.$refs.overlay);
}
}
},
computed: {

View File

@ -407,6 +407,12 @@ export default {
<td>null</td>
<td>Establishes relationships between the component and label(s) where its value should be one or more element IDs.</td>
</tr>
<tr>
<td>appendTo</td>
<td>string</td>
<td>null</td>
<td>Id of the element or "body" for document where the overlay should be appended to.</td>
</tr>
</tbody>
</table>
</div>