Skip to content

Commit

Permalink
Use collective.js.cycle2 Cycle2SlideShow utils class
Browse files Browse the repository at this point in the history
  • Loading branch information
rodfersou committed Jul 12, 2016
1 parent 4421e4d commit aeb3d4c
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 59 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ There's a frood who really knows where his towel is.
1.0b2 (unreleased)
------------------

- Use collective.js.cycle2 Cycle2SlideShow utils class.
[rodfersou]

- Use HTML entities in Unicode Normalization Form C to avoid warnings when validating.
[hvelarde]

Expand Down
2 changes: 1 addition & 1 deletion src/sc/photogallery/browser/static/photogallery.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ body.portaltype-photo-gallery .cycle-player img,
top: 0;
left: 0;
display: block;
width: 100%;
width: auto;
max-width: 100%;
height: auto;
max-height: 100%;
Expand Down
54 changes: 1 addition & 53 deletions src/sc/photogallery/browser/static/photogallery.js
Original file line number Diff line number Diff line change
@@ -1,60 +1,8 @@
var PhotoGallery = (function() {
function PhotoGallery(el) {
var self = this;
self.$el = $(el);
self.proportion = 3 / 2;
self.bind_events();
self.fix_image_size();
}
PhotoGallery.prototype.$ = function(selector) {
var self = this;
return $(selector, self.$el);
};
PhotoGallery.prototype.bind_events = function() {
var self = this;
self.$('.cycle-player').on('cycle-next cycle-prev', self, self.sync_slideshows);
self.$('.cycle-carrossel .thumb-itens').on('click', self, self.thumbs_click);
};
PhotoGallery.prototype.fix_image_size = function() {
var self, max_height, max_width, $player, $imgs;
self = this;

// Calc max_with and max_height
$player = self.$('.cycle-player');
max_width = $player.width();
max_height = max_width / self.proportion;
// Calc max_with and max_height

$imgs = self.$('.cycle-player img');
$imgs.css({
'max-width': max_width,
'max-height': max_height
});
};

PhotoGallery.prototype.sync_slideshows = function(e, opts) {
var self, index, $player, $slideshows;
self = e.data;
$slideshows = self.$('.cycle-slideshow');
$slideshows.cycle('goto', opts.currSlide);
};

PhotoGallery.prototype.thumbs_click = function(e) {
var self, index, $thumbs, $slideshows;
self = e.data;
e.preventDefault();
$thumbs = self.$('.cycle-carrossel');
index = $thumbs.data('cycle.API').getSlideIndex(this);
$slideshows = self.$('.cycle-slideshow');
$slideshows.cycle('goto', index);
};
return PhotoGallery;
})();
$(window).load(function() {
var i, len, ref, slideshow;
ref = $('.slideshow-container');
for (i = 0, len = ref.length; i < len; i++) {
slideshow = ref[i];
new PhotoGallery(slideshow);
new cycle2SlideShow(slideshow);
}
});
1 change: 1 addition & 0 deletions src/sc/photogallery/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
'++resource++collective.js.cycle2/jquery.cycle2.min.js',
'++resource++collective.js.cycle2/jquery.cycle2.carousel.min.js',
'++resource++collective.js.cycle2/jquery.cycle2.swipe.min.js',
'++resource++collective.js.cycle2/utils.min.js',
)

HAS_ZIPEXPORT = True
Expand Down
7 changes: 7 additions & 0 deletions src/sc/photogallery/logger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding:utf-8 -*-
from sc.photogallery.config import PROJECTNAME

import logging


logger = logging.getLogger(PROJECTNAME)
16 changes: 16 additions & 0 deletions src/sc/photogallery/upgrades/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
# -*- coding: utf-8 -*-
from plone import api
from sc.photogallery.logger import logger


def cook_css_resources(context): # pragma: no cover
"""Cook CSS resources."""
css_tool = api.portal.get_tool('portal_css')
css_tool.cookResources()
logger.info('CSS resources were cooked')


def cook_javascript_resources(context): # pragma: no cover
"""Cook JavaScript resources."""
js_tool = api.portal.get_tool('portal_javascripts')
js_tool.cookResources()
logger.info('JavaScript resources were cooked')
6 changes: 1 addition & 5 deletions src/sc/photogallery/upgrades/v1001/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
from plone.app.upgrade.utils import loadMigrationProfile
from sc.photogallery.config import PROJECTNAME
from sc.photogallery.interfaces import IPhotoGallery

import logging


logger = logging.getLogger(PROJECTNAME)
from sc.photogallery.logger import logger


def apply_profile(context):
Expand Down

0 comments on commit aeb3d4c

Please sign in to comment.