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

added tagmanager publicMethod 'extractTagsFromString' #262

Open
wants to merge 1 commit 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 3.0.3-bmaso-extractTagsFromString
* support for new public method "extractTagsFromString"

## 3.0.1 - 2013-12-12

* Issue #180: Add 'tags' method to retrieve tags (LukeL99)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# [Tags Manager v3.0.2](http://welldonethings.com/tags/manager/v3)
# [Tags Manager v3.0.3-bmaso-extractTagsFromString](http://welldonethings.com/tags/manager/v3)

A jQuery plugin to create tag input fields, which works nicely with [Twitter Typeahead.js](http://twitter.github.io/typeahead.js/) and [Twitter Bootstrap](http://twitter.github.com/bootstrap)

Expand Down
2 changes: 1 addition & 1 deletion TagManager.jquery.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "TagManager",
"version": "3.0.2",
"version": "3.0.-extractTagsFromString",
"title": "Tag Manager",
"author": {
"name": "Max Favilli",
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "A jQuery plugin to create tag input fields, which works nicely with Twitter Typeahead.js and Twitter Bootstrap",
"type": "component",
"homepage": "https://github.com/max-favilli/tagmanager",
"version": "3.0.1",
"version": "3.0.3-bmaso-extractTagsFromString",
"license": "MPL",
"authors": [
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "TagManager",
"version": "3.0.1",
"version": "3.0.3-bmaso-extractTagsFromString",
"title": "Tag Manager",
"author": {
"name": "Max Favilli",
Expand Down
22 changes: 21 additions & 1 deletion tagmanager.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* ===================================================
* tagmanager.js v3.0.2
* tagmanager.js v3.0.3-bmaso-extractTagsFromString
* http://welldonethings.com/tags/manager
* ===================================================
* Copyright 2012 Max Favilli
Expand Down Expand Up @@ -241,6 +241,26 @@
tags: function () {
var $self = this, tlis = $self.data("tlis");
return tlis;
},

extractTagsFromString: function(sourceStr) {
var $self = $(this), opts = $self.data('opts'), str = $.trim(sourceStr);
for(var ii=0; ii<str.length; ii++) {
if($.inArray(str.charCodeAt(ii), opts.delimiterChars) != -1) {
str = str.substring(0, ii) + "#" + str.substring(ii+1, str.length);
}
}

var tagsArr = str.split(/[#\s]+/);

//...remove any 0-length members of the response array...
for(var jj=tagsArr.length-1; jj>=0; --jj) {
if(!tagsArr[jj].length) {
tagsArr.splice(jj, 1); // note: Array.prototype.splice is a mutator method, so this changes original array
}
}

return tagsArr;
}
},

Expand Down