diff --git a/gems/volt-editable_text/Gemfile b/gems/volt-editable_text/Gemfile index af2c945..74e4cec 100644 --- a/gems/volt-editable_text/Gemfile +++ b/gems/volt-editable_text/Gemfile @@ -1,4 +1,4 @@ source 'https://rubygems.org' -# Specify your gem's dependencies in volt-editable-text.gemspec +# Specify your gem's dependencies in volt-editable_text.gemspec gemspec diff --git a/gems/volt-editable_text/README.md b/gems/volt-editable_text/README.md index 3a80a71..bd90609 100644 --- a/gems/volt-editable_text/README.md +++ b/gems/volt-editable_text/README.md @@ -8,7 +8,7 @@ Provides a component that displays text, but becomes editable in a field when cl Add this line to your application's Gemfile: - gem 'volt-editable-text' + gem 'volt-editable_text' And then execute: @@ -16,8 +16,8 @@ And then execute: Then require it as a component in any components' dependencies.rb you want to use it in. - component 'editable-text' + component 'editable_text' Finally, use the tag. - <:editable-text value="{{_some_value}}" /> + <:editable_text value="{{_some_value}}" /> diff --git a/gems/volt-editable_text/VERSION b/gems/volt-editable_text/VERSION deleted file mode 100644 index 429d94a..0000000 --- a/gems/volt-editable_text/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.0.9 \ No newline at end of file diff --git a/gems/volt-editable_text/app/editable-text/views/main/index.html b/gems/volt-editable_text/app/editable-text/views/main/index.html deleted file mode 100644 index 3e48476..0000000 --- a/gems/volt-editable_text/app/editable-text/views/main/index.html +++ /dev/null @@ -1,6 +0,0 @@ -<:Body> - {{if toggled}} - - {{else}} - {{value}} - {{end}} diff --git a/gems/volt-editable_text/app/editable-text/controllers/main_controller.rb b/gems/volt-editable_text/app/editable_text/controllers/main_controller.rb similarity index 54% rename from gems/volt-editable_text/app/editable-text/controllers/main_controller.rb rename to gems/volt-editable_text/app/editable_text/controllers/main_controller.rb index a979654..5bebdf0 100644 --- a/gems/volt-editable_text/app/editable-text/controllers/main_controller.rb +++ b/gems/volt-editable_text/app/editable_text/controllers/main_controller.rb @@ -7,30 +7,22 @@ def index self.toggled = false end - def body_element - Element.find('body') - end + # def body_element + # Element.find('body') + # end + + # def input_element + # Element.find(section.container_node).find('input') + # end def toggle_editing self.toggled = !toggled if toggled - # Editing enabled, bind a listener for when they click on the document to disable - # it again. - body_element.on('click.editabletext') do |event| - # Find the id for the text field inside of this component. - clicked_id = Element.find(section.container_node).find('input').id - - if clicked_id != event.target.id - # Didn't click inside of the edit text field, toggle back. - toggle_editing - end - end - else - body_element.off('click.editabletext') + `setTimeout(function(){ $(#{section.container_node}).find('input').focus(); }, 0)` end end - + def edit(event) if event.key_code == 13 #for some reason .stop or stop_propagation thow the following error: @@ -41,6 +33,10 @@ def edit(event) toggle_editing end end + + def blur + toggle_editing + end def value=(newvalue) attrs.value = newvalue @@ -53,6 +49,6 @@ def value def size return attrs.value.size end - + end -end \ No newline at end of file +end diff --git a/gems/volt-editable_text/app/editable_text/views/main/index.html b/gems/volt-editable_text/app/editable_text/views/main/index.html new file mode 100644 index 0000000..1799548 --- /dev/null +++ b/gems/volt-editable_text/app/editable_text/views/main/index.html @@ -0,0 +1,6 @@ +<:Body> + {{if toggled}} + + {{else}} + {{value}} + {{end}} diff --git a/gems/volt-editable_text/lib/volt/editable/text.rb b/gems/volt-editable_text/lib/volt/editable/text.rb deleted file mode 100644 index 92e11a1..0000000 --- a/gems/volt-editable_text/lib/volt/editable/text.rb +++ /dev/null @@ -1,9 +0,0 @@ -require "volt/editable/text/version" - -class Volt - class Editable - class Text - # Your code goes here... - end - end -end diff --git a/gems/volt-editable_text/lib/volt/editable_text.rb b/gems/volt-editable_text/lib/volt/editable_text.rb new file mode 100644 index 0000000..1105162 --- /dev/null +++ b/gems/volt-editable_text/lib/volt/editable_text.rb @@ -0,0 +1,6 @@ +module Volt + class EditableText + VERSION = '0.0.9' + # Your code goes here... + end +end diff --git a/gems/volt-editable_text/volt-editable-text.gemspec b/gems/volt-editable_text/volt-editable_text.gemspec similarity index 77% rename from gems/volt-editable_text/volt-editable-text.gemspec rename to gems/volt-editable_text/volt-editable_text.gemspec index ad82a3c..da88c06 100644 --- a/gems/volt-editable_text/volt-editable-text.gemspec +++ b/gems/volt-editable_text/volt-editable_text.gemspec @@ -2,15 +2,14 @@ lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -version = File.read(File.expand_path('../VERSION', __FILE__)).strip - +require 'volt/editable_text' Gem::Specification.new do |spec| - spec.name = "volt-editable-text" - spec.version = version + spec.name = "volt-editable_text" + spec.version = Volt::EditableText::VERSION spec.authors = ["Ryan Stout"] spec.email = ["ryan@agileproductions.com"] - spec.summary = %q{Volt component that gives a :editable-text control which shows text, and lets you edit the text when it is clicked on.} + spec.summary = %q{Volt component that gives a :editable_text control which shows text, and lets you edit the text when it is clicked on.} spec.homepage = "" spec.license = "MIT"