diff --git a/Gemfile b/Gemfile --- a/Gemfile +++ b/Gemfile @@ -42,6 +42,7 @@ gem "test-unit" gem 'will_paginate', '~> 3.0.0' gem 'dynamic_form' +gem 'in_place_editing' group :test, :development do gem "rspec-rails", "~> 2.0" diff --git a/Gemfile.lock b/Gemfile.lock --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,6 +45,7 @@ haml (3.1.7) hike (1.2.1) i18n (0.6.1) + in_place_editing (1.2.0) journey (1.0.4) json (1.7.5) mail (2.4.4) @@ -125,6 +126,7 @@ coffee-rails (~> 3.2.1) dynamic_form haml + in_place_editing mysql2 prototype-rails rails (= 3.2.8) diff --git a/vendor/plugins/in_place_editing/README b/vendor/plugins/in_place_editing/README deleted file mode 100644 --- a/vendor/plugins/in_place_editing/README +++ /dev/null @@ -1,14 +0,0 @@ -InPlaceEditing -============== - -Example: - - # Controller - class BlogController < ApplicationController - in_place_edit_for :post, :title - end - - # View - <%= in_place_editor_field :post, 'title' %> - -Copyright (c) 2007 David Heinemeier Hansson, released under the MIT license \ No newline at end of file diff --git a/vendor/plugins/in_place_editing/Rakefile b/vendor/plugins/in_place_editing/Rakefile deleted file mode 100644 --- a/vendor/plugins/in_place_editing/Rakefile +++ /dev/null @@ -1,22 +0,0 @@ -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' - -desc 'Default: run unit tests.' -task :default => :test - -desc 'Test in_place_editing plugin.' -Rake::TestTask.new(:test) do |t| - t.libs << 'lib' - t.pattern = 'test/**/*_test.rb' - t.verbose = true -end - -desc 'Generate documentation for in_place_editing plugin.' -Rake::RDocTask.new(:rdoc) do |rdoc| - rdoc.rdoc_dir = 'rdoc' - rdoc.title = 'InPlaceEditing' - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.rdoc_files.include('README') - rdoc.rdoc_files.include('lib/**/*.rb') -end diff --git a/vendor/plugins/in_place_editing/init.rb b/vendor/plugins/in_place_editing/init.rb deleted file mode 100644 --- a/vendor/plugins/in_place_editing/init.rb +++ /dev/null @@ -1,2 +0,0 @@ -ActionController::Base.send :include, InPlaceEditing -ActionController::Base.helper InPlaceMacrosHelper diff --git a/vendor/plugins/in_place_editing/lib/in_place_editing.rb b/vendor/plugins/in_place_editing/lib/in_place_editing.rb deleted file mode 100644 --- a/vendor/plugins/in_place_editing/lib/in_place_editing.rb +++ /dev/null @@ -1,25 +0,0 @@ -module InPlaceEditing - def self.included(base) - base.extend(ClassMethods) - end - - # Example: - # - # # Controller - # class BlogController < ApplicationController - # in_place_edit_for :post, :title - # end - # - # # View - # <%= in_place_editor_field :post, 'title' %> - # - module ClassMethods - def in_place_edit_for(object, attribute, options = {}) - define_method("set_#{object}_#{attribute}") do - @item = object.to_s.camelize.constantize.find(params[:id]) - @item.update_attribute(attribute, params[:value]) - render :text => @item.send(attribute).to_s - end - end - end -end diff --git a/vendor/plugins/in_place_editing/lib/in_place_macros_helper.rb b/vendor/plugins/in_place_editing/lib/in_place_macros_helper.rb deleted file mode 100644 --- a/vendor/plugins/in_place_editing/lib/in_place_macros_helper.rb +++ /dev/null @@ -1,71 +0,0 @@ -module InPlaceMacrosHelper - # Makes an HTML element specified by the DOM ID +field_id+ become an in-place - # editor of a property. - # - # A form is automatically created and displayed when the user clicks the element, - # something like this: - #
- # - # - # cancel - #
- # - # The form is serialized and sent to the server using an AJAX call, the action on - # the server should process the value and return the updated value in the body of - # the reponse. The element will automatically be updated with the changed value - # (as returned from the server). - # - # Required +options+ are: - # :url:: Specifies the url where the updated value should - # be sent after the user presses "ok". - # - # Addtional +options+ are: - # :rows:: Number of rows (more than 1 will use a TEXTAREA) - # :cols:: Number of characters the text input should span (works for both INPUT and TEXTAREA) - # :size:: Synonym for :cols when using a single line text input. - # :cancel_text:: The text on the cancel link. (default: "cancel") - # :save_text:: The text on the save link. (default: "ok") - # :loading_text:: The text to display while the data is being loaded from the server (default: "Loading...") - # :saving_text:: The text to display when submitting to the server (default: "Saving...") - # :external_control:: The id of an external control used to enter edit mode. - # :load_text_url:: URL where initial value of editor (content) is retrieved. - # :options:: Pass through options to the AJAX call (see prototype's Ajax.Updater) - # :with:: JavaScript snippet that should return what is to be sent - # in the AJAX call, +form+ is an implicit parameter - # :script:: Instructs the in-place editor to evaluate the remote JavaScript response (default: false) - # :click_to_edit_text::The text shown during mouseover the editable text (default: "Click to edit") - def in_place_editor(field_id, options = {}) - function = "new Ajax.InPlaceEditor(" - function << "'#{field_id}', " - function << "'#{url_for(options[:url])}'" - - js_options = {} - js_options['cancelText'] = %('#{options[:cancel_text]}') if options[:cancel_text] - js_options['okText'] = %('#{options[:save_text]}') if options[:save_text] - js_options['loadingText'] = %('#{options[:loading_text]}') if options[:loading_text] - js_options['savingText'] = %('#{options[:saving_text]}') if options[:saving_text] - js_options['rows'] = options[:rows] if options[:rows] - js_options['cols'] = options[:cols] if options[:cols] - js_options['size'] = options[:size] if options[:size] - js_options['externalControl'] = "'#{options[:external_control]}'" if options[:external_control] - js_options['loadTextURL'] = "'#{url_for(options[:load_text_url])}'" if options[:load_text_url] - js_options['ajaxOptions'] = options[:options] if options[:options] - js_options['evalScripts'] = options[:script] if options[:script] - js_options['callback'] = "function(form) { return #{options[:with]} }" if options[:with] - js_options['clickToEditText'] = %('#{options[:click_to_edit_text]}') if options[:click_to_edit_text] - function << (', ' + options_for_javascript(js_options)) unless js_options.empty? - - function << ')' - - javascript_tag(function) - end - - # Renders the value of the specified object and method with in-place editing capabilities. - def in_place_editor_field(object, method, tag_options = {}, in_place_editor_options = {}) - tag = ::ActionView::Helpers::InstanceTag.new(object, method, self) - tag_options = {:tag => "span", :id => "#{object}_#{method}_#{tag.object.id}_in_place_editor", :class => "in_place_editor_field"}.merge!(tag_options) - in_place_editor_options[:url] = in_place_editor_options[:url] || url_for({ :action => "set_#{object}_#{method}", :id => tag.object.id }) - tag.to_content_tag(tag_options.delete(:tag), tag_options) + - in_place_editor(tag_options[:id], in_place_editor_options) - end -end diff --git a/vendor/plugins/in_place_editing/test/in_place_editing_test.rb b/vendor/plugins/in_place_editing/test/in_place_editing_test.rb deleted file mode 100644 --- a/vendor/plugins/in_place_editing/test/in_place_editing_test.rb +++ /dev/null @@ -1,69 +0,0 @@ -require File.expand_path(File.join(File.dirname(__FILE__), '../../../../test/test_helper')) -require 'test/unit' - -class InPlaceEditingTest < Test::Unit::TestCase - include InPlaceEditing - include InPlaceMacrosHelper - - include ActionView::Helpers::UrlHelper - include ActionView::Helpers::TagHelper - include ActionView::Helpers::TextHelper - include ActionView::Helpers::FormHelper - include ActionView::Helpers::CaptureHelper - - def setup - @controller = Class.new do - def url_for(options) - url = "http://www.example.com/" - url << options[:action].to_s if options and options[:action] - url - end - end - @controller = @controller.new - end - - def test_in_place_editor_external_control - assert_dom_equal %(), - in_place_editor('some_input', {:url => {:action => 'inplace_edit'}, :external_control => 'blah'}) - end - - def test_in_place_editor_size - assert_dom_equal %(), - in_place_editor('some_input', {:url => {:action => 'inplace_edit'}, :size => 4}) - end - - def test_in_place_editor_cols_no_rows - assert_dom_equal %(), - in_place_editor('some_input', {:url => {:action => 'inplace_edit'}, :cols => 4}) - end - - def test_in_place_editor_cols_with_rows - assert_dom_equal %(), - in_place_editor('some_input', {:url => {:action => 'inplace_edit'}, :rows => 5, :cols => 40}) - end - - def test_inplace_editor_loading_text - assert_dom_equal %(), - in_place_editor('some_input', {:url => {:action => 'inplace_edit'}, :loading_text => 'Why are we waiting?'}) - end - - def test_in_place_editor_url - assert_match "Ajax.InPlaceEditor('id-goes-here', 'http://www.example.com/action_to_set_value')", - in_place_editor( 'id-goes-here', :url => { :action => "action_to_set_value" }) - end - - def test_in_place_editor_load_text_url - assert_match "Ajax.InPlaceEditor('id-goes-here', 'http://www.example.com/action_to_set_value', {loadTextURL:'http://www.example.com/action_to_get_value'})", - in_place_editor( 'id-goes-here', - :url => { :action => "action_to_set_value" }, - :load_text_url => { :action => "action_to_get_value" }) - end - - def test_in_place_editor_eval_scripts - assert_match "Ajax.InPlaceEditor('id-goes-here', 'http://www.example.com/action_to_set_value', {evalScripts:true})", - in_place_editor( 'id-goes-here', - :url => { :action => "action_to_set_value" }, - :script => true ) - end - -end \ No newline at end of file