-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaside.coffee
47 lines (35 loc) · 1.22 KB
/
aside.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
###
...
@namespace Atoms.Organism
@class Aside
@author Javier Jimenez Villar <[email protected]> || @soyjavi
###
"use strict"
class Atoms.Organism.Aside extends Atoms.Class.Organism
@template : """<aside {{#if.id}}id="{{id}}"{{/if.id}} {{#if.style}}class="{{style}}"{{/if.style}}></aside>"""
@available: ["Organism.Header", "Organism.Section", "Organism.Footer", "Molecule.Navigation", "Molecule.Form"]
@base : "Aside"
@events : ["show", "hide"]
constructor: (attributes = {}, scaffold) ->
attributes.method = "prepend"
super attributes, scaffold
Atoms.App.Aside[@constructor.name] = @
render: ->
super
for animation_end in __.Constants.ANIMATION.END.split " "
@el.bind animation_end, @onAnimationEnd
show: ->
unless @el then @render()
@el.addClass "active"
@el.attr "data-state", "in" if Atoms.Device.screen is "small"
hide: ->
if @el?.hasClass "active"
if Atoms.Device.screen is "small"
@el.attr "data-state", "out"
else
@el.removeClass "active"
onAnimationEnd: (event) =>
state = @el.attr "data-state"
@trigger (if state is "in" then "show" else "hide")
@el.removeAttr "data-state"
@el.removeClass "active" if state is "out"