on_the_spot 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -0
- data/History.md +6 -1
- data/VERSION +1 -1
- data/app/assets/javascripts/on_the_spot_code.js +17 -13
- data/lib/on_the_spot/on_the_spot_helpers.rb +7 -11
- data/on_the_spot.gemspec +3 -2
- data/spec/on_the_spot_spec.rb +19 -11
- metadata +5 -4
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--backtrace
|
data/History.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# Change History / Release Notes
|
2
2
|
|
3
|
-
## Version 0.0.
|
3
|
+
## Version 0.0.17 (1/11/2011)
|
4
|
+
|
5
|
+
* added support for `onblur` action: when focus is lost, allow to autosave.
|
6
|
+
* make sure that the loadurl can also work if not using a select. This allows the usage of TinyMCE, Markdown or otherwise formatted editable content.
|
7
|
+
|
8
|
+
## Version 0.0.16 (12/10/2011)
|
4
9
|
|
5
10
|
* added support for checkboxes (thanks to Peter Savichev)
|
6
11
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.17
|
@@ -11,19 +11,21 @@ $(document).ready(function() {
|
|
11
11
|
});
|
12
12
|
|
13
13
|
function initializeOnTheSpot(n){
|
14
|
-
var el
|
15
|
-
auth_token
|
16
|
-
data_url
|
17
|
-
ok_text
|
18
|
-
cancel_text
|
19
|
-
tooltip_text
|
20
|
-
edit_type
|
21
|
-
select_data
|
22
|
-
rows
|
23
|
-
columns
|
24
|
-
load_url
|
25
|
-
selected
|
26
|
-
|
14
|
+
var el = $(this),
|
15
|
+
auth_token = el.attr('data-auth'),
|
16
|
+
data_url = el.attr('data-url'),
|
17
|
+
ok_text = el.attr('data-ok') || 'OK',
|
18
|
+
cancel_text = el.attr('data-cancel') || 'Cancel',
|
19
|
+
tooltip_text = el.attr('data-tooltip') || 'Click to edit ...',
|
20
|
+
edit_type = el.attr('data-edittype'),
|
21
|
+
select_data = el.attr('data-select'),
|
22
|
+
rows = el.attr('data-rows'),
|
23
|
+
columns = el.attr('data-columns'),
|
24
|
+
load_url = el.attr('data-loadurl'),
|
25
|
+
selected = el.attr('data-selected'),
|
26
|
+
onblur_action = el.attr('data-onblur') || 'cancel',
|
27
|
+
callback = el.attr('data-callback');
|
28
|
+
|
27
29
|
|
28
30
|
var options = {
|
29
31
|
tooltip: tooltip_text,
|
@@ -36,6 +38,8 @@ function initializeOnTheSpot(n){
|
|
36
38
|
//just show the error-msg for now
|
37
39
|
alert(xhr.responseText);
|
38
40
|
},
|
41
|
+
loadurl: load_url,
|
42
|
+
onblur: onblur_action,
|
39
43
|
submitdata: {
|
40
44
|
authenticity_token: auth_token,
|
41
45
|
_method: 'put'
|
@@ -34,7 +34,6 @@ module OnTheSpot
|
|
34
34
|
:rows => 5,
|
35
35
|
:columns => 40,
|
36
36
|
:url => {:action => 'update_attribute_on_the_spot'}
|
37
|
-
|
38
37
|
)
|
39
38
|
|
40
39
|
update_url = url_for(options[:url])
|
@@ -47,16 +46,11 @@ module OnTheSpot
|
|
47
46
|
|
48
47
|
editable_type = options[:type].nil? ? nil : options[:type].to_sym
|
49
48
|
html_options[:'data-edittype'] = editable_type.to_s unless editable_type.nil?
|
50
|
-
if editable_type == :select
|
51
|
-
# we
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
# we should find a hash
|
56
|
-
select_data = options[:data]
|
57
|
-
raise OnTheSpotMissingParameters.new("Using type select needs either data or loadurl to function!") if select_data.nil?
|
58
|
-
html_options[:'data-select'] = convert_array_to_json(select_data, field_value)
|
59
|
-
end
|
49
|
+
if editable_type == :select && options[:loadurl].nil?
|
50
|
+
# we should find a hash
|
51
|
+
select_data = options[:data]
|
52
|
+
raise OnTheSpotMissingParameters.new("Using type select needs either data or loadurl to function!") if select_data.nil?
|
53
|
+
html_options[:'data-select'] = convert_array_to_json(select_data, field_value)
|
60
54
|
elsif editable_type == :textarea
|
61
55
|
html_options[:'data-rows'] = options[:rows]
|
62
56
|
html_options[:'data-columns'] = options[:columns]
|
@@ -67,6 +61,8 @@ module OnTheSpot
|
|
67
61
|
html_options[:'data-auth'] = form_authenticity_token if defined? form_authenticity_token
|
68
62
|
html_options[:'data-selected'] = options[:selected]
|
69
63
|
html_options[:'data-callback'] = options[:callback]
|
64
|
+
html_options[:'data-onblur'] = options[:onblur] if options[:onblur] && ['cancel','submit', 'ignore'].include?(options[:onblur])
|
65
|
+
html_options[:'data-loadurl'] = options[:loadurl] unless options[:loadurl].nil?
|
70
66
|
|
71
67
|
content_tag("span", html_options) do
|
72
68
|
if options[:display_text]
|
data/on_the_spot.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{on_the_spot}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.17"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Nathan Van der Auwera"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-11-06}
|
13
13
|
s.description = %q{Unobtrusive in place editing, using jEditable; only works in Rails 3}
|
14
14
|
s.email = %q{nathan@dixis.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.files = [
|
20
20
|
".bundle/config",
|
21
21
|
".document",
|
22
|
+
".rspec",
|
22
23
|
".travis.yml",
|
23
24
|
"Gemfile",
|
24
25
|
"Gemfile.lock",
|
data/spec/on_the_spot_spec.rb
CHANGED
@@ -52,56 +52,64 @@ describe "OnTheSpot" do
|
|
52
52
|
@tester.should_receive(:url_for).with({:action => 'update_attribute_on_the_spot'}).and_return('/bla')
|
53
53
|
end
|
54
54
|
|
55
|
-
it "
|
55
|
+
it "makes the correct html for an edit-field" do
|
56
56
|
@result = @tester.on_the_spot_edit @dummy, :content
|
57
57
|
@result.should == "<span class=\"on_the_spot_editing\" data-cancel=\"cancel\" data-ok=\"ok\" data-tooltip=\"tooltip\" data-url=\"/bla\" id=\"r_spec/mocks/mock__content__123\">test</span>"
|
58
58
|
end
|
59
59
|
|
60
|
-
it "
|
60
|
+
it "makes the correct html for an edit-field with text selected on click" do
|
61
61
|
@result = @tester.on_the_spot_edit @dummy, :content, :selected => true
|
62
62
|
@result.should == "<span class=\"on_the_spot_editing\" data-cancel=\"cancel\" data-ok=\"ok\" data-selected=\"true\" data-tooltip=\"tooltip\" data-url=\"/bla\" id=\"r_spec/mocks/mock__content__123\">test</span>"
|
63
63
|
end
|
64
64
|
|
65
|
-
it "
|
65
|
+
it "makes the correct html for an edit-field and overrule display-text" do
|
66
66
|
@result = @tester.on_the_spot_edit @dummy, :content, :display_text => 'jediknight'
|
67
67
|
@result.should == "<span class=\"on_the_spot_editing\" data-cancel=\"cancel\" data-ok=\"ok\" data-tooltip=\"tooltip\" data-url=\"/bla\" id=\"r_spec/mocks/mock__content__123\">jediknight</span>"
|
68
68
|
end
|
69
69
|
|
70
|
-
it "
|
70
|
+
it "makes the correct html for a text-area" do
|
71
71
|
@result = @tester.on_the_spot_edit @dummy, :content, :type => :textarea
|
72
72
|
@result.should == "<span class=\"on_the_spot_editing\" data-cancel=\"cancel\" data-columns=\"40\" data-edittype=\"textarea\" data-ok=\"ok\" data-rows=\"5\" data-tooltip=\"tooltip\" data-url=\"/bla\" id=\"r_spec/mocks/mock__content__123\">test</span>"
|
73
73
|
end
|
74
74
|
|
75
|
-
it "
|
75
|
+
it "makes the correct html for a text-area with text selected on click" do
|
76
76
|
@result = @tester.on_the_spot_edit @dummy, :content, :type => :textarea, :selected => true
|
77
77
|
@result.should == "<span class=\"on_the_spot_editing\" data-cancel=\"cancel\" data-columns=\"40\" data-edittype=\"textarea\" data-ok=\"ok\" data-rows=\"5\" data-selected=\"true\" data-tooltip=\"tooltip\" data-url=\"/bla\" id=\"r_spec/mocks/mock__content__123\">test</span>"
|
78
78
|
end
|
79
79
|
|
80
|
-
it "
|
80
|
+
it "makes the correct html for a select-box" do
|
81
81
|
@result = @tester.on_the_spot_edit @dummy, :content, :type => :select, :data => [['test', 'This a test'], ['prod', 'Pure Production'], ['QA', 'Quality Assurance']]
|
82
82
|
@result.should == "<span class=\"on_the_spot_editing\" data-cancel=\"cancel\" data-edittype=\"select\" data-ok=\"ok\" data-select=\"{ 'test':'This a test', 'prod':'Pure Production', 'QA':'Quality Assurance', 'selected':'test'}\" data-tooltip=\"tooltip\" data-url=\"/bla\" id=\"r_spec/mocks/mock__content__123\">This a test</span>"
|
83
83
|
end
|
84
84
|
|
85
|
-
it "
|
85
|
+
it "makes the correct html for a checkbox" do
|
86
86
|
@dummy.stub!(:content).and_return(true)
|
87
87
|
@result = @tester.on_the_spot_edit @dummy, :content, :type => :checkbox
|
88
88
|
@result.should == "<span class=\"on_the_spot_editing\" data-cancel=\"cancel\" data-edittype=\"checkbox\" data-ok=\"ok\" data-tooltip=\"tooltip\" data-url=\"/bla\" id=\"r_spec/mocks/mock__content__123\">true</span>"
|
89
89
|
end
|
90
90
|
|
91
|
-
it "
|
91
|
+
it "makes the correct html for an edit-field with a callback" do
|
92
92
|
@result = @tester.on_the_spot_edit @dummy, :content, :callback => 'testCallback(value, settings);'
|
93
93
|
@result.should == "<span class=\"on_the_spot_editing\" data-callback=\"testCallback(value, settings);\" data-cancel=\"cancel\" data-ok=\"ok\" data-tooltip=\"tooltip\" data-url=\"/bla\" id=\"r_spec/mocks/mock__content__123\">test</span>"
|
94
94
|
end
|
95
95
|
|
96
|
+
it "makes the correct html for an edit-field with an onblur action" do
|
97
|
+
@result = @tester.on_the_spot_edit @dummy, :content, :onblur => 'submit'
|
98
|
+
@result.should == "<span class=\"on_the_spot_editing\" data-cancel=\"cancel\" data-ok=\"ok\" data-onblur=\"submit\" data-tooltip=\"tooltip\" data-url=\"/bla\" id=\"r_spec/mocks/mock__content__123\">test</span>"
|
99
|
+
end
|
96
100
|
|
101
|
+
it "makes the correct html for an edit-field with a loadurl" do
|
102
|
+
@result = @tester.on_the_spot_edit @dummy, :content, :loadurl => '/load/data'
|
103
|
+
@result.should == "<span class=\"on_the_spot_editing\" data-cancel=\"cancel\" data-loadurl=\"/load/data\" data-ok=\"ok\" data-tooltip=\"tooltip\" data-url=\"/bla\" id=\"r_spec/mocks/mock__content__123\">test</span>"
|
104
|
+
end
|
97
105
|
|
98
106
|
context "a select-box with a loadurl" do
|
99
|
-
it "
|
107
|
+
it "makea the correct html (and not look up the value)" do
|
100
108
|
@result = @tester.on_the_spot_edit @dummy, :content, :type => :select, :loadurl => '/load/data'
|
101
109
|
@result.should == "<span class=\"on_the_spot_editing\" data-cancel=\"cancel\" data-edittype=\"select\" data-loadurl=\"/load/data\" data-ok=\"ok\" data-tooltip=\"tooltip\" data-url=\"/bla\" id=\"r_spec/mocks/mock__content__123\">test</span>"
|
102
110
|
end
|
103
111
|
|
104
|
-
it "
|
112
|
+
it "usea the display-text preferrably" do
|
105
113
|
@result = @tester.on_the_spot_edit @dummy, :content, :type => :select, :loadurl => '/load/data', :display_text => 'ninja'
|
106
114
|
@result.should == "<span class=\"on_the_spot_editing\" data-cancel=\"cancel\" data-edittype=\"select\" data-loadurl=\"/load/data\" data-ok=\"ok\" data-tooltip=\"tooltip\" data-url=\"/bla\" id=\"r_spec/mocks/mock__content__123\">ninja</span>"
|
107
115
|
end
|
@@ -113,7 +121,7 @@ describe "OnTheSpot" do
|
|
113
121
|
@tester.should_receive(:url_for).with({:action => 'update_it_otherwise'}).and_return('/bla')
|
114
122
|
end
|
115
123
|
|
116
|
-
it "
|
124
|
+
it "make the correct html for an edit-field" do
|
117
125
|
@result = @tester.on_the_spot_edit @dummy, :content, :url => {:action => 'update_it_otherwise' }
|
118
126
|
@result.should == "<span class=\"on_the_spot_editing\" data-cancel=\"cancel\" data-ok=\"ok\" data-tooltip=\"tooltip\" data-url=\"/bla\" id=\"r_spec/mocks/mock__content__123\">test</span>"
|
119
127
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: on_the_spot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 61
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 17
|
10
|
+
version: 0.0.17
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nathan Van der Auwera
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-11-06 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -79,6 +79,7 @@ extra_rdoc_files:
|
|
79
79
|
files:
|
80
80
|
- .bundle/config
|
81
81
|
- .document
|
82
|
+
- .rspec
|
82
83
|
- .travis.yml
|
83
84
|
- Gemfile
|
84
85
|
- Gemfile.lock
|