-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git subrepo clone git@github.com:ijcd/volt-editable-text.git gems/vol…
…t-editable_text subrepo: subdir: "gems/volt-editable_text" merged: "fb3c997" upstream: origin: "git@github.com:ijcd/volt-editable-text.git" branch: "master" commit: "fb3c997" git-subrepo: version: "0.2.3" origin: "https://github.com/Homebrew/homebrew.git" commit: "fdc0570"
- Loading branch information
Showing
10 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
*.gem | ||
*.rbc | ||
.bundle | ||
.config | ||
.yardoc | ||
Gemfile.lock | ||
InstalledFiles | ||
_yardoc | ||
coverage | ||
doc/ | ||
lib/bundler/man | ||
pkg | ||
rdoc | ||
spec/reports | ||
test/tmp | ||
test/version_tmp | ||
tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
; DO NOT EDIT (unless you know what you are doing) | ||
; | ||
; This subdirectory is a git "subrepo", and this file is maintained by the | ||
; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme | ||
; | ||
[subrepo] | ||
remote = git@github.com:ijcd/volt-editable-text.git | ||
branch = master | ||
commit = fb3c99731e0d72fe0e9ff5acea427f4f5bf724c5 | ||
parent = 9b8aa1a9f4f30ac3c718d904b395c3db7133ccaf | ||
cmdver = 0.2.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source 'https://rubygems.org' | ||
|
||
# Specify your gem's dependencies in volt-editable-text.gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Volt Editable Text Component | ||
|
||
**Note** Currently this only supports Volt 0.8.x, updates for 0.9.x coming soon. | ||
|
||
Provides a component that displays text, but becomes editable in a field when clicked on. | ||
|
||
## Usage | ||
|
||
Add this line to your application's Gemfile: | ||
|
||
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' | ||
|
||
Finally, use the tag. | ||
|
||
<:editable-text value="{{_some_value}}" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require "bundler/gem_tasks" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.0.9 |
58 changes: 58 additions & 0 deletions
58
gems/volt-editable_text/app/editable-text/controllers/main_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
module EditableText | ||
class MainController < Volt::ModelController | ||
attr_accessor :section | ||
reactive_accessor :toggled | ||
|
||
def index | ||
self.toggled = false | ||
end | ||
|
||
def body_element | ||
Element.find('body') | ||
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') | ||
end | ||
end | ||
|
||
def edit(event) | ||
if event.key_code == 13 | ||
#for some reason .stop or stop_propagation thow the following error: | ||
#undefined method `stop_propagation' for #<Volt::JSEvent:7672> | ||
|
||
#event.stop_propagation | ||
|
||
toggle_editing | ||
end | ||
end | ||
|
||
def value=(newvalue) | ||
attrs.value = newvalue | ||
end | ||
|
||
def value | ||
return attrs.value | ||
end | ||
|
||
def size | ||
return attrs.value.size | ||
end | ||
|
||
end | ||
end |
6 changes: 6 additions & 0 deletions
6
gems/volt-editable_text/app/editable-text/views/main/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<:Body> | ||
{{if toggled}} | ||
<input type="text" e-keypress="edit(event)" size="{{size}}" value="{{value}}" /> | ||
{{else}} | ||
<span e-click="toggle_editing">{{value}}</span> | ||
{{end}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require "volt/editable/text/version" | ||
|
||
class Volt | ||
class Editable | ||
class Text | ||
# Your code goes here... | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# coding: utf-8 | ||
lib = File.expand_path('../lib', __FILE__) | ||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | ||
|
||
version = File.read(File.expand_path('../VERSION', __FILE__)).strip | ||
|
||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "volt-editable-text" | ||
spec.version = 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.homepage = "" | ||
spec.license = "MIT" | ||
|
||
spec.files = `git ls-files -z`.split("\x0") | ||
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } | ||
spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) | ||
spec.require_paths = ["lib"] | ||
|
||
spec.add_development_dependency "volt", "~> 0.8.23" | ||
spec.add_development_dependency "rake" | ||
end |