front page slider logic changes: add link, pause when button is clicked

This commit is contained in:
Sanj 2011-12-15 17:05:50 +05:30
parent 5987e956a3
commit 480c72f742
4 changed files with 21 additions and 6 deletions

View File

@ -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:

View File

@ -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)

View File

@ -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);
}

View File

@ -21,7 +21,7 @@
{% load thumbnail %}
{% for f in front_images %}
{% comment %} {% thumbnail f.image "468x282" crop="center" as im %} {% endcomment %}
<img src="{{ f.image.url }}" width="468" height="282" alt="" title="{{ f.caption }}" class="banner">
<img src="{{ f.image.url }}" width="468" height="282" alt="" title="{{ f.caption }}" data-link="{{ f.link }}" class="banner">
{% endfor %}
<!-- <img src="/static/images/noel/banner2.jpg" width="468" height="282" alt="banner-image" id="banner" > -->