-
Notifications
You must be signed in to change notification settings - Fork 11.5k
/
Copy pathmain.coffee
164 lines (133 loc) · 4.26 KB
/
main.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
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
Template.body.onRendered ->
dataLayerComputation = Tracker.autorun ->
w = window
d = document
s = 'script'
l = 'dataLayer'
i = RocketChat.settings.get 'API_Analytics'
if Match.test(i, String) and i.trim() isnt ''
dataLayerComputation?.stop()
do (w,d,s,l,i) ->
w[l] = w[l] || []
w[l].push {'gtm.start': new Date().getTime(), event:'gtm.js'}
f = d.getElementsByTagName(s)[0]
j = d.createElement(s)
dl = if l isnt 'dataLayer' then '&l=' + l else ''
j.async = true
j.src = '//www.googletagmanager.com/gtm.js?id=' + i + dl
f.parentNode.insertBefore j, f
metaLanguageComputation = Tracker.autorun ->
if RocketChat.settings.get 'Meta:language'
metaLanguageComputation?.stop()
Meta.set
name: 'http-equiv'
property: 'content-language'
content: RocketChat.settings.get 'Meta:language'
Meta.set
name: 'name'
property: 'language'
content: RocketChat.settings.get 'Meta:language'
metaFBComputation = Tracker.autorun ->
if RocketChat.settings.get 'Meta:fb:app_id'
metaFBComputation?.stop()
Meta.set
name: 'property'
property: 'fb:app_id'
content: RocketChat.settings.get 'Meta:fb:app_id'
metaRobotsComputation = Tracker.autorun ->
if RocketChat.settings.get 'Meta:robots'
metaRobotsComputation?.stop()
Meta.set
name: 'name'
property: 'robots'
content: RocketChat.settings.get 'Meta:robots'
metaGoogleComputation = Tracker.autorun ->
if RocketChat.settings.get 'Meta:google-site-verification'
metaGoogleComputation?.stop()
Meta.set
name: 'name'
property: 'google-site-verification'
content: RocketChat.settings.get 'Meta:google-site-verification'
metaMSValidateComputation = Tracker.autorun ->
if RocketChat.settings.get 'Meta:msvalidate.01'
metaMSValidateComputation?.stop()
Meta.set
name: 'name'
property: 'msvalidate.01'
content: RocketChat.settings.get 'Meta:msvalidate.01'
if Meteor.isCordova
$(document.body).addClass 'is-cordova'
Template.main.helpers
logged: ->
if Meteor.userId()?
$('html').addClass("noscroll").removeClass("scroll")
return true
else
$('html').addClass("scroll").removeClass("noscroll")
return false
subsReady: ->
return not Meteor.userId()? or (FlowRouter.subsReady('userData', 'activeUsers'))
hasUsername: ->
return Meteor.userId()? and Meteor.user().username?
flexOpened: ->
console.log 'layout.helpers flexOpened' if window.rocketDebug
return 'flex-opened' if Session.equals('flexOpened', true)
flexOpenedRTC1: ->
console.log 'layout.helpers flexOpenedRTC1' if window.rocketDebug
return 'layout1' if Session.equals('rtcLayoutmode', 1)
flexOpenedRTC2: ->
console.log 'layout.helpers flexOpenedRTC2' if window.rocketDebug
return 'layout2' if (Session.get('rtcLayoutmode') > 1)
Template.main.events
"click .burger": ->
console.log 'room click .burger' if window.rocketDebug
chatContainer = $("#rocket-chat")
menu.toggle()
'touchstart': (e, t) ->
if document.body.clientWidth > 780
return
t.touchstartX = undefined
t.touchstartY = undefined
t.movestarted = false
if $(e.currentTarget).closest('.main-content').length > 0
t.touchstartX = e.originalEvent.touches[0].clientX
t.touchstartY = e.originalEvent.touches[0].clientY
t.mainContent = $('.main-content')
'touchmove': (e, t) ->
if t.touchstartX?
touch = e.originalEvent.touches[0]
diffX = t.touchstartX - touch.clientX
diffY = t.touchstartY - touch.clientY
absX = Math.abs(diffX)
absY = Math.abs(diffY)
if t.movestarted is true or (absX > 20 and absY < 20)
t.movestarted = true
if menu.isOpen()
t.left = 260 - diffX
else
t.left = -diffX
if t.left > 260
t.left = 260
if t.left < 0
t.left = 0
t.mainContent.addClass('notransition')
t.mainContent.css('transform', 'translate('+t.left+'px)')
'touchend': (e, t) ->
t.touchstartX = undefined
if t.movestarted is true
t.mainContent.removeClass('notransition')
t.mainContent.css('transform', '');
if menu.isOpen()
if t.left >= 200
menu.open()
else
menu.close()
else
if t.left >= 60
menu.open()
else
menu.close()
Template.main.onRendered ->
# RTL Support - Need config option on the UI
if isRtl localStorage.getItem "userLanguage"
$('html').addClass "rtl"