/*
This file is part of JonDesign's SmoothGallery v2.0. 3.2.0
JonDesign's SmoothGallery is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
JonDesign's SmoothGallery is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with JonDesign's SmoothGallery; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Main Developer: Jonathan Schemoul (JonDesign: http://jondesign/)
Contributed code by:
- Christian Ehret (bugfix)
- Nitrix (bugfix)
- Valerio from Mad4Milk for his great help with the carousel scrolling and many other things.
- Archie Cowan for helping me find a bugfix on carousel inner width problem.
- Tomocchino from #mootools for the preloader class
Many thanks to:
- The mootools team for the great mootools lib, and it's help and support throughout the project.
*/
// declaring the class
var gallery = {
initialize: function(element, options) {
setoptions({
showArrows: true,
showCarousel: true,
showInfopane: true,
embedLinks: true,
fadeDuration: 200,
timed: false,
delay: 5000,
preloader: true,
preloaderImage: true,
preloaderErrorImage: true,
/* Data retrieval */
manualData: [],
populateFrom: false,
populateData: true,
destroyAfterPopulate: true,
elementSelector: "imageelement",
titleSelector: "h2",
subtitleSelector: "p",
linkSelector: "open",
imageSelector: "full",
thumbnailSelector: "thumbnail",
defaultTransition: 'fadeslideleft',
/* InfoPane options */
slideInfoZoneOpacity: 0.95,
slideInfoZoneSlide: true,
/* Carousel options */
carouselMinimizedOpacity: 0.4,
carouselMinimizedHeight: 20,
carouselMaximizedOpacity: 0.9,
thumbHeight: 75,
thumbWidth: 100,
thumbSpacing: 10,
thumbIdleOpacity: 0.6,
textShowCarousel: 'Featured Content',
showCarouselLabel: true,
thumbCloseCarousel: true,
useThumbGenerator: false,
thumbGenerator: 'php',
useExternalCarousel: false,
carouselElement: false,
carouselHorizontal: true,
activateCarouselScroller: true,
carouselPreloader: true,
textPreloadingCarousel: 'Loading...',
/* CSS Classes */
baseClass: 'jdGallery',
withArrowsClass: 'withArrows',
/* Plugins: HistoryManager */
useHistoryManager: false,
customHistoryKey: false
}, options);
fireevent('onInit');
currentiter = 0;
lastiter = 0;
maxiter = 0;
galleryelement = element;
gallerydata = manualdata;
galleryinit = 1;
galleryelements = Array();
thumbnailelements = Array();
addclass(baseclass);
populatefrom = element;
if (populatefrom)
populatefrom = populatefrom;
if (populatedata)
populatedata();
display="block";
if (usehistorymanager)
inithistory();
if (embedlinks)
{
currentlink = new Element('a').addClass('open').setProperties({
href: '#',
title: ''
}).injectInside(element);
if ((!showarrows) && (!showcarousel))
galleryelement = element = currentlink;
else
setstyle('display', 'none');
}
constructelements();
if ((length>1)&&(showarrows))
{
var leftArrow = new Element('a').addClass('left').addEvent(
'click',
bind(this)
).injectInside(element);
var rightArrow = new Element('a').addClass('right').addEvent(
'click',
bind(this)
).injectInside(element);
addclass(witharrowsclass);
}
loadingelement = new Element('div').addClass('loadingElement').injectInside(element);
if (showinfopane) initinfoslideshow();
if (showcarousel) initcarousel();
doslideshow(1);
},
populateData: function() {
currentArrayPlace = length;
options = options;
var data = $A(gallerydata);
extend(populategallery(populatefrom, currentArrayPlace));
gallerydata = data;
fireevent('onPopulated');
},
populateGallery: function(element, startNumber) {
var data = [];
options = options;
currentArrayPlace = startNumber;
getelements(elementselector).each(function(el) {
elementDict = {
image: getelement(imageselector).getProperty('src'),
number: currentArrayPlace,
transition: defaulttransition
};
extend = $extend;
if ((showinfopane) | (showcarousel))
extend({
title: getelement(titleselector).innerHTML,
description: getelement(subtitleselector).innerHTML
});
if (embedlinks)
extend({
link: getelement(linkselector).href||false,
linkTitle: getelement(linkselector).title||false,
linkTarget: getelement(linkselector).getProperty('target')||false
});
if ((!usethumbgenerator) && (showcarousel))
extend({
thumbnail: getelement(thumbnailselector).getProperty('src')
});
else if (usethumbgenerator)
extend({
thumbnail: thumbgenerator + '?imgfile=' + image + '&max_width=' + thumbwidth + '&max_height=' + thumbheight
});
extend([elementDict]);
currentArrayPlace++;
if (destroyafterpopulate)
remove();
});
return data;
},
constructElements: function() {
el = galleryelement;
maxiter = length;
var currentImg;
for(i=0;i