Unit 7 Essay Criminal Law

profileChief707
splash_non_touch.js

function SplashNonTouch(){ /* Notes oooooooooooooooooooooooooooooooooooooooooooooooooo */ /// For new splash design, currently only intended on mobile \\\ /// The initial prototype was tested on the project's entire browser scope, in case it is later decided to use it accross all devices (ie. desktop). \\\ console.log("SplashNonTouch() \n--------------------------------------------------"); function main() { /* Normalize oooooooooooooooooooooooooooooooooooooooooooooooooo */ // if (!window.console) console = {log: function() {}}; /* General oooooooooooooooooooooooooooooooooooooooooooooooooo */ // console.log("main()"); /// Vars that do not change \\\ var spacingW = 60; /// .splash_body padding total \\\ var timelineItem = $(".timeline_item"); var lastItemIndex = timelineItem.length-1; //5 var timelineItemW = timelineItem.outerWidth(); var prevNextBtnW = 2*($(".prev_button").outerWidth()); /// Vars that change \\\ var currentIndex = 0; /// left-most item's index \\\ var previousCarouselWidth = 0; /* Listeners oooooooooooooooooooooooooooooooooooooooooooooooooo */ (function addListeners() { // console.log('addListeners()'); $(window).resize(function() { onWindowResize(); }); $(".hover_area").on("hover", function () { var hoveredItem = $(this); updateHighlighting(hoveredItem); updateCloaking(hoveredItem); }); $(".next_button").on("click", function () { var windowW = $(window).width(); var containerAvailableW = windowW- spacingW- prevNextBtnW; showNextItem(containerAvailableW); updateDisabled(containerAvailableW); }); $(".prev_button").on("click", function () { showPrevItem(); var windowW = $(window).width(); var containerAvailableW = windowW- spacingW- prevNextBtnW; updateDisabled(containerAvailableW); }); })(); /* Actions oooooooooooooooooooooooooooooooooooooooooooooooooo */ function onWindowResize(){ // console.log('onWindowResize()'); var windowObj = $(window); var windowH = windowObj.height(); var windowW = windowObj.width(); var containerAvailableW = windowW- spacingW- prevNextBtnW; var carouselW = timelineItemW*( Math.floor((containerAvailableW)/timelineItemW) ); var carouselIndexCapacity = Math.floor((containerAvailableW / timelineItemW))-1; var btnContainerW = carouselW+ prevNextBtnW; updateCarousel( windowW, carouselIndexCapacity, currentIndex, carouselW, btnContainerW ); updateDisabled(containerAvailableW); verticallyCenterTimeline(windowH); } function updateCarousel( windowWIn, carouselIndexCapacityIn, currentIndexIn, carouselWIn, btnContainerWIn ){ // console.log("updateCarousel()"); if(carouselWIn != previousCarouselWidth){ if(previousCarouselWidth < carouselWIn){ // console.log("updateCarousel()\n\tpotential to size up"); if( (lastItemIndex- carouselIndexCapacityIn) >= currentIndexIn ){ // console.log("\t\tstill unrevealed items on the right"); showPrevItem(); }else{ // console.log("\t\tno unrevealed items to the right"); showPrevItem(); } }else{ // console.log("updateCarousel()\n\tpotential to size down"); } previousCarouselWidth = carouselWIn; $("#carousel_container").css("width", carouselWIn+ "px"); $(".prev_next_container").css("width", btnContainerWIn+ "px"); } } function getCarouselIndexCapacity(containerAvailableWIn) { // console.log('getCarouselIndexCapacity()'); var capacity = Math.floor((containerAvailableWIn / timelineItemW))-1; return capacity; } function verticallyCenterTimeline(windowHIn){ // console.log("verticallyCenterTimeline()"); var newPaddingTop = (windowHIn)/2- ( $(".main_title").outerHeight() );// $("ARTICLE").css("padding-top", newPaddingTop+ "px"); } function showNextItem(containerAvailableWIn){ // console.log('showNextItem()'); if( currentIndex+getCarouselIndexCapacity(containerAvailableWIn) < lastItemIndex ){ // console.log('\ttimelineItemW: '+ timelineItemW); currentIndex ++; $('#timeline').css('margin-left', -(currentIndex* timelineItemW)+ 'px'); } } function showPrevItem(){ // console.log('showPrevItem()'); if(currentIndex > 0){ currentIndex --; $('#timeline').css('margin-left', -(currentIndex* timelineItemW)+ 'px'); } } function updateDisabled(containerAvailableWIn){ // console.log('updateDisabled()'); // console.log("\tcurrentIndex: "+ currentIndex); var carouselIndexCapacity = getCarouselIndexCapacity(containerAvailableWIn); if( currentIndex+carouselIndexCapacity >= lastItemIndex ){ disableIcon(".next_button"); }else if( currentIndex+carouselIndexCapacity < lastItemIndex ){ enableIcon(".next_button"); } if(currentIndex == 0){ disableIcon(".prev_button"); }else if(currentIndex > 0){ enableIcon(".prev_button"); } } function disableIcon(selectorIn){ // console.log("disableIcon()"); // console.log("\tdisable: "+ selectorIn); $(selectorIn).addClass("disabled"); } function enableIcon(selectorIn){ // console.log("enableIcon()"); $(selectorIn).removeClass("disabled"); } function updateCloaking(hoveredItemIn){ // console.log("updateCloaking()"); hoveredItemIn.closest(".timeline_item").siblings().find(".fade").fadeOut('slow'); hoveredItemIn.closest(".timeline_item").find(".fade").fadeIn('slow'); } function updateHighlighting(hoveredItemIn){ // console.log("updateHighlighting()"); hoveredItemIn.find(".timeline_number").addClass("highlighted"); hoveredItemIn.closest(".timeline_item").siblings().find(".timeline_number").removeClass("highlighted"); } /* Text Formatting oooooooooooooooooooooooooooooooooooooooooooooooooo */ function trailOffTitles(){ // console.log('trailOffTitles()'); $('.timeline_title H4').dotdotdot({ ellipsis : '... ', wrap : 'word', watch : false, height : 48, tolerance : 0, lastCharacter : { remove : [ ' ', ',', ';', '.', '!', '?' ], noEllipsis : [] } }); } function hyphenateSummaries(){ // console.log("hyphenateSummaries()"); Hyphenator.config({ classname : "timeline_description" }); Hyphenator.run(); } /* Initial Setup oooooooooooooooooooooooooooooooooooooooooooooooooo */ (function initialize(){ // console.log("initialize()"); var maxCarouselWidth = timelineItem.length* timelineItemW; $(".fade").hide(); /// Prevent Width from exceeding width of total timeline items \\\ $("#carousel_container").css("max-width", maxCarouselWidth+ "px"); $(".prev_next_container").css("max-width", (maxCarouselWidth+ prevNextBtnW)+ "px"); onWindowResize(); hyphenateSummaries(); trailOffTitles(); // window.setTimeout(trailOffTitles, 500); })(); } $(window).ready(function() { main(); }); }