I feel this is deeply inelegant, but I really want the option of classical inheritance in the future. How could this be written better. FYI animation here is from GSAP if you are curious.
class Modal
angular.element(document).ready =>
@modalElem = document.getElementById 'modal'
@overlayElem = document.getElementById 'overlay'
@isOpen = false
@getWindowDim : ->
return dim =
height : window.innerWidth or document.documentElement.clientWidth
width : window.innerHeight or document.documentElement.clientHeight
@openModal : (attrs) ->
unless @isOpen
@isOpen = true
width = attrs.width
height = attrs.height
content = attrs.content
wDim = @getWindowDim()
@modalElem.style.width = 0
@modalElem.style.height = 0
@overlayElem.style.display = 'block'
TweenLite.to @modalElem, 0.75,
width : width
height : height
marginTop : (height/-2)
marginLeft : (width/-2)
opacity : 1
ease : Back.easeOut
@
@closeModal : ->
if @isOpen
@isOpen = false
TweenLite.to @modalElem, 0.33,
width : 0
height : 0
marginTop : 0
marginLeft : 0
opacity : 0
ease : Back.easeOut
onComplete : =>
@overlayElem.style.display = 'none'
@
modal = angular.module 'modal'
modal.directive 'openmodal', ->
return (scope, element, attrs) ->
element.bind 'click', ->
Modal.openModal attrs
modal.directive 'closemodal', ->
return (scope, element, attrs) ->
element.bind 'click', ->
Modal.closeModal()