Sha256: 8d6554a5ee61327e9f380910bf4677def00eaa24b790158dd6ab3b84409f3ac5

Contents?: true

Size: 1.59 KB

Versions: 39

Compression:

Stored size: 1.59 KB

Contents

@Trigger = (->
  
  u = up.util
  
  mouseover = ($element, options) ->
    event = createMouseEvent('mouseover', options)
    dispatch($element, event)

  mousedown = ($element, options) ->
    event = createMouseEvent('mousedown', options)
    dispatch($element, event)

  mouseup = ($element, options) ->
    event = createMouseEvent('mouseup', options)
    dispatch($element, event)
    
  click = ($element, options) ->
    event = createMouseEvent('click', options)
    dispatch($element, event)

  # Can't use the new MouseEvent constructor in IE11 because computer.
  # http://www.codeproject.com/Tips/893254/JavaScript-Triggering-Event-Manually-in-Internet-E
  createMouseEvent = (type, options) ->
    options = u.options(options,
      view: window,
      cancelable: true,
      bubbles: true,
      detail: 0,
      screenX: 0,
      screenY: 0,
      clientX: 0,
      clientY: 0,
      ctrlKey: false,
      altKey: false,
      shiftKey: false,
      metaKey: false,
      button: 0,
      relatedTarget: null
    )
    event = document.createEvent('MouseEvent')
    event.initMouseEvent(type,
      options.bubbles,
      options.cancelable,
      options.view,
      options.detail,
      options.screenX,
      options.screenY,
      options.clientX,
      options.clientY,
      options.ctrlKey,
      options.altKey,
      options.shiftKey,
      options.metaKey,
      options.button,
      options.relatedTarget
    )
    event

  dispatch = ($element, event) ->
    $element.each ->
      this.dispatchEvent(event)

  mouseover: mouseover
  mousedown: mousedown
  mouseup: mouseup
  click: click
  
)()

Version data entries

39 entries across 39 versions & 2 rubygems

Version Path
unpoly-rails-0.28.1 spec_app/spec/javascripts/helpers/trigger.js.coffee
unpoly-rails-0.28.0 spec_app/spec/javascripts/helpers/trigger.js.coffee
unpoly-rails-0.27.3 spec_app/spec/javascripts/helpers/trigger.js.coffee
unpoly-rails-0.27.2 spec_app/spec/javascripts/helpers/trigger.js.coffee
unpoly-rails-0.27.1 spec_app/spec/javascripts/helpers/trigger.js.coffee
unpoly-rails-0.27.0 spec_app/spec/javascripts/helpers/trigger.js.coffee
unpoly-rails-0.26.2 spec_app/spec/javascripts/helpers/trigger.js.coffee
unpoly-rails-0.26.1 spec_app/spec/javascripts/helpers/trigger.js.coffee
unpoly-rails-0.26.0 spec_app/spec/javascripts/helpers/trigger.js.coffee
unpoly-rails-0.25.2 spec_app/spec/javascripts/helpers/trigger.js.coffee
unpoly-rails-0.25.1 spec_app/spec/javascripts/helpers/trigger.js.coffee
unpoly-rails-0.25.0 spec_app/spec/javascripts/helpers/trigger.js.coffee
unpoly-rails-0.24.1 spec_app/spec/javascripts/helpers/trigger.js.coffee
unpoly-rails-0.24.0 spec_app/spec/javascripts/helpers/trigger.js.coffee
unpoly-rails-0.23.0 spec_app/spec/javascripts/helpers/trigger.js.coffee
unpoly-rails-0.22.1 spec_app/spec/javascripts/helpers/trigger.js.coffee
unpoly-rails-0.22.0 spec_app/spec/javascripts/helpers/trigger.js.coffee
unpoly-rails-0.21.0 spec_app/spec/javascripts/helpers/trigger.js.coffee
unpoly-rails-0.20.0 spec_app/spec/javascripts/helpers/trigger.js.coffee
upjs-rails-0.19.0 spec_app/spec/javascripts/helpers/trigger.js.coffee