-
-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
80 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]> | ||
*/ | ||
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 <[email protected]> | ||
*/ | ||
/** | ||
* Display a warning typed alert message with a text and a title. | ||
* | ||
* @param string $title | ||
* @param string $text | ||
* @author Rashid Ali <[email protected]> | ||
*/ | ||
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 <[email protected]> | ||
*/ | ||
/** | ||
* Display a question typed alert message with a text and a title. | ||
* | ||
* @param string $title | ||
* @param string $text | ||
* @author Rashid Ali <[email protected]> | ||
*/ | ||
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 <[email protected]> | ||
*/ | ||
/** | ||
* Display a html typed alert message with html code. | ||
* | ||
* @param string $title | ||
* @param string $code | ||
* @param string $icon | ||
* @author Rashid Ali <[email protected]> | ||
*/ | ||
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 <[email protected]> | ||
*/ | ||
/** | ||
* Modal window padding. | ||
* The default padding is 1.25rem. | ||
* | ||
* @param string $padding | ||
* @author Rashid Ali <[email protected]> | ||
*/ | ||
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. | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters