Skip to content

Instantly share code, notes, and snippets.

@amywieliczka
Last active November 19, 2015 21:37
Show Gist options
  • Save amywieliczka/fcfbea187b4211b1eafa to your computer and use it in GitHub Desktop.
Save amywieliczka/fcfbea187b4211b1eafa to your computer and use it in GitHub Desktop.
Banner for the old Calisphere
var CDL = (typeof CDL !== 'undefined') ? CDL : {};
CDL.calisphereBanner = (typeof CDL.calisphereBanner !== 'undefined') ? CDL.calisphereBanner : function() {
var bannerDisplayed;
var ca = document.cookie.split(';');
for (var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0) === ' ') { c = c.substring(1); }
if (c.indexOf('bannerDisplayed=') === 0) { bannerDisplayed = c.substring('bannerDisplayed='.length, c.length); }
}
if (!bannerDisplayed) {
$('body').append("<a href='http://www.calisphere.cdlib.org'><div id='calisphereBanner' style='z-index: 100; display: none; box-sizing: content-box; width: 688px; height: 212px; border: 1px solid black; position: fixed; bottom: 0; left: 100px; font-family: arial; text-align: left;'><button type='button' id='closeCalisphereBanner' style='z-index: 20; position: absolute; top: 2px; right: 7px; float: right; padding: 0; border: 0; cursor: pointer; background-color: transparent; font-family: Helvetica Neue,Helvetica,Arial,sans-serif; font-size: 20px; line-height: 1; opacity: .7; color: rgb(0,79,99);' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>x</span></button><div style='overflow: auto; background-color: #fff;'><div style='float: left;'><img src='http://cdn.calisphere.org/json4lib/banner-img.png'></div><div style='display: table-cell; float: none; width: auto; padding: 15px 15px 3px 15px; color: #fff; background-color: #00778b; line-height: initial; letter-spacing: .1em;'><p style='margin: 0 0 8.4px 0; font-size: 17.4px;'>Have you heard?</p><p style='margin: 0 0 27.1px 0; font-size: 17.4px;'>There&#39;s a new Calisphere!</p><p style='margin: 0 0 10px 0; font-size: 14.78px'>Visit our beta site to find even more primary sources.</p></div><img src='http://cdn.calisphere.org/json4lib/calisphere-logo.png'></div></div></a>");
var d = new Date();
d.setTime(d.getTime() + (1*24*60*60*1000));
var expires = 'expires='+d.toGMTString();
document.cookie = 'bannerDisplayed=true; ' + expires + '; path=/;';
$('#calisphereBanner').delay(2000).slideDown(800);
$('#closeCalisphereBanner').hover(
function() {
$('#closeCalisphereBanner').css({'opacity': '1', 'color': '#000'});
},
function() {
$('#closeCalisphereBanner').css({'opacity': '.7', 'color': 'rgb(0,79,99)'});
}
);
$('#closeCalisphereBanner').click(
function(e) {
e.preventDefault();
e.stopPropagation();
$('#calisphereBanner').slideUp(800);
}
);
}
};
(function() {
if (typeof jQuery === 'undefined') {
// more or less stolen form jquery core and adapted by paul irish
function getScript(url,success){
var script=document.createElement('script');
script.src=url;
var head=document.getElementsByTagName('head')[0],
done=false;
// Attach handlers for all browsers
script.onload=script.onreadystatechange = function(){
if ( !done && (!this.readyState ||
this.readyState === 'loaded' ||
this.readyState === 'complete') ) {
done=true;
success();
script.onload = script.onreadystatechange = null;
head.removeChild(script);
}
};
head.appendChild(script);
}
getScript('https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js', function() {
if (typeof jQuery === 'undefined') {
} else {
$(document).ready(CDL.calisphereBanner);
}
});
}
else {
CDL.calisphereBanner();
}
})();
@amywieliczka
Copy link
Author

This gist uses the following two attached files.

banner-img
calisphere-logo

@tingletech
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment