Skip to content

Instantly share code, notes, and snippets.

@tingletech
Forked from amywieliczka/banner-img.png
Last active November 16, 2015 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tingletech/748859fcbe3f39be96bf to your computer and use it in GitHub Desktop.
Save tingletech/748859fcbe3f39be96bf 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='display: none; width: 688px; height: 212px; border: 1px solid black; position: fixed; bottom: 0px; left: 100px; font-family: arial;'><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;'><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; height: 138px; background-color: #00778b; 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.toUTCString();
document.cookie = 'bannerDisplayed=True; ' + '; 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();
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment