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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ea4f5c077671637ba0c4834240d4a6bbb692939a
4
- data.tar.gz: eecc5b36bf90b5eb522339722c4f04c15b2e7505
2
+ SHA256:
3
+ metadata.gz: f2768fd6fa7aaa91e3b6f301689f4836fad4852d0e0976f61c0b90b67c81feec
4
+ data.tar.gz: 6421d1d9299f17209b3e8f18850cee1e88918ceea862b39a6f2e1b9a5907e559
5
5
  SHA512:
6
- metadata.gz: f276753badf6959713cc8737e45c462411ec8685417339644e16923d0c3096ab57750279e66f8a9243a92d7f06d9995f3059a8b3f2fda0093f03c68c3b6eee2f
7
- data.tar.gz: af003c3f71308c49a7f1a4e78033e54bd9dea6be5b79fbb6112ab4d1304e6c0202bb2b3ce6689afae2801bd14e5ca582c09866aa0293137e6c69dc0588213dbd
6
+ metadata.gz: d274d6c92c6a78c0a79e2c835d2b3ed79334f6bfeeee7738a84fe8e3f87ee5f8d7c9f5b78caacb5d34e7c4f9ddde7ab20c5d7882a39205f5126ed17574a19389
7
+ data.tar.gz: bf0db9f18ae12ca21cc56a996eb15716a6e2d7d388208b14d0eed08688294e18efbeba2b9be4159315ac5bdc3daf72721bfc3d5e2175213a9c33b2e108b09285
data/.travis.yml CHANGED
@@ -11,7 +11,7 @@ env:
11
11
 
12
12
  rvm:
13
13
  - 1.9.3
14
- - 2.0.0
14
+ - 2.2.1
15
15
  - jruby-19mode
16
16
 
17
17
 
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", git: 'https://github.com/teampoltergeist/poltergeist.git'
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
- Using ```gem 'rails-assets-sweetalert'```
23
-
24
- application.js:
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
- ```css
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
- $.each($linkToVerify.data(), function(key, val){
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 page:load ajaxComplete', function() {
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();
@@ -1,3 +1,3 @@
1
1
  module SweetAlertConfirm
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -12,6 +12,6 @@
12
12
  //
13
13
  //= require jquery
14
14
  //= require jquery_ujs
15
- //= require sweet-alert
15
+ //= require sweetalert
16
16
  //= require sweet-alert-confirm
17
17
  // require_tree .
@@ -13,6 +13,6 @@
13
13
  //= require jquery
14
14
  //= require jquery_ujs
15
15
  //= require turbolinks
16
- //= require sweet-alert
16
+ //= require sweetalert
17
17
  //= require sweet-alert-confirm
18
18
  // require_tree .
@@ -10,7 +10,7 @@
10
10
  * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
11
  * file per style scope.
12
12
  *
13
- *= require sweet-alert
13
+ *= require sweetalert
14
14
  *= require_tree .
15
15
  *= require_self
16
16
  */
@@ -10,7 +10,7 @@
10
10
  * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
11
  * file per style scope.
12
12
  *
13
- *= require sweet-alert.css
13
+ *= require sweetalert.css
14
14
  *=* require_tree .
15
15
  *=* require_self
16
16
  */
@@ -12,5 +12,5 @@
12
12
  //
13
13
  //= require jquery
14
14
  //= require jquery_ujs
15
- //= require sweet-alert
15
+ //= require sweetalert
16
16
  //= require sweet-alert-confirm
@@ -13,6 +13,6 @@
13
13
  //= require jquery
14
14
  //= require jquery_ujs
15
15
  //= require turbolinks
16
- //= require sweet-alert
16
+ //= require sweetalert
17
17
  //= require sweet-alert-confirm
18
18
  // require_tree .
@@ -10,7 +10,7 @@
10
10
  * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
11
  * file per style scope.
12
12
  *
13
- *= require sweet-alert
13
+ *= require sweetalert
14
14
  *= require_tree .
15
15
  *= require_self
16
16
  */
@@ -10,7 +10,7 @@
10
10
  * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
11
  * file per style scope.
12
12
  *
13
- *= require sweet-alert.css
13
+ *= require sweetalert.css
14
14
  *=* require_tree .
15
15
  *=* require_self
16
16
  */
@@ -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('.icon.info')
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.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: 2015-09-20 00:00:00.000000000 Z
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
- rubyforge_project:
236
- rubygems_version: 2.4.1
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: