Showing/hiding main funding banner
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 14 May 2013 14:25:01 +0000 (16:25 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 3 Jun 2013 08:03:30 +0000 (10:03 +0200)
apps/funding/static/funding/funding.js [new file with mode: 0644]
apps/funding/static/funding/funding.scss
apps/funding/templates/funding/tags/funding.html
apps/funding/templatetags/funding_tags.py
apps/wolnelektury_core/templates/superbase.html
wolnelektury/settings/static.py

diff --git a/apps/funding/static/funding/funding.js b/apps/funding/static/funding/funding.js
new file mode 100644 (file)
index 0000000..5b3b3f0
--- /dev/null
@@ -0,0 +1,27 @@
+$(function() {
+    $('.funding .close').click(function(e) {\r
+        e.preventDefault();
+        var fundNode = $(e.target).parent();\r
+        fundNode.slideUp(function(){fundingHandle.show()});
+        if(Modernizr.localstorage)
+            localStorage['hide-offer-id'] = fundNode.attr('data-offer-id');\r
+    });
+        
+
+    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');
+    });\r
+});
\ No newline at end of file
index 50fb864..059cc16 100755 (executable)
@@ -2,6 +2,7 @@
     background: orange;
     margin: auto;
     padding: 5px 0;
     background: orange;
     margin: auto;
     padding: 5px 0;
+    position: relative;
     a.call {
         height: 1.2em;
         width: 9em;
     a.call {
         height: 1.2em;
         width: 9em;
         font-weight: bold;
         font-size: 1.5em;
     }
         font-weight: bold;
         font-size: 1.5em;
     }
-    
+    .close {
+        position: absolute;
+        top: 0px;
+        right: 5px;
+    }
 }
 
 .funding-top-header {
 }
 
 .funding-top-header {
         }
     }
 }
         }
     }
 }
+
+.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
index 751f59f..73de1ac 100755 (executable)
@@ -2,7 +2,8 @@
 {% load time_tags %}
 {% if offer %}
 {% spaceless %}
 {% load time_tags %}
 {% if offer %}
 {% spaceless %}
-<div class="funding {{ add_class }}" style="">
+<div class="funding {{ add_class }}" data-offer-id="{{offer.id}}" style="">
+    {% if closeable %}<a href="#" class="close">X</a>{% endif %}
     {% if link and is_current %}
         <div style="float:left; padding-right: .6em;">
             <a class="call honking" href="{% url 'funding_current' offer.slug %}">
     {% if link and is_current %}
         <div style="float:left; padding-right: .6em;">
             <a class="call honking" href="{% url 'funding_current' offer.slug %}">
@@ -39,5 +40,8 @@
     </div>
     <div style="clear: both"></div>
 </div>
     </div>
     <div style="clear: both"></div>
 </div>
+{% if closeable %}
+    <div class="funding-handle">{% trans "Help free the book!" %}</div>
+{% endif %}
 {% endspaceless %}
 {% endif %}
 {% endspaceless %}
 {% endif %}
index bfac265..2d6ea35 100755 (executable)
@@ -5,7 +5,7 @@ register = template.Library()
 
 
 @register.inclusion_tag("funding/tags/funding.html", takes_context=True)
 
 
 @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:
     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,
         'missing': offer.target - offer_sum,
         'percentage': 100 * offer_sum / offer.target,
         'link': link,
+        'closeable': closeable,
         'add_class': add_class,
     }
 
         'add_class': add_class,
     }
 
index 58fddff..0d1ffa6 100644 (file)
@@ -35,7 +35,7 @@
         {% include "annoy.html" %}
 
         {% block bodycontent %}
         {% include "annoy.html" %}
 
         {% block bodycontent %}
-        {% funding link=1 add_class="funding-top-header" %}
+        {% funding link=1 closeable=1 add_class="funding-top-header" %}
                <div id="header-bg"></div>
 
         <div id="header">
                <div id="header-bg"></div>
 
         <div id="header">
index cdfb30a..960b800 100644 (file)
@@ -87,7 +87,8 @@ PIPELINE_JS = {
             'sponsors/js/sponsors.js',
             'player/openplayer.js',
             'js/search.js',
             'sponsors/js/sponsors.js',
             'player/openplayer.js',
             'js/search.js',
-
+            'funding/funding.js',
+            
             'js/annoy.js',
             ),
         'output_filename': 'js/base.min.js',
             'js/annoy.js',
             ),
         'output_filename': 'js/base.min.js',