volt-editable-text 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/README.md +21 -0
- data/Rakefile +1 -0
- data/VERSION +1 -0
- data/app/editable-text/controllers/index_controller.rb +52 -0
- data/app/editable-text/views/index/index.html +7 -0
- data/lib/volt/editable/text.rb +9 -0
- data/volt-editable-text.gemspec +24 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6494713b75951dc0bde7f914a3dd9231d641eab0
|
4
|
+
data.tar.gz: 2ac8272ca5aa3351f568b5df23f3fe88475929aa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5bf530678af6eb04fe1254e6de9e698dab852b799bb91664fa1df7a450f2462e3ccf9e1d3bb50db02c6bd0b67b31cbd49875d63935d9ff22aa8ee63f53589f6f
|
7
|
+
data.tar.gz: 363ce62a191ce94fd2926d91a9f51c12776464ea8dce424534c88b808de055279f4a45209436b3d38e67f2cfc56d70b21e15e06f9860f09f63714b3be03ddd3f
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# Volt Editable Text Component
|
2
|
+
|
3
|
+
Provides a component that displays text, but becomes editable in a field when clicked on.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'volt-editable-text'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Then require it as a component in any components' dependencies.rb you want to use it in.
|
16
|
+
|
17
|
+
component 'editable-text'
|
18
|
+
|
19
|
+
Finally, use the tag.
|
20
|
+
|
21
|
+
<:editable-text value="{_some_value}" />
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module EditableText
|
2
|
+
class IndexController < ModelController
|
3
|
+
model :page
|
4
|
+
|
5
|
+
attr_reader :data
|
6
|
+
attr_accessor :section
|
7
|
+
|
8
|
+
def initialize(data)
|
9
|
+
super
|
10
|
+
|
11
|
+
@data = data
|
12
|
+
|
13
|
+
@toggled = ReactiveValue.new(false)
|
14
|
+
end
|
15
|
+
|
16
|
+
def toggled
|
17
|
+
@toggled
|
18
|
+
end
|
19
|
+
|
20
|
+
def body_element
|
21
|
+
Element.find('body')
|
22
|
+
end
|
23
|
+
|
24
|
+
def toggle_editing
|
25
|
+
controller._toggled = (!controller._toggled).cur
|
26
|
+
|
27
|
+
if controller._toggled.cur
|
28
|
+
# Editing enabled, bind a listener for when they click on the document to disable
|
29
|
+
# it again.
|
30
|
+
body_element.on('click.editabletext') do |event|
|
31
|
+
# Find the id for the text field inside of this component.
|
32
|
+
clicked_id = Element.find(section.container_node).find('input').id
|
33
|
+
|
34
|
+
if clicked_id != event.target.id
|
35
|
+
# Didn't click inside of the edit text field, toggle back.
|
36
|
+
toggle_editing
|
37
|
+
end
|
38
|
+
end
|
39
|
+
else
|
40
|
+
body_element.off('click.editabletext')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def edit(event)
|
45
|
+
if event.key_code == 13
|
46
|
+
event.stop
|
47
|
+
|
48
|
+
toggle_editing
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
version = File.read(File.expand_path('../VERSION', __FILE__)).strip
|
6
|
+
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = "volt-editable-text"
|
10
|
+
spec.version = version
|
11
|
+
spec.authors = ["Ryan Stout"]
|
12
|
+
spec.email = ["ryanstout@gmail.com"]
|
13
|
+
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.}
|
14
|
+
spec.homepage = ""
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "volt", "~> 0.5.0"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: volt-editable-text
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Stout
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: volt
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.5.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.5.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- ryanstout@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- README.md
|
51
|
+
- Rakefile
|
52
|
+
- VERSION
|
53
|
+
- app/editable-text/controllers/index_controller.rb
|
54
|
+
- app/editable-text/views/index/index.html
|
55
|
+
- lib/volt/editable/text.rb
|
56
|
+
- volt-editable-text.gemspec
|
57
|
+
homepage: ''
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.2.0
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: Volt component that gives a :editable-text control which shows text, and
|
81
|
+
lets you edit the text when it is clicked on.
|
82
|
+
test_files: []
|