From 06e89615c597299c70afe0bf3785ede4fb2f3be4 Mon Sep 17 00:00:00 2001 From: Rashid Ali Date: Fri, 14 Jun 2019 17:04:06 +0500 Subject: [PATCH] Updated to v2.0 --- docs/README.md | 34 +++++-------- docs/_coverpage.md | 10 ++-- docs/_sidebar.md | 19 +++++--- docs/carbonad.js | 42 ++++++++++++++++ docs/changelog.md | 59 +++++++++++++++++++++++ docs/codefund.js | 16 +++---- docs/config.md | 44 ++++++++--------- docs/configuration.md | 41 ---------------- docs/credits.md | 2 +- docs/demo.md | 12 +++-- docs/environment.md | 108 ++++++++++++++++++++++++++++++++++++++++++ docs/helpers.md | 80 ++++++++++++++++++++++++++++++- docs/index.html | 85 ++++++++++++++++++++++++++++----- docs/install.md | 30 ++++++++++-- docs/middleware.md | 55 ++++++++++++++------- docs/sw.js | 11 +++-- docs/tutorial.md | 19 ++++++++ docs/usage.md | 6 ++- 18 files changed, 521 insertions(+), 152 deletions(-) create mode 100644 docs/carbonad.js create mode 100644 docs/changelog.md delete mode 100644 docs/configuration.md create mode 100644 docs/environment.md create mode 100644 docs/tutorial.md diff --git a/docs/README.md b/docs/README.md index cd61676..80c7af8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,3 +1,15 @@ +

+ + SweetAlert2 + +

+

+A BEAUTIFUL, RESPONSIVE, CUSTOMIZABLE, ACCESSIBLE (WAI-ARIA) REPLACEMENT FOR JAVASCRIPT'S POPUP BOXES FOR LARAVEL +

+

+ +

+

Total Downloads Latest Stable Version @@ -7,24 +19,4 @@ License

-# Introduction - -A BEAUTIFUL, RESPONSIVE, CUSTOMIZABLE, ACCESSIBLE (WAI-ARIA) REPLACEMENT FOR JAVASCRIPT'S POPUP BOXES FOR LARAVEL - -

- -

- -## Backers - -Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/sweet-alert#backer)] - - - -## Sponsors - -Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/sweet-alert#sponsor)] - - - -> note: if you are using sweet-alert v1.0 you can get README for v1.0 from [here](https://github.com/realrashid/sweet-alert/blob/1.0/readme.md) +!> note: if you are using sweet-alert v1.0 you can get README for v1.0 from [here](https://github.com/realrashid/sweet-alert/blob/1.0/readme.md) diff --git a/docs/_coverpage.md b/docs/_coverpage.md index 866703f..487ec17 100644 --- a/docs/_coverpage.md +++ b/docs/_coverpage.md @@ -1,10 +1,12 @@ -

sweet-alert 1.1.2

