mirror of
https://github.com/Choices-js/Choices.git
synced 2024-06-17 05:05:08 +02:00
277 lines
11 KiB
HTML
277 lines
11 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 multiple inputs</h2>
|
|
<div data-test-hook="basic">
|
|
<label for="choices-basic">Basic</label>
|
|
<button class="open-dropdown push-bottom">Open dropdown</button>
|
|
<button class="close-dropdown push-bottom">Close dropdown</button>
|
|
<select class="form-control" name="choices-basic" id="choices-basic" multiple>
|
|
<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" multiple>
|
|
<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" multiple>
|
|
<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" multiple>
|
|
<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="disabled-via-attr">
|
|
<label for="choices-disabled-via-attr">Disabled via attribute</label>
|
|
<select class="form-control" name="choices-disabled-via-attr" id="choices-disabled-via-attr" multiple 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="selection-limit">
|
|
<label for="choices-selection-limit">Input limit</label>
|
|
<select class="form-control" name="choices-selection-limit" id="choices-selection-limit" multiple>
|
|
<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>
|
|
</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" multiple>
|
|
<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" multiple>
|
|
<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" multiple>
|
|
<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="placeholder">
|
|
<label for="choices-placeholder">Placeholder</label>
|
|
<select class="form-control" name="choices-placeholder" id="choices-placeholder" multiple>
|
|
<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" multiple></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" multiple>
|
|
<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="custom-properties">
|
|
<label for="choices-custom-properties">Custom properties</label>
|
|
<select class="form-control" name="choices-custom-properties" id="choices-custom-properties" multiple></select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const choicesBasic = new Choices('#choices-basic');
|
|
|
|
document.querySelector('button.open-dropdown').addEventListener('click', () => {
|
|
choicesBasic.showDropdown();
|
|
});
|
|
|
|
document.querySelector('button.close-dropdown').addEventListener('click', () => {
|
|
choicesBasic.hideDropdown();
|
|
});
|
|
|
|
new Choices('#choices-remove-button', {
|
|
removeItemButton: true,
|
|
});
|
|
|
|
new Choices('#choices-disabled-choice');
|
|
|
|
new Choices('#choices-add-items-disabled', {
|
|
addItems: false,
|
|
});
|
|
|
|
new Choices('#choices-disabled-via-attr');
|
|
|
|
new Choices('#choices-selection-limit', {
|
|
maxItemCount: 5,
|
|
});
|
|
|
|
new Choices('#choices-prepend-append', {
|
|
prependValue: 'before-',
|
|
appendValue: '-after',
|
|
});
|
|
|
|
new Choices('#choices-render-choice-limit', {
|
|
renderChoiceLimit: 1,
|
|
});
|
|
|
|
new Choices('#choices-search-floor', {
|
|
searchFloor: 5,
|
|
});
|
|
|
|
new Choices('#choices-placeholder', {
|
|
placeholder: true,
|
|
placeholderValue: 'I am a placeholder',
|
|
});
|
|
|
|
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');
|
|
|
|
new Choices('#choices-custom-properties', {
|
|
searchFields: ['label', 'value', 'customProperties.country'],
|
|
choices: [
|
|
{
|
|
id: 1,
|
|
value: 'London',
|
|
label: 'London',
|
|
customProperties: {
|
|
country: 'United Kingdom',
|
|
},
|
|
},
|
|
{
|
|
id: 2,
|
|
value: 'Berlin',
|
|
label: 'Berlin',
|
|
customProperties: {
|
|
country: 'Germany',
|
|
},
|
|
},
|
|
{
|
|
id: 3,
|
|
value: 'Lisbon',
|
|
label: 'Lisbon',
|
|
customProperties: {
|
|
country: 'Portugal',
|
|
},
|
|
}
|
|
]
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|