From: Radek Czajka Date: Mon, 27 Aug 2012 11:19:56 +0000 (+0200) Subject: promobox, some fixes X-Git-Url: https://git.mdrn.pl/prawokultury.git/commitdiff_plain/e8813ee4389a5e22df46d1973409d70a8e6706be?hp=8e82784fa2fe21d9c3828adbf43178a39c7cdea6 promobox, some fixes --- diff --git a/.gitignore b/.gitignore index fa1b927..5818dca 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,5 @@ TAGS media search_index +.sass-cache + diff --git a/migdal/admin.py b/migdal/admin.py index 6d4baef..ac0e640 100644 --- a/migdal/admin.py +++ b/migdal/admin.py @@ -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 diff --git a/migdal/templates/migdal/entry/entry_detail.html b/migdal/templates/migdal/entry/entry_detail.html index f37777e..573e139 100755 --- a/migdal/templates/migdal/entry/entry_detail.html +++ b/migdal/templates/migdal/entry/entry_detail.html @@ -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" %} diff --git a/migdal/templates/migdal/entry/entry_list.html b/migdal/templates/migdal/entry/entry_list.html index a68bd2a..e7dd057 100755 --- a/migdal/templates/migdal/entry/entry_list.html +++ b/migdal/templates/migdal/entry/entry_list.html @@ -30,19 +30,20 @@
+
    {% for object in object_list.promobox %} - {% entry_promobox object %} + {% entry_promobox object forloop.counter %} {% endfor %}
+
{% endif %} diff --git a/migdal/templates/migdal/entry/entry_promobox.html b/migdal/templates/migdal/entry/entry_promobox.html index 110c1cf..0eb9fac 100755 --- a/migdal/templates/migdal/entry/entry_promobox.html +++ b/migdal/templates/migdal/entry/entry_promobox.html @@ -1,13 +1,15 @@ {% load i18n %} -
  • diff --git a/migdal/templates/migdal/entry/info/entry_begin.html b/migdal/templates/migdal/entry/info/entry_begin.html index 256a38d..70d34bd 100755 --- a/migdal/templates/migdal/entry/info/entry_begin.html +++ b/migdal/templates/migdal/entry/info/entry_begin.html @@ -1,3 +1,4 @@ +{% load i18n %}

    {{ object.title }}

    diff --git a/migdal/templatetags/migdal_tags.py b/migdal/templatetags/migdal_tags.py index 9c7b15b..8b20f83 100644 --- a/migdal/templatetags/migdal_tags.py +++ b/migdal/templatetags/migdal_tags.py @@ -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')) diff --git a/prawokultury/settings.d/50-static.conf b/prawokultury/settings.d/50-static.conf index da9a583..2c42405 100755 --- a/prawokultury/settings.d/50-static.conf +++ b/prawokultury/settings.d/50-static.conf @@ -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 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 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 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 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 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 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 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 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 index c49b9ff..0000000 Binary files a/prawokultury/static/css/.sass-cache/b2066c63e4faa8152ec807a224a5f44c4f66fc15/sidebar.scssc and /dev/null differ diff --git a/prawokultury/static/css/promobox.css b/prawokultury/static/css/promobox.css index 5192095..58c4cfe 100644 --- a/prawokultury/static/css/promobox.css +++ b/prawokultury/static/css/promobox.css @@ -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 { diff --git a/prawokultury/static/css/promobox.scss b/prawokultury/static/css/promobox.scss index 803a250..cf209c5 100755 --- a/prawokultury/static/css/promobox.scss +++ b/prawokultury/static/css/promobox.scss @@ -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 index 0000000..91128ca --- /dev/null +++ b/prawokultury/static/js/promobox.js @@ -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 diff --git a/prawokultury/templates/base.html b/prawokultury/templates/base.html index b21a928..452e3f0 100755 --- a/prawokultury/templates/base.html +++ b/prawokultury/templates/base.html @@ -91,5 +91,7 @@
    + + {% compressed_js 'base' %} \ No newline at end of file