thin_man 0.12.3 → 0.13.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: 7876c85cc5ac8eba96b68d282342768f4c324fea
4
- data.tar.gz: 5d6e382a7d82aa90622dfaf35cd9a72630f58208
3
+ metadata.gz: 87711557897ed02cc919dca89d0247eafeb8c3fd
4
+ data.tar.gz: 275053997334c8b1628635c3ab95494b0de31cc3
5
5
  SHA512:
6
- metadata.gz: 9f89b005636a4a6994b1bc23f64d9ca9d45dcdcf13c2e4166f5f44d3754a3c55cee066cec6e63fda161e0b530b05cb30e9560312335d52167bb8ff99d71c3a03
7
- data.tar.gz: 008f8123e5847514aafff0168dfb392c5c50feb633f2acf975332cb63ebc6aab09a2b16206d62cda84e6d82c39a2cbf71c1741ffcf195c520c47493f6050cccd
6
+ metadata.gz: e82988c3cb2edaafa892b1856b9b327b9cf8eaa8321e80c246d79f67a5d28030aeae79e728255f552269362911a7b9a7055bfafbd1dcbd3cc12f1ffc098e8b60
7
+ data.tar.gz: 9637ea2eac2db6f5a3cf74bddc81c32b81eb42cb2af640d5c99cc9e9e7bd2c45b74e4424525d4f2cade9e26a472f19ca6474c2ca6a4b280a3255dffa273a3921
@@ -13,6 +13,10 @@ var initThinMan = function(){
13
13
  this.jq_obj = jq_obj;
14
14
  this.params = params;
15
15
  if(!this.params){ this.params = {}}
16
+ // Bail out if this is a no-mouse-click ajax element and we were mouse clicked
17
+ if(this.wasMouseClicked() && this.noMouseClick()){
18
+ return false;
19
+ }
16
20
  this.getTrigger();
17
21
  this.getTarget();
18
22
  this.getErrorTarget();
@@ -47,13 +51,7 @@ var initThinMan = function(){
47
51
  getTarget: function(){
48
52
  var target_selector = this.jq_obj.data('ajax-target');
49
53
  if(target_selector){
50
- if($(target_selector).length > 0){
51
- this.target = $(target_selector);
52
- }else{
53
- console.log('Warning! Thin Man selector ' + target_selector + ' not found')
54
- }
55
- }else{
56
- console.log('Warning! Thin Man selector not given')
54
+ this.target = $(target_selector);
57
55
  }
58
56
  },
59
57
  getErrorTarget: function(){
@@ -227,6 +225,12 @@ var initThinMan = function(){
227
225
  return 'success'
228
226
  }
229
227
  return 'error'
228
+ },
229
+ wasMouseClicked: function(){
230
+ return this.params.e && this.params.e.type && this.params.e.type == 'click'
231
+ },
232
+ noMouseClick: function(){
233
+ this.jq_obj.data('no-mouse-click')
230
234
  }
231
235
  }),
