Unit 7 Essay Criminal Law
function SplashTouch(){ /* 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("SplashTouch() \n--------------------------------------------------"); function main() { /* Normalize oooooooooooooooooooooooooooooooooooooooooooooooooo */ // if (!window.console) console = {log: function() {}}; console.log("mainMobile()"); /* General oooooooooooooooooooooooooooooooooooooooooooooooooo */ var previousWindowWidth; var previousWindowHeight; var horizontalLayoutBreakPointW = 599; var horizontalLayoutBreakPointH = 460; var previousCarouselH = 0; var oversizedWidth = 15000; var bkgImage = $("BODY").css("background-image"); /* Listeners -------------------------------------------------- */ $(window).resize(onWindowResize); function onWindowResize(){ console.log("onWindowResize()"); updateCarouselWidth(); updateMiniBkg(); // // trailOffText( $('.timeline_description'), $('.timeline_description').outerHeight() ); trailOffDescriptions(); } /* Listeners -------------------------------------------------- */ function makeItemsClickable(){ console.log("makeItemsClickable()"); var timelineItem = $("SECTION"); $(timelineItem).each(function(){ // console.log("\t section"); var $this = $(this); var link = $("A",this).attr("href"); // console.log( "\t"+ link ); $this.attr("data-url_destination",link); $this.on("click",onClickItem); }); } function onClickItem(){ console.log("onClickItem()"); window.location = $(this).attr("data-url_destination"); } function updateCarouselWidth(){ console.log("updateCarouselWidth()"); /// Temporarily remove -webkit-overflow-scrolling:touch to workaroud it's bug of not updating scrollable area \\\ /// Allow .carousel_container to flow into it's appropriate width \\\ /// Set the resulting width to parent for scrolling \\\ /// Remove min-width and allow width:100% declaration to style .splash_body \\\ /// Note: heights are hard-coded into media queries since they are predictable in current design \\\ var splashBody = $(".splash_body"); var splashBodyContent = $(".splash_body > .content_frame"); var carouselContainer = $(".splash_body > .content_frame .carousel_container"); if( isInVerticalUiBoundaries() ){ // console.log("\t Display Vertical |||||||||||"); splashBody.css("min-width",""); splashBodyContent.css("width",""); }else{ // console.log("\t Display Horizontal ----------"); $(splashBody).css("-webkit-overflow-scrolling",""); $(splashBody).css("min-width",oversizedWidth+"px"); $(splashBodyContent).css("width","auto"); var newWidth = carouselContainer.outerWidth(); $(splashBodyContent).css("width", newWidth+"px"); // console.log("\t newWidth: "+ newWidth+"px"); $(splashBody).css("min-width",""); //width:100%; $(splashBody).css("-webkit-overflow-scrolling","touch"); } } function setMiniBkgImage(){ console.log("setMiniBkgImage()"); // $(".mini_bkg").css( "background-image",$("BODY").css("background-image") ); $(".mini_bkg").css( "background-image", bkgImage ); } function updateMiniBkg(){ console.log("updateMiniBkg()"); var $window = $(window); var windowW = $window.width(); var windowH = $window.height(); if( windowW<=768 || windowH<=600 ){ var $miniBkg = $(".mini_bkg"); var carouselOffset = $(".carousel_container").offset(); var miniBkgOffset = $(".mini_bkg").offset(); // console.log("\t carouselOffset: "+ carouselOffset.top+ " miniBkgOffset: "+ miniBkgOffset.top); var newHeight = carouselOffset.top - miniBkgOffset.top; $miniBkg.css("height",newHeight+"px"); coverLargeBkg(); }else{ // console.log( "\telse: "+ windowW ); uncoverLargeBkg(); } } function coverLargeBkg(){ console.log('hideLargeBkg'); $("BODY").css("background-image",""); } function uncoverLargeBkg(){ console.log('hideLargeBkg'); $("BODY").css("background-image", bkgImage); } function isInVerticalUiBoundaries(){ var browserWindow = $(window); var browserWindowW = browserWindow.width(); var browserWindowH = browserWindow.height(); if( browserWindowW <= horizontalLayoutBreakPointW && browserWindowH <= horizontalLayoutBreakPointH ){ return true; } return; } function updateOversizedWidth(){ console.log("updateOversizedWidth()"); /// A size generously large enough to allow all timeline items to flow horizontally without wrapping \\\ var sectionCount = $("SECTION").length+ 1; ///TODO: Find out why .length is not sufficient. The +1 should not be necessary, but resolves a width issue in mobile chrome. \\\ // oversizedWidth = sectionCount* ($("SECTION:nth-child(2)").outerWidth()); oversizedWidth = sectionCount* 714; /// a timeline_item at it's widest design is 714px \\\ // console.log("\t "+ oversizedWidth); } /* Text Formatting -------------------------------------------------- */ function trailOffDescriptions(){ console.log('trailOffDescriptions()'); var browserWindow = $(window); var browserWindowW = browserWindow.width(); var browserWindowH = browserWindow.height(); /// Prevent many redundant trail-off functions with this conditional (perhaps a premature optimization for future desktop support) \\\ /// In vertical UI boundaries the width is fluid and frequently changes \\\ if( isInVerticalUiBoundaries() ){ applyDescriptionTrailOff(); /// In horizontal UI boundaries the description area does not change sizes as frequenlty as the vertifcal UI \\\ }else{ var currentCarouselH = $(".carousel_container").height(); // console.log("\t currentCarouselH: "+currentCarouselH+ "\t previousCarouselH: "+ previousCarouselH); if(currentCarouselH !== previousCarouselH){ previousCarouselH = currentCarouselH; applyDescriptionTrailOff(); } } } function applyDescriptionTrailOff(){ console.log('applyDescriptionTrailOff()'); $('.timeline_description').each(function(){ // console.log("\t "+ currentIndex); var $this = $(this); var timelineItem = $this.closest(".timeline_item"); var timelineTitle = $(".hover_area", timelineItem); // $(timelineTitle).addClass("red_border"); var newDescriptionH = timelineItem.height() - timelineTitle.outerHeight(); // console.log("\t timelineItemH: "+ timelineItem.height()); // console.log("\t timelineTitleH: "+ timelineTitle.outerHeight()); // console.log("\t newDescriptionH: "+ newDescriptionH); $this.css("height", newDescriptionH+ "px"); trailOffText(this, newDescriptionH); }); } function trailOffText(elementIn, heightIn){ console.log('trailOffText()'); $(elementIn).dotdotdot({ ellipsis : '... ', wrap : 'word', watch : false, height : heightIn, tolerance : 0, lastCharacter : { remove : [ ' ', ',', ';', '.', '!', '?' ], noEllipsis : [] } }); } /// Android Chrome Bug Workaround. TODO: Remove workaround once bug is resolved. \\\ /// https://code.google.com/p/chromium/issues/detail?id=156703 \\\ /* Initial Setup oooooooooooooooooooooooooooooooooooooooooooooooooo */ function initialize(){ console.log("initialize()"); makeItemsClickable(); updateOversizedWidth(); updateCarouselWidth(); setMiniBkgImage(); updateMiniBkg(); // // trailOffText( $('.timeline_description'), $('.timeline_description').outerHeight() ); trailOffDescriptions(); } initialize(); } $(window).ready(function() { main(); }); }