Skip to content
This repository was archived by the owner on Sep 28, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bootstrap-tokenfield.jquery.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bootstrap-tokenfield",
"version": "0.12.1",
"version": "0.12.2",
"title": "bootstrap-tokenfield",
"author": {
"name": "ragulka",
Expand Down
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bootstrap-tokenfield",
"description": "Advanced tagging/tokenizing plugin for input fields with a focus on keyboard and copy-paste support.",
"version": "0.12.1",
"version": "0.12.2",
"authors": [
{
"name": "ragulka",
Expand Down Expand Up @@ -37,4 +37,4 @@
"chai": "~1.7.*",
"typeahead.js": "~0.10.1"
}
}
}
57 changes: 26 additions & 31 deletions dist/bootstrap-tokenfield.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@
args[0] = $.extend( {}, defaults, args[0] )

this.$input.typeahead.apply( this.$input, args )
this.$hint = this.$input.prev('.tt-hint')
this.typeahead = true
}
}
Expand Down Expand Up @@ -269,9 +268,11 @@
parseInt($tokenLabel.css('margin-right'), 10)
}

$tokenLabel
.text(attrs.label)
.css('max-width', this.maxTokenWidth)
$tokenLabel.css('max-width', this.maxTokenWidth)
if (this.options.html)
$tokenLabel.html(attrs.label)
else
$tokenLabel.text(attrs.label)

// Listen to events on token
$token
Expand Down Expand Up @@ -311,17 +312,20 @@
}

// Update tokenfield dimensions
this.update()
var _self = this
setTimeout(function () {
_self.update()
}, 0)

// Return original element
return this.$element.get(0)
}

, setTokens: function (tokens, add, triggerChange) {
if (!tokens) return

if (!add) this.$wrapper.find('.token').remove()

if (!tokens) return

if (typeof triggerChange === 'undefined') {
triggerChange = true
}
Expand Down Expand Up @@ -380,12 +384,19 @@
return this.$input.val()
}

, setInput: function (val) {
if (this.$input.hasClass('tt-input')) {
// Typeahead acts weird when simply setting input value to empty,
// so we set the query to empty instead
this.$input.typeahead('val', val)
} else {
this.$input.val(val)
}
}

, listen: function () {
var _self = this

this.$element
.on('change', $.proxy(this.change, this))

this.$wrapper
.on('mousedown',$.proxy(this.focusInput, this))

Expand Down Expand Up @@ -628,12 +639,6 @@
}
}

, change: function (e) {
if ( e.initiator === 'tokenfield' ) return // Prevent loops

this.setTokens( this.$element.val() )
}

, createTokensFromInput: function (e, focus) {
if (this.$input.val().length < this.options.minLength)
return // No input, simply return
Expand All @@ -644,13 +649,7 @@
if (tokensBefore == this.getTokensList() && this.$input.val().length)
return false // No tokens were added, do nothing (prevent form submit)

if (this.$input.hasClass('tt-input')) {
// Typeahead acts weird when simply setting input value to empty,
// so we set the query to empty instead
this.$input.typeahead('val', '')
} else {
this.$input.val('')
}
this.setInput('')

if (this.$input.data( 'edit' )) {
this.unedit(focus)
Expand Down Expand Up @@ -881,12 +880,11 @@
}

this.$input.width( mirrorWidth )

if (this.$hint) {
this.$hint.width( mirrorWidth )
}
}
else {
//temporary reset width to minimal value to get proper results
this.$input.width(this.options.minWidth);

var w = (this.textDirection === 'rtl')
? this.$input.offset().left + this.$input.outerWidth() - this.$wrapper.offset().left - parseInt(this.$wrapper.css('padding-left'), 10) - inputPadding - 1
: this.$wrapper.offset().left + this.$wrapper.width() + parseInt(this.$wrapper.css('padding-left'), 10) - this.$input.offset().left - inputPadding;
Expand All @@ -895,10 +893,6 @@
// dimensions returned by jquery will be NaN -> we default to 100%
// so placeholder won't be cut off.
isNaN(w) ? this.$input.width('100%') : this.$input.width(w);

if (this.$hint) {
isNaN(w) ? this.$hint.width('100%') : this.$hint.width(w);
}
}
}

Expand Down Expand Up @@ -1010,6 +1004,7 @@
$.fn.tokenfield.defaults = {
minWidth: 60,
minLength: 0,
html: true,
allowEditing: true,
allowPasting: true,
limit: 0,
Expand Down
4 changes: 2 additions & 2 deletions dist/bootstrap-tokenfield.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs-assets/js/docs.min.js

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

13 changes: 2 additions & 11 deletions js/bootstrap-tokenfield.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@
, getInput: function() {
return this.$input.val()
}

, setInput: function (val) {
if (this.$input.hasClass('tt-input')) {
// Typeahead acts weird when simply setting input value to empty,
Expand All @@ -397,9 +397,6 @@
, listen: function () {
var _self = this

this.$element
.on('change', $.proxy(this.change, this))

this.$wrapper
.on('mousedown',$.proxy(this.focusInput, this))

Expand Down Expand Up @@ -642,12 +639,6 @@
}
}

, change: function (e) {
if ( e.initiator === 'tokenfield' ) return // Prevent loops

this.setTokens( this.$element.val() )
}

, createTokensFromInput: function (e, focus) {
if (this.$input.val().length < this.options.minLength)
return // No input, simply return
Expand Down Expand Up @@ -893,7 +884,7 @@
else {
//temporary reset width to minimal value to get proper results
this.$input.width(this.options.minWidth);

var w = (this.textDirection === 'rtl')
? this.$input.offset().left + this.$input.outerWidth() - this.$wrapper.offset().left - parseInt(this.$wrapper.css('padding-left'), 10) - inputPadding - 1
: this.$wrapper.offset().left + this.$wrapper.width() + parseInt(this.$wrapper.css('padding-left'), 10) - this.$input.offset().left - inputPadding;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "bootstrap-tokenfield",
"title": "Bootstrap Tokenfield",
"description": "Advanced tagging/tokenizing plugin for input fields with a focus on keyboard and copy-paste support.",
"version": "0.12.1",
"version": "0.12.2",
"main": "dist/bootstrap-tokenfield.js",
"homepage": "http://sliptree.github.io/bootstrap-tokenfield/",
"author": {
Expand Down