Skip to content

Commit

Permalink
Simplify code to reset attachment fields
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
javierm committed Jul 13, 2021
1 parent 8cdee16 commit acbd1b0
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 14 deletions.
5 changes: 0 additions & 5 deletions app/assets/javascripts/documentable.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,6 @@
"_method": "delete"
},
complete: function() {
$(data.cachedAttachmentField).val("");
$(data.addAttachmentLabel).show();
App.Documentable.clearFilename(data);
App.Documentable.clearInputErrors(data);
App.Documentable.clearProgressBar(data);
App.Documentable.unlockUploads();
$(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");
Expand Down
9 changes: 0 additions & 9 deletions app/assets/javascripts/imageable.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
$("#nested-image").on("cocoon:after-remove", function() {
$("#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) {
var input;
$("#new_image_link").addClass("hide");
Expand Down Expand Up @@ -137,12 +134,6 @@
"_method": "delete"
},
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");
$(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");
Expand Down

0 comments on commit acbd1b0

Please sign in to comment.