Skip to content

Instantly share code, notes, and snippets.

@RaphaelAudet
Created February 20, 2018 10:07
Show Gist options
  • Save RaphaelAudet/a0adff4f3d33d56cad08bc7bb2f1b9d3 to your computer and use it in GitHub Desktop.
Save RaphaelAudet/a0adff4f3d33d56cad08bc7bb2f1b9d3 to your computer and use it in GitHub Desktop.
random coffeescript tests
visibleY = (el) ->
`var el`
rect = el.getBoundingClientRect()
top = rect.top
height = rect.height
el = el.parentNode
loop
rect = el.getBoundingClientRect()
if top <= rect.bottom == false
return false
# Check if the element is out of view due to a container scrolling
if top + height <= rect.top
return false
el = el.parentNode
unless el != document.body
break
# Check its within the document viewport
top <= document.documentElement.clientHeight
attachEvent = (element, event, callbackFunction) ->
if element.addEventListener
element.addEventListener event, callbackFunction, false
else if element.attachEvent
element.attachEvent 'on' + event, callbackFunction
return
validatebrief= ->
console.log "validating"
if $('#brief_logistic_attributes_quantity1').val() == ""
$('#brief_logistic_attributes_quantity1_validation').show()
else
$('#brief_logistic_attributes_quantity1_validation').hide()
update = ->
validatebrief()
# console.log visibleY(document.getElementById('btn_submit_brief'))
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment