Skip to content

Commit

Permalink
Update volt-editable_text for 0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
ijcd committed Nov 12, 2015
1 parent 16e2c4c commit 431f5c2
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 44 deletions.
2 changes: 1 addition & 1 deletion gems/volt-editable_text/Gemfile
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions gems/volt-editable_text/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ 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:

$ bundle

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}}" />
1 change: 0 additions & 1 deletion gems/volt-editable_text/VERSION

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -41,6 +33,10 @@ def edit(event)
toggle_editing
end
end

def blur
toggle_editing
end

def value=(newvalue)
attrs.value = newvalue
Expand All @@ -53,6 +49,6 @@ def value
def size
return attrs.value.size
end

end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<:Body>
{{if toggled}}
<input type="text" e-keypress="edit(event)" e-focusout="blur" size="{{size}}" value="{{value}}" />
{{else}}
<span e-click="toggle_editing">{{value}}</span>
{{end}}
9 changes: 0 additions & 9 deletions gems/volt-editable_text/lib/volt/editable/text.rb

This file was deleted.

6 changes: 6 additions & 0 deletions gems/volt-editable_text/lib/volt/editable_text.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Volt
class EditableText
VERSION = '0.0.9'
# Your code goes here...
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit 431f5c2

Please sign in to comment.