station 0.0.101 → 0.0.106
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/nexmo-developer +1 -44
- data/docs/How-To-Use.md +1 -1
- data/lib/nexmo_developer/.rspec +0 -1
- data/lib/nexmo_developer/Gemfile +4 -4
- data/lib/nexmo_developer/Gemfile.lock +20 -18
- data/lib/nexmo_developer/app/presenters/sidenav_item.rb +2 -2
- data/lib/nexmo_developer/app/services/translator/file_translator.rb +18 -12
- data/lib/nexmo_developer/app/services/translator/smartling/api/upload_file.rb +4 -2
- data/lib/nexmo_developer/app/services/translator/translation_request.rb +3 -2
- data/lib/nexmo_developer/app/services/translator/utils.rb +28 -1
- data/lib/nexmo_developer/app/views/tutorial/list.html.erb +1 -1
- data/lib/nexmo_developer/app/views/use_case/_index.html.erb +1 -1
- data/lib/nexmo_developer/app/webpacker/javascript/volta/volta.js +108 -21
- data/lib/nexmo_developer/app/webpacker/stylesheets/application.scss +1 -1
- data/lib/nexmo_developer/app/webpacker/stylesheets/objects/_use_cases.scss +1 -1
- data/lib/nexmo_developer/lib/tasks/smartling.rake +1 -1
- data/lib/nexmo_developer/nexmo_developer.rb +44 -0
- data/lib/nexmo_developer/version.rb +1 -1
- data/package.json +13 -12
- data/station.gemspec +3 -3
- data/yarn.lock +1681 -354
- metadata +34 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 535d0fed39ee1d438548c090513743c0d7485d677f0f3c5b480d8d9b4580fb5e
|
4
|
+
data.tar.gz: ef616316e4bcfb51a8cfd42e3580c6b4b0fe54c70e7701e5361debc5a80c89da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fef0e5aadcad3f0a45e597b0191afdafa5d3d207a3ef9f71ef987364b48a251e68711564d63c34c721b44d814532d19a402a2066f3382fda7c0b17357adb2e0
|
7
|
+
data.tar.gz: 134963a2864bbb7fe53313eada9f6b07dce0ae358a6ed74eced5e6d97eeb1757d5ae56ebd722ea297e3410a3a4fee9852ecc170a3b455eea5da3e50ed969a8c8
|
data/bin/nexmo-developer
CHANGED
@@ -44,50 +44,7 @@ end.parse!
|
|
44
44
|
$LOAD_PATH.unshift(File.expand_path('../lib/nexmo_developer', __dir__))
|
45
45
|
APP_PATH = File.expand_path('../lib/nexmo_developer/config/application', __dir__)
|
46
46
|
|
47
|
-
|
48
|
-
require 'activeadmin'
|
49
|
-
require 'bootsnap'
|
50
|
-
require 'bugsnag'
|
51
|
-
require 'devise'
|
52
|
-
require 'geocoder'
|
53
|
-
require 'gravatar_image_tag'
|
54
|
-
require 'greenhouse_io'
|
55
|
-
require 'recaptcha'
|
56
|
-
require 'split/dashboard'
|
57
|
-
require 'listen'
|
58
|
-
require 'inherited_resources'
|
59
|
-
require 'msgpack'
|
60
|
-
require 'pg'
|
61
|
-
require 'coffee-rails'
|
62
|
-
require 'octokit'
|
63
|
-
require 'webpacker'
|
64
|
-
require 'clipboard/rails'
|
65
|
-
require 'gmaps4rails'
|
66
|
-
require 'nexmo_markdown_renderer'
|
67
|
-
require 'truncato'
|
68
|
-
require 'puma'
|
69
|
-
require 'barnes'
|
70
|
-
require 'woothee'
|
71
|
-
require 'algoliasearch'
|
72
|
-
require 'rest-client'
|
73
|
-
require 'chartkick'
|
74
|
-
require 'groupdate'
|
75
|
-
require 'terminal-table'
|
76
|
-
require 'lograge'
|
77
|
-
require 'jbuilder'
|
78
|
-
require 'nokogiri'
|
79
|
-
require 'colorize'
|
80
|
-
require 'neatjson'
|
81
|
-
require 'slack-notifier'
|
82
|
-
require 'autoprefixer-rails'
|
83
|
-
require 'titleize'
|
84
|
-
require 'countries'
|
85
|
-
require 'country_select'
|
86
|
-
require 'smartling'
|
87
|
-
require 'newrelic_rpm'
|
88
|
-
require 'redis'
|
89
|
-
require 'rake'
|
90
|
-
|
47
|
+
require_relative '../lib/nexmo_developer/nexmo_developer'
|
91
48
|
require 'config/application'
|
92
49
|
require 'rails/command'
|
93
50
|
|
data/docs/How-To-Use.md
CHANGED
@@ -49,7 +49,7 @@ The files required are:
|
|
49
49
|
* `business_info.yml`: Specific business/organizational information for the platform. This includes the platform name, the path to the header and footer logos, and more.
|
50
50
|
* `top_navigation.yml`: The links for the top navigation bar of the platform.
|
51
51
|
* `meta_info.yml`: Information used to generate the links in the platform's `<head>` tags, such as search engine optimization details.
|
52
|
-
* `products.yml`: A list of each product or item covered in the platform's content. The icon, documentation path
|
52
|
+
* `products.yml`: A list of each product or item covered in the platform's content. The icon, documentation path, color schema and automated translation frequency for each product is also specified here.
|
53
53
|
|
54
54
|
In addition to the above configuration files, Station also expects the following files to be created and placed inside the `/public/meta` path. These files are meta icons also used in the generation of the `<head>` content:
|
55
55
|
|
data/lib/nexmo_developer/.rspec
CHANGED
data/lib/nexmo_developer/Gemfile
CHANGED
@@ -13,7 +13,7 @@ gem 'webpacker'
|
|
13
13
|
# Use postgresql as the database for Active Record
|
14
14
|
gem 'pg', '~> 1.2'
|
15
15
|
# Use Puma as the app server
|
16
|
-
gem 'puma', '~> 5.
|
16
|
+
gem 'puma', '~> 5.1'
|
17
17
|
# Use SCSS for stylesheets
|
18
18
|
gem 'sassc-rails', '~> 2.1'
|
19
19
|
# Use Uglifier as compressor for JavaScript assets
|
@@ -110,8 +110,8 @@ gem 'bootsnap', require: false
|
|
110
110
|
gem 'diffy', require: false
|
111
111
|
|
112
112
|
# Automatic Ruby code style checking tool. Aims to enforce the community-driven Ruby Style Guide.
|
113
|
-
gem 'rubocop', '~> 1.
|
114
|
-
gem 'rubocop-rails', '~> 2.
|
113
|
+
gem 'rubocop', '~> 1.6.1', require: false
|
114
|
+
gem 'rubocop-rails', '~> 2.9', require: false
|
115
115
|
|
116
116
|
# Volta needs a CSS autoprefixer
|
117
117
|
gem 'autoprefixer-rails'
|
@@ -131,7 +131,7 @@ gem 'country_select', '~> 4.0'
|
|
131
131
|
|
132
132
|
gem 'nexmo-oas-renderer', '~> 2.4.1', require: false
|
133
133
|
|
134
|
-
gem 'nexmo_markdown_renderer', '~> 0.
|
134
|
+
gem 'nexmo_markdown_renderer', '~> 0.7.3'
|
135
135
|
|
136
136
|
gem 'smartling'
|
137
137
|
|
@@ -93,7 +93,7 @@ GEM
|
|
93
93
|
activesupport (>= 3.0.0, < 6.1)
|
94
94
|
ruby2_keywords (>= 0.0.2, < 1.0)
|
95
95
|
ast (2.4.1)
|
96
|
-
autoprefixer-rails (10.0.
|
96
|
+
autoprefixer-rails (10.1.0.0)
|
97
97
|
execjs
|
98
98
|
awesome_print (1.8.0)
|
99
99
|
banzai (0.1.3)
|
@@ -114,7 +114,7 @@ GEM
|
|
114
114
|
concurrent-ruby (~> 1.0)
|
115
115
|
builder (3.2.4)
|
116
116
|
byebug (11.1.3)
|
117
|
-
capybara (3.
|
117
|
+
capybara (3.34.0)
|
118
118
|
addressable
|
119
119
|
mini_mime (>= 0.1.3)
|
120
120
|
nokogiri (~> 1.8)
|
@@ -258,7 +258,7 @@ GEM
|
|
258
258
|
activerecord
|
259
259
|
kaminari-core (= 1.2.1)
|
260
260
|
kaminari-core (1.2.1)
|
261
|
-
listen (3.3.
|
261
|
+
listen (3.3.3)
|
262
262
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
263
263
|
rb-inotify (~> 0.9, >= 0.9.10)
|
264
264
|
lograge (0.11.2)
|
@@ -266,7 +266,7 @@ GEM
|
|
266
266
|
activesupport (>= 4)
|
267
267
|
railties (>= 4)
|
268
268
|
request_store (~> 1.0)
|
269
|
-
loofah (2.
|
269
|
+
loofah (2.8.0)
|
270
270
|
crass (~> 1.0.2)
|
271
271
|
nokogiri (>= 1.5.9)
|
272
272
|
lumberjack (1.2.8)
|
@@ -308,7 +308,7 @@ GEM
|
|
308
308
|
sass (~> 3.1)
|
309
309
|
shotgun (~> 0.9)
|
310
310
|
sinatra (~> 2.0)
|
311
|
-
nexmo_markdown_renderer (0.
|
311
|
+
nexmo_markdown_renderer (0.7.3)
|
312
312
|
activemodel (~> 6.0)
|
313
313
|
banzai (~> 0.1.2)
|
314
314
|
i18n (~> 1.7)
|
@@ -350,7 +350,7 @@ GEM
|
|
350
350
|
coderay (~> 1.1)
|
351
351
|
method_source (~> 1.0)
|
352
352
|
public_suffix (4.0.6)
|
353
|
-
puma (5.
|
353
|
+
puma (5.1.1)
|
354
354
|
nio4r (~> 2.0)
|
355
355
|
rack (2.2.3)
|
356
356
|
rack-protection (2.1.0)
|
@@ -437,21 +437,21 @@ GEM
|
|
437
437
|
rspec-snapshot (0.1.2)
|
438
438
|
rspec (> 3.0.0)
|
439
439
|
rspec-support (3.10.0)
|
440
|
-
rubocop (1.
|
440
|
+
rubocop (1.6.1)
|
441
441
|
parallel (~> 1.10)
|
442
442
|
parser (>= 2.7.1.5)
|
443
443
|
rainbow (>= 2.2.2, < 4.0)
|
444
|
-
regexp_parser (>= 1.8)
|
444
|
+
regexp_parser (>= 1.8, < 3.0)
|
445
445
|
rexml
|
446
|
-
rubocop-ast (>= 1.
|
446
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
447
447
|
ruby-progressbar (~> 1.7)
|
448
448
|
unicode-display_width (>= 1.4.0, < 2.0)
|
449
|
-
rubocop-ast (1.
|
449
|
+
rubocop-ast (1.3.0)
|
450
450
|
parser (>= 2.7.1.5)
|
451
|
-
rubocop-rails (2.
|
451
|
+
rubocop-rails (2.9.0)
|
452
452
|
activesupport (>= 4.2.0)
|
453
453
|
rack (>= 1.1)
|
454
|
-
rubocop (>= 0.
|
454
|
+
rubocop (>= 0.90.0, < 2.0)
|
455
455
|
ruby-progressbar (1.10.1)
|
456
456
|
ruby2_keywords (0.0.2)
|
457
457
|
sass (3.7.4)
|
@@ -475,10 +475,12 @@ GEM
|
|
475
475
|
shotgun (0.9.2)
|
476
476
|
rack (>= 1.0)
|
477
477
|
simple-random (1.0.3)
|
478
|
-
simplecov (0.
|
478
|
+
simplecov (0.20.0)
|
479
479
|
docile (~> 1.1)
|
480
480
|
simplecov-html (~> 0.11)
|
481
|
+
simplecov_json_formatter (~> 0.1)
|
481
482
|
simplecov-html (0.12.3)
|
483
|
+
simplecov_json_formatter (0.1.2)
|
482
484
|
sinatra (2.1.0)
|
483
485
|
mustermann (~> 1.0)
|
484
486
|
rack (~> 2.2)
|
@@ -544,7 +546,7 @@ GEM
|
|
544
546
|
woothee (1.11.1)
|
545
547
|
xpath (3.2.0)
|
546
548
|
nokogiri (~> 1.8)
|
547
|
-
zeitwerk (2.4.
|
549
|
+
zeitwerk (2.4.2)
|
548
550
|
|
549
551
|
PLATFORMS
|
550
552
|
ruby
|
@@ -590,12 +592,12 @@ DEPENDENCIES
|
|
590
592
|
neatjson
|
591
593
|
newrelic_rpm
|
592
594
|
nexmo-oas-renderer (~> 2.4.1)
|
593
|
-
nexmo_markdown_renderer (~> 0.
|
595
|
+
nexmo_markdown_renderer (~> 0.7.3)
|
594
596
|
nokogiri (~> 1.10.9)
|
595
597
|
octokit
|
596
598
|
pg (~> 1.2)
|
597
599
|
pry
|
598
|
-
puma (~> 5.
|
600
|
+
puma (~> 5.1)
|
599
601
|
rack (>= 2.0.6)
|
600
602
|
rails (~> 6.0.3)
|
601
603
|
rawler!
|
@@ -605,8 +607,8 @@ DEPENDENCIES
|
|
605
607
|
rspec-collection_matchers
|
606
608
|
rspec-rails (~> 4.0)
|
607
609
|
rspec-snapshot (~> 0.1.2)
|
608
|
-
rubocop (~> 1.
|
609
|
-
rubocop-rails (~> 2.
|
610
|
+
rubocop (~> 1.6.1)
|
611
|
+
rubocop-rails (~> 2.9)
|
610
612
|
ruby-progressbar
|
611
613
|
sassc-rails (~> 2.1)
|
612
614
|
simplecov
|
@@ -38,8 +38,8 @@ class SidenavItem
|
|
38
38
|
|
39
39
|
def css_classes
|
40
40
|
classes = ['Nxd-sidenav-badge Vlt-badge Vlt-badge--margin-left Vlt-badge--small']
|
41
|
-
classes << 'Vlt-
|
42
|
-
classes << 'Vlt-
|
41
|
+
classes << 'Vlt-badge--transparent Vlt-badge--green' if label.casecmp('beta').zero?
|
42
|
+
classes << 'Vlt-badge--transparent Vlt-badge--blue' if label.casecmp('dev preview').zero?
|
43
43
|
|
44
44
|
classes.join(' ')
|
45
45
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Translator
|
2
2
|
class FileTranslator
|
3
|
+
include Utils
|
4
|
+
|
3
5
|
attr_reader :doc_path
|
4
6
|
|
5
7
|
def initialize(doc_path)
|
@@ -12,41 +14,45 @@ module Translator
|
|
12
14
|
Translator::TranslationRequest.new(
|
13
15
|
locale: locale_with_region(locale),
|
14
16
|
frequency: frequency,
|
15
|
-
file_uri:
|
17
|
+
file_uri: uri,
|
18
|
+
file_path: full_path
|
16
19
|
)
|
17
20
|
end
|
18
21
|
end
|
19
22
|
end
|
20
23
|
|
24
|
+
def uri
|
25
|
+
@uri ||= file_uri(doc_path)
|
26
|
+
end
|
27
|
+
|
21
28
|
def frontmatter
|
22
29
|
@frontmatter ||= YAML.safe_load(File.read(full_path))
|
23
30
|
end
|
24
31
|
|
25
32
|
def full_path
|
26
|
-
@full_path ||= "#{Rails.configuration.docs_base_path}
|
33
|
+
@full_path ||= "#{Rails.configuration.docs_base_path}/#{doc_path}"
|
27
34
|
end
|
28
35
|
|
29
36
|
def frequency
|
30
37
|
@frequency ||= frontmatter['translation_frequency'] || product_translation_frequency
|
31
38
|
end
|
32
39
|
|
33
|
-
def
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
'zh-CN'
|
39
|
-
else
|
40
|
-
locale.to_s
|
40
|
+
def product_from_path
|
41
|
+
@product_from_path ||= begin
|
42
|
+
Pathname.new(
|
43
|
+
doc_path.gsub(%r{(_documentation|_tutorials|_use_cases)/#{I18n.default_locale}/}, '')
|
44
|
+
).dirname.to_s
|
41
45
|
end
|
42
46
|
end
|
43
47
|
|
44
48
|
def product
|
45
49
|
@product ||= begin
|
46
50
|
products = YAML.safe_load(File.open("#{Rails.configuration.docs_base_path}/config/products.yml"))
|
47
|
-
product = products['products'].detect
|
51
|
+
product = products['products'].detect do |p|
|
52
|
+
product_from_path.starts_with?(p['path']) || frontmatter['products']&.include?(p['path'])
|
53
|
+
end
|
48
54
|
|
49
|
-
raise ArgumentError,
|
55
|
+
raise ArgumentError, "Unable to match document with products list in config/products.yml for #{full_path}" unless product
|
50
56
|
|
51
57
|
product
|
52
58
|
end
|
@@ -53,8 +53,10 @@ module Translator
|
|
53
53
|
def file
|
54
54
|
@file ||= begin
|
55
55
|
file = Tempfile.new
|
56
|
-
file.write
|
57
|
-
|
56
|
+
file.write(
|
57
|
+
Nexmo::Markdown::Pipelines::Smartling::Preprocessor.new.call(
|
58
|
+
File.read(@translation_request.file_path)
|
59
|
+
)
|
58
60
|
)
|
59
61
|
file.rewind
|
60
62
|
file.close
|
@@ -1,11 +1,12 @@
|
|
1
1
|
module Translator
|
2
2
|
class TranslationRequest
|
3
|
-
attr_reader :locale, :frequency, :file_uri
|
3
|
+
attr_reader :locale, :frequency, :file_uri, :file_path
|
4
4
|
|
5
|
-
def initialize(locale:, frequency:, file_uri:)
|
5
|
+
def initialize(locale:, frequency:, file_uri:, file_path:)
|
6
6
|
@locale = locale
|
7
7
|
@frequency = frequency
|
8
8
|
@file_uri = file_uri
|
9
|
+
@file_path = file_path
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
@@ -11,12 +11,33 @@ module Translator
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
def locale_with_region(locale)
|
15
|
+
case locale.to_s
|
16
|
+
when 'ja', 'ja-JP'
|
17
|
+
'ja-JP'
|
18
|
+
when 'cn', 'zh-CN'
|
19
|
+
'zh-CN'
|
20
|
+
else
|
21
|
+
locale.to_s
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
14
25
|
def storage_folder(filename, locale)
|
15
26
|
if filename.starts_with? '_documentation'
|
16
27
|
dir_path = Pathname.new(file_uri(filename)).dirname.to_s
|
17
28
|
"#{Rails.configuration.docs_base_path}/_documentation/#{locale}/#{dir_path}"
|
29
|
+
elsif filename.starts_with? '_use_cases'
|
30
|
+
"#{Rails.configuration.docs_base_path}/_use_cases/#{locale}"
|
18
31
|
elsif filename.starts_with? 'config/locales'
|
19
32
|
Pathname.new(file_uri(filename)).dirname.to_s
|
33
|
+
elsif filename.starts_with? 'config/tutorials'
|
34
|
+
pathname = Pathname.new(filename.gsub("config/tutorials/#{I18n.default_locale}/", ''))
|
35
|
+
dir_path = pathname.dirname.to_s == '.' ? '' : "/#{pathname.dirname}"
|
36
|
+
"#{Rails.configuration.docs_base_path}/config/tutorials/#{locale}#{dir_path}"
|
37
|
+
elsif filename.starts_with? '_tutorials'
|
38
|
+
pathname = Pathname.new(filename.gsub("_tutorials/#{I18n.default_locale}/", ''))
|
39
|
+
dir_path = pathname.dirname.to_s == '.' ? '' : "/#{pathname.dirname}"
|
40
|
+
"#{Rails.configuration.docs_base_path}/_tutorials/#{locale}#{dir_path}"
|
20
41
|
else
|
21
42
|
dir_path = Pathname.new(file_uri(filename)).dirname.to_s
|
22
43
|
"#{Rails.configuration.docs_base_path}/_documentation/#{locale}/#{dir_path}"
|
@@ -36,7 +57,13 @@ module Translator
|
|
36
57
|
end
|
37
58
|
|
38
59
|
def file_uri(filename)
|
39
|
-
filename.
|
60
|
+
if filename.starts_with? '_documentation'
|
61
|
+
filename.gsub(%r{_documentation/[a-z]{2}/}, '')
|
62
|
+
else
|
63
|
+
filename.gsub(%r{(_use_cases|_tutorials|config/tutorials)/#{I18n.default_locale}/(.*)}) do |_|
|
64
|
+
"#{$1}/#{$2}"
|
65
|
+
end
|
66
|
+
end
|
40
67
|
end
|
41
68
|
end
|
42
69
|
end
|
@@ -38,7 +38,7 @@
|
|
38
38
|
|
39
39
|
<p><%= tutorial.description %></p>
|
40
40
|
|
41
|
-
<a href="<%= tutorial.url %>/<%= params[:code_language] %>" class="Vlt-<%= Card::COLOUR.fetch(tutorial.subtitle, 'blue') %>-
|
41
|
+
<a href="<%= tutorial.url %>/<%= params[:code_language] %>" class="Vlt-<%= Card::COLOUR.fetch(tutorial.subtitle, 'blue') %>-darker Nxd-card__cta">
|
42
42
|
<%= t('read_more') %>
|
43
43
|
<svg class="Vlt-icon Vlt-icon--smaller">
|
44
44
|
<use xlink:href="/symbol/volta-icons.svg#Vlt-icon-arrow-thin-right" />
|
@@ -27,7 +27,7 @@
|
|
27
27
|
|
28
28
|
<p><%= use_case.description %></p>
|
29
29
|
|
30
|
-
<a href="<%= url_for(controller: 'use_case', action: :show, document: use_case.relative_path, only_path: true) %>" class="Vlt-<%= Card::COLOUR.fetch(use_case.subtitle, 'blue') %>-
|
30
|
+
<a href="<%= url_for(controller: 'use_case', action: :show, document: use_case.relative_path, only_path: true) %>" class="Vlt-<%= Card::COLOUR.fetch(use_case.subtitle, 'blue') %>-darker">
|
31
31
|
<%= t('read_more') %>
|
32
32
|
<svg class="Vlt-icon Vlt-icon--smaller">
|
33
33
|
<use xlink:href="/symbol/volta-icons.svg#Vlt-icon-arrow-thin-right" />
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import Tooltip from './tooltip.min.js';
|
2
2
|
|
3
|
-
|
3
|
+
/* @preserve
|
4
4
|
* Copyright (c) 2001-present, Vonage.
|
5
5
|
*
|
6
6
|
* Core of volta
|
@@ -310,6 +310,11 @@ Volta.accordion = function () {
|
|
310
310
|
this.trigger.addEventListener('click', function(){
|
311
311
|
self.toggle();
|
312
312
|
});
|
313
|
+
this.trigger.addEventListener('keydown', function(event) {
|
314
|
+
if (event.code === 'Space' || event.code === 'Enter') {
|
315
|
+
this.trigger.click();
|
316
|
+
}
|
317
|
+
});
|
313
318
|
}
|
314
319
|
},
|
315
320
|
close: function(trigger) {
|
@@ -319,6 +324,7 @@ Volta.accordion = function () {
|
|
319
324
|
|
320
325
|
trigger.classList.remove(classes.triggerActive);
|
321
326
|
panel.classList.add(classes.contentClosing);
|
327
|
+
trigger.setAttribute("aria-expanded", "false");
|
322
328
|
|
323
329
|
panel.style.height = window.getComputedStyle(panel).height;
|
324
330
|
panel.offsetHeight; // force repaint
|
@@ -361,6 +367,7 @@ Volta.accordion = function () {
|
|
361
367
|
|
362
368
|
trig.classList.add(classes.triggerActive);
|
363
369
|
panel.classList.add(classes.contentOpening);
|
370
|
+
trig.setAttribute("aria-expanded", "true");
|
364
371
|
|
365
372
|
var startHeight = panel.style.height;
|
366
373
|
panel.style.height = 'auto';
|
@@ -640,6 +647,7 @@ Volta.dropdown = function () {
|
|
640
647
|
noCloseBlock: 'Vlt-dropdown__block--noclose',
|
641
648
|
panel: 'Vlt-dropdown__panel',
|
642
649
|
panelContent: 'Vlt-dropdown__panel__content',
|
650
|
+
selected: 'Vlt-dropdown__link--selected',
|
643
651
|
selection: 'Vlt-dropdown__selection',
|
644
652
|
switch: 'Vlt-switch',
|
645
653
|
switchSlider: 'Vlt-switch__slider'
|
@@ -653,21 +661,32 @@ Volta.dropdown = function () {
|
|
653
661
|
this.selection = this.dropdown.querySelector('.' + _class.selection);
|
654
662
|
this.isSelectionVisible = !!this.selection;
|
655
663
|
this.btn = this.dropdown.querySelector('.' + _class.btn) || this.dropdown.querySelector('.' + _class.btnLegacy);
|
664
|
+
this._links = this.dropdown.querySelectorAll('.' + _class.link);
|
656
665
|
this._suppress = supressClickHandler;
|
657
666
|
|
658
667
|
if(!this._suppress) {
|
659
668
|
this._addEventListener();
|
660
669
|
}
|
661
670
|
},
|
671
|
+
_openEventHandler: undefined,
|
672
|
+
_keyboardEventHandler: undefined,
|
662
673
|
_addEventListener: function(){
|
663
|
-
|
664
|
-
this.
|
674
|
+
this._openEventHandler = this.open.bind(this);
|
675
|
+
this._keyboardEventHandler = this.keyboardNavigation.bind(this);
|
676
|
+
|
677
|
+
this.dropdown.addEventListener('click', this._openEventHandler, { once: true });
|
678
|
+
this.dropdown.addEventListener('keydown', this._keyboardEventHandler, { once: true });
|
679
|
+
|
680
|
+
this._links.forEach(function(link) {
|
681
|
+
link.addEventListener('keydown', this._keyboardEventHandler);
|
682
|
+
}.bind(this));
|
665
683
|
},
|
666
684
|
close: function(text) {
|
667
685
|
if(text) {
|
668
686
|
this._setDropdownSelectionText(text);
|
669
687
|
}
|
670
688
|
this.dropdown.classList.remove(_class.expanded);
|
689
|
+
this.dropdown.setAttribute("aria-expanded", "false");
|
671
690
|
|
672
691
|
if(!this._suppress){
|
673
692
|
this._addEventListener();
|
@@ -696,31 +715,95 @@ Volta.dropdown = function () {
|
|
696
715
|
}
|
697
716
|
|
698
717
|
var text;
|
699
|
-
if(parentIsPanel && Volta._hasClass(e.target, _class.label)) {
|
718
|
+
if (parentIsPanel && Volta._hasClass(e.target, _class.label)) {
|
700
719
|
text = e.target.innerHTML;
|
701
|
-
} else if (parentIsPanel) {
|
720
|
+
} else if (parentIsPanel && e.keyCode !== 27) { // esc
|
702
721
|
var label = e.target.querySelector('.' + _class.label);
|
703
|
-
if(label) {
|
722
|
+
if (label) {
|
704
723
|
text = label.innerHTML;
|
705
724
|
}
|
706
725
|
}
|
707
726
|
|
727
|
+
document.querySelector('body').removeEventListener('click', this._closeEventHandler);
|
728
|
+
this.dropdown.removeEventListener('keydown', this._keyboardEventHandler, { once: true });
|
729
|
+
this.dropdown.removeEventListener('click', this._openEventHandler, { once: true });
|
730
|
+
|
731
|
+
this._links.forEach(function(link) {
|
732
|
+
link.removeEventListener('keydown', this._keyboardEventHandler);
|
733
|
+
}.bind(this));
|
734
|
+
|
708
735
|
this.close(text);
|
736
|
+
},
|
737
|
+
keyboardNavigation: function(e) {
|
738
|
+
e.preventDefault();
|
739
|
+
e.stopPropagation();
|
740
|
+
|
741
|
+
if (e.keyCode === 27) { // esc
|
742
|
+
this._closeEvent(e);
|
743
|
+
}
|
709
744
|
|
710
|
-
|
745
|
+
if (e.code === 'ArrowDown' || e.code === 'ArrowUp' || e.code === 'Enter' || e.keyCode === 32) { // 32 = spacebar
|
746
|
+
this._links.forEach(function(link) {
|
747
|
+
link.setAttribute('tabIndex', '-1');
|
748
|
+
});
|
749
|
+
|
750
|
+
if (e.currentTarget.classList.contains(_class.wrapper)) {
|
751
|
+
this.dropdown.classList.add(_class.expanded);
|
752
|
+
this.dropdown.removeEventListener('click', this._openEventHandler, { once: true });
|
753
|
+
|
754
|
+
var selectedLink = this.dropdown.querySelector('.' + _class.selected) || this._links[0];
|
755
|
+
|
756
|
+
if (selectedLink) {
|
757
|
+
selectedLink.setAttribute('tabIndex', '0');
|
758
|
+
selectedLink.focus();
|
759
|
+
}
|
760
|
+
}
|
761
|
+
|
762
|
+
if (e.code === 'ArrowUp') {
|
763
|
+
var nextItem = e.currentTarget.previousElementSibling;
|
764
|
+
}
|
765
|
+
|
766
|
+
if (e.code === 'ArrowDown') {
|
767
|
+
var nextItem = e.currentTarget.nextElementSibling;
|
768
|
+
}
|
769
|
+
|
770
|
+
if (nextItem && nextItem.classList.contains(_class.link)) {
|
771
|
+
nextItem.setAttribute('tabIndex', '0');
|
772
|
+
nextItem.focus();
|
773
|
+
}
|
774
|
+
|
775
|
+
if (!this._suppress && e.currentTarget.classList.contains(_class.wrapper)) {
|
776
|
+
this.closeEventHandler();
|
777
|
+
}
|
778
|
+
}
|
779
|
+
|
780
|
+
if (e.code === 'Enter' && !e.currentTarget.classList.contains(_class.wrapper)) {
|
781
|
+
e.currentTarget.click();
|
782
|
+
}
|
711
783
|
},
|
712
784
|
open: function(event) {
|
713
|
-
if(event) {
|
785
|
+
if (event) {
|
714
786
|
event.preventDefault();
|
715
787
|
event.stopPropagation();
|
716
788
|
}
|
717
789
|
|
718
790
|
this.dropdown.classList.add(_class.expanded);
|
791
|
+
this.dropdown.setAttribute("aria-expanded", "true");
|
719
792
|
|
720
|
-
|
721
|
-
|
722
|
-
|
793
|
+
var selectedLink = this.dropdown.querySelector('.' + _class.selected) || this._links[0];
|
794
|
+
|
795
|
+
if (selectedLink) {
|
796
|
+
selectedLink.setAttribute('tabIndex', '0');
|
797
|
+
selectedLink.focus();
|
723
798
|
}
|
799
|
+
|
800
|
+
if (!this._suppress) {
|
801
|
+
this.closeEventHandler();
|
802
|
+
}
|
803
|
+
},
|
804
|
+
closeEventHandler: function() {
|
805
|
+
this._closeEventHandler = this._closeEvent.bind(this);
|
806
|
+
document.querySelector('body').addEventListener('click', this._closeEventHandler);
|
724
807
|
},
|
725
808
|
_setDropdownSelectionText: function(text) {
|
726
809
|
if(this.isSelectionVisible) {
|
@@ -1308,9 +1391,6 @@ Volta.tab = function () {
|
|
1308
1391
|
|
1309
1392
|
link.index = index;
|
1310
1393
|
link.addEventListener('keyup', _this._keyUpEventListener.bind(_this));
|
1311
|
-
link.addEventListener('toggle', function () {
|
1312
|
-
_this.toggle(link);
|
1313
|
-
});
|
1314
1394
|
link.addEventListener('click', function () {
|
1315
1395
|
_this.toggle(link);
|
1316
1396
|
});
|
@@ -1375,6 +1455,7 @@ Volta.tab = function () {
|
|
1375
1455
|
|
1376
1456
|
this._activeLink.setAttribute('tabindex', '0');
|
1377
1457
|
this._activeLink.setAttribute('aria-selected', 'true');
|
1458
|
+
this._activeLink.focus();
|
1378
1459
|
if (this._activePanel) {
|
1379
1460
|
this._activePanel.removeAttribute('hidden');
|
1380
1461
|
}
|
@@ -1538,12 +1619,10 @@ Volta.tooltip = function () {
|
|
1538
1619
|
left: 'Vlt-tooltip--left',
|
1539
1620
|
tooltip: 'Vlt-tooltip',
|
1540
1621
|
top: 'Vlt-tooltip--top',
|
1541
|
-
right: 'Vlt-tooltip--right'
|
1622
|
+
right: 'Vlt-tooltip--right',
|
1623
|
+
large: 'Vlt-tooltip--large'
|
1542
1624
|
}
|
1543
1625
|
|
1544
|
-
var currentTooltip = undefined,
|
1545
|
-
currentTooltipContent = undefined;
|
1546
|
-
|
1547
1626
|
return {
|
1548
1627
|
create: create,
|
1549
1628
|
init: attachTooltipHandlers
|
@@ -1567,6 +1646,7 @@ Volta.tooltip = function () {
|
|
1567
1646
|
*/
|
1568
1647
|
function create(tooltip) {
|
1569
1648
|
var placement;
|
1649
|
+
var size;
|
1570
1650
|
|
1571
1651
|
if (Volta._hasClass(tooltip, _class.bottom)) {
|
1572
1652
|
placement = 'bottom';
|
@@ -1578,10 +1658,16 @@ Volta.tooltip = function () {
|
|
1578
1658
|
placement = 'right';
|
1579
1659
|
}
|
1580
1660
|
|
1661
|
+
if (Volta._hasClass(tooltip, _class.large)) {
|
1662
|
+
size = ' Vlt-tooltip--large';
|
1663
|
+
} else {
|
1664
|
+
size='';
|
1665
|
+
}
|
1666
|
+
|
1581
1667
|
var template =
|
1582
|
-
'<div class="Vlt-tooltip--js" role="tooltip">' +
|
1583
|
-
'<div class="tooltip-arrow Vlt-tooltip__arrow"></div>' +
|
1584
|
-
'<div class="tooltip-inner Vlt-tooltip__content"></div>' +
|
1668
|
+
'<div class="Vlt-tooltip--js' + size + '" role="tooltip">' +
|
1669
|
+
'<div class="tooltip-arrow Vlt-tooltip__arrow"></div>' +
|
1670
|
+
'<div class="tooltip-inner Vlt-tooltip__content"></div>' +
|
1585
1671
|
'</div>';
|
1586
1672
|
|
1587
1673
|
var title = tooltip.title;
|
@@ -2142,4 +2228,5 @@ Volta.menu = function () {
|
|
2142
2228
|
}
|
2143
2229
|
}();
|
2144
2230
|
|
2231
|
+
|
2145
2232
|
export default Volta;
|