mirror of
https://github.com/Choices-js/Choices.git
synced 2024-06-20 14:45:00 +02:00
241 lines
11 KiB
HTML
241 lines
11 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<title>Choices</title>
|
|
<link rel="stylesheet" href="assets/styles/css/base.min.css">
|
|
<link rel="stylesheet" href="assets/styles/css/choices.min.css">
|
|
<script src="assets/scripts/dist/choices.min.js"></script>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div class="section">
|
|
<!-- <h1>Choices</h1>
|
|
<p>A lightweight, configurable select box/text input plugin. Similar to Select2 and Selectize but without the jQuery dependency.</p>
|
|
<h2>Text inputs</h2>
|
|
<label for="choices-1">Limited to 5</label>
|
|
<input id="choices-1" type="text" value="preset-1,preset-2" placeholder="Enter something">
|
|
|
|
<label for="choices-2">Unique values only, no pasting</label>
|
|
<input id="choices-2" type="text" value="preset-1, preset-2" placeholder="This is a placeholder" class="custom class">
|
|
|
|
<label for="choices-3">Email addresses only</label>
|
|
<input id="choices-3" type="text" placeholder="This is a placeholder">
|
|
|
|
<label for="choices-4">Disabled</label>
|
|
<input id="choices-4" type="text" value="josh@joshuajohnson.co.uk, joe@bloggs.co.uk" placeholder="This is a placeholder">
|
|
|
|
<label for="choices-5">Prepends and appends a value to each items return value</label>
|
|
<input id="choices-5" type="text" value="preset-1, preset-2" placeholder="This is a placeholder">
|
|
|
|
<label for="choices-6">Preset values passed through options</label>
|
|
<input id="choices-6" type="text" value="olivia@benson.com" placeholder="This is a placeholder">
|
|
|
|
<hr>
|
|
|
|
<h2>Multiple select input</h2>
|
|
<label for="choices-7">Default</label>
|
|
<select name="choices-7" id="choices-7" placeholder="This is a placeholder" multiple>
|
|
<option value="Dropdown item 1">Dropdown item 1</option>
|
|
<option value="Dropdown item 2">Dropdown item 2</option>
|
|
<option value="Dropdown item 3" selected>Dropdown item 3</option>
|
|
<option value="Dropdown item 4" disabled>Dropdown item 4</option>
|
|
</select>
|
|
|
|
<label for="choices-8">With pre-selected option</label>
|
|
<select data-choice name="choices-8" id="choices-8" placeholder="Choose an option" multiple>
|
|
<option value="Dropdown item 1">Dropdown item 1</option>
|
|
<option value="Dropdown item 2" selected>Dropdown item 2</option>
|
|
<option value="Dropdown item 3">Dropdown item 3</option>
|
|
</select>
|
|
|
|
<label for="choices-9">Option groups</label>
|
|
<select data-choice name="choices-9" id="choices-9" placeholder="This is a placeholder" 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>
|
|
<optgroup label="DE" disabled>
|
|
<option value="Hamburg">Hamburg</option>
|
|
<option value="Munich">Munich</option>
|
|
<option value="Berlin">Berlin</option>
|
|
</optgroup>
|
|
<optgroup label="US">
|
|
<option value="New York">New York</option>
|
|
<option value="Washington" disabled>Washington</option>
|
|
<option value="Michigan">Michigan</option>
|
|
</optgroup>
|
|
<optgroup label="SP">
|
|
<option value="Madrid">Madrid</option>
|
|
<option value="Barcelona">Barcelona</option>
|
|
<option value="Malaga">Malaga</option>
|
|
</optgroup>
|
|
<optgroup label="CA">
|
|
<option value="Montreal">Montreal</option>
|
|
<option value="Toronto">Toronto</option>
|
|
<option value="Vancouver">Vancouver</option>
|
|
</optgroup>
|
|
</select>
|
|
|
|
<label for="choices-10">Options from remote source</label>
|
|
<select name="choices-10" id="choices-10" placeholder="Pick an Arctic Monkeys record" multiple></select>
|
|
|
|
<hr>
|
|
|
|
<h2>Single select input</h2>
|
|
<label for="choices-11">Default</label>
|
|
<select data-choice name="choices-11" id="choices-11" placeholder="This is a placeholder">
|
|
<option value="Dropdown item 1">Dropdown item 1</option>
|
|
<option value="Dropdown item 2">Dropdown item 2</option>
|
|
<option value="Dropdown item 3">Dropdown item 3</option>
|
|
</select>
|
|
|
|
<label for="choices-12">Options from remote source</label>
|
|
<select name="choices-12" id="choices-12" placeholder="Pick an Arctic Monkeys record"></select>
|
|
|
|
<label for="choices-13">Option groups</label>
|
|
<select data-choice name="choices-13" id="choices-13" placeholder="This is a placeholder">
|
|
<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>
|
|
<optgroup label="DE" disabled>
|
|
<option value="Hamburg">Hamburg</option>
|
|
<option value="Munich">Munich</option>
|
|
<option value="Berlin">Berlin</option>
|
|
</optgroup>
|
|
<optgroup label="US">
|
|
<option value="New York">New York</option>
|
|
<option value="Washington" disabled>Washington</option>
|
|
<option value="Michigan">Michigan</option>
|
|
</optgroup>
|
|
<optgroup label="SP">
|
|
<option value="Madrid">Madrid</option>
|
|
<option value="Barcelona">Barcelona</option>
|
|
<option value="Malaga">Malaga</option>
|
|
</optgroup>
|
|
<optgroup label="CA">
|
|
<option value="Montreal">Montreal</option>
|
|
<option value="Toronto">Toronto</option>
|
|
<option value="Vancouver">Vancouver</option>
|
|
</optgroup>
|
|
</select>
|
|
|
|
<label for="choices-14">Countries remote source</label>
|
|
<select name="choices-14" id="choices-14" placeholder="Pick a country"></select> -->
|
|
|
|
<select name="choices-bug" id="choices-bug" placeholder="This is a placeholder">
|
|
<option value="0">Zero</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
// const choices1 = new Choices(document.getElementById('choices-1'), {
|
|
// delimiter: ',',
|
|
// editItems: true,
|
|
// maxItemCount: 5,
|
|
// removeItemButton: true
|
|
// });
|
|
|
|
// const choices2 = new Choices('#choices-2', {
|
|
// paste: false,
|
|
// duplicateItems: false,
|
|
// editItems: true,
|
|
// });
|
|
|
|
// const choices3 = new Choices('#choices-3', {
|
|
// duplicates: false,
|
|
// editItems: true,
|
|
// regexFilter: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
|
|
// });
|
|
|
|
// const choices4 = new Choices('#choices-4', {
|
|
// addItems: false,
|
|
// removeItems: false,
|
|
// }).disable();
|
|
|
|
// const choices5 = new Choices('#choices-5', {
|
|
// prependValue: 'item-',
|
|
// appendValue: `-${Date.now()}`,
|
|
// }).removeActiveItems();
|
|
|
|
// const choices6 = new Choices('#choices-6', {
|
|
// items: ['josh@joshuajohnson.co.uk', { value: 'joe@bloggs.co.uk', label: 'Joe Bloggs' } ],
|
|
// });
|
|
|
|
// const choices7 = new Choices('#choices-7', { search: false }).setValue(['Set value 1', 'Set value 2']);
|
|
|
|
// const choices10 = new Choices('#choices-10', {
|
|
// placeholder: true,
|
|
// placeholderValue: 'Pick an Strokes record',
|
|
// callbackOnRender: (state) => console.log(state)
|
|
// }).ajax((callback) => {
|
|
// fetch('https://api.discogs.com/artists/55980/releases?token=QBRmstCkwXEvCjTclCpumbtNwvVkEzGAdELXyRyW')
|
|
// .then((response) => {
|
|
// response.json().then(function(data) {
|
|
// callback(data.releases, 'title', 'title');
|
|
// });
|
|
// })
|
|
// .catch((error) => {
|
|
// console.log(error);
|
|
// });
|
|
// });
|
|
|
|
// const choices12 = new Choices('#choices-12', {
|
|
// placeholder: true,
|
|
// placeholderValue: 'Pick an Arctic Monkeys record'
|
|
// }).ajax((callback) => {
|
|
// fetch('https://api.discogs.com/artists/391170/releases?token=QBRmstCkwXEvCjTclCpumbtNwvVkEzGAdELXyRyW')
|
|
// .then((response) => {
|
|
// response.json().then((data) => {
|
|
// callback(data.releases, 'title', 'title');
|
|
// });
|
|
// })
|
|
// .catch((error) => {
|
|
// console.log(error);
|
|
// });
|
|
// });
|
|
|
|
// const choices14 = new Choices('#choices-14').ajax((callback) => {
|
|
// fetch('https://restcountries.eu/rest/v1/all')
|
|
// .then((response) => {
|
|
// response.json().then((data) => {
|
|
// callback(data, 'alpha2Code', 'name');
|
|
// });
|
|
// })
|
|
// .catch((error) => {
|
|
// console.log(error);
|
|
// });
|
|
// });
|
|
|
|
// const choicesMultiple = new Choices('[data-choice]', {
|
|
// placeholderValue: 'This is a placeholder set in the config',
|
|
// removeButton: true
|
|
// });
|
|
|
|
const choicesBug = new Choices('#choices-bug', {
|
|
options: [
|
|
{value: 'One', label: 'Label One', selected: true, disabled: false},
|
|
{value: 'Two', label: 'Label Two'},
|
|
{value: 'Three', label: 'Label Three'},
|
|
],
|
|
});
|
|
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |