(function() { if (typeof HostedEmailSocializer !== 'undefined') return; HostedEmailSocializer = Class.create({ FacebookPopupState: { Exposed: 1, Hidden: 0 }, initialize: function() { if (typeof HostedEmailSocializer.instance !== 'undefined') return; HostedEmailSocializer.instance = this; this.initializeAddThis(); this.initializeFacebook(); this.initializeLinkedIn(); }, initializeLinkedIn: function() { document.observe('dom:loaded', function(e) { //$('linkedin').down('a').observe('click', function(e) { // this.fireEvent('linkedin_share'); //}.bind(this)); }.bind(this)); }, initializeAddThis: function() { addthis.addEventListener('addthis.menu.share', function(event) { this.fireEvent(event.data.service + '_share'); }.bind(this)); }, initializeFacebook: function() { FB.Event.subscribe('edge.create', function(href, widget) { this.fireEvent('facebook_like'); this.hideFacebookPopup(); }.bind(this)); var channelUrl = document.location.protocol + '//' + document.location.host + '/facebook_channel.html'; FB.init({ channelUrl: channelUrl, xfbml: false, version: 'v2.2' }); this.facebookPopupState = this.FacebookPopupState.Hidden; if (window.location.hash == '#like') { document.observe('dom:loaded', this.exposeFacebookPopup.bind(this)); } else { document.observe('dom:loaded', function() { FB.XFBML.parse(); }); } }, hideFacebookPopup: function() { if (this.facebookPopupState != this.FacebookPopupState.Exposed) return; Element.remove(this.likeElm); Element.remove(this.backgroundElm); Element.remove(this.maskElm); this.facebookPopupState = this.FacebookPopupState.Hidden; }, exposeFacebookPopup: function() { if (this.facebookPopupState != this.FacebookPopupState.Hidden) return; // Mask (background shader) this.maskElm = new Element('div', { 'class': 'vr_hosted_email_socializer_like_mask', 'style': 'width: ' + this.getViewportForAllBrowsers()[0] + 'px; ' + 'height: ' + this.getViewportForAllBrowsers()[1] + 'px' }); // Popup background this.backgroundElm = new Element('div', { 'class': 'vr_hosted_email_socializer_like_popup' }); // Popup this.likeElm = new Element('div', { 'class': 'vr_hosted_email_socializer_like_content' }); this.likeElm.innerHTML = '
To like this email, please click the Like button below:

' + '
' + '' + '
' + '

'; Element.observe(Element.down(this.likeElm, 'button'), 'click', this.hideFacebookPopup.bind(this)); document.body.appendChild(this.maskElm); document.body.appendChild(this.backgroundElm); document.body.appendChild(this.likeElm); Element.show(this.likeElm); this.facebookPopupState = this.FacebookPopupState.Exposed; // Manually parse FBML FB.XFBML.parse(); }, fireEvent: function(event) { // }, getViewportForAllBrowsers: function() { var viewportwidth; var viewportheight; // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight if (typeof window.innerWidth != 'undefined') { viewportwidth = window.innerWidth, viewportheight = window.innerHeight } // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document) else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) { viewportwidth = document.documentElement.clientWidth, viewportheight = document.documentElement.clientHeight } // older versions of IE else { viewportwidth = document.getElementsByTagName('body')[0].clientWidth, viewportheight = document.getElementsByTagName('body')[0].clientHeight } return [ viewportwidth, viewportheight ]; } }); })()