Skip to content

Commit a0eab18

Browse files
Sandeshshiftkey
authored andcommitted
Handled unresponsive popular tags
1 parent 90a2f7c commit a0eab18

File tree

1 file changed

+37
-14
lines changed

1 file changed

+37
-14
lines changed

javascripts/main.js

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -154,24 +154,47 @@ define([
154154
});
155155

156156
projectsPanel.find('ul.popular-tags li a').each((i, elem) => {
157-
$(elem).on('click', function () {
158-
selTags = $('.tags-filter').val() || [];
159-
selectedTag = preparePopTagName($(this).text() || '');
157+
$(elem).on('click', function (e) {
158+
e.preventDefault();
159+
const selTags = $('.tags-filter').val() || [];
160+
// Get the tag name from the title attribute which has the clean name
161+
const titleText = $(this).attr('title') || '';
162+
const selectedTag = titleText.replace('Popular Tag: ', '').trim();
163+
160164
if (selectedTag) {
161-
tagID = allTags
162-
.map((tag) => tag.name.toLowerCase())
163-
.indexOf(selectedTag);
164-
if (tagID !== -1) {
165-
selTags.push(selectedTag);
166-
location.href = updateQueryStringParameter(
167-
getFilterUrl(),
168-
'tags',
169-
encodeURIComponent(selTags)
170-
);
165+
// Find the matching tag in allTags
166+
const matchingTag = allTags.find(
167+
(tag) => tag.name.toLowerCase() === selectedTag.toLowerCase()
168+
);
169+
170+
if (matchingTag) {
171+
const actualTagName = matchingTag.name;
172+
// Check if tag is not already selected
173+
if (selTags.indexOf(actualTagName) === -1) {
174+
selTags.push(actualTagName);
175+
}
176+
// Update the select element and trigger chosen update
177+
$('.tags-filter').val(selTags).trigger('chosen:updated').change();
171178
}
172179
}
173180
});
174181
});
182+
183+
// Handle "See More" button functionality
184+
projectsPanel.find('#see-more-btn').on('click', function () {
185+
const hiddenProjects = projectsPanel.find('.project-card.hidden-project');
186+
const projectsToShow = hiddenProjects.slice(0, 9);
187+
188+
projectsToShow.removeClass('hidden-project');
189+
190+
const remainingCount = hiddenProjects.length - projectsToShow.length;
191+
192+
if (remainingCount <= 0) {
193+
$(this).parent('.see-more-container').hide();
194+
} else {
195+
projectsPanel.find('#remaining-count').text(remainingCount);
196+
}
197+
});
175198
};
176199

177200
/*
@@ -348,4 +371,4 @@ define([
348371
app.run('#/');
349372
});
350373
});
351-
});
374+
});

0 commit comments

Comments
 (0)