Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed #7 double extract fired due to enter and blur. tests pass again.

  • Loading branch information...
commit 5315f700bd8b51b3c1c3f88a92db37195a6143e8 1 parent 13649cb
@DimitarChristoff authored
View
1  Demo/index.html
@@ -58,6 +58,7 @@
method: "get"
}), {
autoSuggest: true,
+ persist: false,
// addOnBlur: false, // only works via enter to add.
onInvalidTag: function(invalidTag) {
console.log(invalidTag + " was rejected due to length");
View
18 Source/js/mooTagify.js
@@ -376,8 +376,15 @@ var mooTagify = this.mooTagify = new Class({
'mouseup': function() {
self.clicked = false
},
- 'keydown:relay(input)': function(e) {
- e.key == 'enter' && self.extractTags() && e.stop()
+ 'keydown:relay(input)': function(e, el) {
+ if (e.key == 'enter') {
+ if (self.options.addOnBlur) {
+ el.blur()
+ }
+ else {
+ self.extractTags() && e.stop()
+ }
+ }
}
}
@@ -395,12 +402,11 @@ var mooTagify = this.mooTagify = new Class({
clearInterval(this.timer)
var newTags = self.listTags.get('value').clean().stripScripts()
- !self.options.caseSensitiveTagMatching && (newTags = newTags.toLowerCase())
+ self.options.caseSensitiveTagMatching || (newTags = newTags.toLowerCase())
if (newTags.length) {
self.processTags(newTags)
- if (self.options.persist)
- self.listTags.focus()
+ self.options.persist && self.listTags.focus.delay(10, self.listTags)
}
self.options.autoSuggest && self.autoSuggester.hide()
return true
@@ -417,7 +423,7 @@ var mooTagify = this.mooTagify = new Class({
// called when blurred tags entry, rebuilds hash tags preview
clearInterval(this.timer)
var tagsArray = tags.split(',').map(function(el) {
- el = el.trim() /* already done in caller .toLowerCase() */
+ el = el.trim()
return el
}).unique()
View
11 test/tests/mooTagify-test.js
@@ -16,10 +16,8 @@ buster.testCase("mooTagify class test - via syn events > ", {
}).inject(document.body);
var self = this;
- this.tagify = new mooTagify(this.element, new Request.JSON({
- url: "checker.php",
- method: "get"
- }), {
+ this.tagify = new mooTagify(this.element, null, {
+ autoSuggest: false,
onReady: function() {
self.ready = true;
done();
@@ -54,7 +52,10 @@ buster.testCase("mooTagify class test - via syn events > ", {
done();
});
- Syn.type('Hello World\r', this.tagify.listTags);
+ var c = this.tagify.listTags;
+ Syn.type('Hello World\r', this.tagify.listTags, function() {
+ console.log(c.get('value'))
+ });
}
});
Please sign in to comment.
Something went wrong with that request. Please try again.