Skip to content

Commit

Permalink
Rewrite of Mark's plugin, replacing the externals with CDN links, upd…
Browse files Browse the repository at this point in the history
…ating to 1.8 widget factory, integrating jQuery UI Autocomplete into the tokenlist widget and cleaning up various stuff
  • Loading branch information
jzaefferer committed Mar 28, 2010
1 parent 0e04cf4 commit 4031aec
Show file tree
Hide file tree
Showing 17 changed files with 62 additions and 155 deletions.
6 changes: 0 additions & 6 deletions Makefile

This file was deleted.

6 changes: 6 additions & 0 deletions README.md
@@ -0,0 +1,6 @@
jQuery Tokenlist Plugin
=====================

A fork of [Mark Gibson's Tokenlist](http://github.com/jollytoad/jquery.ui-tokenlist).

Uses jQuery UI for themeing and autocomplete.
1 change: 0 additions & 1 deletion build
Submodule build deleted from 114ea4
3 changes: 0 additions & 3 deletions demo/demo.css

This file was deleted.

79 changes: 0 additions & 79 deletions demo/demo.html

This file was deleted.

39 changes: 0 additions & 39 deletions demo/demo.js

This file was deleted.

28 changes: 28 additions & 0 deletions demo/index.html
@@ -0,0 +1,28 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Token List Demo</title>
<link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/themes/base/jquery-ui.css" rel="stylesheet" />
<link rel="stylesheet" href="../jquery.tokenlist.css" type="text/css" />
</head>
<body>
<h1>Token List Demo</h1>

<p>Convert a plain text field into a facebook style list builder:</p>

<label for="test1">Numbers from one to ten please, no duplicates:</label>
<input id="test1" type="text" value="one, two, four" class="test"/>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.js"></script>
<script type="text/javascript" src="../jquery.tokenlist.js"></script>
<script type="text/javascript">
$('.test').tokenlist({
validate: ['one','two','three','four','five','six','seven','eight','nine','ten']
});
</script>
</body>
</html>

1 change: 0 additions & 1 deletion demo/jquery.js

This file was deleted.

1 change: 0 additions & 1 deletion demo/ui-css

This file was deleted.

1 change: 0 additions & 1 deletion demo/ui-src

This file was deleted.

1 change: 0 additions & 1 deletion external/jquery

This file was deleted.

1 change: 0 additions & 1 deletion external/jquery-ui

This file was deleted.

File renamed without changes.
47 changes: 28 additions & 19 deletions src/jquery.ui.tokenlist.js → jquery.tokenlist.js
@@ -1,17 +1,27 @@
/*!
* jQuery UI Token List @VERSION
* jQuery Token List Plugin
*
* Copyright (c) 2009 Adaptavist.com
* Copyright 2010 Jörn Zaefferer
* Dual licensed under the MIT and GPL licenses.
*/
/* Depends:
* ui.core.js
*
* Based on work by Mark Gibson (http://github.com/jollytoad/jquery.ui-tokenlist)
*
* Depends:
* jquery.ui.widget.js
*/
(function($) {

$.widget('ui.tokenlist', {

options: {
split: /\s*,\s*/,
join: ', ',
removeTip: "Remove Item",
duplicates: false,
validate: false // May be false, an array of allowed values, or a validation function
},

_init: function() {
_create: function() {
var self = this, key = $.ui.keyCode;

if ( !this.options.items ) {
Expand Down Expand Up @@ -117,6 +127,14 @@ $.widget('ui.tokenlist', {
if (self.add($(this).val()).length) {
$(this).val('');
}
}).autocomplete({
source: this.options.validate,
delay: 0,
select: function() {
setTimeout(function() {
self.inputElem.trigger("change.tokenlist");
}, 13);
}
});

// Add the new item input field
Expand Down Expand Up @@ -259,19 +277,10 @@ $.widget('ui.tokenlist', {
.trigger('change');
}
this.element.trigger('change');
}
});

$.extend($.ui.tokenlist, {
getter: "add input items value",
version: "@VERSION",

defaults: {
split: /\s*,\s*/,
join: ', ',
removeTip: "Remove Item",
duplicates: false,
validate: false // Maybe false, an array of allowed values, or a validation function
},

_getData: function(data) {
return this.options[data];
}
});

Expand Down
1 change: 0 additions & 1 deletion src/jquery.ui.autocomplete.js

This file was deleted.

1 change: 0 additions & 1 deletion src/jquery.ui.menu.js

This file was deleted.

1 change: 0 additions & 1 deletion version.txt

This file was deleted.

0 comments on commit 4031aec

Please sign in to comment.