Permalink
Browse files

Merge https://github.com/aehlke/tag-it

Conflicts:
	css/jquery.tagit.css
	js/tag-it.js
  • Loading branch information...
2 parents 6ae73a5 + 396745e commit 79f8747fe0aea79316896e1a6bc92b216b5e2aaf @grisevg grisevg committed Sep 6, 2011
Showing with 22 additions and 18 deletions.
  1. +2 −2 css/jquery.tagit.css
  2. +4 −4 css/tagit.ui-zendesk.css
  3. +16 −12 js/tag-it.js
View
4 css/jquery.tagit.css
@@ -22,7 +22,7 @@ ul.tagit li.tagit-choice a.tagit-label {
cursor: pointer;
text-decoration: none;
}
-ul.tagit li.tagit-choice .close {
+ul.tagit li.tagit-choice .tagit-close {
cursor: pointer;
position: absolute;
right: .1em;
@@ -31,7 +31,7 @@ ul.tagit li.tagit-choice .close {
}
/* used for some custom themes that don't need image icons */
-ul.tagit li.tagit-choice .close .text-icon {
+ul.tagit li.tagit-choice .tagit-close .text-icon {
display: none;
}
View
8 css/tagit.ui-zendesk.css
@@ -20,16 +20,16 @@ ul.tagit li.tagit-choice {
color: #555;
font-weight: normal;
}
-ul.tagit li.tagit-choice a.close {
+ul.tagit li.tagit-choice a.tagit-close {
text-decoration: none;
}
-ul.tagit li.tagit-choice .close {
+ul.tagit li.tagit-choice .tagit-close {
right: .4em;
}
ul.tagit li.tagit-choice .ui-icon {
display: none;
}
-ul.tagit li.tagit-choice .close .text-icon {
+ul.tagit li.tagit-choice .tagit-close .text-icon {
display: inline;
font-family: arial, sans-serif;
font-size: 16px;
@@ -41,7 +41,7 @@ ul.tagit li.tagit-choice:hover, ul.tagit li.tagit-choice.remove {
border-color: #6d95e0;
}
ul.tagit li.tagit-choice a.tagLabel:hover,
-ul.tagit li.tagit-choice a.close .text-icon:hover {
+ul.tagit li.tagit-choice a.tagit-close .text-icon:hover {
color: #222;
}
ul.tagit input[type="text"] {
View
28 js/tag-it.js
@@ -29,16 +29,16 @@
$.widget('ui.tagit', {
options: {
itemName : 'item',
- fieldName : 'tags',
+ fieldName : 'tags',
removeConfirmation: false,
caseSensitive : true,
// Autocomplete settings
- autocompleteHeader : null,
+ autocompleteHeader: null,
availableTags : [],
- tagSource : null,
- minLength : 1,
- delay :300,
+ tagSource : null,
+ minLength : 1,
+ delay : 300,
showAllOnFocus : false,
// When enabled, quotes are not neccesary
@@ -102,21 +102,25 @@
this.tagList = this.element.find('ul, ol').andSelf().last();
}
- this._tagInput = $('<input type="text">').addClass('ui-widget-content');
+ this._tagInput = $('<input type="text" />').addClass('ui-widget-content');
if (this.options.tabIndex) {
this._tagInput.attr('tabindex', this.options.tabIndex);
}
if (!this.options.tagSource && this.options.availableTags) {
this.options.tagSource = function(search, showChoices) {
var filter = search.term.toLowerCase();
- var choices = $.grep(that.options.availableTags, function(element) {
+ var choices = $.grep(this.options.availableTags, function(element) {
// Only match autocomplete options that begin with the search term.
// (Case insensitive.)
return (element.toLowerCase().indexOf(filter) === 0);
});
- showChoices(that._subtractArray(choices, that.assignedTags()));
+ showChoices(this._subtractArray(choices, this.assignedTags()));
};
+
+ // Bind tagSource callback functions to this context.
+ if ($.isFunction(this.options.tagSource)) {
+ this.options.tagSource = $.proxy(this.options.tagSource, this);
}
@@ -157,7 +161,7 @@
});
} else {
// Create our single field input after our list.
- this.options.singleFieldNode = this.tagList.after('<input type="hidden" style="display:none;" value="" name="' + this.options.fieldName + '">');
+ this.options.singleFieldNode = this.tagList.after('<input type="hidden" style="display:none;" value="" name="' + this.options.fieldName + '" />');
}
}
@@ -250,7 +254,7 @@
// Preventing the tag input to be updated with the chosen value.
return false;
},
- appendTo:this.tagList[0],
+ appendTo:this.tagList[0],//Autocomplete list should be appended to tagit element, instead of <body>
});
//Show all posibilities on focus
if (this.options.showAllOnFocus) {
@@ -351,7 +355,7 @@
var removeTagIcon = $('<span></span>')
.addClass('ui-icon ui-icon-close');
var removeTag = $('<a><span class="text-icon">\xd7</span></a>') // \xd7 is an X
- .addClass('close')
+ .addClass('tagit-close')
.append(removeTagIcon)
.click(function(e) {
// Removes a tag when the little 'x' is clicked.
@@ -366,7 +370,7 @@
this._updateSingleTagsField(tags);
} else {
var escapedValue = label.html();
- tag.append('<input type="hidden" style="display:none;" value="' + escapedValue + '" name="' + this.options.itemName + '[' + this.options.fieldName + '][]">');
+ tag.append('<input type="hidden" style="display:none;" value="' + escapedValue + '" name="' + this.options.itemName + '[' + this.options.fieldName + '][]" />');
}
this._trigger('onTagAdded', null, tag);

0 comments on commit 79f8747

Please sign in to comment.