glimmer-cw-cdatetime-nebula 1.5.0.1.0 → 1.5.0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +88 -20
- data/VERSION +1 -1
- data/app/assets/stylesheets/glimmer_cw_cdatetime_nebula/clocklet.min.css +1 -0
- data/app/assets/stylesheets/glimmer_cw_cdatetime_nebula/glimmer_cw_cdatetime_nebula.css +15 -0
- data/lib/glimmer-cw-cdatetime-nebula.rb +29 -14
- data/lib/glimmer-cw-cdatetime-nebula/ext/glimmer/swt/c_date_time_proxy.rb +7 -7
- data/lib/glimmer-cw-cdatetime-nebula/ext/glimmer/swt/cdt_proxy.rb +11 -10
- data/lib/glimmer-cw-cdatetime-nebula/vendor/clocklet.min.js +1 -0
- data/lib/glimmer_cw_cdatetime_nebula/engine.rb +9 -0
- data/lib/views/nebula/c_date_time.rb +3 -3
- data/opal/glimmer-cw-cdatetime-nebula/ext/glimmer/cdt.rb +499 -0
- data/opal/glimmer-cw-cdatetime-nebula/ext/glimmer/swt/c_date_time_proxy.rb +281 -0
- data/opal/views/nebula/c_date_time.rb +1 -0
- data/samples/nebula/c_date_time_gallery.rb +27 -13
- metadata +12 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2b27a5ece4803fbb7129f299f334db84f2e04a3493771b4450422960444feeb
|
4
|
+
data.tar.gz: aeb73d132ab04b909950c530699aa4ab32737c674318742e0331951f4ddb06c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4e3c7f7caa2e359da5ec4c799c573e18f3e35ca66d63b7b4aee3d5d4b72e73f8b0f39943a6d680f078b59a66f9272057e87fca41e8c6a3c2df2d295bbf3d036
|
7
|
+
data.tar.gz: 90080b9ed297c65bf21007debb9e6fe58a81513371bde8f25239e3e04e8b608b988341dcd17785f841f493e70a832f272cf41772762e55b015ebc6eb86805105
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 1.5.0.2.0
|
4
|
+
|
5
|
+
- Support Glimmer DSL for Opal with `c_time`, `c_time_drop_down`, `c_time_compact`, `c_date`, and `c_date_drop_down`
|
6
|
+
- Update c_date_time_gallery sample to use data-binding
|
7
|
+
- c_date_time_gallery sample running in Glimmer DSL for Opal
|
8
|
+
- Upgraded gem to a Rails Engine gem to share assets with a Rails app
|
9
|
+
|
3
10
|
## 1.5.0.1.0
|
4
11
|
|
5
12
|
- Upgraded to support glimmer-dsl-swt 4.17.2.0 up to 5.0.0.0
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Nebula CDateTime Widget 1.5.0.
|
1
|
+
# Nebula CDateTime Widget 1.5.0.2.0
|
2
2
|
## [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer-dsl-swt/master/images/glimmer-logo-hi-res.png" height=40 /> Glimmer Custom Widget](https://github.com/AndyObtiva/glimmer-dsl-swt#custom-widget-gem)
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/glimmer-cw-cdatetime-nebula.svg)](http://badge.fury.io/rb/glimmer-cw-cdatetime-nebula)
|
4
4
|
|
@@ -8,18 +8,25 @@ The [Nebula CDateTime Widget](https://www.eclipse.org/nebula/widgets/cdatetime/c
|
|
8
8
|
|
9
9
|
Packaged as a [Glimmer Custom Widget](https://github.com/AndyObtiva/glimmer-dsl-swt#custom-widget-gem) to provide date/time selection via a combo/dropdown-style widget in [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) using the `c_date_time` [Glimmer DSL](https://github.com/AndyObtiva/glimmer-dsl-swt#glimmer-gui-dsl-syntax) keyword.
|
10
10
|
|
11
|
+
Now, also supports [Glimmer DSL for Opal](#glimmer-dsl-for-opal) Auto-Webifier of Desktop Apps via Rails/Opal.
|
12
|
+
|
11
13
|
[glimmer-cw-cdatetime-nebula](https://rubygems.org/gems/glimmer-cw-cdatetime-nebula) 1.5.0.x.y gem versions map to Nebula CDateTime Widget version 1.5.0 (which comes with [Nebula 2.4.2](https://www.eclipse.org/nebula/releases/2.4.2/index.php))
|
12
14
|
|
13
15
|
## Table of contents
|
14
16
|
|
15
|
-
- [Nebula CDateTime Widget 1.5.0.
|
17
|
+
- [Nebula CDateTime Widget 1.5.0.2.0](#nebula-cdatetime-widget-15020)
|
16
18
|
- [Pre-requisites](#pre-requisites)
|
17
19
|
- [Setup](#setup)
|
18
|
-
- [Glimmer
|
19
|
-
|
20
|
-
|
20
|
+
- [Glimmer DSL for SWT](#glimmer-dsl-for-swt)
|
21
|
+
- [Glimmer Application](#glimmer-application)
|
22
|
+
- [Glimmer Custom Shell or Glimmer Custom Widget](#glimmer-custom-shell-or-glimmer-custom-widget)
|
23
|
+
- [Java Imports](#java-imports)
|
24
|
+
- [Glimmer DSL for Opal](#glimmer-dsl-for-opal)
|
25
|
+
- [Setup](#setup)
|
21
26
|
- [Instructions](#instructions)
|
22
27
|
- [Sample](#sample)
|
28
|
+
- [Glimmer DSL for SWT Sample](#glimmer-dsl-for-swt-sample)
|
29
|
+
- [Glimmer DSL for Opal Sample](#glimmer-dsl-for-opal-sample)
|
23
30
|
- [Simple Style](#simple-style)
|
24
31
|
- [`c_date_time`](#cdatetime)
|
25
32
|
- [`c_date`](#cdate)
|
@@ -50,22 +57,29 @@ Packaged as a [Glimmer Custom Widget](https://github.com/AndyObtiva/glimmer-dsl-
|
|
50
57
|
|
51
58
|
## Pre-requisites
|
52
59
|
|
53
|
-
- [Glimmer](https://github.com/AndyObtiva/glimmer-dsl-swt) application, [Glimmer](https://github.com/AndyObtiva/glimmer-dsl-swt) custom shell, or another [Glimmer](https://github.com/AndyObtiva/glimmer-dsl-swt) custom widget
|
60
|
+
- [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) application, [Glimmer](https://github.com/AndyObtiva/glimmer-dsl-swt) custom shell, or another [Glimmer](https://github.com/AndyObtiva/glimmer-dsl-swt) custom widget
|
54
61
|
- JRuby version required by [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt)
|
55
62
|
- Java version required by [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt)
|
56
63
|
|
64
|
+
For [Glimmer DSL for Opal](https://github.com/AndyObtiva/glimmer-dsl-opal) auto-webification, this is also required:
|
65
|
+
|
66
|
+
- [Glimmer DSL for Opal](https://github.com/AndyObtiva/glimmer-dsl-opal) Rails application
|
67
|
+
- [Clocklet](https://github.com/luncheon/clocklet) (included in gem)
|
68
|
+
|
57
69
|
## Setup
|
58
70
|
|
59
71
|
Versions follow this convention:
|
60
72
|
- First 3 numbers map to the official Nebula CDateTime library version (e.g. 1.5.0)
|
61
73
|
- Last 2 numbers map to minor and patch versions for Glimmer Custom Widget wrapper
|
62
74
|
|
63
|
-
### Glimmer
|
75
|
+
### Glimmer DSL for SWT
|
76
|
+
|
77
|
+
#### Glimmer Application
|
64
78
|
|
65
79
|
Add the following to a [Glimmer](https://github.com/AndyObtiva/glimmer-dsl-swt) application `Gemfile`:
|
66
80
|
|
67
81
|
```ruby
|
68
|
-
gem 'glimmer-cw-cdatetime-nebula', '1.5.0.
|
82
|
+
gem 'glimmer-cw-cdatetime-nebula', '~> 1.5.0.2.0'
|
69
83
|
```
|
70
84
|
|
71
85
|
Run:
|
@@ -76,7 +90,7 @@ jruby -S bundle
|
|
76
90
|
|
77
91
|
(or just `bundle` if using [RVM)
|
78
92
|
|
79
|
-
|
93
|
+
#### Glimmer Custom Shell or Glimmer Custom Widget
|
80
94
|
|
81
95
|
When reusing in a [Glimmer](https://github.com/AndyObtiva/glimmer-dsl-swt) custom shell or custom widget, you can follow the same steps for Glimmer application, and then add a require statement to your library file after `glimmer-dsl-swt` and before additional library require statements:
|
82
96
|
|
@@ -86,12 +100,43 @@ require 'glimmer-cw-cdatetime-nebula'
|
|
86
100
|
# ... more require statements follow
|
87
101
|
```
|
88
102
|
|
89
|
-
|
103
|
+
#### Java Imports
|
90
104
|
|
91
105
|
Requiring the gem automatically configures java imports in [Glimmer](https://github.com/AndyObtiva/glimmer-dsl-swt) for auto import via [JRuby](https://www.jruby.org/) `include_package` on first use:
|
92
106
|
- `org.eclipse.nebula.cwt`
|
93
107
|
- `org.eclipse.nebula.widgets.cdatetime`
|
94
108
|
|
109
|
+
### Glimmer DSL for Opal
|
110
|
+
|
111
|
+
The [glimmer-cw-cdatetime-nebula](https://rubygems.org/gems/glimmer-cw-cdatetime-nebula) gem is a Rails Engine gem that includes assets and supports [Glimmer DSL for Opal](https://github.com/AndyObtiva/glimmer-dsl-opal).
|
112
|
+
|
113
|
+
#### Setup
|
114
|
+
|
115
|
+
Please follow the following steps to setup assuming you have a pre-setup [Glimmer DSL for Opal](https://github.com/AndyObtiva/glimmer-dsl-opal) Rails app.
|
116
|
+
|
117
|
+
Add the following to `Gemfile` after `glimmer-dsl-opal` and other `glimer-dsl-*` gems:
|
118
|
+
|
119
|
+
```ruby
|
120
|
+
gem 'glimmer-cw-cdatetime-nebula', '~> 1.5.0.2.0'
|
121
|
+
```
|
122
|
+
|
123
|
+
Edit `app/views/layouts/application.html.erb` and add the following below other `stylesheet_link_tag` declarations:
|
124
|
+
|
125
|
+
```erb
|
126
|
+
<%= stylesheet_link_tag 'glimmer_cw_cdatetime_nebula/glimmer_cw_cdatetime_nebula', media: 'all', 'data-turbolinks-track': 'reload' %>
|
127
|
+
```
|
128
|
+
|
129
|
+
That's it! Now, you can use the following keywords:
|
130
|
+
- `c_date`
|
131
|
+
- `c_time`
|
132
|
+
- `c_date_drop_down`
|
133
|
+
- `c_time_drop_down`
|
134
|
+
- `c_time_compact`
|
135
|
+
|
136
|
+
Here is a sample Rails app that has everything configured (you just have to edit `app/assets/javascripts/application.rb` to enable the desired sample):
|
137
|
+
|
138
|
+
https://github.com/AndyObtiva/sample-glimmer-dsl-opal-rails5-app
|
139
|
+
|
95
140
|
## Instructions
|
96
141
|
|
97
142
|
This [glimmer-cw-cdatetime-nebula](https://rubygems.org/gems/glimmer-cw-cdatetime-nebula) gem adds the `c_date_time` keyword to the [Glimmer GUI DSL](https://github.com/AndyObtiva/glimmer-dsl-swt#glimmer-gui-dsl-syntax) as well as other alias keywords (e.g. drop down style, spinner style, and compact style) as explained below.
|
@@ -108,6 +153,8 @@ Further instructions may be found at the [Nebula CDateTime Widget homepage](http
|
|
108
153
|
|
109
154
|
### Sample
|
110
155
|
|
156
|
+
#### Glimmer DSL for SWT Sample
|
157
|
+
|
111
158
|
Please run the following command to launch the [Nebula CDateTime Glimmer Custom Widget Gallery](samples/nebula/c_date_time_gallery.rb) app:
|
112
159
|
|
113
160
|
```
|
@@ -123,10 +170,10 @@ class CDateTimeGallery
|
|
123
170
|
include Glimmer
|
124
171
|
|
125
172
|
def open
|
126
|
-
shell {
|
173
|
+
shell {
|
127
174
|
grid_layout(4, false) {
|
128
175
|
vertical_spacing 20
|
129
|
-
}
|
176
|
+
}
|
130
177
|
text 'Nebula CDateTime Glimmer Custom Widget Gallery'
|
131
178
|
|
132
179
|
label {
|
@@ -139,7 +186,7 @@ class CDateTimeGallery
|
|
139
186
|
|
140
187
|
tab_folder {
|
141
188
|
tab_item {
|
142
|
-
grid_layout 2, false
|
189
|
+
grid_layout 2, false
|
143
190
|
text 'Simple'
|
144
191
|
|
145
192
|
label {
|
@@ -191,7 +238,7 @@ class CDateTimeGallery
|
|
191
238
|
}
|
192
239
|
|
193
240
|
tab_item {
|
194
|
-
grid_layout 2, false
|
241
|
+
grid_layout 2, false
|
195
242
|
text 'Spinner'
|
196
243
|
|
197
244
|
label {
|
@@ -220,7 +267,7 @@ class CDateTimeGallery
|
|
220
267
|
}
|
221
268
|
|
222
269
|
tab_item {
|
223
|
-
grid_layout 2, false
|
270
|
+
grid_layout 2, false
|
224
271
|
text 'Compact'
|
225
272
|
|
226
273
|
label {
|
@@ -246,15 +293,37 @@ class CDateTimeGallery
|
|
246
293
|
c_time_compact {
|
247
294
|
layout_data(:fill, :center, true, true)
|
248
295
|
}
|
249
|
-
}
|
296
|
+
}
|
250
297
|
}
|
251
|
-
}.open
|
252
|
-
end
|
298
|
+
}.open
|
299
|
+
end
|
253
300
|
end
|
254
301
|
|
255
302
|
CDateTimeGallery.new.open
|
256
303
|
```
|
257
304
|
|
305
|
+
#### Glimmer DSL for Opal Sample
|
306
|
+
|
307
|
+
The same Glimmer DSL for SWT sample runs in Glimmer DSL for Opal unchanged, albeit with partial support at the moment.
|
308
|
+
|
309
|
+
Open a `Document.ready?` block in `app/assets/javascripts/application.rb` and add inside it the Glimmer GUI DSL code above or a require statement as done below.
|
310
|
+
|
311
|
+
```ruby
|
312
|
+
require 'glimmer-dsl-opal'
|
313
|
+
|
314
|
+
Document.ready? do
|
315
|
+
require 'samples/nebula/c_date_time_gallery.rb'
|
316
|
+
end
|
317
|
+
```
|
318
|
+
|
319
|
+
Run:
|
320
|
+
|
321
|
+
`rails s`
|
322
|
+
|
323
|
+
Visit: 'http://localhost:3000'
|
324
|
+
|
325
|
+
![simple screenshot](images/glimmer-cw-cdatetime-nebula-opal-simple.png)
|
326
|
+
|
258
327
|
### Simple Style
|
259
328
|
|
260
329
|
Simple style is the default style when using `c_date_time`, `c_date`, and `c_time` keywords. It displays a graphical calendar/clock.
|
@@ -389,7 +458,7 @@ The `selection` property provides access to the value selected by the user. It c
|
|
389
458
|
Example:
|
390
459
|
|
391
460
|
```ruby
|
392
|
-
# ...
|
461
|
+
# ...
|
393
462
|
composite {
|
394
463
|
# ...
|
395
464
|
@start_at = c_date_time(:border, :drop_down, :date_long) {
|
@@ -476,7 +545,6 @@ c_time { |proxy|
|
|
476
545
|
}
|
477
546
|
```
|
478
547
|
|
479
|
-
|
480
548
|
## TODO
|
481
549
|
|
482
550
|
[TODO.md](TODO.md)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.5.0.
|
1
|
+
1.5.0.2.0
|
@@ -0,0 +1 @@
|
|
1
|
+
.clocklet,.clocklet-ampm,.clocklet-container,.clocklet-dial,.clocklet-hand,.clocklet-hand-origin,.clocklet-plate,.clocklet-tick{touch-action:manipulation;touch-action:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;box-sizing:border-box;position:absolute;font-size:inherit}.clocklet--inline,.clocklet-container--inline{position:static}.clocklet-container{display:inline;width:0;height:0}.clocklet{font-size:16px;width:270px;height:270px;margin-top:1px;padding:8px;border-radius:3px}.clocklet:not(.clocklet--showing){transition:opacity .2s ease-out}.clocklet:not(.clocklet--shown):not(.clocklet--inline){opacity:0;pointer-events:none}[data-clocklet-placement=bottom][data-clocklet-alignment=left]{transform-origin:0 0}[data-clocklet-placement=bottom][data-clocklet-alignment=right]{transform-origin:100% 0}[data-clocklet-placement=top][data-clocklet-alignment=left]{transform-origin:0 100%}[data-clocklet-placement=top][data-clocklet-alignment=right]{transform-origin:100% 100%}.clocklet-plate{position:relative;height:100%;border-radius:50%}.clocklet-dial{left:0;top:0;right:0;bottom:0;margin:auto;border-radius:50%}.clocklet-ampm:before,.clocklet-hand,.clocklet-hand-origin,.clocklet-tick{z-index:1}.clocklet-hand{left:0;top:6.4%;right:0;bottom:50%;margin:auto;transform-origin:50% 100%}.clocklet-tick{width:1.75em;height:1.75em;margin:-.875em;border-radius:50%;padding:0;outline:0;border:0;cursor:pointer;background-color:transparent;color:inherit;font-family:inherit;font-weight:inherit}.clocklet-tick:before{content:attr(data-clocklet-tick-value)}.clocklet-ampm{top:calc(50% + .75em);left:0;right:0;margin:auto;width:3em;height:1.5em;border-radius:.75em;cursor:pointer}.clocklet-ampm,.clocklet-ampm:before{display:flex;align-items:center;justify-content:center}.clocklet-ampm:before{position:relative;width:2em;height:2em;border-radius:50%;content:attr(data-clocklet-ampm);transform:translateX(-1em)}.clocklet--shown .clocklet-ampm:before{transition:transform .1s ease-out}.clocklet-ampm[data-clocklet-ampm=pm]:before{transform:translateX(1em)}.clocklet-ampm[data-clocklet-ampm-formatted]:not([data-clocklet-ampm-formatted=""]):before{content:attr(data-clocklet-ampm-formatted)}.clocklet-hand-origin{left:calc(50% - 5px);top:calc(50% - 5px);right:calc(50% - 5px);bottom:calc(50% - 5px);border-radius:50%}.clocklet:not([data-clocklet-value]) .clocklet-hand,.clocklet:not([data-clocklet-value]) .clocklet-hand-origin,.clocklet[data-clocklet-value=""] .clocklet-hand,.clocklet[data-clocklet-value=""] .clocklet-hand-origin{display:none}.clocklet-dial--hour{width:calc(40% + 56px);height:calc(40% + 56px)}.clocklet-hand--hour{width:8px}.clocklet-tick--hour[data-clocklet-tick-value="0"]:before{content:"12"}.clocklet-dial--minute{width:100%;height:100%}.clocklet-hand--minute{width:2px}.clocklet-tick--minute:not([data-clocklet-tick-value$="0"]):not([data-clocklet-tick-value$="5"]){transform:scale(.6)}@media screen and (max-width:480px){.clocklet{transform:scale(.8)}}@media screen and (max-width:400px){.clocklet{transform:scale(.75)}}.clocklet{border:1px solid #ddd;background-color:#eee}[data-clocklet-placement=top]{box-shadow:4px -4px 4px hsla(0,0%,50.2%,.5)}[data-clocklet-placement=bottom]{box-shadow:4px 4px 4px hsla(0,0%,50.2%,.5)}.clocklet-plate{background-color:#fff}.clocklet-hand{background-color:#a1ddff}.clocklet-hand-origin{background-color:#4bf}.clocklet-tick--selected{background-color:#57c2ff;color:#fff}.clocklet--hoverable:not(.clocklet--dragging) .clocklet-tick:hover{background-color:#7ccfff}.clocklet-ampm{background-color:hsla(0,0%,80%,.6)}.clocklet-ampm:before{background-color:#57c2ff;color:#fff}.clocklet-ampm:hover:before{background-color:#7ccfff}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
|
6
|
+
* vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2020 - Andy Maleh
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
5
5
|
# "Software"), to deal in the Software without restriction, including
|
@@ -7,10 +7,10 @@
|
|
7
7
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
8
|
# permit persons to whom the Software is furnished to do so, subject to
|
9
9
|
# the following conditions:
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# The above copyright notice and this permission notice shall be
|
12
12
|
# included in all copies or substantial portions of the Software.
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
15
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
16
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
@@ -19,18 +19,33 @@
|
|
19
19
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
|
-
|
22
|
+
if RUBY_ENGINE == 'ruby'
|
23
|
+
require 'opal'
|
24
|
+
Opal.append_path File.expand_path('../../opal', __FILE__).untaint
|
25
|
+
Opal.append_path File.expand_path('..', __FILE__).untaint
|
26
|
+
Opal.append_path File.expand_path('../..', __FILE__).untaint
|
27
|
+
|
28
|
+
require_relative 'glimmer_cw_cdatetime_nebula/engine'
|
29
|
+
elsif RUBY_ENGINE == 'opal'
|
30
|
+
require 'glimmer-dsl-swt'
|
23
31
|
|
24
|
-
require 'glimmer-
|
32
|
+
require 'glimmer-cw-cdatetime-nebula/vendor/clocklet.min'
|
25
33
|
|
26
|
-
|
27
|
-
|
34
|
+
require 'glimmer-cw-cdatetime-nebula/ext/glimmer/dsl/swt/cdt_expression'
|
35
|
+
require 'glimmer-cw-cdatetime-nebula/ext/glimmer/swt/c_date_time_proxy'
|
36
|
+
require 'views/nebula/c_date_time'
|
37
|
+
else # jruby
|
38
|
+
require 'glimmer-dsl-swt'
|
39
|
+
|
40
|
+
require_relative '../vendor/nebula/org.eclipse.nebula.cwt_1.1.0.202007241204.jar'
|
41
|
+
require_relative '../vendor/nebula/org.eclipse.nebula.widgets.cdatetime_1.5.0.202007241204.jar'
|
28
42
|
|
29
|
-
Glimmer::Config.import_swt_packages += [
|
30
|
-
|
31
|
-
|
32
|
-
]
|
43
|
+
Glimmer::Config.import_swt_packages += [
|
44
|
+
'org.eclipse.nebula.cwt',
|
45
|
+
'org.eclipse.nebula.widgets.cdatetime',
|
46
|
+
]
|
33
47
|
|
34
|
-
require 'glimmer-cw-cdatetime-nebula/ext/glimmer/dsl/swt/cdt_expression'
|
35
|
-
require 'glimmer-cw-cdatetime-nebula/ext/glimmer/swt/c_date_time_proxy'
|
36
|
-
require 'views/nebula/c_date_time'
|
48
|
+
require 'glimmer-cw-cdatetime-nebula/ext/glimmer/dsl/swt/cdt_expression'
|
49
|
+
require 'glimmer-cw-cdatetime-nebula/ext/glimmer/swt/c_date_time_proxy'
|
50
|
+
require 'views/nebula/c_date_time'
|
51
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2020 - Andy Maleh
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
5
5
|
# "Software"), to deal in the Software without restriction, including
|
@@ -7,10 +7,10 @@
|
|
7
7
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
8
|
# permit persons to whom the Software is furnished to do so, subject to
|
9
9
|
# the following conditions:
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# The above copyright notice and this permission notice shall be
|
12
12
|
# included in all copies or substantial portions of the Software.
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
15
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
16
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
@@ -22,8 +22,8 @@
|
|
22
22
|
module Glimmer
|
23
23
|
module SWT
|
24
24
|
# This modules just configures Glimmer to work with Nebula CDateTime
|
25
|
-
# Since it is wrapping an existing SWT widget with the same name,
|
26
|
-
# it is not implemented as a typical "Glimmer Custom Widget", yet
|
25
|
+
# Since it is wrapping an existing SWT widget with the same name,
|
26
|
+
# it is not implemented as a typical "Glimmer Custom Widget", yet
|
27
27
|
# just a Glimmer widget proxy that extends Glimmer::SWT::WidgetProxy
|
28
28
|
class CDateTimeProxy < WidgetProxy
|
29
29
|
def text_widget_proxy
|
@@ -61,7 +61,7 @@ module Glimmer
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
WidgetProxy::DEFAULT_INITIALIZERS['c_time'] = WidgetProxy::DEFAULT_INITIALIZERS['c_time_compact'] = WidgetProxy::DEFAULT_INITIALIZERS['c_time_spinner'] = WidgetProxy::DEFAULT_INITIALIZERS['c_time_drop_down'] = lambda do |widget|
|
64
|
-
has_pattern_style = %w[time_short time_medium date_short date_medium date_long].reduce(false) {|result, style| result || widget.get_data('proxy').has_style?(style)}
|
64
|
+
has_pattern_style = %w[time_short time_medium date_short date_medium date_long].reduce(false) {|result, style| result || widget.get_data('proxy').has_style?(style)}
|
65
65
|
unless has_pattern_style
|
66
66
|
widget.format = Glimmer::SWT::CDTProxy[:time_short]
|
67
67
|
widget.pattern = 'hh:mm a'
|
@@ -80,7 +80,7 @@ module Glimmer
|
|
80
80
|
'c_date_time_drop_down' => 'c_date_time',
|
81
81
|
'c_date_drop_down' => 'c_date_time',
|
82
82
|
'c_time_drop_down' => 'c_date_time',
|
83
|
-
)
|
83
|
+
)
|
84
84
|
|
85
85
|
private
|
86
86
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2020 - Andy Maleh
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
5
5
|
# "Software"), to deal in the Software without restriction, including
|
@@ -7,10 +7,10 @@
|
|
7
7
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
8
|
# permit persons to whom the Software is furnished to do so, subject to
|
9
9
|
# the following conditions:
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# The above copyright notice and this permission notice shall be
|
12
12
|
# included in all copies or substantial portions of the Software.
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
15
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
16
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
@@ -20,21 +20,22 @@
|
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
22
|
require 'glimmer/swt/style_constantizable'
|
23
|
+
require 'glimmer-cw-cdatetime-nebula/ext/glimmer/cdt' if RUBY_ENGINE == 'opal'
|
23
24
|
|
24
25
|
module Glimmer
|
25
26
|
module SWT
|
26
27
|
# Proxy for org.eclipse.nebula.widgets.cdatetime.CDT
|
27
28
|
#
|
28
29
|
# Follows the Proxy Design Pattern
|
29
|
-
class CDTProxy
|
30
|
-
include Glimmer::SWT::StyleConstantizable
|
30
|
+
class CDTProxy
|
31
|
+
include Glimmer::SWT::StyleConstantizable
|
31
32
|
|
32
33
|
class << self
|
33
34
|
JAVA_IMPORT = 'org.eclipse.nebula.widgets.cdatetime.CDT'
|
34
35
|
|
35
|
-
java_import JAVA_IMPORT
|
36
|
+
java_import JAVA_IMPORT if RUBY_ENGINE == 'jruby'
|
36
37
|
|
37
|
-
def constant_java_import
|
38
|
+
def constant_java_import
|
38
39
|
JAVA_IMPORT
|
39
40
|
end
|
40
41
|
|
@@ -46,10 +47,10 @@ module Glimmer
|
|
46
47
|
CDT::NONE
|
47
48
|
end
|
48
49
|
|
49
|
-
def extra_styles
|
50
|
-
{}
|
51
|
-
end
|
52
50
|
end
|
51
|
+
|
53
52
|
end
|
53
|
+
|
54
54
|
end
|
55
|
+
|
55
56
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).clocklet=e()}(this,function(){"use strict";function r(t,e,o){return t=String(t),!e||!isFinite(e)||t.length>=e?t:n(e-t.length,o)+t}function t(t,e,o){return t=String(t),!e||!isFinite(e)||t.length>=e?t:t+n(e-t.length,o)}function n(t,e){for(var o=e=null==e||""===e?" ":String(e);o.length<t;)o+=e;return o.substr(0,t)}function o(){for(var t=0,e=arguments.length;t<e;++t){var o=arguments[t];if("number"==typeof o)return o;if("string"==typeof o){o=parseFloat(o);if(isFinite(o))return o}}}var l=1e3,c=60*l,i=60*c,e=12*i,a=24*i;function u(){return(Date.now()-(new Date).getTimezoneOffset()*c)%a}function s(t){t=Math.floor(t)%a;return 0<=t?t:t+a}function p(t){return e<=t?t-e:t}function k(t){return t<e?t+e:t}function d(t,e){switch(t=s(t),e&&String(e)[0].toLowerCase()){case"a":return p(t);case"p":return k(t);default:return t}}function f(t){switch(typeof t){case"number":return s(t);case"string":return function(t){if(!(t=t&&String(t).replace(/[\uff00-\uffef]/g,function(t){return String.fromCharCode(t.charCodeAt(0)-65248)}).replace(/\s/g,"").replace(/(a|p)\.?m?\.?$/i,function(t,e){return e.toLowerCase()})))return 0;if("now"===t.toLowerCase())return u();t=t.match(/^([+-]?[0-9]{1,2})(?:([0-9]{2})(?:([0-9]{2})([0-9]*))?)?(a|p)?$/i)||t.match(/^([+-]?[0-9]*\.[0-9]*)()()()(a|p)?$/i)||t.match(/^([+-]?[0-9]*\.?[0-9]*):([+-]?[0-9]*\.?[0-9]*)(?::([+-]?[0-9]*\.?[0-9]*))?()(a|p)?$/i);return t?d((t[1]?parseFloat(t[1])*i:0)+(t[2]?parseFloat(t[2])*c:0)+(t[3]?parseFloat(t[3])*l:0)+(t[4]?1e3*parseFloat("0."+t[4]):0),t[5]):NaN}(t);case"object":if(t)return function(t){if("number"==typeof t.totalMilliseconds)return s(t.totalMilliseconds);var e=o(t.h,t.hour,t.hours,0)*i+o(t.m,t.minute,t.minutes,0)*c+o(t.s,t.second,t.seconds,0)*l+o(t.S,t.millisecond,t.milliseconds,0);return!0!==t.am&&!1!==t.pm?!0!==t.pm&&!1!==t.am?d(e,t.a):k(e):p(e)}(t instanceof Array?{h:t[0],m:t[1],s:t[2],S:t[3]}:t)}return NaN}function b(){return/\\.|HH?|hh?|kk?|mm?|ss?|S{1,3}|AA?|aa?|_H|_h|_k|_m|_s/g}var h={H:m(0,23),HH:m(0,23,2,"0"),_H:m(0,23,2),h:m(1,12),hh:m(1,12,2,"0"),_h:m(1,12,2),k:m(0,11),kk:m(0,11,2,"0"),_k:m(0,23,2),m:m(0,59),mm:m(0,59,2,"0"),_m:m(0,59,2),s:m(0,59),ss:m(0,59,2,"0"),_s:m(0,59,2),S:m(0,9),SS:m(0,99,2,"0"),SSS:m(0,999,3,"0"),a:function(e){return function(t){return"pm"===e?"am":"pm"}},A:function(e){return function(t){return"PM"===e?"AM":"PM"}},aa:function(e){return function(t){return"p.m."===e?"a.m.":"p.m."}},AA:function(e){return function(t){return"P.M."===e?"A.M.":"P.M."}}};function m(c,i,a,u){return void 0===a&&(a=1),function(l){return function(t,e){var o,n,o=(o=parseInt(l,10)+t,n=c,t=i,e?(o=(o-n)%(++t-n))<0?o+t:o+n:o<n?n:t<o?t:o);return isNaN(o)?void 0:r(o,a,u)}}}function y(t,e,o){for(var n=v(t),l=0,c=0,i=0;i<n.length;++i){var a=n[i];if(a.literal){var u=e.indexOf(a.property,l);if(-1===u||o<=u){if(0===i)return;var r=e.slice(c,u);return{property:s=n[i-1].property,index:c,value:r,adjust:h[s](r)}}c=l=u+a.property.length}else"_"===a.property[0]&&" "===e[l]&&++l}t=n[n.length-1];if(t&&!t.literal){var s,r=e.slice(l);return{property:s=t.property,index:l,value:r,adjust:h[s](r)}}}function v(t){for(var e,o=b(),n=[],l=0;e=o.exec(t);){var c=e.index,i=o.lastIndex;l!==c&&n.push({index:l,property:t.slice(l,c),literal:!0}),"\\"===e[0][0]?n.push({index:c,property:e[0].slice(1),literal:!0}):n.push({index:c,property:e[0],literal:!1}),l=i}return l<t.length&&n.push({index:l,property:t.slice(l),literal:!0}),n}var g=(Object.defineProperty(O.prototype,"hour",{get:function(){return Math.floor(this._totalMilliseconds/i)},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"hour12",{get:function(){return(this.hour+11)%12+1},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"minute",{get:function(){return Math.floor(this._totalMilliseconds%i/c)},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"second",{get:function(){return Math.floor(this._totalMilliseconds%c/l)},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"millisecond",{get:function(){return this._totalMilliseconds%l},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"am",{get:function(){return this.hour<12},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"pm",{get:function(){return 12<=this.hour},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"hours",{get:function(){return this.hour},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"hours12",{get:function(){return this.hour12},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"minutes",{get:function(){return this.minute},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"seconds",{get:function(){return this.second},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"milliseconds",{get:function(){return this.millisecond},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"H",{get:function(){return this.invalid?"-":String(this.hour)},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"h",{get:function(){return this.invalid?"-":String(this.hour12)},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"k",{get:function(){return this.invalid?"-":String((this.hour+23)%24+1)},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"m",{get:function(){return this.invalid?"-":String(this.minute)},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"s",{get:function(){return this.invalid?"-":String(this.second)},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"S",{get:function(){return this.invalid?"-":String(Math.floor(this.millisecond/100))},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"SS",{get:function(){return this.invalid?"--":t(Math.floor(this.millisecond/10),2,"0")},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"SSS",{get:function(){return this.invalid?"---":t(this.millisecond,3,"0")},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"a",{get:function(){return this.invalid?"--":this.am?"am":"pm"},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"A",{get:function(){return this.invalid?"--":this.am?"AM":"PM"},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"aa",{get:function(){return this.invalid?"----":this.am?"a.m.":"p.m."},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"AA",{get:function(){return this.invalid?"----":this.am?"A.M.":"P.M."},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"HH",{get:function(){return this.invalid?"--":r(this.H,2,"0")},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"_H",{get:function(){return this.invalid?"--":r(this.H,2," ")},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"hh",{get:function(){return this.invalid?"--":r(this.h,2,"0")},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"_h",{get:function(){return this.invalid?"--":r(this.h,2," ")},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"kk",{get:function(){return this.invalid?"--":r(this.k,2,"0")},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"_k",{get:function(){return this.invalid?"--":r(this.k,2," ")},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"mm",{get:function(){return this.invalid?"--":r(this.m,2,"0")},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"_m",{get:function(){return this.invalid?"--":r(this.m,2," ")},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"ss",{get:function(){return this.invalid?"--":r(this.s,2,"0")},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"_s",{get:function(){return this.invalid?"--":r(this.s,2," ")},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"HHmm",{get:function(){return this.HH+":"+this.mm},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"HHmmss",{get:function(){return this.HHmm+":"+this.ss},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"HHmmssSSS",{get:function(){return this.HHmmss+"."+this.SSS},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"totalMilliseconds",{get:function(){return this._totalMilliseconds},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"totalSeconds",{get:function(){return Math.floor(this._totalMilliseconds/l)},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"totalMinutes",{get:function(){return Math.floor(this._totalMilliseconds/c)},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"valid",{get:function(){return 0<=this._totalMilliseconds&&this._totalMilliseconds<a},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"invalid",{get:function(){return!this.valid},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"startOfHour",{get:function(){return new O(this._totalMilliseconds-this._totalMilliseconds%i)},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"startOfMinute",{get:function(){return new O(this._totalMilliseconds-this._totalMilliseconds%c)},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"startOfSecond",{get:function(){return new O(this._totalMilliseconds-this._totalMilliseconds%l)},enumerable:!0,configurable:!0}),O.prototype.ifInvalid=function(t){return this.valid?this:new O(f(t))},O.prototype.startOf=function(t){switch(t){case"hour":return this.startOfHour;case"minute":return this.startOfMinute;case"second":return this.startOfSecond;default:return this}},O.prototype.toString=function(){return this.HHmmssSSS},O.prototype.format=function(t){return e=this,String(t).replace(b(),function(t){return"\\"===t[0]?t[1]:e[t]});var e},O.prototype.with=function(t){return new O(f({h:o(t.h,t.hour,t.hours,this.hour),m:o(t.m,t.minute,t.minutes,this.minute),s:o(t.s,t.second,t.seconds,this.second),S:o(t.S,t.millisecond,t.milliseconds,this.millisecond),am:!0===t.am||!1===t.pm||"am"===t.a||"pm"!==t.a&&void 0}))},O.prototype.plus=function(t){t=f(t);return 0===t?this:new O(this._totalMilliseconds+t)},O.prototype.minus=function(t){t=f(t);return 0===t?this:new O(this._totalMilliseconds-t)},O.prototype.equals=function(t){return 0===this.compareTo(t)},O.prototype.compareTo=function(t){return this._totalMilliseconds-f(t)},O.prototype.isBefore=function(t){return this.compareTo(t)<0},O.prototype.isBeforeOrEqual=function(t){return this.compareTo(t)<=0},O.prototype.isAfter=function(t){return 0<this.compareTo(t)},O.prototype.isAfterOrEqual=function(t){return 0<=this.compareTo(t)},O.prototype.isBetweenExclusive=function(t,e){return this.isAfter(t)&&this.isBefore(e)},O.prototype.isBetweenInclusive=function(t,e){return this.isAfterOrEqual(t)&&this.isBeforeOrEqual(e)},O);function O(t){this._totalMilliseconds=t}function E(t){return null==t?P:t instanceof g?t:0===(t=f(t))?S:isNaN(t)?P:new g(t)}var S=new g(0),P=new g(NaN);function j(t,e,o){void 0===o&&(o=P);for(var n=o,l=0,c=t.length;l<c;++l){var i=E(t[l]);i.valid&&(n=e(n,i,l,t))}return n}function _(t){var e=document.createEvent("CustomEvent");e.initCustomEvent("input",!0,!1,"complete"),t.dispatchEvent(e)}E.prototype=g.prototype,E.INVALID=P,E.ZERO=S,E.now=function(){return new g(u())},E.min=function(){return j(arguments,function(t,e){return t.invalid||e.isBefore(t)?e:t})},E.max=function(){return j(arguments,function(t,e){return t.invalid||e.isAfter(t)?e:t})};var w,M,x=function(){return(x=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var l in e=arguments[o])Object.prototype.hasOwnProperty.call(e,l)&&(t[l]=e[l]);return t}).apply(this,arguments)};void 0===window.ontouchend?M=!1:(w=window.ontouchend,M=(window.ontouchend=void 0)!==window.ontouchend,window.ontouchend=w);var H=M;function L(t,e,o,n,l){var c=document.createEvent("CustomEvent");return c.initCustomEvent(e,o,n,l),c.preventDefault=function(){Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})},t.dispatchEvent(c),c}function A(t,e){return t.getAttribute("data-clocklet-"+e)}function C(t,e,o){t.setAttribute("data-clocklet-"+e,o)}var N=(T.prototype.value=function(t){this.hand.style.transform="rotate("+360*t/this.maxValue+"deg)";var e="clocklet-tick--selected",o=this.dial.getElementsByClassName(e)[0],t=this.dial.querySelector('[data-clocklet-tick-value="'+t+'"]');o!==t&&(o&&o.classList.remove(e),t&&t.classList.add(e))},T.prototype._onDragStart=function(t){var e;t.touches&&1<t.touches.length?this.dragging=!1:(this.dragging=!0,(e=A(t.target,"tick-value"))&&this.setValue(e),t.preventDefault(),L(this.dial,"clocklet.dragstart",!0,!1))},T.prototype._onDrag=function(t){var e,o,n;this.dragging&&(e=t.targetTouches?t.targetTouches[0]:t,(n=(o=document.elementFromPoint(e.clientX,e.clientY))&&A(o,"tick-value"))&&this.dial.contains(o)?this.setValue(n):(o=this.dial.getBoundingClientRect(),n=e.clientX-o.left-o.width/2,o=e.clientY-o.top-o.height/2,n=Math.atan2(o,n),this.setValue(Math.round(n*this.maxValue/(2*Math.PI)+this.maxValue/4+this.maxValue)%this.maxValue)),t.preventDefault())},T.prototype._onDragEnd=function(t){this.dragging=!1,t.preventDefault(),L(this.dial,"clocklet.dragend",!0,!1)},T);function T(t,e,o){this.dial=t,this.maxValue=e,this.setValue=o,this.hand=this.dial.getElementsByClassName("clocklet-hand")[0],this.dragging=!1,window.PointerEvent?(t.addEventListener("pointerdown",this._onDragStart.bind(this)),addEventListener("pointermove",this._onDrag.bind(this),!0),addEventListener("pointerup",this._onDragEnd.bind(this),!0)):H?(t.addEventListener("touchstart",this._onDragStart.bind(this)),t.addEventListener("touchmove",this._onDrag.bind(this)),t.addEventListener("touchend",this._onDragEnd.bind(this))):(t.addEventListener("mousedown",this._onDragStart.bind(this)),addEventListener("mousemove",this._onDrag.bind(this),!0),addEventListener("mouseup",this._onDragEnd.bind(this),!0))}var D={className:"",format:"HH:mm",placement:"bottom",alignment:"left",appendTo:"body",zIndex:"",dispatchesInputEvents:!0};function I(t){if(t){for(var e={},o=0,n=t.split(";");o<n.length;o++){var l=n[o],c=l.indexOf(":");e[l.slice(0,c).trim().replace(/[a-zA-Z0-9_]-[a-z]/g,function(t){return t[0]+t[2].toUpperCase()})]=l.slice(c+1).trim()}return e}}var B='<div class="clocklet"><div class="clocklet-plate"><div class="clocklet-dial clocklet-dial--minute"><div class="clocklet-hand clocklet-hand--minute"></div><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="0" style="left:50%;top:11%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="1" style="left:54.8%;top:4.3%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="2" style="left:59.6%;top:5%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="3" style="left:64.2%;top:6.3%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="4" style="left:68.7%;top:8%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="5" style="left:69.5%;top:16.2%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="6" style="left:77%;top:12.8%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="7" style="left:80.8%;top:15.8%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="8" style="left:84.2%;top:19.2%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="9" style="left:87.2%;top:23%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="10" style="left:83.8%;top:30.5%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="11" style="left:92%;top:31.3%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="12" style="left:93.7%;top:35.8%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="13" style="left:95%;top:40.4%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="14" style="left:95.7%;top:45.2%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="15" style="left:89%;top:50%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="16" style="left:95.7%;top:54.8%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="17" style="left:95%;top:59.6%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="18" style="left:93.7%;top:64.2%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="19" style="left:92%;top:68.7%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="20" style="left:83.8%;top:69.5%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="21" style="left:87.2%;top:77%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="22" style="left:84.2%;top:80.8%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="23" style="left:80.8%;top:84.2%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="24" style="left:77%;top:87.2%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="25" style="left:69.5%;top:83.8%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="26" style="left:68.7%;top:92%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="27" style="left:64.2%;top:93.7%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="28" style="left:59.6%;top:95%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="29" style="left:54.8%;top:95.7%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="30" style="left:50%;top:89%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="31" style="left:45.2%;top:95.7%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="32" style="left:40.4%;top:95%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="33" style="left:35.8%;top:93.7%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="34" style="left:31.3%;top:92%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="35" style="left:30.5%;top:83.8%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="36" style="left:23%;top:87.2%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="37" style="left:19.2%;top:84.2%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="38" style="left:15.8%;top:80.8%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="39" style="left:12.8%;top:77%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="40" style="left:16.2%;top:69.5%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="41" style="left:8%;top:68.7%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="42" style="left:6.3%;top:64.2%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="43" style="left:5%;top:59.6%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="44" style="left:4.3%;top:54.8%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="45" style="left:11%;top:50%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="46" style="left:4.3%;top:45.2%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="47" style="left:5%;top:40.4%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="48" style="left:6.3%;top:35.8%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="49" style="left:8%;top:31.3%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="50" style="left:16.2%;top:30.5%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="51" style="left:12.8%;top:23%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="52" style="left:15.8%;top:19.2%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="53" style="left:19.2%;top:15.8%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="54" style="left:23%;top:12.8%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="55" style="left:30.5%;top:16.2%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="56" style="left:31.3%;top:8%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="57" style="left:35.8%;top:6.3%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="58" style="left:40.4%;top:5%"></button><button class="clocklet-tick clocklet-tick--minute" type="button" data-clocklet-tick-value="59" style="left:45.2%;top:4.3%"></button></div><div class="clocklet-dial clocklet-dial--hour"><div class="clocklet-hand clocklet-hand--hour"></div><button class="clocklet-tick clocklet-tick--hour" type="button" data-clocklet-tick-value="0" style="left:50%;top:11%"></button><button class="clocklet-tick clocklet-tick--hour" type="button" data-clocklet-tick-value="1" style="left:69.5%;top:16.2%"></button><button class="clocklet-tick clocklet-tick--hour" type="button" data-clocklet-tick-value="2" style="left:83.8%;top:30.5%"></button><button class="clocklet-tick clocklet-tick--hour" type="button" data-clocklet-tick-value="3" style="left:89%;top:50%"></button><button class="clocklet-tick clocklet-tick--hour" type="button" data-clocklet-tick-value="4" style="left:83.8%;top:69.5%"></button><button class="clocklet-tick clocklet-tick--hour" type="button" data-clocklet-tick-value="5" style="left:69.5%;top:83.8%"></button><button class="clocklet-tick clocklet-tick--hour" type="button" data-clocklet-tick-value="6" style="left:50%;top:89%"></button><button class="clocklet-tick clocklet-tick--hour" type="button" data-clocklet-tick-value="7" style="left:30.5%;top:83.8%"></button><button class="clocklet-tick clocklet-tick--hour" type="button" data-clocklet-tick-value="8" style="left:16.2%;top:69.5%"></button><button class="clocklet-tick clocklet-tick--hour" type="button" data-clocklet-tick-value="9" style="left:11%;top:50%"></button><button class="clocklet-tick clocklet-tick--hour" type="button" data-clocklet-tick-value="10" style="left:16.2%;top:30.5%"></button><button class="clocklet-tick clocklet-tick--hour" type="button" data-clocklet-tick-value="11" style="left:30.5%;top:16.2%"></button></div><div class="clocklet-ampm"></div><div class="clocklet-hand-origin"></div></div></div>';function V(t,e){return z(t,e,/[Hhk]$/)}function R(t,e){return z(t,e,/a/i)}function z(t,e,o){for(var n=0,l=0,c=v(e);l<c.length;l++){var i=c[l];if(i.literal)n+=i.property.length;else{var a=t[i.property];if(o.test(i.property))return{index:n,value:a};n+=a.length}}}var F=["position","left","top","right","bottom","marginLeft","marginTop","marginRight","marginBottom"],q=matchMedia("(hover: none)").matches,$=(Z.prototype.open=function(e,t){var o=this,n=x(Object.create(this.defaultOptions),t),l=e.getBoundingClientRect(),c=getComputedStyle(e),i=this.container,a=this.root,t={options:n};L(e,"clocklet.opening",!0,!0,t).defaultPrevented||(this.input=e,this.dispatchesInputEvents=n.dispatchesInputEvents,C(a,"placement",n.placement),C(a,"alignment",n.alignment),C(a,"format",n.format),C(a,"append-to",n.appendTo),a.className="clocklet clocklet--showing "+(q?"":"clocklet--hoverable ")+n.className,i.style.zIndex=""!==n.zIndex?n.zIndex:(parseInt(c.zIndex,10)||0)+1,"parent"===n.appendTo?e.parentElement.insertBefore(i,e):i.parentElement!==document.body&&document.body.appendChild(i),"top"===n.placement?(a.style.top="",a.style.bottom="0"):(a.style.top=l.height+"px",a.style.bottom=""),"right"===n.alignment?(a.style.left="",a.style.right="-"+l.width+"px"):("center"===n.alignment?a.style.left=(e.offsetWidth-a.offsetWidth)/2+"px":a.style.left="0",a.style.right=""),"fixed"===c.position||"parent"===n.appendTo&&"absolute"===c.position?(this._relocate=void 0,K(i.style,c,F)):(K(i.style,{},F),"parent"===n.appendTo?"flex"===(n=getComputedStyle(e.parentElement)).display||"inline-flex"===n.display?(i.style.position="absolute",this._relocate=function(){i.style.left=e.offsetLeft+"px",i.style.top=e.offsetTop+"px"}):(i.style.position="relative",this._relocate=function(){i.style.left=i.style.top="",i.style.left=e.offsetLeft-i.offsetLeft+"px",i.style.top=e.offsetTop-i.offsetTop+"px"}):(i.style.position="absolute",this._relocate=function(){var t=e.getBoundingClientRect();i.style.left=document.documentElement.scrollLeft+document.body.scrollLeft+t.left+"px",i.style.top=document.documentElement.scrollTop+document.body.scrollTop+t.top+"px"}),this._relocate()),this.updateHighlight(),setTimeout(function(){a.classList.remove("clocklet--showing"),o.input&&a.classList.add("clocklet--shown")}),L(e,"clocklet.opened",!0,!1,t))},Z.prototype.close=function(){var t=this.input,e={};t&&(L(t,"clocklet.closing",!0,!0,e).defaultPrevented?t.focus():(this.input=void 0,this.root.classList.remove("clocklet--shown"),L(t,"clocklet.closed",!0,!1,e)))},Z.prototype.inline=function(t,e){var o=void 0===e?{}:e,n=o.input,e=o.format,o=new Z(this.defaultOptions);return t.appendChild(o.container),o.container.classList.add("clocklet-container--inline"),o.root.classList.add("clocklet--inline"),o.dispatchesInputEvents=o.defaultOptions.dispatchesInputEvents,e=e||o.defaultOptions.format,C(o.root,"format",e),n||((n=t.appendChild(document.createElement("input"))).style.display="none"),n.setAttribute("data-clocklet","format:"+e),n.setAttribute("data-clocklet-inline",""),o.input=n,o.updateHighlight(),o},Z.prototype.value=function(t){var e,o,n;this.input&&(e=this.input.value,o="string"==typeof t?E(t):E(this.input.value).with(void 0!==t.a?t:{h:t.h,m:t.m,a:A(this.ampm,"ampm")}),n=A(this.root,"format"),this.input.value=o.format(n),"text"!==this.input.type||"object"!=typeof t||(n=void 0!==t.h?V(o,n):void 0!==t.m?z(o,n,/m$/):void 0!==t.a?R(o,n)||V(o,n):void 0)&&this.input.setSelectionRange(n.index,n.index+n.value.length),this.dispatchesInputEvents&&this.input.value!==e&&L(this.input,"input",!0,!1,{time:o}))},Z.prototype.updateHighlight=function(){var t;this.input&&((t=this.input.value?E(this.input.value):E.INVALID).valid?(C(this.root,"value",t.HHmm),this.hour.value(t.hour%12),this.minute.value(t.minute),C(this.ampm,"ampm",t.a)):(C(this.root,"value",""),this.hour.value(-1),this.minute.value(-1),C(this.ampm,"ampm","am")),t=R(t.valid?t:E.ZERO,A(this.root,"format")),C(this.ampm,"ampm-formatted",t&&t.value||""))},Z);function Z(t){var e,o=this;this.container=((e=document.createElement("div")).className="clocklet-container",e.innerHTML=B,e),this.root=this.container.firstElementChild,this.plate=this.root.firstElementChild,this.hour=new N(this.plate.getElementsByClassName("clocklet-dial--hour")[0],12,function(t){return o.value({h:t})}),this.minute=new N(this.plate.getElementsByClassName("clocklet-dial--minute")[0],60,function(t){return o.value({m:t})}),this.ampm=this.plate.getElementsByClassName("clocklet-ampm")[0],this.defaultOptions=x(Object.create(D),t),addEventListener("input",function(t){return t.target===o.input&&o.updateHighlight()},!0),this.root.addEventListener("mousedown",function(t){return t.preventDefault()}),this.ampm.addEventListener("mousedown",function(){return o.value({a:"pm"===A(o.ampm,"ampm")?"am":"pm"})}),this.root.addEventListener("clocklet.dragstart",function(){return o.root.classList.add("clocklet--dragging")}),this.root.addEventListener("clocklet.dragend",function(){return o.root.classList.remove("clocklet--dragging")});t=function(){return o._relocate&&o._relocate()};addEventListener("resize",t),addEventListener("orientationchange",t)}function K(t,e,o){for(var n=0,l=o;n<l.length;n++){var c=l[n];t[c]=e[c]||""}}var W,X,Y,U,G,J,Q={dataAttributeName:"clocklet",formatSelector:function(t){t=I(t.getAttribute("data-clocklet"));return t&&t.format}};return G=(U=Q)&&U.dataAttributeName||"lenientime",J=U&&U.formatSelector||function(t){return t.dataset.lenientime},addEventListener("change",function(t){var e=t.target,o=e.value,t=e.dataset;o&&G in t&&((t=(t=E(o)).valid?t.format(J(e)||"HH:mm"):"")!==o&&(e.value=t,_(e)))},!0),X=(W=Q)&&W.dataAttributeName||"lenientime",Y=W&&W.formatSelector||function(t){return t.dataset.lenientime},W&&W.amountSelector,addEventListener("keydown",function(t){var e,o,n,l,c=t.which;38!==c&&40!==c||t.altKey||t.ctrlKey||t.metaKey||(n=(e=t.target).dataset,X in n&&(t.preventDefault(),o=Y(e)||"HH:mm",(n=e.value)?(l=null===(t=e.selectionStart)?void 0:y(o,n,t))&&(t=(38===c?1:-1)*(W&&W.amountSelector&&W.amountSelector(e)||1),void 0!==(c=l.adjust(t,!0))&&(t=l.index,e.value=n.slice(0,t)+c+n.slice(t+l.value.length),e.setSelectionRange(t,t+c.length),_(e))):(e.value=E.ZERO.format(o),(l=y(o,e.value,0))&&e.setSelectionRange(l.index,l.index+l.value.length),_(e))))},!0),function(t){void 0===t&&(t={});var e,o=new $(t.defaultOptions),n=t.target||"input[data-clocklet]:not([data-clocklet-inline])",l=t.optionsSelector||function(t){return I(t.getAttribute("data-clocklet"))},t=o.close.bind(o);return n instanceof Element?(n.addEventListener("focus",function(t){return o.open(t.target,l(t.target))}),n.addEventListener("blur",t)):(e="function"==typeof n?n:function(t){return(Element.prototype.matches||Element.prototype.msMatchesSelector).call(t,n)},addEventListener("focusin",function(t){t=t.target;e(t)&&o.open(t,l(t))},!0),addEventListener("focusout",t,!0)),o}()});
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module GlimmerCwCdatetimeNebula
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace GlimmerCwCdatetimeNebula
|
4
|
+
|
5
|
+
initializer "glimmer_cw_cdatetime_nebula.assets.precompile" do |app|
|
6
|
+
app.config.assets.precompile += %w( glimmer_cw_cdatetime_nebula/glimmer_cw_cdatetime_nebula.css )
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|