nexmo-oas-renderer 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.env.example +1 -0
- data/.gitignore +5 -0
- data/CHANGELOG.md +2 -0
- data/CONTRIBUTING.md +46 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +183 -0
- data/LICENSE.txt +21 -0
- data/README.md +73 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/nexmo-oas-renderer +5 -0
- data/lib/nexmo/oas/engine.rb +9 -0
- data/lib/nexmo/oas/renderer.rb +13 -0
- data/lib/nexmo/oas/renderer/app.rb +116 -0
- data/lib/nexmo/oas/renderer/config.ru +7 -0
- data/lib/nexmo/oas/renderer/config/code_languages.yml +138 -0
- data/lib/nexmo/oas/renderer/config/dynamic_content.yml +1 -0
- data/lib/nexmo/oas/renderer/config/redirects.yml +8 -0
- data/lib/nexmo/oas/renderer/constraints/open_api.rb +76 -0
- data/lib/nexmo/oas/renderer/constraints/redirector.rb +17 -0
- data/lib/nexmo/oas/renderer/decorators/response_parser_decorator.rb +55 -0
- data/lib/nexmo/oas/renderer/filters/anchor.rb +17 -0
- data/lib/nexmo/oas/renderer/filters/audio.rb +21 -0
- data/lib/nexmo/oas/renderer/filters/block_escape.rb +24 -0
- data/lib/nexmo/oas/renderer/filters/break.rb +13 -0
- data/lib/nexmo/oas/renderer/filters/code.rb +64 -0
- data/lib/nexmo/oas/renderer/filters/code_snippet.rb +194 -0
- data/lib/nexmo/oas/renderer/filters/code_snippet_list.rb +33 -0
- data/lib/nexmo/oas/renderer/filters/code_snippets.rb +158 -0
- data/lib/nexmo/oas/renderer/filters/collapsible.rb +27 -0
- data/lib/nexmo/oas/renderer/filters/columns.rb +50 -0
- data/lib/nexmo/oas/renderer/filters/concept_list.rb +33 -0
- data/lib/nexmo/oas/renderer/filters/dynamic_content.rb +30 -0
- data/lib/nexmo/oas/renderer/filters/external_link.rb +32 -0
- data/lib/nexmo/oas/renderer/filters/frontmatter.rb +14 -0
- data/lib/nexmo/oas/renderer/filters/heading.rb +61 -0
- data/lib/nexmo/oas/renderer/filters/icon.rb +22 -0
- data/lib/nexmo/oas/renderer/filters/indent.rb +20 -0
- data/lib/nexmo/oas/renderer/filters/inline_escape.rb +17 -0
- data/lib/nexmo/oas/renderer/filters/js_sequence_diagram.rb +21 -0
- data/lib/nexmo/oas/renderer/filters/label.rb +32 -0
- data/lib/nexmo/oas/renderer/filters/language.rb +15 -0
- data/lib/nexmo/oas/renderer/filters/markdown.rb +85 -0
- data/lib/nexmo/oas/renderer/filters/modal.rb +41 -0
- data/lib/nexmo/oas/renderer/filters/partial.rb +28 -0
- data/lib/nexmo/oas/renderer/filters/php_inliner.rb +15 -0
- data/lib/nexmo/oas/renderer/filters/screenshot.rb +26 -0
- data/lib/nexmo/oas/renderer/filters/tab.rb +250 -0
- data/lib/nexmo/oas/renderer/filters/techio.rb +24 -0
- data/lib/nexmo/oas/renderer/filters/tooltip.rb +22 -0
- data/lib/nexmo/oas/renderer/filters/tutorial_link.rb +27 -0
- data/lib/nexmo/oas/renderer/filters/tutorials.rb +28 -0
- data/lib/nexmo/oas/renderer/filters/unfreeze.rb +20 -0
- data/lib/nexmo/oas/renderer/filters/user_personalization.rb +43 -0
- data/lib/nexmo/oas/renderer/helpers/navigation.rb +66 -0
- data/lib/nexmo/oas/renderer/helpers/render.rb +24 -0
- data/lib/nexmo/oas/renderer/helpers/summary.rb +30 -0
- data/lib/nexmo/oas/renderer/helpers/url.rb +17 -0
- data/lib/nexmo/oas/renderer/lib/core_ext/string.rb +14 -0
- data/lib/nexmo/oas/renderer/lib/redcarpet.rb +14 -0
- data/lib/nexmo/oas/renderer/models/code_snippet.rb +75 -0
- data/lib/nexmo/oas/renderer/models/tutorial.rb +83 -0
- data/lib/nexmo/oas/renderer/pipelines/markdown_pipeline.rb +52 -0
- data/lib/nexmo/oas/renderer/presenters/api_specification.rb +42 -0
- data/lib/nexmo/oas/renderer/presenters/groups.rb +35 -0
- data/lib/nexmo/oas/renderer/presenters/navigation.rb +24 -0
- data/lib/nexmo/oas/renderer/presenters/open_api_specification.rb +68 -0
- data/lib/nexmo/oas/renderer/presenters/versions.rb +40 -0
- data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Black.woff +0 -0
- data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Black.woff2 +0 -0
- data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Heavy.woff +0 -0
- data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Heavy.woff2 +0 -0
- data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Regular.woff +0 -0
- data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Regular.woff2 +0 -0
- data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Semibold.woff +0 -0
- data/lib/nexmo/oas/renderer/public/assets/fonts/Lato-Semibold.woff2 +0 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/android.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/curl.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/dotnet.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/ios.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/java.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/javascript.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/node.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/php.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/python.svg +11 -0
- data/lib/nexmo/oas/renderer/public/assets/images/brands/ruby.svg +1 -0
- data/lib/nexmo/oas/renderer/public/assets/images/lost.svg +37 -0
- data/lib/nexmo/oas/renderer/public/assets/javascripts/components/format.js +42 -0
- data/lib/nexmo/oas/renderer/public/assets/javascripts/volta.accordion.js +249 -0
- data/lib/nexmo/oas/renderer/public/assets/javascripts/volta.core.js +230 -0
- data/lib/nexmo/oas/renderer/public/assets/javascripts/volta.modal.js +300 -0
- data/lib/nexmo/oas/renderer/public/assets/javascripts/volta.tabs.js +139 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/api.css +95 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/buttons.css +80 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/core.css +79 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/mediaqueries.css +2 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/mediaqueries.css.map +7 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/navigation.css +79 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/nexmo.css +68 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/api.scss +147 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/core.scss +133 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/mediaqueries.scss +48 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/navigation.scss +106 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/nexmo.scss +61 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/style.scss +10 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/syntax.scss +63 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/typography.scss +248 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/variables.scss +91 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/sass/volta-templates.scss +119 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/style.css +2 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/style.css.map +7 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/syntax.css +79 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/typography.css +86 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/variables.css +2 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/variables.css.map +7 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/volta-templates.css +2 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/volta-templates.css.map +7 -0
- data/lib/nexmo/oas/renderer/public/assets/stylesheets/volta.min.css +1 -0
- data/lib/nexmo/oas/renderer/public/assets/symbol/volta-icons.svg +1 -0
- data/lib/nexmo/oas/renderer/public/favicon.ico +0 -0
- data/lib/nexmo/oas/renderer/services/code_language_api.rb +98 -0
- data/lib/nexmo/oas/renderer/services/oas_parser.rb +21 -0
- data/lib/nexmo/oas/renderer/services/open_api_definition_resolver.rb +33 -0
- data/lib/nexmo/oas/renderer/version.rb +7 -0
- data/lib/nexmo/oas/renderer/views/api/show.erb +1 -0
- data/lib/nexmo/oas/renderer/views/code_snippets/_application_messages_dispatch.html.erb +9 -0
- data/lib/nexmo/oas/renderer/views/code_snippets/_application_rtc.html.erb +41 -0
- data/lib/nexmo/oas/renderer/views/code_snippets/_application_voice.html.erb +24 -0
- data/lib/nexmo/oas/renderer/views/code_snippets/_code_only.html.erb +6 -0
- data/lib/nexmo/oas/renderer/views/code_snippets/_configure_client.html.erb +20 -0
- data/lib/nexmo/oas/renderer/views/code_snippets/_dependencies.html.erb +11 -0
- data/lib/nexmo/oas/renderer/views/code_snippets/_write_code.html.erb +13 -0
- data/lib/nexmo/oas/renderer/views/code_snippets/list/plain.html.erb +10 -0
- data/lib/nexmo/oas/renderer/views/concepts/list/plain.html.erb +5 -0
- data/lib/nexmo/oas/renderer/views/layouts/_head.erb +4 -0
- data/lib/nexmo/oas/renderer/views/layouts/_javascripts.erb +9 -0
- data/lib/nexmo/oas/renderer/views/layouts/api.erb +23 -0
- data/lib/nexmo/oas/renderer/views/layouts/open_api.erb +10 -0
- data/lib/nexmo/oas/renderer/views/open_api/_callback.erb +5 -0
- data/lib/nexmo/oas/renderer/views/open_api/_callback_endpoint.erb +48 -0
- data/lib/nexmo/oas/renderer/views/open_api/_code_examples.erb +16 -0
- data/lib/nexmo/oas/renderer/views/open_api/_endpoint.erb +156 -0
- data/lib/nexmo/oas/renderer/views/open_api/_model.erb +38 -0
- data/lib/nexmo/oas/renderer/views/open_api/_navigation.erb +80 -0
- data/lib/nexmo/oas/renderer/views/open_api/_parameter_groups.erb +50 -0
- data/lib/nexmo/oas/renderer/views/open_api/_parameters.erb +165 -0
- data/lib/nexmo/oas/renderer/views/open_api/_response_description_parameters.erb +61 -0
- data/lib/nexmo/oas/renderer/views/open_api/_response_descriptions.erb +41 -0
- data/lib/nexmo/oas/renderer/views/open_api/show.erb +104 -0
- data/lib/nexmo/oas/renderer/views/static/404.erb +6 -0
- data/lib/nexmo/oas/renderer/views/tutorials/_index.html.erb +32 -0
- data/lib/nexmo/oas/renderer/views/tutorials/index.html.erb +7 -0
- data/lib/nexmo/oas/renderer/views/tutorials/list/plain.html.erb +5 -0
- data/lib/nexmo/oas/renderer/views/tutorials/show.html.erb +8 -0
- data/nexmo-oas-renderer.gemspec +49 -0
- metadata +399 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative '../helpers/navigation'
|
2
|
+
|
3
|
+
module Nexmo
|
4
|
+
module OAS
|
5
|
+
module Renderer
|
6
|
+
module Presenters
|
7
|
+
class Navigation
|
8
|
+
include Helpers::Navigation
|
9
|
+
|
10
|
+
attr_reader :title, :content
|
11
|
+
|
12
|
+
def initialize(content:, title: nil)
|
13
|
+
@content = content
|
14
|
+
@title = title
|
15
|
+
end
|
16
|
+
|
17
|
+
def navigation_from_content
|
18
|
+
super(content: @content, title: @title)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
require_relative './groups'
|
3
|
+
require_relative './versions'
|
4
|
+
require_relative '../services/open_api_definition_resolver'
|
5
|
+
|
6
|
+
module Nexmo
|
7
|
+
module OAS
|
8
|
+
module Renderer
|
9
|
+
module Presenters
|
10
|
+
|
11
|
+
class OpenApiSpecification
|
12
|
+
extend Forwardable
|
13
|
+
|
14
|
+
attr_reader :definition_name
|
15
|
+
|
16
|
+
def_delegators :@versions, :current_version, :available_versions
|
17
|
+
def_delegators :@groups, :groups
|
18
|
+
|
19
|
+
def initialize(definition_name:, expand_responses:)
|
20
|
+
@definition_name = definition_name
|
21
|
+
@expand_responses = expand_responses
|
22
|
+
@versions = Versions.new(definition_name)
|
23
|
+
@groups = Groups.new(definition)
|
24
|
+
end
|
25
|
+
|
26
|
+
def display_initialization?
|
27
|
+
initialization? && initialization_content && initialization_config
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialization?
|
31
|
+
File.file? "#{API.oas_path}/../initialization/#{@definition_name}.md"
|
32
|
+
end
|
33
|
+
|
34
|
+
def initialization_content
|
35
|
+
@initialization_content ||= MarkdownPipeline.new.call(
|
36
|
+
File.read("#{API.oas_path}/../initialization/#{@definition_name}.md")
|
37
|
+
) if initialization?
|
38
|
+
end
|
39
|
+
|
40
|
+
def initialization_config
|
41
|
+
@initialization_config ||= YAML.safe_load(
|
42
|
+
File.read("#{API.oas_path}/../initialization/#{@definition_name}.md")
|
43
|
+
) if initialization?
|
44
|
+
end
|
45
|
+
|
46
|
+
def errors?
|
47
|
+
File.exist?("#{API.oas_path}/../errors/#{@definition_name}.md")
|
48
|
+
end
|
49
|
+
|
50
|
+
def definition_errors
|
51
|
+
@definition_errors ||= MarkdownPipeline.new.call(
|
52
|
+
File.read("#{API.oas_path}/../errors/#{@definition_name}.md")
|
53
|
+
) if errors?
|
54
|
+
end
|
55
|
+
|
56
|
+
def definition
|
57
|
+
@definition ||= OpenApiDefinitionResolver.find(@definition_name)
|
58
|
+
end
|
59
|
+
|
60
|
+
def auto_expand_responses
|
61
|
+
@expand_responses
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative '../constraints/open_api'
|
2
|
+
|
3
|
+
module Nexmo
|
4
|
+
module OAS
|
5
|
+
module Renderer
|
6
|
+
module Presenters
|
7
|
+
|
8
|
+
class Versions
|
9
|
+
def initialize(definition_name)
|
10
|
+
@definition_name = definition_name
|
11
|
+
end
|
12
|
+
|
13
|
+
def base_name
|
14
|
+
@base_name ||= @definition_name.gsub(/\.v\d+/, '')
|
15
|
+
end
|
16
|
+
|
17
|
+
def current_version
|
18
|
+
@current_version ||= begin
|
19
|
+
m = /\.v(\d+)/.match(@definition_name)
|
20
|
+
m.nil? ? '1' : m[1]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def available_versions
|
25
|
+
@available_versions ||= begin
|
26
|
+
versions = Constraints::OpenApi.find_all_versions(base_name)
|
27
|
+
# Add in anything in the old /_api folder
|
28
|
+
if File.exist?("_api/#{base_name}.md")
|
29
|
+
versions.push({ 'version' => '1', 'name' => base_name })
|
30
|
+
end
|
31
|
+
|
32
|
+
versions.sort_by! { |v| v['version'] }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg id="android" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="60" height="60" viewBox="0 0 128 128" style="enable-background:new 0 0 48 48;;fill:#000000;"><g id="surface1"> <path style="fill:#7CB342;" d="M12,29c0,1.1-0.9,2-2,2s-2-0.9-2-2v-9c0-1.1,0.9-2,2-2s2,0.9,2,2V29z"></path> <path style="fill:#7CB342;" d="M40,29c0,1.1-0.9,2-2,2s-2-0.9-2-2v-9c0-1.1,0.9-2,2-2s2,0.9,2,2V29z"></path> <path style="fill:#7CB342;" d="M22,40c0,1.1-0.9,2-2,2s-2-0.9-2-2v-9c0-1.1,0.9-2,2-2s2,0.9,2,2V40z"></path> <path style="fill:#7CB342;" d="M30,40c0,1.1-0.9,2-2,2s-2-0.9-2-2v-9c0-1.1,0.9-2,2-2s2,0.9,2,2V40z"></path> <path style="fill:#7CB342;" d="M14,18v15c0,1.1,0.9,2,2,2h16c1.1,0,2-0.9,2-2V18H14z"></path> <path style="fill:#7CB342;" d="M24,8c-6,0-9.7,3.6-10,8h20C33.7,11.6,30,8,24,8z M20,13.6c-0.6,0-1-0.4-1-1c0-0.6,0.4-1,1-1 s1,0.4,1,1C21,13.1,20.6,13.6,20,13.6z M28,13.6c-0.6,0-1-0.4-1-1c0-0.6,0.4-1,1-1s1,0.4,1,1C29,13.1,28.6,13.6,28,13.6z"></path> <path style="fill:#7CB342;" d="M28.3,10.5c-0.2,0-0.4-0.1-0.6-0.2c-0.5-0.3-0.6-0.9-0.3-1.4l1.7-2.5c0.3-0.5,0.9-0.6,1.4-0.3 c0.5,0.3,0.6,0.9,0.3,1.4l-1.7,2.5C29,10.3,28.7,10.5,28.3,10.5z"></path> <path style="fill:#7CB342;" d="M19.3,10.1c-0.3,0-0.7-0.2-0.8-0.5l-1.3-2.1c-0.3-0.5-0.2-1.1,0.3-1.4c0.5-0.3,1.1-0.2,1.4,0.3 l1.3,2.1c0.3,0.5,0.2,1.1-0.3,1.4C19.7,10,19.5,10.1,19.3,10.1z"></path></g></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg id="curl" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128"><path id="plain" fill="#0b3754" d="M64,7.83H4.77L14.95,95.13l49,25,.06,0,49.07-25L123.23,7.83Zm42.77,54.86c0,.88,0,1.67-.77,2L73.25,80.44l-2.42,1.13-.27-3.15V72.23l.24-1.57,1.09-.47L95.07,59.81l-21.54-9.6L64.35,68.34,58.9,78.87l-1.22,2.27-2.05-.9L22,64.71a2.42,2.42,0,0,1-1.45-2V56.91a2.39,2.39,0,0,1,1.42-2l34-15.73,3.21-1.44v9.66l.24,1.34-1.56.7L34.45,59.79,56.3,69.42l8.05-16,6.21-12.65,1.13-2.28,1.81.91L106,54.89c.73.35.76,1.14.76,2Z"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg id="dotnet" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128"><path fill-rule="evenodd" clip-rule="evenodd" fill="#1384C8" d="M82.108 78.432c.479-1.232 1.022-2.445 1.427-3.701 2.288-7.097 4.554-14.2 6.805-21.309.865-2.731 1.813-5.42 3.515-7.767 2.692-3.709 6.442-5.652 10.88-6.331 1.741-.266 3.518-.389 5.28-.406 5.267-.05 10.536-.015 15.804-.01.28 0 .56.029.957.052-.129.304-.199.525-.311.724-1.955 3.494-3.872 7.009-5.885 10.468-3.505 6.022-7.016 12.042-10.631 17.998-2.319 3.819-4.834 7.52-7.687 10.974-2.105 2.548-4.321 4.984-7.146 6.77-1.925 1.217-3.981 1.929-6.315 1.917-8.278-.045-16.556-.012-24.834-.024-2.461-.004-4.568-.941-6.356-2.603-2.563-2.381-4.093-5.412-5.345-8.608-2.284-5.835-3.563-11.951-5.031-18.014-.688-2.838-1.47-5.654-2.215-8.478-.048-.183-.142-.354-.25-.617l-.577.542c-3.228 3.207-6.071 6.741-8.615 10.498-.693 1.024-.926 2.374-1.313 3.591-1.424 4.47-2.722 8.983-4.264 13.411-1.477 4.242-4.125 7.616-8.264 9.61-2.42 1.165-5.004 1.795-7.689 1.855-3.98.088-7.962.098-11.943.134-.952.009-.996-.069-.748-.99 1.707-6.338 3.87-12.514 6.58-18.492 2.794-6.167 6.085-12.048 10.231-17.419 2.823-3.657 5.941-7.031 9.843-9.582 1.979-1.293 4.083-2.315 6.477-2.584.394-.045.793-.073 1.189-.073 8.478-.004 16.956.082 25.433-.039 4.547-.065 7.839 1.855 10.304 5.515 1.533 2.276 2.63 4.761 3.553 7.328 1.861 5.178 3.018 10.547 4.325 15.878.748 3.051 1.581 6.081 2.379 9.12.06.228.157.446.238.668l.199-.006z"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg id="ios" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="53" height="53" viewBox="0 0 128 128" style="fill:#296CAD;"> <path style="line-height:normal;text-indent:0;text-align:start;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000;text-transform:none;block-progression:tb;isolation:auto;mix-blend-mode:normal" d="M 15 3 C 8.3845336 3 3 8.3845336 3 15 L 3 35 C 3 41.615466 8.3845336 47 15 47 L 35 47 C 41.615466 47 47 41.615466 47 35 L 47 15 C 47 8.3845336 41.615466 3 35 3 L 15 3 z M 15 5 L 35 5 C 40.534534 5 45 9.4654664 45 15 L 45 35 C 45 40.534534 40.534534 45 35 45 L 15 45 C 9.4654664 45 5 40.534534 5 35 L 5 15 C 5 9.4654664 9.4654664 5 15 5 z M 11.615234 18.066406 C 10.912234 18.066406 10.394531 18.567563 10.394531 19.226562 C 10.394531 19.876563 10.912234 20.376953 11.615234 20.376953 C 12.318234 20.376953 12.837891 19.876562 12.837891 19.226562 C 12.837891 18.567562 12.318234 18.066406 11.615234 18.066406 z M 22.037109 18.636719 C 18.398109 18.636719 16.113281 21.18525 16.113281 25.28125 C 16.113281 29.36825 18.354109 31.933594 22.037109 31.933594 C 25.711109 31.933594 27.943359 29.35925 27.943359 25.28125 C 27.943359 21.19425 25.693109 18.637719 22.037109 18.636719 z M 34.966797 18.636719 C 32.198797 18.636719 30.351562 20.139437 30.351562 22.398438 C 30.351562 24.261437 31.397406 25.37025 33.691406 25.90625 L 35.326172 26.302734 C 37.005172 26.697734 37.744141 27.277141 37.744141 28.244141 C 37.744141 29.369141 36.583953 30.185547 35.001953 30.185547 C 33.306858 30.185547 32.128927 29.421639 31.960938 28.21875 L 30.007812 28.21875 C 30.148813 30.48675 32.037609 31.935547 34.849609 31.935547 C 37.855609 31.935547 39.736328 30.416234 39.736328 27.990234 C 39.736328 26.083234 38.6645 25.027875 36.0625 24.421875 L 34.666016 24.078125 C 33.014016 23.691125 32.345703 23.172578 32.345703 22.267578 C 32.345703 21.124578 33.383453 20.378906 34.939453 20.378906 C 36.416453 20.378906 37.434141 21.106391 37.619141 22.275391 L 39.535156 22.275391 C 39.421156 20.139391 37.541797 18.636719 34.966797 18.636719 z M 22.037109 20.472656 C 24.446109 20.472656 25.931641 22.33725 25.931641 25.28125 C 25.931641 28.20725 24.445109 30.097656 22.037109 30.097656 C 19.603109 30.097656 18.126953 28.20825 18.126953 25.28125 C 18.126953 22.33725 19.646109 20.473656 22.037109 20.472656 z M 10.675781 22.056641 L 10.675781 31.626953 L 12.556641 31.626953 L 12.556641 22.056641 L 10.675781 22.056641 z" font-weight="400" font-family="sans-serif" white-space="normal" overflow="visible"></path></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg id="java" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128"><path fill="#0074BD" d="M47.617 98.12s-4.767 2.774 3.397 3.71c9.892 1.13 14.947.968 25.845-1.092 0 0 2.871 1.795 6.873 3.351-24.439 10.47-55.308-.607-36.115-5.969zM44.629 84.455s-5.348 3.959 2.823 4.805c10.567 1.091 18.91 1.18 33.354-1.6 0 0 1.993 2.025 5.132 3.131-29.542 8.64-62.446.68-41.309-6.336z"/><path fill="#EA2D2E" d="M69.802 61.271c6.025 6.935-1.58 13.17-1.58 13.17s15.289-7.891 8.269-17.777c-6.559-9.215-11.587-13.792 15.635-29.58 0 .001-42.731 10.67-22.324 34.187z"/><path fill="#0074BD" d="M102.123 108.229s3.529 2.91-3.888 5.159c-14.102 4.272-58.706 5.56-71.094.171-4.451-1.938 3.899-4.625 6.526-5.192 2.739-.593 4.303-.485 4.303-.485-4.953-3.487-32.013 6.85-13.743 9.815 49.821 8.076 90.817-3.637 77.896-9.468zM49.912 70.294s-22.686 5.389-8.033 7.348c6.188.828 18.518.638 30.011-.326 9.39-.789 18.813-2.474 18.813-2.474s-3.308 1.419-5.704 3.053c-23.042 6.061-67.544 3.238-54.731-2.958 10.832-5.239 19.644-4.643 19.644-4.643zM90.609 93.041c23.421-12.167 12.591-23.86 5.032-22.285-1.848.385-2.677.72-2.677.72s.688-1.079 2-1.543c14.953-5.255 26.451 15.503-4.823 23.725 0-.002.359-.327.468-.617z"/><path fill="#EA2D2E" d="M76.491 1.587s12.968 12.976-12.303 32.923c-20.266 16.006-4.621 25.13-.007 35.559-11.831-10.673-20.509-20.07-14.688-28.815 8.548-12.834 32.229-19.059 26.998-39.667z"/><path fill="#0074BD" d="M52.214 126.021c22.476 1.437 57-.8 57.817-11.436 0 0-1.571 4.032-18.577 7.231-19.186 3.612-42.854 3.191-56.887.874 0 .001 2.875 2.381 17.647 3.331z"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg id="javascript" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="55" height="55" viewBox="0 0 128 128" style="fill:#000000;"><g id="surface1"><path style=" " d="M 43.335938 4 L 6.667969 4 C 5.195313 4 4 5.195313 4 6.667969 L 4 43.332031 C 4 44.804688 5.195313 46 6.667969 46 L 43.332031 46 C 44.804688 46 46 44.804688 46 43.335938 L 46 6.667969 C 46 5.195313 44.804688 4 43.335938 4 Z M 27 36.183594 C 27 40.179688 24.65625 42 21.234375 42 C 18.140625 42 15.910156 39.925781 15 38 L 18.144531 36.097656 C 18.75 37.171875 19.671875 38 21 38 C 22.269531 38 23 37.503906 23 35.574219 L 23 23 L 27 23 Z M 35.675781 42 C 32.132813 42 30.121094 40.214844 29 38 L 32 36 C 32.816406 37.335938 33.707031 38.613281 35.589844 38.613281 C 37.171875 38.613281 38 37.824219 38 36.730469 C 38 35.425781 37.140625 34.960938 35.402344 34.199219 L 34.449219 33.789063 C 31.695313 32.617188 29.863281 31.148438 29.863281 28.039063 C 29.863281 25.179688 32.046875 23 35.453125 23 C 37.878906 23 39.621094 23.84375 40.878906 26.054688 L 37.910156 27.964844 C 37.253906 26.789063 36.550781 26.328125 35.453125 26.328125 C 34.335938 26.328125 33.628906 27.039063 33.628906 27.964844 C 33.628906 29.109375 34.335938 29.570313 35.972656 30.28125 L 36.925781 30.691406 C 40.171875 32.078125 42 33.496094 42 36.683594 C 42 40.117188 39.300781 42 35.675781 42 Z "></path></g></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg id="node" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128"><path fill="#83CD29" d="M112.678 30.334l-44.143-25.605c-2.781-1.584-6.424-1.584-9.227 0l-44.488 25.605c-2.869 1.651-4.82 4.754-4.82 8.073v51.142c0 3.319 1.992 6.423 4.862 8.083l11.729 6.688c5.627 2.772 7.186 2.772 9.746 2.772 8.334 0 12.662-5.039 12.662-13.828v-50.49c.001-.713.446-1.774-.255-1.774h-5.622c-.712 0-2.122 1.061-2.122 1.773v50.49c0 3.896-3.616 7.773-10.202 4.48l-12.122-7.013c-.422-.23-.676-.693-.676-1.181v-51.142c0-.482.463-.966.891-1.213l44.378-25.561c.415-.235 1.002-.235 1.415 0l43.963 25.555c.421.253.354.722.354 1.219v51.142c0 .488.092.963-.323 1.198l-44.133 25.576c-.378.227-.87.227-1.285 0l-11.317-6.749c-.341-.198-.752-.269-1.08-.086-3.145 1.783-3.729 2.02-6.679 3.043-.727.253-1.799.692.408 1.929l14.798 8.754c1.416.82 3.027 1.246 4.647 1.246 1.642 0 3.249-.426 4.666-1.246l43.976-25.582c2.871-1.672 4.322-4.764 4.322-8.083v-51.142c-.001-3.319-1.452-6.414-4.323-8.073zM77.727 81.445c-11.727 0-14.309-3.235-15.17-9.066-.102-.628-.634-1.379-1.274-1.379h-5.73c-.709 0-1.28.86-1.28 1.566 0 7.466 4.06 16.512 23.454 16.512 14.038 0 22.088-5.455 22.088-15.109 0-9.572-6.467-12.084-20.082-13.886-13.762-1.819-15.16-2.738-15.16-5.962 0-2.658 1.184-6.203 11.374-6.203 9.104 0 12.46 1.954 13.841 8.091.119.577.646.991 1.241.991h5.754c.354 0 .691-.143.939-.396.241-.272.367-.613.336-.979-.893-10.569-7.913-15.494-22.112-15.494-12.632 0-20.166 5.334-20.166 14.275 0 9.698 7.497 12.378 19.622 13.577 14.505 1.422 15.633 3.542 15.633 6.395 0 4.956-3.978 7.067-13.308 7.067z"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg id="php" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128"><path fill="#6181B6" d="M64 33.039c-33.74 0-61.094 13.862-61.094 30.961s27.354 30.961 61.094 30.961 61.094-13.862 61.094-30.961-27.354-30.961-61.094-30.961zm-15.897 36.993c-1.458 1.364-3.077 1.927-4.86 2.507-1.783.581-4.052.461-6.811.461h-6.253l-1.733 10h-7.301l6.515-34h14.04c4.224 0 7.305 1.215 9.242 3.432 1.937 2.217 2.519 5.364 1.747 9.337-.319 1.637-.856 3.159-1.614 4.515-.759 1.357-1.75 2.624-2.972 3.748zm21.311 2.968l2.881-14.42c.328-1.688.208-2.942-.361-3.555-.57-.614-1.782-1.025-3.635-1.025h-5.79l-3.731 19h-7.244l6.515-33h7.244l-1.732 9h6.453c4.061 0 6.861.815 8.402 2.231s2.003 3.356 1.387 6.528l-3.031 15.241h-7.358zm40.259-11.178c-.318 1.637-.856 3.133-1.613 4.488-.758 1.357-1.748 2.598-2.971 3.722-1.458 1.364-3.078 1.927-4.86 2.507-1.782.581-4.053.461-6.812.461h-6.253l-1.732 10h-7.301l6.514-34h14.041c4.224 0 7.305 1.215 9.241 3.432 1.935 2.217 2.518 5.418 1.746 9.39zM95.919 54h-5.001l-2.727 14h4.442c2.942 0 5.136-.29 6.576-1.4 1.442-1.108 2.413-2.828 2.918-5.421.484-2.491.264-4.434-.66-5.458-.925-1.024-2.774-1.721-5.548-1.721zM38.934 54h-5.002l-2.727 14h4.441c2.943 0 5.136-.29 6.577-1.4 1.441-1.108 2.413-2.828 2.917-5.421.484-2.491.264-4.434-.66-5.458s-2.772-1.721-5.546-1.721z"/></svg>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<svg version="1.1" id="python" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
2
|
+
viewBox="0 0 128 128" style="enable-background:new 0 0 128 128;" xml:space="preserve">
|
3
|
+
<path fill="#FFD845" d="M122.3,48.8c-2.1-8.4-6.1-14.8-14.6-14.8H97v13c0,10-8.8,18-18.5,18H49.3c-8,0-14.3,7.3-14.3,15.3v27.8
|
4
|
+
c0,7.9,6.7,12.6,14.5,14.8c9.2,2.7,18,3.2,29.1,0c7.3-2.1,14.5-6.4,14.5-14.8V97H64v-4h43.7c8.5,0,11.6-5.8,14.6-14.7
|
5
|
+
C125.3,69.2,125.2,60.5,122.3,48.8L122.3,48.8z M80.3,104.4c3,0,5.5,2.5,5.5,5.5c0,3.1-2.5,5.6-5.5,5.6c-3,0-5.5-2.5-5.5-5.6
|
6
|
+
C74.8,106.9,77.3,104.4,80.3,104.4z"/>
|
7
|
+
<path fill="#3979B0" d="M78.4,4c-5-0.8-10.2-1.2-15.2-1.2c-5,0-9.6,0.4-13.8,1.2C37.1,6.2,35,10.8,35,19.2V30h29v4H23.8
|
8
|
+
c-8.5,0-15.9,5.1-18.2,14.8c-2.7,11.1-2.8,17.9,0,29.5C7.6,87,12.6,93,21.1,93H31V80c0-9.6,8.4-18,18.3-18h29.2
|
9
|
+
C86.6,62,93,55.1,93,47V19.2C93,11.3,86.4,5.3,78.4,4z M47.5,22.9c-3,0-5.5-2.5-5.5-5.5c0-3.1,2.5-5.6,5.5-5.6c3,0,5.5,2.5,5.5,5.6
|
10
|
+
C53,20.4,50.5,22.9,47.5,22.9z"/>
|
11
|
+
</svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg id="ruby" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128"><path fill-rule="evenodd" clip-rule="evenodd" fill="#D91404" d="M35.971 111.33c27.466 3.75 54.444 7.433 81.958 11.188-9.374-15.606-18.507-30.813-27.713-46.144l-54.245 34.956zM125.681 24.947c-2.421 3.636-4.847 7.269-7.265 10.907-8.304 12.493-16.607 24.986-24.903 37.485-.462.696-1.061 1.248-.41 2.321 8.016 13.237 15.969 26.513 23.942 39.777 1.258 2.095 2.53 4.182 4.157 6.192 1.612-32.193 3.223-64.387 4.834-96.58l-.355-.102zM16.252 66.22c.375.355 1.311.562 1.747.347 7.689-3.779 15.427-7.474 22.948-11.564 2.453-1.333 4.339-3.723 6.452-5.661 6.997-6.417 13.983-12.847 20.966-19.278.427-.395.933-.777 1.188-1.275 2.508-4.902 4.973-9.829 7.525-14.898-3.043-1.144-5.928-2.263-8.849-3.281-.396-.138-1.02.136-1.449.375-6.761 3.777-13.649 7.353-20.195 11.472-3.275 2.061-5.943 5.098-8.843 7.743-4.674 4.266-9.342 8.542-13.948 12.882-1.222 1.152-2.336 2.468-3.288 3.854-3.15 4.587-6.206 9.24-9.402 14.025 1.786 1.847 3.41 3.613 5.148 5.259zM44.354 59.949c-3.825 16.159-7.627 32.227-11.556 48.823 18.423-11.871 36.421-23.468 54.3-34.987-14.228-4.605-28.41-9.196-42.744-13.836zM120.985 25.103c-15.566 2.601-30.76 5.139-46.15 7.71 5.242 12.751 10.379 25.246 15.662 38.096 10.221-15.359 20.24-30.41 30.488-45.806zM44.996 56.644c14.017 4.55 27.755 9.01 41.892 13.6-5.25-12.79-10.32-25.133-15.495-37.737-8.815 8.059-17.498 15.999-26.397 24.137zM16.831 75.643c-4.971 11.883-9.773 23.362-14.662 35.048 9.396-.278 18.504-.547 27.925-.825-4.423-11.412-8.759-22.6-13.263-34.223zM30.424 101.739l.346-.076c3.353-13.941 6.754-27.786 10.177-42.272-7.636 3.969-14.92 7.754-22.403 11.644 3.819 9.926 7.891 20.397 11.88 30.704zM115.351 22.842c-4.459-1.181-8.918-2.366-13.379-3.539-6.412-1.686-12.829-3.351-19.237-5.052-.801-.213-1.38-.352-1.851.613-2.265 4.64-4.6 9.245-6.901 13.868-.071.143-.056.328-.111.687 13.886-2.104 27.679-4.195 41.47-6.285l.009-.292zM89.482 12.288l36.343 10.054c-2.084-5.939-4.017-11.446-6.005-17.11l-30.285 6.715-.053.341zM33.505 114.007c-4.501-.519-9.122-.042-13.687.037-3.75.063-7.5.206-11.25.323-.386.012-.771.09-1.156.506 31.003 2.866 62.005 5.732 93.007 8.6l.063-.414c-9.938-1.357-19.877-2.714-29.815-4.07-12.384-1.691-24.747-3.551-37.162-4.982zM2.782 99.994c3.995-9.27 7.973-18.546 11.984-27.809.401-.929.37-1.56-.415-2.308-1.678-1.597-3.237-3.318-5.071-5.226-2.479 12.24-4.897 24.177-7.317 36.113l.271.127c.185-.297.411-.578.548-.897zM81.522 9.841c6.737-1.738 13.572-3.097 20.367-4.613.44-.099.87-.244 1.303-.368l-.067-.332c-9.571 1.287-19.141 2.575-29.194 3.928 2.741 1.197 4.853 2.091 7.591 1.385z"/></svg>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
3
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
4
|
+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
5
|
+
width="200px" height="200px" viewBox="0 0 200 200" enable-background="new 0 0 200 200" xml:space="preserve">
|
6
|
+
<circle fill="#FFFFFF" cx="99.453" cy="99.453" r="97.453"/>
|
7
|
+
<g>
|
8
|
+
<path fill="#1C8ECD" d="M100,0C44.772,0,0,44.771,0,100c0,55.229,44.772,100,100,100c55.229,0,100-44.771,100-100
|
9
|
+
C200,44.771,155.229,0,100,0z M136.423,159.785c-11.741,0-22.331-5.014-29.754-13.006H38.098c-2.631,0-4.765-2.133-4.765-4.764
|
10
|
+
v-85.15c0-2.631,2.133-4.764,4.765-4.764h123.804c2.632,0,4.766,2.133,4.766,4.764v35.207c6.45,7.194,10.381,16.689,10.381,27.088
|
11
|
+
C177.048,141.561,158.822,159.785,136.423,159.785z"/>
|
12
|
+
<path fill="#D2E3EB" d="M97.001,109.355c0.873-3.506,2.203-6.834,3.921-9.917H43.417v37.254h56.366
|
13
|
+
c-1.178-2.45-2.112-5.041-2.782-7.73H53.688v-7.675h42.166c-0.036-0.706-0.056-1.415-0.056-2.129c0-0.718,0.02-1.427,0.056-2.132
|
14
|
+
H53.688v-7.674h43.313V109.355z"/>
|
15
|
+
<rect x="43.417" y="62.185" fill="#D2E3EB" width="113.166" height="6.279"/>
|
16
|
+
<path fill="#E6547B" d="M166.667,108.152c-1.271-3.482-3.094-6.701-5.416-9.506c-1.394-1.684-2.964-3.213-4.668-4.583
|
17
|
+
c-5.524-4.447-12.53-7.125-20.16-7.125c-10.336,0-19.524,4.912-25.426,12.502c-4.241,5.457-6.795,12.289-6.795,19.72
|
18
|
+
c0,6.467,1.933,12.482,5.226,17.535c2.68,4.109,6.272,7.556,10.486,10.084c4.837,2.902,10.471,4.603,16.509,4.603
|
19
|
+
c6.039,0,11.673-1.7,16.511-4.603c6.293-3.777,11.184-9.627,13.733-16.612c1.258-3.44,1.978-7.138,1.978-11.007
|
20
|
+
C168.645,115.29,167.925,111.594,166.667,108.152z M139.688,139.867c-0.273,0.642-0.654,1.195-1.146,1.664
|
21
|
+
c-0.487,0.469-1.06,0.834-1.708,1.1c-0.652,0.264-1.354,0.396-2.107,0.396c-0.771,0-1.483-0.135-2.138-0.396
|
22
|
+
c-0.651-0.266-1.216-0.631-1.692-1.1c-0.479-0.469-0.854-1.022-1.129-1.664c-0.275-0.641-0.414-1.328-0.414-2.062
|
23
|
+
c0-0.732,0.139-1.412,0.414-2.047c0.272-0.63,0.648-1.178,1.129-1.646c0.479-0.467,1.041-0.84,1.692-1.113
|
24
|
+
c0.652-0.273,1.364-0.412,2.138-0.412c0.754,0,1.455,0.139,2.107,0.412c0.648,0.273,1.221,0.646,1.708,1.113
|
25
|
+
c0.489,0.471,0.87,1.019,1.146,1.646c0.274,0.635,0.412,1.312,0.412,2.047S139.962,139.227,139.688,139.867z M147.945,112.467
|
26
|
+
c-0.428,1.12-0.973,2.098-1.633,2.932c-0.662,0.834-1.385,1.555-2.168,2.151c-0.783,0.603-1.527,1.166-2.229,1.696
|
27
|
+
c-0.703,0.527-1.313,1.047-1.832,1.557c-0.521,0.508-0.84,1.079-0.962,1.709l-0.854,4.274h-6.475l-0.671-4.916
|
28
|
+
c-0.021-0.123-0.036-0.244-0.046-0.366c-0.012-0.121-0.018-0.244-0.018-0.367c0-0.895,0.215-1.678,0.645-2.351
|
29
|
+
c0.427-0.671,0.965-1.287,1.617-1.847c0.648-0.562,1.354-1.1,2.104-1.619c0.753-0.519,1.454-1.077,2.104-1.678
|
30
|
+
c0.652-0.603,1.191-1.272,1.619-2.018c0.429-0.741,0.643-1.622,0.643-2.641c0-1.221-0.402-2.191-1.207-2.916
|
31
|
+
c-0.805-0.723-1.906-1.086-3.312-1.086c-1.078,0-1.979,0.113-2.701,0.338c-0.725,0.226-1.344,0.475-1.862,0.748
|
32
|
+
s-0.972,0.523-1.358,0.748c-0.386,0.226-0.771,0.336-1.158,0.336c-0.877,0-1.525-0.377-1.955-1.131l-2.504-3.846
|
33
|
+
c0.752-0.632,1.572-1.222,2.457-1.772c0.888-0.549,1.838-1.032,2.854-1.45c1.019-0.417,2.112-0.743,3.282-0.977
|
34
|
+
s2.438-0.352,3.801-0.352c1.912,0,3.639,0.254,5.176,0.763c1.536,0.509,2.842,1.237,3.922,2.183
|
35
|
+
c1.078,0.946,1.907,2.086,2.488,3.419c0.579,1.332,0.87,2.812,0.87,4.441C148.587,110.005,148.373,111.348,147.945,112.467z"/>
|
36
|
+
</g>
|
37
|
+
</svg>
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class Format {
|
2
|
+
constructor() {
|
3
|
+
this.formatSelector = document.getElementsByClassName('js-format-selector')[0]
|
4
|
+
if (this.formatSelector) {
|
5
|
+
this.formatChanged(this.formatSelector.value, false)
|
6
|
+
this.formatSelector.addEventListener('change', (event) => {
|
7
|
+
this.formatChanged(event.target.value)
|
8
|
+
})
|
9
|
+
|
10
|
+
this.restoreFormat()
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
formatChanged(format, persist = true) {
|
15
|
+
for (var item of document.getElementsByClassName('js-format')) {
|
16
|
+
item.hidden = true
|
17
|
+
}
|
18
|
+
for (var item of document.querySelectorAll(`.js-format[data-format='${format}']`)) {
|
19
|
+
item.hidden = false
|
20
|
+
}
|
21
|
+
|
22
|
+
if (persist) {
|
23
|
+
this.persistFormat(format)
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
persistFormat(format) {
|
28
|
+
if (window.localStorage) {
|
29
|
+
window.localStorage.setItem('format', format)
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
restoreFormat() {
|
34
|
+
if (window.localStorage) {
|
35
|
+
const format = window.localStorage.getItem('format')
|
36
|
+
if (format) {
|
37
|
+
this.formatSelector.value = format
|
38
|
+
this.formatChanged(format, false)
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
@@ -0,0 +1,249 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2001-present, Vonage.
|
3
|
+
*
|
4
|
+
* Accordions (requires core)
|
5
|
+
*/
|
6
|
+
|
7
|
+
'use strict';
|
8
|
+
|
9
|
+
Volta.accordion = function () {
|
10
|
+
var _class = {
|
11
|
+
standard: {
|
12
|
+
container: 'Vlt-accordion',
|
13
|
+
containerGroup: 'Vlt-accordion--group',
|
14
|
+
trigger: 'Vlt-accordion__trigger',
|
15
|
+
triggerActive: 'Vlt-accordion__trigger_active',
|
16
|
+
content: 'Vlt-accordion__content',
|
17
|
+
contentOpen: 'Vlt-accordion__content_open',
|
18
|
+
contentOpening: 'Vlt-accordion__content_opening',
|
19
|
+
contentClosing: 'Vlt-accordion__content_closing',
|
20
|
+
},
|
21
|
+
js: {
|
22
|
+
content: 'Vlt-js-accordion__content',
|
23
|
+
contentOpen: 'Vlt-js-accordion__content_open',
|
24
|
+
contentOpening: 'Vlt-js-accordion__content_opening',
|
25
|
+
contentClosing: 'Vlt-js-accordion__content_closing',
|
26
|
+
trigger: 'Vlt-js-accordion__trigger',
|
27
|
+
triggerActive: 'Vlt-js-accordion__trigger_active'
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
function Accordion() {}
|
32
|
+
|
33
|
+
Accordion.prototype = {
|
34
|
+
init: function(element, suppressClickHandler, triggerElem) {
|
35
|
+
if(this.isStandard) {
|
36
|
+
this._initStandard(element, suppressClickHandler);
|
37
|
+
} else {
|
38
|
+
this._initJs(element, suppressClickHandler, triggerElem);
|
39
|
+
}
|
40
|
+
},
|
41
|
+
_initStandard: function(element, suppressClickHandler) {
|
42
|
+
var self = this;
|
43
|
+
|
44
|
+
if(!suppressClickHandler) {
|
45
|
+
element.querySelectorAll('.' + _class.standard.trigger).forEach(function(trigger) {
|
46
|
+
var parent = Volta._closest(trigger, '.' + _class.standard.container, _class.standard.container);
|
47
|
+
|
48
|
+
if(parent && parent == element) {
|
49
|
+
trigger.addEventListener('click', function(){
|
50
|
+
self.toggle(trigger);
|
51
|
+
});
|
52
|
+
}
|
53
|
+
});
|
54
|
+
}
|
55
|
+
},
|
56
|
+
_initJs: function(element, suppressClickHandler, triggerElem) {
|
57
|
+
this._content = element;
|
58
|
+
|
59
|
+
if(triggerElem) {
|
60
|
+
this.trigger = triggerElem;
|
61
|
+
} else if(this._content.dataset.trigger) {
|
62
|
+
var triggerId = this._content.dataset.trigger;
|
63
|
+
this.trigger = document.querySelector('#' + triggerId);
|
64
|
+
} else {
|
65
|
+
console.warn("Volta: js accordion trigger missing");
|
66
|
+
}
|
67
|
+
|
68
|
+
var self = this;
|
69
|
+
if(!suppressClickHandler && this.trigger) {
|
70
|
+
this.trigger.addEventListener('click', function(){
|
71
|
+
self.toggle();
|
72
|
+
});
|
73
|
+
}
|
74
|
+
},
|
75
|
+
close: function(trigger) {
|
76
|
+
var panel = this._content || trigger.nextElementSibling;
|
77
|
+
var trigger = this.trigger || trigger;
|
78
|
+
var classes = this.trigger ? _class.js : _class.standard;
|
79
|
+
|
80
|
+
trigger.classList.remove(classes.triggerActive);
|
81
|
+
panel.classList.add(classes.contentClosing);
|
82
|
+
|
83
|
+
panel.style.height = window.getComputedStyle(panel).height;
|
84
|
+
panel.offsetHeight; // force repaint
|
85
|
+
panel.style.height = '0px';
|
86
|
+
panel.classList.remove(classes.contentOpen);
|
87
|
+
|
88
|
+
var self = this;
|
89
|
+
panel.addEventListener('transitionend', function closingTransitionEndEvent(event) {
|
90
|
+
if (event.propertyName == 'height' && Volta._hasClass(panel, classes.contentClosing)) {
|
91
|
+
panel.classList.remove(classes.contentClosing);
|
92
|
+
panel.style.height = '0px';
|
93
|
+
panel.removeEventListener('transitionend', closingTransitionEndEvent, false);
|
94
|
+
|
95
|
+
if(self.isGroup && self._isTriggerActive(trigger, true)){
|
96
|
+
self._activeGroupTrigger = undefined;
|
97
|
+
}
|
98
|
+
}
|
99
|
+
}, { passive: true, once: true });
|
100
|
+
},
|
101
|
+
isOpening: false,
|
102
|
+
_activeGroupTrigger: undefined,
|
103
|
+
_isTriggerActive: function(trigger, match) {
|
104
|
+
return (this.isGroup && this._activeGroupTrigger && (!match || this._activeGroupTrigger === trigger)) || Volta._hasClass(trigger, _class.standard.triggerActive);
|
105
|
+
},
|
106
|
+
open: function(trigger) {
|
107
|
+
if(!this.trigger) {
|
108
|
+
if(this._isTriggerActive(trigger, false)) {
|
109
|
+
this.close(this._activeGroupTrigger || trigger);
|
110
|
+
}
|
111
|
+
if(this.isGroup) {
|
112
|
+
this._activeGroupTrigger = trigger;
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
var trig = this.trigger || trigger;
|
117
|
+
var classes = this.trigger ? _class.js : _class.standard;
|
118
|
+
var panel = this._content || trig.nextElementSibling;
|
119
|
+
|
120
|
+
this.isOpening = true;
|
121
|
+
|
122
|
+
trig.classList.add(classes.triggerActive);
|
123
|
+
panel.classList.add(classes.contentOpening);
|
124
|
+
|
125
|
+
var startHeight = panel.style.height;
|
126
|
+
panel.style.height = 'auto';
|
127
|
+
var endHeight = window.getComputedStyle(panel).height;
|
128
|
+
panel.style.height = startHeight;
|
129
|
+
panel.offsetHeight; // force repaint
|
130
|
+
panel.style.height = endHeight;
|
131
|
+
|
132
|
+
var self = this;
|
133
|
+
panel.addEventListener('transitionend', function openingTransitionEndEvent(event) {
|
134
|
+
if (event.propertyName == 'height' && Volta._hasClass(panel, classes.contentOpening)) {
|
135
|
+
panel.style.height = 'auto';
|
136
|
+
panel.classList.remove(classes.contentOpening);
|
137
|
+
panel.classList.add(classes.contentOpen);
|
138
|
+
panel.removeEventListener('transitionend', openingTransitionEndEvent, false);
|
139
|
+
self.isOpening = false;
|
140
|
+
}
|
141
|
+
}, { passive: true, once: true });
|
142
|
+
},
|
143
|
+
toggle: function(trigger) {
|
144
|
+
if(this.isOpening) {
|
145
|
+
return false;
|
146
|
+
}
|
147
|
+
if((this.trigger && Volta._hasClass(this._content, _class.js.contentOpen))
|
148
|
+
|| (!this.trigger && this._isTriggerActive(trigger, true))) {
|
149
|
+
this.close(trigger);
|
150
|
+
} else {
|
151
|
+
this.open(trigger);
|
152
|
+
}
|
153
|
+
}
|
154
|
+
}
|
155
|
+
|
156
|
+
return {
|
157
|
+
create: create,
|
158
|
+
init: initialise
|
159
|
+
}
|
160
|
+
|
161
|
+
/**
|
162
|
+
* @public
|
163
|
+
*
|
164
|
+
* @description Create an individual accordion object
|
165
|
+
* @param {Element|string} elementOrId Reference to the accordion content element or the id
|
166
|
+
* @param {Boolean} suppressClickHandler Whether click events should be attached on creation
|
167
|
+
* @param {Element} trigger Private required for legacy accordions
|
168
|
+
* @param {Boolean} isGroup Private required for legacy accordions
|
169
|
+
* @return {Object}
|
170
|
+
*/
|
171
|
+
function create(elementOrId, suppressClickHandler, trigger, isGroup, isStandard) {
|
172
|
+
if(!elementOrId) {
|
173
|
+
console.warn("Volta: no parameter supplied to accordion.create()");
|
174
|
+
}
|
175
|
+
var accordion = Object.create(Accordion.prototype, {});
|
176
|
+
var element = getElement(elementOrId);
|
177
|
+
|
178
|
+
Object.defineProperties(accordion, {
|
179
|
+
'isStandard': {
|
180
|
+
value: isStandard || Volta._hasClass(element, _class.standard.container),
|
181
|
+
writable: false
|
182
|
+
}
|
183
|
+
});
|
184
|
+
|
185
|
+
Object.defineProperties(accordion, {
|
186
|
+
'isGroup': {
|
187
|
+
value: isGroup,
|
188
|
+
writable: false
|
189
|
+
}
|
190
|
+
});
|
191
|
+
|
192
|
+
accordion.init(element, suppressClickHandler, trigger);
|
193
|
+
|
194
|
+
return accordion;
|
195
|
+
}
|
196
|
+
|
197
|
+
/**
|
198
|
+
* @public
|
199
|
+
*
|
200
|
+
* @description Initialise all the accordions on the current screen
|
201
|
+
*/
|
202
|
+
function initialise() {
|
203
|
+
//standard
|
204
|
+
var standardAccordions = document.querySelectorAll('.' + _class.standard.container);
|
205
|
+
|
206
|
+
if(standardAccordions.length) {
|
207
|
+
standardAccordions.forEach(function(accordion){
|
208
|
+
create(accordion, false, null, Volta._hasClass(accordion, _class.standard.containerGroup), true);
|
209
|
+
});
|
210
|
+
}
|
211
|
+
|
212
|
+
//js
|
213
|
+
var triggers = document.querySelectorAll('.' + _class.js.trigger + '[data-accordion]');
|
214
|
+
if(triggers.length > 0) {
|
215
|
+
triggers.forEach(function(trigger) {
|
216
|
+
var accordionId = trigger.dataset.accordion;
|
217
|
+
if(!accordionId) {
|
218
|
+
return;
|
219
|
+
}
|
220
|
+
create(accordionId, false, trigger);
|
221
|
+
});
|
222
|
+
}
|
223
|
+
|
224
|
+
//js - legacy
|
225
|
+
var jsAccordions = document.querySelectorAll('.' + _class.js.content + '[data-trigger]');
|
226
|
+
if(jsAccordions.length > 0) {
|
227
|
+
jsAccordions.forEach(function(jsLegacy) {
|
228
|
+
create(jsLegacy);
|
229
|
+
});
|
230
|
+
}
|
231
|
+
}
|
232
|
+
|
233
|
+
/**
|
234
|
+
* @private
|
235
|
+
*/
|
236
|
+
function getElement(elementOrId) {
|
237
|
+
var element;
|
238
|
+
|
239
|
+
if(elementOrId.classList) {
|
240
|
+
element = elementOrId;
|
241
|
+
} else if (elementOrId.substring(0, 1) === "#") {
|
242
|
+
element = document.querySelector(elementOrId);
|
243
|
+
} else {
|
244
|
+
element = document.querySelector('#' + elementOrId);
|
245
|
+
}
|
246
|
+
|
247
|
+
return element;
|
248
|
+
}
|
249
|
+
}();
|