sweet-alert-confirm 0.2.1 → 0.3.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
2
  SHA1:
3
- metadata.gz: 0e2fbc7775fcd8b3351f57e8710c229431b13095
4
- data.tar.gz: 737b14b9f91318bbacf6c40738f941184dcb77de
3
+ metadata.gz: 7f32a1c64a0fe20d527652b4879cece6514479b5
4
+ data.tar.gz: 3b5004d07c472c9903f7053e0fcb22c06a2958bd
5
5
  SHA512:
6
- metadata.gz: b75eb40ed8c40a128f99a094e38ad272b14ed4b93f4b3aa447dd2e7bb333288025a0b208998e363f4563120409972c85fedb5191d9636305f079997bd68430e4
7
- data.tar.gz: c4706c97f9bd255833c949661c0887f5debc2a5178ea866ac596c7f1aac4e3f60fc7843e9d15550057b91c712b8a5bb6801ecc87d5dcf9f84b562aad6d8189e4
6
+ metadata.gz: 629817d1a61d64c6fc837123663fba57bebef58d31c6ca8a7f46eb599530d1a70dc0bf92b6d6e19d6555594a9a71e84735cc7ebeab6691647c2895e1973d13ac
7
+ data.tar.gz: 24e1b28b9df196793cc9a339f68fb06277fce0813a03b6afb219fb6960c9d789f519e8b3f7aa23c3fd32411668f64951739709a31aec9ade6abff9e4c8543028
data/.travis.yml CHANGED
@@ -1,9 +1,11 @@
1
1
  env:
2
- - "RAILS_VERSION=3.2.15"
3
- - "RAILS_VERSION=3.2.19"
4
- - "RAILS_VERSION=4.0.8"
5
- - "RAILS_VERSION=4.1.4"
6
- - "RAILS_VERSION=master"
2
+ - RAILS_VERSION=3.2.15
3
+ - RAILS_VERSION=3.2.15
4
+ - RAILS_VERSION=3.2.19 USE_TURBOLINKS=true
5
+ - RAILS_VERSION=4.0.8
6
+ - RAILS_VERSION=4.1.4
7
+ - RAILS_VERSION=4.1.4 USE_TURBOLINKS=true
8
+ - RAILS_VERSION=master
7
9
 
8
10
  rvm:
9
11
  - 1.9.3
data/Gemfile CHANGED
@@ -25,6 +25,7 @@ rails = case rails_version
25
25
  end
26
26
 
27
27
  gem "rails", rails
28
+ gem "turbolinks"
28
29
 
29
30
  group :development, :test do
30
31
  gem "jquery-rails"
@@ -35,6 +36,6 @@ group :development, :test do
35
36
  end
36
37
  gem "sweet-alert"
37
38
  gem "capybara"
38
- gem "poltergeist", git: 'https://github.com/teampoltergeist/poltergeist.git'
39
+ gem "poltergeist" #, git: 'https://github.com/teampoltergeist/poltergeist.git'
39
40
  gem "rake"
40
41
  end
data/README.md CHANGED
@@ -6,20 +6,41 @@ sweet-alert-rails-confirm
6
6
 
7
7
  A Rails confirm replacement with SweetAlert
8
8
 
9
- depends on http://github.com/Najtmare/sweet-alert-rails
9
+ depends on https://github.com/t4t5/sweetalert
10
+
11
+ So you need to Install:
12
+ gem 'sweet-alert'
13
+
14
+ Or the latest with:
15
+ gem 'rails-assets-sweetalert' # Using https://rails-assets.org/
10
16
 
11
- Install:
12
- gem 'sweet-alert-confirm'
13
-
14
17
  ## Requirements
15
18
  Rails >= 3.1
16
19
 
17
20
  ## Usage
18
21
 
22
+ Using ```gem 'rails-assets-sweetalert'```
23
+
24
+ application.js:
25
+
26
+ ```javascript
27
+ //= require sweetalert
28
+ //= require sweet-alert-confirm
29
+ ```
30
+ application.css:
31
+
32
+ ```css
33
+ /*
34
+ *= require sweetalert
35
+ */
36
+ ```
37
+
38
+ Using ```gem 'sweet-alert'```
19
39
 
20
40
  application.js:
21
41
 
22
42
  ```javascript
43
+ //= require sweet-alert
23
44
  //= require sweet-alert-confirm
24
45
  ```
25
46
  application.css:
@@ -36,15 +57,14 @@ application.css:
36
57
  You can pass options in `data:`
37
58
  ```Ruby
38
59
  data: {
39
- confirm: 'Are you ready?'
40
- :'confirm-button-text' => 'Im ready',
41
- :'cancel-button-text' => 'No way',
42
- :'confirm-button-color' => '#66CD00',
43
- :'sweet-alert-type' => 'info',
44
- text: 'This is a subtitle',
45
- :'image-url' => '/pic.png'
46
-
47
- }
60
+ confirm: 'Are you ready?'
61
+ :'confirm-button-text' => 'Im ready',
62
+ :'cancel-button-text' => 'No way',
63
+ :'confirm-button-color' => '#66CD00',
64
+ :'sweet-alert-type' => 'info',
65
+ text: 'This is a subtitle',
66
+ :'image-url' => '/pic.png'
67
+ }
48
68
  ```
49
69
 
