turboboost 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a62f444668b545d3f748164b0a7ad8d0f6ddce5f
4
- data.tar.gz: 380c2f65d317b85a0597b4fdd529c5bf5fe19511
3
+ metadata.gz: 1e54f385fd5a0fb3aeb452f91f9a84df07f86ea3
4
+ data.tar.gz: 010b5b416127a3ec3ebafa35b05004734ac71950
5
5
  SHA512:
6
- metadata.gz: 11cff951ad36b13036fd84adf7cd87dbd8664c78b3e6b0572add842b6caab25b4f0c855ad047aa219bb0de37fc5f964f3e3c54c79e54497c7d53ded5d6742971
7
- data.tar.gz: e8f6dbac731bab61e458176ce116b389a0f5252c6a1081aeb549ecf023dfaacbbd56d3b4906e6cc90487533d66c37dcb80cf99b516afc69dd896d3aeb30b083a
6
+ metadata.gz: 0164cd06e9387aa2b611245fbb8760f48821a406e24ecb68be18046194161d0f3234cf0cdcb28a76cb59b9ae759c54ecb4ed3868625d153b7fb7f4fc1efe4ea1
7
+ data.tar.gz: d735cfb64bc74194e124c0372ed83f9c3835fe311649f85c88f1cf5ba4a87b25c169669073415b6f4ead73871e59688312cdfdd8bcf68fccad02139df4df9333
data/Gemfile CHANGED
@@ -6,4 +6,3 @@ gem 'mocha'
6
6
  gem 'turn'
7
7
  gem 'awesome_print'
8
8
  gem 'sqlite3'
9
- gem 'appraisal'
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- turboboost (0.0.12)
4
+ turboboost (0.1.0)
5
5
  coffee-rails
6
6
  jquery-rails
7
7
  railties
@@ -30,8 +30,7 @@ GEM
30
30
  thread_safe (~> 0.3, >= 0.3.4)
31
31
  tzinfo (~> 1.1)
32
32
  ansi (1.4.3)
33
- appraisal (2.0.1)
34
- activesupport (>= 3.2.21)
33
+ appraisal (2.1.0)
35
34
  bundler
36
35
  rake
37
36
  thor (>= 0.14.0)
@@ -55,13 +54,13 @@ GEM
55
54
  loofah (2.0.2)
56
55
  nokogiri (>= 1.5.9)
57
56
  metaclass (0.0.1)
58
- mini_portile (0.6.2)
57
+ mini_portile2 (2.1.0)
59
58
  minitest (5.7.0)
60
59
  mocha (0.14.0)
61
60
  metaclass (~> 0.0.1)
62
- nokogiri (1.6.6.2)
63
- mini_portile (~> 0.6.0)
64
- rack (1.6.1)
61
+ nokogiri (1.6.8.1)
62
+ mini_portile2 (~> 2.1.0)
63
+ rack (1.6.4)
65
64
  rack-test (0.6.3)
66
65
  rack (>= 1.0)
67
66
  rails-deprecated_sanitizer (1.0.3)
@@ -92,7 +91,7 @@ PLATFORMS
92
91
  ruby
93
92
 
94
93
  DEPENDENCIES
95
- appraisal
94
+ appraisal (~> 2.1)
96
95
  awesome_print
97
96
  bundler (~> 1.3)
98
97
  mocha
@@ -100,3 +99,6 @@ DEPENDENCIES
100
99
  sqlite3
101
100
  turboboost!
102
101
  turn
102
+
103
+ BUNDLED WITH
104
+ 1.13.2
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## Turboboost ##
2
2
 
3
- Turboboost extends the power of Turbolinks into the forms of your Rails app and provides additional convenient AJAX handlers for forms and links. It aims to be a seemless and logical addition to any Turbolinks-rocking Rails 3.2/4+ app. Currently it depends on jQuery. The main features are:
3
+ Turboboost extends the power of Turbolinks into the forms of your Rails app and provides additional convenient AJAX handlers for forms and links. It aims to be a seemless and logical addition to any Turbolinks-rocking Rails 3.2+ app. Currently it depends on jQuery. The main features are:
4
4
 
