mirror of
https://github.com/Choices-js/Choices.git
synced 2024-06-19 22:25:09 +02:00
233 lines
9.2 KiB
HTML
233 lines
9.2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
|
|
<title>Choices</title>
|
|
<meta name=description itemprop=description content="A lightweight, configurable select box/text input plugin. Similar to Select2 and Selectize but without the jQuery dependency.">
|
|
<link rel="apple-touch-icon" sizes="180x180" href="../assets/images/apple-touch-icon.png">
|
|
<link rel="icon" type="image/png" href="../assets/images/favicon-32x32.png" sizes="32x32">
|
|
<link rel="icon" type="image/png" href="../assets/images/favicon-16x16.png" sizes="16x16">
|
|
<link rel="manifest" href="../assets/images/manifest.json">
|
|
<link rel="mask-icon" href="../assets/images/safari-pinned-tab.svg" color="#00bcd4">
|
|
<link rel="shortcut icon" href="../assets/images/favicon.ico">
|
|
<meta name="msapplication-config" content="../assets/images/browserconfig.xml">
|
|
<meta name="theme-color" content="#ffffff">
|
|
|
|
<!-- Ignore these -->
|
|
<link rel="stylesheet" href="../assets/styles/base.min.css?version=3.0.2">
|
|
<!-- End ignore these -->
|
|
|
|
<!-- Choices includes -->
|
|
<link rel="stylesheet" href="../assets/styles/choices.min.css?version=3.0.2">
|
|
<script src="../assets/scripts/choices.min.js?version=2.8.8"></script>
|
|
<!-- End Choices includes -->
|
|
</head>
|
|
|
|
<body>
|
|
<div class="container">
|
|
<div class="section">
|
|
<h2>Select one inputs</h2>
|
|
<div data-test-hook="basic">
|
|
<label for="choices-basic">Basic</label>
|
|
<select class="form-control" name="choices-basic" id="choices-basic">
|
|
<option value="Choice 1">Choice 1</option>
|
|
<option value="Choice 2">Choice 2</option>
|
|
<option value="Find me">Choice 3</option>
|
|
<option value="Choice 4">Choice 4</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div data-test-hook="remove-button">
|
|
<label for="choices-remove-button">Remove button</label>
|
|
<select class="form-control" name="choices-remove-button" id="choices-remove-button">
|
|
<option value="Choice 1">Choice 1</option>
|
|
<option value="Choice 2">Choice 2</option>
|
|
<option value="Choice 3">Choice 3</option>
|
|
<option value="Choice 4">Choice 4</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div data-test-hook="disabled-choice">
|
|
<label for="choices-disabled-choice">Disabled choice</label>
|
|
<select class="form-control" name="choices-disabled-choice" id="choices-disabled-choice">
|
|
<option value="Choice 1">Choice 1</option>
|
|
<option value="Choice 2">Choice 2</option>
|
|
<option value="Choice 3">Choice 3</option>
|
|
<option value="Choice 4" disabled>Choice 4</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div data-test-hook="add-items-disabled">
|
|
<label for="choices-add-items-disabled">Add items disabled</label>
|
|
<select class="form-control" name="choices-add-items-disabled" id="choices-add-items-disabled">
|
|
<option value="Choice 1" selected>Choice 1</option>
|
|
<option value="Choice 2">Choice 2</option>
|
|
<option value="Choice 3">Choice 3</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div data-test-hook="prepend-append">
|
|
<label for="choices-prepend-append">Prepend/append</label>
|
|
<select class="form-control" name="choices-prepend-append" id="choices-prepend-append">
|
|
<option value="Choice 1">Choice 1</option>
|
|
<option value="Choice 2">Choice 2</option>
|
|
<option value="Choice 3">Choice 3</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div data-test-hook="render-choice-limit">
|
|
<label for="choices-render-choice-limit">Render choice limit</label>
|
|
<select class="form-control" name="choices-render-choice-limit" id="choices-render-choice-limit">
|
|
<option value="Choice 1">Choice 1</option>
|
|
<option value="Choice 2">Choice 2</option>
|
|
<option value="Choice 3">Choice 3</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div data-test-hook="search-disabled">
|
|
<label for="choices-search-disabled">Search disabled</label>
|
|
<select class="form-control" name="choices-search-disabled" id="choices-search-disabled">
|
|
<option value="Choice 1">Choice 1</option>
|
|
<option value="Choice 2">Choice 2</option>
|
|
<option value="Choice 3">Choice 3</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div data-test-hook="search-floor">
|
|
<label for="choices-search-floor">Search floor</label>
|
|
<select class="form-control" name="choices-search-floor" id="choices-search-floor">
|
|
<option value="Choice 1">Choice 1</option>
|
|
<option value="Choice 2">Choice 2</option>
|
|
<option value="Choice 3">Choice 3</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div data-test-hook="remote-data">
|
|
<label for="choices-remote-data">Remote data</label>
|
|
<select class="form-control" name="choices-remote-data" id="choices-remote-data"></select>
|
|
</div>
|
|
|
|
<div data-test-hook="scrolling-dropdown">
|
|
<label for="choices-scrolling-dropdown">Scrolling dropdown</label>
|
|
<select class="form-control" name="choices-scrolling-dropdown" id="choices-scrolling-dropdown">
|
|
<option value="Choice 1">Choice 1</option>
|
|
<option value="Choice 2">Choice 2</option>
|
|
<option value="Choice 3">Choice 3</option>
|
|
<option value="Choice 4">Choice 4</option>
|
|
<option value="Choice 5">Choice 5</option>
|
|
<option value="Choice 6">Choice 6</option>
|
|
<option value="Choice 7">Choice 7</option>
|
|
<option value="Choice 8">Choice 8</option>
|
|
<option value="Choice 9">Choice 9</option>
|
|
<option value="Choice 10">Choice 10</option>
|
|
<option value="Choice 11">Choice 11</option>
|
|
<option value="Choice 12">Choice 12</option>
|
|
<option value="Choice 13">Choice 13</option>
|
|
<option value="Choice 14">Choice 14</option>
|
|
<option value="Choice 15">Choice 15</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div data-test-hook="groups">
|
|
<label for="choices-groups">Choice groups</label>
|
|
<select class="form-control" name="choices-groups" id="choices-groups" multiple>
|
|
<optgroup label="UK">
|
|
<option value="London">London</option>
|
|
<option value="Manchester">Manchester</option>
|
|
<option value="Liverpool">Liverpool</option>
|
|
</optgroup>
|
|
<optgroup label="FR">
|
|
<option value="Paris">Paris</option>
|
|
<option value="Lyon">Lyon</option>
|
|
<option value="Marseille">Marseille</option>
|
|
</optgroup>
|
|
</select>
|
|
</div>
|
|
|
|
<div data-test-hook="parent-child">
|
|
<label for="choices-parent">Parent</label>
|
|
<select class="form-control" name="choices-parent" id="choices-parent">
|
|
<option value="Parent choice 1">Parent choice 1</option>
|
|
<option value="Parent choice 2">Parent choice 2</option>
|
|
<option value="Parent choice 3">Parent choice 3</option>
|
|
</select>
|
|
|
|
<label for="choices-child">Child</label>
|
|
<select class="form-control" name="choices-child" id="choices-child">
|
|
<option value="Child choice 1">Child choice 1</option>
|
|
<option value="Child choice 2">Child choice 2</option>
|
|
<option value="Child choice 3">Child choice 3</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
new Choices('#choices-basic');
|
|
|
|
new Choices('#choices-remove-button', {
|
|
removeItemButton: true,
|
|
});
|
|
|
|
new Choices('#choices-disabled-choice', {
|
|
removeItemButton: true,
|
|
});
|
|
|
|
new Choices('#choices-add-items-disabled', {
|
|
addItems: false,
|
|
});
|
|
|
|
new Choices('#choices-prepend-append', {
|
|
prependValue: 'before-',
|
|
appendValue: '-after',
|
|
});
|
|
|
|
new Choices('#choices-render-choice-limit', {
|
|
renderChoiceLimit: 1
|
|
});
|
|
|
|
new Choices('#choices-search-disabled', {
|
|
searchEnabled: false
|
|
})
|
|
|
|
new Choices('#choices-search-floor', {
|
|
searchFloor: 5,
|
|
});
|
|
|
|
new Choices('#choices-remote-data', {
|
|
shouldSort: false,
|
|
}).ajax((callback) => {
|
|
fetch('/data')
|
|
.then((response) => {
|
|
response.json().then((data) => {
|
|
callback(data, 'value', 'label');
|
|
});
|
|
})
|
|
.catch((error) => {
|
|
console.error(error);
|
|
});
|
|
});
|
|
|
|
new Choices('#choices-scrolling-dropdown', {
|
|
shouldSort: false,
|
|
});
|
|
|
|
new Choices('#choices-groups');
|
|
|
|
const parent = new Choices('#choices-parent');
|
|
const child = new Choices('#choices-child').disable();
|
|
|
|
parent.passedElement.element.addEventListener('change', (event) => {
|
|
if (event.detail.value === 'Parent choice 2') {
|
|
child.enable();
|
|
} else {
|
|
child.disable();
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|