Rev | Line | |
---|
[44] | 1 | function 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.