-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdialog_push.coffee
74 lines (62 loc) · 1.94 KB
/
dialog_push.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
###
Base class for Organism
@namespace Atoms.Organism
@extends Dialog
@class Push
@author Javier Jimenez Villar <[email protected]> || @soyjavi
###
"use strict"
class Atoms.Organism.Push extends Atoms.Organism.Dialog
@template: """
<article>
<header>
<figure></figure>
<span class="icon user"></span>
<h1></h1>
</header>
<section>
<p></p>
</section>
</article>"""
constructor: (attributes) ->
super attributes
@parent = @el.parent().addClass "no-block"
@figure = @el.find("figure")
@icon = @el.find(".icon")
@title = @el.find("h1")
@text = @el.find("p")
@el.on "touch", @_onTouch
# -- Instance Methods ---------------------------------------------------------
show: (attributes, timeout = 3000) ->
clearTimeout @id_timeout
@parent.removeClass "expand"
@title.html attributes.title
@text.html attributes.description
@figure.hide()
if attributes.image?
@figure.show().css "background-image", "url('#{attributes.image}')"
@icon.hide()
if attributes.icon?
@icon.show().attr "class", "icon #{attributes.icon}"
@el.parent().addClass "active"
@el.addClass "show"
@trigger "show"
#@TODO: Hack for Firefox AnimationEnd listener fails
setTimeout (=> do @onAnimationEnd), __.Constants.ANIMATION.DURATION
if attributes.timeout?
@id_timeout = setTimeout =>
do @hide unless @parent.hasClass "expand"
, attributes.timeout
hide: ->
@el.addClass "hide"
@trigger "hide"
__.Url.current()?.front()
clearTimeout @id_timeout
# -- Private Methods --------------------------------------------------------
_onTouch: (event) =>
unless @parent.hasClass "expand"
@parent.addClass "expand"
__.Url.current()?.back()
else
do @hide
new Atoms.Organism.Push()