Sha256: c2808fd6b787c7e3cb79d53ab14ee0a54c305ebd7f85754a18aa883b170d703e
Contents?: true
Size: 1.21 KB
Versions: 94
Compression:
Stored size: 1.21 KB
Contents
export default () => { const noticeCloseComplete = function(notice) { notice.remove() removeNoticesIfEmpty() } const noticeKey = function (notice) { const id = notice.data('notice-id') return `notice-dismissed(id:${id})` } const isDismissible = function (notice) { return notice.data('notice-dismissible') } const bootstrap = function() { $(document).on('click', '.notice a[data-close]', function(event) { const notice = $(this).parents('.notice') localStorage.setItem(noticeKey(notice), true) TweenLite.to(notice, 0.6, { scale: 0, height: 0, transformOrigin: "center top", ease: Power2.easeIn, onComplete: () => noticeCloseComplete(notice) }); }); } const removeNoticesIfEmpty = function() { if ($('.notices .notice').length === 0) { $('.notices').remove() } } const clearRead = function() { $('.notices .notice').each(function() { const notice = $(this) if(isDismissible(notice)) { return } if (localStorage.getItem(noticeKey(notice))) { $(this).remove() } }) removeNoticesIfEmpty() } $(document).ready(function() { bootstrap() clearRead() }); }
Version data entries
94 entries across 94 versions & 1 rubygems