Skip to content

Instantly share code, notes, and snippets.

@ashukasma
Last active December 17, 2015 08:02
Show Gist options
  • Save ashukasma/26d36e5c90de1dfe26a3 to your computer and use it in GitHub Desktop.
Save ashukasma/26d36e5c90de1dfe26a3 to your computer and use it in GitHub Desktop.
Sale Banner code
{% if template contains 'index' %}
{% assign balckfridayimage = 'blackfriday.png'%}
{% assign url = '/collections/sale' %}
<style>
#bfsale{
position:fixed;
left:0px;
bottom:0px;
opacity:0;
display: block;
z-index:999;
}
#bfsale img{
max-width:100%;
display: block;
}
#bfclose{
position: absolute;
right: -8px;
top: -8px;
width: 20px;
height: 20px;
font-size: 15px;
line-height: 20px;
font-family: monospace;
border-radius: 15px;
background: #fff;
border: 1px solid #999;
color: #999;
display: block;
text-align: center;
cursor:pointer;
}
</style>
<div id="bfsale" >
<span id="bfclose">X</span>
<a href="{{url}}" target="_blank">
<img src="{{ balckfridayimage | asset_url}}">
</a>
</div>
<script>
function fadeIn(element) {
var op = 0.1; // initial opacity
var timer = setInterval(function () {
if (op >= 1){
clearInterval(timer);
}
element.style.opacity = op;
element.style.filter = 'alpha(opacity=' + op * 100 + ")";
op += op * 0.1;
}, 50);
}
document.addEventListener("DOMContentLoaded", function(event) {
//do work
setTimeout(function(){
var bfsale= document.getElementById('bfsale');
fadeIn(bfsale);
},1000);
});
document.getElementById("bfclose").addEventListener("click", function(){
var bfsale= document.getElementById('bfsale');
bfsale.style.display = "none";
});
</script>
{% endif %}
{% include 'black-friday-sale-banner' %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment