Browse Source

Bug 16297 - Remove the use of "onclick" from OAI sets configuration template

In order to bring the OAI sets configuration template into compliance
with coding guideline JS9, this patch changes with way some JavaScript
events are handled by moving JS handling out of the HTML markup.

To test, apply the patch and go to Administration -> OAI sets
configuration.

- Create or edit a set.
- Test the "Add description" link. Clicking it should add a
  description textarea.
- Test the "Remove" link associated with multiple description lines.
  Click them should remove the corresponding textarea.
- Test that additions and removals are saved correctly.

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
16.05.x
Owen Leonard 8 years ago
committed by Kyle M Hall
parent
commit
29292c9f8d
  1. 19
      koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_sets.tt

19
koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_sets.tt

@ -7,13 +7,13 @@ function newDescField() {
$("#adddescription").before(
'<li><label>setDescription: </label>' +
'<textarea style="vertical-align:middle" rows="2" cols="30" name="description"></textarea>' +
'<a onclick="delDescField(this); return false;" href="#"><i class="fa fa-fw fa-trash"></i> Remove</a>' +
'<a class="remove_description" href="#"><i class="fa fa-fw fa-trash"></i> Remove</a>' +
'</li>'
);
}
function delDescField(minusButton) {
var li = $(minusButton).parent('li');
var li = minusButton.parent('li');
$(li).remove();
}
@ -25,6 +25,17 @@ $(document).ready(function() {
$(".delete_oai_set").on("click",function(){
return confirmDelete();
});
$("body").on("click", ".remove_description", function(e){
e.preventDefault();
delDescField($(this));
});
$(".add_description").on("click", function(e){
e.preventDefault();
newDescField();
});
});
//]]>
</script>
@ -67,10 +78,10 @@ $(document).ready(function() {
<li>
<label>setDescription: </label>
<textarea style="vertical-align:middle" rows="2" cols="30" name="description">[% desc.description %]</textarea>
<a onclick="delDescField(this); return false;" href="#"><i class="fa fa-fw fa-trash"></i> Remove</a>
<a class="remove_description" href="#"><i class="fa fa-fw fa-trash"></i> Remove</a>
</li>
[% END %]
<li id="adddescription"><span class="label">&nbsp;</span><a href="#" onclick='newDescField(); return false;'><i class="fa fa-fw fa-plus"></i> Add description</a></li>
<li id="adddescription"><span class="label">&nbsp;</span><a href="#" class="add_description"><i class="fa fa-fw fa-plus"></i> Add description</a></li>
</ol>
</fieldset>

Loading…
Cancel
Save