Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: jpalmucci/tag-it
base: f107e8017a
...
head fork: jpalmucci/tag-it
compare: 5e4bf84819
Checking mergeability… Don't worry, you can still create the pull request.
  • 14 commits
  • 3 files changed
  • 0 commit comments
  • 6 contributors
Commits on Aug 04, 2011
@GUI GUI Fix variable scope. This caused a bug when multiple fields were prese…
…nt, and the first time the "x" was clicked to remove a tag.
f816b26
Commits on Aug 09, 2011
@aehlke aehlke Merge pull request #15 from GUI/master
fix variable scope to fix the tag removal button
f868ea9
Commits on Aug 17, 2011
@julen julen Added a setting to optionally animate tag removals. 95937be
@julen julen Update comment; the animate argument doesn't exist. 00a3752
@aehlke aehlke Merge pull request #17 from julen/master
Animating tag removals should be optional
440b9b7
Commits on Aug 18, 2011
@GUI GUI Bind the tagSource callback to the tag-it context. This allows custom…
… callbacks to access tag-it functions, such as assignedTags(), like the default callback does.
453e113
@GUI GUI The tagSource option could just be a URL string (as jQueryUI's autoco…
…mplete accepts). Don't bind the callback in that case.
565a6e4
Commits on Aug 26, 2011
@berwinter berwinter closed input's to be valid XHTML 7bb6305
Commits on Aug 31, 2011
@aehlke aehlke Merge pull request #25 from berwinter/master
valid XHTML
21fda6e
@aehlke aehlke Merge pull request #19 from GUI/master
Bind the tagSource callback to the tag-it context
00d7a4a
Commits on Sep 05, 2011
@andrusha andrusha Renamed .close -> .tagit-close c461975
@aehlke aehlke Merge pull request #29 from andrusha/master
Renamed .close to .tagit-close
396745e
Commits on Nov 02, 2011
@jpalmucci Send the onTagRemove event after the single input field has been upda…
…ted so its easy to grab the new set of tags as a set.
586c9fc
@jpalmucci add maxTags and onlyAvailableTags options 5e4bf84
Showing with 35 additions and 18 deletions.
  1. +2 −2 css/jquery.tagit.css
  2. +4 −4 css/tagit.ui-zendesk.css
  3. +29 −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
41 js/tag-it.js
@@ -34,11 +34,16 @@
tagSource : null,
removeConfirmation: false,
caseSensitive : true,
-
+ maxTags : 9999,//maximum tags allowed default almost unlimited
+ onlyAvailableTags : false,//boolean, allows tags that are in availableTags or not
+
// When enabled, quotes are not neccesary
// for inputting multi-word tags.
allowSpaces: false,
+ // Whether to animate tag removals or not.
+ animate: true,
+
// The below options are for using a single field instead of several
// for our form values.
//
@@ -93,21 +98,26 @@
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);
}
this.options.tagSource = 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);
+ }
+
this.tagList
.addClass('tagit')
.addClass('ui-widget ui-widget-content ui-corner-all')
@@ -145,7 +155,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 + '" />');
}
}
@@ -293,10 +303,16 @@
},
createTag: function(value, additionalClass) {
- that = this;
+ var that = this;
// Automatically trims the value of leading and trailing whitespace.
value = $.trim(value);
+ if (that.tagList.children('.tagit-choice').length >= that.options.maxTags) {
+ return false;
+ }
+ if (that.options.onlyAvailableTags && $.inArray(that._formatStr(value),that.options.availableTags)==-1) {
+ return false;
+ }
if (!this._isNew(value) || value === '') {
return false;
}
@@ -313,7 +329,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.
@@ -328,7 +344,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);
@@ -341,12 +357,10 @@
},
removeTag: function(tag, animate) {
- if (typeof animate === 'undefined') { animate = true; }
+ animate = animate || this.options.animate;
tag = $(tag);
- this._trigger('onTagRemoved', null, tag);
-
if (this.options.singleField) {
var tags = this.assignedTags();
var removedTagLabel = this.tagLabel(tag);
@@ -355,6 +369,9 @@
});
this._updateSingleTagsField(tags);
}
+
+ this._trigger('onTagRemoved', null, tag);
+
// Animate the removal.
if (animate) {
tag.fadeOut('fast').hide('blind', {direction: 'horizontal'}, 'fast', function(){
@@ -366,7 +383,7 @@
},
removeAll: function() {
- // Removes all tags. Takes an optional `animate` argument.
+ // Removes all tags.
var that = this;
this.tagList.children('.tagit-choice').each(function(index, tag) {
that.removeTag(tag, false);

No commit comments for this range

Something went wrong with that request. Please try again.