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 = $('