+![logo](https://sweetalert2.github.io/images/swal2-logo.png) +

sweet-alert 2.0.0

By Rashid Ali

-> A BEAUTIFUL, RESPONSIVE, CUSTOMIZABLE, -ZERO DEPENDENCIES +

+A BEAUTIFUL, RESPONSIVE, CUSTOMIZABLE, ACCESSIBLE (WAI-ARIA) REPLACEMENT FOR JAVASCRIPT'S POPUP BOXES FOR LARAVEL +

[GitHub](https://github.com/realrashid/sweet-alert) -[Get Started](/README) +[Get Started](/readme) diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 08d607f..15bf22d 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -1,10 +1,15 @@ * Getting started - * [Installation](sweet-alert/install.md) - * [Configuration](sweet-alert/config.md) - * [Usage](sweet-alert/usage?id=usage) - * [Helpers](sweet-alert/helpers?id=helpers) - * [Middleware](sweet-alert/middleware?id=middleware) - * [Demo](sweet-alert/demo) + * [Installation](install.md) + * [Configuration](config.md) + * [Environment Variables](environment.md) + * [Usage](usage?id=usage) + * [Middleware](middleware?id=middleware) + * [Helpers](helpers?id=helpers) + * [Demo](demo) + * [Changelog](changelog) -* [Credits](sweet-alert/credits.md) +* Video Tutorial + * [Tutorial](tutorial.md) +* Credits + * [Credits](credits.md) diff --git a/docs/carbonad.js b/docs/carbonad.js new file mode 100644 index 0000000..d5fd3a3 --- /dev/null +++ b/docs/carbonad.js @@ -0,0 +1,42 @@ +;(function(window) { + window.Carbon = { + scriptEl: null, + create: function() { + return function(hook, vm) { + hook.ready(function() { + window.Carbon.injectCarbonStyle(); + }) + + hook.doneEach(function () { + window.Carbon.injectCarbonContainer(); + }) + } + }, + + injectCarbonContainer() { + let nav = document.getElementsByClassName('sidebar-nav') + let carbonContainer = document.createElement('script') + carbonContainer.src = '//cdn.carbonads.com/carbon.js?serve=CK7ICKQI&placement=realrashidgithubio' + carbonContainer.id = '_carbonads_js' + nav[0].insertBefore(carbonContainer, nav[0].firstChild) + + if (document.getElementsByClassName('carbonads').length === 0) { + window._carbon && window._carbon.serve(); + } + }, + + injectCarbonStyle() { + var carbonCss = document.createElement('style'); + window.Carbon.injectCarbonContainer(); + var css = '#carbonads{font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", Helvetica, Arial,sans-serif}#carbonads{display: flex;max-width: 330px;background-color: hsl(0, 0%, 98%);box-shadow: 0 1px 4px 1px hsla(0, 0%, 0%, 0.1)}#carbonads a{color: inherit;text-decoration: none}#carbonads a:hover{color: inherit}#carbonads span{position: relative;display: block;overflow: hidden}#carbonads .carbon-wrap{display: flex}.carbon-img{display: block;margin: 0;line-height: 1}.carbon-img img{display: block}.carbon-text{font-size: 13px;padding: 10px;line-height: 1.5;text-align: left}.carbon-poweredby{display: block;padding: 8px 10px;background: repeating-linear-gradient(-45deg,transparent,transparent 5px,hsla(0, 0%, 0%, 0.025) 5px,hsla(0, 0%, 0%, 0.025) 10px)hsla(203, 11%, 95%, 0.4);text-align: center;text-transform: uppercase;letter-spacing: 0.5px;font-weight: 600;font-size: 9px;line-height: 1}'; + + carbonCss.type = 'text/css'; + if (carbonCss.styleSheet){ + carbonCss.styleSheet.cssText = css; + } else { + carbonCss.appendChild(document.createTextNode(css)); + } + document.head.appendChild(carbonCss); + } + } + })(window) diff --git a/docs/changelog.md b/docs/changelog.md new file mode 100644 index 0000000..c4d67e5 --- /dev/null +++ b/docs/changelog.md @@ -0,0 +1,59 @@ +# Changelog + +All notable changes to `sweet-alert` will be documented in this file. + +## v2.0 - 2019-06-14 +- Upgraded SweetAlert2 to latest version +- Added width() helper method +- Added padding() helper method +- Added background() helper method +- Added animation() helper method +- Added focusConfirm() helper method +- Added focusCancel() helper method +- Added CDN Support +- Docs Updated +- Fix some bugs + +Changes +```php +// From +public function toast($title = '', $type = '', $position = 'bottom-right'){...} +// To +public function toast($title = '', $type = ''){...} + +// set the default position in package config file or use the helper method position() +``` + +## v1.1.2 - 2019-03-29 +- Upgraded SweetAlert2 to latest version +- Added hideCloseButton() helper method +- Added reverseButtons() helper method +- Added image() method +- Added addImage() helper method +- Added position() helper method +- Docs Updated +- Fix some bugs + +## v1.1.1 - 2018-03-25 +Added some new methods +- `alert() method` +- `alert()->success() method` +- `alert()->info() method` +- `alert()->wanring() method` +- `alert()->question() method` +- `alert()->error() method` +- `alert()->html() method` +- `toast() method` +- `showConfirmButton() helper method` +- `showCloseButton() helper method` +- `showCancelButton() helper method` +- `persistent() helper method` +- `autoClose() helper method` +- `toToast() helper method` +- `footer() helper method` + +## v1.0 - 2018-03-25 +- Deprecated + +## v1.0 - 2017-09-02 +- initial release diff --git a/docs/codefund.js b/docs/codefund.js index c676bd5..152c7f0 100644 --- a/docs/codefund.js +++ b/docs/codefund.js @@ -1,15 +1,15 @@ ;(function(window) { - window.DocsifyCodefund = { + window.Codefund = { scriptEl: null, create: function(codefundId) { return function(hook, vm) { hook.ready(function() { - window.DocsifyCodefund.injectCodeFundStyle(); + window.Codefund.injectCodeFundStyle(); }) hook.doneEach(function () { - window.DocsifyCodefund.injectCodeFundScript(codefundId); - window.DocsifyCodefund.injectCodeFundContainer(); + window.Codefund.injectCodeFundScript(codefundId); + window.Codefund.injectCodeFundContainer(); }) } }, @@ -26,20 +26,20 @@ }, injectCodeFundScript(codefundId) { - if (window.DocsifyCodefund.scriptEl) { - window.DocsifyCodefund.scriptEl.remove() + if (window.Codefund.scriptEl) { + window.Codefund.scriptEl.remove() } var script = document.createElement('script') script.src = "https://codefund.app/properties/" + codefundId + "/funder.js" script.async = "async" document.body.appendChild(script) - window.DocsifyCodefund.scriptEl = script + window.Codefund.scriptEl = script }, injectCodeFundStyle() { var style = document.createElement('style'); - window.DocsifyCodefund.injectCodeFundContainer(); + window.Codefund.injectCodeFundContainer(); var css = '#cf span.cf-wrapper { background-color: transparent!important } #cf a.cf-text { color: #444!important; font-weight: 400!important; font-size: 10px!important }'; style.type = 'text/css'; diff --git a/docs/config.md b/docs/config.md index ec38164..0b4f632 100644 --- a/docs/config.md +++ b/docs/config.md @@ -1,41 +1,35 @@ # Configuration -> Optional in Laravel 5.5 or above +### Include SweetAlert 2 View -After installing the sweet-alert package, register the +in your master layout ```php -RealRashid\SweetAlert\SweetAlertServiceProvider::class +@include('sweetalert::alert') ``` -in your `config/app.php` configuration file: -```php -'providers' => [ - // Other service providers... +and run the below command to publish the package assets. - RealRashid\SweetAlert\SweetAlertServiceProvider::class, -], +```bash +php artisan vendor:publish --provider="RealRashid\SweetAlert\SweetAlertServiceProvider" ``` -Also, add the `Alert` facade to the `aliases` array in your `app` configuration file: +> note: The javascript library of sweetalert2 is already loaded and included in the view with the help of above command! -```php -'Alert' => RealRashid\SweetAlert\Facades\Alert::class, -``` - -# Include SweetAlert 2 View - -in your master layout +!> If you don't want to use pre-loaded **sweetalert.all.js** so you can use cdn. +Just chnage the below .env key. ```php -@include('sweetalert::alert') +// By Default its true +// Turn it to false +SWEET_ALERT_LOCAL=false +// Add sweetalert2 cdn link +SWEET_ALERT_CDN='' ``` +!> You can not use local **sweetalert.all.js** or cdn together! -and run the below command to publish the sweetalert.all.js in your public assets. - -```bash -php artisan vendor:publish --provider="RealRashid\SweetAlert\SweetAlertServiceProvider" +ex: +```php +SWEET_ALERT_LOCAL=true +SWEET_ALERT_CDN='link' ``` - -> note: the javascript library of sweetalert.all.js is already loaded in above included view - diff --git a/docs/configuration.md b/docs/configuration.md deleted file mode 100644 index 9094551..0000000 --- a/docs/configuration.md +++ /dev/null @@ -1,41 +0,0 @@ -# Methods Definition - -#### Alert Methods - -| Method | Argument | -|:---------------------: |:------------------------------: | -| `alert()` | `$title, $message, $type` | -| `alert()->success()` | `$title, $message` | -| `alert()->info()` | `$title, $message` | -| `alert()->warning()` | `$title, $message` | -| `alert()->error()` | `$title, $message` | -| `alert()->question()` | `$title, $message` | -| `alert()->html()` | `$htmltitle, $htmlCode, $type` | -| `toast()` | `$message, $type, $position` | - -#### Chain Methods - -| Chain Method | Argument | Snippet | -|:---------------------: |:------------------------------------------------: |:-----------------------------------------------------------------------------------------------: | -| `persistent()` | `$showConfirmBtn = true, $showCloseBtn = false` | `alert()->success('Alert Persistent', 'Successfully')->persistent(false,true);` | -| `autoClose()` | `$milliseconds = 5000` | `alert()->info('I am going to close after', '5 seconds')->autoClose(5000);` | -| `showConfirmButton()` | `$btnText = 'Ok', $btnColor = '#3085d6'` | `alert()->info('Info', 'Alert')->showConfirmButton('Button Text','#3085d6');` | -| `showCancelButton()` | `$btnText = 'Cencel', $btnColor = '#aaa'` | `alert()->question('Is Post Created', 'Successfully?)->showCancelButton('Button Text','#aaa');` | -| `showCloseButton()` | `$closeButtonAriaLabel = 'aria-label'` | `alert()->warning('Post Created', 'Successfully')->showCloseButton('aria-label');` | -| `footer()` | `$htmlcode` | `alert()->error('Oops...', 'Something went wrong!')->footer('Why do I have this issue?');` | -| `toToast()` | `$position = 'top-right'` | `alert()->success('Post Created', 'Successfully')->toToast();` | -| | | | -| | | | -> can also support multiple chaining - -``` php - -alert() - ->error('Oops...', 'Something went wrong!') - ->footer('Why do I have this issue?') - ->showConfirmButton() - ->showCancelButton() - ->showCloseButton() - ->autoClose(5000); - -``` diff --git a/docs/credits.md b/docs/credits.md index 21f9d29..c6a3933 100644 --- a/docs/credits.md +++ b/docs/credits.md @@ -1,4 +1,4 @@ -## Credits +# Credits * [SweetAlert2](https://github.com/sweetalert2/sweetalert2) diff --git a/docs/demo.md b/docs/demo.md index 46267d0..9ed5287 100644 --- a/docs/demo.md +++ b/docs/demo.md @@ -76,10 +76,12 @@ alert()->html('HTML example'," # Toast Demo +> Set the Default Toast Position in `config/sweetalert.php` file OR use the `position()` helper method! + ##### Success Toast ``` php -toast('Success Toast','success','top-right'); +toast('Success Toast','success'); ```

@@ -89,7 +91,7 @@ toast('Success Toast','success','top-right'); ##### Info Toast ``` php -toast('Info Toast','info','top-right'); +toast('Info Toast','info'); ```

@@ -99,7 +101,7 @@ toast('Info Toast','info','top-right'); ##### Warning Toast ``` php -toast('Warning Toast','warning','top-right'); +toast('Warning Toast','warning'); ```

@@ -109,7 +111,7 @@ toast('Warning Toast','warning','top-right'); ##### Question Toast ``` php -toast('Question Toast','question','top-right'); +toast('Question Toast','question'); ```

@@ -119,7 +121,7 @@ toast('Question Toast','question','top-right'); ##### Error Toast ``` php -toast('Error Toast','error','top-right'); +toast('Error Toast','error'); ```

diff --git a/docs/environment.md b/docs/environment.md new file mode 100644 index 0000000..9c97659 --- /dev/null +++ b/docs/environment.md @@ -0,0 +1,108 @@ +# Environment Variables + +```php +/* +|-------------------------------------------------------------------------- +| SweetAlert2 Local .JS File +|-------------------------------------------------------------------------- +| By default SweetAlert2 use its local sweetalert.all.js +| file. +*/ +SWEET_ALERT_LOCAL=true + +/* +|-------------------------------------------------------------------------- +| CDN LINK +|-------------------------------------------------------------------------- +| By default SweetAlert2 use its local sweetalert.all.js +| file. +| However, you can use its cdn if you want. +*/ +SWEET_ALERT_CDN='' + +/* +|-------------------------------------------------------------------------- +| AutoClose Timer +|-------------------------------------------------------------------------- +| This is for the all Modal windows. +| For specific modal just use the autoClose() helper method. +*/ +SWEET_ALERT_TIMER=5000 + +/* +|-------------------------------------------------------------------------- +| Width +|-------------------------------------------------------------------------- +| Modal window width, including paddings (box-sizing: border-box). +| Can be in px or %. +| The default width is 32rem. +| This is for the all Modal windows. +| for particular modal just use the width() helper method. +*/ +SWEET_ALERT_WIDTH=32rem + +/* +|-------------------------------------------------------------------------- +| Height Auto +|-------------------------------------------------------------------------- +| By default, SweetAlert2 sets html's and body's CSS height to auto !important. +| If this behavior isn't compatible with your project's layout, +| set heightAuto to false. +*/ +SWEET_ALERT_HEIGHT_AUTO=true + +/* +|-------------------------------------------------------------------------- +| Padding +|-------------------------------------------------------------------------- +| Modal window padding. +| Can be in px or %. +| The default padding is 1.25rem. +| This is for the all Modal windows. +| for particular modal just use the padding() helper method. +*/ +SWEET_ALERT_PADDING=1.25rem + +/* +|-------------------------------------------------------------------------- +| Animation +|-------------------------------------------------------------------------- +| If set to false, modal CSS animation will be disabled. +| For specific modal just use the animation() helper method. +*/ +SWEET_ALERT_ANIMATION=true + +/* +|-------------------------------------------------------------------------- +| ShowConfirmButton +|-------------------------------------------------------------------------- +| If set to false, a "Confirm"-button will not be shown. +| It can be useful when you're using custom HTML description. +| This is for the all Modal windows. +| For specific modal just use the showConfirmButton() helper method. +*/ +SWEET_ALERT_CONFIRM_BUTTON=true + +/* +|-------------------------------------------------------------------------- +| ShowCloseButton +|-------------------------------------------------------------------------- +| If set to true, a "Close"-button will be shown, +| which the user can click on to dismiss the modal. +| This is for the all Modal windows. +| For specific modal just use the showCloseButton() helper method. +*/ +SWEET_ALERT_CLOSE_BUTTON=false + +/* +|-------------------------------------------------------------------------- +| Toast position +|-------------------------------------------------------------------------- +| Modal window or toast position, can be 'top', +| 'top-start', 'top-end', 'center', 'center-start', +| 'center-end', 'bottom', 'bottom-start', or 'bottom-end'. +| For specific modal just use the position() helper method. +*/ +SWEET_ALERT_TOAST_POSITION=top-end + +``` \ No newline at end of file diff --git a/docs/helpers.md b/docs/helpers.md index f9a540d..e9ab480 100644 --- a/docs/helpers.md +++ b/docs/helpers.md @@ -19,7 +19,7 @@ autoClose($milliseconds = 5000) ``` php // example: -toast('Success Toast','success','top-right')->autoClose(5000); +toast('Success Toast','success')->autoClose(5000); ``` ##### Position @@ -27,10 +27,12 @@ toast('Success Toast','success','top-right')->autoClose(5000); ` position($position = 'top-end') ` +> Modal window and Toast position, can be **'top'**, **'top-start'**, **'top-end'**, +**'center'**, **'center-start'**, **'center-end'**, **'bottom'**, **'bottom-start'**, or **'bottom-end'**. ``` php // example: -alert('Title','Lorem Lorem Lorem', 'success')->position('top-left'); +alert('Title','Lorem Lorem Lorem', 'success')->position('top-end'); ``` ##### ShowConfirmButton @@ -134,3 +136,77 @@ addImage($imageUrl) // example: alert('Title','Lorem Lorem Lorem', 'success')->addImage('https://unsplash.it/400/200'); ``` + +##### Width + +` +width('32rem') +` +> Modal window width, including paddings (box-sizing: border-box). + Can be in px or %. + The default width is 32rem. + +``` php +// example: +alert('Title','Lorem Lorem Lorem', 'success')->width('720px'); +``` + +##### Padding + +` +padding('1.25rem') +` +> Modal window padding. Can be in px or %. The default padding is 1.25rem. + +``` php +// example: +alert('Title','Lorem Lorem Lorem', 'success')->padding('50px'); +``` + +##### Background + +` +background('#fff') +` +> Modal window background (CSS background property). The default background is '#fff'. + +``` php +// example: +alert('Title','Lorem Lorem Lorem', 'success')->background('#fff'); +``` + +##### Animation + +` +animation(true) +` +> If set to false, modal CSS animation will be disabled. + +``` php +// example: +alert('Title','Lorem Lorem Lorem', 'success')->animation(false); +``` + +##### Focus Confirm + +` +focusConfirm(true) +` +> Set to false if you want to focus the first element in tab order instead of "Confirm"-button by default. + +``` php +// example: +alert()->question('Are you sure?','You won\'t be able to revert this!')->showCancelButton()->showConfirmButton()->focusConfirm(true); +``` + +##### Focus Cancel + +` +focusCancel(false) +` +> Set to true if you want to focus the "Cancel"-button by default. + +``` php +// example: +alert()->question('Are you sure?','You won\'t be able to revert this!')->showCancelButton()->showConfirmButton()->focusCancel(true); +``` diff --git a/docs/index.html b/docs/index.html index a29d7d9..baf48eb 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,41 +1,101 @@ + Laravel SweetAlert by Rashid Ali - + + - - + + + + + + + + + + + + + + - + +

@@ -48,4 +108,5 @@ } + diff --git a/docs/install.md b/docs/install.md index f651901..2b11418 100644 --- a/docs/install.md +++ b/docs/install.md @@ -1,7 +1,31 @@ -# Install +# Installation To get started with SweetAlert2, use Composer to add the package to your project's dependencies: -``` +```bash composer require realrashid/sweet-alert -``` \ No newline at end of file +``` + +!> Optional in Laravel 5.5 or above! + +After installing the sweet-alert package, register the service provider + +```php +RealRashid\SweetAlert\SweetAlertServiceProvider::class, +``` +in your `config/app.php` configuration file: + +```php +'providers' => [ + /* + * Package Service Providers... + */ + RealRashid\SweetAlert\SweetAlertServiceProvider::class, +], +``` + +Also, add the `Alert` facade to the `aliases` array in your `app` configuration file: + +```php +'Alert' => RealRashid\SweetAlert\Facades\Alert::class, +``` diff --git a/docs/middleware.md b/docs/middleware.md index 75a80f3..6b99ad0 100644 --- a/docs/middleware.md +++ b/docs/middleware.md @@ -3,16 +3,14 @@ #### Using the Middleware -First thing first +First thing first Let register the middleware in web middleware groups by simply adding the middleware class ```php -RealRashid\SweetAlert\ToSweetAlert::class +\RealRashid\SweetAlert\ToSweetAlert::class ``` -into the - -`$middlewareGroups` of your `app/Http/Kernel.php` class. +into the `$middlewareGroups` of your `app/Http/Kernel.php` class. ### Examples @@ -25,24 +23,29 @@ Error Alert public function FunctionName(Request $request) { return redirect('login')->with('error', 'Authentication Failed!'); + // OR + return redirect('login')->withError('Authentication Failed!'); } - ``` Success Alert ```php -public function FunctionName(Request $request) +public function store(Request $request) { - return redirect('login')->with('success', 'Login Successfully!'); + //validation + $task = Task::create($request->all()); + return redirect('tasks')->with('success', 'Task Created Successfully!'); + // OR + return redirect('tasks')->withSuccess('Task Created Successfully!'); } - ``` ```php return redirect('route')->with('type', 'message'); +// OR +return redirect('route')->withType('message'); ``` -All available types -`info` `warning` `question` +All available types `error` `success` `info` `warning` `question` . #### Toast @@ -51,21 +54,37 @@ Error Toast public function FunctionName(Request $request) { return redirect('login')->with('toast_error', 'Authentication Failed!'); + // OR + return redirect('login')->withToastError('Authentication Failed!'); } - ``` Success Toast ```php -public function FunctionName(Request $request) +public function update(Request $request, Task $task) { - return redirect('login')->with('toast_success', 'Login Successfully!'); + //validation + // Updating logic + return redirect('tasks')->with('toast_success', 'Successfully modified the task!'); + // OR + return redirect('tasks')->withToastSuccess('Successfully modified the task!'); } - ``` ```php -return redirect('route')->with('type', 'message'); +return redirect('route')->with('toast_type', 'message'); +// OR +return redirect('route')->withToastType('message'); ``` -All available types -`toast_info` `toast_warning` `toast_question` +All available types `toast_error` `toast_success` `toast_info` `toast_warning` `toast_question`. + +!> You can not use helper methods with Middleware but you can set default values in `config/sweetalert.php` file! **Recommend** to use the .env keys. + +``` +SWEET_ALERT_MIDDLEWARE_TOAST_POSITION='top-end' +SWEET_ALERT_MIDDLEWARE_TOAST_CLOSE_BUTTON=true +``` + +> Positions **'top'**, **'top-start'**, **'top-end'**, +**'center'**, **'center-start'**, **'center-end'**, **'bottom'**, **'bottom-start'**, or **'bottom-end'**. + diff --git a/docs/sw.js b/docs/sw.js index 94461cd..5f7c8ea 100644 --- a/docs/sw.js +++ b/docs/sw.js @@ -1,16 +1,21 @@ /* =========================================================== - * sweetaler sw.js + * SweetAlert sw.js * =========================================================== * Copyright 2016 @huxpro * Licensed under Apache 2.0 * Register service worker. * ========================================================== */ -const RUNTIME = 'sweetaler' +const RUNTIME = 'sweetalert' const HOSTNAME_WHITELIST = [ self.location.hostname, 'fonts.gstatic.com', 'fonts.googleapis.com', + 'github.com', + 'raw.github.com', + 'poser.pugx.org', + 'ionicabizau.github.io', + 'opencollective.com', 'unpkg.com' ] @@ -80,4 +85,4 @@ self.addEventListener('fetch', event => { .catch(_ => { /* eat any errors */ }) ) } -}) \ No newline at end of file +}) diff --git a/docs/tutorial.md b/docs/tutorial.md new file mode 100644 index 0000000..84a8695 --- /dev/null +++ b/docs/tutorial.md @@ -0,0 +1,19 @@ +# Tutorial + +
+
+
+
+ + +
+
+
+
diff --git a/docs/usage.md b/docs/usage.md index 0b20ca6..ab58094 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -38,8 +38,9 @@ in your controller method Alert::html('Html Title', 'Html Code', 'Type'); ``` ```php - Alert::toast('Toast Message', 'Toast Type', 'Toast Position'); + Alert::toast('Toast Message', 'Toast Type'); ``` + > Set the Default Toast Position in `config/sweetalert.php` file OR use the `position()` helper method! ### Using the helper function @@ -80,5 +81,6 @@ in your controller method #### Toast ```php - toast('Your Post as been submited!','success','top-right'); + toast('Your Post as been submited!','success'); ``` + > Set the Default Toast Position in `config/sweetalert.php` file OR use the `position()` helper method!