? gallerystyles/greenarrows/images/next-prev.png
Index: gallerystyles/greenarrows/greenarrows.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/galleryformatter/gallerystyles/greenarrows/greenarrows.css,v
retrieving revision 1.1.2.4
diff -u -p -r1.1.2.4 greenarrows.css
--- gallerystyles/greenarrows/greenarrows.css 16 May 2010 16:41:37 -0000 1.1.2.4
+++ gallerystyles/greenarrows/greenarrows.css 14 Sep 2010 13:09:24 -0000
@@ -89,3 +89,38 @@
.galleryformatter-greenarrows .gallery-thumbs .forward:hover { background-position: 0px -52px; }
.galleryformatter-greenarrows .gallery-thumbs .back:hover { background-position: -4px -156px; }
+
+.gallery-slides { position: relative; }
+
+.galleryformatter-greenarrows .slide-button {
+ background: transparent url(images/next-prev.png) no-repeat top left;
+ height: 64px;
+ width: 32px;
+ display: block;
+ cursor: pointer;
+ text-indent: -9999px;
+ bottom: 40%;
+ position: absolute;
+ filter:alpha(opacity=20);
+ -ms-filter:”alpha(opacity=20)”;
+ -moz-opacity:0.2;
+ -khtml-opacity: 0.2;
+ opacity: 0.2;
+}
+
+.galleryformatter-greenarrows .prev-slide {
+ background-position: top left;
+ left: 0;
+}
+.galleryformatter-greenarrows .next-slide {
+ background-position: top right;
+ right: 0;
+}
+.galleryformatter-greenarrows .slide-button:hover {
+ filter: alpha(opacity=100);
+ -ms-filter: ”alpha(opacity=100)”;
+ -moz-opacity: 1;
+ -khtml-opacity: 1;
+ opacity: 1;
+}
+
Index: theme/galleryformatter.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/galleryformatter/theme/galleryformatter.js,v
retrieving revision 1.1.2.8
diff -u -p -r1.1.2.8 galleryformatter.js
--- theme/galleryformatter.js 9 Sep 2010 19:40:23 -0000 1.1.2.8
+++ theme/galleryformatter.js 14 Sep 2010 13:09:24 -0000
@@ -26,7 +26,7 @@ Drupal.galleryformatter.prepare = functi
if (($thumbsLi.size() * liWidth) > $thumbs.width()) {
$('ul', $thumbs).width('99999px');
$thumbs.infiniteCarousel();
- $thumbsLi = $('li', $thumbs); // we need to reselect because infiniteCarousel inserts new empty li elements if necessary
+ $thumbsLi = $('.gallery-thumbs ul li'); // we need to reselect because infiniteCarousel inserts new empty li elements if necessary
}
$thumbsLi.each(function(){
@@ -85,4 +85,60 @@ Drupal.galleryformatter.prepare = functi
else {
showFirstSlide();
}
+
+ // Setup buttons for next/prev slide
+ $slideButtons = ('<>');
+ $('.gallery-slides', $el).append($slideButtons);
+
+ /*
+ * Bind click event behaviours on the next/prev slide buttons:
+ */
+ var $wrapper = $('.gallery-thumbs .wrapper');
+ var visibleWidth = $wrapper.outerWidth();
+ // Helper function to show the previous slide and scroll prev page if necessary
+ function showPrevSlide(){
+ var currentScroll = $wrapper.get(0).scrollLeft;
+ var $prevThumbLi = $thumbsLi.filter('.active').prevAll().not('.empty, .cloned').filter(':first');
+ // if no results we are on the first element
+ if(!$prevThumbLi.size()) {
+ // select the last one
+ $prevThumbLi = $thumbsLi.not('.empty, .cloned').filter(':last');
+ }
+ var $slideToClick = $('a', $prevThumbLi);
+ var $prevIsVisible = (($prevThumbLi.get(0).offsetLeft >= currentScroll) && ($prevThumbLi.get(0).offsetLeft <= (visibleWidth + currentScroll)));
+ if($prevIsVisible) {
+ $slideToClick.trigger('click');
+ }
+ else {
+ $thumbs.trigger('prev');
+ $slideToClick.click();
+ }
+ }
+ $('a.prev-slide', $el).click(function(){
+ showPrevSlide();
+ });
+
+ // Helper function to show the next slide and scroll next page if necessary
+ function showNextSlide(){
+ var currentScroll = $wrapper.get(0).scrollLeft;
+ var $nextThumbLi = $thumbsLi.filter('.active').nextAll().not('.empty, .cloned').filter(':first');
+ // if no results we are on the last element
+ if(!$nextThumbLi.size()) {
+ // select the first one
+ $nextThumbLi = $thumbsLi.not('.empty, .cloned').filter(':first');
+ }
+ var $slideToClick = $('a', $nextThumbLi);
+ var $nextIsVisible = (($nextThumbLi.get(0).offsetLeft >= currentScroll) && ($nextThumbLi.get(0).offsetLeft <= (visibleWidth + currentScroll)));
+ if($nextIsVisible) {
+ var $slideToClick = $('a', $nextThumbLi);
+ $('a', $nextThumbLi).trigger('click');
+ }
+ else {
+ $thumbs.trigger('next');
+ $slideToClick.click();
+ }
+ }
+ $('a.next-slide', $el).click(function(){
+ showNextSlide();
+ });
};
Index: theme/infiniteCarousel.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/galleryformatter/theme/infiniteCarousel.js,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 infiniteCarousel.js
--- theme/infiniteCarousel.js 23 May 2010 11:15:58 -0000 1.1.2.1
+++ theme/infiniteCarousel.js 14 Sep 2010 13:09:24 -0000
@@ -78,5 +78,13 @@ $.fn.infiniteCarousel = function () {
$(this).bind('goto', function (event, page) {
gotoPage(page);
});
+
+ // custom events to trigger next and prev pages
+ $(this).bind('next', function () {
+ gotoPage(currentPage + 1);
+ });
+ $(this).bind('prev', function () {
+ gotoPage(currentPage - 1);
+ })
});
};