bull-date-time-picker 0.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e857e755f1827198d0553bdc26cea549e0c4b1f5
4
+ data.tar.gz: 1691c94b6b28c379226185a9a66b55fdfdd18f63
5
+ SHA512:
6
+ metadata.gz: ed1d368c9564d8dc59ccf63e7e2d7e02e62aa9b8216774c4930ceab11687e14f9e1cd456148e40974c7d7a9d541cdec41912dd83d3ef48d6525d60ed04ed169c
7
+ data.tar.gz: 72a882546ba4e703771a0c0ad3a1e4ece5005f3a34c2c823727b593b9cd962fb2dc1b67b0555015a3f5a6932dafe461d1d800ea0a8c3279458c448db320b9503
@@ -0,0 +1,8 @@
1
+ if RUBY_ENGINE == 'opal'
2
+ require_relative 'datetime_ui'
3
+ else
4
+ # NOT running inside of opal, set things up
5
+ # so opal can find the files.
6
+ require 'opal'
7
+ Opal.append_path File.expand_path('..', __FILE__).untaint
8
+ end
@@ -0,0 +1,94 @@
1
+ require 'reactive-ruby'
2
+ require 'time'
3
+
4
+ def day_row week, date
5
+ ret = []
6
+ ini_month = Time.new(date.year, date.month, 1, date.hour, date.min)
7
+ ini = ini_month - (ini_month.wday-1)*24*60*60
8
+ ini = ini + 7*week*24*60*60
9
+ end_ = ini + 7*24*60*60
10
+ d = ini
11
+ while d < end_
12
+ if ini_month.month == d.month
13
+ if d == Time.new
14
+ decoration = 'xbold xunderline xtoday xdatetime-day'
15
+ else
16
+ decoration = 'xbold xdatetime-day'
17
+ end
18
+ else
19
+ decoration = 'xcursive xdatetime-day'
20
+ end
21
+ ret << {value: d.strftime('%d'), date: d, decoration: decoration}
22
+ d = d + 24*60*60
23
+ end
24
+ ret
25
+ end
26
+
27
+ class Day < React::Component::Base
28
+ param :data
29
+ param :change_date#, type: Proc
30
+
31
+ def render
32
+ span(class: params.data['decoration']){params.data['value']}.on(:click) do |event|
33
+ params.change_date.call params.data['date']
34
+ end
35
+ end
36
+ end
37
+
38
+ class Week < React::Component::Base
39
+ param :week
40
+ param :day
41
+ param :change_date#, type: Proc
42
+
43
+ def render
44
+ div(class: 'xdatetime-week') do
45
+ day_row(params.week, params.day).each do |d|
46
+ Day(data: d, change_date: params.change_date) # key?
47
+ end
48
+ end
49
+ end
50
+ end
51
+
52
+ class DateTimeInput < React::Component::Base
53
+ param :change_date #, type: Proc
54
+ param :time
55
+ param :value
56
+ param :format, type: String
57
+
58
+ before_mount do
59
+ state.show! false
60
+ state.day! Time.now
61
+ end
62
+
63
+ def render
64
+ day = params.value || Time.now
65
+ val = if params.value
66
+ params.value.strftime(params.format)
67
+ else
68
+ ''
69
+ end
70
+ div do
71
+ #input(type: :text, value: day.strftime(params.format)).on(:click) {|event| state.show! !state.show}
72
+ input(type: :text, value: val).on(:click) {|event| state.show! !state.show}
73
+ div(class: 'xdatetime-popover') do
74
+ div(class: 'xdatetime-header') do
75
+ i(class: 'minus-month fa fa-minus').on(:click) {state.day! state.day - 30*24*60*60} #{params.change_date.call day - 30*24*60*60}
76
+ span{state.day.strftime('%m')}
77
+ i(class: 'plus-month fa fa-plus').on(:click) {state.day! state.day + 30*24*60*60}
78
+ i(class: 'minus-year fa fa-minus').on(:click) {state.day! state.day - 365*24*60*60}
79
+ span{state.day.strftime('%Y')}
80
+ i(class: 'plus-year fa fa-plus').on(:click) {state.day! state.day + 365*24*60*60}
81
+ end
82
+ 6.times {|w| Week(week: w, day: state.day, change_date: params.change_date)}
83
+ div(class: 'xdatetime-bottom') do
84
+ i(class: 'minus-hour fa fa-minus').on(:click) {params.change_date.call day - 60*60; state.day! state.day - 60*60}
85
+ i(class: 'plus-hour fa fa-plus').on(:click) {params.change_date.call day + 60*60; state.day! state.day + 60*60}
86
+ span{day.strftime('%H:%M')}
87
+ i(class: 'minus-minute fa fa-minus').on(:click) {params.change_date.call day - 60; state.day! state.day - 60}
88
+ i(class: 'plus-minute fa fa-plus').on(:click) {params.change_date.call day + 60; state.day! state.day + 60}
89
+ end if params.time
90
+ end if state.show
91
+ end
92
+ end
93
+ end
94
+
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bull-date-time-picker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Miguel Alarcos
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-09 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Date time picker feature for Bull
14
+ email: miguel.alarcos@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/bull-date-time-picker.rb
20
+ - lib/datetime_ui.rb
21
+ homepage:
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.5.1
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Date time picker feature for Bull
45
+ test_files: []