Skip to content

Commit

Permalink
Dm 4260 fix paginated practice card images (#724)
Browse files Browse the repository at this point in the history
* move `#replaceImagePlaceholders` methods to `_practice_card_utilities`

refactors to be more readable, removes argument as it will always be the same for practice cards

* add include tags for `practice_card_utilities` and `signed_resource`

* add invocation of `replaceImagePlaceholders` where practice cards have been loaded

* edit `practice_card.html.erb` to always render placeholder

* edit invocation of `#replaceImagePlaceholders` to no longer use argument

* edit `#buildPracticeCard` function to include `data-practice-name` in `practice-card-img-placeholder` div

remove `#replaceImagePlaceholders`, `#replacePlaceholderWithImage`, and `#loadImage` functions

update invocation of `#replaceImagePlaceholders` to no longer use argument

edit invocation of `#replaceImagePlaceholders` to no longer use argument

* refactor `#replacePlaceholderWithImage` function as per CodeQl warning: "DOM text reinterpreted as HTML"

* add explicit export of function as per CodeQl warning: "Unused function"

* remove `export` from `replaceImagePlaceholders` function

* add invocation of `replaceImagePlaceholders`

* edit `replacePlaceholderWithImage` function to replace `.practice-card-img-placeholder` div class with `.practice-card-img` class
  • Loading branch information
PhilipDeFraties authored Oct 19, 2023
1 parent 298a716 commit 3e51520
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/assets/javascripts/_practice_card_utilities.es6
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function toggleFocusStylingForPracticeTitle() {
});
}

export function replaceImagePlaceholders() {
function replaceImagePlaceholders() {
$('.dm-practice-card').each(function() {
const placeholder = $(this).find('.practice-card-img-placeholder');

Expand Down Expand Up @@ -67,7 +67,11 @@ function replacePlaceholderWithImage(imageUrl, practiceId, practiceName) {
.addClass('dm-practice-card-img-container')
.append(imgElement);

$('.practice-card-img-placeholder[data-practice-id="' + practiceId + '"]').empty().append(containerDiv);
const placeholder = $('.practice-card-img-placeholder[data-practice-id="' + practiceId + '"]');
placeholder.empty()
.append(containerDiv)
.removeClass('practice-card-img-placeholder')
.addClass('practice-card-img');
});
}

Expand Down
2 changes: 2 additions & 0 deletions app/views/page/show.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ function paginatedPageComponent() {
// If there isn't another set, remove the current 'Load more' link and add proper margin to the container
$(currentPageClass).remove();
<% end %>

replaceImagePlaceholders();
}

$(paginatedPageComponent)

0 comments on commit 3e51520

Please sign in to comment.