tungsten 0.1.57 → 0.1.58
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/tungsten/_icons.js +1 -1
- data/app/assets/javascripts/tungsten/enhancements/flash-messages.js +2 -2
- data/app/assets/javascripts/tungsten/enhancements/form-diff.js +92 -0
- data/app/assets/javascripts/tungsten/enhancements/form-reset.js +14 -0
- data/app/assets/javascripts/tungsten/{_form-helpers.js → enhancements/form-submit-helpers.js} +1 -19
- data/app/assets/javascripts/tungsten/enhancements/input-change.js +38 -0
- data/app/assets/javascripts/tungsten/enhancements/input-number-only.js +19 -0
- data/app/assets/javascripts/tungsten/enhancements/input-reset-value.js +51 -0
- data/app/assets/javascripts/tungsten/enhancements/input-unit.js +58 -0
- data/app/assets/javascripts/tungsten/enhancements/link-here.js +11 -0
- data/app/assets/javascripts/tungsten/enhancements/{text-helpers.js → textarea-expand.js} +4 -12
- data/app/assets/javascripts/tungsten/{enhancements → modules}/clipboard.js +0 -0
- data/app/assets/javascripts/tungsten/{enhancements → modules}/notify.js +0 -0
- data/app/assets/javascripts/tungsten/modules/unit-converter.js +53 -0
- data/app/assets/javascripts/tungsten/tungsten.js +11 -4
- data/app/assets/stylesheets/tungsten/components/_cards.scss +1 -0
- data/app/assets/stylesheets/tungsten/components/_copy-input.scss +22 -6
- data/app/assets/stylesheets/tungsten/components/_notices.scss +1 -1
- data/app/assets/stylesheets/tungsten/components/_progress-bar.scss +2 -2
- data/app/assets/stylesheets/tungsten/components/_toggle-nav.scss +1 -1
- data/app/assets/stylesheets/tungsten/components/_tooltip.scss +24 -7
- data/app/assets/stylesheets/tungsten/core/_sections.scss +7 -2
- data/app/assets/stylesheets/tungsten/form/_base.scss +48 -8
- data/app/assets/stylesheets/tungsten/form/_defaulted-inputs.scss +48 -0
- data/app/assets/stylesheets/tungsten/form/_form-diff.scss +96 -0
- data/app/assets/stylesheets/tungsten/form/_index.scss +3 -0
- data/app/assets/stylesheets/tungsten/form/_label-placeholder.scss +3 -3
- data/app/assets/stylesheets/tungsten/form/_unit-select.scss +40 -0
- data/app/assets/stylesheets/tungsten/form/_validation.scss +2 -2
- data/app/helpers/tungsten/button_helper.rb +6 -1
- data/app/helpers/tungsten/content_helper.rb +4 -0
- data/app/helpers/tungsten/form_helper.rb +75 -113
- data/app/helpers/tungsten/section_helper.rb +7 -1
- data/lib/tungsten/version.rb +1 -1
- data/public/code-0.1.58.js +101 -0
- data/public/code-0.1.58.js.gz +0 -0
- data/public/code-0.1.58.map.json +1 -0
- data/public/{tungsten-0.1.57.css → tungsten-0.1.58.css} +270 -62
- data/public/tungsten-0.1.58.css.gz +0 -0
- data/public/tungsten-0.1.58.js +125 -0
- data/public/tungsten-0.1.58.js.gz +0 -0
- data/public/tungsten-0.1.58.map.json +1 -0
- metadata +25 -14
- data/public/code-0.1.57.js +0 -95
- data/public/code-0.1.57.js.gz +0 -0
- data/public/code-0.1.57.map.json +0 -1
- data/public/tungsten-0.1.57.css.gz +0 -0
- data/public/tungsten-0.1.57.js +0 -103
- data/public/tungsten-0.1.57.js.gz +0 -0
- data/public/tungsten-0.1.57.map.json +0 -1
@@ -10,7 +10,7 @@
|
|
10
10
|
// Input labels
|
11
11
|
.placeholder-label {
|
12
12
|
|
13
|
-
padding: 0;
|
13
|
+
//padding: 0;
|
14
14
|
font-size: $font-size;
|
15
15
|
|
16
16
|
// Hide input placeholder text
|
@@ -41,7 +41,7 @@
|
|
41
41
|
padding-top: $padding-y - ($distance-y / 2);
|
42
42
|
padding-bottom: ($distance-y / 2);
|
43
43
|
|
44
|
-
|
44
|
+
~ .placeholder-label-text, {
|
45
45
|
z-index: 2;
|
46
46
|
transform: translate3d($distance-x, -($distance-y), 0) scale($scale);
|
47
47
|
color: $gray-08;
|
@@ -51,7 +51,7 @@
|
|
51
51
|
|
52
52
|
&.valid, &.invalid {
|
53
53
|
input {
|
54
|
-
|
54
|
+
~ .placeholder-label-text {
|
55
55
|
color: inherit;
|
56
56
|
}
|
57
57
|
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
.unit-select {
|
2
|
+
position: absolute;
|
3
|
+
right: 1px;
|
4
|
+
top: 1px;
|
5
|
+
|
6
|
+
&:after {
|
7
|
+
content: "";
|
8
|
+
border: 1px solid $gray-07;
|
9
|
+
border-left: none;
|
10
|
+
border-top: none;
|
11
|
+
width: 8px;
|
12
|
+
display: inline-block;
|
13
|
+
height: 8px;
|
14
|
+
transform: rotate(45deg);
|
15
|
+
position: absolute;
|
16
|
+
right: 10px;
|
17
|
+
top: 1em;
|
18
|
+
pointer-events: none;
|
19
|
+
}
|
20
|
+
|
21
|
+
&:hover:after {
|
22
|
+
border-color: $blue-01;
|
23
|
+
}
|
24
|
+
|
25
|
+
select {
|
26
|
+
transition-property: color;
|
27
|
+
color: $gray-07;
|
28
|
+
box-shadow: none;
|
29
|
+
width: auto;
|
30
|
+
background: transparent;
|
31
|
+
padding: 0 1.8em 0 .8em;
|
32
|
+
border-left: 1px solid rgba($gray-11, .2);
|
33
|
+
border-radius: 0;
|
34
|
+
min-height: 41px;
|
35
|
+
@include active {
|
36
|
+
box-shadow: none;
|
37
|
+
color: $blue-01;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
label.valid:not(.remotely-invalid) {
|
3
3
|
color: $green-01;
|
4
4
|
|
5
|
-
input, select, textarea {
|
5
|
+
input, select:not([tabindex="-1"]), textarea {
|
6
6
|
-webkit-text-fill-color: currentColor;
|
7
7
|
box-shadow: input-shadow( $green-01 );
|
8
8
|
|
@@ -16,7 +16,7 @@ label.invalid,
|
|
16
16
|
label.remotely-invalid:not(.valid) {
|
17
17
|
color: $red-01;
|
18
18
|
|
19
|
-
input, select, textarea {
|
19
|
+
input, select:not([tabindex="-1"]), textarea {
|
20
20
|
-webkit-text-fill-color: currentColor;
|
21
21
|
box-shadow: input-shadow( $red-01 );
|
22
22
|
|
@@ -24,6 +24,10 @@ module Tungsten
|
|
24
24
|
options[:dialog][:confirm] = options.delete(:confirm)
|
25
25
|
end
|
26
26
|
|
27
|
+
if options[:confirm_if]
|
28
|
+
options[:dialog][:if] = options.delete(:confirm_if)
|
29
|
+
end
|
30
|
+
|
27
31
|
(options.delete(:dialog) || {}).each do |key, val|
|
28
32
|
if key.to_s == 'confirm'
|
29
33
|
options[:data]["dialog-title"] ||= val
|
@@ -49,7 +53,8 @@ module Tungsten
|
|
49
53
|
type: options.delete(:type) || 'button',
|
50
54
|
target: options.delete(:target),
|
51
55
|
href: options.delete(:href),
|
52
|
-
'aria-label'=> options.delete(:aria_label)
|
56
|
+
'aria-label'=> options.delete(:aria_label),
|
57
|
+
tabindex: options.delete(:tabindex)
|
53
58
|
}
|
54
59
|
|
55
60
|
button = content_tag tag_name, button_options do
|
@@ -22,6 +22,11 @@ module Tungsten
|
|
22
22
|
type: "text"
|
23
23
|
},
|
24
24
|
|
25
|
+
number: {
|
26
|
+
type: "number",
|
27
|
+
step: "any"
|
28
|
+
},
|
29
|
+
|
25
30
|
tel: {
|
26
31
|
type: "tel",
|
27
32
|
placeholder: "Phone number"
|
@@ -117,97 +122,6 @@ module Tungsten
|
|
117
122
|
end
|
118
123
|
end
|
119
124
|
|
120
|
-
def slider_input_tag(name, options={})
|
121
|
-
options = options.stringify_keys
|
122
|
-
classnames = options.delete('class') || ''
|
123
|
-
|
124
|
-
if label = options.delete('label')
|
125
|
-
label = content_tag(:span, class: 'label-text') { label }
|
126
|
-
end
|
127
|
-
|
128
|
-
data = options['data'] || {}
|
129
|
-
data['input'] ||= name
|
130
|
-
|
131
|
-
if options['position_label']
|
132
|
-
data['position_label'] = options['position_label']
|
133
|
-
end
|
134
|
-
|
135
|
-
# Set values (and max based on values size)
|
136
|
-
if values = options['values']
|
137
|
-
data['values'] = values.join(',')
|
138
|
-
options['max'] ||= values.size - 1
|
139
|
-
end
|
140
|
-
|
141
|
-
# Support legacy option
|
142
|
-
options['labels'] ||= options['label']
|
143
|
-
|
144
|
-
if labels = options['labels']
|
145
|
-
if labels.is_a?(Array)
|
146
|
-
data['label'] = labels.join(';')
|
147
|
-
options['max'] ||= labels.size - 1
|
148
|
-
elsif labels.is_a?(Hash)
|
149
|
-
labels.each do |label, value|
|
150
|
-
data['label-'+dasherize(label.to_s.downcase)] = value.join(';')
|
151
|
-
options['max'] ||= value.size - 1
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
if labels == false
|
157
|
-
data['label'] = 'false'
|
158
|
-
end
|
159
|
-
|
160
|
-
if labels = options['external_labels']
|
161
|
-
if labels.is_a?(Hash)
|
162
|
-
labels.each do |label, value|
|
163
|
-
data['external-label-'+dasherize(label.to_s.downcase)] = value.join(';')
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
if before = options['before']
|
169
|
-
if before.is_a?(String)
|
170
|
-
data['before-label'] = before
|
171
|
-
else
|
172
|
-
before.each do |key, value|
|
173
|
-
data["before-label-#{key}"] = value
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
if mark = options['mark']
|
179
|
-
data['mark'] = mark.join(',')
|
180
|
-
end
|
181
|
-
|
182
|
-
if after = options['after']
|
183
|
-
if after.is_a?(String)
|
184
|
-
data['after-label'] = after
|
185
|
-
else
|
186
|
-
after.each do |key, value|
|
187
|
-
data["after-label-#{key}"] = value
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
if line_labels = options['line_labels']
|
193
|
-
data['line_labels'] = []
|
194
|
-
line_labels.each do |k, v|
|
195
|
-
data['line_labels'] << "#{k}:#{v}"
|
196
|
-
end
|
197
|
-
data['line_labels'] = data['line_labels'].join(';')
|
198
|
-
end
|
199
|
-
|
200
|
-
options['value'] ||= options['min'] || 0
|
201
|
-
|
202
|
-
html_options = {"id"=> options['id'], "class" => classnames, "type" => "range", "min" => options['min'], "max" => options['max'], "value" => options['value'] }.update('data' => data)
|
203
|
-
|
204
|
-
content_tag(:label, class: 'range-label') {
|
205
|
-
concat label if label
|
206
|
-
concat tag :input, html_options
|
207
|
-
}
|
208
|
-
end
|
209
|
-
alias :range_input_tag :slider_input_tag
|
210
|
-
|
211
125
|
# Country select
|
212
126
|
def select_country_tag(name, options = {}, country_options = {})
|
213
127
|
country_options.reverse_merge! INPUT_OPTIONS[:select_country][:country_options]
|
@@ -279,6 +193,9 @@ module Tungsten
|
|
279
193
|
end
|
280
194
|
|
281
195
|
options[:type] = :radio
|
196
|
+
(options[:class] ||= '') << ' input'
|
197
|
+
options[:data] ||= {}
|
198
|
+
options[:data][:show] = options.delete(:show)
|
282
199
|
|
283
200
|
tick_wrapper( name, options ) do
|
284
201
|
radio_button_tag(name, value, checked, options)
|
@@ -286,6 +203,10 @@ module Tungsten
|
|
286
203
|
|
287
204
|
end
|
288
205
|
|
206
|
+
def slider_input_tag(name, options={})
|
207
|
+
input_tag(:range, name, options)
|
208
|
+
end
|
209
|
+
|
289
210
|
def checkbox_input_tag(name, checked = false, options = {})
|
290
211
|
value = true
|
291
212
|
|
@@ -297,7 +218,7 @@ module Tungsten
|
|
297
218
|
options[:type] = :checkbox
|
298
219
|
|
299
220
|
tick_wrapper( name, options ) do
|
300
|
-
options
|
221
|
+
options[:class] = 'input'
|
301
222
|
concat tag :input, name: name, type: :hidden, value: false
|
302
223
|
concat check_box_tag(name, value, checked, options)
|
303
224
|
end
|
@@ -345,6 +266,8 @@ module Tungsten
|
|
345
266
|
|
346
267
|
def base_tag(name, value, options, type, &block)
|
347
268
|
case type
|
269
|
+
when :range
|
270
|
+
range_input_tag(name, options)
|
348
271
|
when :select
|
349
272
|
value = value.html_safe if value
|
350
273
|
select_tag(name, value, options)
|
@@ -367,23 +290,31 @@ module Tungsten
|
|
367
290
|
value = nil
|
368
291
|
end
|
369
292
|
|
293
|
+
options[:autocomplete] ||= 'off'
|
294
|
+
|
370
295
|
options[:data] ||= {}
|
371
296
|
options[:data][:message] ||= options.delete(:message)
|
297
|
+
options[:data]['unique-id'] = "#{SecureRandom.hex(8)}"
|
298
|
+
options[:data][:default] ||= options.delete(:default)
|
372
299
|
|
373
300
|
if errors = options.delete(:errors)
|
374
301
|
options[:data]['invalid-value'] = value
|
375
302
|
end
|
376
303
|
|
304
|
+
if unit = options.delete(:unit)
|
305
|
+
options[:data][:unit] = unit
|
306
|
+
end
|
307
|
+
|
377
308
|
if options.delete(:copy)
|
378
|
-
|
379
|
-
copy = copy_button ".#{copy_class}"
|
309
|
+
copy = copy_button("[data-unique-id='#{options[:data]['unique-id']}']", tabindex: '-1')
|
380
310
|
end
|
381
311
|
|
382
312
|
options = (INPUT_OPTIONS[type]||{}).deep_merge options
|
383
313
|
options[:type] ||= type
|
384
314
|
|
385
|
-
label_options = {
|
386
|
-
class: "#{label_class(options[:type])} #{options.delete(:class)} #{'remotely-invalid' if errors}"
|
315
|
+
label_options = {
|
316
|
+
class: "#{label_class(options[:type])} #{options.delete(:class)} #{'remotely-invalid' if errors} #{'copy-input' if copy}",
|
317
|
+
data: { 'input-type' => type }
|
387
318
|
}
|
388
319
|
|
389
320
|
if options[:type] != :textarea && placeholder = options[:placeholder]
|
@@ -391,13 +322,37 @@ module Tungsten
|
|
391
322
|
label_options[:class] += ' placeholder-label'
|
392
323
|
end
|
393
324
|
|
394
|
-
if
|
395
|
-
|
396
|
-
label_options[:class] += ' standard-label'
|
325
|
+
if label_description = options.delete(:description)
|
326
|
+
label_description = content_tag(:span, class: 'label-description') { label_description }
|
397
327
|
end
|
398
328
|
|
329
|
+
if label_text = options.delete(:label)
|
330
|
+
label_text = content_tag(:span, class: 'label-text') {
|
331
|
+
concat label_text
|
332
|
+
if options[:data][:default]
|
333
|
+
concat " "
|
334
|
+
concat restore_default(options[:data]['unique-id'])
|
335
|
+
end
|
336
|
+
}
|
337
|
+
if self && label_description
|
338
|
+
label_options[:class] += ' description-label'
|
339
|
+
else
|
340
|
+
label_options[:class] += ' standard-label'
|
341
|
+
end
|
342
|
+
end
|
399
343
|
|
400
|
-
|
344
|
+
if requires_restart = options.delete(:requires_restart)
|
345
|
+
label_options[:class] += ' requires-restart'
|
346
|
+
requires_restart = content_tag(:span, class: 'requires-restart-input-message') {
|
347
|
+
if requires_restart.is_a?(String)
|
348
|
+
concat requires_restart
|
349
|
+
else
|
350
|
+
concat "Changing this requires a database restart."
|
351
|
+
end
|
352
|
+
}
|
353
|
+
end
|
354
|
+
|
355
|
+
options[:class] = 'input'
|
401
356
|
|
402
357
|
if options.delete(:shell_text)
|
403
358
|
input_wrapper_options[:class] += ' shell-text'
|
@@ -407,6 +362,7 @@ module Tungsten
|
|
407
362
|
|
408
363
|
label = content_tag(:label, label_options) {
|
409
364
|
concat label_text
|
365
|
+
concat label_description
|
410
366
|
|
411
367
|
if type == :select
|
412
368
|
concat tag
|
@@ -415,6 +371,7 @@ module Tungsten
|
|
415
371
|
concat content_tag(:span, input_wrapper_options) {
|
416
372
|
concat tag
|
417
373
|
concat placeholder
|
374
|
+
concat copy if copy
|
418
375
|
}
|
419
376
|
end
|
420
377
|
|
@@ -435,22 +392,20 @@ module Tungsten
|
|
435
392
|
}.html_safe
|
436
393
|
|
437
394
|
end
|
395
|
+
concat requires_restart if requires_restart
|
438
396
|
}
|
439
397
|
|
440
|
-
|
441
|
-
input_wrapper_options[:class] += " copy-input"
|
442
|
-
content_tag(:span, input_wrapper_options) {
|
443
|
-
concat label
|
444
|
-
concat copy
|
445
|
-
}
|
446
|
-
else
|
447
|
-
label
|
448
|
-
end
|
449
|
-
|
398
|
+
label
|
450
399
|
end
|
451
400
|
|
452
401
|
private
|
453
402
|
|
403
|
+
def restore_default(selector)
|
404
|
+
content_tag(:a, href: "#", tabindex: '-1', class: "restore-default", data: { 'restore-default' => "[data-unique-id='#{selector}']" }) {
|
405
|
+
content_tag(:span, "aria-label" => "Restore default value", class: "has-tooltip" ) { "⎋" }
|
406
|
+
}
|
407
|
+
end
|
408
|
+
|
454
409
|
def label_class( type )
|
455
410
|
type = case type
|
456
411
|
when :tel, :password, :number, :url, :email, :search
|
@@ -468,6 +423,8 @@ module Tungsten
|
|
468
423
|
|
469
424
|
tag = capture(&block).html_safe
|
470
425
|
|
426
|
+
options.delete(:required)
|
427
|
+
|
471
428
|
tick = content_tag(:span, class: 'tick') {''}
|
472
429
|
|
473
430
|
classnames = ['label-text']
|
@@ -484,7 +441,7 @@ module Tungsten
|
|
484
441
|
}
|
485
442
|
end
|
486
443
|
|
487
|
-
def
|
444
|
+
def range_input_tag(name, options={})
|
488
445
|
options = options.stringify_keys
|
489
446
|
classnames = options.delete('class') || ''
|
490
447
|
|
@@ -494,7 +451,7 @@ module Tungsten
|
|
494
451
|
if options['position_label']
|
495
452
|
data['position_label'] = options['position_label']
|
496
453
|
end
|
497
|
-
|
454
|
+
|
498
455
|
# Set values (and max based on values size)
|
499
456
|
if values = options['values']
|
500
457
|
data['values'] = values.join(',')
|
@@ -563,6 +520,12 @@ module Tungsten
|
|
563
520
|
|
564
521
|
options['value'] ||= options['min'] || 0
|
565
522
|
|
523
|
+
|
524
|
+
if data[:default] && options['values']
|
525
|
+
data[:default] = options['values'].find_index(data[:default]) || data[:default]
|
526
|
+
end
|
527
|
+
|
528
|
+
|
566
529
|
html_options = {"class" => classnames, "type" => "range", "min" => options['min'], "max" => options['max'], "value" => options['value'] }.update('data' => data)
|
567
530
|
tag :input, html_options
|
568
531
|
end
|
@@ -571,6 +534,5 @@ module Tungsten
|
|
571
534
|
input.gsub(/[\W,_]/, '-').gsub(/-{2,}/, '-')
|
572
535
|
end
|
573
536
|
|
574
|
-
alias :range_input_tag :slider_input_tag
|
575
537
|
end
|
576
538
|
end
|
@@ -27,7 +27,7 @@ module Tungsten
|
|
27
27
|
|
28
28
|
if text
|
29
29
|
text = content_tag( :a, text, href: "##{@id}", class: 'app-section-title-anchor' ) unless @id.nil?
|
30
|
-
text =
|
30
|
+
text = heading(text)
|
31
31
|
end
|
32
32
|
|
33
33
|
tag = content_tag( :div, options ) {
|
@@ -36,6 +36,12 @@ module Tungsten
|
|
36
36
|
}
|
37
37
|
end
|
38
38
|
|
39
|
+
def heading( text, options={})
|
40
|
+
options[:class] ||= ''
|
41
|
+
options[:class] << ' app-section-heading'
|
42
|
+
content_tag( :h2, text, options )
|
43
|
+
end
|
44
|
+
|
39
45
|
def content( options={}, &block )
|
40
46
|
content_tag( :div, class: 'app-section-content', &block )
|
41
47
|
end
|