Created
August 25, 2014 23:54
-
-
Save joelip/7c025520912596dcecf9 to your computer and use it in GitHub Desktop.
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
(function() { | |
var borderRadius, closeBookmarklet, closeButton, css, cssBody, iframe, inProgressBanner, inProgressBannerText, receiveMessage, shadow, targetUrl, title, url, | |
_this = this; | |
if (window.location.host === "www.potluck.it" || window.nestBookmarkletShown) { | |
return; | |
} else { | |
window.nestBookmarkletShown = true; | |
} | |
shadow = "0 0 15px rgba(0,0,0,0.45)"; | |
borderRadius = "4px"; | |
cssBody = ".nest-bookmarklet {\n | |
font-family: \"Lucida Grande\", Helvetica, Arial;\n | |
font-size: 13px;\n\n | |
position: fixed;\n | |
top: 0;\n | |
bottom: 0;\n | |
right: 0;\n | |
z-index: 9999;\n | |
z-index: 2147483647;\n | |
}\n\n | |
.nest-bookmarklet.in-progress {\n | |
width: 150px;\n | |
height: 50px;\n | |
margin: 15px;\n | |
background-color: #F8F8F6;\n | |
text-align: center;\n\n | |
-webkit-box-shadow: " + shadow + ";\n | |
-moz-box-shadow: " + shadow + ";\n | |
box-shadow: " + shadow + ";\n | |
-webkit-border-radius: " + borderRadius + ";\n | |
-moz-border-radius: " + borderRadius + ";\n | |
border-radius: " + borderRadius + ";\n | |
background-color: #F8F8F6;\n | |
border: 1px solid #AEABA8;\n | |
}\n\n | |
.nest-bookmarklet-in-progress-text {\n | |
font-size: 20px;\n | |
line-height: 50px;\n | |
font-weight: bold;\n | |
color: #949493;\n | |
}\n\n\n | |
.nest-bookmarklet.iframe {\n | |
visibility: hidden;\n | |
width: 450px;\n | |
height: 100%;\n | |
border: 0;\n | |
-webkit-transition: all 0.5s;\n | |
-moz-transition: all 0.5s;\n | |
transition: all 0.5s;\n | |
}\n\n | |
.nest-bookmarklet-close {\n | |
visibility: hidden;\n | |
cursor: pointer;\n | |
position: fixed;\n | |
top: 15px;\n | |
right: 17px;\n | |
font-size: 15px;\n | |
line-height: 16px;\n | |
font-weight: bold;\n | |
font-family: \"Arial\";\n | |
z-index: 999999999;\n | |
z-index: 3147483647;\n | |
color: #949493;\n | |
}\n\n | |
.nest-bookmarklet-pop {\n | |
-webkit-transform: scale(0.1);\n | |
-webkit-transform-origin: 50% -20%;\n\n | |
-moz-transform: scale(0.1);\n | |
-moz-transform-origin: 50% -20%;\n\n | |
transform: scale(0.1);\n | |
transform-origin: 50% -20%;\n\n | |
opacity: 0;\n | |
}"; | |
css = document.createElement('style'); | |
css.type = 'text/css'; | |
css.innerHTML = cssBody; | |
document.body.appendChild(css); | |
inProgressBanner = document.createElement('div'); | |
inProgressBanner.className = 'nest-bookmarklet in-progress'; | |
inProgressBannerText = document.createElement('div'); | |
inProgressBannerText.className = 'nest-bookmarklet-in-progress-text'; | |
inProgressBannerText.innerHTML = 'Loading...'; | |
inProgressBanner.appendChild(inProgressBannerText); | |
document.body.appendChild(inProgressBanner); | |
url = encodeURIComponent(window.location.href); | |
title = encodeURIComponent(document.title); | |
targetUrl = "//www.potluck.it/rooms/new?bookmarklet=1&url=" + url + "&title=" + title; | |
iframe = document.createElement('iframe'); | |
iframe.className = 'nest-bookmarklet iframe nest-bookmarklet-pop'; | |
iframe.src = targetUrl; | |
document.body.appendChild(iframe); | |
closeButton = document.createElement('div'); | |
closeButton.className = 'nest-bookmarklet-close'; | |
closeButton.innerHTML = "×"; | |
document.body.appendChild(closeButton); | |
receiveMessage = function(event) { | |
if (event.origin.indexOf("www.potluck.it") === -1) { | |
return; | |
} | |
if (event.data === 'close') { | |
return closeBookmarklet(); | |
} | |
}; | |
window.addEventListener("message", receiveMessage, false); | |
closeBookmarklet = function() { | |
iframe.className = 'nest-bookmarklet iframe nest-bookmarklet-pop'; | |
closeButton.parentNode.removeChild(closeButton); | |
return setTimeout(function() { | |
iframe.parentNode.removeChild(iframe); | |
return window.nestBookmarkletShown = false; | |
}, 400); | |
}; | |
iframe.onload = function() { | |
inProgressBanner.parentNode.removeChild(inProgressBanner); | |
iframe.style.visibility = 'visible'; | |
iframe.className = 'nest-bookmarklet iframe'; | |
return setTimeout(function() { | |
return closeButton.style.visibility = 'visible'; | |
}, 400); | |
}; | |
closeButton.onclick = function() { | |
return closeBookmarklet(); | |
}; | |
}).call(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment