thin_man 0.1.0 → 0.2.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 +4 -4
- data/app/assets/javascripts/ajax_bindings.js +17 -1
- data/lib/thin_man/ajax_helper.rb +16 -6
- data/lib/thin_man/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f694f9976865f2be6904db55f25b9fe67baf5924
|
4
|
+
data.tar.gz: d86cb2736377c899faa647e912b5b8fe7fcd094f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a9dcd0bc13ac90ad5254096bb373922194aa441cd08516cb366bf99585fe938d66500330cd3da90064becadee9187bd898844a231775e50fed434c9f4367324
|
7
|
+
data.tar.gz: 64e09ecaf6369581877f16ca99e428af4ea7d4ccb2dcab06416a13ede5263cc457c6bfb7b1c7e8e18a8763d717e21a96ac6ce5d3ca4a1cb8f51a684ae2379418
|
@@ -53,7 +53,7 @@ var AjaxSubmission = Class.extend({
|
|
53
53
|
}
|
54
54
|
},
|
55
55
|
getErrorTarget: function(){
|
56
|
-
if($(this.jq_obj.data('
|
56
|
+
if($(this.jq_obj.data('error-target')).length > 0){
|
57
57
|
this.error_target = $(this.jq_obj.data('error-target'));
|
58
58
|
}else{
|
59
59
|
this.error_target = $(this.jq_obj.data('ajax-target'));
|
@@ -113,6 +113,16 @@ var AjaxSubmission = Class.extend({
|
|
113
113
|
if ((jqXHR.status == 200) && !(typeof step === 'undefined')) {
|
114
114
|
$(form_map[step]).ScrollTo();
|
115
115
|
}
|
116
|
+
if(this.removeOnSuccess()){
|
117
|
+
if($(this.removeOnSuccess())){
|
118
|
+
$(this.removeOnSuccess()).remove();
|
119
|
+
}
|
120
|
+
}
|
121
|
+
if(this.emptyOnSuccess()){
|
122
|
+
if($(this.emptyOnSuccess())){
|
123
|
+
$(this.emptyOnSuccess()).empty();
|
124
|
+
}
|
125
|
+
}
|
116
126
|
},
|
117
127
|
ajaxComplete: function(jqXHR) {
|
118
128
|
this.showTrigger();
|
@@ -158,6 +168,12 @@ var AjaxSubmission = Class.extend({
|
|
158
168
|
}
|
159
169
|
}
|
160
170
|
},
|
171
|
+
removeOnSuccess: function(){
|
172
|
+
return this.jq_obj.data('remove-on-success')
|
173
|
+
},
|
174
|
+
emptyOnSuccess: function(){
|
175
|
+
return this.jq_obj.data('empty-on-success')
|
176
|
+
},
|
161
177
|
httpResponseToFlashStyle: function(response_code){
|
162
178
|
if([403,409,500].indexOf(response_code) > -1){
|
163
179
|
return 'error'
|
data/lib/thin_man/ajax_helper.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module ThinMan
|
2
2
|
module AjaxHelper
|
3
|
-
def ajax_link(name, options, html_options, target, sub_class
|
3
|
+
def ajax_link(name, options, html_options, target, sub_class: nil, insert_method: nil)
|
4
4
|
sub_class ||= 'true'
|
5
5
|
insert_method ||= 'html'
|
6
6
|
ajax_options = {
|
@@ -14,11 +14,21 @@ module ThinMan
|
|
14
14
|
html_options.merge(ajax_options))
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
def ajax_form_hash(target, sub_class: nil, insert_method: 'html')
|
18
|
+
ajax_options = {
|
19
|
+
'data-ajax-form' => true,
|
20
|
+
'data-ajax-target' => target,
|
21
|
+
'data-insert-method' => insert_method
|
22
|
+
}
|
23
|
+
ajax_options.merge!('data-sub-type' => sub_class) if sub_class.present?
|
24
|
+
ajax_options
|
25
|
+
end
|
26
|
+
|
27
|
+
def ajax_link_attrs(target, insert_method: nil, sub_type: nil)
|
28
|
+
data_attrs = "data-ajax-link=true data-ajax-target=#{target}"
|
29
|
+
data_attrs += " data-insert-method=#{insert_method}" if insert_method
|
30
|
+
data_attrs += " data-insert-method=#{sub_type}" if sub_type
|
31
|
+
data_attrs
|
22
32
|
end
|
23
33
|
|
24
34
|
def dom_target(resource)
|
data/lib/thin_man/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thin_man
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Draut, Adam Bialek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|