I see that you've placed:
Code:
<script data-require="jquery@2.2.4" data-semver="2.2.4" src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script><script src="exchange.js"></script>
after every listing it looks like, or a lot of them. You don't need any of those. You only need what you already have at the end of the page.
As to sprites:
Hmm, I'm not all that up on imagesprites. I mean I know that a sprite is usually a background image that is composed of two or more images in one and that the image you see is set by the size of the element having the sprite as a background image and by the background position style on that element. As you can see, you can put any HTML you like into the currencyrates function. So you just need to put the elements in there that would have the sprite and set their background-image, background-position, and dimensions in style. One other consideration, their display style property should probably be inline-block for that because you want them to be able to have width and height but not cause a line break. So something like:
Code:
jQuery.fn.currencyrates = function(rates){
var base = this.text().replace(/\D/g, '');
this.append ([' , <span class="usd"><span class="curr-ico"></span> $ ', commatize(base * rates.USD), '</span>',
' , <span class="gpb"><span class="curr-ico"></span> £ ', commatize(base * rates.GBP), '</span>',
' , <span class="eur"><span class="curr-ico"></span> € ', commatize(base * rates.EUR), '</span>'].join(''));
}
Then in your stylesheet you could have something like so (assuming your image sprite is named as indicated):
Code:
.curr-ico {
width: 20px;
height: 20px;
background-image: url('img/curr-ico-sprite.png');
display: inline-block;
}
.usd .curr-ico {
background-position: 0;
}
.gbp .curr-ico {
background-position: 0 20px;
}
.eur .curr-ico {
background-position: 0 40px;
}
The actual positioning would have to correspond to what works best with your image sprite, which you would have to make (or find one) to be suitable for that purpose.
Bookmarks