From 3833c12ccce59bcc49c4cfa892401973558f604d Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Mon, 2 Jan 2017 17:01:27 -0500 Subject: Refactoring/rewrite of modal boxes handling --- app/Helper/ModalHelper.php | 73 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 app/Helper/ModalHelper.php (limited to 'app/Helper/ModalHelper.php') diff --git a/app/Helper/ModalHelper.php b/app/Helper/ModalHelper.php new file mode 100644 index 00000000..e6037a8c --- /dev/null +++ b/app/Helper/ModalHelper.php @@ -0,0 +1,73 @@ +helper->app->component('submit-buttons', array( + 'submitLabel' => isset($params['submitLabel']) ? $params['submitLabel'] : t('Save'), + 'orLabel' => t('or'), + 'cancelLabel' => t('cancel'), + 'color' => isset($params['color']) ? $params['color'] : 'blue', + 'tabindex' => isset($params['tabindex']) ? $params['tabindex'] : null, + 'disabled' => isset($params['disabled']) ? true : false, + )); + } + + public function confirmButtons($controller, $action, array $params = array(), $submitLabel = '', $tabindex = null) + { + return $this->helper->app->component('confirm-buttons', array( + 'url' => $this->helper->url->href($controller, $action, $params, true), + 'submitLabel' => $submitLabel ?: t('Yes'), + 'orLabel' => t('or'), + 'cancelLabel' => t('cancel'), + 'tabindex' => $tabindex, + )); + } + + public function largeIcon($icon, $label, $controller, $action, array $params = array()) + { + $html = ''; + return $this->helper->url->link($html, $controller, $action, $params, false, 'js-modal-large', $label); + } + + public function large($icon, $label, $controller, $action, array $params = array()) + { + $html = ' '.$label; + return $this->helper->url->link($html, $controller, $action, $params, false, 'js-modal-large'); + } + + public function medium($icon, $label, $controller, $action, array $params = array()) + { + $html = ' '.$label; + return $this->helper->url->link($html, $controller, $action, $params, false, 'js-modal-medium'); + } + + public function small($icon, $label, $controller, $action, array $params = array()) + { + $html = ' '.$label; + return $this->helper->url->link($html, $controller, $action, $params, false, 'js-modal-small'); + } + + public function mediumButton($icon, $label, $controller, $action, array $params = array()) + { + $html = ' '.$label; + return $this->helper->url->link($html, $controller, $action, $params, false, 'js-modal-medium btn'); + } + + public function confirm($icon, $label, $controller, $action, array $params = array()) + { + $html = ' '.$label; + return $this->helper->url->link($html, $controller, $action, $params, false, 'js-modal-confirm'); + } +} -- cgit v1.2.3