//= require jquery
//= require popper
//= require bootstrap-sprockets

// 
// Home
//

function displayCollapsible(clicked_id) {

            var inner = document.querySelector("#"+clicked_id+".module-collapsible-container-inner");
            var text = document.querySelector("#"+clicked_id+".module-collapsible-container-outer > .in-text-link")
            if (inner.style.display === "none") {
                inner.style.display = "flex";
                console.log(text.innerHTML);
                text.innerHTML = text.innerHTML.replace(/▶/g, "▼");
                
            } else {
                inner.style.display = "none";
                text.innerHTML = text.innerHTML.replace(/▼/g, "▶");
                
            }

        }


// Move the module summaries' height so they match up with the diagonal linear gradient
function setDynamicSizes () {
	// Section Buttons 
	var cw = $('.section-button').width();
	$('.section-button').css('height', cw+'px');
    // Adjust line connector
    var lineWidth = Math.floor($('.line-connector-container').width() * (0.5 - parseInt($('.line-connector#first').css('left'))/$('.line-connector-container').width()) - $('.logo-spacer > img').width()/2);
    $('.line-connector#first').css('width', lineWidth+'px');
    //Adjust info-oval sides
    var infoOvalHeight = $('.info-oval > p').height();
    $('.info-oval > div[class$="-semi-circle"]').css({'height': infoOvalHeight+'px', 'width': infoOvalHeight/2.0+'px'});
    $('.right-semi-circle').css({'border-bottom-right-radius': infoOvalHeight+'px', 'border-top-right-radius': infoOvalHeight+'px'});
    $('.left-semi-circle').css({'border-bottom-left-radius': infoOvalHeight+'px', 'border-top-left-radius': infoOvalHeight+'px'});
    // team portraits
    var teamPhotoAspectRatio = 1.23;
    var teamImageWrapWidth = $('.team-image-wrap').width();
    var teamImageWrapHeight = teamImageWrapWidth * teamPhotoAspectRatio;
    $('.team-image-wrap').css('height', teamImageWrapHeight+'px');
	//Module Summaries
	var midWidth = document.querySelector('.modules-summary-container-outer > .logo-spacer').offsetWidth / 2.0;
	var midHeight = document.querySelector('.modules-summary-container-outer > .logo-spacer').offsetHeight / 2.0;
	var angle = -12.5 * Math.PI / 180.0;
    var buffer = 100;
    var icons = document.getElementsByClassName('summary-modules-outer');
    for (i=0; i<icons.length; i++){
        var marginTop = midHeight - (icons[i].offsetLeft - midWidth) * Math.tan(angle) + buffer;
        icons[i].style.marginTop = marginTop.toString() + 'px';
        
    }
};
window.onload = setDynamicSizes;
setTimeout(setDynamicSizes, 1000);
window.onresize = setDynamicSizes;

@@ -66,17 +66,16 @@
 kets%0A%0A//
- 
 %0A// Home
@@ -549,33 +549,17 @@
 , %22%E2%96%BC%22);%0A
-                
 %0A
+
         
@@ -689,25 +689,9 @@
 %22);%0A
-                
 %0A
+
     
@@ -831,16 +831,16 @@
 es () %7B%0A
+
 %09// Sect
@@ -850,17 +850,16 @@
  Buttons
- 
 %0A%09var cw
@@ -2537,17 +2537,9 @@
 x';%0A
-        
 %0A
+
     
@@ -2611,16 +2611,16 @@
  1000);%0A
-
 window.o
@@ -2626,28 +2626,237 @@
 onresize = setDynamicSizes;%0A
+%0A$(document).ready(function() %7B%0A    if (window.location.hash !== %22%22) %7B%0A        var eid = $(window.location.hash).parents(%22.module-collapsible-container-outer%22)%5B0%5D.id;%0A        displayCollapsible(eid)%0A    %7D%0A%7D);%0A

implement uncollapsing collapsibles when opening an url with an anchor inside an collapsed collapsible