Skip to content

Commit

Permalink
Fixes to whitelist, readme, dist
Browse files Browse the repository at this point in the history
  • Loading branch information
underovsky committed Oct 28, 2019
1 parent 088606f commit 9893260
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ If you want a function to be called every time a tag is updated/deleted, set it

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.

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

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

Expand All @@ -111,6 +111,7 @@ $('.tagsinput#tags').tagsInput({
delimiter: [',',';'], // or a string with a single delimiter
unique: true,
removeWithBackspace: true,
whitelist: [], // null or aray of whitelisted values
onAddTag: callback_function,
onRemoveTag: callback_function,
onChange: callback_function
Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.tagsinput-revisited.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jquery.tagsinput-revisited",
"version": "2.0.0",
"description": "",
"version": "2.1",
"description": "Revisited version of popular jQuery Tags Input Plugin",
"main": "jquery.tagsinput-revisited",
"directories": {
"test": "test"
Expand Down
15 changes: 5 additions & 10 deletions src/jquery.tagsinput-revisited.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@

value = jQuery.trim(value);

var settings = inputSettings[id]
if ( settings.whitelist && settings.whitelist.indexOf(value) == -1) {
var settings = inputSettings[id];
if (settings.whitelist && settings.whitelist.indexOf(value) === -1) {
return false;
}


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

this.each(function() {
var id = $(this).attr('id');
var id = $(this).attr('id');
var old = $(this).val().split(_getDelimiter(delimiter[id]));





$('#' + id + '_tagsinput .tag').remove();

var str = '';
Expand All @@ -86,7 +81,6 @@
}
}


$.fn.tagsInput.importTags(this, str);

if (callbacks[id] && callbacks[id]['onRemoveTag']) {
Expand Down Expand Up @@ -124,7 +118,8 @@
hide: true,
delimiter: ',',
unique: true,
removeWithBackspace: true
removeWithBackspace: true,
whitelist: null
}, options);

var uniqueIdCounter = 0;
Expand Down

0 comments on commit 9893260

Please sign in to comment.