Skip to content

Commit

Permalink
Implemented confirmKeys option
Browse files Browse the repository at this point in the history
  • Loading branch information
timschlechter committed Oct 5, 2013
1 parent ff6c563 commit 1b7c2aa
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 22 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,13 @@ Integrates with Twitter Bootstraps' 2.3.2 typeahead, or use custom typeahead whe
### Angular JS directive
Include [bootstrap-tagsinput-angular.js](https://github.com/TimSchlechter/bootstrap-tagsinput/blob/master/src/bootstrap-tagsinput-angular.js) and register the 'bootstrap-tagsinput' in your Angular JS application to use the bootstrap-tagsinput directive. Look at [the examples page](http://timschlechter.github.io/bootstrap-tagsinput/examples/#angular) how to use the directive.

## History
### 0.3.5
* [confirmKeys option](https://github.com/TimSchlechter/bootstrap-tagsinput/issues/10)
### 0.3.4
* [Limit number of tags, enable/disable input](https://github.com/TimSchlechter/bootstrap-tagsinput/pull/28)
* [Avoid conflict with other selects when checking for value presence](https://github.com/TimSchlechter/bootstrap-tagsinput/pull/33)
* [Add bsTagsInput angular directive & example for bootstrap3 with typeahea...](https://github.com/TimSchlechter/bootstrap-tagsinput/pull/24)

## License
This project is licensed under [MIT](https://raw.github.com/TimSchlechter/bootstrap-tagsinput/master/LICENSE "Read more about the MIT license").
2 changes: 1 addition & 1 deletion bootstrap-tagsinput.jquery.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bootstrap-tagsinput",
"version": "0.3.4",
"version": "0.3.5",
"title": "Bootstrap Tags Input",
"author": {
"name": "Tim Schlechter"
Expand Down
Binary file modified build/bootstrap-tagsinput.zip
Binary file not shown.
23 changes: 13 additions & 10 deletions dist/bootstrap-tagsinput.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
itemText: function(item) {
return this.itemValue(item);
},
freeInput : true,
maxTags : 0
freeInput: true,
maxTags: undefined,
confirmKeys: [13]
};

function TagsInput(element, options) {
Expand Down Expand Up @@ -96,9 +97,13 @@
self.$element.append($option);
}

if (!dontPushVal)
if (!dontPushVal)
self.pushVal();

// Add class when reached maxTags
if (self.options.maxTags === self.itemsArray.length)
self.$container.addClass('bootstrap-tagsinput-max');

self.$element.trigger($.Event('itemAdded', { item: item }));
},

Expand All @@ -121,8 +126,9 @@
if (!dontPushVal)
self.pushVal();

if (self.options.maxTags && self.itemsArray.length < self.options.maxTags && !this.isEnabled())
this.enable();
// Remove class when reached maxTags
if (self.options.maxTags > self.itemsArray.length)
self.$container.removeClass('bootstrap-tagsinput-max');

self.$element.trigger($.Event('itemRemoved', { item: item }));
},
Expand Down Expand Up @@ -290,15 +296,12 @@
$input.focus();
}
break;
// ENTER
case 13:
if (self.options.freeInput) {
default:
if (self.options.freeInput && self.options.confirmKeys.indexOf(event.which) >= 0) {
self.add($input.val());
$input.val('');
event.preventDefault();
}
break;

}

$input.attr('size', Math.max(1, $input.val().length));
Expand Down
4 changes: 2 additions & 2 deletions dist/bootstrap-tagsinput.min.js

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

Loading

0 comments on commit 1b7c2aa

Please sign in to comment.