From 480c72f742f12a622a6058e50cc2f6124137b000 Mon Sep 17 00:00:00 2001 From: Sanj Date: Thu, 15 Dec 2011 17:05:50 +0530 Subject: [PATCH] front page slider logic changes: add link, pause when button is clicked --- itf/app/models.py | 6 +++--- itf/frontpage/models.py | 1 + itf/static/js/frontpage.js | 18 ++++++++++++++++-- itf/templates/noel/index.html | 2 +- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/itf/app/models.py b/itf/app/models.py index 8bbcf4e..a03158e 100755 --- a/itf/app/models.py +++ b/itf/app/models.py @@ -90,9 +90,9 @@ class ItfModel(models.Model): def get_main_image(self): if not hasattr(self, 'main_image'): return {'thumb': None} #FIXME - main_image = self.main_image - if type(main_image).__name__ == 'function': - main_image = main_image() + main_image_getter = self.main_image + if type(main_image_getter).__name__ == 'function': + main_image = main_image_getter() if main_image is not None: imgfield = main_image elif self.get_modelextra().default_image: diff --git a/itf/frontpage/models.py b/itf/frontpage/models.py index 74957f7..418c079 100755 --- a/itf/frontpage/models.py +++ b/itf/frontpage/models.py @@ -3,6 +3,7 @@ from django.db import models class FrontImage(models.Model): image = models.ImageField(upload_to='upload/frontImages/') caption = models.TextField(blank=True) + link = models.URLField(verify_exists=False, blank=True, null=True, max_length=512) is_active = models.BooleanField(default=True) order = models.IntegerField(default=1) diff --git a/itf/static/js/frontpage.js b/itf/static/js/frontpage.js index 3474273..587d301 100755 --- a/itf/static/js/frontpage.js +++ b/itf/static/js/frontpage.js @@ -42,6 +42,20 @@ $(function() { location.href = link; }); + $('.banner').click(function() { + var link = $(this).attr("data-link"); + location.href = link; + }); + + $('.buttons').click(function() { + var $t = $(this); + var buttonNo = parseInt($t.attr("id").replace("button", "")); + $('.buttonsSelected').removeClass("buttonsSelected"); + $t.addClass("buttonsSelected"); + $('.banner').hide(); + $('.banner').eq(buttonNo).show(); + cycleFrontImages = false; + }); }); @@ -118,6 +132,7 @@ $(function() { }); +cycleFrontImages = true; function cycleFrontImage() { // BOO = $('.buttonsSelected'); var currImage = parseInt($('.buttonsSelected').attr("id").replace("button", "")); @@ -132,8 +147,7 @@ function cycleFrontImage() { $('.buttonsSelected').removeClass("buttonsSelected"); $('.banner').eq(nextImage).show(); $('#button' + nextImage).addClass("buttonsSelected"); - setTimeout(cycleFrontImage, 10000); + if (cycleFrontImages) setTimeout(cycleFrontImage, 10000); } - diff --git a/itf/templates/noel/index.html b/itf/templates/noel/index.html index 367fd1f..526fc0e 100755 --- a/itf/templates/noel/index.html +++ b/itf/templates/noel/index.html @@ -21,7 +21,7 @@ {% load thumbnail %} {% for f in front_images %} {% comment %} {% thumbnail f.image "468x282" crop="center" as im %} {% endcomment %} - + {% endfor %}