diff --git a/admin/themes/default/javascripts/elements.js b/admin/themes/default/javascripts/elements.js index c1e9e21e4..3abcf1736 100644 --- a/admin/themes/default/javascripts/elements.js +++ b/admin/themes/default/javascripts/elements.js @@ -53,10 +53,20 @@ Omeka.Elements = {}; }); fieldDiv.html(response); fieldDiv.trigger('omeka:elementformload'); - } + fieldDiv.find('.add-element').focus(); + setTimeout(() => { + Omeka.Elements.alertElementChange('element-' + elementId, fieldDiv); + }, 2000); + } }); }; + Omeka.Elements.alertElementChange = function (elementId, fieldDiv) { + var alertsDiv = $('#' + elementId + '-alerts'); + var rowCount = fieldDiv.find('.input-block').length; + alertsDiv.find('span.count').text(rowCount); + } + /** * Set up add/remove element buttons for ElementText inputs. * @@ -93,7 +103,7 @@ Omeka.Elements = {}; context.find(addSelector).click(function (event) { event.preventDefault(); var fieldDiv = $(this).parents(fieldSelector); - + Omeka.Elements.elementFormRequest(fieldDiv, {add: '1'}, elementFormPartialUrl, recordType, recordId); }); @@ -101,6 +111,8 @@ Omeka.Elements = {}; context.find(removeSelector).click(function (event) { event.preventDefault(); var removeButton = $(this); + var fieldDiv = $(this).parents(fieldSelector); + var elementId = fieldDiv.attr('id'); // Don't delete the last input block for an element. if (removeButton.parents(fieldSelector).find(inputBlockSelector).length === 1) { @@ -117,6 +129,11 @@ Omeka.Elements = {}; }); inputBlock.remove(); + fieldDiv.find('textarea').last().focus(); + setTimeout(() => { + Omeka.Elements.alertElementChange(elementId, fieldDiv); + }, 2000); + // Hide remove buttons for fields with one input. $(fieldSelector).each(function () { var removeButtons = $(this).find(removeSelector); diff --git a/application/views/helpers/ElementForm.php b/application/views/helpers/ElementForm.php index cc3ef5bf5..cc2178baa 100644 --- a/application/views/helpers/ElementForm.php +++ b/application/views/helpers/ElementForm.php @@ -87,7 +87,10 @@ public function elementForm(Element $element, Omeka_Record_AbstractRecord $recor } // Compose html for element form - $html = $divWrap ? '