on_the_spot 0.0.14 → 0.0.16

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.
data/History.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Change History / Release Notes
2
2
 
3
+ ## Version 0.0.15 (12/10/2011)
4
+
5
+ * added support for checkboxes (thanks to Peter Savichev)
6
+
7
+ ## Version 0.0.14 (13/9/2011)
8
+
9
+ * Fixed bugs #17 and #20
10
+ * Improved rails 3.1 compatibility
11
+
12
+ ## Version 0.0.13 (24/7/2011)
13
+
14
+ * Made on_the_spot rails 3.1 compatible
15
+
3
16
  ## Version 0.0.12 (02/07/2011)
4
17
 
5
18
  * Added the option to execute a callback after editing
data/README.markdown CHANGED
@@ -9,18 +9,25 @@ On-the-spot is a Rails3 compliant unobtrusive javascript in-place-editing plugin
9
9
  Inside your `Gemfile` add the following:
10
10
 
11
11
  gem "on_the_spot"
12
-
12
+
13
+ Run the installation task:
14
+
15
+ rails g on_the_spot:install
16
+
17
+ This will copy the default translation files, and for rails 3.0 it will also copy the needed assets (javascript files).
18
+
13
19
  ### Rails 3.1
14
20
 
15
21
  Add the following to application.js so it compiles to the asset_pipeline
16
22
 
17
23
  //= require on_the_spot
18
24
 
19
- ### Rails 3.0.x
25
+ Or, inside your `application.html.haml` you could still include the needed javascripts, using
20
26
 
21
- Run the installation task:
27
+ = javascript_include_tag :on_the_spot
22
28
 
23
- rails g on_the_spot:install
29
+
30
+ ### Rails 3.0.x
24
31
 
25
32
  Inside your `application.html.haml` you will need to add below the default javascripts:
26
33
 
@@ -70,7 +77,7 @@ It should be as simple as that :)
70
77
 
71
78
  The `on_the_spot_edit` also accepts options:
72
79
 
73
- * `:type` : `:textarea` or `:select` (none means default edit)
80
+ * `:type` : `:textarea`, `:select` or `:checkbox` (none means default edit)
74
81
  * `:ok_text` : the text for the ok-button
75
82
  * `:cancel_text` : the text for the cancel-button
76
83
  * `:display_text`: if you want to overrule the displayed text, especially useful when using your own `:url` or `:loadurl`
@@ -81,7 +88,7 @@ The `on_the_spot_edit` also accepts options:
81
88
  * `:loadurl`: for select, an url that will return the data in JSON format (use instead of `:data`)
82
89
  * `:url`: URL to post to if you don't want to use the standard routes
83
90
  * `:selected`: Text selected by default on edit (boolean, default is false)
84
- * `:callback`: The name of a javascript function that is called after form has been submitted
91
+ * `:callback`: The name of a javascript function that is called after form has been submitted
85
92
 
86
93
 
87
94
  For the texts: if a text is not specified, the default is taken from the `on_the_spot.en.yml` (or your current language).
@@ -132,7 +139,7 @@ and, after a `bundle install`, you run
132
139
  That will download and install all the necessary files for you.
133
140
 
134
141
  ## Note on Patches/Pull Requests
135
-
142
+
136
143
  * Fork the project.
137
144
  * Make your feature addition or bug fix.
138
145
  * Add tests for it. This is important so I don't break it in a
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.14
1
+ 0.0.16
@@ -0,0 +1,26 @@
1
+ /**********************************************************************
2
+ * Custom input types for the jquery.jeditable plugin
3
+ * By Richard Davies <Richard__at__richarddavies.us>, 2009
4
+ * By Peter Savichev (proton) <psavichev@gmail.com>, 2011
5
+ *********************************************************************/
6
+
7
+ // Create a custom input type for checkboxes
8
+ $.editable.addInputType("checkbox", {
9
+ element : function(settings, original) {
10
+ var input = $('<input type="checkbox">');
11
+ $(this).append(input);
12
+
13
+ $(input).change(function() {
14
+ var value = $(input).attr("checked") ? 1 : 0;
15
+ $(input).val(value);
16
+ });
17
+ return(input);
18
+ },
19
+ content : function(string, settings, original) {
20
+ var checked = (string == "true") ? 1 : 0;
21
+ var input = $(':input:first', this);
22
+ if(checked) $(input).attr("checked", "checked");
23
+ else $(input).removeAttr("checked");
24
+ $(input).val(checked);
25
+ }
26
+ });
@@ -4,4 +4,5 @@
4
4
  // javascript_include_tag :on_the_spot
