Created
April 4, 2012 20:30
-
-
Save marklearst/2305357 to your computer and use it in GitHub Desktop.
3xHackory=Pro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var carouselController = (function() { | |
| // Didn't make a single var due to clarity; | |
| var currentSection = "shoppers"; | |
| var currentDevice = "desktop" | |
| var imageAssetsDesktop = { | |
| shoppers:["images/billboards/shoppers/vehicle billboard/desktop/fv_rad_billboard_vehicle.jpg", "images/billboards/shoppers/incentives/desktop/fv_rad_billboard_incentives.jpg", "images/billboards/shoppers/mttoty/desktop/fv_rad_billboard_mttoty.jpg", "images/billboards/shoppers/mustang/desktop/fv_rad_billboard_mustang.jpg"], | |
| owners:["images/billboards/owners/owners home/desktop/fv_rad_billboard_owners.jpg","images/billboards/owners/payment options/desktop/fv_rad_billboard_paymentoptions.jpg","images/billboards/owners/owners home/desktop/fv_rad_billboard_owners.jpg","images/billboards/owners/payment options/desktop/fv_rad_billboard_paymentoptions.jpg"], | |
| community:["images/billboards/community/corporate/desktop/fv_rad_billboard_corporate.jpg","images/billboards/community/ford social/desktop/fv_rad_billboard_fordsocial.jpg","images/billboards/community/racing/desktop/fv_rad_billboard_racing.jpg","images/billboards/community/wip/desktop/fv_rad_billboard_wip.jpg"] | |
| }; | |
| var imageAssetsTablet = { | |
| shoppers:["images/billboards/shoppers/vehicle billboard/tablet/fv_rad_billboard_vehicle.jpg", "images/billboards/shoppers/incentives/tablet/fv_rad_billboard_incentives.jpg", "images/billboards/shoppers/mttoty/tablet/fv_rad_billboard_mttoty.jpg", "images/billboards/shoppers/mustang/tablet/fv_rad_billboard_mustang.jpg"], | |
| owners:["images/billboards/owners/owners home/tablet/fv_rad_billboard_owners.jpg","images/billboards/owners/payment options/tablet/fv_rad_billboard_paymentoptions.jpg","images/billboards/owners/owners home/tablet/fv_rad_billboard_owners.jpg","images/billboards/owners/payment options/tablet/fv_rad_billboard_paymentoptions.jpg"], | |
| community:["images/billboards/community/corporate/tablet/fv_rad_billboard_corporate.jpg","images/billboards/community/ford social/tablet/fv_rad_billboard_fordsocial.jpg","images/billboards/community/racing/tablet/fv_rad_billboard_racing.jpg","images/billboards/community/wip/tablet/fv_rad_billboard_wip.jpg"] | |
| }; | |
| var imageAssetsMobile = { | |
| shoppers:["images/billboards/shoppers/vehicle billboard/mobile/fv_rad_billboard_vehicle.jpg", "images/billboards/shoppers/incentives/mobile/fv_rad_billboard_incentives.jpg", "images/billboards/shoppers/mttoty/mobile/fv_rad_billboard_mttoty.jpg", "images/billboards/shoppers/mustang/mobile/fv_rad_billboard_mustang.jpg"], | |
| owners:["images/billboards/owners/owners home/mobile/fv_rad_billboard_owners.jpg","images/billboards/owners/payment options/mobile/fv_rad_billboard_paymentoptions.jpg","images/billboards/owners/owners home/mobile/fv_rad_billboard_owners.jpg","images/billboards/owners/payment options/mobile/fv_rad_billboard_paymentoptions.jpg"], | |
| community:["images/billboards/community/corporate/mobile/fv_rad_billboard_corporate.jpg","images/billboards/community/ford social/mobile/fv_rad_billboard_fordsocial.jpg","images/billboards/community/racing/mobile/fv_rad_billboard_racing.jpg","images/billboards/community/wip/mobile/fv_rad_billboard_wip.jpg"] | |
| }; | |
| var setArray = function(device) { | |
| var setAssetArray; | |
| if (device === "desktop") { | |
| setAssetArray = imageAssetsDesktop; | |
| } else if (device === "tablet") { | |
| setAssetArray = imageAssetsTablet; | |
| } else { | |
| setAssetArray = imageAssetsMobile; | |
| } | |
| return setAssetArray; | |
| } | |
| var updateImgName = function(device) { | |
| $('.flexslider img').each(function(index) { | |
| if (setArray(device)[carouselController.getCurrentSection()][index-1] !== undefined) { | |
| $(this).attr('src', setArray(device)[carouselController.getCurrentSection()][index-1]); | |
| } | |
| }); | |
| $('.clone').eq(0).find('img').each(function(index) { | |
| var img = $(this).attr('src'); | |
| var imgReplace = img.replace('/'+currentDevice+'/', '/'+device+'/'); | |
| $(this).attr('src', imgReplace); | |
| }); | |
| $('.clone').eq(1).find('img').each(function(index) { | |
| var img = $(this).attr('src'); | |
| var imgReplace = img.replace('/'+currentDevice+'/', '/'+device+'/'); | |
| $(this).attr('src', imgReplace); | |
| }); | |
| }; | |
| var swapOutImgs = function(section, device) { | |
| currentSection = section; | |
| $('.flexslider').css('opacity', 0); | |
| $('.flexslider img').each(function(index) { | |
| if (setArray(device)[carouselController.getCurrentSection()][index-1] !== undefined) { | |
| $(this).attr('src', setArray(device)[currentSection][index-1]); | |
| } | |
| }); | |
| } | |
| var faderControl = function() { | |
| $('.flexslider').stop().animate({opacity: 1}, 300); | |
| } | |
| return { | |
| getImgList:function() { | |
| return [imageAssetsDesktop, imageAssetsTablet, imageAssetsMobile]; | |
| }, | |
| getCurrentSection:function() { | |
| return currentSection; | |
| }, | |
| setCurrentSection:function(section) { | |
| currentSection = section; | |
| }, | |
| getCurrentDevice:function() { | |
| return currentDevice; | |
| }, | |
| setCurrentDevice:function(device) { | |
| currentDevice = device; | |
| }, | |
| activateNewCarousel:function(section, version) { | |
| if(currentSection != section) { | |
| carouselController.setCurrentSection(section); | |
| swapOutImgs(section, version); | |
| faderControl(); | |
| } | |
| }, | |
| updateDevice:function(idevice) { | |
| updateImgName(idevice, currentDevice) | |
| currentDevice = idevice; | |
| } | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment