(function($, window, document, undefined) { var $swatcheSelected = $('.swatches .selected'), $swatchFirstActive = $('.swatches .selected:first'), $interiorSeating = $('#interior-seating'), $clickZoom, $wheelZoom = $('a.wheel_zoom'); $galleryContainer = $('.mod-gallery-slider'), $interiorSeating = $('#interior-seating'), $swapItem = $('li.swap-item'), $wheels = $('#wheels .wheel'), $prev = $('.swap-btn-previous'), $next = $('.swap-btn-next'), $close = $('.cllc-modal-button'); $swatchFirstActive.addClass('active'); if($interiorSeating.length>0) $clickZoom = $('a.click_zoom'); else $clickZoom = $('a.wheel_zoom'); $wheels.attr('data-swap-item','1'); /* $prev.on('click', function(){ DATALAYER.linkTrack(true, { lid: 'prev', lpos: 'content' }); }) $next.on('click', function(){ DATALAYER.linkTrack(true, { lid: 'next', lpos: 'content' }); }) $(document).on('click','.cllc-modal-window.image_overlay button', function(){ DATALAYER.linkTrack(true, { lid: 'close', lpos: 'overlay-content' }); }) */ $(document).keyup(function(e) { if (e.keyCode == 27) { // escape key maps to keycode `27` $('.cllc-modal-button').trigger('click'); } }); $swapItem.on('click', function(evt){ evt.preventDefault(); if($(this).hasClass('selected')){ var currentItem = $('#wheels .swap-item.selected a').data('motion-wheel'), currentBodyImg = $('#wheels .swap-item.selected a').data('body-img'); $wheels.attr({'src':currentItem,'data-swap-item':$(this).data('swap-item')}); $('#wheels .body-img').attr('src',currentBodyImg); } }); $swatcheSelected.on('click', function(){ var $image = $(this).find('a img').data('slide-image'), $title1 = $(this).find('a img').data('slide-title-1'), $title2 = $(this).find('a img').data('slide-title-2'), $description1 = $(this).find('a img').data('slide-description-1'), $description2 = $(this).find('a img').data('slide-description-2'), $array = [], $slide1 = $('.exterior-gallery .slide[data-slide=1]'); $slide2 = $('.exterior-gallery .slide[data-slide=2]'); $array = $image.split(','); $slide1.find('img').attr('src',$array[0]); $galleryContainer.find('.details h3').html($title1); $galleryContainer.find('.details p').html($description1); $slide2.find('img').attr('src',$array[1]); $galleryContainer.find('.details h3').html($title2); $galleryContainer.find('.details p').html($description2); /*for(var i=0;i<$slide.length;i++){ $slide.eq(i).find('img').attr('src',$array[i]); $slide.eq(i).find('.details h3').html($title); $slide.eq(i).find('.details p').html($description); } */ //$('#interior-slideshow-pagination a').eq(0).trigger('click'); }) $swatcheSelected.hover(function() { var that = this, wdth = $(this).width(), pWdth = $(this).find('p').width(), calcLeft = (wdth - pWdth) *0.5 ; $(that).find('p').fadeIn(100).css('left',calcLeft-10); }, function() { var that = this; setTimeout(function(){ $(that).find('p').hide(); },100) }); $interiorSeating.on('click', '.options li a', function(){ var clickItem = $(this).data('category'); $('.swatches[data-category='+clickItem+']').find('li.selected:first').trigger('click'); }) $clickZoom.on('click', function(event){ event.preventDefault(); var that = this, $element, modal = new cllc.ui.modal(), image, caption, description, content, zoomIn; // DATALAYER.linkTrack(true, { // lid: 'click_to_zoom', // lpos: 'content' // }); if($interiorSeating.length>0){ $element = $('.swatches .selected.active img'); if($(that).parent().attr('data-slide') === "1"){ image = $element.data('overlay-image-1'); caption = $('#gallery .details').find('h3').text(); description = $('#gallery .details').find('p').text(); zoomIn = $element.data('zoom-image-1'); }else{ image = $element.data('overlay-image-2'); caption = $('#gallery .details').find('h3').text(); description = $('#gallery .details').find('p').text(); zoomIn = $element.data('zoom-image-2'); } } else{ $element = $('#wheels .swap-item.selected a'); image = $element.data('overlay-image'); caption = $element.data('overlay-caption'); description = $element.data('overlay-description'); } content = '

'+caption+''+description+'

'; // add class to modal for styling $(modal.window).addClass('image_overlay'); $('.cllc-modal-mask').addClass('image_overlay_mask'); modal.open(content); if($interiorSeating.length>0){ $('.image_zoom').zoom({ url: zoomIn, magnify:1, callback: function(){ $(this).css('opacity',1); } }); }else{ $('.image_zoom').zoom({ magnify:1, callback: function(){ $(this).css('opacity',1); } }); } }); $wheelZoom.on('click', function(event){ event.preventDefault(); var that = this, $element, modal = new cllc.ui.modal(), image, caption, description, content, zoomIn; // DATALAYER.linkTrack(true, { // lid: 'click_to_zoom', // lpos: 'content' // }); $element = $('#wheels .swap-item.selected a'); image = $element.data('overlay-image'); caption = $element.data('overlay-caption'); description = $element.data('overlay-description'); content = '

'+caption+''+description+'

'; // add class to modal for styling $(modal.window).addClass('image_overlay'); $('.cllc-modal-mask').addClass('image_overlay_mask'); modal.open(content); $('.image_zoom').zoom({ magnify:1, callback: function(){ $(this).css('opacity',1); } }); }); $('#interior-seating .options').on('click', 'li.active', function(){ var wdth = $(this).find('a').outerWidth(), spanWdth = $(this).find('span').width(), calcLeft = (wdth - spanWdth) * 0.5 ; $(this).find('span').css('margin-left',calcLeft); }); })(jQuery, window, document); /** CGJEEP-8384 **/ $(function() { var ccode_value=Vehicles.getCcode(cllc.context.get()); var model_name=Vehicles.getModelFromCcode(ccode_value); cllc.context.set("models",model_name); });