Team:Cambridge-JIC/Assets/Fudge js

/*$('body').scrollspy({

   target: '.bs-docs-sidebar',
   offset: 40

});*/

function hndl(me) {

   if($(me).parent().children("div").is(':visible')) {
       $(".navsub_m").hide()
   } else {
       $(".navsub_m").hide()
       $(me).parent().children("div").show()
   }

}

String.prototype.endsWith = function(suffix) {

   return ~this.indexOf(suffix, this.length - suffix.length);

};

$(window).ready(function(){

//if($("#notebook").length == 1) return;

$(window).on("resize", function () {


// highlight curr page if(!window.location.href.match(/501/g)) {

   if($(window).width() < 768) {
       $("a").each(function() {

if(~$(this).parent().parent().parent().prop("className").indexOf("nhs")) { $(this).parent().parent().parent().attr("class", "navsub"); $(this).parent().parent().parent().parent().attr("class", ""); $(this).parent().attr("class", ""); }

if(~$(this).parent().prop('className').indexOf("nh")) { $(this).parent().attr("class", ""); }

});

   }

}


$(".nh").children(".navsub").addClass("nhs")


   if($(".navbar-toggle").is(":visible")) {
       $("#hovertext").html("Tap on a face");
       $(".navsub").each(function() {
           $(this).removeClass("navsub");
           $(this).addClass("navsub_m");
           $(this).hide();
           $(this).data("link", $(this).parent().children("a").attr("href"));
           $(this).parent().children("a").attr("href", "#");
           $(this).parent().children("a").attr("onclick", "hndl(this)");
       })
       $(".slide").each(function(){
           if($(this).data("mobile") == null) {
               $(this).data("mobile", 1)
               //$(this).css("background-size", "");
               //$(this).data("width", $(this).width());
               //$(this).width("auto")
               //$(this).data("minheight", $(this).css("min-height"));
               //$(this).css("min-height", "0px")
               $(this).children("div").data("fsz", $(this).children("div").css("font-size"));
               $(this).children("div").css("font-size", "12pt")
               $(this).children("div").data("ml", $(this).children("div").css("margin-left"));
               //$(this).children("div").css("margin-left", "30px")
               $(this).children(".padleft").data("pl", $(this).children(".padleft").css("padding-left"));
               $(this).children(".padleft").css("padding-left", "50px")
               $(".team .face .profile p").data("fsz", $(".team .face .profile p").css("font-size"));
               $(".team .face .profile p").css("font-size", "90%")
               //$(this).data("img", $(this).css("background-image"));
               //mobimg = $(this).data("mobimg")
               //$(this).css("background-image", (mobimg == null? "none":mobimg))
           }
       });
   } else {
       $("#hovertext").html("Hover over on a face");
       $(".navsub_m").each(function(){
           $(this).removeClass("navsub_m");
           $(this).show()
           $(this).addClass("navsub");
           $(this).parent().children("a").attr("href", $(this).data("link"));
           $(this).parent().children("a").attr("onclick", "");
       })
       $(".slide").each(function(){
           $(this).css("background-size", "");
           if($(this).data("mobile") == 1) {
               $(this).data("mobile", null)
               //$(this).width($(this).data("width")+"px")
               //$(this).css("background-image", $(this).data("img"))
               //$(this).css("min-height", $(this).data("minheight"))
               $(this).children("div").css("font-size", $(this).children("div").data("fsz"))
               //$(this).children("div").css("margin-left", $(this).children("div").data("ml"))
               $(this).children(".padleft").css("padding-left", $(this).children(".padleft").data("pl"))
               $(".team .face .profile p").css("font-size", $(".team .face .profile p").data("fsz"))
           }
       });
   }
   $(".navbar-collapse").css("max-height", ($(window).height()-67)+"px")

//reset highlighted page

if(!window.location.href.match(/501/g)) {

   if($(window).width() >= 768) {
       $("a").each(function(){
          hr=$(this).attr("href");
          if(hr && hr.match(/\/\/2015/g) && !hr.match(/http:/g)) {

url = 'http://' + window.location.hostname + window.location.pathname;

              if(url.endsWith(hr)){
                  if(~$(this).parent().parent().prop('className').indexOf("nav")) {
                      $(this).parent().attr("class", "nh");
                  }
                 if($(this).parent().parent().parent().prop('className')=="navsub") {
                    $(this).parent().parent().parent().attr("class", "nhs");
                    $(this).parent().parent().parent().parent().attr("class", "nh");
                    $(this).parent().attr("class", "nh");
                 }
             }
          }
       })
   }

}

}).resize();

$(".face").on("click", facepalm) $(".profile").on("mouseover", function(){ facepalm() $(this).addClass("profilehovered"); $(this).css("opacity", 1); })

$(".profile").on("mouseout", function(){ $(".blur").removeClass("facehovered"); $(".profile").removeClass("profilehovered"); $(".profile").css("opacity", 0); })

$("img").each(function(){

if($(this).parent().prop('nodeName') != 'a') { $(this).on("click", function(){ window.location = $(this).attr("src") }); $(this).css('cursor','pointer'); }

});


});

function facepalm(){ $(".blur").removeClass("facehovered"); $(".profile").removeClass("profilehovered"); $(".profile").css("opacity", 0);

$(this).children(".blur").addClass("facehovered"); $(this).children(".profile").addClass("profilehovered"); $(this).children(".profile").css("opacity", 1);

}