5
5
  * Form response redirection is handled by Turbolinks.
6
6
  * Customizable success and error handling through registered JavaScript, with support for Rails' Flash and optional error rendering built-in.
@@ -7,11 +7,14 @@ turboboostable = "[data-turboboost]"
7
7
  errID = "#error_explanation"
8
8
  errTemplate = (errors) ->
9
9
  "<ul><li>#{$.makeArray(errors).join('</li><li>')}</li></ul>"
10
+ formProcessingClass = 'turboboost-form-processing'
10
11
 
11
12
  enableForm = ($form) ->
13
+ $form.removeClass(formProcessingClass)
12
14
  $form.find("[type='submit']").removeAttr('disabled').data('turboboostDisabled', false)
13
15
 
14
16
  disableForm = ($form) ->
17
+ $form.addClass(formProcessingClass)
15
18
  $form.find("[type='submit']").attr('disabled', 'disabled').data('turboboostDisabled', true)
16
19
 
17
20
  tryJSONParse = (str) ->
@@ -46,8 +49,9 @@ turboboostFormError = (e, errors) ->
46
49
  turboboostComplete = (e, resp) ->
47
50
  $el = $(@)
48
51
  isForm = @nodeName is "FORM"
52
+ status = parseInt(resp.status)
49
53
 
50
- if 200 <= resp.status < 300
54
+ if 200 <= status < 300
51
55
  $el.trigger "turboboost:success", tryJSONParse resp.getResponseHeader('X-Flash')
52
56
  $el.find(errID).remove() if Turboboost.insertErrors and isForm
53
57
  if (location = resp.getResponseHeader('Location')) and !$el.attr('data-no-turboboost-redirect')
@@ -58,13 +62,13 @@ turboboostComplete = (e, resp) ->
58
62
  else
59
63
  enableForm $el if isForm and Turboboost.handleFormDisabling
60
64
  $inserted = maybeInsertSuccessResponseBody(resp)
61
- else if 400 <= resp.status < 600
65
+ else if 400 <= status < 600
62
66
  enableForm $el if isForm and Turboboost.handleFormDisabling
63
67
  $el.trigger "turboboost:error", resp.responseText
64
68
 
65
69
  if $.contains(document.documentElement, $el[0])
66
70
  $el.trigger "turboboost:complete"
67
- else
71
+ else if $inserted
68
72
  $inserted.trigger "turboboost:complete"
69
73
 
70
74
  turboboostBeforeSend = (e, xhr, settings) ->
@@ -72,7 +76,7 @@ turboboostBeforeSend = (e, xhr, settings) ->
72
76
  isForm = @nodeName is "FORM"
73
77
  return e.stopPropagation() unless isForm
74
78
  $el = $(@)
75
- disableForm $el if Turboboost.handleFormDisabling
79
+ disableForm $el if isForm and Turboboost.handleFormDisabling
76
80
  if settings.type is "GET" and !$el.attr('data-no-turboboost-redirect')
77
81
  Turbolinks.visit [@action, $el.serialize()].join("?")
78
82
  return false
@@ -101,7 +105,7 @@ maybeInsertSuccessResponseBody = (resp) ->
101
105
 
102
106
  maybeReenableForms = ->
103
107
  return unless Turboboost.handleFormDisabling
104
- $("form#{turboboostable} input[type='submit']").each ->
108
+ $("form#{turboboostable} [type='submit']").each ->
105
109
  enableForm $(@).closest('form') if $(@).data('turboboostDisabled')
106
110
 
107
111
  $(document)
@@ -6,7 +6,6 @@ gem "mocha"
6
6
  gem "turn"
7
7
  gem "awesome_print"
8
8
  gem "sqlite3"
9
- gem "appraisal"
10
9
  gem "rails", "~> 3.2.21"
11
10
  gem "test-unit"
12
11
  gem "strong_parameters"
