This commit is contained in:
Evgeny Zinoviev 2021-01-04 00:29:54 +03:00
parent dcc3506910
commit f01e27a00b
5 changed files with 6 additions and 33 deletions

View File

@ -141,7 +141,7 @@ class Maps {
let html = `<b>${pharmacyName}</b><br>`; let html = `<b>${pharmacyName}</b><br>`;
html += `${pharmacyAddress}<br>`; html += `${pharmacyAddress}<br>`;
html += `тел: ${pharmacyPhone}<br><br>`; html += `тел: ${pharmacyPhone}<br><br>`;
html += lines.join('\n'); html += lines.join('<br>');
mark.properties.set('balloonContent', html); mark.properties.set('balloonContent', html);
}); });
this.map.geoObjects.add(mark); this.map.geoObjects.add(mark);

View File

@ -25,10 +25,8 @@ class Autocomplete {
field.addEventListener('click', (e) => { field.addEventListener('click', (e) => {
if (this.createItems() === 0) { if (this.createItems() === 0) {
// prevent show empty
e.stopPropagation(); e.stopPropagation();
this.dropdown.hide(); this.dropdown.hide();
// field.dropdown('hide');
} }
}); });
@ -51,13 +49,10 @@ class Autocomplete {
} }
renderIfNeeded() { renderIfNeeded() {
if (this.createItems() > 0) { if (this.createItems() > 0)
this.dropdown.show(); this.dropdown.show();
// field.dropdown('show'); else
} else {
// sets up positioning
this.field.click(); this.field.click();
}
} }
createItem(lookup, item) { createItem(lookup, item) {
@ -69,9 +64,8 @@ class Autocomplete {
label = item.label.substring(0, idx) label = item.label.substring(0, idx)
+ `<span class="${className}">${item.label.substring(idx, idx + lookup.length)}</span>` + `<span class="${className}">${item.label.substring(idx, idx + lookup.length)}</span>`
+ item.label.substring(idx + lookup.length, item.label.length); + item.label.substring(idx + lookup.length, item.label.length);
} else { } else
label = item.label; label = item.label;
}
return ce(`<button type="button" class="dropdown-item" data-value="${item.value}">${label}</button>`); return ce(`<button type="button" class="dropdown-item" data-value="${item.value}">${label}</button>`);
} }
@ -79,7 +73,6 @@ class Autocomplete {
const lookup = this.field.value; const lookup = this.field.value;
if (lookup.length < this.options.treshold) { if (lookup.length < this.options.treshold) {
this.dropdown.hide(); this.dropdown.hide();
// field.dropdown('hide');
return 0; return 0;
} }
@ -101,12 +94,11 @@ class Autocomplete {
item.addEventListener('click', (e) => { item.addEventListener('click', (e) => {
let dataValue = e.target.getAttribute('data-value'); let dataValue = e.target.getAttribute('data-value');
this.field.value = e.target.innerText; this.field.value = e.target.innerText;
if (this.options.onSelectItem) { if (this.options.onSelectItem)
this.options.onSelectItem({ this.options.onSelectItem({
value: e.target.value, value: e.target.value,
label: e.target.innerText, label: e.target.innerText,
}); });
}
this.dropdown.hide(); this.dropdown.hide();
}) })
}); });

View File

@ -1,17 +0,0 @@
/*.acme-container {*/
/* margin-top: 1.5rem;*/
/*}*/
#test {
position: absolute;
color: #fff;
background-color: red;
opacity: 0.25;
top: 0;
right: 0;
padding: 5px 8px;
cursor: pointer;
}
#test:hover {
opacity: 1;
}

View File

@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/3.0.4/socket.io.js" integrity="sha512-aMGMvNYu8Ue4G+fHa359jcPb1u+ytAF+P2SCb+PxrjCdO3n3ZTxJ30zuH39rimUggmTwmh2u7wvQsDTHESnmfQ==" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/3.0.4/socket.io.js" integrity="sha512-aMGMvNYu8Ue4G+fHa359jcPb1u+ytAF+P2SCb+PxrjCdO3n3ZTxJ30zuH39rimUggmTwmh2u7wvQsDTHESnmfQ==" crossorigin="anonymous"></script>
@ -34,6 +33,5 @@
</div> </div>
</div> </div>
</div> </div>
<div id="test">test</div>
</body> </body>
</html> </html>

View File

@ -4,4 +4,4 @@ from app import create_app, socketio
app = create_app() app = create_app()
if __name__ == '__main__': if __name__ == '__main__':
socketio.run(app) socketio.run(app, host='0.0.0.0')