diff --git a/client/src/annotator_ui.js b/client/src/annotator_ui.js
index b3afe214f..e5ff723f1 100644
--- a/client/src/annotator_ui.js
+++ b/client/src/annotator_ui.js
@@ -72,7 +72,7 @@ var AnnotatorUI = (function($, window, undefined) {
// utility function, originally for stripping numerix suffixes
// from arc types (e.g. "Theme2" -> "Theme"). For values
// without suffixes (including non-strings), returns given value.
- if (typeof(s) != "string") {
+ if (typeof(s) != "string") {
return s; // can't strip
}
var m = s.match(/^(.*?)(\d*)$/);
@@ -128,7 +128,7 @@ var AnnotatorUI = (function($, window, undefined) {
// in rapid annotation mode, prioritize the keys 0..9 for the
// ordered choices in the quick annotation dialog.
- if (Configuration.rapidModeOn && rapidAnnotationDialogVisible &&
+ if (Configuration.rapidModeOn && rapidAnnotationDialogVisible &&
"0".charCodeAt() <= code && code <= "9".charCodeAt()) {
var idx = String.fromCharCode(code);
var $input = $('#rapid_span_'+idx);
@@ -602,7 +602,7 @@ var AnnotatorUI = (function($, window, undefined) {
eLeft = Math.min(Math.max(eLeft,0), screenWidth - elementWidth);
} else {
eLeft = 0;
- }
+ }
if (screenHeight > elementHeight) {
eTop = Math.min(Math.max(eTop,0), screenHeight - elementHeight);
} else {
@@ -672,7 +672,7 @@ var AnnotatorUI = (function($, window, undefined) {
}
$('#span_selected').text(spanText);
- var encodedText = encodeURIComponent(spanText);
+ var encodedText = encodeURIComponent(spanText);
$.each(searchConfig, function(searchNo, search) {
$('#span_'+search[0]).attr('href', search[1].replace('%s', encodedText));
});
@@ -880,8 +880,17 @@ var AnnotatorUI = (function($, window, undefined) {
var shownCount = 0;
$.each(attrTypes, function(attrNo, attr) {
var $input = $('#'+category+'_attr_'+Util.escapeQuotes(attr.type));
- var showAttr = showAllAttributes || $.inArray(attr.type, validAttrs) != -1;
- if (showAttr) {
+ var attrIsApplicable = $.inArray(attr.type, validAttrs) != -1;
+ if (attrIsApplicable) {
+ // If attribute is not currently showing, then reset form value to default.
+ if ($input.closest('.attribute_type_label').css('display') == 'none') {
+ $input.val(attr.default).change();
+ }
+ } else {
+ $input.val('').change(); // clear form value to avoid submitting inapplicable default value
+ }
+
+ if (showAllAttributes || attrIsApplicable) {
// $input.button('widget').parent().show();
$input.closest('.attribute_type_label').show();
shownCount++;
@@ -895,12 +904,12 @@ var AnnotatorUI = (function($, window, undefined) {
showValidAttributes = function() {
var type = $('#span_form input:radio:checked').val();
-
+
showAllAttributes = false;
-
+
var entityAttrCount = showAttributesFor(entityAttributeTypes, 'entity', type);
var eventAttrCount = showAttributesFor(eventAttributeTypes, 'event', type);
-
+
// show attribute frames only if at least one attribute is
// shown, and set size classes appropriately
if (eventAttrCount > 0) {
@@ -975,7 +984,7 @@ var AnnotatorUI = (function($, window, undefined) {
var $label = $('').
attr('for', 'rapid_span_' + (typeNo+1)).
text(name+' (' + (100.0 * prob).toFixed(1) + '%)');
- $label.css('background-color', spanBgColor);
+ $label.css('background-color', spanBgColor);
// TODO: check for unnecessary extra wrapping here
var $content = $('
').
append($numlabel).
@@ -1016,7 +1025,7 @@ var AnnotatorUI = (function($, window, undefined) {
});
// fill in some space and the special "Other" option, with key "0" (zero)
$spanTypeDiv.append($('
')); // non-breaking space
- var $numlabel = $('0:');
+ var $numlabel = $('0:');
var $input = $('');
var $label = $('');
var $content = $('').
@@ -1074,7 +1083,7 @@ var AnnotatorUI = (function($, window, undefined) {
// TODO: better response to failure
dispatcher.post('messages', [[['Lookup error', 'warning', -1]]]);
return false;
- }
+ }
// set input style according to whether we have a valid value
var $idinput = $('#span_norm_id');
// TODO: make sure the key echo in the response matches the
@@ -1187,7 +1196,7 @@ var AnnotatorUI = (function($, window, undefined) {
};
var normSearchSubmit = function(evt) {
if (normSearchSubmittable) {
- var selectedId = $('#norm_search_id').val();
+ var selectedId = $('#norm_search_id').val();
var selectedTxt = $('#norm_search_query').val();
normSubmit(selectedId, selectedTxt);
@@ -1291,7 +1300,7 @@ var AnnotatorUI = (function($, window, undefined) {
}
// blank the table
$('#norm_search_result_select thead').empty();
- $('#norm_search_result_select tbody').empty();
+ $('#norm_search_result_select tbody').empty();
// TODO: support for two (or more) dialogs open at the same time
// so we don't need to hide this before showing normSearchDialog
dispatcher.post('hideForm');
@@ -1359,7 +1368,7 @@ var AnnotatorUI = (function($, window, undefined) {
// do not allow equiv<->non-equiv change options
if (arcType && isEquiv != isThisEquiv) return;
- var displayName = ((arcDesc.labels && arcDesc.labels[0]) ||
+ var displayName = ((arcDesc.labels && arcDesc.labels[0]) ||
arcTypeName);
var $input = $('');
var $label = $('').text(displayName);
@@ -1755,7 +1764,7 @@ var AnnotatorUI = (function($, window, undefined) {
// but this is clumsy and suboptimal (user may have scrolled
// during the ajax invocation); think of a better way.
lastRapidAnnotationEvent = evt;
- dispatcher.post('ajax', [ {
+ dispatcher.post('ajax', [ {
action: 'suggestSpanTypes',
collection: coll,
'document': doc,
@@ -1766,7 +1775,7 @@ var AnnotatorUI = (function($, window, undefined) {
}, 'suggestedSpanTypes']);
}
}
- };
+ };
var onMouseUp = function(evt) {
if (that.user === null) return;
@@ -1866,9 +1875,9 @@ var AnnotatorUI = (function($, window, undefined) {
$('#arc_roles, #span_roles').on('click', '.collapser', collapseHandler);
var spanFormSubmitRadio = function(evt) {
+ showValidAttributes();
+ showValidNormalizations();
if (Configuration.confirmModeOn) {
- showValidAttributes();
- showValidNormalizations();
$('#span_form-ok').focus();
} else {
spanFormSubmit(evt, $(evt.target));
@@ -1964,10 +1973,10 @@ var AnnotatorUI = (function($, window, undefined) {
} else if (attr.bool) {
var escapedName = Util.escapeQuotes(attr.name);
var $input = $('');
var $label = $('');
$span.append($input).append($label);
$input.button();
@@ -1995,7 +2004,7 @@ var AnnotatorUI = (function($, window, undefined) {
// disable not only categories of types (events or entities),
// but the specific set of types that are incompatible with
// the current attribute settings.
-
+
// just assume all attributes are event attributes
// TODO: support for entity attributes
// TODO2: the above comment is almost certainly false, check and remove
@@ -2286,7 +2295,7 @@ var AnnotatorUI = (function($, window, undefined) {
return attributes;
}
- var spanAndAttributeTypesLoaded = function(_spanTypes,
+ var spanAndAttributeTypesLoaded = function(_spanTypes,
_entityAttributeTypes,
_eventAttributeTypes,
_relationTypesHash) {
@@ -2346,7 +2355,7 @@ var AnnotatorUI = (function($, window, undefined) {
// TODO: why are these globals defined here instead of at the top?
var spanForm = $('#span_form');
var rapidSpanForm = $('#rapid_span_form');
-
+
var deleteSpan = function() {
if (Configuration.confirmModeOn && !confirm("Are you sure you want to delete this annotation?")) {
return;
@@ -2411,7 +2420,7 @@ var AnnotatorUI = (function($, window, undefined) {
$roles.append($role).append($label);
});
var $roleButtons = $roles.find('input').button();
-
+
dispatcher.post('showForm', [splitForm]);
};
@@ -2534,7 +2543,7 @@ var AnnotatorUI = (function($, window, undefined) {
dispatcher.post('initForm', [rapidSpanForm, {
alsoResize: '#rapid_span_types',
- width: 400,
+ width: 400,
close: function(evt) {
keymap = null;
}