Fix dropdown on demo

This commit is contained in:
Roman Hotsiy 2016-08-21 10:42:38 +03:00
parent eb0beda4e6
commit 40a3102934
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
3 changed files with 25 additions and 4 deletions

View File

@ -9,10 +9,10 @@
</head>
<body>
<nav>
<header> ReDoc </header>
<header> <a href="/"> ReDoc </a> </header>
<template is="dom-bind" id="specs">
<form id="schema-url-form" is="iron-form">
<vaadin-combo-box-light id="spec-input" items="[[specs]]" attr-for-value="value" allow-custom-value>
<vaadin-combo-box-light id="spec-input" items="[[specs]]" allow-custom-value>
<input placeholder="URL to a spec to try" id="schema-url-input" type="text" is="iron-input" value="https://rebilly.github.io/RebillyAPI/swagger.json">
</vaadin-combo-box-light>
<button type="submit"> Explore </button>

View File

@ -109,6 +109,10 @@ nav iframe {
top: 0;
}
header a {
color: inherit;
text-decoration: none;
}
@media (min-width: 1000px) {
nav header {
position: absolute;

View File

@ -48,10 +48,27 @@
'https://api.apis.guru/v2/specs/data2crm.com/1/swagger.yaml',
'https://api.apis.guru/v2/specs/graphhopper.com/1.0/swagger.yaml'
];
var $specInput = document.getElementById('spec-input');
$specInput.addEventListener('value-changed', function(e) {
schemaUrlInput.value = e.detail.value;
// $specInput.addEventListener('value-changed', function(e) {
// schemaUrlInput.value = e.detail.value;
// location.search = updateQueryStringParameter(location.search, 'url', schemaUrlInput.value);
// });
function selectItem() {
let value = this.innerText.trim();
schemaUrlInput.value = value;
location.search = updateQueryStringParameter(location.search, 'url', schemaUrlInput.value);
}
// for some reason events are not triggered so have to dirty fix this
$specInput.addEventListener('click', function(event) {
let $elems = document.querySelectorAll('.item.vaadin-combo-box-overlay');
$elems.forEach(function($el) {
$el.addEventListener('mousedown', selectItem);
$el.addEventListener('mousedown', selectItem);
});
});
});
//window.redocDebugMode = true;