Covet.pics widget Javascript events & methods:

Events

  • galleryReady
  • modalOpen
  • modalClose
  • modalChanged
  • addToCart

Methods

  • openPopup(popup-id)
  • openUpload()

Code examples:

// 
// Covet.pics Widget - Javascript Events
// 

// 
// galleryReady - when gallery loads
// parameter: itemsCount - number of loaded items
// 
document.addEventListener('galleryReady:covetPics', function(e) {
  console.log('Gallery Id: ', e.detail.galleryId);
  console.log('Gallery items count: ', e.detail.itemsCount);
  console.log('Gallery element', e.detail.el);
});

// 
// modalOpen - when gallery modal opens
// 
document.addEventListener('modalOpen:covetPics', function(e) {
  console.log('modalOpen');
});

// 
// modalClose - when gallery modal is closed
// 
document.addEventListener('modalClose:covetPics', function(e) {
  console.log('modalClose');
});

// 
// modalChanged - when gallery modal is changed (when user clicks on previous/next button)
// 
document.addEventListener('modalChanged:covetPics', function(e) {
  console.log('modalChanged');
});

// 
// addToCart - when customer adds Product to cart in Covet.pics modal
// parameter: variantID - ID of product variant that's added to the cart
// parameter: productId - ID of product
// 
document.addEventListener('addToCart:covetPics', function(e) {
  console.log("addToCart", e.detail);
});


// 
// Covet.pics Widget - Javascript Methods
// 

// 
// openModal(modalID) - open Covet.pics modal
// parameter: modalID - ID of modal
//
document.querySelector('covet-pics-popup').openPopup(XYZ);

// 
// openUpload() - open Covet.pics photo upload widget
//
document.querySelector('covet-pics-upload').openUpload();