Skip to content

Commit

Permalink
Refactor #183
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Feb 3, 2020
1 parent d223975 commit 8447b38
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions src/components/dialog/Dialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default {
this.removeStylesFromMask();
},
beforeDestroy() {
this.disableModality();
this.disableDocumentSettings();
},
methods: {
close() {
Expand All @@ -95,14 +95,14 @@ export default {
this.$emit('show');
this.focus();
this.enableModality();
this.enableDocumentSettings();
},
onLeave() {
this.$emit('hide');
},
onAfterLeave() {
this.maskVisible = false;
this.disableModality();
this.disableDocumentSettings();
},
onAppear() {
if (this.visible) {
Expand All @@ -115,28 +115,32 @@ export default {
focusable.focus();
}
},
enableModality() {
maximize() {
this.maximized = !this.maximized;
if (!this.modal) {
if (this.maximized)
DomHandler.addClass(document.body, 'p-overflow-hidden');
else
DomHandler.removeClass(document.body, 'p-overflow-hidden');
}
},
enableDocumentSettings() {
if (this.modal) {
DomHandler.addClass(document.body, 'p-overflow-hidden');
this.bindDocumentKeydownListener();
}
else if (this.maximizable && this.maximized) {
DomHandler.addClass(document.body, 'p-overflow-hidden');
}
},
disableModality() {
disableDocumentSettings() {
if (this.modal) {
DomHandler.removeClass(document.body, 'p-overflow-hidden');
this.unbindDocumentKeydownListener();
}
},
maximize() {
this.maximized = !this.maximized;
if (!this.modal) {
if (this.maximized) {
DomHandler.addClass(document.body, 'p-overflow-hidden');
}
else {
DomHandler.removeClass(document.body, 'p-overflow-hidden');
}
else if (this.maximizable && this.maximized) {
DomHandler.removeClass(document.body, 'p-overflow-hidden');
}
},
onKeyDown(event) {
Expand Down

0 comments on commit 8447b38

Please sign in to comment.