Skip to content

Commit 9893260

Browse files
committed
Fixes to whitelist, readme, dist
1 parent 088606f commit 9893260

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ If you want a function to be called every time a tag is updated/deleted, set it
9090

9191
By default, if the cursor is immediately after a tag, hitting backspace will delete that tag. If you want to override this, set the `removeWithBackspace` option to false.
9292

93-
For validation purposes you can use `unique`, `limit`, `minChars`, `maxChars` and `validationPattern` parameters.
93+
For validation purposes you can use `unique`, `limit`, `minChars`, `maxChars`, `whitelist` and `validationPattern` parameters.
9494

9595
You can check `example.html` file to see the plugin usage examples.
9696

@@ -111,6 +111,7 @@ $('.tagsinput#tags').tagsInput({
111111
delimiter: [',',';'], // or a string with a single delimiter
112112
unique: true,
113113
removeWithBackspace: true,
114+
whitelist: [], // null or aray of whitelisted values
114115
onAddTag: callback_function,
115116
onRemoveTag: callback_function,
116117
onChange: callback_function

dist/jquery.tagsinput-revisited.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jquery.tagsinput-revisited",
3-
"version": "2.0.0",
4-
"description": "",
3+
"version": "2.1",
4+
"description": "Revisited version of popular jQuery Tags Input Plugin",
55
"main": "jquery.tagsinput-revisited",
66
"directories": {
77
"test": "test"

src/jquery.tagsinput-revisited.js

+5-10
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@
2222

2323
value = jQuery.trim(value);
2424

25-
var settings = inputSettings[id]
26-
if ( settings.whitelist && settings.whitelist.indexOf(value) == -1) {
25+
var settings = inputSettings[id];
26+
if (settings.whitelist && settings.whitelist.indexOf(value) === -1) {
2727
return false;
2828
}
29-
3029

3130
if ((inputSettings[id].unique && $(this).tagExist(value)) || !_validateTag(value, inputSettings[id], tagslist, delimiter[id])) {
3231
$('#' + id + '_tag').addClass('error');
@@ -70,13 +69,9 @@
7069
value = decodeURI(value);
7170

7271
this.each(function() {
73-
var id = $(this).attr('id');
72+
var id = $(this).attr('id');
7473
var old = $(this).val().split(_getDelimiter(delimiter[id]));
7574

76-
77-
78-
79-
8075
$('#' + id + '_tagsinput .tag').remove();
8176

8277
var str = '';
@@ -86,7 +81,6 @@
8681
}
8782
}
8883

89-
9084
$.fn.tagsInput.importTags(this, str);
9185

9286
if (callbacks[id] && callbacks[id]['onRemoveTag']) {
@@ -124,7 +118,8 @@
124118
hide: true,
125119
delimiter: ',',
126120
unique: true,
127-
removeWithBackspace: true
121+
removeWithBackspace: true,
122+
whitelist: null
128123
}, options);
129124

130125
var uniqueIdCounter = 0;

0 commit comments

Comments
 (0)