Skip to content

Commit

Permalink
add copyright and versioning info
Browse files Browse the repository at this point in the history
JS cleanup
  • Loading branch information
aehlke committed Jun 14, 2011
1 parent ab0f4e1 commit fb09577
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Check the [example.html](http://aehlke.github.com/tag-it/example.html) for sever

## Usage

First, load [jQuery](http://jquery.com/) (1.5.x or greater), [jQuery UI](http://jqueryui.com/) (1.8.x or greater), and the plugin:
First, load [jQuery](http://jquery.com/) (v1.4 or greater), [jQuery UI](http://jqueryui.com/) (v1.8 or greater), and the plugin:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js" type="text/javascript" charset="utf-8"></script>
Expand Down
2 changes: 1 addition & 1 deletion examples.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<link href="css/tagit.ui-zendesk.css" rel="stylesheet" type="text/css">

<!-- jQuery and jQuery UI are required dependencies. -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js" type="text/javascript" charset="utf-8"></script>

<!-- The real deal -->
Expand Down
72 changes: 56 additions & 16 deletions js/tag-it.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@

/*
* jQuery UI Tag-it!
*
* @version v2.0 (06/2011)
*
* Copyright 2011, Levy Carneiro Jr.
* Released under the MIT license.
* http://aehlke.github.com/tag-it/LICENSE
*
* Homepage:
* http://aehlke.github.com/tag-it/
*
* Authors:
* Levy Carneiro Jr.
* Martin Rehfeld
* Tobias Schmidt
* Skylar Challand
* Alex Ehlke
*
* Maintainer:
* Alex Ehlke - Twitter: @aehlke
*
* Dependencies:
* jQuery v1.4+
* jQuery UI v1.8+
*/
(function($) {

$.widget('ui.tagit', {
Expand All @@ -9,19 +34,33 @@
tagSource : null,
removeConfirmation: false,
caseSensitive : true,
allowSpaces : false, // when enabled, quotes are not neccesary for inputting multi-word tags

// The below options are for using a single field instead of several for our form values.
singleField: false, // When enabled, will use a single hidden field for the form, rather than
// one per tag. It will delimit tags in the field with singleFieldDelimiter.
// When enabled, quotes are not neccesary
// for inputting multi-word tags.
allowSpaces: false,

// The below options are for using a single field instead of several
// for our form values.
//
// When enabled, will use a single hidden field for the form,
// rather than one per tag. It will delimit tags in the field
// with singleFieldDelimiter.
singleField: false,

singleFieldDelimiter: ',',
singleFieldNode: null, // Set this to an input DOM node to use an existing form field.
// Any text in it will be erased on init. But it will be populated with
// the text of tags as they are created, delimited by singleFieldDelimiter.
// If this is not set, we create an input node for it, with the name
// given in settings.fieldName, ignoring settings.itemName.

tabIndex: null, // Optionally set a tabindex attribute on the input that gets created for tag-it.
// Set this to an input DOM node to use an existing form field.
// Any text in it will be erased on init. But it will be
// populated with the text of tags as they are created,
// delimited by singleFieldDelimiter.
// If this is not set, we create an input node for it,
// with the name // given in settings.fieldName,
// ignoring settings.itemName.
singleFieldNode: null,

// Optionally set a tabindex attribute on the input that gets
// created for tag-it.
tabIndex: null,


// Event callbacks.
Expand All @@ -37,8 +76,8 @@

// There are 2 kinds of DOM nodes this widget can be instantiated on:
// 1. UL, OL, or some element containing either of these.
// 2. INPUT, in which case 'singleField' is overridden to true, a UL is created
// and the INPUT is hidden.
// 2. INPUT, in which case 'singleField' is overridden to true,
// a UL is created and the INPUT is hidden.
if (this.element.is('input')) {
this.tagList = $('<ul></ul>').insertAfter(this.element);
this.options.singleField = true;
Expand Down Expand Up @@ -66,15 +105,16 @@
this.tagList
.addClass('tagit')
.addClass('ui-widget ui-widget-content ui-corner-all')
// create the input field.
// Create the input field.
.append($('<li class="tagit-new"></li>').append(this._tagInput))
.click(function(e) {
var target = $(e.target);
if (target.hasClass('tagit-label')) {
that._trigger('onTagClicked', e, target.closest('.tagit-choice'));
} else {
// Sets the focus() to the input field, if the user clicks anywhere inside the UL.
// This is needed because the input field needs to be of a small size.
// Sets the focus() to the input field, if the user
// clicks anywhere inside the UL. This is needed
// because the input field needs to be of a small size.
that._tagInput.focus();
}
});
Expand Down

0 comments on commit fb09577

Please sign in to comment.