diff --git a/src/Toaster.php b/src/Toaster.php index 430d4e4..8543d3a 100644 --- a/src/Toaster.php +++ b/src/Toaster.php @@ -31,7 +31,6 @@ class Toaster public function __construct(SessionStore $session) { $this->setDefaultConfig(); - $this->session = $session; } @@ -51,7 +50,22 @@ protected function setDefaultConfig() 'heightAuto' => config('sweetalert.height_auto'), 'padding' => config('sweetalert.padding'), 'showConfirmButton' => config('sweetalert.show_confirm_button'), - 'showCloseButton' => config('sweetalert.show_close_button') + 'showCloseButton' => config('sweetalert.show_close_button'), + 'customClass' => [ + 'container' => config('sweetalert.customClass.container'), + 'popup' => config('sweetalert.customClass.popup'), + 'header' => config('sweetalert.customClass.header'), + 'title' => config('sweetalert.customClass.title'), + 'closeButton' => config('sweetalert.customClass.closeButton'), + 'icon' => config('sweetalert.customClass.icon'), + 'image' => config('sweetalert.customClass.image'), + 'content' => config('sweetalert.customClass.content'), + 'input' => config('sweetalert.customClass.input'), + 'actions' => config('sweetalert.customClass.actions'), + 'confirmButton' => config('sweetalert.customClass.confirmButton'), + 'cancelButton' => config('sweetalert.customClass.cancelButton'), + 'footer' => config('sweetalert.customClass.footer') + ] ]; } @@ -61,14 +75,9 @@ protected function setDefaultConfig() * @return $config * @author Rashid Ali */ - public function middleware() - { - unset($this->config['position']); - unset($this->config['heightAuto']); - unset($this->config['width']); - unset($this->config['padding']); - unset($this->config['showCloseButton']); - unset($this->config['timer']); + public function middleware() + { + unset($this->config['position'], $this->config['heightAuto'], $this->config['width'], $this->config['padding'], $this->config['showCloseButton'], $this->config['timer']); $this->config['position'] = config('sweetalert.middleware.toast_position'); $this->config['showCloseButton'] = config('sweetalert.middleware.toast_close_button'); @@ -77,7 +86,7 @@ public function middleware() $this->flash(); return $this; - } + } /** * Flash an alert message. @@ -125,26 +134,26 @@ public function info($title = '', $text = '') return $this; } - /** - * Display a warning typed alert message with a text and a title. - * - * @param string $title - * @param string $text - * @author Rashid Ali - */ + /** + * Display a warning typed alert message with a text and a title. + * + * @param string $title + * @param string $text + * @author Rashid Ali + */ public function warning($title = '', $text = '') { $this->alert($title, $text, 'warning'); return $this; } - /** - * Display a question typed alert message with a text and a title. - * - * @param string $title - * @param string $text - * @author Rashid Ali - */ + /** + * Display a question typed alert message with a text and a title. + * + * @param string $title + * @param string $text + * @author Rashid Ali + */ public function question($title = '', $text = '') { $this->alert($title, $text, 'question'); @@ -183,9 +192,9 @@ public function image($title = '', $text = '', $imageUrl, $imageWidth = 400, $im $this->config['imageUrl'] = $imageUrl; $this->config['imageWidth'] = $imageWidth; $this->config['imageHeight'] = $imageHeight; - if(!is_null($imageAlt)){ + if (!is_null($imageAlt)) { $this->config['imageAlt'] = $imageAlt; - }else{ + } else { $this->config['imageAlt'] = $title; } $this->config['animation'] = false; @@ -194,14 +203,14 @@ public function image($title = '', $text = '', $imageUrl, $imageWidth = 400, $im return $this; } - /** - * Display a html typed alert message with html code. - * - * @param string $title - * @param string $code - * @param string $icon - * @author Rashid Ali - */ + /** + * Display a html typed alert message with html code. + * + * @param string $title + * @param string $code + * @param string $icon + * @author Rashid Ali + */ public function html($title = '', $code = '', $icon = '') { $this->config['title'] = $title; @@ -245,14 +254,13 @@ public function toToast($position = '') { $this->config['toast'] = true; $this->config['showCloseButton'] = true; - if(!empty($position)){ + if (!empty($position)) { $this->config['position'] = $position; - }else{ + } else { $this->config['position'] = config('sweetalert.toast_position'); } $this->config['showConfirmButton'] = false; - unset($this->config['width']); - unset($this->config['padding']); + unset($this->config['width'], $this->config['padding']); $this->flash(); return $this; @@ -333,13 +341,13 @@ public function width($width = '32rem') return $this; } - /** - * Modal window padding. - * The default padding is 1.25rem. - * - * @param string $padding - * @author Rashid Ali - */ + /** + * Modal window padding. + * The default padding is 1.25rem. + * + * @param string $padding + * @author Rashid Ali + */ public function padding($padding = '1.25rem') { $this->config['padding'] = $padding; @@ -408,7 +416,7 @@ public function focusCancel($focus = false) */ public function animation($showAnimation, $hideAnimation) { - if(!config('sweetalert.animation.enable')){ + if (!config('sweetalert.animation.enable')) { config(['sweetalert.animation.enable' => true]); } $this->config['showClass'] = ['popup' => "animated {$showAnimation}"]; @@ -578,7 +586,6 @@ public function reverseButtons() return $this; } - /** * Remove the timer from config option. * diff --git a/src/config/sweetalert.php b/src/config/sweetalert.php index 92679fa..aeed5cd 100644 --- a/src/config/sweetalert.php +++ b/src/config/sweetalert.php @@ -140,4 +140,29 @@ 'auto_display_error_messages' => env('SWEET_ALERT_AUTO_DISPLAY_ERROR_MESSAGES', false), ], + /* + |-------------------------------------------------------------------------- + | Custom Class + |-------------------------------------------------------------------------- + | A custom CSS class for the modal: + | + */ + + 'customClass' => [ + + 'container' => env('SWEET_ALERT_CONTAINER_CLASS'), + 'popup' => env('SWEET_ALERT_POPUP_CLASS'), + 'header' => env('SWEET_ALERT_HEADER_CLASS'), + 'title' => env('SWEET_ALERT_TITLE_CLASS'), + 'closeButton' => env('SWEET_ALERT_CLOSE_BUTTON_CLASS'), + 'icon' => env('SWEET_ALERT_ICON_CLASS'), + 'image' => env('SWEET_ALERT_IMAGE_CLASS'), + 'content' => env('SWEET_ALERT_CONTENT_CLASS'), + 'input' => env('SWEET_ALERT_INPUT_CLASS'), + 'actions' => env('SWEET_ALERT_ACTIONS_CLASS'), + 'confirmButton' => env('SWEET_ALERT_CONFIRM_BUTTON_CLASS'), + 'cancelButton' => env('SWEET_ALERT_CANCEL_BUTTON_CLASS'), + 'footer' => env('SWEET_ALERT_FOOTER_CLASS'), + ], + ];