promobox, some fixes
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Mon, 27 Aug 2012 11:19:56 +0000 (13:19 +0200)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Mon, 27 Aug 2012 11:19:56 +0000 (13:19 +0200)
21 files changed:
.gitignore
migdal/admin.py
migdal/templates/migdal/entry/entry_detail.html
migdal/templates/migdal/entry/entry_list.html
migdal/templates/migdal/entry/entry_promobox.html
migdal/templates/migdal/entry/info/entry_begin.html
migdal/templatetags/migdal_tags.py
prawokultury/settings.d/50-static.conf
prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/base.scssc [deleted file]
prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/entry.scssc [deleted file]
prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/footer.scssc [deleted file]
prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/header.scssc [deleted file]
prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/layout.scssc [deleted file]
prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/menu.scssc [deleted file]
prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/promobox.scssc [deleted file]
prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/search.scssc [deleted file]
prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/sidebar.scssc [deleted file]
prawokultury/static/css/promobox.css
prawokultury/static/css/promobox.scss
prawokultury/static/js/promobox.js [new file with mode: 0644]
prawokultury/templates/base.html

index fa1b927..5818dca 100644 (file)
@@ -32,3 +32,5 @@ TAGS
 
 media
 search_index
+.sass-cache
+
index 6d4baef..ac0e640 100644 (file)
@@ -59,7 +59,7 @@ class EntryAdmin(admin.ModelAdmin):
 
 
 class CategoryAdmin(admin.ModelAdmin):
