thin_man 0.16.0 → 0.17.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/thin_man.js +18 -0
- data/lib/thin_man/ajax_helper.rb +10 -2
- data/lib/thin_man/version.rb +1 -1
- data/test/javascript/spec/thinManSpec.js +2 -2
- data/test/thin_man_test.rb +7 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c06e9191250030954e43aa80ec1039a04387c6da
|
4
|
+
data.tar.gz: 5f79ff39a656093021667941d8aea2accffd4749
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a84356d1c56ca333fcc91aa5a27b1cbb84438228daec8c86e2076c925daa416f210120aaaab845acc93e383563bb7dde58dd49f858573ab9e2848536eb8a1eb
|
7
|
+
data.tar.gz: 2edf5c8474575ecf040aa91f958cc74b6c2f0cc7c6f86b52b324089a837d83159b8900f5e3a0a34d3e73ee746a4396467e9b6625406ab0a37ccc59640c684183
|
@@ -23,6 +23,7 @@ var initThinMan = function(){
|
|
23
23
|
this.progress_color = jq_obj.data('progress-color');
|
24
24
|
this.progress_target = $(jq_obj.data('progress-target'));
|
25
25
|
this.custom_progress = typeof(jq_obj.data('custom-progress')) != 'undefined';
|
26
|
+
this.scroll_to = jq_obj.data('scroll-to')
|
26
27
|
if(this.progress_target.length == 0 && this.trigger.length > 0){
|
27
28
|
this.progress_target = this.trigger
|
28
29
|
this.trigger_is_progress_target = true
|
@@ -93,6 +94,23 @@ var initThinMan = function(){
|
|
93
94
|
}
|
94
95
|
});
|
95
96
|
}
|
97
|
+
if(this.scroll_to){
|
98
|
+
if(this.target.not(':visible')){
|
99
|
+
if(this.target.parents('[data-tab-id]').length > 0){
|
100
|
+
this.target.parents('[data-tab-id]').each(function(){
|
101
|
+
var tab_key = $(this).data('tab-id')
|
102
|
+
$('[data-tab-target-id="' + tab_key + '"]').trigger('click')
|
103
|
+
})
|
104
|
+
}
|
105
|
+
}
|
106
|
+
var extra_offset = 0
|
107
|
+
if($('[data-thin-man-offset]').length > 0){
|
108
|
+
extra_offset = $('[data-thin-man-offset]').outerHeight()
|
109
|
+
}
|
110
|
+
$('html, body').animate({
|
111
|
+
scrollTop: this.target.offset().top - extra_offset
|
112
|
+
}, 1000);
|
113
|
+
}
|
96
114
|
}
|
97
115
|
},
|
98
116
|
refocus: function(){
|
data/lib/thin_man/ajax_helper.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
module ThinMan
|
2
2
|
module AjaxHelper
|
3
|
-
def ajax_link(name, options, html_options, target,
|
3
|
+
def ajax_link(name, options, html_options, target,
|
4
|
+
sub_class: nil, insert_method: nil, empty_on_success: nil,
|
5
|
+
http_method: nil, no_mouse_click: nil, progress_target: nil,
|
6
|
+
progress_color: nil, scroll_to: nil)
|
4
7
|
ajax_options = {
|
5
8
|
'data-ajax-link' => true,
|
6
9
|
'data-ajax-target' => target
|
@@ -12,6 +15,7 @@ module ThinMan
|
|
12
15
|
ajax_options.merge!('data-no-mouse-click' => no_mouse_click) if no_mouse_click.present?
|
13
16
|
ajax_options.merge!('data-progress-target' => progress_target) if progress_target.present?
|
14
17
|
ajax_options.merge!('data-progress-color' => progress_color) if progress_color.present?
|
18
|
+
ajax_options.merge!('data-scroll-to' => scroll_to) if scroll_to.present?
|
15
19
|
link_to(name,
|
16
20
|
options,
|
17
21
|
html_options.merge(ajax_options))
|
@@ -109,7 +113,10 @@ module ThinMan
|
|
109
113
|
data_attrs
|
110
114
|
end
|
111
115
|
|
112
|
-
def ajax_link_attrs(target,
|
116
|
+
def ajax_link_attrs(target,
|
117
|
+
insert_method: nil, sub_type: nil, empty_on_success: nil,
|
118
|
+
http_method: nil, no_mouse_click: nil, progress_target: nil,
|
119
|
+
progress_color: nil, scroll_to: nil)
|
113
120
|
data_attrs = "data-ajax-link=true data-ajax-target=#{target}"
|
114
121
|
data_attrs += " data-insert-method=#{insert_method}" if insert_method
|
115
122
|
data_attrs += " data-ajax-method=#{http_method}" if http_method
|
@@ -118,6 +125,7 @@ module ThinMan
|
|
118
125
|
data_attrs += " data-no-mouse-click=#{no_mouse_click}" if no_mouse_click
|
119
126
|
data_attrs += " data-progress-target=#{progress_target}" if progress_target
|
120
127
|
data_attrs += " data-progress-color=#{progress_color}" if progress_color
|
128
|
+
data_attrs += " data-scroll-to=#{scroll_to}" if scroll_to
|
121
129
|
data_attrs
|
122
130
|
end
|
123
131
|
|
data/lib/thin_man/version.rb
CHANGED
@@ -151,11 +151,11 @@ describe("thin_man", function(){
|
|
151
151
|
|
152
152
|
it("serialize data", function(){
|
153
153
|
$form.affix('input[type="text"][name="name"][value="Jon Snow"]');
|
154
|
-
thin_man.AjaxFormSubmission($form);
|
154
|
+
var thin = new thin_man.AjaxFormSubmission($form);
|
155
155
|
spyOn($, 'ajax');
|
156
156
|
$form.submit();
|
157
157
|
expect($.ajax).toHaveBeenCalled();
|
158
|
-
expect(
|
158
|
+
expect(thin.ajax_options.data).toEqual([{ name: 'name', value: 'Jon Snow' },{name: 'thin_man_submitter', value: 'link_now'}]);
|
159
159
|
});
|
160
160
|
|
161
161
|
it(".getProcessData", function(){
|
data/test/thin_man_test.rb
CHANGED
@@ -13,6 +13,7 @@ class ThinManTest < ActionView::TestCase
|
|
13
13
|
@no_mouse_click = true
|
14
14
|
@progress_target = '#progress_element'
|
15
15
|
@progress_color = 'blue'
|
16
|
+
@scroll_to = true
|
16
17
|
|
17
18
|
@replace_response = true
|
18
19
|
@no_confirm = true
|
@@ -20,7 +21,11 @@ class ThinManTest < ActionView::TestCase
|
|
20
21
|
end
|
21
22
|
|
22
23
|
it "generates ajax link hash" do
|
23
|
-
test_link = ajax_link('test link', "http://test.com", @html_options, @target,
|
24
|
+
test_link = ajax_link('test link', "http://test.com", @html_options, @target,
|
25
|
+
insert_method: @insert_method, empty_on_success: @empty_on_success,
|
26
|
+
http_method: @http_method, no_mouse_click: @no_mouse_click,
|
27
|
+
progress_target: @progress_target, progress_color: @progress_color,
|
28
|
+
scroll_to: @scroll_to)
|
24
29
|
test_link.must_match "data-ajax-link="
|
25
30
|
test_link.must_match(/class=.test_class./)
|
26
31
|
test_link.must_match "data-ajax-target=\"#{@target}\""
|
@@ -30,6 +35,7 @@ class ThinManTest < ActionView::TestCase
|
|
30
35
|
test_link.must_match "data-no-mouse-click=\"#{@no_mouse_click}\""
|
31
36
|
test_link.must_match "data-progress-target=\"#{@progress_target}\""
|
32
37
|
test_link.must_match "data-progress-color=\"#{@progress_color}\""
|
38
|
+
test_link.must_match "data-scroll-to=\"#{@scroll_to}\""
|
33
39
|
end
|
34
40
|
|
35
41
|
it "generates an instant link" do
|
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.17.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: 2017-
|
11
|
+
date: 2017-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -64,6 +64,20 @@ dependencies:
|
|
64
64
|
- - "<"
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: '3'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: rake
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
type: :development
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
67
81
|
description: 'A Rails library that makes web apps lively while keeping all the logic
|
68
82
|
on the server. '
|
69
83
|
email:
|