source: trunk/www.guidonia.net/wp/wp-content/plugins/simple-tags/2.7/inc/js/helper-add-tags.js@ 44

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 817 bytes
Line 
1function addTag(tag) {
2 // Trim tag
3 tag = tag.replace( /^\s+/, '' ).replace( /\s+$/, '' );
4
5 if ( document.getElementById("adv-tags-input") ) { // Tags input from Simple Tags
6
7 var tag_entry = document.getElementById("adv-tags-input");
8 if ( tag_entry.value.length > 0 && !tag_entry.value.match(/,\s*$/) ) {
9 tag_entry.value += ", ";
10 }
11
12 var re = new RegExp(tag + ",");
13 if ( !tag_entry.value.match(re) ) {
14 tag_entry.value += tag + ", ";
15 }
16
17 } else { // Default tags input from WordPress
18
19 var newtags = jQuery('#tags-input').val();
20 newtags += ',' + tag;
21
22 // massage
23 newtags = newtags.replace( /\s+,+\s*/g, ',' ).replace( /,+/g, ',' ).replace( /,+\s+,+/g, ',' ).replace( /,+\s*$/g, '' ).replace( /^\s*,+/g, '' );
24 jQuery('#tags-input').val( newtags );
25 tag_update_quickclicks();
26
27 }
28}
Note: See TracBrowser for help on using the repository browser.