|
1 | | -# BVSelect-VanillaJS |
2 | | - BVSelect - VanillaJS Version |
| 1 | +BVSelect - Vanilla JS |
| 2 | +-- |
| 3 | +<p align="center"> |
| 4 | +<img width="500" src="https://bmsvieira.github.io/BVSelect-VanillaJS/demo-template/images/BV.png"> |
| 5 | +</p> |
| 6 | +<br> |
| 7 | + |
| 8 | +Replaces native select elements with fully customizable dropdowns. |
| 9 | + |
| 10 | +Even though this replaces native select options, you can still use <b>Form Submit</b>, <b>Onchange Events</b> and <b>Attributes</b> as you would with normal usage. |
| 11 | + |
| 12 | +Demo: |
| 13 | +- |
| 14 | +https://bmsvieira.github.io/BVSelect-VanillaJS/ |
| 15 | + |
| 16 | +<b>JQuery Version:</b> |
| 17 | + |
| 18 | +https://github.com/BMSVieira/BVSelect |
| 19 | + |
| 20 | +Features: |
| 21 | +- |
| 22 | +- 🔧 Fully Customizable |
| 23 | +- 💪 No Dependencies, built with VanillaJS |
| 24 | +- 🌎 Tested in All Modern Browsers (IE11 not Included) |
| 25 | +- 😎 Images & FontIcons |
| 26 | +- ⌨️ Normal Usage (Multiple Selection included) |
| 27 | +- 🔎 Built-in Searchbox |
| 28 | +- 🖥 Prevented Viewport Overflow |
| 29 | + |
| 30 | +Installation: |
| 31 | +- |
| 32 | + |
| 33 | +1 - Include JavaScript Source. |
| 34 | +```javascript |
| 35 | +<script src="path/to/bvselect.js"></script> |
| 36 | +``` |
| 37 | +2 - Include Styles. |
| 38 | +```javascript |
| 39 | +<link rel="stylesheet" href="path/to/bvselect.css"> |
| 40 | +``` |
| 41 | +4 - Set HTML. |
| 42 | +```javascript |
| 43 | +<select id="selectbox"> |
| 44 | + <option data-separator="true"> Select Option </option> |
| 45 | + <option value="1"> Option 1 </option> |
| 46 | + <option value="2"> Option 2 </option> |
| 47 | + <option value="3" disabled> Option 3 </option> |
| 48 | + <option value="4"> Option 4 </option> |
| 49 | +</select> |
| 50 | +``` |
| 51 | +3 - Initilize. |
| 52 | +```javascript |
| 53 | + document.addEventListener("DOMContentLoaded", function() { |
| 54 | + var demo1 = new BVSelect({ |
| 55 | + selector: "#selectbox", |
| 56 | + searchbox: true, |
| 57 | + offset: true |
| 58 | + }); |
| 59 | + }); |
| 60 | +``` |
| 61 | + |
| 62 | + |
| 63 | +Methods: |
| 64 | +- |
| 65 | + |
| 66 | +<b>Destroy:</b> |
| 67 | +```javascript |
| 68 | +demo1.Destroy(); |
| 69 | +``` |
| 70 | +Removes dropdown, unbinds all its events and brings back the original Select |
| 71 | + |
| 72 | +<b>Update:</b> |
| 73 | +```javascript |
| 74 | +demo1.Update(); |
| 75 | +``` |
| 76 | +Updates current dropdown based on changes to the original selectbox. |
| 77 | + |
| 78 | +<b>Get ID:</b> |
| 79 | +```javascript |
| 80 | +demo1.GetID(); |
| 81 | +``` |
| 82 | +Returns the ID that was generated to build dropdown, so you can add custom classes. |
| 83 | + |
| 84 | +Settings: |
| 85 | +- |
| 86 | +| Name | Value | Default | Description | |
| 87 | +| --- | --- | --- | --- | |
| 88 | +| `width` | `px` or `%` | `100%` | Specify the width of the main element| |
| 89 | +| `searchbox` | `true` or `false` | `false` | Add a search box to the list | |
| 90 | +| `offset` | `true` or `false` | `true` | Fixes Viewport Offset | |
| 91 | + |
| 92 | +<b>Example:</b> |
| 93 | +```javascript |
| 94 | + document.addEventListener("DOMContentLoaded", function() { |
| 95 | + var demo1 = new BVSelect({ |
| 96 | + selector: "#selectbox", |
| 97 | + searchbox: true, |
| 98 | + offset: true |
| 99 | + }); |
| 100 | + }); |
| 101 | +``` |
| 102 | +Attributes: |
| 103 | +- |
| 104 | +| Name | Value | Description | |
| 105 | +| --- | --- | --- | |
| 106 | +| `data-separator` | `true` or `false` | Highlights an option | |
| 107 | +| `data-img` | `Image Source` | Adds an Image to option | |
| 108 | +| `data-icon` | `fa fa-hashtag` | Adds an FontIcon to option, can be used any provider as long it is identical. Images will be prioritized over icons. | |
| 109 | +| `disabled (native)` | `disabled` | Disables an option | |
| 110 | + |
| 111 | +*To add FontIcons, you must include it's own sources* |
| 112 | + |
| 113 | +<b>Example:</b> |
| 114 | +```html |
| 115 | +<select id="selectbox"> |
| 116 | + <option value="##" data-separator="true" selected>Select Option</option> |
| 117 | + <option data-img="path/to/img.png" value="--">Cristiano Ronaldo</option> |
| 118 | + <option data-icon="fa fa-hashtag" value="--" >Lionel Messi </option> |
| 119 | + <option data-img="path/to/img.png" value="--" disabled>Neymar Jr. (Disabled)</option> |
| 120 | + <option data-img="path/to/img.png" value="--">Ronaldinho</option> |
| 121 | + <option data-img="path/to/img.png" value="--">Luis Figo</option> |
| 122 | +</select> |
| 123 | +``` |
| 124 | +*All CSS styles are fully customizable in order to match your style* |
| 125 | + |
| 126 | +Frequently Asked Questions |
| 127 | +- |
| 128 | + |
| 129 | +<b>Is there any themes?</b> |
| 130 | + |
| 131 | +It doesn't need themes since the CSS is fully customizable, you are able to change everything to match your style. |
| 132 | + |
| 133 | +<b>In addition to design, what changes?</b> |
| 134 | + |
| 135 | +Replaces the original SelectBox but you can use it as you would with a native one, OnChange Events, Attributes, Form Submit, Append/Remove Options, everything. |
| 136 | + |
| 137 | +<b>What about Browser Compatibility?</b> |
| 138 | + |
| 139 | +It was tested successfully in every modern browser (IE11 not Included) |
0 commit comments