Commit 9005f2e8 by lduarte1991

Annotations Tools: spacing and comment fixes - will be squashed

parent d6549d2e
...@@ -1028,22 +1028,24 @@ Annotator.Plugin.HighlightTags = (function(_super) { ...@@ -1028,22 +1028,24 @@ Annotator.Plugin.HighlightTags = (function(_super) {
return getColorValues(item) return getColorValues(item)
} }
HighlightTags.prototype.colorize = function(){ HighlightTags.prototype.colorize = function() {
var annotations = Array.prototype.slice.call($(".annotator-hl")); var annotations = Array.prototype.slice.call($(".annotator-hl"));
for (annNum = 0; annNum < annotations.length; ++annNum){ for (annNum = 0; annNum < annotations.length; ++annNum) {
var anns = $.data(annotations[annNum],"annotation"); var anns = $.data(annotations[annNum],"annotation");
if (typeof anns.tags != "undefined" && anns.tags.length == 0) { if (typeof anns.tags !== "undefined" && anns.tags.length == 0) {
// image annotations should not change the background of the highlight // image annotations should not change the background of the highlight
// only the border so as not to block the image behind it. // only the border so as not to block the image behind it.
if (anns.media !== "image") { if (anns.media !== "image") {
$(annotations[annNum]).css("background-color",""); $(annotations[annNum]).css("background-color", "");
} else { } else {
$(annotations[annNum]).css("border", "2px solid rgb(255, 255, 255)"); $(annotations[annNum]).css("border", "2px solid rgb(255, 255, 255)");
$(annotations[annNum]).css("outline", "2px solid rgb(0, 0, 0)"); $(annotations[annNum]).css("outline", "2px solid rgb(0, 0, 0)");
} }
} }
if (typeof anns.tags != "undefined" && this.colors !== {}) {
if (typeof anns.tags !== "undefined" && this.colors !== {}) {
for (var index = 0; index < anns.tags.length; ++index) { for (var index = 0; index < anns.tags.length; ++index) {
if (anns.tags[index].indexOf("flagged-") == -1) { if (anns.tags[index].indexOf("flagged-") == -1) {
...@@ -1079,7 +1081,7 @@ Annotator.Plugin.HighlightTags = (function(_super) { ...@@ -1079,7 +1081,7 @@ Annotator.Plugin.HighlightTags = (function(_super) {
} else { } else {
// if there are no tags or predefined colors, keep the background at default // if there are no tags or predefined colors, keep the background at default
if (anns.media !== "image"){ if (anns.media !== "image") {
$(annotations[annNum]).css("background",""); $(annotations[annNum]).css("background","");
} }
} }
...@@ -1088,31 +1090,38 @@ Annotator.Plugin.HighlightTags = (function(_super) { ...@@ -1088,31 +1090,38 @@ Annotator.Plugin.HighlightTags = (function(_super) {
this.annotator.publish('colorizeCompleted'); this.annotator.publish('colorizeCompleted');
} }
HighlightTags.prototype.updateField = function(field, annotation){ HighlightTags.prototype.updateField = function(field, annotation) {
// the first time that this plug in runs, the predetermined instructor tags are
// added and stored for the dropdown list
if(this.isFirstTime){ if(this.isFirstTime) {
var tags = this.options.tag.split(","); var tags = this.options.tag.split(",");
var tokensavailable = []; var tokensavailable = [];
tags.forEach (function(tagnames){
lonename = tagnames.split(":");
tokensavailable.push({'id': lonename[0], 'name':lonename[0]}); // tags are given the structure that the dropdown/token function requires
tags.forEach (function(tagnames) {
lonename = tagnames.split(":");
tokensavailable.push({'id': lonename[0], 'name': lonename[0]});
}); });
// they are then added to the appropriate input for tags in annotator
$("#tag-input").tokenInput(tokensavailable); $("#tag-input").tokenInput(tokensavailable);
this.isFirstTime = false; this.isFirstTime = false;
} }
$('#token-input-tag-input').attr('placeholder','Add tags...');
$('#token-input-tag-input').attr('placeholder', 'Add tags...');
$('#tag-input').tokenInput('clear'); $('#tag-input').tokenInput('clear');
if (typeof annotation.tags != "undefined") {
for (tagnum = 0; tagnum < annotation.tags.length; tagnum++){ // loops through the tags already in the annotation and "add" them to this annotation
if (typeof annotation.tags !== "undefined") {
for (tagnum = 0; tagnum < annotation.tags.length; tagnum++) {
var n = annotation.tags[tagnum]; var n = annotation.tags[tagnum];
if (typeof this.annotator.plugins["HighlightTags"] != 'undefined') { if (typeof this.annotator.plugins["HighlightTags"] !== 'undefined') {
if (annotation.tags[tagnum].indexOf("flagged-")==-1){ // if there are flags, we must ignore them
if (annotation.tags[tagnum].indexOf("flagged-") == -1) {
$('#tag-input').tokenInput('add',{'id':n,'name':n}); $('#tag-input').tokenInput('add',{'id':n,'name':n});
} }
} else{ } else {
$('#tag-input').tokenInput('add',{'id':n,'name':n}); $('#tag-input').tokenInput('add', {'id': n, 'name': n});
} }
} }
} }
...@@ -1142,7 +1151,7 @@ Annotator.Plugin.HighlightTags = (function(_super) { ...@@ -1142,7 +1151,7 @@ Annotator.Plugin.HighlightTags = (function(_super) {
}); });
} }
//The following function is run when a person hits submit. // The following function is run when a person hits submit.
HighlightTags.prototype.pluginSubmit = function(field, annotation) { HighlightTags.prototype.pluginSubmit = function(field, annotation) {
var tokens = Array.prototype.slice.call($(".token-input-input-token").parent().find('.token-input-token')); var tokens = Array.prototype.slice.call($(".token-input-input-token").parent().find('.token-input-token'));
var arr = []; var arr = [];
...@@ -1153,16 +1162,21 @@ Annotator.Plugin.HighlightTags = (function(_super) { ...@@ -1153,16 +1162,21 @@ Annotator.Plugin.HighlightTags = (function(_super) {
annotation.tags = arr; annotation.tags = arr;
} }
//The following allows you to edit the annotation popup when the viewer has already // The following allows you to edit the annotation popup when the viewer has already
//hit submit and is just viewing the annotation. // hit submit and is just viewing the annotation.
HighlightTags.prototype.updateViewer = function(field, annotation) { HighlightTags.prototype.updateViewer = function(field, annotation) {
if (typeof annotation.tags != "undefined") { if (typeof annotation.tags != "undefined") {
// if there are no tags, the space for tags in the pop up is removed and function ends
if (annotation.tags.length == 0) { if (annotation.tags.length == 0) {
$(field).remove(); $(field).remove();
return; return;
} }
// otherwise we prepare to loop through them
var nonFlagTags = true; var nonFlagTags = true;
var tokenList = "<ul class=\"token-input-list\">"; var tokenList = "<ul class=\"token-input-list\">";
for (tagnum = 0; tagnum < annotation.tags.length; ++tagnum){ for (tagnum = 0; tagnum < annotation.tags.length; ++tagnum){
if (typeof this.annotator.plugins["Flagging"] !== 'undefined') { if (typeof this.annotator.plugins["Flagging"] !== 'undefined') {
// once again we ingore flags // once again we ingore flags
...@@ -1190,18 +1204,20 @@ Annotator.Plugin.HighlightTags = (function(_super) { ...@@ -1190,18 +1204,20 @@ Annotator.Plugin.HighlightTags = (function(_super) {
} }
tokenList += "</ul>"; tokenList += "</ul>";
$(field).append(tokenList); $(field).append(tokenList);
// the field for tags is removed also if all the tags ended up being flags
if (nonFlagTags) { if (nonFlagTags) {
$(field).remove(); $(field).remove();
} }
} else{ } else {
$(field).remove(); $(field).remove();
} }
this.annotator.publish("finishedDrawingTags"); this.annotator.publish("finishedDrawingTags");
} }
//The following will call the colorize function during an external call and then return // The following will call the colorize function during an external call and then return
//an event signaling completion. // an event signaling completion.
HighlightTags.prototype.externalCall = function() { HighlightTags.prototype.externalCall = function() {
this.colorize(); this.colorize();
this.annotator.publish('finishedExternalCallToHighlightTags'); this.annotator.publish('finishedExternalCallToHighlightTags');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment