in_place_editing 1.1.2 → 1.2.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.
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
1
  source :rubygems
2
2
 
3
- gem "rails", "~> 3.0.10"
3
+ gem 'rails', '~> 3.0', '>= 3.0.10'
4
+ gem 'rdoc'
@@ -2,11 +2,15 @@
2
2
 
3
3
  A Rails plugin for in-place editing fields.
4
4
 
5
- = Installation
6
5
 
7
- gem install in_place_editing
6
+ == Installation
8
7
 
9
- = Usage
8
+ In the +Gemfile+:
9
+
10
+ gem 'in_place_editing'
11
+
12
+
13
+ == Usage
10
14
 
11
15
  In your controller define what model and fields you want in-place editing support for.
12
16
 
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'rake'
2
2
  require 'rake/testtask'
3
- require 'rake/rdoctask'
3
+ require 'rdoc/task'
4
4
  require 'bundler'
5
5
  Bundler::GemHelper.install_tasks
6
6
 
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "in_place_editing"
6
- s.version = "1.1.2"
6
+ s.version = "1.2.0"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["David Heinemeier Hansson", "Jeremy Kemper", "Jose Fernandez", "Pawel Stradomski, Mark Turner"]
9
9
  s.email = ["mark@amerine.net"]
@@ -70,12 +70,20 @@ module InPlaceMacrosHelper
70
70
  end
71
71
 
72
72
  # Renders the value of the specified object and method with in-place editing capabilities.
73
- def in_place_editor_field(object, method, tag_options = {}, in_place_editor_options = {})
74
- instance_tag = ::ActionView::Helpers::InstanceTag.new(object, method, self)
73
+ def in_place_editor_field(object_or_name, method, tag_options = {}, in_place_editor_options = {})
74
+ if object_or_name.respond_to? :to_model
75
+ object_name = object_or_name.to_model.class.model_name.singular
76
+ object = object_or_name.to_model
77
+ else
78
+ object_name = object_or_name
79
+ object = nil
80
+ end
81
+
82
+ instance_tag = ::ActionView::Helpers::InstanceTag.new(object_name, method, self, object)
75
83
  tag_options = {:tag => "span",
76
- :id => "#{object}_#{method}_#{instance_tag.object.id}_in_place_editor",
84
+ :id => "#{object_name}_#{method}_#{instance_tag.object.id}_in_place_editor",
77
85
  :class => "in_place_editor_field"}.merge!(tag_options)
78
- in_place_editor_options[:url] = in_place_editor_options[:url] || url_for({ :action => "set_#{object}_#{method}", :id => instance_tag.object.id })
86
+ in_place_editor_options[:url] = in_place_editor_options[:url] || url_for({ :action => "set_#{object_name}_#{method}", :id => instance_tag.object.id })
79
87
  tag = content_tag(tag_options.delete(:tag), h(instance_tag.value(instance_tag.object)),tag_options)
80
88
  return tag + in_place_editor(tag_options[:id], in_place_editor_options)
81
89
  end
@@ -21,7 +21,6 @@ class InPlaceEditingTest < Test::Unit::TestCase
21
21
  url
22
22
  end
23
23
 
24
-
25
24
  @controller = InPlaceEditingController.new
26
25
  @protect_against_forgery = false
27
26
  end
@@ -31,28 +30,28 @@ class InPlaceEditingTest < Test::Unit::TestCase
31
30
  end
32
31
 
33
32
  def test_in_place_editor_external_control
34
- assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Ajax.InPlaceEditor('some_input', 'http://www.example.com/inplace_edit', {externalControl:'blah'})\n//]]>\n</script>),
35
- in_place_editor('some_input', {:url => {:action => 'inplace_edit'}, :external_control => 'blah'})
33
+ html = javascript_tag "new Ajax.InPlaceEditor('some_input', 'http://www.example.com/inplace_edit', {externalControl:'blah'})"
34
+ assert_dom_equal html, in_place_editor('some_input', {:url => {:action => 'inplace_edit'}, :external_control => 'blah'})
36
35
  end
37
36
 
38
37
  def test_in_place_editor_size
39
- assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Ajax.InPlaceEditor('some_input', 'http://www.example.com/inplace_edit', {size:4})\n//]]>\n</script>),
40
- in_place_editor('some_input', {:url => {:action => 'inplace_edit'}, :size => 4})
38
+ html = javascript_tag "new Ajax.InPlaceEditor('some_input', 'http://www.example.com/inplace_edit', {size:4})"
39
+ assert_dom_equal html, in_place_editor('some_input', {:url => {:action => 'inplace_edit'}, :size => 4})
41
40
  end
42
41
 
43
42
  def test_in_place_editor_cols_no_rows
44
- assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Ajax.InPlaceEditor('some_input', 'http://www.example.com/inplace_edit', {cols:4})\n//]]>\n</script>),
45
- in_place_editor('some_input', {:url => {:action => 'inplace_edit'}, :cols => 4})
43
+ html = javascript_tag "new Ajax.InPlaceEditor('some_input', 'http://www.example.com/inplace_edit', {cols:4})"
44
+ assert_dom_equal html, in_place_editor('some_input', {:url => {:action => 'inplace_edit'}, :cols => 4})
46
45
  end
47
46
 
48
47
  def test_in_place_editor_cols_with_rows
49
- assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Ajax.InPlaceEditor('some_input', 'http://www.example.com/inplace_edit', {cols:40, rows:5})\n//]]>\n</script>),
50
- in_place_editor('some_input', {:url => {:action => 'inplace_edit'}, :rows => 5, :cols => 40})
48
+ html = javascript_tag "new Ajax.InPlaceEditor('some_input', 'http://www.example.com/inplace_edit', {cols:40, rows:5})"
49
+ assert_dom_equal html, in_place_editor('some_input', {:url => {:action => 'inplace_edit'}, :rows => 5, :cols => 40})
51
50
  end
52
51
 
53
52
  def test_inplace_editor_loading_text
54
- assert_dom_equal %(<script type=\"text/javascript\">\n//<![CDATA[\nnew Ajax.InPlaceEditor('some_input', 'http://www.example.com/inplace_edit', {loadingText:'Why are we waiting?'})\n//]]>\n</script>),
55
- in_place_editor('some_input', {:url => {:action => 'inplace_edit'}, :loading_text => 'Why are we waiting?'})
53
+ html = javascript_tag "new Ajax.InPlaceEditor('some_input', 'http://www.example.com/inplace_edit', {loadingText:'Why are we waiting?'})"
54
+ assert_dom_equal html, in_place_editor('some_input', {:url => {:action => 'inplace_edit'}, :loading_text => 'Why are we waiting?'})
56
55
  end
57
56
 
58
57
  def test_in_place_editor_url
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: in_place_editing
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2011-09-05 00:00:00.000000000Z
15
+ date: 2012-07-12 00:00:00.000000000 Z
16
16
  dependencies: []
17
17
  description: In Place Editing Rails Plugin
18
18
  email:
@@ -53,10 +53,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
53
53
  version: '0'
54
54
  requirements: []
55
55
  rubyforge_project: in_place_editing
56
- rubygems_version: 1.8.6
56
+ rubygems_version: 1.8.23
57
57
  signing_key:
58
58
  specification_version: 3
59
59
  summary: In Place Editing Rails Plugin
60
60
  test_files:
61
61
  - test/in_place_editing_test.rb
62
62
  - test/test_helper.rb
63
+ has_rdoc: