Skip to content

Instantly share code, notes, and snippets.

@oscarotero
Last active September 9, 2016 07:45
Show Gist options
  • Save oscarotero/3c3ec20267098f06c67b7a5966ee364d to your computer and use it in GitHub Desktop.
Save oscarotero/3c3ec20267098f06c67b7a5966ee364d to your computer and use it in GitHub Desktop.
Scripts comúns
var $cookies = $('#cookies-message');
var cookies = localStorage.getItem('accept-cookies');
if (cookies !== 'accepted') {
$cookies.removeClass('is-accepted');
}
$cookies.find('button').on('click', function () {
$cookies.fadeOut('normal');
localStorage.setItem('accept-cookies', 'accepted');
});
/* Compartir nas redes sociais */
$('.js-share').click(function (e) {
e.preventDefault();
window.open($(this).attr('href'), 'share', 'toolbar=0, status=0, width=650, height=360');
});
/* Cabeceira "sticky" */
var sticked = false;
var $window = $(window);
var $html = $('html');
$window.on('scroll', function() {
var pos = $window.scrollTop();
if (pos > 5 && !sticked) {
$html.addClass('is-scrolled');
sticked = true;
} else if (pos < 5 && sticked) {
$html.removeClass('is-scrolled');
sticked = false;
}
}).trigger('scroll');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment