mirror of
https://github.com/Choices-js/Choices.git
synced 2024-05-20 22:46:33 +02:00
Codebeat fixes
This commit is contained in:
parent
1b7b3045b8
commit
9ac62aec31
|
@ -1,12 +1,8 @@
|
||||||
# Choices.js ![Build Status](https://travis-ci.org/jshjohnson/Choices.svg?branch=master) [![CDNJS](https://img.shields.io/cdnjs/v/choices.js.svg)](https://cdnjs.com/libraries/choices.js) [![npm](https://img.shields.io/npm/v/choices.js.svg)](https://www.npmjs.com/package/choices.js)
|
# Choices.js ![Build Status](https://travis-ci.org/jshjohnson/Choices.svg?branch=master) [![CDNJS](https://img.shields.io/cdnjs/v/choices.js.svg)](https://cdnjs.com/libraries/choices.js) [![npm](https://img.shields.io/npm/v/choices.js.svg)](https://www.npmjs.com/package/choices.js) [![codebeat badge](https://codebeat.co/badges/07c7b2d9-d5aa-4772-9fbb-a153e62d0f81)](https://codebeat.co/projects/github-com-jshjohnson-choices-develop)
|
||||||
A vanilla, lightweight (~20kb gzipped 🎉), configurable select box/text input plugin. Similar to Select2 and Selectize but without the jQuery dependency.
|
A vanilla, lightweight (~20kb gzipped 🎉), configurable select box/text input plugin. Similar to Select2 and Selectize but without the jQuery dependency.
|
||||||
|
|
||||||
[Demo](https://joshuajohnson.co.uk/Choices/)
|
[Demo](https://joshuajohnson.co.uk/Choices/)
|
||||||
|
|
||||||
---
|
|
||||||
### 👉 Please use [develop](https://github.com/jshjohnson/Choices/tree/develop) as the base branch for pull requests 👈
|
|
||||||
---
|
|
||||||
|
|
||||||
## TL;DR
|
## TL;DR
|
||||||
* Lightweight
|
* Lightweight
|
||||||
* No jQuery dependency
|
* No jQuery dependency
|
||||||
|
|
|
@ -117,6 +117,7 @@ class Choices {
|
||||||
this._wasTap = true;
|
this._wasTap = true;
|
||||||
this._placeholderValue = this._generatePlaceholderValue();
|
this._placeholderValue = this._generatePlaceholderValue();
|
||||||
this._baseId = generateId(this.passedElement.element, 'choices-');
|
this._baseId = generateId(this.passedElement.element, 'choices-');
|
||||||
|
this._direction = this.passedElement.element.getAttribute('dir') || 'ltr';
|
||||||
this._idNames = {
|
this._idNames = {
|
||||||
itemChoice: 'item-choice',
|
itemChoice: 'item-choice',
|
||||||
};
|
};
|
||||||
|
@ -1658,54 +1659,43 @@ class Choices {
|
||||||
}
|
}
|
||||||
|
|
||||||
_createElements() {
|
_createElements() {
|
||||||
const direction = this.passedElement.element.getAttribute('dir') || 'ltr';
|
|
||||||
const containerOuter = this._getTemplate(
|
|
||||||
'containerOuter',
|
|
||||||
direction,
|
|
||||||
this._isSelectElement,
|
|
||||||
this._isSelectOneElement,
|
|
||||||
this.config.searchEnabled,
|
|
||||||
this.passedElement.element.type,
|
|
||||||
);
|
|
||||||
const containerInner = this._getTemplate('containerInner');
|
|
||||||
const itemList = this._getTemplate('itemList', this._isSelectOneElement);
|
|
||||||
const choiceList = this._getTemplate(
|
|
||||||
'choiceList',
|
|
||||||
this._isSelectOneElement,
|
|
||||||
);
|
|
||||||
const input = this._getTemplate('input');
|
|
||||||
const dropdown = this._getTemplate('dropdown');
|
|
||||||
|
|
||||||
this.containerOuter = new Container({
|
this.containerOuter = new Container({
|
||||||
element: containerOuter,
|
element: this._getTemplate(
|
||||||
|
'containerOuter',
|
||||||
|
this._direction,
|
||||||
|
this._isSelectElement,
|
||||||
|
this._isSelectOneElement,
|
||||||
|
this.config.searchEnabled,
|
||||||
|
this.passedElement.element.type,
|
||||||
|
),
|
||||||
classNames: this.config.classNames,
|
classNames: this.config.classNames,
|
||||||
type: this.passedElement.element.type,
|
type: this.passedElement.element.type,
|
||||||
position: this.config.position,
|
position: this.config.position,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.containerInner = new Container({
|
this.containerInner = new Container({
|
||||||
element: containerInner,
|
element: this._getTemplate('containerInner'),
|
||||||
classNames: this.config.classNames,
|
classNames: this.config.classNames,
|
||||||
type: this.passedElement.element.type,
|
type: this.passedElement.element.type,
|
||||||
position: this.config.position,
|
position: this.config.position,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.input = new Input({
|
this.input = new Input({
|
||||||
element: input,
|
element: this._getTemplate('input'),
|
||||||
classNames: this.config.classNames,
|
classNames: this.config.classNames,
|
||||||
type: this.passedElement.element.type,
|
type: this.passedElement.element.type,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.choiceList = new List({
|
this.choiceList = new List({
|
||||||
element: choiceList,
|
element: this._getTemplate('choiceList', this._isSelectOneElement),
|
||||||
});
|
});
|
||||||
|
|
||||||
this.itemList = new List({
|
this.itemList = new List({
|
||||||
element: itemList,
|
element: this._getTemplate('itemList', this._isSelectOneElement),
|
||||||
});
|
});
|
||||||
|
|
||||||
this.dropdown = new Dropdown({
|
this.dropdown = new Dropdown({
|
||||||
element: dropdown,
|
element: this._getTemplate('dropdown'),
|
||||||
classNames: this.config.classNames,
|
classNames: this.config.classNames,
|
||||||
type: this.passedElement.element.type,
|
type: this.passedElement.element.type,
|
||||||
});
|
});
|
||||||
|
@ -1853,10 +1843,7 @@ class Choices {
|
||||||
_addPredefinedItems() {
|
_addPredefinedItems() {
|
||||||
const handlePresetItem = item => {
|
const handlePresetItem = item => {
|
||||||
const itemType = getType(item);
|
const itemType = getType(item);
|
||||||
if (itemType === 'Object') {
|
if (itemType === 'Object' && item.value) {
|
||||||
if (!item.value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._addItem({
|
this._addItem({
|
||||||
value: item.value,
|
value: item.value,
|
||||||
label: item.label,
|
label: item.label,
|
||||||
|
|
Loading…
Reference in a new issue