Difference between revisions of "Team:Cambridge-JIC/Assets/Fudge.js"

(Created page with "function hndl(me) { if($(me).parent().children("div").is(':visible')) { $(".navsub_m").hide() } else { $(".navsub_m").hide() $(me).parent().childr...")
 
Line 79: Line 79:
 
     }
 
     }
 
     $(".navbar-collapse").css("max-height", ($(window).height()-67)+"px")
 
     $(".navbar-collapse").css("max-height", ($(window).height()-67)+"px")
 +
 +
 +
// highlight curr page
 +
if(!window.location.href.match(/501/g))
 +
    if(!$(window).height() < 768) {
 +
 +
        $("a").each(function(){
 +
          hr=$(this).attr("href");
 +
 +
          if(hr && hr.match(/\/\/2015/g) && !hr.match(/http:/g)) {
 +
 +
              if(window.location.href.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");
 +
                  }
 +
 +
              }
 +
          }
 +
 +
        })
 +
    }  else {
 +
 +
        $("a").each(function(){
 +
 +
if($(this).parent().parent().parent().attr("class") == "nhs") {
 +
$(this).parent().parent().parent().attr("class", "navsub");
 +
$(this).parent().parent().parent().parent().attr("class", "");
 +
$(this).parent().attr("class", "nh");
 +
}
 +
 +
if(!~$(this).parent().parent().prop('className').indexOf("nav")) {
 +
$(this).parent().attr("class", "");
 +
}
 +
 +
});
 +
 +
}
 +
 
}).resize();
 
}).resize();
  
Line 101: Line 146:
 
});
 
});
  
// highlight curr page
 
if(!window.location.href.match(/501/g))
 
    if(!$(window).height() < 768) {
 
 
$("a").each(function(){
 
hr=$(this).attr("href");
 
 
if(hr){
 
if(hr.match(/\/\/2015/g)){
 
if(!hr.match(/http:/g)) {
 
 
if(window.location.href.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");
 
}
 
 
console.log(hr)
 
 
 
}
 
}
 
}
 
}
 
 
})
 
}
 
  
 
});
 
});

Revision as of 15:19, 4 August 2015

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 () {

   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", "100%");
               //$(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", "100% 100%");
           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")


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

   if(!$(window).height() < 768) {
       $("a").each(function(){
          hr=$(this).attr("href");
          if(hr && hr.match(/\/\/2015/g) && !hr.match(/http:/g)) {
              if(window.location.href.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");
                 }
             }
          }
       })
   }  else {
       $("a").each(function(){

if($(this).parent().parent().parent().attr("class") == "nhs") { $(this).parent().parent().parent().attr("class", "navsub"); $(this).parent().parent().parent().parent().attr("class", ""); $(this).parent().attr("class", "nh"); }

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

});

}

}).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(){ $(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);

}