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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
var IntroModal = View.extend({
el: "#intro_modal",
events: {
"click .intro_proceed": "proceed",
"click .intro_tagline": "navigateToTagline",
"click a": "navigate",
},
alreadyShown: false,
curtainBackgroundColor: false,
initialize: function(){
this.$introTitle = this.$(".intro_title")
this.$introTaglineTop = this.$(".tagline_top")
this.$introTaglineBottom = this.$(".tagline_bottom")
this.$introContent = this.$(".intro_content")
this.$introProceed = this.$(".intro_proceed")
},
check: function(){
if (this.alreadyShown) {
this.hide()
return false
}
var lastMessage = localStorage.getItem('app.intro_modal_last_message')
switch (app.store.showModal) {
case 'never':
this.hide()
return false
case 'once':
if (lastMessage === app.store.modalContent) {
this.hide()
return false
}
this.show()
return true
case 'always':
this.show()
return true
default:
this.hide()
return false
}
},
build: function(){
var modalTitle = app.store.modalTitle.trim()
var modalTagline = app.store.modalTagline.trim()
var modalTaglineHref = app.store.modalTaglineLink.trim()
var modalContent = app.store.modalContent.trim()
var modalButton = app.store.modalButton.trim().toUpperCase() || "PROCEED"
if (app.store.modalBackgroundColor === 'black') {
this.curtainBackgroundColor = 'white'
} else {
this.curtainBackgroundColor = 'black'
}
this.$el.addClass(app.store.modalBackgroundColor)
if (modalTagline.length === 0) {
app.store.modalTaglinePosition = 'hidden'
}
switch (app.store.modalTaglinePosition) {
case 'hidden':
this.$introTaglineBottom.hide()
this.$introTaglineTop.hide()
break
case 'top':
this.$introTaglineBottom.hide()
this.$introTaglineTop.show()
this.$introTaglineTop.addClass(app.store.modalTaglineColor)
this.$introTaglineTop.text(app.store.modalTagline)
break
case 'bottom':
this.$introTaglineTop.hide()
this.$introTaglineBottom.show()
this.$introTaglineBottom.addClass(app.store.modalTaglineColor)
this.$introTaglineBottom.text(app.store.modalTagline)
break
}
if (modalTitle.length === 0) {
this.$introTitle.hide()
} else {
this.$introTitle.show()
this.$introTitle.text(modalTitle)
}
if (modalContent.length === 0) {
this.$introContent.hide()
} else {
this.$introContent.show()
this.$introContent.text(modalContent)
}
this.$introProceed.html(sanitize(modalButton))
},
show: function(){
this.alreadyShown = true
this.build()
this.$el.show()
setTimeout(function(){
this.$el.addClass('visible')
}.bind(this), 20)
app.curtain.show('opaque')
setTimeout(function(){
app.curtain.show('opaque')
}, 300)
},
hide: function(){
this.alreadyShown = true
localStorage.setItem('app.intro_modal_last_message', app.store.modalContent)
app.curtain.hide()
this.$el.removeClass('visible')
setTimeout(function(){
this.$el.hide()
app.curtain.$el.removeClass('opaque')
if (this.curtainBackgroundColor) {
app.curtain.$el.removeClass(this.curtainBackgroundColor)
}
}.bind(this), 300)
},
navigateToTagline: function(){
var modalTaglineHref = app.store.modalTaglineLink.trim()
if (modalTaglineHref.length) {
this.hide()
console.log(modalTaglineHref)
if (modalTaglineHref.indexOf('http') === 0) {
window.open(modalTaglineHref, '_system')
} else {
app.router.go(modalTaglineHref)
}
}
},
navigate: function(e){
var href = $(e.currentTarget).attr('href').replace('#', '')
console.log(href)
this.hide()
app.router.go(href)
},
proceed: function(){
console.log('proceed')
this.hide()
},
})
|