-    list_display = translated_fields(('title', 'slug'))
+    list_display = translated_fields(('title', 'slug')) + ('taxonomy',)
     prepopulated_fields = dict([
             ("slug_%s" % lang_code, ("title_%s" % lang_code,))
             for lang_code, lang_name in settings.LANGUAGES
index f37777e..573e139 100755 (executable)
@@ -4,11 +4,7 @@
 
 
 {% block "main_menu" %}
-    {% if entry.categories %}
-        {% main_menu 'objects' entry.categories.all %}
-    {% else %}
-        {% main_menu 'entry_type' entry.type %}
-    {% endif %}
+    {% main_menu 'object' entry %}
 {% endblock "main_menu" %}
 
 
index a68bd2a..e7dd057 100755 (executable)
 <div id="promobox">
 <ul id="promobox-switcher">
 {% for object in object_list.promobox %}
-    <li>
-        <a href="" 
-        {% if forloop.counter == 1 %} class="active"{% endif %}
+    <li {% if forloop.counter == 1 %} class="active"{% endif %}>
+        <a href="{{ object.get_absolute_url }}"
         >{{ forloop.counter }}</a>
     </li>
 {% endfor %}
 </ul>
 
+<div id="promobox-wrapper">
 <ul class="promobox">
 {% for object in object_list.promobox %}
-    {% entry_promobox object %}
+    {% entry_promobox object forloop.counter %}
 {% endfor %}
 </ul>
+</div>
 
 </div>
 {% endif %}
index 110c1cf..0eb9fac 100755 (executable)
@@ -1,13 +1,15 @@
 {% load i18n %}
 
 
-<li class="promobox-item" style="
+<li class="promobox-item"{% if counter == 1 %}class="active"{% endif %}
+    style="
+    {% if counter != 1 %}display: none;{% endif %}
     {% if object.image %}
         background: url('{{ object.image.url }}');
         background-size:100%;
         background-position: 50% 50%;
     {% else %}
-        background: white;
+        background: black;
     {% endif %}
 ">
 
index 256a38d..70d34bd 100755 (executable)
@@ -1,3 +1,4 @@
+{% load i18n %}
 <h2><a href="{{ object.get_absolute_url }}">{{ object.title }}</a></h2>
 
 <div class="entry-data">
index 9c7b15b..8b20f83 100644 (file)
@@ -40,7 +40,7 @@ def entry_short(context, entry):
 
 
 @register.simple_tag(takes_context=True)
-def entry_promobox(context, entry):
+def entry_promobox(context, entry, counter):
     t = template.loader.select_template((
         'migdal/entry/%s/entry_promobox.html' % entry.type,
         'migdal/entry/entry_promobox.html',
@@ -48,6 +48,7 @@ def entry_promobox(context, entry):
     context = {
         'request': context['request'],
         'object': entry,
+        'counter': counter,
     }
     return t.render(template.Context(context))
 
@@ -88,9 +89,9 @@ class MenuItem(object):
 
 
 class ModelMenuItem(object):
-    def __init__(self, obj, html_id=None):
+    def __init__(self, obj, title=None, html_id=None):
         self.obj = obj
-        self.title = unicode(obj)
+        self.title = title or unicode(obj)
         self.url = obj.get_absolute_url()
         self.html_id = html_id
 
@@ -98,6 +99,13 @@ class ModelMenuItem(object):
         self.active = (chooser == 'object' and value == self.obj or
                         chooser == 'objects' and self.obj in value)
 
+class CategoryMenuItem(ModelMenuItem):
+    def check_active(self, chooser, value):
+        super(CategoryMenuItem, self).check_active(chooser, value)
+        self.active = (self.active or
+                       (chooser == 'object' and isinstance(value, Entry) and
+                        self.obj in value.categories.all()))
+
 
 class EntryTypeMenuItem(object):
     def __init__(self, title, type_, html_id=None):
@@ -117,8 +125,8 @@ def main_menu(context, chooser=None, value=None):
         ModelMenuItem(Entry.objects.get(slug_pl='o-nas')),
         EntryTypeMenuItem(_(u'Publications'), u'publications'),
         MenuItem(_(u'Events'), reverse('events')),
-        ModelMenuItem(Category.objects.get(slug_pl='stanowisko')),
-        ModelMenuItem(Category.objects.get(slug_pl='pierwsza-pomoc')),
+        CategoryMenuItem(Category.objects.get(slug_pl='stanowisko'), title=_('Positions')),
+        CategoryMenuItem(Category.objects.get(slug_pl='pierwsza-pomoc')),
     ]
     if context['request'].LANGUAGE_CODE == 'pl':
         items.append(MenuItem(u'en', '/en/', html_id='item-lang'))
index da9a583..2c42405 100755 (executable)
@@ -28,6 +28,14 @@ PIPELINE_CSS = {
         'output_filename': 'compressed/base.css',
     },
 }
+PIPELINE_JS = {
+    'base': {
+        'source_filenames': (
+            'js/promobox.js',
+        ),
+        'output_filename': 'compressed/base.js',
+    },
+}
 
 PIPELINE_COMPILERS = (
   'pipeline.compilers.sass.SASSCompiler',
diff --git a/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/base.scssc b/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/base.scssc
deleted file mode 100644 (file)
index 99915bc..0000000
Binary files a/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/base.scssc and /dev/null differ
diff --git a/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/entry.scssc b/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/entry.scssc
deleted file mode 100644 (file)
index 3ae2702..0000000
Binary files a/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/entry.scssc and /dev/null differ
diff --git a/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/footer.scssc b/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/footer.scssc
deleted file mode 100644 (file)
index 3e59988..0000000
Binary files a/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/footer.scssc and /dev/null differ
diff --git a/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/header.scssc b/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/header.scssc
deleted file mode 100644 (file)
index 2b899cc..0000000
Binary files a/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/header.scssc and /dev/null differ
diff --git a/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/layout.scssc b/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/layout.scssc
deleted file mode 100644 (file)
index 11f8a4e..0000000
Binary files a/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/layout.scssc and /dev/null differ
diff --git a/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/menu.scssc b/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/menu.scssc
deleted file mode 100644 (file)
index 3262a1f..0000000
Binary files a/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/menu.scssc and /dev/null differ
diff --git a/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/promobox.scssc b/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/promobox.scssc
deleted file mode 100644 (file)
index 3a112b5..0000000
Binary files a/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/promobox.scssc and /dev/null differ
diff --git a/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/search.scssc b/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/search.scssc
deleted file mode 100644 (file)
index 4312664..0000000
Binary files a/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/search.scssc and /dev/null differ
diff --git a/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/sidebar.scssc b/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/sidebar.scssc
deleted file mode 100644 (file)
index c49b9ff..0000000
Binary files a/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/sidebar.scssc and /dev/null differ
index 5192095..58c4cfe 100644 (file)
@@ -8,13 +8,16 @@ ul.promobox {
   padding: 0;
   margin: 0;
   height: 32.3em;
-  overflow: hidden; }
+  overflow: hidden;
+  position: relative; }
 
 .promobox-item {
   border-radius: 0 0 2em 0;
   list-style: none;
   padding: 0;
-  margin: 0; }
+  margin: 0;
+  position: absolute;
+  width: 100%; }
 
 .promobox-link {
   background-image: url("/static/img/rog.png");
@@ -39,7 +42,7 @@ ul.promobox {
     padding: .45em .5em;
     border-radius: 0 1em 1em 0;
     color: white; }
-  #promobox-switcher a.active {
+  #promobox-switcher .active a {
     background: #02529b; }
 
 .promobox-info {
index 803a250..cf209c5 100755 (executable)
@@ -10,13 +10,15 @@ ul.promobox {
     margin: 0;
     height: 32.3em;
     overflow: hidden;
-
+    position: relative;
 }
 .promobox-item {
     border-radius: 0 0 2em 0;
     list-style:none;
     padding:0;
     margin: 0;
+    position:absolute;
+    width: 100%;
 }
 .promobox-link {
     background-image: url('/static/img/rog.png');
@@ -44,7 +46,7 @@ ul.promobox {
         border-radius: 0 1em 1em 0;
         color: white;
     }
-    a.active {
+    .active a {
         background: #02529b;
     }
 }
diff --git a/prawokultury/static/js/promobox.js b/prawokultury/static/js/promobox.js
new file mode 100644 (file)
index 0000000..91128ca
--- /dev/null
@@ -0,0 +1,40 @@
+$(document).ready(function(){
+
+var $slides = $("ul.promobox li");
+var $switchers = $("ul#promobox-switcher li");
+
+var change_slide = function(slide_no) {
+    var $slide = $($slides.get(slide_no));
+    var $switcher = $($switchers.get(slide_no));
+
+    $slides.filter('.active').fadeOut();
+    $slides.filter('.active').removeClass('active');
+    $switchers.filter('.active').removeClass('active');
+    $slide.fadeIn();
+    $slide.addClass('active');
+    $switcher.addClass('active');
+    reset_timeout();
+};
+
+
+$switchers.each(function(i, e) {
+    $(e).click(function(e) {
+        e.preventDefault();
+        change_slide(i);
+    });
+});
+
+
+var timeout = null;
+var cycle_slide = function() {
+    var current = $slides.filter('.active').index();
+    change_slide((current + 1) % $slides.length);
+}
+var reset_timeout = function() {
+    clearTimeout(timeout);
+    timeout = setTimeout(cycle_slide, 5000);
+};
+timeout = setTimeout(cycle_slide, 3000);
+
+
+});
\ No newline at end of file
index b21a928..452e3f0 100755 (executable)
@@ -91,5 +91,7 @@
         </div>
 
     </div>
+    <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js" charset="utf-8"></script>
+    {% compressed_js 'base' %}
     </body>
 </html>
\ No newline at end of file