Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //global variable needed because function that uses it is recursive
- var totalCycles = 0;
- $(document).ready(function() {
- $(".email").slideToggle("slow");
- //br is the most efficient way to get desired effect with inline h3's
- $("<br/>").insertBefore("h3");
- });
- $(window).load(function() {
- parallelNavbar();
- //collapse all expandable sections on page load
- toggleExpansion($(".expansion_text"));
- totalCycles = assignCycleNumbers();
- cycleAssociates();
- });
- // window is resized
- $(function(){
- $(window).resize(function() {
- parallelNavbar();
- totalCycles = assignCycleNumbers();
- });
- });
- // h3 clicked for expansion
- $(function(){
- $("h3").click( function(){
- toggleExpansion($(this).siblings(".expansion_text"));
- });
- });
- $(function(){
- $("#expand_email").click( function(){
- $(".email").slideToggle("slow");
- });
- });
- /* ^ Events ^ */
- function toggleExpansion(expandableText){
- expandableText.slideToggle( "slow", function(){
- if ( $(this).is(":visible") ){
- //remove ".." that sugests expansion
- var oldtext = $(this).siblings("h3").text();
- $(this).siblings("h3").text(oldtext.replace("..",""));
- var page = $("#page");
- page.animate({scrollTop: page.scrollTop() +
- $(this).siblings("h3").position().top},1100);
- }
- else{
- $(this).siblings("h3").append("..");
- }
- });
- }
- function parallelNavbar(){
- //make the navigation parallel with the content
- var distance = $("#header").outerHeight();
- $("#header_equivalent").height(distance);
- }
- function cycleAssociates(){
- var cycle = 0;
- var recursiveCycling = function(cycle, totalCycles){
- var currentAssociate = ".cycle" + cycle;
- //fade in all img with the current cyle class over a second,
- //wait 3 seconds before fading out over a second.
- $(currentAssociate).delay(100).fadeIn(1000).delay(3000).fadeOut(1000,
- function(){
- cycle++;
- if(cycle > totalCycles){
- cycle = 0;
- }
- recursiveCycling(cycle, totalCycles);
- });
- };
- recursiveCycling(cycle, totalCycles);
- }
- function assignCycleNumbers(){
- //first remove any old cycle# classes (resized window case)
- $('[class*="cycle"]').removeClass( function(unusedIdx,c){
- return c.match(/cycle\d+/g).join(" ");
- });
- //measure div width
- var divSpace = $("#bodies").innerWidth();
- //assign a cycle number to a number of logos until no more will fit in that div
- var cycleNum = 0;
- $(".associate").each(function(){
- if( divSpace - $(this).width() > 0){
- $(this).addClass("cycle" + cycleNum);
- divSpace = divSpace - $(this).width();
- }
- else{ //next logo won't fit current cycle, create next cycle
- cycleNum++
- $(this).addClass("cycle" + cycleNum);
- divSpace = $("#bodies").innerWidth() - $(this).width();
- }
- });
- return cycleNum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement