') // var newDes = $j('.set1 .product_short_description').clone(); $j(newDes).addClass('mobi'); $j('#tabbed_child_images').after($j(newDes)); // $j('#product_tab_stage').prepend('Product Details'); $j('body').on("click", ".btn-desc-mobi", function() { $j('html').toggleClass('desc-mobi-open'); return false; }); // if (!$j('.product_tab_content ul li').length) { $j('html').addClass('no-expand-desc'); } // to stop vid play var vidPoll; $j('body').on('click','#alt_video_images .c_modalify', function() { //console.log('clicked'); vidPoll = setInterval(vidCheck, 200); }); function vidCheck() { if (!$j('#brv').hasClass('active')) { var vidTemp = $j('#brv .c_modal_i').html(); $j('#brv .c_modal_i').html(''); $j('#brv .c_modal_i').html($j(vidTemp)); clearInterval(vidPoll); } else { //console.log('vid still open') } } // IncludeJavaScript("//www.brighton.com/store_image/site/js/photoswipe.min.js",function() { console.log('ps 1 loaded'); IncludeJavaScript("//www.brighton.com/store_image/site/js/photoswipe-ui-default.min.js",function() { console.log('ps 2 loaded'); // var initPhotoSwipeFromDOM = function(gallerySelector) { function getParents(el, parentSelector /* optional */) { // If no parentSelector defined will bubble up all the way to *document* if (parentSelector === undefined) { parentSelector = document; } var parents = []; var p = el.parentNode; while (p !== parentSelector) { var o = p; parents.push(o); p = o.parentNode; } parents.push(parentSelector); // Push that parentSelector you wanted to stop at return parents; } var parseThumbnailElements = function(el) { var uniqueTEParent = $j(el).attr('id'); //var thumbElements = $j(el).find('.alt_image'),//el.childNodes, var thumbElements = $j('#'+uniqueTEParent).find('.owl-item:not(.cloned) .alt_image'), numNodes = thumbElements.length, items = [], el, childElements, thumbnailEl, size, item; console.log(numNodes) for(var i = 0; i < numNodes; i++) { el = thumbElements[i]; // include only element nodes if(el.nodeType !== 1) { continue; } childElements = el.children; size = el.getAttribute('data-size').split('x'); // create slide object item = { src: el.getAttribute('data-href'), w: parseInt(size[0], 10), h: parseInt(size[1], 10), author: el.getAttribute('data-author') }; item.el = el; // save link to element for getThumbBoundsFn if(childElements.length > 0) { item.msrc = childElements[0].getAttribute('src'); // thumbnail url if(childElements.length > 1) { item.title = childElements[1].innerHTML; // caption (contents of figure) } } var mediumSrc = el.getAttribute('data-med'); if(mediumSrc) { size = el.getAttribute('data-med-size').split('x'); // "medium-sized" image item.m = { src: mediumSrc, w: parseInt(size[0], 10), h: parseInt(size[1], 10) }; } // original image item.o = { src: item.src, w: item.w, h: item.h }; items.push(item); } return items; }; // find nearest parent element var closest = function closest(el, fn) { return el && ( fn(el) ? el : closest(el.parentNode, fn) ); }; var onThumbnailsClick = function(e) { var w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; console.log(w) if (w > 0) { e = e || window.event; e.preventDefault ? e.preventDefault() : e.returnValue = false; var eTarget = e.target || e.srcElement; var clickedListItem = $j(e.target).parents('.alt_image'); console.log('cLI:'); console.log(clickedListItem) if(!clickedListItem || $j(e.target).is('.bgv')) { return; } var clickedGallery = $j(e.target).parents('.owl-stage'); console.log('cG:'); console.log(clickedGallery); if(!clickedGallery) { return; } //var childNodes = $j(clickedListItem).parents('.owl-stage').find('.alt_image'), var childNodes = $j(clickedListItem).parents('.owl-stage').find('.owl-item:not(.cloned) .alt_image'), numChildNodes = childNodes.length, nodeIndex = 0, index; console.log('cN:') console.log(childNodes) console.log('nCH:') console.log(numChildNodes) for (var i = 0; i < numChildNodes; i++) { console.log('f nCN') if(childNodes[i].nodeType !== 1) { continue; } console.log('cN[i]:') console.log($j(childNodes[i])) console.log('cLI') console.log(clickedListItem) if($j(childNodes[i]).attr('id') == $j(clickedListItem).attr('id')) { console.log('cN is cLI') index = nodeIndex; break; } nodeIndex++; } console.log('i:') console.log(index); if(index >= 0) { console.log('open PS') openPhotoSwipe( index, clickedGallery ); } else { console.log('donot open PS') } return false; } }; var photoswipeParseHash = function() { var hash = window.location.hash.substring(1), params = {}; if(hash.length < 5) { // pid=1 return params; } var vars = hash.split('&'); for (var i = 0; i < vars.length; i++) { if(!vars[i]) { continue; } var pair = vars[i].split('='); if(pair.length < 2) { continue; } params[pair[0]] = pair[1]; } if(params.gid) { params.gid = parseInt(params.gid, 10); } return params; }; var openPhotoSwipe = function(index, galleryElement, disableAnimation, fromURL) { var pswpElement = document.querySelectorAll('.pswp')[0], gallery, options, items; items = parseThumbnailElements(galleryElement); // define options (if needed) options = { captionEl: false, tapToClose: true, getThumbBoundsFn: function(index) { // See Options->getThumbBoundsFn section of docs for more info var thumbnail = items[index].el.children[0], pageYScroll = window.pageYOffset || document.documentElement.scrollTop, rect = thumbnail.getBoundingClientRect(); return {x:rect.left, y:rect.top + pageYScroll, w:rect.width}; } }; if(fromURL) { if(options.galleryPIDs) { // parse real index when custom PIDs are used // http://photoswipe.com/documentation/faq.html#custom-pid-in-url for(var j = 0; j < items.length; j++) { if(items[j].pid == index) { options.index = j; break; } } } else { options.index = parseInt(index, 10) - 1; } } else { options.index = parseInt(index, 10); } // exit if index not found if( isNaN(options.index) ) { return; } var radios = document.getElementsByName('gallery-style'); for (var i = 0, length = radios.length; i < length; i++) { if (radios[i].checked) { if(radios[i].id == 'radio-all-controls') { } else if(radios[i].id == 'radio-minimal-black') { options.mainClass = 'pswp--minimal--dark'; options.barsSize = {top:0,bottom:0}; options.captionEl = false; options.fullscreenEl = false; options.shareEl = false; options.bgOpacity = 0.85; options.tapToClose = true; options.tapToToggleControls = false; } break; } } if(disableAnimation) { options.showAnimationDuration = 0; } // Pass data to PhotoSwipe and initialize it gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options); // see: http://photoswipe.com/documentation/responsive-images.html var realViewportWidth, useLargeImages = false, firstResize = true, imageSrcWillChange; gallery.listen('beforeResize', function() { var dpiRatio = window.devicePixelRatio ? window.devicePixelRatio : 1; dpiRatio = Math.min(dpiRatio, 2.5); realViewportWidth = gallery.viewportSize.x * dpiRatio; if(realViewportWidth >= 1200 || (!gallery.likelyTouchDevice && realViewportWidth > 800) || screen.width > 1200 ) { if(!useLargeImages) { useLargeImages = true; imageSrcWillChange = true; } } else { if(useLargeImages) { useLargeImages = false; imageSrcWillChange = true; } } if(imageSrcWillChange && !firstResize) { gallery.invalidateCurrItems(); } if(firstResize) { firstResize = false; } imageSrcWillChange = false; }); gallery.listen('gettingData', function(index, item) { if( useLargeImages ) { item.src = item.o.src; item.w = item.o.w; item.h = item.o.h; } else { item.src = item.m.src; item.w = item.m.w; item.h = item.m.h; } }); gallery.init(); }; // select all gallery elements var galleryElements = document.querySelectorAll( gallerySelector ); for(var i = 0, l = galleryElements.length; i < l; i++) { galleryElements[i].setAttribute('data-pswp-uid', i+1); galleryElements[i].onclick = onThumbnailsClick; } // Parse URL and open gallery if it contains #&pid=3&gid=1 var hashData = photoswipeParseHash(); if(hashData.pid && hashData.gid) { openPhotoSwipe( hashData.pid, galleryElements[ hashData.gid - 1 ], true, true ); } }; // var oSCount = 0; $j('#child_images .owl-stage').each(function() { $j(this).attr('id','oSCount'+oSCount); oSCount++; }); // initPhotoSwipeFromDOM('#child_images .owl-stage'); }); }); $j(window).resize(function() { if ($j(window).width() < 768) { } }); function prepCI() { $j('.alt_image').each(function() { if (!$j(this).hasClass('alt_video_image')) { var tarZoo = $j(this).find('a').attr('href');//.replace('/giant/','/standard/'); var tarMed = $j(this).find('a img').attr('src'); $j(this).attr('data-href',tarZoo).attr('data-size','1200x1200').attr('data-med',tarZoo).attr('data-med-size','1200x1200'); $j(this).append('