From: Radek Czajka Date: Mon, 31 Mar 2014 11:40:12 +0000 (+0200) Subject: Add the annoying 1 percent bar. X-Git-Tag: 0.1.18~1 X-Git-Url: https://git.mdrn.pl/fnpdjango.git/commitdiff_plain/c12237ab5666f7bc2e752ccfd874926dd844d186?hp=bb0871a31eef84a99fb187d37600dde563beeb69 Add the annoying 1 percent bar. --- diff --git a/fnpdjango/static/fnpdjango/annoy/annoy.css b/fnpdjango/static/fnpdjango/annoy/annoy.css new file mode 100644 index 0000000..fb5b458 --- /dev/null +++ b/fnpdjango/static/fnpdjango/annoy/annoy.css @@ -0,0 +1,58 @@ +#annoy-on { + font-size: 13px; + line-height: 1.15em; + + padding: .1em 1em; + background: orange; + z-index: 200; + font-family: Arial, sans-serif; + display: block; + padding: 0 1em; + width: 1em; + text-align:center; + border-radius: 0 0 0 1em; + position: absolute; + top: 0; + right: 0; + color: black; + box-shadow: .5em 0 1em black; +} + +#annoy { + font-size: 13px; + line-height: 1.15em; + padding: 1em 5em 1em 0; + display: none; + background: orange; + font-family: Arial, sans-serif; + position: relative; + z-index: 200; + box-shadow: 0 0 1em black; +} +#annoy p { + margin: 0 0 0 10em;; +} +#annoy a { + color: #4E56C8; +} +#annoy img { + float: left; + margin: 0 2em; +} + +#annoy a#annoy-off { + padding: .5em 1em .5em; + width: 1em; + text-align:center; + font-family: Arial, sans-serif; + display: block; + + border-radius: 0 0 0 1em; + position: absolute; + top: 0; + right: 0; + color: black; +} +#annoy a#annoy-off:hover { + cursor: pointer; +} diff --git a/fnpdjango/static/fnpdjango/annoy/annoy.js b/fnpdjango/static/fnpdjango/annoy/annoy.js new file mode 100644 index 0000000..ad1444d --- /dev/null +++ b/fnpdjango/static/fnpdjango/annoy/annoy.js @@ -0,0 +1,40 @@ +(function($) { +$(function() { + +$("#annoy").each(function(i, annoy) { + + var edition = "annoyed" + new Date().getFullYear(); + + var have_localstorage; + try { + localStorage.setItem("test", "test"); + localStorage.removeItem("test"); + have_localstorage = true; + } catch(e) { + have_localstorage = false; + } + + $("#annoy-on").click(function(e) { + e.preventDefault(); + $(annoy).slideDown('fast'); + $(this).hide(); + if (have_localstorage) localStorage.removeItem(edition); + }); + + $("#annoy-off").click(function() { + $(annoy).slideUp('fast'); + $("#annoy-on").show(); + if (have_localstorage) localStorage[edition] = true; + }); + + if (have_localstorage) { + if (!localStorage[edition]) { + $("#annoy-on").hide(); + $(annoy).show(); + } + } + }); + + +}); +})(jQuery); diff --git a/fnpdjango/static/fnpdjango/annoy/procent.png b/fnpdjango/static/fnpdjango/annoy/procent.png new file mode 100644 index 0000000..3d0f82d Binary files /dev/null and b/fnpdjango/static/fnpdjango/annoy/procent.png differ diff --git a/fnpdjango/templates/fnpdjango/annoy.html b/fnpdjango/templates/fnpdjango/annoy.html new file mode 100644 index 0000000..bfec223 --- /dev/null +++ b/fnpdjango/templates/fnpdjango/annoy.html @@ -0,0 +1,17 @@ +{% load static from staticfiles %} +1% +
+ + Logo akcji 1% +

Droga użytkowniczko, drogi użytkowniku!

+

Fundacja Nowoczesna Polska to + organizacja pożytku publicznego działająca na rzecz wolności korzystania + z dóbr kultury. Wesprzyj nasze działania, przeznaczając na nie 1% swojego podatku. + Możesz to zrobić, wpisując w zeznaniu podatkowym numer + KRS 0000070056.

+ +

Dowiedz się więcej

+ + x +
+
diff --git a/fnpdjango/templatetags/fnp_annoy.py b/fnpdjango/templatetags/fnp_annoy.py new file mode 100644 index 0000000..c4a7dec --- /dev/null +++ b/fnpdjango/templatetags/fnp_annoy.py @@ -0,0 +1,16 @@ +from django.conf import settings +from django import template +register = template.Library() + + +@register.simple_tag +def annoy(): + """Annoy people with 1-percent tax plead. + + To use, set FNP_ANNOY to True + and add fnpdjango/annoy/annoy.{css,js} to your template. + """ + if getattr(settings, 'FNP_ANNOY', False): + return template.loader.render_to_string('fnpdjango/annoy.html') + else: + return u"" diff --git a/fnpdjango/templatetags/macros.py b/fnpdjango/templatetags/macros.py old mode 100755 new mode 100644 diff --git a/setup.py b/setup.py index 6444a5c..080b75b 100755 --- a/setup.py +++ b/setup.py @@ -22,13 +22,13 @@ def whole_trees(package_dir, paths): setup( name='fnpdjango', - version='0.1.17', + version='0.1.18', author='Radek Czajka', author_email='radekczajka@nowoczesnapolska.org.pl', url = '', packages=find_packages(), package_data={ - 'fnpdjango': whole_trees('fnpdjango', ['templates', 'locale']), + 'fnpdjango': whole_trees('fnpdjango', ['templates', 'locale', 'static']), 'fnpdjango.deploy': ['templates/*.template'], 'fnpdjango.management.commands': ['babel.cfg'], },