Sha256: f8f0461b3090d3c5ac56dfa20e0ebc77e142eadf8482f1dcafe29f78e89771e3

Contents?: true

Size: 1.96 KB

Versions: 2

Compression:

Stored size: 1.96 KB

Contents

add_image_handlers = ->
  ($ '#main-image').data 'selectedThumb', ($ '#main-image img').attr('src')
  ($ 'ul.thumbnails li').eq(0).addClass 'selected'
  ($ 'ul.thumbnails a').on 'click', (event) ->
    ($ '#main-image').data 'selectedThumb', ($ event.currentTarget).attr('href')
    ($ '#main-image').data 'selectedThumbId', ($ event.currentTarget).parent().attr('id')
    ($ 'ul.thumbnails').find('li').removeClass 'selected'
    ($ event.currentTarget).parent('li').addClass 'selected'
    false

  ($ 'ul.thumbnails li').on 'mouseenter', (event) ->
    ($ '#main-image img').first().attr 'src', ($ event.currentTarget).find('a').attr('href')
    ($ '[data-drift]').first().attr 'href', ($ event.currentTarget).find('a').attr('href')

  # ($ 'ul.thumbnails li').on 'mouseleave', (event) ->
  #   ($ '#main-image img').first().attr 'src', ($ '#main-image').data('selectedThumb')
  #   ($ '[data-drift]').first().attr 'href', ($ '#main-image').data('selectedThumb')

window.SpreeProductHoverZoom = {
  zoomFactor: 4,
  handleTouch: true,
  touchDelay: 0,
}

$ ->
  add_image_handlers()

  el_drift = $('[data-drift]')[0]

  driftOptions =
    paneContainer: $('[data-hook=product_hover_zoom]')[0]
    zoomFactor: SpreeProductHoverZoom.zoomFactor
    sourceAttribute: 'href'
    handleTouch: SpreeProductHoverZoom.handleTouch
    touchDelay: SpreeProductHoverZoom.touchDelay

  new Drift(el_drift, driftOptions) if (el_drift && $(el_drift).attr('href').length > 0)

  # Single zoom view for main product image
  # new Luminous($('[data-luminous]')[0]);
  # do nothing on main product image click
  $('[data-luminous]').on 'click', (e) ->
    e.preventDefault()
    return

  # Gallery view for thumbnails

  # Whether pressing the arrow keys should move to the next/previous slide.
  galleryOpts = arrowNavigation: true
  # These options have the same defaults and potential values as the Luminous class.
  luminousOpts = {}
  new LuminousGallery($('ul.thumbnails > li > a'), galleryOpts, luminousOpts)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_product_hover_zoom-1.0.3 app/assets/javascripts/spree/frontend/spree_product_hover_zoom.js.coffee.erb
spree_product_hover_zoom-1.0.2 app/assets/javascripts/spree/frontend/spree_product_hover_zoom.js.coffee.erb