Skip to content

Commit c488fb7

Browse files
Tim JoostenTim Joosten
authored andcommitted
Revert "Implement defer method for the javascript files"
This reverts commit 6f0707b.
1 parent e5bad96 commit c488fb7

File tree

3 files changed

+1
-25
lines changed

3 files changed

+1
-25
lines changed

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ All notable changes to `misfits/toastr` will be documented in this file.
55
## 1.1.0 - XXXX-XX-XX
66

77
- Fix #1 | Fix typo. (`signleton` to `singleton`)
8-
- Bring the javascript defer option to the package
98

109
## 1.0.0 - 2018-06-24
1110

README.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@ Include jQuery and [toastr.js](https://github.com/CodeSeven/toastr) in your mast
2525
{!! Toastr::render() !!}
2626
```
2727

28-
If you defer the loading of your scripts include `Toastr::render(true)`
29-
30-
```html
31-
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js" defer></script>
32-
<script src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js" defer></script>
33-
{!! Toastr::render(true) !!}
34-
```
35-
3628
Call one of these methods in your controllers to insert a toast:
3729
- `Toastr::warning($message, $title = null, $options = [])` - add a warning toast
3830
- `Toastr::error($message, $title = null, $options = [])` - add an error toast

src/Toastr.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,13 @@ public function __construct(SessionManager $session, Repository $config)
5454
/**
5555
* Render the notifications script tag
5656
*
57-
* @param bool $defer Indicates that the resources are loading with deferred option or not.
5857
* @return string
5958
*/
60-
public function render(bool $defer = false): string
59+
public function render(): string
6160
{
6261
$notifications = $this->session->get('toastr::notifications');
6362
$output = '<script type="text/javascript">';
6463
$lastconfig = [];
65-
66-
if ($defer) {
67-
$output = 'window.addEventListener("DOMContentLoaded", function() {
68-
(function($) {
69-
$(document).ready(function() {
70-
$(function(){';
71-
}
7264

7365
if (! $notifications) { // Notifications are empty so register a empty array under the variable.
7466
$notifications = [];
@@ -96,13 +88,6 @@ public function render(bool $defer = false): string
9688
(isset($notification['title']) ? ", '" . str_replace("'", "\\'", htmlentities($notification['title'])) . "'" : null) . ');';
9789
}
9890

99-
if ($defer) {
100-
$output = '});
101-
});
102-
})(jQuery);
103-
});';
104-
}
105-
10691
$output .= '</script>';
10792

10893
return $output;

0 commit comments

Comments
 (0)