glimmer-cw-cdatetime-nebula 1.5.0.2.0 → 1.5.0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b2b27a5ece4803fbb7129f299f334db84f2e04a3493771b4450422960444feeb
4
- data.tar.gz: aeb73d132ab04b909950c530699aa4ab32737c674318742e0331951f4ddb06c6
3
+ metadata.gz: 3eed11d34e046c49e1784c672e4b8a857e42415c6edfa51525367a43f36cd95b
4
+ data.tar.gz: f0f22840c3b0629c4da6e895325bbcddc8604b11efb5b914f2c67b84831ec6b2
5
5
  SHA512:
6
- metadata.gz: d4e3c7f7caa2e359da5ec4c799c573e18f3e35ca66d63b7b4aee3d5d4b72e73f8b0f39943a6d680f078b59a66f9272057e87fca41e8c6a3c2df2d295bbf3d036
7
- data.tar.gz: 90080b9ed297c65bf21007debb9e6fe58a81513371bde8f25239e3e04e8b608b988341dcd17785f841f493e70a832f272cf41772762e55b015ebc6eb86805105
6
+ metadata.gz: b4288432cfd5ce4fb201a4d104716eaaffb8c3cbb92a1f82e5ddd12f0ead0386c0b47a793a80ad1e9cdee5bb30e234258cf86a0e4762213d32acf122ab5ae534
7
+ data.tar.gz: 13245e207fd752175fee1ea8af52d8471d6b55f94c5a9c1e7282c5ba003e83a61acbe1841eb3bb7f863720f085987b44da8577a37a01115580e32056b0b9cd19
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.5.0.3.0
4
+
5
+ - Support Glimmer DSL for Opal with the `c_date_time` and `c_date_time_drop_down` keywords
6
+
3
7
  ## 1.5.0.2.0
4
8
 
5
9
  - Support Glimmer DSL for Opal with `c_time`, `c_time_drop_down`, `c_time_compact`, `c_date`, and `c_date_drop_down`
data/README.md CHANGED
@@ -126,9 +126,11 @@ Edit `app/views/layouts/application.html.erb` and add the following below other
126
126
  <%= stylesheet_link_tag 'glimmer_cw_cdatetime_nebula/glimmer_cw_cdatetime_nebula', media: 'all', 'data-turbolinks-track': 'reload' %>
127
127
  ```
128
128
 
129
- That's it! Now, you can use the following keywords:
129
+ That's it! Now, you can use the following keywords (with other keywords mentioned under [instructions](#instructions) having partial support):
130
+ - `c_date_time`
130
131
  - `c_date`
131
132
  - `c_time`
133
+ - `c_date_time_drop_down`
132
134
  - `c_date_drop_down`
133
135
  - `c_time_drop_down`
134
136
  - `c_time_compact`
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.5.0.2.0
1
+ 1.5.0.3.0
@@ -41,28 +41,31 @@ module Glimmer
41
41
  end
42
42
 
43
43
  def post_add_content
44
- if time?
45
- clocklet
46
- if drop_down?
47
- time_button_dom_element.on('click') do |event|
48
- `clocklet.open(document.getElementById(#{input_id}))`
49
- end
50
- end
51
- else
44
+ if date?
52
45
  options = {
53
46
  changeMonth: true,
54
47
  changeYear: true,
55
48
  }
56
49
  if drop_down?
57
- options = {
50
+ options = options.merge(
58
51
  showOn: 'both',
59
52
  buttonImage: 'assets/glimmer/images/calendar.gif',
60
53
  buttonImageOnly: true,
61
54
  buttonText: 'Select date',
62
- }
55
+ )
56
+ end
57
+ date_input_dom_element.datepicker(options)
58
+ end
59
+
60
+ if time?
61
+ clocklet
62
+ if drop_down?
63
+ time_button_dom_element.on('click') do |event|
64
+ `clocklet.open(document.getElementById(#{time_input_id}))`
65
+ end
63
66
  end
64
- input_dom_element.datepicker(options)
65
67
  end
68
+
66
69
  selection_value = self.selection
67
70
  @added_content = true
68
71
  self.selection = selection_value
@@ -75,20 +78,20 @@ module Glimmer
75
78
  @@clocklet_default_options_set = true
76
79
  end
77
80
  if simple?
78
- @clocklet ||= Native(`clocklet.inline(document.getElementById(#{clock_id}), {input: document.getElementById(#{input_id})})`)
81
+ @clocklet ||= Native(`clocklet.inline(document.getElementById(#{clock_id}), {input: document.getElementById(#{time_input_id})})`)
79
82
  end
80
83
  end
81
84
 
82
- def date?
83
- args.to_a.include_any?(:date_short, :date_medium, :date_long)
85
+ def date_time?
86
+ !args.to_a.include_any?(:date_short, :date_medium, :date_long) && !args.to_a.include_any?(:time_short, :time_medium)
84
87
  end
85
88
 
86
- def time?
87
- args.to_a.include_any?(:time_short, :time_medium)
89
+ def date?
90
+ args.to_a.include_any?(:date_short, :date_medium, :date_long) || date_time?
88
91
  end
89
92
 
90
- def date_time?
91
- !date? && !time?
93
+ def time?
94
+ args.to_a.include_any?(:time_short, :time_medium) || date_time?
92
95
  end
93
96
 
94
97
  def drop_down?
@@ -110,14 +113,16 @@ module Glimmer
110
113
  def selection
111
114
  if @added_content
112
115
  default_date = DateTime.new if @selection.nil?
113
- default_year = @selection&.year || default_date.year
114
- default_month = @selection&.month || default_date.month
115
- default_day = @selection&.day || default_date.day
116
- default_hour = @selection&.hour || default_date.hour
117
- default_min = @selection&.min || default_date.min
118
- default_sec = @selection&.sec || default_date.sec
116
+
117
+ current_year = @selection&.year || default_date.year
118
+ current_month = @selection&.month || default_date.month
119
+ current_day = @selection&.day || default_date.day
120
+ current_hour = @selection&.hour || default_date.hour
121
+ current_min = @selection&.min || default_date.min
122
+ current_sec = @selection&.sec || default_date.sec
123
+
119
124
  if time?
120
- time_string = input_dom_element.val
125
+ time_string = time_input_dom_element.val
121
126
  _, current_hour, current_min, am_pm = time_string.match(/(\d{1,2})\:(\d{1,2})[ ]?([APap]?\.?[Mm]?\.?)/).to_a
122
127
  current_hour ||= default_hour
123
128
  current_min ||= default_min
@@ -125,10 +130,15 @@ module Glimmer
125
130
  am_pm = am_pm.to_s.gsub('.', '').upcase
126
131
  current_hour += 12 if am_pm == 'PM'
127
132
  current_min = current_min.to_i
128
- @selection = DateTime.new(default_year, default_month, default_day, current_hour, current_min, default_sec)
129
- else
130
- @selection = DateTime.new(input_dom_element.datepicker('getDate')&.year.to_i, input_dom_element.datepicker('getDate')&.month.to_i, input_dom_element.datepicker('getDate')&.day.to_i, default_hour, default_min, default_sec)
131
133
  end
134
+
135
+ if date?
136
+ current_year = date_input_dom_element.datepicker('getDate')&.year.to_i
137
+ current_month = date_input_dom_element.datepicker('getDate')&.month.to_i
138
+ current_day = date_input_dom_element.datepicker('getDate')&.day.to_i
139
+ end
140
+
141
+ @selection = DateTime.new(current_year, current_month, current_day, current_hour, current_min, current_sec)
132
142
  @selection = @selection&.to_datetime
133
143
  else
134
144
  @initial_selection
@@ -138,15 +148,18 @@ module Glimmer
138
148
  def selection=(value)
139
149
  if @added_content
140
150
  @selection = value&.to_datetime || DateTime.new
151
+
141
152
  if time?
142
153
  formatted_time = @selection.strftime('%I:%M %p')
143
154
  if drop_down? || spinner? || compact?
144
- input_dom_element.val(formatted_time)
155
+ time_input_dom_element.val(formatted_time)
145
156
  else
146
157
  clocklet.value(formatted_time)
147
158
  end
148
- else
149
- input_dom_element.datepicker('setDate', @selection.to_time)
159
+ end
160
+
161
+ if date?
162
+ date_input_dom_element.datepicker('setDate', @selection.to_time)
150
163
  end
151
164
  else
152
165
  @initial_selection = value
@@ -167,7 +180,13 @@ module Glimmer
167
180
  end
168
181
 
169
182
  def listener_path
170
- input_path
183
+ if date_time?
184
+ "#{date_input_path}, #{time_input_path}"
185
+ elsif date?
186
+ date_input_path
187
+ else # time
188
+ time_input_path
189
+ end
171
190
  end
172
191
 
173
192
  def time_button_id
@@ -190,20 +209,36 @@ module Glimmer
190
209
  'span'
191
210
  end
192
211
 
193
- def input_id
194
- "#{id}-input"
212
+ def date_input_id
213
+ "#{id}-date-input"
195
214
  end
196
215
 
197
- def input_class
198
- "#{name}-input"
216
+ def date_input_class
217
+ "#{name}-date-input"
199
218
  end
200
219
 
201
- def input_path
202
- "#{path} ##{input_id}"
220
+ def date_input_path
221
+ "#{path} ##{date_input_id}"
203
222
  end
204
223
 
205
- def input_dom_element
206
- Document.find(input_path)
224
+ def date_input_dom_element
225
+ Document.find(date_input_path)
226
+ end
227
+
228
+ def time_input_id
229
+ "#{id}-time-input"
230
+ end
231
+
232
+ def time_input_class
233
+ "#{name}-time-input"
234
+ end
235
+
236
+ def time_input_path
237
+ "#{path} ##{time_input_id}"
238
+ end
239
+
240
+ def time_input_dom_element
241
+ Document.find(time_input_path)
207
242
  end
208
243
 
209
244
  def clock_id
@@ -223,26 +258,36 @@ module Glimmer
223
258
  end
224
259
 
225
260
  def dom
226
- input_element = date? && simple? ? 'div' : 'input'
227
- input_class_value = "#{input_class} hide" if time? && simple?
228
- input_attributes = {type: 'text', id: input_id, class: input_class_value}
229
- input_attributes['data-clocklet'] = 'format: hh:mm A; appendTo: parent;' if time?
261
+ date_input_element = simple? ? 'div' : 'input'
262
+ date_input_attributes = {type: 'text', style: 'display: inline-block; vertical-align: top;', id: date_input_id, class: date_input_class}
263
+ time_input_class_value = "#{time_input_class} hide" if time? && simple?
264
+ time_input_attributes = {type: 'text', id: time_input_id, class: time_input_class_value}
265
+ time_input_attributes['data-clocklet'] = 'format: hh:mm A; appendTo: parent;' if time?
266
+ clock_attributes = {id: clock_id, class: clock_class, style: 'display: inline-block; vertical-align: top;'}
267
+ clock_attributes[:style] = 'display: inline-block; vertical-align: top; font-size: 13px; '
230
268
  the_class = name
231
269
  the_class += ' simple' if simple?
232
270
  the_class += ' drop-down' if drop_down?
233
- the_class += ' compact' if compact?
234
271
  the_class += ' spinner' if spinner?
272
+ the_class += ' compact' if compact?
235
273
  @dom ||= html {
236
274
  span(id: id, class: the_class) {
275
+ # TODO move style somewhere to embed one time for all elements instead of repeating per element
237
276
  style {
238
277
  css {
278
+ s('.c-date-time.simple .clocklet, .c-date-time.drop-down .clocklet') {
279
+ pv 'font-size', '13px'
280
+ pv 'width', '207px'
281
+ pv 'height', '207px'
282
+ }
239
283
  s('.c-date-time.compact .clocklet, .c-date-time.spinner .clocklet') {
240
284
  pv 'display', 'none'
241
285
  }
242
286
  }
243
287
  }
244
- send(input_element, input_attributes)
245
- div(id: clock_id, class: clock_class) if time? && simple?
288
+ send(date_input_element, date_input_attributes) {} if date?
289
+ input(time_input_attributes) {} if time?
290
+ div(clock_attributes) {} if time? && simple?
246
291
  button(id: time_button_id, class: time_button_class, style: "border: none; background: url(assets/glimmer/images/ui-icons_222222_256x240.png) -80px, -96px; width: 16px; height: 16px;") if time? && drop_down?
247
292
  }
248
293
  }.to_s
@@ -57,13 +57,17 @@ class CDateTimeGallery
57
57
  text 'c_date_time'
58
58
  font name: 'Consolas', height: 14
59
59
  }
60
- c_date_time
60
+ c_date_time {
61
+ selection bind(person, :date_of_birth)
62
+ }
61
63
 
62
64
  label {
63
65
  text 'c_date'
64
66
  font name: 'Consolas', height: 14
65
67
  }
66
- c_date
68
+ c_date {
69
+ selection bind(person, :date_of_birth)
70
+ }
67
71
 
68
72
  label {
69
73
  text 'c_time'
@@ -84,6 +88,7 @@ class CDateTimeGallery
84
88
  }
85
89
  c_date_time_drop_down {
86
90
  layout_data(:fill, :center, true, true)
91
+ selection bind(person, :date_of_birth)
87
92
  }
88
93
 
89
94
  label {
@@ -92,6 +97,7 @@ class CDateTimeGallery
92
97
  }
93
98
  c_date_drop_down {
94
99
  layout_data(:fill, :center, true, true)
100
+ selection bind(person, :date_of_birth)
95
101
  }
96
102
 
97
103
  label {
@@ -114,6 +120,7 @@ class CDateTimeGallery
114
120
  }
115
121
  c_date_time_spinner {
116
122
  layout_data(:fill, :center, true, true)
123
+ selection bind(person, :date_of_birth)
117
124
  }
118
125
 
119
126
  label {
@@ -122,6 +129,7 @@ class CDateTimeGallery
122
129
  }
123
130
  c_date_spinner {
124
131
  layout_data(:fill, :center, true, true)
132
+ selection bind(person, :date_of_birth)
125
133
  }
126
134
 
127
135
  label {
@@ -144,6 +152,7 @@ class CDateTimeGallery
144
152
  }
145
153
  c_date_time_compact {
146
154
  layout_data(:fill, :center, true, true)
155
+ selection bind(person, :date_of_birth)
147
156
  }
148
157
 
149
158
  label {
@@ -152,6 +161,7 @@ class CDateTimeGallery
152
161
  }
153
162
  c_date_compact {
154
163
  layout_data(:fill, :center, true, true)
164
+ selection bind(person, :date_of_birth)
155
165
  }
156
166
 
157
167
  label {
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-cw-cdatetime-nebula
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0.2.0
4
+ version: 1.5.0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-18 00:00:00.000000000 Z
11
+ date: 2020-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 4.17.10.0
18
+ version: 4.17.10.2
19
19
  - - "<"
20
20
  - !ruby/object:Gem::Version
21
21
  version: 5.0.0.0
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 4.17.10.0
29
+ version: 4.17.10.2
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 5.0.0.0