forked from ioncache/Tag-Handler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
executable file
·215 lines (163 loc) · 8.32 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
jQuery Tag Handler v1.0.1
Copyright (C) 2010 Mark Jubenville
Mark Jubenville - [email protected]
http://ioncache.github.com/Tag-Handler
Development time supported by:
Raybec Communications
http://www.raybec.com
http://www.mysaleslink.com
Modified by Javier Fernandez Escribano - [email protected]
Added autocomplete queries as the user writes
Development time supported by:
Tourist Eye
http://www.touristeye.com
Based heavily on:
Tag it! by Levy Carneiro Jr (http://levycarneiro.com/)
http://levycarneiro.com/projects/tag-it/example.html
http://github.com/levycarneiro/tag-it
http://plugins.jquery.com/project/tag-it
Tag icons/cursors converted from:
From the famfamfam.com Silk icon set:
http://www.famfamfam.com/lab/icons/silk/
Loader image created at:
Preloaders.net
http://preloaders.net/
------------------------------------------------------------------------------
Description
------------------------------------------------------------------------------
Tag Handler is a jQuery plugin used for managing tag-type metadata.
------------------------------------------------------------------------------
Basic Usage Instructions
------------------------------------------------------------------------------
* Tag Handler must be attached to one or more <ul> tags in your HTML.
* To add a tag, click on the tag box, type in a name, and hit enter or comma.
* Tags may be removed from the tag box by hitting backspace inside the box or
by clicking on the tag.
* The list of tags may be initialized in 1 of 3 ways:
1. By passing arrays of tag names as options to the plugin
("availableTags" and "assignedTags"); or,
2. By supplying a "getURL" for the tags to be retrieved via AJAX.
When using this method, the server must supply a JSON formatted array
named "availableTags" and optionally an additional array named
"assignedTags".
3. By supplying a "getURL" and initLoad: false.
When using this method, it will get the "assignedTags" from the array as in
method 1. When the user writes a tag, it will query the server searching for
similar tags.
Either way, the information from these 3 methods will be used in the
following manner:
availableTags: each item in this array will populate the autocomplete
drop-down list
assignedTags: each item this array will become a tag in the tag box
* Tags may be sent back to the server by supplying an "updateURL". In this case,
an array will be sent back to the server named "tags".
* You can define whether the user can create new tags or select tags only.
* You can define if the user can edit the tags.
* A sample CSS file is included that can be used to help with formatting tags.
------------------------------------------------------------------------------
Plugin Examples
------------------------------------------------------------------------------
Example 1: The Tag Handler will be initialized with no options and no default
tags:
$("#basic_tag_handler").tagHandler();
Example 2: The Tag Handler will be initialized with preset tags from the
assignedTags and availableTags arrays, and autocomplete witll be
turned on:
$("#array_tag_handler").tagHandler({
assignedTags: [ 'Perl' ],
availableTags: [ 'C', 'C++', 'C#', 'Java', 'Perl', 'PHP', 'Python' ],
autocomplete: true
});
Example 3: The Tag Handler will be initialized and pull data via ajax, also
sending some data to the server:
$("#ajaxget_tag_handler").tagHandler({
getData: { id: 'user123', type: 'user' },
getURL: '/ajaxtest/get',
autocomplete: true
});
Example 4: Same as Example 3, but a different user is set in the getData /
UpdateData options and now the tags will save when clicking the save
button:
$("#ajaxupdate_tag_handler").tagHandler({
getData: { id: 'user234', type: 'user' },
getURL: '/ajaxtest/get',
updateData: { id: 'user234', type: 'user' },
updateURL: '/ajaxtest/update',
autocomplete: true
});
Example 5: Same as Example 4, but autoUpdate is true, tags will save
automatically (no save button will be shown):
$("#ajaxautoupdate_tag_handler").tagHandler({
getData: { id: 'user234', type: 'user' },
getURL: '/ajaxtest/get',
updateData: { id: 'user234', type: 'user' },
updateURL: '/ajaxtest/update',
autocomplete: true,
autoUpdate: true
});
Example 6: The Tag Handler will be initialized but it will request the tag list when the user writes more than 2 chars, also sending some data to the server:
$("#ajaxget_tag_handler").tagHandler({
getData: { id: 'user123', type: 'user' },
initLoad: false,
getURL: '/ajaxtest/get',
autocomplete: true,
minChars: 2
});
Example 7: Same as example 6, but the user cannot create new tags:
$("#ajaxget_tag_handler").tagHandler({
getData: { id: 'user123', type: 'user' },
initLoad: false,
getURL: '/ajaxtest/get',
autocomplete: true,
minChars: 2,
allowAdd: false
});
------------------------------------------------------------------------------
Plugin Options
------------------------------------------------------------------------------
Tag data specific options:
--------------------------
Option Description Default Value
-------------- ---------------------------------------------- --------------
assignedTags array to pass a list of already assigned tags []
availableTags array to pass a list of all available tags []
getData data field with info for getURL ''
getURL URL for retrieving tag lists via ajax ''
initLoad: indicates if load all tags at init true
updatetData data field with additional info for updtateURL ''
updateURL URL for saving tags via ajax ''
Miscellaneous options:
----------------------
Option Description Default Value
-------------- ---------------------------------------------- --------------
allowEdit indicates whether the tag list is editable true
allowAdd indicates whether the user can add new tags true
autocomplete requires jqueryui autocomplete plugin false
autoUpdate indicates whether updating occurs automatically false
whenever a tag is added/deleted - if set true,
the save button will not be shown
className base class name that will be added to the tag 'tagHandler'
container
queryname variable name to query the server 'q'
debug will turn on some console logging debug info false
delimiter extra delimiter to use to separate tags ''
note 'enter' and 'comma' are always allowed
sortTags sets sorting of tag names alphabetically true
minChars minimum number of chars to query the server 0
msgNoNewTag message shown when the user cannot add a new "You don't have enough points
tag to create a new tag"
msgError message shown when there is an error loading "There was an error getting
the tags the tag list."
------------------------------------------------------------------------------
License
------------------------------------------------------------------------------
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see < http://www.gnu.org/licenses/ >.