@@ -6,7 +6,6 @@ gem "mocha"
6
6
  gem "turn"
7
7
  gem "awesome_print"
8
8
  gem "sqlite3"
9
- gem "appraisal"
10
9
  gem "rails", "~> 4.0.13"
11
10
 
12
11
  gemspec :path => "../"
@@ -6,7 +6,6 @@ gem "mocha"
6
6
  gem "turn"
7
7
  gem "awesome_print"
8
8
  gem "sqlite3"
9
- gem "appraisal"
10
9
  gem "rails", "~> 4.1.9"
11
10
 
12
11
  gemspec :path => "../"
@@ -6,7 +6,6 @@ gem "mocha"
6
6
  gem "turn"
7
7
  gem "awesome_print"
8
8
  gem "sqlite3"
9
- gem "appraisal"
10
9
  gem "rails", "~> 4.2.0"
11
10
  gem "responders", "~> 2.0"
12
11
 
@@ -5,7 +5,7 @@ require 'turboboost/version'
5
5
  module Turboboost
6
6
  class Engine < Rails::Engine
7
7
  initializer :turboboost do
8
- ActionView::Base.send :include, Turboboost::FormHelper
8
+ ActionView::Base.send :prepend, Turboboost::FormHelper
9
9
  end
10
10
  end
11
11
  end
@@ -1,35 +1,25 @@
1
1
  module Turboboost
2
- # borrowed from - https://github.com/fs/turboforms/blob/master/lib/turboforms.rb
3
2
  module FormHelper
4
3
  extend ActiveSupport::Concern
5
4
 
6
- included do
7
- alias_method_chain :form_for, :data_turboboost
8
- alias_method_chain :form_tag, :data_turboboost
9
- end
10
-
11
- def form_for_with_data_turboboost(record_or_name_or_array, *args, &proc)
5
+ def form_for(record_or_name_or_array, *args, &proc)
12
6
  options = args.extract_options!
13
-
14
7
  if options.key?(:turboboost) && options.delete(:turboboost)
15
8
  options[:html] ||= {}
16
9
  options[:html]['data-turboboost'] = true
17
10
  options[:remote] = true
18
11
  end
19
-
20
- form_for_without_data_turboboost(record_or_name_or_array, *(args << options), &proc)
12
+ super(record_or_name_or_array, *(args << options), &proc)
21
13
  end
22
14
 
23
- def form_tag_with_data_turboboost(record_or_name_or_array, *args, &proc)
15
+ def form_tag(url_for_options = {}, *args, &proc)
24
16
  options = args.extract_options!
25
-
26
17
  if options.key?(:turboboost) && options.delete(:turboboost)
27
18
  options[:data] ||= {}
28
19
  options[:data]['turboboost'] = true
29
20
  options[:remote] = true
30
21
  end
31
-
32
- form_tag_without_data_turboboost(record_or_name_or_array, *(args << options), &proc)
22
+ super(url_for_options, *(args << options), &proc)
33
23
  end
34
24
 
35
25
  def convert_options_to_data_attributes(options, html_options)
@@ -1,3 +1,3 @@
1
1
  module Turboboost
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -25,4 +25,5 @@ Gem::Specification.new do |spec|
25
25
 
26
26
  spec.add_development_dependency 'bundler', '~> 1.3'
27
27
  spec.add_development_dependency 'rake', '~> 0'
28
+ spec.add_development_dependency 'appraisal', '~> 2.1'
28
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turboboost
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Talbott
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-18 00:00:00.000000000 Z
11
+ date: 2017-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: appraisal
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.1'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.1'
97
111
  description: Enhanced AJAX handling for Rails apps.
98
112
  email:
99
113
  - justin@waymondo.com
@@ -148,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
162
  version: '0'
149
163
  requirements: []
150
164
  rubyforge_project:
151
- rubygems_version: 2.4.5
165
+ rubygems_version: 2.6.7
152
166
  signing_key:
153
167
  specification_version: 4
154
168
  summary: Turboboost extends the power of Turbolinks into the forms of your Rails app