volt-datepicker 0.1.0

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.
@@ -0,0 +1,2 @@
1
+ # Component dependencies
2
+ component 'fields'
@@ -0,0 +1,10 @@
1
+ # Place any code you want to run when the component is included on the client
2
+ # or server.
3
+
4
+ # To include code only on the client use:
5
+ # if RUBY_PLATFORM == 'opal'
6
+ #
7
+ # To include code only on the server, use:
8
+ # unless RUBY_PLATFORM == 'opal'
9
+ # ^^ this will not send compile in code in the conditional to the client.
10
+ # ^^ this include code required in the conditional.
@@ -0,0 +1 @@
1
+ # Component routes
@@ -0,0 +1,42 @@
1
+ module Datepicker
2
+ class MainController < Fields::MainController
3
+ def index_ready
4
+ # When ready, attach the date picker
5
+ root = first_element
6
+
7
+ # Setup the datepicker
8
+ field = nil
9
+
10
+ `self.field = $(root).find('.form-control').get(0)`
11
+
12
+ opts = nil
13
+ `opts = {};`
14
+
15
+ `opts.field = self.field;`
16
+ `opts.onSelect = function(date) {`
17
+ date_changed(`date`)
18
+ `};`
19
+
20
+ `self.picker = new Pikaday(opts);`
21
+ end
22
+
23
+ def date_changed(date)
24
+ unix = `date.getTime()/1000`
25
+
26
+ time = Time.at(unix)
27
+
28
+ attrs.value = time.strftime(attrs.date_format || '%m/%d/%Y')
29
+ end
30
+
31
+ def klass
32
+ attrs.klass || 'form-control'
33
+ end
34
+
35
+ def before_index_remove
36
+ `picker.destroy()`
37
+
38
+ # remove reference to dom node
39
+ @field = nil
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,13 @@
1
+ <:Body>
2
+ <div class="form-group {{ if errors }}has-error{{ elsif marked }}has-success{{ end }} has-feedback">
3
+ {{ if label.present? }}
4
+ <label class="control-label">{{ label }}</label>
5
+ {{ end }}
6
+ <input type="{{ @type }}" value="{{ attrs.value }}" e-focusout="blur" class="{{ klass }}" placeholder="{{ attrs.placeholder }}" />
7
+ {{ if errors }}
8
+ <span class="glyphicon glyphicon-remove form-control-feedback"></span>
9
+ <span class="control-label errors">{{ (errors || []).join(', ') }}</span>
10
+ {{ elsif marked }}
11
+ <span class="glyphicon glyphicon-ok form-control-feedback"></span>
12
+ {{ end }}
13
+ </div>
@@ -0,0 +1,5 @@
1
+ module Volt
2
+ module Datepicker
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,18 @@
1
+ # If you need to require in code in the gem's app folder, keep in mind that
2
+ # the app is not on the load path when the gem is required. Use
3
+ # app/{gemname}/config/initializers/boot.rb to require in client or server
4
+ # code.
5
+ #
6
+ # Also, in volt apps, you typically use the lib folder in the
7
+ # app/{componentname} folder instead of this lib folder. This lib folder is
8
+ # for setting up gem code when Bundler.require is called. (or the gem is
9
+ # required.)
10
+ #
11
+ # If you need to configure volt in some way, you can add a Volt.configure block
12
+ # in this file.
13
+
14
+ module Volt
15
+ module Datepicker
16
+ # Your code goes here...
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ # Volt sets up rspec and capybara for testing.
2
+ require 'volt/spec/setup'
3
+ Volt.spec_setup
4
+
5
+ RSpec.configure do |config|
6
+ config.run_all_when_everything_filtered = true
7
+ config.filter_run :focus
8
+
9
+ # Run specs in random order to surface order dependencies. If you find an
10
+ # order dependency and want to debug it, you can fix the order by providing
11
+ # the seed, which is printed after each run.
12
+ # --seed 1234
13
+ config.order = 'random'
14
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Volt::Datepicker do
4
+ it 'should have a version number' do
5
+ expect(Volt::Datepicker::VERSION).not_to be nil
6
+ end
7
+
8
+ it 'should do something useful' do
9
+ expect(false).to be true
10
+ end
11
+ 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
+ require 'volt/datepicker/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "volt-datepicker"
8
+ spec.version = Volt::Datepicker::VERSION
9
+ spec.authors = ["Ryan Stout"]
10
+ spec.email = ["ryanstout@gmail.com"]
11
+ spec.summary = %q{A field which shows a datepicker when focused}
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency 'volt-fields', '~> 0.1.2'
21
+
22
+ spec.add_development_dependency 'rspec', '~> 3.2.0'
23
+ spec.add_development_dependency "rake"
24
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: volt-datepicker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Stout
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: volt-fields
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 3.2.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 3.2.0
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
+ - ryanstout@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - Gemfile
65
+ - README.md
66
+ - Rakefile
67
+ - app/datepicker/assets/css/pikaday.css
68
+ - app/datepicker/assets/js/pikaday.js
69
+ - app/datepicker/config/dependencies.rb
70
+ - app/datepicker/config/initializers/boot.rb
71
+ - app/datepicker/config/routes.rb
72
+ - app/datepicker/controllers/main_controller.rb
73
+ - app/datepicker/views/main/index.html
74
+ - lib/volt/datepicker.rb
75
+ - lib/volt/datepicker/version.rb
76
+ - spec/spec_helper.rb
77
+ - spec/volt/datepicker_spec.rb
78
+ - volt-datepicker.gemspec
79
+ homepage: ''
80
+ licenses:
81
+ - MIT
82
+ metadata: {}
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 2.4.5
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: A field which shows a datepicker when focused
103
+ test_files:
104
+ - spec/spec_helper.rb
105
+ - spec/volt/datepicker_spec.rb