-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dependabot/bundler/jquery-rails-4.4.0
- Loading branch information
Showing
8 changed files
with
303 additions
and
1,066 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,80 @@ | ||
<h1 class="text-center">Chapters</h1> | ||
<div id="chapter-map" class="mb-5"></div> | ||
|
||
<div class="row mt-5"> | ||
<!-- Search container and input --> | ||
<div class="search-container"> | ||
<div class="search-wrapper"> | ||
<span class="search-icon">🔍</span> | ||
<input type="text" id="searchInput" placeholder="Search chapters..."> | ||
</div> | ||
</div> | ||
<!-- Chapter cards --> | ||
<div class="chapters-row"> | ||
<% @chapters.each do |chapter| %> | ||
<% if chapter.active? %> | ||
<% cName = 'chapter-active' %> | ||
<% else %> | ||
<% cName = 'chapter-inactive' %> | ||
<% end %> | ||
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 mb-5"> | ||
<%= link_to chapter_path(chapter) do %> | ||
<div class='card chapter-card <%= cName %>'> | ||
<div class="chapter-img chapter-hover text-center"> | ||
<figure><%= image_tag chapter.image_url, :size => '260x150', :class => 'chapter-img' %></figure> | ||
</div> | ||
<div class="card-body text-center"> | ||
<h4 class="card-title" ><%= chapter.name %> Chapter</h4> | ||
<p class="card-text"><%= chapter.city %>,<% if chapter.state.present? && chapter.state!=chapter.city %> <%= chapter.state %>,<% end %> <%= chapter.country %></p> | ||
<p class="text-muted"><%= pluralize(chapter.past_events.count, "Past event") %></p> | ||
<p class="text-muted"><%= pluralize(chapter.upcoming_events.count, "Upcoming event") %></p> | ||
<%= link_to '', chapter_path(chapter), class:'stretched-link' %> | ||
</div> | ||
<div class="chapter-card <%= chapter.active? ? 'chapter-active' : 'chapter-inactive' %>"> | ||
<div class="chapter-img-container"> | ||
<img src="<%= chapter.image_url %>" alt="<%= chapter.name %>" class="chapter-img"> | ||
</div> | ||
<div class="chapter-status"> | ||
<%= chapter.active? ? 'Active' : 'Inactive' %> | ||
</div> | ||
<div class="card-body"> | ||
<h3 class="card-title"><%= chapter.name %></h3> | ||
<p class="card-text"><%= chapter.city %>,<% if chapter.state.present? && chapter.state!=chapter.city %> <%= chapter.state %>,<% end %> <%= chapter.country %></p> | ||
<div class="upcoming-events"> | ||
<span class="event-icon">🔜</span> | ||
<span class="text-muted"><%= chapter.upcoming_events.count %> upcoming events</span> | ||
</div> | ||
<div class="chapter-details"> | ||
<div class="event-count"> | ||
<span class="event-icon">📅</span> | ||
<span class="text-muted"><%= chapter.past_events.count %> past events</span> | ||
</div> | ||
<% end %> | ||
<a href="<%= chapter_path(chapter) %>" class="learn-more">Learn More</a> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> | ||
</div> | ||
|
||
<!-- JavaScript code for dynamic functionality --> | ||
<script> | ||
$(document).ready(function() { | ||
$(".chapter-card" ).hover( | ||
function() { | ||
$(this).addClass('shadow-lg chapter-zoom').css('cursor', 'pointer') | ||
}, function() { | ||
$(this).removeClass('shadow-lg chapter-zoom') | ||
} | ||
) | ||
}) | ||
</script> | ||
(function () { | ||
const existingCards = Array.from(document.querySelectorAll(".chapter-card")); | ||
const searchInput = document.getElementById("searchInput"); | ||
|
||
// Create a search index | ||
const searchIndex = existingCards.map(card => ({ | ||
element: card, | ||
title: card.querySelector(".card-title").textContent.toLowerCase(), | ||
location: card.querySelector(".card-text").textContent.toLowerCase() | ||
})); | ||
|
||
// Debounce function | ||
const debounce = (func, delay) => { | ||
let timeoutId; | ||
return (...args) => { | ||
clearTimeout(timeoutId); | ||
timeoutId = setTimeout(() => func.apply(null, args), delay); | ||
}; | ||
}; | ||
|
||
// Optimized search function | ||
const performSearch = debounce((query) => { | ||
const searchQuery = query.toLowerCase(); | ||
|
||
requestAnimationFrame(() => { | ||
searchIndex.forEach(item => { | ||
const isVisible = item.title.includes(searchQuery) || item.location.includes(searchQuery); | ||
item.element.style.display = isVisible ? "" : "none"; | ||
}); | ||
}); | ||
}, 250); | ||
|
||
searchInput.addEventListener("input", function() { | ||
performSearch(this.value); | ||
}); | ||
})(); | ||
</script> | ||
<%= render partial: 'chapters/chapter_map_loader', | ||
locals: { chapter_address: @chapter_address, map_area_id: 'chapter-map' } %> | ||
locals: { chapter_address: @chapter_address, map_area_id: 'chapter-map' } %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.