50
70
  ![Custom confirm](https://cloud.githubusercontent.com/assets/5833678/4653700/14389916-54b0-11e4-9850-14ee970e9345.png)
@@ -56,4 +76,3 @@ Fork the repo & pull request you fix/feature
56
76
  append `RAILS_VERSION=4.1.2` or whichever you target before your `bundle` command ex: `RAILS_VERSION=4.1.2 bundle install`
57
77
 
58
78
  please add/modify test examples on fix or features
59
-
@@ -1,4 +1,3 @@
1
- //= require sweet-alert
2
1
  (function( $ ) {
3
2
  var sweetAlertConfirm = function(event) {
4
3
  swalDefaultOptions = {
@@ -10,7 +9,6 @@
10
9
 
11
10
  }
12
11
 
13
- //this.click(function(event) {
14
12
  $linkToVerify = $(this)
15
13
  var swalOptions = swalDefaultOptions;
16
14
  var optionKeys = [
@@ -57,7 +55,6 @@
57
55
  }
58
56
  }
59
57
  else {
60
- //[FIXME]Check this im not sure about this
61
58
  if (r === false) {
62
59
  return false;
63
60
  } else {
@@ -76,15 +73,16 @@
76
73
  });
77
74
 
78
75
  return false;
79
- //});
80
- //return this;
81
76
  }
82
77
  $(document).on('ready page:load ajaxComplete', function() {
83
78
  $('[data-sweet-alert-confirm]').on('click', sweetAlertConfirm)
84
79
  });
80
+
85
81
  $(document).on('ready page:load', function() {
86
82
  //To avoid "Uncaught TypeError: Cannot read property 'querySelector' of null" on turbolinks
87
- window.sweetAlertInitialize();
83
+ if (typeof window.sweetAlertInitialize === 'function') {
84
+ window.sweetAlertInitialize();
85
+ }
88
86
  });
89
87
 
90
88
 
@@ -1,3 +1,2 @@
1
1
  /*
2
- *= require sweet-alert
3
2
  */
@@ -1,7 +1,7 @@
1
1
  require 'sweet-alert-confirm/view_helpers'
2
2
  module SweetAlertConfirm
3
3
  class Railtie < Rails::Railtie
4
- initializer "sweet_alert_confirm.view_helpers" do
4
+ initializer 'sweet_alert_confirm.view_helpers' do
5
5
  ActionView::Base.send :include, ViewHelpers
6
6
  end
7
7
  end
@@ -1,3 +1,3 @@
1
1
  module SweetAlertConfirm
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -10,7 +10,7 @@ module SweetAlertConfirm
10
10
  super *args, &block
11
11
  end
12
12
 
13
- def submit_tag(value = "Save changes", options = {})
13
+ def submit_tag(value = 'Save changes', options = {})
14
14
  options['data-sweet-alert-confirm'] = options.delete(:confirm) || options[:data].delete(:confirm) if options_has_confirm?(options)
15
15
  super value, options
16
16
  end
@@ -23,7 +23,7 @@ module SweetAlertConfirm
23
23
  html_options[:data].delete(:confirm)
24
24
  end
25
25
  super *args, &block
26
- end
26
+ end
27
27
 
28
28
  protected
29
29
  def options_has_confirm?(options)
@@ -1,6 +1,7 @@
1
- require 'sweet-alert'
2
- require "sweet-alert-confirm/version"
1
+ # require 'sweet-alert'
2
+ require 'sweet-alert-confirm/version'
3
3
  require 'sweet-alert-confirm/railtie'
4
4
  require 'sweet-alert-confirm/rails/engine'
5
+
5
6
  module SweetAlertConfirm
6
7
  end
@@ -14,4 +14,4 @@
14
14
  //= require jquery_ujs
15
15
  //= require sweet-alert
16
16
  //= require sweet-alert-confirm
17
- //= require_tree .
17
+ // require_tree .
@@ -0,0 +1,18 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require turbolinks
16
+ //= require sweet-alert
17
+ //= require sweet-alert-confirm
18
+ // require_tree .
@@ -6,4 +6,8 @@ class ConfirmsController < ApplicationController
6
6
  format.js {}
7
7
  end
8
8
  end
9
+
10
+ def pre_index
11
+
12
+ end
9
13
  end
@@ -0,0 +1 @@
1
+ <%= link_to 'Index', confirms_page_path %>
@@ -3,7 +3,11 @@
3
3
  <head>
4
4
  <title>Dummy</title>
5
5
  <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
- <%= javascript_include_tag 'application' %>
6
+ <% if ENV['USE_TURBOLINKS'] %>
7
+ <%= javascript_include_tag 'application_turbolinks', "data-turbolinks-track" => true %>
8
+ <% else %>
9
+ <%= javascript_include_tag 'application', "data-turbolinks-track" => false %>
10
+ <% end %>
7
11
  <%= csrf_meta_tags %>
8
12
  </head>
9
13
  <body>
@@ -5,4 +5,4 @@ Rails.application.config.assets.version = '1.0'
5
5
 
6
6
  # Precompile additional assets.
7
7
  # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
8
- # Rails.application.config.assets.precompile += %w( search.js )
8
+ Rails.application.config.assets.precompile += %w( application_turbolinks.js )
@@ -53,6 +53,7 @@ Rails.application.routes.draw do
53
53
  # # (app/controllers/admin/products_controller.rb)
54
54
  # resources :products
55
55
  # end
56
+ root 'confirms#pre_index'
56
57
  get :confirms_page, to: 'confirms#index'
57
58
  get :get_cow, to: 'confirms#get_cow'
58
59
  delete :delete_cow, to: 'confirms#delete_cow'
@@ -14,4 +14,3 @@
14
14
  //= require jquery_ujs
15
15
  //= require sweet-alert
16
16
  //= require sweet-alert-confirm
17
- //= require_tree .
@@ -0,0 +1,18 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require turbolinks
16
+ //= require sweet-alert
17
+ //= require sweet-alert-confirm
18
+ // require_tree .
@@ -6,4 +6,8 @@ class ConfirmsController < ApplicationController
6
6
  format.js {}
7
7
  end
8
8
  end
9
+
10
+ def pre_index
11
+
12
+ end
9
13
  end
@@ -0,0 +1 @@
1
+ <%= link_to 'Index', confirms_page_path %>
@@ -3,7 +3,11 @@
3
3
  <head>
4
4
  <title>Dummy</title>
5
5
  <%= stylesheet_link_tag "application", :media => "all" %>
6
- <%= javascript_include_tag "application" %>
6
+ <% if ENV['USE_TURBOLINKS'] %>
7
+ <%= javascript_include_tag 'application_turbolinks', "data-turbolinks-track" => true %>
8
+ <% else %>
9
+ <%= javascript_include_tag 'application', "data-turbolinks-track" => false %>
10
+ <% end %>
7
11
  <%= csrf_meta_tags %>
8
12
  </head>
9
13
  <body>
@@ -55,6 +55,7 @@ Dummy::Application.routes.draw do
55
55
  # This is a legacy wild controller route that's not recommended for RESTful applications.
56
56
  # Note: This route will make all actions in every controller accessible via GET requests.
57
57
  # match ':controller(/:action(/:id))(.:format)'
58
+ root to: 'confirms#pre_index'
58
59
  get :confirms_page, to: 'confirms#index'
59
60
  get :get_cow, to: 'confirms#get_cow'
60
61
  delete :delete_cow, to: 'confirms#delete_cow'
@@ -1,6 +1,16 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'basic confirms', js: true, type: :feature do
4
+ before do
5
+ if ENV['USE_TURBOLINKS']
6
+ visit root_path
7
+ page.execute_script('Turbolinks.visit("/confirms_page");')
8
+ #find_link('Index').trigger('click')
9
+ else
10
+ visit root_path
11
+ click_link 'Index'
12
+ end
13
+ end
4
14
 
5
15
  shared_examples 'Confirm shows correctly' do |is_cow_deleted, is_remote|
6
16
  let(:got_cow) { 'You got a pretty cow' }
@@ -8,13 +18,11 @@ describe 'basic confirms', js: true, type: :feature do
8
18
  let(:message) { is_cow_deleted ? deleted_cow : got_cow }
9
19
 
10
20
  it 'doesnt follow the link when click' do
11
- # require 'pry'
12
- # binding.pry
13
21
  expect(page).to have_content('Are you sure?')
14
22
  expect(page).not_to have_content(message)
15
23
  end
16
24
 
17
- it 'dont follow the link when click on cancel' do
25
+ it 'doesnt follow the link when click on cancel' do
18
26
  sleep 1
19
27
  expect(page).to_not have_content(message)
20
28
  click_button('Cancel')
@@ -35,7 +43,7 @@ describe 'basic confirms', js: true, type: :feature do
35
43
 
36
44
  describe 'normal links' do
37
45
  before do
38
- visit confirms_page_path
46
+ #visit confirms_page_path
39
47
  find_link("Basic confirm").trigger('click')
40
48
  end
41
49
 
@@ -44,8 +52,8 @@ describe 'basic confirms', js: true, type: :feature do
44
52
 
45
53
  describe 'methods links' do
46
54
  before do
47
- visit confirms_page_path
48
55
  find_link("Delete confirm").trigger('click')
56
+ sleep 2
49
57
  end
50
58
 
51
59
  it_behaves_like 'Confirm shows correctly', true
@@ -53,8 +61,8 @@ describe 'basic confirms', js: true, type: :feature do
53
61
 
54
62
  describe 'remote links' do
55
63
  before do
56
- visit confirms_page_path
57
64
  find_link("Remote confirm").trigger('click')
65
+ sleep 3
58
66
  end
59
67
 
60
68
  it_behaves_like 'Confirm shows correctly', true, true
@@ -62,8 +70,9 @@ describe 'basic confirms', js: true, type: :feature do
62
70
 
63
71
  it 'ajax change content in the page after accept confirm' do
64
72
  #click_on '.confirm'
73
+ sleep 3
65
74
  expect(page).to_not have_content('You murdered a silly cow with ajax')
66
- sleep 1
75
+ sleep 3
67
76
  click_button('Ok')
68
77
  expect(page).to have_content('You murdered a silly cow with ajax')
69
78
  end
@@ -87,7 +96,7 @@ describe 'basic confirms', js: true, type: :feature do
87
96
 
88
97
  describe 'Submit confirm' do
89
98
  before do
90
- visit confirms_page_path
99
+ #visit confirms_page_path
91
100
  find("#submit-delete").trigger('click')
92
101
  end
93
102
  it_behaves_like 'Confirm shows correctly', true
@@ -95,7 +104,7 @@ describe 'basic confirms', js: true, type: :feature do
95
104
 
96
105
  describe 'button_tag links' do
97
106
  before do
98
- visit confirms_page_path
107
+ #visit confirms_page_path
99
108
  find_button("Button_tag confirm").trigger('click')
100
109
  end
101
110
 
@@ -14,9 +14,9 @@ Gem::Specification.new do |s|
14
14
  s.description = ""
15
15
  s.license = "MIT"
16
16
 
17
- #s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
18
- s.add_dependency "jquery-rails"
19
- s.add_dependency "sweet-alert"
17
+ # s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
18
+ # s.add_dependency "jquery-rails"
19
+ # s.add_dependency "sweet-alert"
20
20
  s.add_development_dependency "rails", ">=3.1"
21
21
  s.add_development_dependency "rspec-rails"
22
22
  s.add_development_dependency "capybara", "~> 2.1"
metadata CHANGED
@@ -1,43 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sweet-alert-confirm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Moises Viloria
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-29 00:00:00.000000000 Z
11
+ date: 2015-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: jquery-rails
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: sweet-alert
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
13
  - !ruby/object:Gem::Dependency
42
14
  name: rails
43
15
  requirement: !ruby/object:Gem::Requirement
@@ -134,6 +106,7 @@ files:
134
106
  - spec/dummy-rails3/app/.DS_Store
135
107
  - spec/dummy-rails3/app/assets/.DS_Store
136
108
  - spec/dummy-rails3/app/assets/javascripts/application.js
109
+ - spec/dummy-rails3/app/assets/javascripts/application_turbolinks.js
137
110
  - spec/dummy-rails3/app/assets/stylesheets/application.css
138
111
  - spec/dummy-rails3/app/assets/stylesheets/application.scss.css
139
112
  - spec/dummy-rails3/app/controllers/application_controller.rb
@@ -145,6 +118,7 @@ files:
145
118
  - spec/dummy-rails3/app/views/confirms/delete_cow.js.erb
146
119
  - spec/dummy-rails3/app/views/confirms/get_cow.html.erb
147
120
  - spec/dummy-rails3/app/views/confirms/index.html.erb
121
+ - spec/dummy-rails3/app/views/confirms/pre_index.html.erb
148
122
  - spec/dummy-rails3/app/views/layouts/application.html.erb
149
123
  - spec/dummy-rails3/config.ru
150
124
  - spec/dummy-rails3/config/application.rb
@@ -204,6 +178,7 @@ files:
204
178
  - spec/dummy/Rakefile
205
179
  - spec/dummy/app/assets/images/.keep
206
180
  - spec/dummy/app/assets/javascripts/application.js
181
+ - spec/dummy/app/assets/javascripts/application_turbolinks.js
207
182
  - spec/dummy/app/assets/javascripts/confirms.js
208
183
  - spec/dummy/app/assets/stylesheets/application.css
209
184
  - spec/dummy/app/assets/stylesheets/application.scss.css
@@ -218,6 +193,7 @@ files:
218
193
  - spec/dummy/app/views/confirms/delete_cow.js.erb
219
194
  - spec/dummy/app/views/confirms/get_cow.html.erb
220
195
  - spec/dummy/app/views/confirms/index.html.erb
196
+ - spec/dummy/app/views/confirms/pre_index.html.erb
221
197
  - spec/dummy/app/views/layouts/application.html.erb
222
198
  - spec/dummy/bin/bundle
223
199
  - spec/dummy/bin/rails