Sha256: e82817b4fdebd9d01970fbdc1748a60852ce0cc913747ab844a5152f16a6b146

Contents?: true

Size: 1.52 KB

Versions: 4

Compression:

Stored size: 1.52 KB

Contents

class ADF.Overlay.Views.FlashOverlay extends ADF.GMap.Views.OverlayView
  
  opened: false
  clickable: false
  hoverable: true
  calibration: [0, -16, -20, 0]
  mouseout: true
  
  constructor: (options) ->
    super(options)
    @pushOverlay()
    
  onMarkerMouseOver: () =>
    @openOverlayOnHover()
    
  onMarkerMouseOut: () =>
    @hideOverlayAfterTime() if @mouseout

  openOverlayOnHover: () =>
    @map.hideAllOverlays()
    @opened = true
    @calculatePosition()
    @show()
    
  hideOverlayIfNeeded: () =>
    @hide() if !@opened

  hideOverlayAfterTime: () =>
    @opened = false
    setTimeout(@hideOverlayIfNeeded, 1000)

  onRenderCompleted: () =>
    if @hoverable && @mouseout
      $(@el).hover(@openOverlayOnHover, @hideOverlayAfterTime)
    
  onMarkerDrag: () ->
    @map.hideAllOverlays()
    
  calculatePosition: () ->
    arr = @getPositionArray()
    @setPosition(arr[0], arr[1])
    
  getPositionArray: () ->
    halfWidth = @map.getMapElement().width() / 2
    halfHeight = @map.getMapElement().height() / 2
    divPixel = @overlay.getDivPixel()
    w = @getWidth() / 2
    h = @getHeight()
    
    return [h + @calibration[0], w + @calibration[3]] if divPixel.x <= halfWidth && divPixel.y < halfHeight
    return [h + @calibration[0], -w + @calibration[1]] if divPixel.x > halfWidth && divPixel.y < halfHeight
    return [@calibration[2], w + @calibration[3]] if divPixel.x <= halfWidth && divPixel.y >= halfHeight
    return [@calibration[2], -w + @calibration[1]] if divPixel.x > halfWidth && divPixel.y >= halfHeight

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
socmap_adf-0.0.10 lib/assets/javascripts/socmap_adf/modules/overlay/views/flash_overlay.coffee
socmap_adf-0.0.9 lib/assets/javascripts/socmap_adf/modules/overlay/views/flash_overlay.coffee
socmap_adf-0.0.8 lib/assets/javascripts/socmap_adf/modules/overlay/views/flash_overlay.coffee
socmap_adf-0.0.7 lib/assets/javascripts/socmap_adf/modules/overlay/views/flash_overlay.coffee