-
-
Save dandrews/fdd4e2721bab4ec941b10f62288c7b0b to your computer and use it in GitHub Desktop.
Turbolinks-compatible version of the Groove support widget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- BEGIN GROOVE WIDGET CODE --> | |
<script id="grv-widget"> | |
/*<![CDATA[*/ | |
window.groove = window.groove || {}; groove.widget = function(){ groove._widgetQueue.push(Array.prototype.slice.call(arguments)); }; groove._widgetQueue = []; | |
groove.widget('setWidgetId', 'INSERT YOUR WIDGET ID HERE'); | |
groove.widget('setAutoload', false); | |
(function(){ | |
var loadEvent = 'turbolinks:load'; | |
var unloadEvent = 'turbolinks:before-visit'; | |
var loadHandler = function() { | |
document.removeEventListener(loadEvent, loadHandler); | |
document.addEventListener(unloadEvent, unloadHandler); | |
groove.widget('load'); | |
}; | |
var unloadHandler = function() { | |
document.removeEventListener(unloadEvent, unloadHandler); | |
groove.widget('unload'); | |
}; | |
document.addEventListener(loadEvent, loadHandler); | |
setTimeout(function() { | |
!function(g,r,v){var a,c,n=r.createElement("iframe");(n.frameElement||n).style.cssText="width: 0; height: 0; border: 0",n.title="",n.role="presentation",n.src="javascript:false",r.body.appendChild(n);try{a=n.contentWindow.document}catch(b){c=r.domain;var d="javascript:document.write('<head><script>document.domain=\""+c+"\";</",i="script></head><body></body>')";n.src=d+i,a=n.contentWindow.document}var s="https:"==r.location.protocol?"https://":"http://",p="http://groove-widget-production.s3.amazonaws.com".replace("http://",s);n.className="grv-widget-tag",a.open()._l=function(){c&&(this.domain=c);var t=this.createElement("script");t.type="text/javascript",t.charset="utf-8",t.async=!0,t.src=p+"/loader.js",this.body.appendChild(t)},a.write('<body onload="document._l();">'),a.close()}(window,document); | |
}, 1); | |
})(); | |
/*]]>*/ | |
</script> | |
<!-- END GROOVE WIDGET CODE --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment