Merge remote-tracking branch 'refs/remotes/jshjohnson/master'

Conflicts:
	assets/scripts/src/choices.js
This commit is contained in:
Simon Babay 2016-08-01 21:27:41 +02:00
commit 8edb33f511
4 changed files with 78 additions and 72 deletions

View file

@ -23,6 +23,9 @@ A lightweight, configurable select box/text input plugin. Similar to Select2 and
const choices = new Choices('[data-choice']);
const choices = new Choices('.js-choice');
// Pass jQuery element
const choices = new Choices($('.js-choice')[0]);
// Passing options (with default options)
const choices = new Choices(elements, {
items: [],

File diff suppressed because one or more lines are too long

View file

@ -862,8 +862,6 @@ export class Choices {
* @private
*/
_onMouseDown(e) {
// If not a right click
// if(e.button !== 2) {
const activeItems = this.store.getItemsFilteredByActive();
const target = e.target || e.touches[0].target;
@ -894,6 +892,14 @@ export class Choices {
this.hideDropdown();
}
// If input is not in focus, it ought to be
if(this.input !== document.activeElement) {
this.input.focus();
}
} else if(this.passedElement.type === 'select-one' && this.dropdown.classList.contains(this.config.classNames.activeState) && e.target === this.containerInner) {
this.hideDropdown();
}
if(target.hasAttribute('data-button')) {
// If we are clicking on a button
if(this.config.removeItems && this.config.removeItemButton) {
@ -956,7 +962,6 @@ export class Choices {
this.toggleDropdown();
}
}
// }
}
/**
@ -1627,7 +1632,6 @@ export class Choices {
_addEventListeners() {
document.addEventListener('keyup', this._onKeyUp);
document.addEventListener('keydown', this._onKeyDown);
document.addEventListener('touchstart', this._onMouseDown);
document.addEventListener('mousedown', this._onMouseDown);
document.addEventListener('mouseover', this._onMouseOver);
@ -1653,7 +1657,6 @@ export class Choices {
_removeEventListeners() {
document.removeEventListener('keyup', this._onKeyUp);
document.removeEventListener('keydown', this._onKeyDown);
document.removeEventListener('touchstart', this._onMouseDown);
document.removeEventListener('mousedown', this._onMouseDown);
document.removeEventListener('mouseover', this._onMouseOver);

View file

@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<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.">