Skip to content

Commit

Permalink
Allow spaces in tags
Browse files Browse the repository at this point in the history
Fixes #4

I've also done some (manual) testing of things like commas, other punctuation,
cyrillic and chinese characters.

It would be good (but low-priority) to write a few proper tests for awkward tag contents.
  • Loading branch information
danohu committed Jan 8, 2015
1 parent 2d3a52e commit 1bb4c11
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 0 additions & 1 deletion drupal_annotation/annotation.store.inc
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ function annotation_api_search() {
$quote = isset($_GET['quote']) ? $_GET['quote'] : NULL;
$uri = isset($_GET['uri']) ? $_GET['uri'] : NULL;
$nid = isset($_GET['nid']) ? $_GET['nid'] : NULL;
$tags = isset($_GET['tags']) ? explode(',', $tags) : NULL;

// Initiate query
$query = new EntityFieldQuery();
Expand Down
14 changes: 14 additions & 0 deletions drupal_annotator/js/annotator_tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,25 @@
if(Drupal.settings.autocomplete_terms.indexOf(annotation.tags[i]) == -1){
Drupal.settings.autocomplete_terms.push(annotation.tags[i]);
}

}
}
Drupal.behaviors.annotatorTags = {
attach: function (context, settings) {
Drupal.Annotator.annotator('addPlugin', 'Tags', {

parseTags: function(string) {
return [$.trim(string)];
},
stringifyTags: function(array) {
if(array.length > 1){
console.log('stringifyTags unexpectedly received multiple tags: ');
console.log(array);
}
return array.join(",");
},


onInit: function(that){
that.annotator.subscribe('annotationEditorSubmit', add_tags_to_autocomplete)
jQuery(that.field).find(':input').autocomplete({
Expand Down

0 comments on commit 1bb4c11

Please sign in to comment.