232
236
  AjaxBrowserPushConnector: Class.extend({
@@ -535,24 +539,24 @@ var initThinMan = function(){
535
539
  window.any_time_manager.load();
536
540
 
537
541
  $(document).ready(function(){
538
- $(document).on('click','[data-ajax-link],[data-ajax-link-now]',function(e){
542
+ $(document).on('click apiclick','[data-ajax-link],[data-ajax-link-now]',function(e){
539
543
  e.preventDefault();
540
544
  var this_class = eval('thin_man.' + thin_man.getSubClass($(this).data('sub-type'),'AjaxLinkSubmission'));
541
- var submission = new this_class($(this));
545
+ var submission = new this_class($(this),{e: e});
542
546
  return false;
543
547
  });
544
548
 
545
- $(document).on('submit','[data-ajax-form]',function(e){
549
+ $(document).on('submit apisubmit','[data-ajax-form]',function(e){
546
550
  e.preventDefault();
547
551
  var this_class = eval('thin_man.' + thin_man.getSubClass($(this).data('sub-type'),'AjaxFormSubmission'));
548
- var submission = new this_class($(this));
552
+ var submission = new this_class($(this),{e: e});
549
553
  return false;
550
554
  });
551
555
 
552
- $(document).on('click','[data-ajax-delete]',function(e){
556
+ $(document).on('click apiclick','[data-ajax-delete]',function(e){
553
557
  e.preventDefault();
554
558
  var this_class = eval('thin_man.' + thin_man.getSubClass($(this).data('sub-type'),'DeleteLink'));
555
- var deletion = new this_class($(this));
559
+ var deletion = new this_class($(this),{e: e});
556
560
  });
557
561
  $(document).on('click', '[data-change-url]',function(e){
558
562
  e.preventDefault();
@@ -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, empty_on_success: nil, http_method: nil)
3
+ def ajax_link(name, options, html_options, target, sub_class: nil, insert_method: nil, empty_on_success: nil, http_method: nil, no_mouse_click: nil)
4
4
  ajax_options = {
5
5
  'data-ajax-link' => true,
6
6
  'data-ajax-target' => target
@@ -9,6 +9,7 @@ module ThinMan
9
9
  ajax_options.merge!('data-insert-method' => insert_method) if insert_method.present?
10
10
  ajax_options.merge!('data-ajax-method' => http_method) if http_method.present?
11
11
  ajax_options.merge!('data-empty-on-success' => empty_on_success) if empty_on_success.present?
12
+ ajax_options.merge!('data-no-mouse-click' => no_mouse_click) if no_mouse_click.present?
12
13
  link_to(name,
13
14
  options,
14
15
  html_options.merge(ajax_options))
@@ -28,7 +29,7 @@ module ThinMan
28
29
  html_options.merge(ajax_options))
29
30
  end
30
31
 
31
- def ajax_delete(name, options, html_options, target, sub_class: nil, replace_response: false, no_confirm: false, custom_progress: nil)
32
+ def ajax_delete(name, options, html_options, target, sub_class: nil, replace_response: false, no_confirm: false, custom_progress: nil, no_mouse_click: nil)
32
33
  ajax_options = {
33
34
  'data-ajax-delete' => true,
34
35
  'data-ajax-target' => target
@@ -37,12 +38,13 @@ module ThinMan
37
38
  ajax_options.merge!('data-replace-response' => true) if replace_response
38
39
  ajax_options.merge!('data-no-confirm' => true) if no_confirm
39
40
  ajax_options.merge!('data-custom-progress' => custom_progress) if custom_progress.present?
41
+ ajax_options.merge!('data-no-mouse-click' => no_mouse_click) if no_mouse_click.present?
40
42
  link_to(name,
41
43
  options,
42
44
  html_options.merge(ajax_options))
43
45
  end
44
46
 
45
- def ajax_form_hash(target, sub_class: nil, insert_method: nil, error_target: nil, empty_on_success: nil, reset_on_success: nil, container: nil, custom_progress: nil)
47
+ def ajax_form_hash(target, sub_class: nil, insert_method: nil, error_target: nil, empty_on_success: nil, reset_on_success: nil, container: nil, custom_progress: nil, no_mouse_click: nil)
46
48
  ajax_options = {
47
49
  'data-ajax-form' => true,
48
50
  'data-ajax-target' => target
@@ -54,25 +56,28 @@ module ThinMan
54
56
  ajax_options.merge!('data-empty-on-success' => empty_on_success) if empty_on_success.present?
55
57
  ajax_options.merge!('data-reset-on-success' => reset_on_success) if reset_on_success.present?
56
58
  ajax_options.merge!('data-custom-progress' => custom_progress) if custom_progress.present?
59
+ ajax_options.merge!('data-no-mouse-click' => no_mouse_click) if no_mouse_click.present?
57
60
  ajax_options
58
61
  end
59
62
 
60
- def ajax_form_attrs(target, sub_class: nil, insert_method: nil, error_target: nil, empty_on_success: nil, reset_on_success: nil)
63
+ def ajax_form_attrs(target, sub_class: nil, insert_method: nil, error_target: nil, empty_on_success: nil, reset_on_success: nil, no_mouse_click: nil)
61
64
  data_attrs = "data-ajax-form=true data-ajax-target=#{target}"
62
65
  data_attrs += " data-insert-method=#{insert_method}" if insert_method
63
66
  data_attrs += " data-sub-type=#{sub_class}" if sub_class
64
67
  data_attrs += " data-empty-on-success=#{empty_on_success}" if empty_on_success
65
68
  data_attrs += " data-reset-on-success=#{reset_on_success}" if reset_on_success
66
69
  data_attrs += " data-error-target=#{error_target}" if error_target
70
+ data_attrs += " data-no-mouse-click=#{no_mouse_click}" if no_mouse_click
67
71
  data_attrs
68
72
  end
69
73
 
70
- def ajax_link_attrs(target, insert_method: nil, sub_type: nil, empty_on_success: nil, http_method: nil)
74
+ def ajax_link_attrs(target, insert_method: nil, sub_type: nil, empty_on_success: nil, http_method: nil, no_mouse_click: nil)
71
75
  data_attrs = "data-ajax-link=true data-ajax-target=#{target}"
72
76
  data_attrs += " data-insert-method=#{insert_method}" if insert_method
73
77
  data_attrs += " data-ajax-method=#{http_method}" if http_method
74
78
  data_attrs += " data-sub-type=#{sub_type}" if sub_type
75
79
  data_attrs += " data-empty-on-success=#{empty_on_success}" if empty_on_success
80
+ data_attrs += " data-no-mouse-click=#{no_mouse_click}" if no_mouse_click
76
81
  data_attrs
77
82
  end
78
83
 
@@ -1,3 +1,3 @@
1
1
  module ThinMan
2
- VERSION = "0.12.3"
2
+ VERSION = "0.13.0"
3
3
  end
@@ -182,30 +182,5 @@ describe("thin_man", function(){
182
182
  });
183
183
  });
184
184
 
185
- describe("Log", function(){
186
- beforeEach(function(){
187
- spyOn(console, 'log');
188
- });
189
-
190
- it("Don't show a warning with a valid target", function(){
191
- $link = affix('a[data-ajax-link="true"][data-ajax-target="#test_dom_id"]');
192
- $target = affix('#test_dom_id');
193
- thin = new thin_man.AjaxLinkSubmission($link);
194
- expect(console.log).not.toHaveBeenCalled();
195
- });
196
-
197
- it("Show a warning when target not found", function(){
198
- $link = affix('a[data-ajax-link="true"][data-ajax-target="#not_valid_target"]');
199
- thin = new thin_man.AjaxLinkSubmission($link);
200
- expect(console.log).toHaveBeenCalledWith('Warning! Thin Man selector #not_valid_target not found');
201
- });
202
-
203
- it("Show a warning when target not provided", function(){
204
- $link = affix('a[data-ajax-link="true"]');
205
- thin = new thin_man.AjaxLinkSubmission($link);
206
- expect(console.log).toHaveBeenCalledWith('Warning! Thin Man selector not given');
207
- });
208
- });
209
-
210
185
  });
211
186
  });
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.12.3
4
+ version: 0.13.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: 2016-02-11 00:00:00.000000000 Z
11
+ date: 2016-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  version: '0'
93
93
  requirements: []
94
94
  rubyforge_project:
95
- rubygems_version: 2.4.5.1
95
+ rubygems_version: 2.5.1
96
96
  signing_key:
97
97
  specification_version: 4
98
98
  summary: A Rails library that makes web apps lively while keeping all the logic on