Vulcan/client/templates/footer.js

85 lines
2.9 KiB
JavaScript
Raw Normal View History

2012-09-24 16:12:50 +09:00
Template.footer.footerCode = function(){
return getSetting('footerCode');
2012-09-24 10:09:53 +09:00
}
2012-09-24 16:12:50 +09:00
Template.footer.analyticsCode = function(){
return getSetting('analytics_Code');
2012-09-24 08:53:13 +09:00
}
2012-09-24 16:12:50 +09:00
Template.footer.tlkioChannel = function(){
return getSetting('tlkioChannel');
2012-09-24 08:53:13 +09:00
}
Template.footer.rendered = function(){
2012-09-24 11:31:45 +09:00
if((mixpanel_id=getSetting("mixpanel_id")) && !window.mixpanel){
(function (c, a) {
window.mixpanel = a;
var b, d, h, e;
b = c.createElement("script");
b.type = "text/javascript";
b.async = !0;
b.src = ("https:" === c.location.protocol ? "https:" : "http:") + '//cdn.mxpnl.com/libs/mixpanel-2.1.min.js';
d = c.getElementsByTagName("script")[0];
d.parentNode.insertBefore(b, d);
a._i = [];
a.init = function (b, c, f) {
function d(a, b) {
var c = b.split(".");
2 == c.length && (a = a[c[0]], b = c[1]);
a[b] = function () {
a.push([b].concat(Array.prototype.slice.call(arguments, 0)))
}
}
var g = a;
"undefined" !== typeof f ? g = a[f] = [] : f = "mixpanel";
g.people = g.people || [];
h = "disable track track_pageview track_links track_forms register register_once unregister identify name_tag set_config people.identify people.set people.increment".split(" ");
for (e = 0; e < h.length; e++) d(g, h[e]);
a._i.push([b, c, f])
};
a.__SV = 1.1
})(document, window.mixpanel || []);
mixpanel.init(mixpanel_id);
if(Meteor.user()){
var currentUserEmail=getCurrentUserEmail();
mixpanel.people.identify(currentUserEmail);
mixpanel.people.set({
'username': Meteor.user().username,
2012-09-24 15:36:37 +09:00
'createdAt': Meteor.user().createdAt,
2012-09-24 11:31:45 +09:00
'email': currentUserEmail
});
mixpanel.register({
'username': Meteor.user().username,
2012-09-24 15:36:37 +09:00
'createdAt': Meteor.user().createdAt,
'email': currentUserEmail
2012-09-24 11:31:45 +09:00
});
}
}
2012-09-24 08:53:13 +09:00
}
Template.footer.events = {
'click .open-chat': function(e){
e.preventDefault();
if(!window.chat_loaded){
2012-09-24 16:12:50 +09:00
if(tlkioChannel=getSetting('tlkioChannel')){
2012-09-24 08:53:13 +09:00
var target_element = document.getElementById('tlkio'),
channel_name = target_element.getAttribute('data-channel'),
custom_css_path = target_element.getAttribute('data-theme'),
iframe = document.createElement('iframe');
var iframe_src = 'http://embed.tlk.io/' + channel_name;
if (custom_css_path && custom_css_path.length > 0) {
iframe_src += ('?custom_css_path=' + custom_css_path);
}
iframe.setAttribute('src', iframe_src);
iframe.setAttribute('width', '100%');
iframe.setAttribute('height', '100%');
iframe.setAttribute('frameborder', '0');
target_element.appendChild(iframe);
}
window.chat_loaded=true;
}
2012-09-24 08:59:04 +09:00
$('body').toggleClass('chat-open');
2012-09-24 08:53:13 +09:00
$('#tlkio').toggleClass('open');
}
}