Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

case insensitive tag matching and display + tests

  • Loading branch information...
commit e1af8acee73b31fdeabf54ccc63637127728a5cb 1 parent bfc2275
@DimitarChristoff authored
Showing with 65 additions and 10 deletions.
  1. +6 −9 Source/js/mooTagify.js
  2. +59 −1 test/tests/mooTagify-test.js
View
15 Source/js/mooTagify.js
@@ -393,9 +393,8 @@ var mooTagify = this.mooTagify = new Class({
clearInterval(this.timer)
var newTags = this.listTags.get('value').clean().stripScripts()
- if (!this.options.caseSensitiveTagMatching) {
- newTags = newTags.toLowerCase()
- }
+ !this.options.caseSensitiveTagMatching && (newTags = newTags.toLowerCase())
+
if (newTags.length) {
this.processTags(newTags)
if (this.options.persist)
@@ -437,9 +436,8 @@ var mooTagify = this.mooTagify = new Class({
target.empty()
var done = 0
Array.each(tagsArray, function(el) {
- if (!this.options.caseSensitiveTagMatching) {
- el = el.toLowerCase()
- }
+ !this.options.caseSensitiveTagMatching && (el = el.toLowerCase())
+
if (done >= this.options.maxItemCount) {
this.fireEvent('limitReached', el)
return
@@ -460,9 +458,8 @@ var mooTagify = this.mooTagify = new Class({
removeTag: function(e) {
var tag = e.target.getParent()
var tagText = tag.get('text')
- if (!this.options.caseSensitiveTagMatching) {
- tagText = tagText.toLowerCase()
- }
+ !this.options.caseSensitiveTagMatching && (tagText = tagText.toLowerCase())
+
var self = this
e.target.getParent().set('tween', {
onComplete: function() {
View
60 test/tests/mooTagify-test.js
@@ -3,7 +3,7 @@ if (typeof require == "function" && typeof module == "object") {
}
buster.testRunner.timeout = 1000;
-buster.testCase("mooTagify class test", {
+buster.testCase("mooTagify class test - case enforced > ", {
setUp: function(done) {
this.element = new Element("div#tagWrap", {
html: [
@@ -126,3 +126,61 @@ buster.testCase("mooTagify class test", {
}
});
+
+buster.testCase("mooTagify class test - case insensitive > ", {
+ setUp: function(done) {
+ this.element = new Element("div#tagWrap", {
+ html: [
+ '<div class="left tagLock">',
+ '</div>',
+ '<div class="left">',
+ '<input id="listTags" name="listTags" placeholder="+Add tags" />',
+ '</div>',
+
+ '<div class="clear"></div>'
+ ].join("")
+ });
+
+ var self = this;
+ this.tagify = new mooTagify(this.element, new Request.JSON({
+ url: "checker.php",
+ method: "get"
+ }), {
+ onReady: function() {
+ self.ready = true;
+ done();
+ },
+ caseSensitiveTagMatching: true
+ });
+ },
+
+ "Expect tags to export in lowercase still": function(done) {
+ var testArray = ['Coda','Was','here'];
+ this.tagify.addEvent("tagsUpdate", function() {
+ var tags = this.getTags();
+ buster.assert.equals(tags, testArray);
+ done();
+ });
+
+ this.tagify.listTags.set("value", testArray.join(','));
+
+ this.tagify.element.fireEvent("blur:relay(input)");
+
+ },
+
+ "Expect tags to show in their original case": function(done) {
+ var self = this, testArray = ['Coda','Was','here'];
+ this.tagify.addEvent("tagsUpdate", function() {
+ var tags = self.element.getElements(".tag").get("text");
+ buster.assert.equals(tags, testArray);
+ done();
+ });
+
+ this.tagify.listTags.set("value", testArray.join(','));
+
+ this.tagify.element.fireEvent("blur:relay(input)");
+
+ }
+
+
+});
Please sign in to comment.
Something went wrong with that request. Please try again.