Skip to content

Commit 9aa165c

Browse files
author
William Troup
authored
Merge pull request #8 from williamtroup/0.3.0
0.3.0
2 parents 1e9c02d + 73e1864 commit 9aa165c

17 files changed

+219
-42
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
Select.js
33

44
[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Select.js%2C%20a%20free%20JavaScript%select%builder&url=https://github.com/williamtroup/Select.js&hashtags=javascript,html,select)
5-
[![npm](https://img.shields.io/badge/npmjs-v0.2.3-blue)](https://www.npmjs.com/package/jselect.js)
6-
[![nuget](https://img.shields.io/badge/nuget-v0.2.3-purple)](https://www.nuget.org/packages/jSelect.js/)
5+
[![npm](https://img.shields.io/badge/npmjs-v0.3.0-blue)](https://www.npmjs.com/package/jselect.js)
6+
[![nuget](https://img.shields.io/badge/nuget-v0.3.0-purple)](https://www.nuget.org/packages/jSelect.js/)
77
[![license](https://img.shields.io/badge/license-MIT-green)](https://github.com/williamtroup/Select.js/blob/main/LICENSE.txt)
88
[![discussions Welcome](https://img.shields.io/badge/discussions-Welcome-red)](https://github.com/williamtroup/Select.js/discussions)
99
[![coded by William Troup](https://img.shields.io/badge/coded_by-William_Troup-yellow)](https://github.com/williamtroup)
1010
</h1>
1111

1212
> <p align="center">A lightweight, and easy-to-use, JavaScript library for creating multi-select drop-down lists!</p>
13-
> <p align="center">v0.2.3</p>
13+
> <p align="center">v0.3.0</p>
1414
<br />
1515
1616
![Select.js](docs/images/main.png)
@@ -25,6 +25,7 @@ Select.js
2525
- Fully styled in CSS/SASS (including the buttons) and compatible with the Bootstrap library.
2626
- Full CSS theme support (using :root variables, with a default dark-mode theme).
2727
- Custom triggers for actions (when elements are rendered, selection is changed, etc).
28+
- Shortcut keys (click [here](docs/SHORTCUT_KEYS.md) to see the full list).
2829
<br />
2930
<br />
3031

@@ -79,9 +80,9 @@ Make sure you include the "DOCTYPE html" tag at the top of your HTML, as follows
7980
</select>
8081
```
8182

82-
To see a list of all the available binding options you can use for "data-select-options", click [here](docs/BINDING_OPTIONS.md).
83+
To see a list of all the available binding options you can use for "data-select-options", click [here](docs/binding/OPTIONS.md).
8384

84-
To see a list of all the available custom triggers you can use for "data-select-options", click [here](docs/BINDING_OPTIONS_CUSTOM_TRIGGERS.md).
85+
To see a list of all the available custom triggers you can use for "data-select-options", click [here](docs/binding/CUSTOM_TRIGGERS.md).
8586

8687
<br>
8788

@@ -116,4 +117,4 @@ Configuration options allow you to customize how Select.js will function. You c
116117
</script>
117118
```
118119

119-
To see a list of all the available configuration options you can use, click [here](docs/CONFIGURATION_OPTIONS.md).
120+
To see a list of all the available configuration options you can use, click [here](docs/configuration/OPTIONS.md).

README_NUGET.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Select.js v0.2.3
1+
# Select.js v0.3.0
22

33
[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Select.js%2C%20a%20free%20JavaScript%select%builder&url=https://github.com/williamtroup/Select.js&hashtags=javascript,html,select)
4-
[![npm](https://img.shields.io/badge/npmjs-v0.2.3-blue)](https://www.npmjs.com/package/jselect.js)
5-
[![nuget](https://img.shields.io/badge/nuget-v0.2.3-purple)](https://www.nuget.org/packages/jSelect.js/)
4+
[![npm](https://img.shields.io/badge/npmjs-v0.3.0-blue)](https://www.npmjs.com/package/jselect.js)
5+
[![nuget](https://img.shields.io/badge/nuget-v0.3.0-purple)](https://www.nuget.org/packages/jSelect.js/)
66
[![license](https://img.shields.io/badge/license-MIT-green)](https://github.com/williamtroup/Select.js/blob/main/LICENSE.txt)
77
[![discussions Welcome](https://img.shields.io/badge/discussions-Welcome-red)](https://github.com/williamtroup/Select.js/discussions)
88
[![coded by William Troup](https://img.shields.io/badge/coded_by-William_Troup-yellow)](https://github.com/williamtroup)
@@ -18,6 +18,7 @@
1818
- Fully styled in CSS/SASS (including the buttons) and compatible with the Bootstrap library.
1919
- Full CSS theme support (using :root variables, with a default dark-mode theme).
2020
- Custom triggers for actions (when elements are rendered, selection is changed, etc).
21+
- Shortcut keys (click [here](https://github.com/williamtroup/docs/SHORTCUT_KEYS.md) to see the full list).
2122

2223

2324
## What browsers are supported?
@@ -65,9 +66,9 @@ Make sure you include the "DOCTYPE html" tag at the top of your HTML, as follows
6566
</select>
6667
```
6768

68-
To see a list of all the available binding options you can use for "data-select-options", click [here](https://github.com/williamtroup/Select.js/blob/main/docs/BINDING_OPTIONS.md).
69+
To see a list of all the available binding options you can use for "data-select-options", click [here](https://github.com/williamtroup/Select.js/blob/main/docs/binding/OPTIONS.md).
6970

70-
To see a list of all the available custom triggers you can use for "data-select-options", click [here](https://github.com/williamtroup/Select.js/blob/main/docs/BINDING_OPTIONS_CUSTOM_TRIGGERS.md).
71+
To see a list of all the available custom triggers you can use for "data-select-options", click [here](https://github.com/williamtroup/Select.js/blob/main/docs/binding/CUSTOM_TRIGGERS.md).
7172

7273

7374
### 4. Finishing Up:
@@ -97,4 +98,4 @@ Configuration options allow you to customize how Select.js will function. You c
9798
</script>
9899
```
99100

100-
To see a list of all the available configuration options you can use, click [here](https://github.com/williamtroup/Select.js/blob/main/docs/CONFIGURATION_OPTIONS.md).
101+
To see a list of all the available configuration options you can use, click [here](https://github.com/williamtroup/Select.js/blob/main/docs/configuration/OPTIONS.md).

dist/select.js

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! Select.js v0.2.3 | (c) Bunoon | MIT License */
1+
/*! Select.js v0.3.0 | (c) Bunoon | MIT License */
22
(function() {
33
function render() {
44
var tagTypes = _configuration.domElementTypes;
@@ -87,7 +87,9 @@
8787
showDropDownMenu(control, dropDown, element, bindingOptions);
8888
};
8989
}
90-
return {control:control, dropDown:dropDown, select:element, bindingOptions:bindingOptions, multiSelectEnabled:element.hasAttribute("multiple")};
90+
var controlElements = {control:control, dropDown:dropDown, select:element, bindingOptions:bindingOptions, multiSelectEnabled:element.hasAttribute("multiple")};
91+
_control_Elements.push(controlElements);
92+
return controlElements;
9193
}
9294
function renderControlButton(controlElements) {
9395
if (controlElements.bindingOptions.showDropDownButton) {
@@ -195,6 +197,7 @@
195197
controlElements.dropDown.style.display = "block";
196198
renderDropDownItems(controlElements);
197199
renderSelectedItems(controlElements, false);
200+
fireCustomTrigger(controlElements.bindingOptions.onDropDownShow);
198201
}, controlElements.bindingOptions.dropDownShowDelay);
199202
} else {
200203
hideDropDownMenu(controlElements);
@@ -204,6 +207,7 @@
204207
if (controlElements.dropDown !== null && controlElements.dropDown.style.display !== "none") {
205208
controlElements.dropDown.style.display = "none";
206209
renderSelectedItems(controlElements, false);
210+
fireCustomTrigger(controlElements.bindingOptions.onDropDownHide);
207211
}
208212
}
209213
function isDropDownMenuVisible(controlElements) {
@@ -238,8 +242,28 @@
238242
function buildAttributeOptionCustomTriggers(options) {
239243
options.onRenderComplete = getDefaultFunction(options.onRenderComplete, null);
240244
options.onSelectedItemsChanged = getDefaultFunction(options.onSelectedItemsChanged, null);
245+
options.onDropDownShow = getDefaultFunction(options.onDropDownShow, null);
246+
options.onDropDownHide = getDefaultFunction(options.onDropDownHide, null);
241247
return options;
242248
}
249+
function buildGlobalDocumentEvents(addEvents) {
250+
addEvents = isDefined(addEvents) ? addEvents : true;
251+
var documentFunc = addEvents ? _parameter_Document.addEventListener : _parameter_Document.removeEventListener;
252+
documentFunc("keydown", onWindowKeyDown);
253+
}
254+
function onWindowKeyDown(e) {
255+
if (e.keyCode === _enum_KeyCodes.escape) {
256+
e.preventDefault();
257+
hideDropDownMenus();
258+
}
259+
}
260+
function hideDropDownMenus() {
261+
var controlElementsLength = _control_Elements.length;
262+
var controlElementIndex = 0;
263+
for (; controlElementIndex < controlElementsLength; controlElementIndex++) {
264+
hideDropDownMenu(_control_Elements[controlElementIndex]);
265+
}
266+
}
243267
function isDefined(value) {
244268
return value !== null && value !== undefined && value !== _string.empty;
245269
}
@@ -341,23 +365,26 @@
341365
var _parameter_Document = null;
342366
var _parameter_Window = null;
343367
var _configuration = {};
368+
var _enum_KeyCodes = {escape:27};
344369
var _string = {empty:"", space:" "};
345370
var _elements_Type = {};
371+
var _control_Elements = [];
346372
var _attribute_Name_Options = "data-select-options";
347373
this.setConfiguration = function(newOptions) {
348374
_configuration = !isDefinedObject(newOptions) ? {} : newOptions;
349375
buildDefaultConfiguration();
350376
return this;
351377
};
352378
this.getVersion = function() {
353-
return "0.2.3";
379+
return "0.3.0";
354380
};
355381
(function(documentObject, windowObject) {
356382
_parameter_Document = documentObject;
357383
_parameter_Window = windowObject;
358384
buildDefaultConfiguration();
359385
_parameter_Document.addEventListener("DOMContentLoaded", function() {
360386
render();
387+
buildGlobalDocumentEvents();
361388
});
362389
if (!isDefined(_parameter_Window.$select)) {
363390
_parameter_Window.$select = this;

dist/select.js.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Select.js Library v0.2.3
2+
* Select.js Library v0.3.0
33
*
44
* Copyright 2023 Bunoon
55
* Released under the MIT License
@@ -121,6 +121,11 @@ div.select-js div.control div.button:hover {
121121
opacity: 0.7;
122122
transition: var(--transition);
123123
}
124+
div.select-js div.control div.button:active {
125+
cursor: pointer;
126+
opacity: 0.5;
127+
transition: var(--transition);
128+
}
124129
div.select-js div.control div.button-open {
125130
transform: rotate(-135deg);
126131
top: 18px;

dist/select.js.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/select.js.min.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)