//requires jQuery //wait for the DOM to be loaded jQuery( document ).ready( function() { //ORDERED LIST //edit ordered list dom to allow styling jQuery( 'ol li' ).wrapInner( '' ); //activate ordered list styling via adding class - edit styles in stylesheet jQuery( 'ol' ).addClass( 'javaScriptStyled' ); //Style hero images. HeroImg.init(); //Style kitchen gallery images. KitGalleryImg.init(); //Structure definition lists. SetColumnsList.init(); //Setup home page. HomePage.init(); //GALLERIES. if( $().fancybox ) { $( 'a[rel=imageGallery]' ).fancybox({ 'ajax' : { cache : false }, 'autoDimensions' : true, 'centerOnScroll' : true, 'padding' : 10, 'overlayColor' : '#000000', 'overlayOpacity' : 0.5, 'transitionIn' : 'elastic', 'transitionOut' : 'elastic', 'titlePosition' : 'outside', 'titleFormat' : function(title, currentArray, currentIndex, currentOpts) { return 'Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' ' + title : '') + ''; } }); }; } ); HomePage = { init: function() { if( !$('body').hasClass('home') ){ return; }; //Place necessary DOM elements //$( 'ul#kitchenHero' ).insert( '
' ); $( 'div#kitchenHero' ).append( '' ); $( 'div#kitchenHero div#slideshowNav' ).append( 'Prev' ); $( 'div#kitchenHero div#slideshowNav' ).append( '' ); $( 'div#kitchenHero div#slideshowNav' ).append( 'Next' ); $( 'div#kitchenHero ul' ).cycle({ fx: 'fade', speed: 500, timeout: 6000, pause: true, startingSlide: 0, cleartypeNoBg: true, prev: 'div#slideshowNav a#slideshowPrev', next: 'div#slideshowNav a#slideshowNext', pager: 'div#slideshowNav div#pager', before: HomePage.onBefore, after: HomePage.onAfter }); } , onBefore : function(curr, next, opts) { //if( $('body').hasClass( 'home' ) ) //{ //alert("Before"); //$(curr).children('div.info').hide(); //$(curr).children('div.info').css( 'height', 0 ); $(curr).children('div.info').css( 'left', -320 ); //$(next).children('div.info').hide(); //$(next).children('div.info').css( 'height', 0 ); $(next).children('div.info').css( 'left', -320 ); //console.log($(curr).children('div.info')) //};//end if } , onAfter : function(curr, next, opts) { //if( $('body').hasClass( 'home' ) ) //{ //$(next).children('div.info').show('fast'); //$(next).children('div.info').animate( { opacity: 'show', height: 308 }, 1000 ); //$(next).children('div.info').animate( { height: 308 }, 1000 ); //$(next).children('div.info').animate( { width: 316 }, 1000 ); $(next).children('div.info').animate( { left: 0 }, 500 ); //$(next).children('div.info').show(); //alert("After"); //console.log(opts) //};//end if } } //Restructure Definittion Lists. Illegal validation but had to get it happening quickly. SetColumnsList = { init : function() { $( 'dl.info' ).each( function( pmIndex ){ //Wrap dt/dd pairs with divs. var myLength = $(this).children('dt').size(); for( var i=0; i < myLength; i++ ) { $(this).children( "dt:eq(0),dd:eq(0)" ).wrapAll( '' ); };//end for //Add clearing div to ensure height of each div. $(this).children( 'div' ).append( '' ); //Set class to initiate styling. $(this).addClass( 'columnsList' ); $(this).children( 'div:odd' ).addClass('odd'); $(this).children( 'div:even' ).addClass('even'); } ); } };//end SetColumnsList //Style hero images. HeroImg = { init : function() { if( $('body').hasClass('home') ){ return; }; jQuery( 'img.hero' ).each( function(){ jQuery( this ).wrap( '' ); var myString = jQuery( this ).attr( 'alt' ); jQuery( this ).after( '' + myString +'
' ); }); jQuery( 'img.heroRow' ).each( function(){ jQuery( this ).wrap( '' ); var myString = jQuery( this ).attr( 'alt' ); jQuery( this ).after( '' + myString +'
' ); }); } };//end object literal HeroImg //Style kitchen gallery images. KitGalleryImg = { init : function() { jQuery( 'ul#imageGallery li' ).each( function( pmIndex ){ jQuery( this ).click( function(){ KitGalleryImg.setGalleryByIndex( pmIndex ); } ); } ); KitGalleryImg.setGalleryByIndex( 0 ); } , setGalleryByIndex : function( pmIndex ) { jQuery( 'ul#imageGallery li' ).each( function( pmListIndex ){ if( pmIndex == pmListIndex ) //Major image { jQuery( this ).addClass( 'major' ); jQuery( this ).removeClass( 'minor' ); var myCurrentImgPath = jQuery( this ).children( 'img' ).attr( 'src' ); var myNewImgPath = myCurrentImgPath.replace( 'Minor', 'Major' ); //alert( myCurrentImgPath + " , " + myNewImgPath ); jQuery( this ).children( 'img' ).attr( 'src', myNewImgPath ); } else //Minor image { jQuery( this ).removeClass( 'major' ); jQuery( this ).addClass( 'minor' ); var myCurrentImgPath = jQuery( this ).children( 'img' ).attr( 'src' ); var myNewImgPath = myCurrentImgPath.replace( 'Major', 'Minor' ); //alert( myCurrentImgPath + " , " + myNewImgPath ); jQuery( this ).children( 'img' ).attr( 'src', myNewImgPath ); };//end if //jQuery( this ).click( function(){ alert( pmListIndex ); } ); } ); } };//end object literal KitGalleryImg