Skip to content

Commit

Permalink
configuration options
Browse files Browse the repository at this point in the history
  • Loading branch information
fivethreeo committed Sep 14, 2011
1 parent cbefd91 commit 12b391d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
18 changes: 17 additions & 1 deletion cmsplugin_filer_gallery/cms_plugins.py
@@ -1,4 +1,5 @@
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.utils import simplejson
from cms.plugin_pool import plugin_pool from cms.plugin_pool import plugin_pool
from cms.plugin_base import CMSPluginBase from cms.plugin_base import CMSPluginBase
from cmsplugin_filer_gallery.models import FilerGallery from cmsplugin_filer_gallery.models import FilerGallery
Expand All @@ -12,8 +13,23 @@ class FilerGalleryPlugin(CMSPluginBase):
admin_preview = False admin_preview = False


def render(self, context, instance, placeholder): def render(self, context, instance, placeholder):
config = simplejson.dumps({
'animation': instance.animation.get_display(), # fade, horizontal-slide, vertical-slide, horizontal-push
'animationSpeed': instance.speed, # how fast animations are
'timer': instance.timer, # True or False to have the timer
'advanceSpeed': instance.advanced_speed, # if timer is enabled, time between transitions
'pauseOnHover': instance.pause_on_hover, # if you hover pauses the slider
'startClockOnMouseOut': instance.start_on_mouseout, # if clock should start on MouseOut
'startClockOnMouseOutAfter': instance.start_after, # how long after MouseOut should the timer start again
'directionalNav': instance.directional_nav, # manual advancing directional navs
'captions': instance.captions, # do you want captions?
'captionAnimation': instance.caption_animation.get_display(), # fade, slideOpen, none
'captionAnimationSpeed': instance.caption_speed, # if so how quickly should they animate in
'bullets': instance.bullets # True or False to activate the bullet navigation
})
context.update({ context.update({
'instance': instance 'instance': instance,
'orbit_config': config
}) })
return context return context


Expand Down
21 changes: 19 additions & 2 deletions cmsplugin_filer_gallery/models.py
Expand Up @@ -3,10 +3,27 @@
from django.db import models from django.db import models
from cms.models import CMSPlugin, Page from cms.models import CMSPlugin, Page


ANIMATION_CHOICES=('fade', 'horizontal-slide', 'vertical-slide', 'horizontal-push')
ANIMATION_CHOICES=dict(enumerate(ANIMATION_CHOICES))

class FilerGallery(CMSPlugin): class FilerGallery(CMSPlugin):


gallery = models.ForeignKey('filer_gallery.Gallery') gallery = models.ForeignKey('filer_gallery.Gallery')

height = models.SmallIntegerField(default=200)
width = models.SmallIntegerField(default=300)
animation = models.SmallIntegerField(choices=ANIMATION_CHOICES)
speed = models.SmallIntegerField(default=600)
timer = models.BooleanField(default=True)
advanced_speed = models.IntegerField(default=4000)
pause_on_hover = models.BooleanField(default=True)
start_on_mouseout = models.BooleanField(default=True)
start_after = models.IntegerField(default=1000)
directional_nav = models.BooleanField(default=False)
captions = models.BooleanField(default=False)
caption_animation = models.SmallIntegerField(choices=ANIMATION_CHOICES)
caption_speed = models.SmallIntegerField(default=800)
bullets = models.BooleanField(default=False)

class Meta: class Meta:
verbose_name = _("django filer gallery") verbose_name = _("django filer gallery")
verbose_name_plural = _("django filer galleries") verbose_name_plural = _("django filer galleries")
Expand Up @@ -7,8 +7,9 @@
<script type="text/javascript"> <script type="text/javascript">
//<![CDATA[ //<![CDATA[
(function ($) { (function ($) {
var config = {{ orbit_config }}
$(document).ready(function () { $(document).ready(function () {
$('#filer-gallery-{{ instance.pk }}').orbit(); $('#filer-gallery-{{ instance.pk }}').orbit(config);
}); });
})(jQuery) })(jQuery)
//]]> //]]>
Expand All @@ -17,6 +18,6 @@


<div id="filer-gallery-{{ instance.pk }}"> <div id="filer-gallery-{{ instance.pk }}">
{% for image in instance.gallery.galleryimage_set.all %} {% for image in instance.gallery.galleryimage_set.all %}
<img src="{% thumbnail image.image 300x200 %}" alt="{{ image.title }}" /> <img src="{% thumbnail image.image size %}" alt="{{ image.title }}" />
{% endfor %} {% endfor %}
</div> </div>

0 comments on commit 12b391d

Please sign in to comment.