Simplify code to reset attachment fields

Since elements are created and destroyed, we don't have to do any kind
of "reset" before destroying or creating them. We would have to do so if
we were just hiding the elements in order to show them again later, but
that's not the case.
This commit is contained in:
Javi Martín
2021-07-12 03:19:34 +02:00
parent 8cdee167f8
commit acbd1b0239
2 changed files with 0 additions and 14 deletions

View File

@@ -134,11 +134,6 @@
"_method": "delete" "_method": "delete"
}, },
complete: function() { complete: function() {
$(data.cachedAttachmentField).val("");
$(data.addAttachmentLabel).show();
App.Documentable.clearFilename(data);
App.Documentable.clearInputErrors(data);
App.Documentable.clearProgressBar(data);
App.Documentable.unlockUploads(); App.Documentable.unlockUploads();
$(data.wrapper).find(".attachment-actions").addClass("small-12").removeClass("small-6 float-right"); $(data.wrapper).find(".attachment-actions").addClass("small-12").removeClass("small-6 float-right");
$(data.wrapper).find(".attachment-actions .action-remove").addClass("small-3").removeClass("small-12"); $(data.wrapper).find(".attachment-actions .action-remove").addClass("small-3").removeClass("small-12");

View File

@@ -8,9 +8,6 @@
$("#nested-image").on("cocoon:after-remove", function() { $("#nested-image").on("cocoon:after-remove", function() {
$("#new_image_link").removeClass("hide"); $("#new_image_link").removeClass("hide");
}); });
$("#nested-image").on("cocoon:before-insert", function() {
$(".js-image-attachment").closest(".image").remove();
});
$("#nested-image").on("cocoon:after-insert", function(e, nested_image) { $("#nested-image").on("cocoon:after-insert", function(e, nested_image) {
var input; var input;
$("#new_image_link").addClass("hide"); $("#new_image_link").addClass("hide");
@@ -137,12 +134,6 @@
"_method": "delete" "_method": "delete"
}, },
complete: function() { complete: function() {
$(data.cachedAttachmentField).val("");
$(data.addAttachmentLabel).show();
App.Imageable.clearFilename(data);
App.Imageable.clearInputErrors(data);
App.Imageable.clearProgressBar(data);
App.Imageable.clearPreview(data);
$("#new_image_link").removeClass("hide"); $("#new_image_link").removeClass("hide");
$(data.wrapper).find(".attachment-actions").addClass("small-12").removeClass("small-6 float-right"); $(data.wrapper).find(".attachment-actions").addClass("small-12").removeClass("small-6 float-right");
$(data.wrapper).find(".attachment-actions .action-remove").addClass("small-3").removeClass("small-12"); $(data.wrapper).find(".attachment-actions .action-remove").addClass("small-3").removeClass("small-12");