Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An option for getting rid of a duplicate tag char typed by the user. #42

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ a little description and the default value:
| **pre-tags-separator** | `String` | `", "` | This is used to `split` the initial text and add `preexistint-tag`. By default, you must put new tags using a comma and a space (`", "`). |
| **tag-box-class** | `String` | `"tagging"` | Class of the tag box. |
| **tag-char** | `String` | `"#"` | Single Tag char. |
| **no-duplicate-tag-char** | `Boolean` | `false` | True to remove a tag char typed by the user. |
| **tag-class** | `String` | `"tag"` | Single Tag class. |
| **tag-on-blur** | `Boolean` | `true` | If `true`, clicking away from the `$type_zone` will add a new tag. |
| **tags-input-name** | `String` | `"tag"` | Name to use as `name=""` in single tags' input. By default, all tags being passed as array like `tag[]`. |
Expand Down
6 changes: 6 additions & 0 deletions tagging.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"pre-tags-separator": ", ", // By default, you must put new tags using a new line
"tag-box-class": "tagging", // Class of the tag box
"tag-char": "#", // Single Tag char
"no-duplicate-tag-char": false, // True to remove a tag char typed by the user
"tag-class": "tag", // Single Tag class
"tags-input-name": "tag", // Name to use as name="" in single tags (by default tag[])
"tag-on-blur": true, // Add the current tag if user clicks away from type-zone
Expand Down Expand Up @@ -131,6 +132,11 @@
text = text.toLowerCase();
}

// If tag-char already given remove it
if ( self.config[ "no-duplicate-tag-char" ] && text.charAt(0) === self.config[ "tag-char" ] ) {
text = text.substring(1);
}

// Checking if text is a Forbidden Word
l = forbidden_words.length;
while ( l-- ) {
Expand Down