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 +4 -4
- data/Gemfile +0 -1
- data/Gemfile.lock +10 -8
- data/README.md +1 -1
- data/app/assets/javascripts/turboboost/turboboost.js.coffee +9 -5
- data/gemfiles/rails_3_2.gemfile +0 -1
- data/gemfiles/rails_4_0.gemfile +0 -1
- data/gemfiles/rails_4_1.gemfile +0 -1
- data/gemfiles/rails_4_2.gemfile +0 -1
- data/lib/turboboost.rb +1 -1
- data/lib/turboboost/form_helper.rb +4 -14
- data/lib/turboboost/version.rb +1 -1
- data/turboboost.gemspec +1 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e54f385fd5a0fb3aeb452f91f9a84df07f86ea3
|
4
|
+
data.tar.gz: 010b5b416127a3ec3ebafa35b05004734ac71950
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0164cd06e9387aa2b611245fbb8760f48821a406e24ecb68be18046194161d0f3234cf0cdcb28a76cb59b9ae759c54ecb4ed3868625d153b7fb7f4fc1efe4ea1
|
7
|
+
data.tar.gz: d735cfb64bc74194e124c0372ed83f9c3835fe311649f85c88f1cf5ba4a87b25c169669073415b6f4ead73871e59688312cdfdd8bcf68fccad02139df4df9333
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
turboboost (0.0
|
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
|
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
|
-
|
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.
|
63
|
-
|
64
|
-
rack (1.6.
|
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
|
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 <=
|
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 <=
|
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}
|
108
|
+
$("form#{turboboostable} [type='submit']").each ->
|
105
109
|
enableForm $(@).closest('form') if $(@).data('turboboostDisabled')
|
106
110
|
|
107
111
|
$(document)
|
data/gemfiles/rails_3_2.gemfile
CHANGED
data/gemfiles/rails_4_0.gemfile
CHANGED
data/gemfiles/rails_4_1.gemfile
CHANGED
data/gemfiles/rails_4_2.gemfile
CHANGED
data/lib/turboboost.rb
CHANGED
@@ -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
|
-
|
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
|
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)
|
data/lib/turboboost/version.rb
CHANGED
data/turboboost.gemspec
CHANGED
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.
|
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:
|
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.
|
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
|