From: Aleksander Ɓukasz Date: Tue, 14 May 2013 14:25:01 +0000 (+0200) Subject: Showing/hiding main funding banner X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/114d9964082b2ca6c0e18214d761021dbca362de Showing/hiding main funding banner --- diff --git a/apps/funding/static/funding/funding.js b/apps/funding/static/funding/funding.js new file mode 100644 index 000000000..5b3b3f072 --- /dev/null +++ b/apps/funding/static/funding/funding.js @@ -0,0 +1,27 @@ +$(function() { + $('.funding .close').click(function(e) { + e.preventDefault(); + var fundNode = $(e.target).parent(); + fundNode.slideUp(function(){fundingHandle.show()}); + if(Modernizr.localstorage) + localStorage['hide-offer-id'] = fundNode.attr('data-offer-id'); + }); + + + var fundingTopHeader = $('.funding-top-header'); + var fundingHandle = $('.funding-handle'); + if(fundingTopHeader) { + var currentOfferId = fundingTopHeader.attr('data-offer-id'); + var toggle = true; + if(Modernizr.localstorage) { + toggle = localStorage['hide-offer-id'] !== currentOfferId; + } + fundingTopHeader.toggle(toggle); + fundingHandle.toggle(!toggle); + } + fundingHandle.click(function(e) { + fundingTopHeader.slideDown(); + $(e.target).hide(); + localStorage.removeItem('hide-offer-id'); + }); +}); \ No newline at end of file diff --git a/apps/funding/static/funding/funding.scss b/apps/funding/static/funding/funding.scss index 50fb86447..059cc1651 100755 --- a/apps/funding/static/funding/funding.scss +++ b/apps/funding/static/funding/funding.scss @@ -2,6 +2,7 @@ background: orange; margin: auto; padding: 5px 0; + position: relative; a.call { height: 1.2em; width: 9em; @@ -52,7 +53,11 @@ font-weight: bold; font-size: 1.5em; } - + .close { + position: absolute; + top: 0px; + right: 5px; + } } .funding-top-header { @@ -116,3 +121,15 @@ } } } + +.funding-handle { + position: absolute; + top: 0; + right: 0; + z-index:2; + background: orange; + cursor:pointer; + padding: .2em 1em; + border-radius: 0 0 0 1em; + font-size: 13px; +} \ No newline at end of file diff --git a/apps/funding/templates/funding/tags/funding.html b/apps/funding/templates/funding/tags/funding.html index 751f59f4a..73de1accc 100755 --- a/apps/funding/templates/funding/tags/funding.html +++ b/apps/funding/templates/funding/tags/funding.html @@ -2,7 +2,8 @@ {% load time_tags %} {% if offer %} {% spaceless %} -
+
+ {% if closeable %}X{% endif %} {% if link and is_current %}
@@ -39,5 +40,8 @@
+{% if closeable %} +
{% trans "Help free the book!" %}
+{% endif %} {% endspaceless %} {% endif %} diff --git a/apps/funding/templatetags/funding_tags.py b/apps/funding/templatetags/funding_tags.py index bfac2654e..2d6ea35c6 100755 --- a/apps/funding/templatetags/funding_tags.py +++ b/apps/funding/templatetags/funding_tags.py @@ -5,7 +5,7 @@ register = template.Library() @register.inclusion_tag("funding/tags/funding.html", takes_context=True) -def funding(context, offer=None, link=False, add_class=""): +def funding(context, offer=None, link=False, closeable=False, add_class=""): if offer is None and context.get('funding_no_show_current') is None: offer = Offer.current() if offer is None: @@ -20,6 +20,7 @@ def funding(context, offer=None, link=False, add_class=""): 'missing': offer.target - offer_sum, 'percentage': 100 * offer_sum / offer.target, 'link': link, + 'closeable': closeable, 'add_class': add_class, } diff --git a/apps/wolnelektury_core/templates/superbase.html b/apps/wolnelektury_core/templates/superbase.html index 58fddff9d..0d1ffa6a7 100644 --- a/apps/wolnelektury_core/templates/superbase.html +++ b/apps/wolnelektury_core/templates/superbase.html @@ -35,7 +35,7 @@ {% include "annoy.html" %} {% block bodycontent %} - {% funding link=1 add_class="funding-top-header" %} + {% funding link=1 closeable=1 add_class="funding-top-header" %}