5
5
  //
6
6
  //= require jquery.jeditable.mini.js
7
+ //= require jquery.jeditable.checkbox.js
7
8
  //= require on_the_spot_code
@@ -15,6 +15,7 @@ module OnTheSpot
15
15
  else
16
16
  copy_file "../../../../../app/assets/javascripts/on_the_spot.js", "public/javascripts/on_the_spot.js"
17
17
  copy_file "../../../../../app/assets/javascripts/jquery.jeditable.mini.js", "public/javascripts/jquery.jeditable.mini.js"
18
+ copy_file "../../../../../app/assets/javascripts/jquery.jeditable.checkbox.js", "public/javascripts/jquery.jeditable.checkbox.js"
18
19
  end
19
20
  end
20
21
 
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.14"
8
+ s.version = "0.0.16"
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-09-13}
12
+ s.date = %q{2011-10-12}
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 = [
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
27
27
  "README.markdown",
28
28
  "Rakefile",
29
29
  "VERSION",
30
+ "app/assets/javascripts/jquery.jeditable.checkbox.js",
30
31
  "app/assets/javascripts/jquery.jeditable.mini.js",
31
32
  "app/assets/javascripts/on_the_spot.js",
32
33
  "app/assets/javascripts/on_the_spot_code.js",
@@ -29,8 +29,10 @@ describe OnTheSpot::Generators::InstallGenerator do
29
29
  test_version.should be_false
30
30
  end
31
31
 
32
- it "copies on_the_spot.js to the correct folder" do
33
- assert_file "public/javascripts/on_the_spot.js"
32
+ ['on_the_spot.js', 'jquery.jeditable.mini.js', 'jquery.jeditable.checkbox.js'].each do |js_file|
33
+ it "copies #{js_file} to the correct folder" do
34
+ assert_file "public/javascripts/#{js_file}"
35
+ end
34
36
  end
35
37
  end
36
38
  end
@@ -43,8 +45,10 @@ describe OnTheSpot::Generators::InstallGenerator do
43
45
  run_generator
44
46
  end
45
47
 
46
- it "does not copy on_the_spot.js" do
47
- assert_no_file "public/javascripts/on_the_spot.js"
48
+ ['on_the_spot.js', 'jquery.jeditable.mini.js', 'jquery.jeditable.checkbox.js'].each do |js_file|
49
+ it "does not copy #{js_file}" do
50
+ assert_no_file "public/javascripts/#{js_file}"
51
+ end
48
52
  end
49
53
  end
50
54
  end
@@ -56,7 +56,7 @@ describe "OnTheSpot" 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
60
  it "should make 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>"
@@ -71,7 +71,7 @@ describe "OnTheSpot" 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
75
  it "should make 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>"
@@ -81,7 +81,13 @@ describe "OnTheSpot" 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 "should make the correct html for a checkbox" do
86
+ @dummy.stub!(:content).and_return(true)
87
+ @result = @tester.on_the_spot_edit @dummy, :content, :type => :checkbox
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
+ end
90
+
85
91
  it "should make the correct html for an edit-field with a callback" do
86
92
  @result = @tester.on_the_spot_edit @dummy, :content, :callback => 'testCallback(value, settings);'
87
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>"
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: 3
4
+ hash: 63
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 14
10
- version: 0.0.14
9
+ - 16
10
+ version: 0.0.16
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-09-13 00:00:00 +02:00
18
+ date: 2011-10-12 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -87,6 +87,7 @@ files:
87
87
  - README.markdown
88
88
  - Rakefile
89
89
  - VERSION
90
+ - app/assets/javascripts/jquery.jeditable.checkbox.js
90
91
  - app/assets/javascripts/jquery.jeditable.mini.js
91
92
  - app/assets/javascripts/on_the_spot.js
92
93
  - app/assets/javascripts/on_the_spot_code.js