Skip to content

Instantly share code, notes, and snippets.

@cadecairos
Created July 21, 2011 14:57
Show Gist options
  • Save cadecairos/1097367 to your computer and use it in GitHub Desktop.
Save cadecairos/1097367 to your computer and use it in GitHub Desktop.
if ( binding === "bindWindow" ) {
editorWindow = targetWindow || window.open( editorSrc, "", "width=" + editorWidth + ",height=" + editorHeight + ",menubar=no,toolbar=no,location=no,status=no" );
setupServer();
editorWindow.addEventListener( "unload", function() {
console.log ("unload!");
butter.unlisten ( "trackeventupdated", updateEditor );
butter.trigger( "trackeditforcedclosed" );
}, false );
}
function setupServer() {
commServer[ binding ]( "editorCommLink", editorWindow, function() {
butter.listen( "trackeventupdated", updateEditor );
butter.listen( "targetadded", function() {
commServer.send( "editorCommLink", butter.getTargets(), "updatedomtargets" );
});
commServer.listen( "editorCommLink", "okayclicked", function( newOptions ){
trackEvent.popcornOptions = newOptions;
editorWindow.close && editorWindow.close();
editorWindow && editorWindow.parentNode && editorWindow.parentNode.removeChild( editorWindow );
butter.unlisten ( "trackeventupdated", updateEditor );
butter.trigger( "trackeditclosed" );
butter.trigger( "trackeventupdated", trackEvent );
});
commServer.listen( "editorCommLink", "applyclicked", function( newOptions ) {
trackEvent.popcornOptions = newOptions;
butter.trigger( "trackeventupdated", trackEvent );
});
commServer.listen( "editorCommLink", "deleteclicked", function() {
butter.removeTrackEvent( trackEvent );
editorWindow.close && editorWindow.close();
editorWindow && editorWindow.parentNode && editorWindow.parentNode.removeChild( editorWindow );
butter.unlisten ( "trackeventupdated", updateEditor );
butter.trigger( "trackeditclosed" );
});
commServer.listen( "editorCommLink", "cancelclicked", function() {
editorWindow.close && editorWindow.close();
editorWindow && editorWindow.parentNode && editorWindow.parentNode.removeChild( editorWindow );
butter.unlisten ( "trackeventupdated", updateEditor );
butter.trigger( "trackeditclosed" );
});
commServer.send( "editorCommLink", { trackEvent: trackEvent, targets: butter.getTargets() }, "edittrackevent");
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment