Add Live Filter to Map - partial
This commit is contained in:
@ -94,10 +94,17 @@
|
||||
margin:25px 0;
|
||||
}
|
||||
}
|
||||
.map-buttons button {
|
||||
.map-buttons button,
|
||||
.map-buttons .input-group{
|
||||
width:300px;
|
||||
}
|
||||
|
||||
.map-buttons .input-group{
|
||||
margin-top: 10px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.map-accordion {
|
||||
margin: 140px auto 0;
|
||||
width:700px;
|
||||
|
@ -391,6 +391,36 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
|
||||
// live filter
|
||||
$('#map-filter').on('keyup', () => {
|
||||
if($('#map-filter').val().length > 1) {
|
||||
var regex = new RegExp($('#map-filter').val().replace(/ /g, '-'), "gi");
|
||||
$('.challenge-title').each((index, title) => {
|
||||
//console.log("title:", JSON.stringify(title));
|
||||
if(regex.test($(title).attr('name'))) {
|
||||
$(title).removeClass('hidden');
|
||||
} else {
|
||||
$(title).addClass('hidden');
|
||||
}
|
||||
|
||||
});
|
||||
$.each($('.map-collapse'), function(i, div) {
|
||||
console.log("bing");
|
||||
if ($(div).find('.hidden').length ===
|
||||
$(div).find('p').length) {
|
||||
console.log("hiding parents");
|
||||
$(div).addClass('hidden');
|
||||
$(div).find('h3').addClass('hidden');
|
||||
$(div).prev('h2').addClass('hidden');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$('.challenge-title').each((title) => {
|
||||
$(title).removeClass('hidden');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// keyboard shortcuts: open map
|
||||
window.Mousetrap.bind('g m', function() {
|
||||
var isCollapsed = $('.map-aside').hasClass('is-collapsed');
|
||||
|
@ -4,6 +4,11 @@ block content
|
||||
p Challenges required for certifications are marked with a *
|
||||
.row.map-buttons
|
||||
button.center-block.btn.btn-sm.btn-block.btn-primary.active#showAll Collapse all challenges
|
||||
.row.map-buttons
|
||||
.input-group
|
||||
input#map-filter.form-control(type="text" placeholder="challenge name")
|
||||
span.input-group-addon
|
||||
i.fa.fa-search
|
||||
hr
|
||||
#accordion.map-accordion
|
||||
for superBlock, index in superBlocks
|
||||
@ -24,12 +29,12 @@ block content
|
||||
div.margin-left-10(id = "nested-collapse"+challengeBlock.name.replace(/\W/gi, '').split(' ').join('-') class = "collapse in map-collapse no-transition")
|
||||
for challenge in challengeBlock.challenges
|
||||
if challenge.completed
|
||||
p.faded.text-primary.ion-checkmark-circled.padded-ionic-icon.negative-15(name="#{challenge.dashedName}")
|
||||
p.challenge-title.faded.text-primary.ion-checkmark-circled.padded-ionic-icon.negative-15(name="#{challenge.dashedName}")
|
||||
a(href="/challenges/#{challenge.dashedName}" target='_parent')
|
||||
= challenge.title
|
||||
span.sr-only= " Complete"
|
||||
else if challenge.isRequired
|
||||
p.ion-ios-circle-outline.padded-ionic-icon.negative-15(name="#{challenge.dashedName}")
|
||||
p.challenge-title.ion-ios-circle-outline.padded-ionic-icon.negative-15(name="#{challenge.dashedName}")
|
||||
a(name="#{challenge.dashedName}" target='_parent' href="/challenges/#{challenge.dashedName}" class=challenge.isComingSoon ? 'disabled' : '')
|
||||
span= challenge.title
|
||||
span.sr-only= " Incomplete"
|
||||
@ -44,7 +49,7 @@ block content
|
||||
span.text-primary    
|
||||
strong *
|
||||
else
|
||||
p.ion-ios-circle-outline.padded-ionic-icon.negative-15(name="#{challenge.dashedName}")
|
||||
p.challenge-title.ion-ios-circle-outline.padded-ionic-icon.negative-15(name="#{challenge.dashedName}")
|
||||
a(name="#{challenge.dashedName}" target='_parent' href="/challenges/#{challenge.dashedName}" class=challenge.isComingSoon ? 'disabled' : '')
|
||||
span= challenge.title
|
||||
span.sr-only= " Incomplete"
|
||||
|
Reference in New Issue
Block a user