thin_man 0.1.0 → 0.2.0

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: c809ccc6d7ac0b149fea6adf82696fd60348e9a4
4
- data.tar.gz: 035191d038c34b40ae8987d0c591b40d502ab271
3
+ metadata.gz: f694f9976865f2be6904db55f25b9fe67baf5924
4
+ data.tar.gz: d86cb2736377c899faa647e912b5b8fe7fcd094f
5
5
  SHA512:
6
- metadata.gz: d3b3d966213f7dc3ae399b2b70c3629ac0a90151034f48c900a388026339f24a8b7094f1e5dab7cd1ff9f8b3e34406edb495ad455b9a592265ce6916d9cd7c02
7
- data.tar.gz: 68174b0c702918cb316fac5cf5f6b76bfa528baddc20b2e21883183b84708e768734e6b72aebbf3b38a75f1011acaef8c790567efb6230ac4937f8e55ac5c835
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('error_target')).length > 0){
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'
@@ -1,6 +1,6 @@
1
1
  module ThinMan
2
2
  module AjaxHelper
3
- def ajax_link(name, options, html_options, target, sub_class=nil, insert_method=nil)
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 ajax_hash(target, method='html')
18
- { data: {
19
- ajax_form: true,
20
- ajax_target: target,
21
- insert_method: method } }
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)
@@ -1,3 +1,3 @@
1
1
  module ThinMan
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.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-19 00:00:00.000000000 Z
11
+ date: 2015-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails