modified: diffout.py
[GalaxyCodeBases.git] / js / TagSelect.js / README.md
blobc5514c84b0350745372f21909bd68c80e1609c3d
1 # TagSelect.js
3 ## Overview
5 HTML5-based input for typing lists of tags, tokens, or other discrete values.
7 No dependencies required. 6kb gzipped.
9 ![screenshot](https://dl.dropboxusercontent.com/u/42869844/LTS/TagSelect.gif)
11 Features:
13 * Built-in validation, with visual feedback on unexpected values.
14 * Full keyboard/cursor support (you can type anywhere in the input).
15 * Full copy/paste support.
17 Currently, all non-word characters are treated as tag dividers. More separator options may be added in the future.
19 > **Compatibility:** Only modern browsers are supported. Some of the nicer features of this plugin (copy/paste support, native selection and cursor movement) aren't realistic on older browsers.
21 ***
23 ## Quickstart (Scripts)
25 Include the files from `dist/` in your project. Example:
27 ```html
28 <link rel="stylesheet" href="tagselect.min.css">
29 <script src="tagselect.min.js"></script>
30 ```
32 Next, you can use the plugin in your own JavaScript. If you have an element with the ID 'my-input':
34 ```html
35 <div id="my-input"></div>
36 ```
38 ```javascript
39 var element = document.querySelector('#my-input');
40 var tags = new TagSelect(element, {
41     options: ['Red', 'Green', 'Blue', 'Yellow', 'Orange', 'Magenta']
42 });
43 ```
45 ## Quickstart (NPM + Browserify / Webpack)
47 Add the dependency:
49 ```bash
50 npm install --save TagSelect.js
51 ```
53 And use it in your script:
55 ```javascript
56 var TagSelect = require('TagSelect.js');
58 var element = document.querySelector('#my-input');
59 var tags = new TagSelect(element, {
60     options: ['Red', 'Green', 'Blue', 'Yellow', 'Orange', 'Magenta']
61 });
62 ```
64 ### Methods
66 ```javascript
67 /* .get()
68 *************************/
69 var selected = tags.get();
70 // => ['Magenta, 'Yellow']
72 /* .set()
73 *************************/
74 tags.set(['Orange']);
76 /* .on()
77 *************************/
78 tags.on('change', function () {
79     console.log('Tags updated!');
80     console.log(tags.get());
82 ```
84 ## Contributing
86 ### Development
88 To get started, you'll need install the development dependencies:
90 ```
91 npm install
92 ```
94 Development tasks, like compiling [Sass](http://sass-lang.com/) and minifying JavaScript, are handled by [NPM scripts](https://docs.npmjs.com/misc/scripts).
96 ```bash
97 # Run a local development server, recompiling files on update.
98 npm run dev
100 # Rebuild all CSS and JS.
101 npm run build
103 # Bump the version, commit the dist/, and release on NPM.
104 npm version [ major | minor | patch ]