sweet-alert-confirm 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.travis.yml +1 -1
- data/Gemfile +6 -1
- data/README.md +13 -19
- data/lib/assets/javascripts/sweet-alert-confirm.js +36 -19
- data/lib/sweet-alert-confirm/version.rb +1 -1
- data/spec/dummy/app/assets/javascripts/application.js +1 -1
- data/spec/dummy/app/assets/javascripts/application_turbolinks.js +1 -1
- data/spec/dummy/app/assets/stylesheets/application.css +1 -1
- data/spec/dummy/app/assets/stylesheets/application.scss.css +1 -1
- data/spec/dummy-rails3/app/assets/javascripts/application.js +1 -1
- data/spec/dummy-rails3/app/assets/javascripts/application_turbolinks.js +1 -1
- data/spec/dummy-rails3/app/assets/stylesheets/application.css +1 -1
- data/spec/dummy-rails3/app/assets/stylesheets/application.scss.css +1 -1
- data/spec/features/sweet_alert_confirm_spec.rb +1 -1
- metadata +6 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f2768fd6fa7aaa91e3b6f301689f4836fad4852d0e0976f61c0b90b67c81feec
|
4
|
+
data.tar.gz: 6421d1d9299f17209b3e8f18850cee1e88918ceea862b39a6f2e1b9a5907e559
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d274d6c92c6a78c0a79e2c835d2b3ed79334f6bfeeee7738a84fe8e3f87ee5f8d7c9f5b78caacb5d34e7c4f9ddde7ab20c5d7882a39205f5126ed17574a19389
|
7
|
+
data.tar.gz: bf0db9f18ae12ca21cc56a996eb15716a6e2d7d388208b14d0eed08688294e18efbeba2b9be4159315ac5bdc3daf72721bfc3d5e2175213a9c33b2e108b09285
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -27,11 +27,16 @@ rails = case rails_version
|
|
27
27
|
gem "rails", rails
|
28
28
|
gem "turbolinks"
|
29
29
|
|
30
|
+
source 'https://rails-assets.org' do
|
31
|
+
gem 'rails-assets-sweetalert'
|
32
|
+
end
|
33
|
+
|
30
34
|
group :development, :test do
|
31
35
|
gem "jquery-rails"
|
36
|
+
gem "test-unit"
|
32
37
|
gem 'sass-rails'
|
33
38
|
gem "sweet-alert"
|
34
39
|
gem "capybara"
|
35
|
-
gem "poltergeist"
|
40
|
+
gem "poltergeist"
|
36
41
|
gem "rake"
|
37
42
|
end
|
data/README.md
CHANGED
@@ -19,31 +19,19 @@ Rails >= 3.1
|
|
19
19
|
|
20
20
|
## Usage
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
```javascript
|
27
|
-
//= require sweetalert
|
28
|
-
//= require sweet-alert-confirm
|
22
|
+
Add it to your Gemfile:
|
23
|
+
```ruby
|
24
|
+
gem 'sweet-alert'
|
25
|
+
gem 'sweet-alert-confirm'
|
29
26
|
```
|
30
|
-
application.css:
|
31
27
|
|
32
|
-
|
33
|
-
/*
|
34
|
-
*= require sweetalert
|
35
|
-
*/
|
36
|
-
```
|
37
|
-
|
38
|
-
Using ```gem 'sweet-alert'```
|
39
|
-
|
40
|
-
application.js:
|
28
|
+
Add the following to application.js:
|
41
29
|
|
42
30
|
```javascript
|
43
31
|
//= require sweet-alert
|
44
32
|
//= require sweet-alert-confirm
|
45
33
|
```
|
46
|
-
application.css:
|
34
|
+
Add the following to application.css:
|
47
35
|
|
48
36
|
```css
|
49
37
|
/*
|
@@ -57,7 +45,7 @@ application.css:
|
|
57
45
|
You can pass options in `data:`
|
58
46
|
```Ruby
|
59
47
|
data: {
|
60
|
-
confirm: 'Are you ready?'
|
48
|
+
:'sweet-alert-confirm: 'Are you ready?'
|
61
49
|
:'confirm-button-text' => 'Im ready',
|
62
50
|
:'cancel-button-text' => 'No way',
|
63
51
|
:'confirm-button-color' => '#66CD00',
|
@@ -81,6 +69,12 @@ var sweetAlertConfirmConfig = {
|
|
81
69
|
};
|
82
70
|
```
|
83
71
|
|
72
|
+
### Before Callback
|
73
|
+
|
74
|
+
A callback that will be runned before alert is shown. Returning `false` will display the alert and `true` will _not_ display it.
|
75
|
+
|
76
|
+
`data-saBeforeFunction='myFunction'`
|
77
|
+
|
84
78
|
## Contribute
|
85
79
|
|
86
80
|
Fork the repo & pull request you fix/feature
|
@@ -28,27 +28,16 @@ var sweetAlertConfirmConfig = sweetAlertConfirmConfig || {}; // Add default conf
|
|
28
28
|
'confirmButtonText',
|
29
29
|
'cancelButtonText',
|
30
30
|
'closeOnConfirm',
|
31
|
+
'html',
|
31
32
|
'imageUrl',
|
32
33
|
'allowOutsideClick',
|
34
|
+
'customClass',
|
33
35
|
'remote',
|
34
36
|
'method',
|
35
37
|
'function'
|
36
|
-
]
|
37
|
-
|
38
|
-
|
39
|
-
if ($.inArray(key, optionKeys) >= 0) {
|
40
|
-
swalOptions[key] = val
|
41
|
-
if (key == 'sweetAlertType') {
|
42
|
-
swalOptions['type'] = val;
|
43
|
-
}
|
44
|
-
|
45
|
-
}
|
46
|
-
})
|
47
|
-
|
48
|
-
var nameFunction = swalOptions['function'];
|
49
|
-
message = $linkToVerify.attr('data-sweet-alert-confirm')
|
50
|
-
swalOptions['title'] = message
|
51
|
-
swal(swalOptions, function(r){
|
38
|
+
];
|
39
|
+
|
40
|
+
function afterAlertCallback(r){
|
52
41
|
if (nameFunction) {
|
53
42
|
window[nameFunction]();
|
54
43
|
}
|
@@ -79,18 +68,46 @@ var sweetAlertConfirmConfig = sweetAlertConfirmConfig || {}; // Add default conf
|
|
79
68
|
else {
|
80
69
|
window.location.href = $linkToVerify.attr('href');
|
81
70
|
}
|
82
|
-
|
71
|
+
|
83
72
|
}
|
84
73
|
}
|
74
|
+
}
|
75
|
+
|
76
|
+
var beforeFunction = null;
|
77
|
+
|
78
|
+
$.each($linkToVerify.data(), function(key, val){
|
79
|
+
if ($.inArray(key, optionKeys) >= 0) {
|
80
|
+
swalOptions[key] = val
|
81
|
+
if (key == 'sweetAlertType') {
|
82
|
+
swalOptions['type'] = val;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
// Make a before callback to verify that swal should be shown
|
86
|
+
if(key == 'sabeforefunction') {
|
87
|
+
beforeFunction = val;
|
88
|
+
}
|
85
89
|
});
|
90
|
+
|
91
|
+
// Skip alert if false
|
92
|
+
if(beforeFunction != null) {
|
93
|
+
var beforeRes = window[beforeFunction]($linkToVerify);
|
94
|
+
if(beforeRes === true) {
|
95
|
+
return afterAlertCallback(true); // Skip alert
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
var nameFunction = swalOptions['function'];
|
100
|
+
message = $linkToVerify.attr('data-sweet-alert-confirm')
|
101
|
+
swalOptions['title'] = message
|
102
|
+
swal(swalOptions, afterAlertCallback);
|
86
103
|
|
87
104
|
return false;
|
88
105
|
}
|
89
|
-
$(document).on('ready
|
106
|
+
$(document).on('ready turbolinks:load turbo:load page:update ajaxComplete', function() {
|
90
107
|
$('[data-sweet-alert-confirm]').on('click', sweetAlertConfirm)
|
91
108
|
});
|
92
109
|
|
93
|
-
$(document).on('ready page:load', function() {
|
110
|
+
$(document).on('ready turbolinks:load turbo:load page:load', function() {
|
94
111
|
//To avoid "Uncaught TypeError: Cannot read property 'querySelector' of null" on turbolinks
|
95
112
|
if (typeof window.sweetAlertInitialize === 'function') {
|
96
113
|
window.sweetAlertInitialize();
|
@@ -87,7 +87,7 @@ describe 'basic confirms', js: true, type: :feature do
|
|
87
87
|
sleep 1
|
88
88
|
expect(page).to have_css('.confirm', text: 'Im ready')
|
89
89
|
expect(page).to have_css('.cancel', text: 'No way')
|
90
|
-
expect(page).to have_css('.
|
90
|
+
expect(page).to have_css('.sa-info', visible: true)
|
91
91
|
expect(page).to have_css('h2', text: 'Are you ready?')
|
92
92
|
expect(page).to have_css('p', text: 'This is a subtitle')
|
93
93
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sweet-alert-confirm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Moises Viloria
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -217,7 +217,7 @@ homepage: http://www.github.com/mois3x/sweet-alert-rails-confirm
|
|
217
217
|
licenses:
|
218
218
|
- MIT
|
219
219
|
metadata: {}
|
220
|
-
post_install_message:
|
220
|
+
post_install_message:
|
221
221
|
rdoc_options: []
|
222
222
|
require_paths:
|
223
223
|
- lib
|
@@ -232,10 +232,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
232
232
|
- !ruby/object:Gem::Version
|
233
233
|
version: '0'
|
234
234
|
requirements: []
|
235
|
-
|
236
|
-
|
237
|
-
signing_key:
|
235
|
+
rubygems_version: 3.1.6
|
236
|
+
signing_key:
|
238
237
|
specification_version: 4
|
239
238
|
summary: A Rails confirm replacement with SweetAlert
|
240
239
|
test_files: []
|
241
|
-
has_rdoc:
|