Skip to content

EspoCRM – Open Source CRM Application

full screen image modal

Yuri Kuznetsovddee6815af79
diff --git a/client/src/ui.js b/client/src/ui.js
index 292b3c73a9..12fef1c1a3 100644
--- a/client/src/ui.js
+++ b/client/src/ui.js
@@ -57,6 +57,9 @@ import $ from 'jquery';
* @property {boolean} [fullHeight] Deprecated.
* @property {Number} [bodyDiffHeight]
* @property {Number} [screenWidthXs]
+ * @property {boolean} [maximizeButton] Is maximizable.
+ * @property {function()} [onMaximize] On maximize handler.
+ * @property {function()} [onMinimize] On minimize handler.
*/
/**
@@ -90,6 +93,37 @@ class Dialog {
buttons
screenWidthXs
+ /**
+ * @private
+ * @type {boolean}
+ */
+ maximizeButton = false
+
+ /**
+ * @private
+ * @type {HTMLAnchorElement}
+ */
+ maximizeButtonElement
+
+ /**
+ * @private
+ * @type {HTMLAnchorElement}
+ */
+ minimizeButtonElement
+
+ /**
+ * @private
+ * @type {function()}
+ */
+ onMaximize
+
+ /**
+ * @private
+ * @type {function()}
+ */
+ onMinimize
+
+
/**
* @param {module:ui.Dialog~Params} options Options.
*/
@@ -153,6 +187,7 @@ class Dialog {
'onRemove',
'onClose',
'onBackdropClick',
+ 'maximizeButton',
];
params.forEach(param => {
@@ -353,6 +388,32 @@ class Dialog {
}
}
+ /**
+ * Hide maximize button.
+ *
+ * @since 9.1.0
+ */
+ hideMaximizeButton() {
+ if (!this.maximizeButtonElement) {
+ return;
+ }
+
+ this.maximizeButtonElement.classList.add('hidden');
+ }
+
+ /**
+ * Show maximize button.
+ *
+ * @since 9.1.0
+ */
+ showMaximizeButton() {
+ if (!this.maximizeButtonElement) {
+ return;
+ }
+
+ this.maximizeButtonElement.classList.remove('hidden');
+ }
+
/**
* Set action items.
*
@@ -426,6 +487,62 @@ class Dialog {
);
}
+ if (this.maximizeButton) {
+ {
+ const a = document.createElement('a');
+ a.classList.add('maximize-button');
+ a.role = 'button';
+ a.tabIndex = -1;
+ a.setAttribute('data-action', 'maximizeModal');
+
+ const icon = document.createElement('span');
+ icon.classList.add('far', 'fa-window-maximize')
+
+ a.append(icon);
+ $header.prepend(a);
+
+ this.maximizeButtonElement = a;
+
+ a.addEventListener('click', () => {
+ if (this.onMaximize) {
+ this.onMaximize();
+ }
+
+ this.maximizeButtonElement.classList.add('hidden');
+ this.minimizeButtonElement.classList.remove('hidden');
+
+ this.el.querySelector('.modal-dialog').classList.add('maximized');
+ });
+ }
+
+ {
+ const a = document.createElement('a');
+ a.classList.add('minimize-button', 'hidden');
+ a.role = 'button';
+ a.tabIndex = -1;
+ a.setAttribute('data-action', 'minimizeModal');
+
+ const icon = document.createElement('span');
+ icon.classList.add('far', 'fa-window-minimize')
+
+ a.append(icon);
+ $header.prepend(a);
+
+ this.minimizeButtonElement = a;
+
+ a.addEventListener('click', () => {
+ if (this.onMinimize) {
+ this.onMinimize();
+ }
+
+ this.minimizeButtonElement.classList.add('hidden');
+ this.maximizeButtonElement.classList.remove('hidden');
+
+ this.el.querySelector('.modal-dialog').classList.remove('maximized');
+ });
+ }
+ }
+
if (this.closeButton) {
$header.prepend(
$('<a>')
diff --git a/client/src/views/modal.js b/client/src/views/modal.js
index 96a95b5a6e..a257d3f967 100644
--- a/client/src/views/modal.js
+++ b/client/src/views/modal.js
@@ -233,6 +233,15 @@ class ModalView extends View {
*/
isCollapsable = false
+ /**
+ * Is maximizable.
+ *
+ * @protected
+ * @type {boolean}
+ * @since 9.1.0
+ */
+ isMaximizable = false
+
/**
* Is collapsed. Do not change value. Only for reading.
*
@@ -255,10 +264,6 @@ class ModalView extends View {
'click .action': function (e) {
Espo.Utils.handleAction(this, e.originalEvent, e.currentTarget);
},
- /** @this module:views/modal */
- 'click [data-action="collapseModal"]': function () {
- this.collapse();
- },
}
/**
@@ -369,6 +374,7 @@ class ModalView extends View {
fixedHeaderHeight: this.fixedHeaderHeight,
closeButton: !this.noCloseButton,
collapseButton: this.isCollapsable,
+ maximizeButton: this.isMaximizable && !this.getHelper().isXsScreen(),
onRemove: () => this.onDialogClose(),
onBackdropClick: () => this.onBackdropClick(),
});
@@ -413,6 +419,10 @@ class ModalView extends View {
$(this.containerSelector).remove();
});
+
+ if (this.isCollapsable) {
+ this.addActionHandler('collapseModal', () => this.collapse());
+ }
}
setupFinal() {
diff --git a/client/src/views/modals/image-preview.js b/client/src/views/modals/image-preview.js
index 2596eeb104..8ddcf260d3 100644
--- a/client/src/views/modals/image-preview.js
+++ b/client/src/views/modals/image-preview.js
@@ -37,6 +37,7 @@ class ImagePreviewModalView extends ModalView {
cssName = 'image-preview'
size = ''
backdrop = true
+ isMaximizable = true
transformClassList = [
'transform-flip',
diff --git a/frontend/less/espo/elements/modal.less b/frontend/less/espo/elements/modal.less
index 4c1e4c1c2d..a6fb4404b0 100644
--- a/frontend/less/espo/elements/modal.less
+++ b/frontend/less/espo/elements/modal.less
@@ -77,12 +77,14 @@
}
}
- .collapse-button {
- float: right;
+ .collapse-button,
+ .maximize-button,
+ .minimize-button {
+ position: relative;
+
padding-right: var(--17px);
padding-left: var(--17px);
- top: var(--3px);
- position: relative;
+ float: right;
&,
> .fas,
@@ -98,6 +100,17 @@
}
}
}
+
+ .maximize-button,
+ .minimize-button {
+ top: var(--2px);
+ left: var(--minus-3px);
+ }
+
+ .collapse-button {
+ top: var(--3px);
+ left: var(--minus-3px);
+ }
}
.modal-footer {
@@ -230,6 +243,12 @@
}
}
+@media screen and (min-width: @screen-sm-min) {
+ .modal-dialog.maximized {
+ width: 100vw;
+ }
+}
+
.dialog-confirm,
.dialog-centered {
> .modal-dialog > .modal-content {