Fixed #183 - Add maximizable property to Dialog

pull/193/head
mertsincan 2020-02-03 12:08:54 +03:00
parent d41c339c60
commit 768485ffcf
1 changed files with 31 additions and 5 deletions

View File

@ -7,6 +7,9 @@
<span :id="ariaLabelledById" class="p-dialog-title" v-if="header" >{{header}}</span> <span :id="ariaLabelledById" class="p-dialog-title" v-if="header" >{{header}}</span>
</slot> </slot>
<div class="p-dialog-titlebar-icons"> <div class="p-dialog-titlebar-icons">
<button class="p-dialog-titlebar-icon p-dialog-titlebar-maximize p-link" @click="maximize" v-if="maximizable" type="button">
<span :class="maximizeIconClass"></span>
</button>
<button class="p-dialog-titlebar-icon p-dialog-titlebar-close p-link" @click="close" v-if="closable" :aria-label="ariaCloseLabel" type="button"> <button class="p-dialog-titlebar-icon p-dialog-titlebar-close p-link" @click="close" v-if="closable" :aria-label="ariaCloseLabel" type="button">
<span class="p-dialog-titlebar-close-icon pi pi-times"></span> <span class="p-dialog-titlebar-close-icon pi pi-times"></span>
</button> </button>
@ -34,6 +37,7 @@ export default {
modal: Boolean, modal: Boolean,
contentStyle: null, contentStyle: null,
rtl: Boolean, rtl: Boolean,
maximizable: Boolean,
closable: { closable: {
type: Boolean, type: Boolean,
default: true default: true
@ -59,7 +63,8 @@ export default {
return { return {
dialogClasses: null, dialogClasses: null,
dialogStyles: null, dialogStyles: null,
maskVisible: this.visible maskVisible: this.visible,
maximized: false
} }
}, },
documentKeydownListener: null, documentKeydownListener: null,
@ -122,6 +127,18 @@ export default {
this.unbindDocumentKeydownListener(); 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');
}
}
},
onKeyDown(event) { onKeyDown(event) {
if (event.which === 9) { if (event.which === 9) {
event.preventDefault(); event.preventDefault();
@ -189,9 +206,16 @@ export default {
}, },
containerClass() { containerClass() {
return ['p-dialog p-component', { return ['p-dialog p-component', {
'p-dialog-rtl': this.rtl 'p-dialog-rtl': this.rtl,
'p-dialog-maximized': this.maximizable && this.maximized
}, this.dialogClasses]; }, this.dialogClasses];
}, },
maximizeIconClass() {
return ['p-dialog-titlebar-maximize-icon pi', {
'pi-window-maximize': !this.maximized,
'pi-window-minimize': this.maximized
}];
},
containerStyle() { containerStyle() {
return this.dialogStyles; return this.dialogStyles;
}, },
@ -232,6 +256,7 @@ export default {
padding: .5em .75em; padding: .5em .75em;
position: relative; position: relative;
border: 0; border: 0;
flex-shrink: 0;
} }
.p-dialog .p-dialog-content { .p-dialog .p-dialog-content {
position: relative; position: relative;
@ -280,6 +305,7 @@ export default {
.p-dialog-footer { .p-dialog-footer {
padding: 1em; padding: 1em;
text-align: right; text-align: right;
flex-shrink: 0;
} }
/* ConfirmDialog */ /* ConfirmDialog */
.p-confirmdialog { .p-confirmdialog {
@ -331,10 +357,10 @@ export default {
transform: none; transform: none;
width: 100vw !important; width: 100vw !important;
max-height: 100%; max-height: 100%;
margin: auto; height: 100%;
margin: 0;
} }
.p-dialog-maximized .p-dialog-content { .p-dialog-maximized .p-dialog-content {
-webkit-transition: height .3s; flex-grow: 1;
transition: height .3s;
} }
</style> </style>