Remove the filter button and collapse completed blocks by default
This commit is contained in:
		
				
					committed by
					
						 SaintPeter
						SaintPeter
					
				
			
			
				
	
			
			
			
						parent
						
							317b27b614
						
					
				
				
					commit
					c62b7abf8f
				
			| @@ -280,6 +280,43 @@ $(document).ready(function() { | |||||||
|     window.location.href = link; |     window.location.href = link; | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|  |   function expandCaret(item) { | ||||||
|  |     $(item) | ||||||
|  |       .prev().find('.fa-caret-right') | ||||||
|  |       .removeClass('fa-caret-right').addClass('fa-caret-down'); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   function collapseCaret(item) { | ||||||
|  |     $(item) | ||||||
|  |       .prev().find('.fa-caret-down') | ||||||
|  |       .removeClass('fa-caret-down').addClass('fa-caret-right'); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   function expandBlock(item) { | ||||||
|  |     $(item).addClass('in').css('height', '100%'); | ||||||
|  |     expandCaret(item); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   function collapseBlock(item) { | ||||||
|  |     $(item).removeClass('in').css('height', '100%'); | ||||||
|  |     collapseCaret(item); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   $.each($('.sr-only'), function(i, span) { | ||||||
|  |     if ($(span).text() === ' Complete') { | ||||||
|  |       $(span).parents('p').addClass('manip-hidden'); | ||||||
|  |     } | ||||||
|  |   }); | ||||||
|  |  | ||||||
|  |   $.each($('.map-collapse'), function(i, div) { | ||||||
|  |     if ($(div).find('.manip-hidden').length === | ||||||
|  |         $(div).find('p').length) { | ||||||
|  |       collapseBlock(div); | ||||||
|  |       $(div).find('h3 > a').addClass('faded'); | ||||||
|  |       $(div).prev('h2').addClass('faded'); | ||||||
|  |     } | ||||||
|  |   }); | ||||||
|  |  | ||||||
|   var scrollTo, dashedName = localStorage.getItem('currentDashedName'), |   var scrollTo, dashedName = localStorage.getItem('currentDashedName'), | ||||||
|     elemsToSearch = $('p.padded-ionic-icon a'), currOrLastChallenge; |     elemsToSearch = $('p.padded-ionic-icon a'), currOrLastChallenge; | ||||||
|   if (!dashedName && $('.sr-only').length) { |   if (!dashedName && $('.sr-only').length) { | ||||||
| @@ -323,63 +360,31 @@ $(document).ready(function() { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   $('#accordion').on('show.bs.collapse', function(e) { |   $('#accordion').on('show.bs.collapse', function(e) { | ||||||
|       $(e.target) |       expandCaret(e.target); | ||||||
|         .prev().find('.fa-caret-right') |  | ||||||
|         .removeClass('fa-caret-right').addClass('fa-caret-down'); |  | ||||||
|       if ($('a[data-toggle=collapse]').length === $('.fa-caret-down').length) { |       if ($('a[data-toggle=collapse]').length === $('.fa-caret-down').length) { | ||||||
|         $('#showAll').text('Collapse all challenges'); |         $('#showAll').text('Collapse all challenges'); | ||||||
|         $('#showAll').addClass('active'); |         $('#showAll').addClass('active'); | ||||||
|       } |       } | ||||||
|   }).on('hide.bs.collapse', function(e) { |   }).on('hide.bs.collapse', function(e) { | ||||||
|       $(e.target) |       collapseCaret(e.target); | ||||||
|         .prev().find('.fa-caret-down') |  | ||||||
|         .removeClass('fa-caret-down').addClass('fa-caret-right'); |  | ||||||
|       if ($('a[data-toggle=collapse]').length === $('.fa-caret-right').length) { |       if ($('a[data-toggle=collapse]').length === $('.fa-caret-right').length) { | ||||||
|         $('#showAll').text('Expand all challenges'); |         $('#showAll').text('Expand all challenges'); | ||||||
|         $('#showAll').removeClass('active'); |         $('#showAll').removeClass('active'); | ||||||
|       } |       } | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|   $('#manipAll').on('click', () => { |  | ||||||
|     var showAll = $('#manipAll').hasClass('active'); |  | ||||||
|     if (showAll) { |  | ||||||
|       $.each($('.sr-only'), function(i, item) { |  | ||||||
|         if ($(item).text() === ' Complete') { |  | ||||||
|           $(item).parents('p').css('display', 'none'); |  | ||||||
|           $(item).parents('p').addClass('manip-hidden'); |  | ||||||
|         } |  | ||||||
|       }); |  | ||||||
|       $('#manipAll').text('Show all challenges'); |  | ||||||
|       return $('#manipAll').removeClass('active'); |  | ||||||
|     } else { |  | ||||||
|       $.each($('.manip-hidden'), function(i, item) { |  | ||||||
|         $(item).css('display', 'block'); |  | ||||||
|         $(item).removeClass('manip-hidden'); |  | ||||||
|       }); |  | ||||||
|       $('#manipAll').text('Show incomplete challenges'); |  | ||||||
|       return $('#manipAll').addClass('active'); |  | ||||||
|     } |  | ||||||
|   }); |  | ||||||
|  |  | ||||||
|   $('#showAll').on('click', () => { |   $('#showAll').on('click', () => { | ||||||
|     var mapExpanded = $('#showAll').hasClass('active'); |     var mapExpanded = $('#showAll').hasClass('active'); | ||||||
|     if (!mapExpanded) { |     if (!mapExpanded) { | ||||||
|       $.each($('.map-collapse:not(".in")'), function(i, item) { |       $.each($('.map-collapse:not(".in")'), | ||||||
|         $(item).css('height', '100%'); |       function(i, div) { | ||||||
|         $(item).addClass('in'); |         expandBlock(div); | ||||||
|         $(item) |  | ||||||
|           .prev().find('.fa-caret-right') |  | ||||||
|           .removeClass('fa-caret-right').addClass('fa-caret-down'); |  | ||||||
|       }); |       }); | ||||||
|       $('#showAll').text('Collapse all challenges'); |       $('#showAll').text('Collapse all challenges'); | ||||||
|       return $('#showAll').addClass('active'); |       return $('#showAll').addClass('active'); | ||||||
|     } else { |     } else { | ||||||
|       $.each($('.map-collapse.in'), function(i, item) { |       $.each($('.map-collapse.in'), function(i, div) { | ||||||
|         $(item).css('height', '100%'); |         collapseBlock(div); | ||||||
|         $(item).removeClass('in'); |  | ||||||
|         $(item) |  | ||||||
|           .prev().find('.fa-caret-down') |  | ||||||
|           .removeClass('fa-caret-down').addClass('fa-caret-right'); |  | ||||||
|       }); |       }); | ||||||
|       $('#showAll').text('Expand all challenges'); |       $('#showAll').text('Expand all challenges'); | ||||||
|       return $('#showAll').removeClass('active'); |       return $('#showAll').removeClass('active'); | ||||||
|   | |||||||
| @@ -3,8 +3,7 @@ block content | |||||||
|         .text-center.map-fixed-header |         .text-center.map-fixed-header | ||||||
|             p Challenges marked with * are required for certification |             p Challenges marked with * are required for certification | ||||||
|             .row.map-buttons |             .row.map-buttons | ||||||
|                 button.center-block.btn.btn-sm.btn-block.btn-primary.active#manipAll Show incomplete challenges |                 button.center-block.btn.btn-sm.btn-block.btn-primary.active#showAll Collapse all challenges | ||||||
|                 button.center-block.btn.btn-sm.btn-block.btn-primary.active#showAll Collapse all |  | ||||||
|             hr |             hr | ||||||
|         #accordion.map-accordion |         #accordion.map-accordion | ||||||
|           for superBlock, index in superBlocks |           for superBlock, index in superBlocks | ||||||
| @@ -25,7 +24,7 @@ block content | |||||||
|                           div.margin-left-10(id = "nested-collapse"+challengeBlock.name.replace(/\W/gi, '').split(' ').join('-') class = "collapse in map-collapse no-transition") |                           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 |                               for challenge in challengeBlock.challenges | ||||||
|                                   if challenge.completed |                                   if challenge.completed | ||||||
|                                       p.slightly-faded.text-primary.ion-checkmark-circled.padded-ionic-icon.negative-15(name="#{challenge.dashedName}") |                                       p.faded.text-primary.ion-checkmark-circled.padded-ionic-icon.negative-15(name="#{challenge.dashedName}") | ||||||
|                                           a(href="/challenges/#{challenge.dashedName}" target='_parent') |                                           a(href="/challenges/#{challenge.dashedName}" target='_parent') | ||||||
|                                               = challenge.title |                                               = challenge.title | ||||||
|                                               span.sr-only= " Complete" |                                               span.sr-only= " Complete" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user