diff --git a/docs/_static/js/kickstarter.js b/docs/_static/js/kickstarter.js new file mode 100644 index 000000000..7d41edb9f --- /dev/null +++ b/docs/_static/js/kickstarter.js @@ -0,0 +1,74 @@ +function setCookie(name, value, days) { + const date = new Date(); + date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); + document.cookie = encodeURIComponent(name) + '=' + + encodeURIComponent(value) + + '; expires=' + date.toGMTString(); +} + +function hasCookie(name, value) { + return document.cookie.split('; ').indexOf(name + '=' + value) >= 0; +} + +$(function () { + const $kickstarter = $( + '' + + '' + + ' ×' + + ' Please consider supporting ' + + ' NoriPyt’s Wagtail Kickstarter' + + ' ' + + ' ' + + ' to accelerate the development of this project.' + + ''); + + if (!hasCookie('kickstarterClosed', 'true') + && new Date() < new Date(2018, 4, 17)) { + $('body').prepend($kickstarter); + $kickstarter.find('.close').click(function (e) { + e.preventDefault(); + setCookie('kickstarterClosed', 'true', 30); + $kickstarter.detach(); + }); + } +}); diff --git a/docs/conf.py b/docs/conf.py index 2597f7a92..34c07b1b4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -289,3 +289,4 @@ texinfo_documents = [ def setup(app): app.add_stylesheet('css/custom.css') + app.add_javascript('js/kickstarter.js')