diff --git a/protected/humhub/widgets/Modal.php b/protected/humhub/widgets/Modal.php index a6c284d7a1..422848df0d 100644 --- a/protected/humhub/widgets/Modal.php +++ b/protected/humhub/widgets/Modal.php @@ -67,6 +67,14 @@ class Modal extends JsWidget */ public $showClose; + /** + * If set to false $backdrop and §keyboard will be set to false automaticly, so + * the modal is only closable by buttons. + * + * @var bool + */ + public $closable = true; + /** * Defines if a click on the modal background should close the modal * @var boolean @@ -128,11 +136,11 @@ class Modal extends JsWidget { $result = []; - if(!$this->backdrop) { + if(!$this->closable || !$this->backdrop) { $result['backdrop'] = 'static'; } - if(!$this->keyboard) { + if(!$this->closable || !$this->keyboard) { $result['keyboard'] = 'false'; } diff --git a/protected/humhub/widgets/ModalDialog.php b/protected/humhub/widgets/ModalDialog.php index b82be33f84..c03efbc142 100644 --- a/protected/humhub/widgets/ModalDialog.php +++ b/protected/humhub/widgets/ModalDialog.php @@ -11,6 +11,8 @@ class ModalDialog extends Modal public $dialogContent; + private $dialogClass; + /** * @inheritdoc */ @@ -34,31 +36,45 @@ class ModalDialog extends Modal //The x close button is rendered by default either if forced by showClose or a headertext is given $showClose = ($this->showClose != null) ? $this->showClose : ($this->header != null); - - $dialogClass = 'modal-dialog'; - $dialogClass .= ($this->size != null) ? ' modal-dialog-'.$this->size : ''; - $dialogClass .= ($this->animation != null) ? ' animated '.$this->animation : ''; - + $bodyClass = 'modal-body'; $bodyClass .= ($this->centerText) ? ' text-center' : ''; $this->initialLoader = ($this->initialLoader ==! null) ? $this->initialLoader : ($this->body === null); $modalData = ''; - $modalData .= !$this->backdrop ? 'data-backdrop="static"' : ''; - $modalData .= !$this->keyboard ? 'data-keyboard="false"' : ''; + $modalData .= !$this->closable || !$this->backdrop ? 'data-backdrop="static"' : ''; + $modalData .= !$this->closable || !$this->keyboard ? 'data-keyboard="false"' : ''; $modalData .= $this->show ? 'data-show="true"' : ''; return $this->render('modalDialog', [ 'header' => $this->header, + 'options' => $this->getOptions(), 'dialogContent' => $this->dialogContent, 'body' => $this->body, 'bodyClass' => $bodyClass, 'footer' => $this->footer, - 'dialogClass' => $dialogClass, 'initialLoader' => $this->initialLoader, 'showClose' => $showClose ]); } + public function getAttributes() + { + $dialogClass = 'modal-dialog'; + $dialogClass .= ($this->size != null) ? ' modal-dialog-'.$this->size : ''; + $dialogClass .= ($this->animation != null) ? ' animated '.$this->animation : ''; + + return [ + 'class' => $dialogClass + ]; + } + public function getData() + { + return [ + 'backdrop' => (!$this->closable || $this->backdrop === false) ? "static" : $this->backdrop, + 'keyboard' => (!$this->closable || !$this->keyboard) ? "false" : 'true', + ]; + } + } diff --git a/static/js/humhub/humhub.ui.modal.js b/static/js/humhub/humhub.ui.modal.js index 87cc2d8ba8..081edbfc70 100644 --- a/static/js/humhub/humhub.ui.modal.js +++ b/static/js/humhub/humhub.ui.modal.js @@ -428,9 +428,20 @@ humhub.module('ui.modal', function (module, require, $) { this.applyAdditions(); this.$.find('input[type="text"]:visible, textarea:visible, [contenteditable="true"]:visible').first().focus(); this.checkAriaLabel(); + this.updateDialogOptions(); return this; }; + Modal.prototype.updateDialogOptions = function() { + var test = this.getDialog(); + var test2 = this.getDialog().data('backdrop'); + var test3 = this.getDialog().data('keyboard'); + this.set({ + backdrop : this.getDialog().data('backdrop'), + keyboard : this.getDialog().data('keyboard') + }); + }; + /** * Retrieves the modal-body element * @returns {humhub.ui.modal_L18.Modal.prototype@pro;$modal@call;find}