Skip to content

Commit 24746ee

Browse files
authored
Merge pull request #6 from RabbiIslamRony/licensing-search
Added search support
2 parents 6f54c7e + d6a7080 commit 24746ee

4 files changed

Lines changed: 45 additions & 4 deletions

File tree

includes/licensing/assets/script.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,30 @@ function handlePostRequest(formSelector, endpoint, successCallback, errorCallbac
211211
});
212212
}
213213

214+
function handleSearch({ inputSelector, searchGroups }) {
215+
const searchInput = document.querySelector(inputSelector);
216+
if (!searchInput) return;
217+
218+
searchInput.addEventListener('input', function () {
219+
const query = this.value.toLowerCase();
220+
221+
searchGroups.forEach(group => {
222+
const container = document.querySelector(group.containerSelector);
223+
if (!container) return;
224+
225+
const items = container.querySelectorAll(group.itemSelector);
226+
227+
items.forEach(item => {
228+
const title = item.querySelector(group.titleSelector)?.textContent.toLowerCase() || '';
229+
const description = item.querySelector(group.descriptionSelector)?.textContent.toLowerCase() || '';
230+
231+
item.style.display = (title.includes(query) || description.includes(query)) ? '' : 'none';
232+
});
233+
});
234+
});
235+
}
236+
237+
214238
document.addEventListener("DOMContentLoaded", function () {
215239

216240
handlePostRequest(
@@ -548,4 +572,21 @@ document.addEventListener("DOMContentLoaded", function () {
548572
initializeDirectoristTabs(".directorist-tabs", ".directorist-nav-tab", ".directorist-tabs-item");
549573
handlePricingTabClick(".directorist-nav-tab-wrapper", "button", ".directorist-nav-tab-wrapper");
550574
progressbar(".directorist-progress-inner");
575+
handleSearch({
576+
inputSelector: '.directorist-product-search-input',
577+
searchGroups: [
578+
{
579+
containerSelector: '#directorist-extensions .directorist-row',
580+
itemSelector: '#directorist-extensions .directorist-col-xxl-3',
581+
titleSelector: '.directorist-extension-title',
582+
descriptionSelector: '.directorist-extension-description'
583+
},
584+
{
585+
containerSelector: '#directorist-templates .directorist-row',
586+
itemSelector: '#directorist-templates .directorist-col-xxl-3',
587+
titleSelector: '.directorist-template-title',
588+
descriptionSelector: '.directorist-template-description'
589+
}
590+
]
591+
});
551592
});

includes/licensing/assets/scss/components/components.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@
799799
}
800800

801801
&-input {
802-
&[type=text] {
802+
&[type=search] {
803803
font-size: 12px;
804804
font-style: normal;
805805
font-weight: 400;

includes/licensing/assets/style.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/licensing/views/templates-extensions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
</svg>
4949
</span>
5050

51-
<input type="text" placeholder="<?php esc_html_e( 'Search...', 'directorist' ); ?>" class="directorist-product-search-input">
51+
<input type="search" placeholder="<?php esc_html_e( 'Search...', 'directorist' ); ?>" class="directorist-product-search-input">
5252
</div>
5353
</div>
5454

0 commit comments

Comments
 (0)