/* $(function() { $( ".draggable" ).draggable(); $( ".pola" ).draggable(); }); */ jQuery().ready(function($){ // Delegate .transition() calls to .animate() // if the browser can't do CSS transitions. if (!$.support.transition) $.fn.transition = $.fn.animate; var cup_targets = new Array(); var pola_targets = new Array(); pola_targets[0] = new Object(); pola_targets[0]["x_def"] = 622; pola_targets[0]["y_def"] = 80; pola_targets[0]["x_rem"] = 695; pola_targets[0]["y_rem"] = 400; pola_targets[1] = new Object(); pola_targets[1]["x_def"] = 622; pola_targets[1]["y_def"] = 80; pola_targets[1]["x_rem"] = 695; pola_targets[1]["y_rem"] = 400; pola_targets[2] = new Object(); pola_targets[2]["x_def"] = 622; pola_targets[2]["y_def"] = 80; pola_targets[2]["x_rem"] = 695; pola_targets[2]["y_rem"] = 400; pola_targets[3] = new Object(); pola_targets[3]["x_def"] = 622; pola_targets[3]["y_def"] = 80; pola_targets[3]["x_rem"] = 695; pola_targets[3]["y_rem"] = 400; pola_targets[4] = new Object(); pola_targets[4]["x_def"] = 622; pola_targets[4]["y_def"] = 80; pola_targets[4]["x_rem"] = 695; pola_targets[4]["y_rem"] = 400; pola_targets[5] = new Object(); pola_targets[5]["x_def"] = 622; pola_targets[5]["y_def"] = 80; pola_targets[5]["x_rem"] = 695; pola_targets[5]["y_rem"] = 400; pola_targets[6] = new Object(); pola_targets[6]["x_def"] = 622; pola_targets[6]["y_def"] = 80; pola_targets[6]["x_rem"] = 695; pola_targets[6]["y_rem"] = 400; pola_targets[7] = new Object(); pola_targets[7]["x_def"] = 622; pola_targets[7]["y_def"] = 80; pola_targets[7]["x_rem"] = 695; pola_targets[7]["y_rem"] = 400; pola_targets[8] = new Object(); pola_targets[8]["x_def"] = 622; pola_targets[8]["y_def"] = 80; pola_targets[8]["x_rem"] = 695; pola_targets[8]["y_rem"] = 400; pola_targets[9] = new Object(); pola_targets[9]["x_def"] = 622; pola_targets[9]["y_def"] = 80; pola_targets[9]["x_rem"] = 695; pola_targets[9]["y_rem"] = 400; pola_targets[10] = new Object(); pola_targets[10]["x_def"] = 622; pola_targets[10]["y_def"] = 80; pola_targets[10]["x_rem"] = 695; pola_targets[10]["y_rem"] = 400; // calc points on circle var numberOfIntern = $('.Intern').length; //console.log('INTERN:'+numberOfIntern); var counter = 0; var angleIncrement = 360 / numberOfIntern; var circleRadius = 120; var circleRadiusRem = 420; var xOffset = 140; var yOffset = 175; for (var i = 0; i < numberOfIntern; i++) { var target_coords = new Object(); var x_d = Math.round((circleRadius * Math.cos((angleIncrement * i) * (Math.PI / 180) - Math.PI/2))) + xOffset; var y_d = Math.round((circleRadius * Math.sin((angleIncrement * i) * (Math.PI / 180) - Math.PI/2))) + yOffset; var x_o = Math.round((circleRadiusRem * Math.cos((angleIncrement * i) * (Math.PI / 180) - Math.PI/1.5))) + xOffset; var y_o = Math.round((circleRadiusRem * Math.sin((angleIncrement * i) * (Math.PI / 180) - Math.PI/1.5))) + yOffset; var x_r = 580; var y_r = 250; target_coords.x_def = x_d; target_coords.y_def = y_d; target_coords.x_rem = x_r; target_coords.y_rem = y_r; target_coords.x_off= x_o; target_coords.y_off = y_o; target_coords.id = i; target_coords.type = 'Intern'; cup_targets.push(target_coords); counter = i+1; } //alert(cup_targets.length); //alert(cup_targets[1]["x_def"]); var numberOfExtern = $('.Extern').length; //console.log('EXTERN:'+numberOfExtern); angleOffset = -40; angleIncrement = 90 / numberOfExtern; circleRadius = 200; circleRadiusRem = 520; xOffset = 160; yOffset = 175; var frei_limit = numberOfIntern+numberOfExtern; for (var i = counter; i < frei_limit; i++) { var frei_target_coords = new Object(); var x_d = Math.round((circleRadius * Math.cos((angleOffset + angleIncrement * i) * (Math.PI / 180) +Math.PI/1.5 ))) + xOffset; var y_d = Math.round((circleRadius * Math.sin((angleOffset + angleIncrement * i) * (Math.PI / 180) +Math.PI/1.5 ))) + yOffset; var x_o = Math.round((circleRadiusRem * Math.cos((angleOffset + angleIncrement * i) * (Math.PI / 180)+Math.PI/1.5 ))) + xOffset; var y_o = Math.round((circleRadiusRem * Math.sin((angleOffset + angleIncrement * i) * (Math.PI / 180) +Math.PI/1.5 ))) + yOffset; var x_r = 580; var y_r = 250; frei_target_coords.x_def = x_d; frei_target_coords.y_def = y_d; frei_target_coords.x_rem = x_r; frei_target_coords.y_rem = y_r; frei_target_coords.x_off= x_o; frei_target_coords.y_off = y_o; frei_target_coords.id = i; frei_target_coords.type = 'Extern'; cup_targets.push(frei_target_coords); counter = i+1; } console.dir(cup_targets); //Set initial Positions $(window).load(function() { jQuery(".cup").each(function() { var mynum = jQuery(this).data("num"); ////console.log('mynum'+mynum); jQuery(this).css("left",cup_targets[mynum]["x_off"]+"px"); jQuery(this).css("top",cup_targets[mynum]["y_off"]+"px"); jQuery(this).css("visibility","visible"); var myrotation = Math.ceil(Math.random() * 90) -45 ; jQuery(this).transition({ rotate: myrotation+'deg', left: cup_targets[mynum]["x_def"] , top: cup_targets[mynum]["y_def"] }, 1000, 'in-out', function() { // Animation complete. jQuery(".stain").css("display","block"); }); }); jQuery(".stain").each(function() { var mynum = jQuery(this).data("num"); jQuery(this).css("left",cup_targets[mynum]["x_def"]+"px"); jQuery(this).css("top",cup_targets[mynum]["y_def"]+"px"); }); }); //document load end function switchCups(ref) { var myself= ref; var myId = ref.data("id"); var polarotation = Math.ceil(Math.random() * 6) -3 ; var cuprotation = Math.ceil(Math.random() * 90) -45 ; var deviateX = Math.ceil(Math.random() * 32) -16 ; var deviateY = Math.ceil(Math.random() * 20) -10 ; //console.log(cuprotation); var activenum = jQuery(myself).data("num"); var prevnum = jQuery(".active_cup").data("num"); //alert(activenum+"/"+prevnum); // Cups classes jQuery(".cup").removeClass("prev_cup"); jQuery(".active_cup").addClass("prev_cup"); jQuery(".cup").removeClass("active_cup"); jQuery(myself).addClass("active_cup"); //depth sorting jQuery(".active_cup").css("z-index",300+activenum); jQuery(".prev_cup").css("z-index",250+activenum); // Polaroids classes jQuery(".pola").removeClass("prev_pola"); jQuery(".pola[data-num="+prevnum+"]").addClass("prev_pola"); jQuery(".pola").removeClass("active_pola"); jQuery(".pola[data-num="+activenum+"]").addClass("active_pola"); //depth sorting jQuery(".active_pola").css("z-index",200+activenum); jQuery(".prev_pola").css("z-index",100+activenum); // Persons classes jQuery(".person").removeClass("active_person"); jQuery(".person[data-num="+activenum+"]").addClass("active_person"); // List classes jQuery(".useritem").removeClass("active_person"); jQuery(".useritem[data-num="+activenum+"]").addClass("active_person"); // Animation //animations use jquery.transit plugin jQuery(myself).transition({ rotate: cuprotation+'deg', left: cup_targets[activenum]["x_rem"] , top: cup_targets[activenum]["y_rem"] }, 800, 'in-out'); jQuery(".active_pola").transition({ rotate: polarotation+'deg', left: pola_targets[activenum]["x_def"]+deviateX , top: pola_targets[activenum]["y_def"]+deviateY }, 1000, 'in-out', function() { // Animation complete. jQuery("#cta").css('display','none'); }); if(cup_targets[prevnum]){ jQuery(".prev_cup").transition({ rotate: '0deg', left: cup_targets[prevnum]["x_def"] , top: cup_targets[prevnum]["y_def"] }, 400, 'in-out'); jQuery(".prev_pola").transition({ rotate: '0deg', left: pola_targets[prevnum]["x_rem"]+deviateX , top: pola_targets[prevnum]["y_rem"]+deviateY }, 800, 'in-out', function() { // Animation complete. jQuery(this).css("left",pola_targets[prevnum]["x_rem"]); jQuery(this).css("top",pola_targets[prevnum]["y_rem"]); }); } // Change BIO jQuery('.bioBlock').addClass('hidden'); jQuery('.bioBlock[data-id="'+myId+'"]').removeClass('hidden'); // Change Link jQuery('.nameLink').removeClass('active'); jQuery('.nameLink[data-id="'+myId+'"]').addClass('active'); } jQuery(".cup").click(function(){ switchCups(jQuery(this)); }); jQuery(".nameLink").click(function(){ var myId = jQuery(this).data("id"); switchCups(jQuery('.cup[data-id="'+ myId+'"]')); }); jQuery(".useritem").click(function(){ var mynum = jQuery(this).data("num"); var target = jQuery(".cup[data-num="+mynum+"]"); switchCups(jQuery(target)); }); });