volt-materialize-fields 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d717b692b8d17efe00f4b19eb44a71dab93b7b9e
4
+ data.tar.gz: 7f0ac9c20ea4e02f83fe90d5421a2924ffc9ca8a
5
+ SHA512:
6
+ metadata.gz: b8c5ed35e58e6c5a133ea82c87662afab7c4871990a1bad1abf8d79e533c26bad29d3d79f975a4bc39960182c99c0a0e0b1a2fbb2bc2a3ab62c6fcd6f283b4b5
7
+ data.tar.gz: 95337f9e3a0cd9adb3ce780cc50d2505ca7be7ed0e812a9bc73610439c14a8f4f422c72f33ec53c802328e3eb3f63e1e620f642520f39ad639a8d8f434709f8a
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in volt-fields.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Volt::Fields for Materialize
2
+
3
+ This is a modified version of Volt-Fields to work with Materializecss
4
+
5
+ Provides controls for text and textarea fields (at the moment) with the following:
6
+
7
+ 1. the necessary html for materialize
8
+ 2. mark the fields when the blur event happens
9
+ 3. change line color to green or red when validating
10
+ 3. display any marked errors within the label
11
+ 4. add an icon if specified in attributes
12
+
13
+ ## Installation
14
+
15
+ This gem requires Volt -v '0.8.27.beta3' or higher and volt-materialize
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ gem 'volt-materialze-fields'
20
+
21
+ Add the fields component to your application's `app/main/config/dependencies.rb`:
22
+
23
+ component 'fields'
24
+
25
+ And then execute:
26
+
27
+ $ bundle
28
+
29
+ ### Example for user fields
30
+ <:fields:text icon="mdi-communication-email" label="E-mail" type="email" value="{{ _email }}" />
31
+ <:fields:text icon="mdi-communication-vpn-key" label="Password" type="password" value="{{ _password }}" />
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( http://github.com/acapro/volt-materialize-fields/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1 @@
1
+ # Component dependencies
@@ -0,0 +1 @@
1
+ # Component routes
@@ -0,0 +1,57 @@
1
+ module Fields
2
+ class TextController < Volt::ModelController
3
+ def index
4
+ # Default to text fields
5
+ if attrs.respond_to?(:type)
6
+ @type = attrs.type
7
+ else
8
+ @type = 'text'
9
+ end
10
+
11
+ # Get the name of the field by looking at the method scope
12
+ @field_name = attrs.value_last_method.gsub(/^[_]/, '')
13
+ end
14
+
15
+ def index_ready
16
+ set_label
17
+ end
18
+
19
+ # Find the parent reactive value that produced the value
20
+ # (usually just model._field)
21
+ def model
22
+ attrs.value_parent
23
+ end
24
+
25
+ def icon?
26
+ return attrs.icon.present?
27
+ end
28
+
29
+ def label
30
+ return attrs.label || @field_name.titleize
31
+ end
32
+
33
+ def label_id
34
+ return label.gsub(/\s+/, "").downcase
35
+ end
36
+
37
+ def set_label
38
+ input_item = Element[".input-field[item=#{label_id}]"]
39
+ input_item_id = input_item.find('input').attr('id')
40
+ input_item.find('label').attr('for', input_item_id)
41
+ end
42
+
43
+ # Find the errors for this field
44
+ def errors
45
+ model.marked_errors[@field_name]
46
+ end
47
+
48
+ # When a field goes out of focus, then we want to start checking a field
49
+ def blur
50
+ attrs.value_parent.mark_field!(@field_name)
51
+ end
52
+
53
+ def marked
54
+ model.marked_fields[@field_name]
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,6 @@
1
+ require 'fields/controllers/text_controller'
2
+
3
+ module Fields
4
+ class TextareaController < TextController
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ <:Body>
2
+ <div class="input-field" item="{{label_id}}">
3
+ {{ if icon? }}<i class="{{attrs.icon}} prefix"></i>{{ end }}
4
+ <input type="{{ @type }}" value="{{ attrs.value }}" e-focusout="blur" class="{{ if errors }}invalid{{ elsif marked }}valid{{ end }}">
5
+ <label>{{label}}{{ if errors }} ({{ errors.or([]).join(', ') }}){{end}}</label>
6
+ </div>
@@ -0,0 +1,6 @@
1
+ <:Body>
2
+ <div class="input-field" item="{{label_id}}">
3
+ {{ if icon? }}<i class="{{attrs.icon}} prefix"></i>{{ end }}
4
+ <textarea type="{{ @type }}" value="{{ attrs.value }}" e-focusout="blur" class="{{ if errors }}invalid{{ elsif marked }}valid{{ end }} materialize-textarea"></textarea>
5
+ <label>{{label}}{{ if errors }} ({{ errors.or([]).join(', ') }}){{end}}</label>
6
+ </div>
@@ -0,0 +1,5 @@
1
+ module Volt
2
+ class Fields
3
+ # Your code goes here...
4
+ end
5
+ end
@@ -0,0 +1,25 @@
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-materialize-fields"
10
+ spec.version = version
11
+ spec.authors = ["Adam Cooper"]
12
+ spec.email = ["mail@adamcooper.de"]
13
+ spec.summary = %q{Provides controls for text and textarea fields with built in error reporting and materialize formatting}
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.8.27.beta3'
23
+ spec.add_development_dependency "volt-materialize", '>= 0.0.4'
24
+ spec.add_development_dependency "rake"
25
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: volt-materialize-fields
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Adam Cooper
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-05 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.8.27.beta3
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.8.27.beta3
27
+ - !ruby/object:Gem::Dependency
28
+ name: volt-materialize
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.4
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.4
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - mail@adamcooper.de
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - README.md
65
+ - Rakefile
66
+ - VERSION
67
+ - app/fields/config/dependencies.rb
68
+ - app/fields/config/routes.rb
69
+ - app/fields/controllers/text_controller.rb
70
+ - app/fields/controllers/textarea_controller.rb
71
+ - app/fields/views/text/index.html
72
+ - app/fields/views/textarea/index.html
73
+ - lib/volt/fields.rb
74
+ - volt-fields.gemspec
75
+ homepage: ''
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.2.2
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Provides controls for text and textarea fields with built in error reporting
99
+ and materialize formatting
100
+ test_files: []