Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a removeToken method to Tokenizer

Summary:
Remove tokens dynamically with a proper function. Same implementation as
Tokenizer.prototype._remove(), except without the focus calls.

Test Plan:
Copied changes to another branch, called the function, saw the token got
removed.

Reviewers: epriestley, linjeffrey

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3525
  • Loading branch information...
commit 922749a109cfd7a39777ffdd8681470ea529a112 1 parent a875df7
Sai Wo Douglas Li authored
Showing with 8 additions and 4 deletions.
  1. +8 −4 src/lib/control/tokenizer/Tokenizer.js
View
12 src/lib/control/tokenizer/Tokenizer.js
@@ -99,7 +99,7 @@ JX.install('Tokenizer', {
this,
function(e) {
if (e.getNode('remove')) {
- this._remove(e.getNodeData('token').key);
+ this._remove(e.getNodeData('token').key, true);
} else if (e.getTarget() == this._root) {
this.focus();
}
@@ -279,6 +279,10 @@ JX.install('Tokenizer', {
return true;
},
+ removeToken : function(key) {
+ return this._remove(key, false);
+ },
+
buildInput: function(value) {
return JX.$N('input', {
className: 'jx-tokenizer-input',
@@ -338,7 +342,7 @@ JX.install('Tokenizer', {
if (!this._focus.value.length) {
var tok;
while (tok = this._tokens.pop()) {
- if (this._remove(tok)) {
+ if (this._remove(tok, true)) {
break;
}
}
@@ -357,14 +361,14 @@ JX.install('Tokenizer', {
}
},
- _remove : function(index) {
+ _remove : function(index, focus) {
if (!this._tokenMap[index]) {
return false;
}
JX.DOM.remove(this._tokenMap[index].node);
delete this._tokenMap[index];
this._redraw(true);
- this.focus();
+ focus && this.focus();
this.invoke('change', this);
Please sign in to comment.
Something went wrong with that request. Please try again.