Advertisement
Guest User

Avram

a guest
Oct 2nd, 2009
629
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 25.55 KB | None | 0 0
  1. <?php
  2. include("../../../../wp-load.php");
  3. $fcg_button = get_option('gallery-fcg-button') != '' ? get_option('gallery-fcg-button') : "Featured Content";
  4. $fcg_fade_duration = get_option('gallery-fade-duration') != '' ? get_option('gallery-fade-duration') : 500;
  5. $fcg_delay = get_option('gallery-delay') != '' ? get_option('gallery-delay') : 9000;
  6. $fcg_default_transaction = get_option('gallery-default-transaction') != '' ? get_option('gallery-default-transaction') : "fade";
  7.  
  8. ?>
  9.  
  10. /*
  11.     This file is part of JonDesign's SmoothGallery v2.0. 3.2.0
  12.  
  13.     JonDesign's SmoothGallery is free software; you can redistribute it and/or modify
  14.     it under the terms of the GNU General Public License as published by
  15.     the Free Software Foundation; either version 3 of the License, or
  16.     (at your option) any later version.
  17.  
  18.     JonDesign's SmoothGallery is distributed in the hope that it will be useful,
  19.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.     GNU General Public License for more details.
  22.  
  23.     You should have received a copy of the GNU General Public License
  24.     along with JonDesign's SmoothGallery; if not, write to the Free Software
  25.     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  26.  
  27.     Main Developer: Jonathan Schemoul (JonDesign: http://www.jondesign.net/)
  28.     Contributed code by:
  29.     - Christian Ehret (bugfix)
  30.     - Nitrix (bugfix)
  31.     - Valerio from Mad4Milk for his great help with the carousel scrolling and many other things.
  32.     - Archie Cowan for helping me find a bugfix on carousel inner width problem.
  33.     - Tomocchino from #mootools for the preloader class
  34.     Many thanks to:
  35.     - The mootools team for the great mootools lib, and it's help and support throughout the project.
  36. */
  37.  
  38. // declaring the class
  39. var gallery = {
  40.     initialize: function(element, options) {
  41.         this.setOptions({
  42.             showArrows: true,
  43.             showCarousel: true,
  44.             showInfopane: true,
  45.             embedLinks: true,
  46.             fadeDuration: <?php echo $fcg_fade_duration; ?>,
  47.             timed: false,
  48.             delay: <?php echo $fcg_delay; ?>,
  49.             preloader: true,
  50.             preloaderImage: true,
  51.             preloaderErrorImage: true,
  52.             /* Data retrieval */
  53.             manualData: [],
  54.             populateFrom: false,
  55.             populateData: true,
  56.             destroyAfterPopulate: true,
  57.             elementSelector: "div.imageElement",
  58.             titleSelector: "h2",
  59.             subtitleSelector: "p",
  60.             linkSelector: "a.open",
  61.             imageSelector: "img.full",
  62.             thumbnailSelector: "img.thumbnail",
  63.             defaultTransition: '<?php echo $fcg_default_transaction; ?>',
  64.             /* InfoPane options */
  65.             slideInfoZoneOpacity: 0.7,
  66.             slideInfoZoneSlide: true,
  67.             /* Carousel options */
  68.             carouselMinimizedOpacity: 0.4,
  69.             carouselMinimizedHeight: 20,
  70.             carouselMaximizedOpacity: 0.9,
  71.             thumbHeight: 75,
  72.             thumbWidth: 100,
  73.             thumbSpacing: 10,
  74.             thumbIdleOpacity: 0.6,
  75.             textShowCarousel: '<?php echo $fcg_button; ?>',
  76.             showCarouselLabel: true,
  77.             thumbCloseCarousel: true,
  78.             useThumbGenerator: false,
  79.             thumbGenerator: 'resizer.php',
  80.             useExternalCarousel: false,
  81.             carouselElement: false,
  82.             carouselHorizontal: true,
  83.             activateCarouselScroller: true,
  84.             carouselPreloader: true,
  85.             textPreloadingCarousel: 'Loading...',
  86.             /* CSS Classes */
  87.             baseClass: 'jdGallery',
  88.             withArrowsClass: 'withArrows',
  89.             /* Plugins: HistoryManager */
  90.             useHistoryManager: false,
  91.             customHistoryKey: false
  92.         }, options);
  93.         this.fireEvent('onInit');
  94.         this.currentIter = 0;
  95.         this.lastIter = 0;
  96.         this.maxIter = 0;
  97.         this.galleryElement = element;
  98.         this.galleryData = this.options.manualData;
  99.         this.galleryInit = 1;
  100.         this.galleryElements = Array();
  101.         this.thumbnailElements = Array();
  102.         this.galleryElement.addClass(this.options.baseClass);
  103.        
  104.         this.populateFrom = element;
  105.         if (this.options.populateFrom)
  106.             this.populateFrom = this.options.populateFrom;     
  107.         if (this.options.populateData)
  108.             this.populateData();
  109.         element.style.display="block";
  110.        
  111.         if (this.options.useHistoryManager)
  112.             this.initHistory();
  113.        
  114.         if (this.options.embedLinks)
  115.         {
  116.             this.currentLink = new Element('a').addClass('open').setProperties({
  117.                 href: '#',
  118.                 title: ''
  119.             }).injectInside(element);
  120.             if ((!this.options.showArrows) && (!this.options.showCarousel))
  121.                 this.galleryElement = element = this.currentLink;
  122.             else
  123.                 this.currentLink.setStyle('display', 'none');
  124.         }
  125.        
  126.         this.constructElements();
  127.         if ((this.galleryData.length>1)&&(this.options.showArrows))
  128.         {
  129.             var leftArrow = new Element('a').addClass('left').addEvent(
  130.                 'click',
  131.                 this.prevItem.bind(this)
  132.             ).injectInside(element);
  133.             var rightArrow = new Element('a').addClass('right').addEvent(
  134.                 'click',
  135.                 this.nextItem.bind(this)
  136.             ).injectInside(element);
  137.             this.galleryElement.addClass(this.options.withArrowsClass);
  138.         }
  139.         this.loadingElement = new Element('div').addClass('loadingElement').injectInside(element);
  140.         if (this.options.showInfopane) this.initInfoSlideshow();
  141.         if (this.options.showCarousel) this.initCarousel();
  142.         this.doSlideShow(1);
  143.     },
  144.     populateData: function() {
  145.         currentArrayPlace = this.galleryData.length;
  146.         options = this.options;
  147.         var data = $A(this.galleryData);
  148.         data.extend(this.populateGallery(this.populateFrom, currentArrayPlace));
  149.         this.galleryData = data;
  150.         this.fireEvent('onPopulated');
  151.     },
  152.     populateGallery: function(element, startNumber) {
  153.         var data = [];
  154.         options = this.options;
  155.         currentArrayPlace = startNumber;
  156.         element.getElements(options.elementSelector).each(function(el) {
  157.             elementDict = {
  158.                 image: el.getElement(options.imageSelector).getProperty('src'),
  159.                 number: currentArrayPlace,
  160.                 transition: this.options.defaultTransition
  161.             };
  162.             elementDict.extend = $extend;
  163.             if ((options.showInfopane) | (options.showCarousel))
  164.                 elementDict.extend({
  165.                     title: el.getElement(options.titleSelector).innerHTML,
  166.                     description: el.getElement(options.subtitleSelector).innerHTML
  167.                 });
  168.             if (options.embedLinks)
  169.                 elementDict.extend({
  170.                     link: el.getElement(options.linkSelector).href||false,
  171.                     linkTitle: el.getElement(options.linkSelector).title||false,
  172.                     linkTarget: el.getElement(options.linkSelector).getProperty('target')||false
  173.                 });
  174.             if ((!options.useThumbGenerator) && (options.showCarousel))
  175.                 elementDict.extend({
  176.                     thumbnail: el.getElement(options.thumbnailSelector).getProperty('src')
  177.                 });
  178.             else if (options.useThumbGenerator)
  179.                 elementDict.extend({
  180.                     thumbnail: options.thumbGenerator + '?imgfile=' + elementDict.image + '&max_width=' + options.thumbWidth + '&max_height=' + options.thumbHeight
  181.                 });
  182.            
  183.             data.extend([elementDict]);
  184.             currentArrayPlace++;
  185.             if (this.options.destroyAfterPopulate)
  186.                 el.remove();
  187.         });
  188.         return data;
  189.     },
  190.     constructElements: function() {
  191.         el = this.galleryElement;
  192.         this.maxIter = this.galleryData.length;
  193.         var currentImg;
  194.         for(i=0;i<this.galleryData.length;i++)
  195.         {
  196.             var currentImg = new Fx.Styles(
  197.                 new Element('div').addClass('slideElement').setStyles({
  198.                     'position':'absolute',
  199.                     'left':'0px',
  200.                     'right':'0px',
  201.                     'margin':'0px',
  202.                     'padding':'0px',
  203.                     'backgroundPosition':"center center",
  204.                     'opacity':'0'
  205.                 }).injectInside(el),
  206.                 'opacity',
  207.                 {duration: this.options.fadeDuration}
  208.             );
  209.             if (this.options.preloader)
  210.             {
  211.                 currentImg.source = this.galleryData[i].image;
  212.                 currentImg.loaded = false;
  213.                 currentImg.load = function(imageStyle) {
  214.                     if (!imageStyle.loaded) {
  215.                         new Asset.image(imageStyle.source, {
  216.                                     'onload'  : function(img){
  217.                                                     img.element.setStyle(
  218.                                                     'backgroundImage',
  219.                                                     "url('" + img.source + "')")
  220.                                                     img.loaded = true;
  221.                                                 }.bind(this, imageStyle)
  222.                         });
  223.                     }
  224.                 }.pass(currentImg, this);
  225.             } else {
  226.                 currentImg.element.setStyle('backgroundImage',
  227.                                     "url('" + this.galleryData[i].image + "')");
  228.             }
  229.             this.galleryElements[parseInt(i)] = currentImg;
  230.         }
  231.     },
  232.     destroySlideShow: function(element) {
  233.         var myClassName = element.className;
  234.         var newElement = new Element('div').addClass('myClassName');
  235.         element.parentNode.replaceChild(newElement, element);
  236.     },
  237.     startSlideShow: function() {
  238.         this.fireEvent('onStart');
  239.         this.loadingElement.style.display = "none";
  240.         this.lastIter = this.maxIter - 1;
  241.         this.currentIter = 0;
  242.         this.galleryInit = 0;
  243.         this.galleryElements[parseInt(this.currentIter)].set({opacity: 1});
  244.         if (this.options.showInfopane)
  245.             this.showInfoSlideShow.delay(1000, this);
  246.         var textShowCarousel = formatString(this.options.textShowCarousel, this.currentIter+1, this.maxIter);
  247.         if (this.options.showCarousel&&(!this.options.carouselPreloader))
  248.             this.carouselBtn.setHTML(textShowCarousel).setProperty('title', textShowCarousel);
  249.         this.prepareTimer();
  250.         if (this.options.embedLinks)
  251.             this.makeLink(this.currentIter);
  252.     },
  253.     nextItem: function() {
  254.         this.fireEvent('onNextCalled');
  255.         this.nextIter = this.currentIter+1;
  256.         if (this.nextIter >= this.maxIter)
  257.             this.nextIter = 0;
  258.         this.galleryInit = 0;
  259.         this.goTo(this.nextIter);
  260.     },
  261.     prevItem: function() {
  262.         this.fireEvent('onPreviousCalled');
  263.         this.nextIter = this.currentIter-1;
  264.         if (this.nextIter <= -1)
  265.             this.nextIter = this.maxIter - 1;
  266.         this.galleryInit = 0;
  267.         this.goTo(this.nextIter);
  268.     },
  269.     goTo: function(num) {
  270.         this.clearTimer();
  271.         if(this.options.preloader)
  272.         {
  273.             this.galleryElements[num].load();
  274.             if (num==0)
  275.                 this.galleryElements[this.maxIter - 1].load();
  276.             else
  277.                 this.galleryElements[num - 1].load();
  278.             if (num==(this.maxIter - 1))
  279.                 this.galleryElements[0].load();
  280.             else
  281.                 this.galleryElements[num + 1].load();
  282.                
  283.         }
  284.         if (this.options.embedLinks)
  285.             this.clearLink();
  286.         if (this.options.showInfopane)
  287.         {
  288.             this.slideInfoZone.clearChain();
  289.             this.hideInfoSlideShow().chain(this.changeItem.pass(num, this));
  290.         } else
  291.             this.currentChangeDelay = this.changeItem.delay(500, this, num);
  292.         if (this.options.embedLinks)
  293.             this.makeLink(num);
  294.         this.prepareTimer();
  295.         /*if (this.options.showCarousel)
  296.             this.clearThumbnailsHighlights();*/
  297.     },
  298.     changeItem: function(num) {
  299.         this.fireEvent('onStartChanging');
  300.         this.galleryInit = 0;
  301.         if (this.currentIter != num)
  302.         {
  303.             for(i=0;i<this.maxIter;i++)
  304.             {
  305.                 if ((i != this.currentIter)) this.galleryElements[i].set({opacity: 0});
  306.             }
  307.             gallery.Transitions[this.galleryData[num].transition].pass([
  308.                 this.galleryElements[this.currentIter],
  309.                 this.galleryElements[num],
  310.                 this.currentIter,
  311.                 num], this)();
  312.             this.currentIter = num;
  313.         }
  314.         var textShowCarousel = formatString(this.options.textShowCarousel, num+1, this.maxIter);
  315.         if (this.options.showCarousel)
  316.             this.carouselBtn.setHTML(textShowCarousel).setProperty('title', textShowCarousel);
  317.         this.doSlideShow.bind(this)();
  318.         this.fireEvent('onChanged');
  319.     },
  320.     clearTimer: function() {
  321.         if (this.options.timed)
  322.             $clear(this.timer);
  323.     },
  324.     prepareTimer: function() {
  325.         if (this.options.timed)
  326.             this.timer = this.nextItem.delay(this.options.delay, this);
  327.     },
  328.     doSlideShow: function(position) {
  329.         if (this.galleryInit == 1)
  330.         {
  331.             imgPreloader = new Image();
  332.             imgPreloader.onload=function(){
  333.                 this.startSlideShow.delay(10, this);
  334.             }.bind(this);
  335.             imgPreloader.src = this.galleryData[0].image;
  336.             if(this.options.preloader)
  337.                 this.galleryElements[0].load();
  338.         } else {
  339.             if (this.options.showInfopane)
  340.             {
  341.                 if (this.options.showInfopane)
  342.                 {
  343.                     this.showInfoSlideShow.delay((500 + this.options.fadeDuration), this);
  344.                 } else
  345.                     if ((this.options.showCarousel)&&(this.options.activateCarouselScroller))
  346.                         this.centerCarouselOn(position);
  347.             }
  348.         }
  349.     },
  350.     createCarousel: function() {
  351.         var carouselElement;
  352.         if (!this.options.useExternalCarousel)
  353.         {
  354.             var carouselContainerElement = new Element('div').addClass('carouselContainer').injectInside(this.galleryElement);
  355.             this.carouselContainer = new Fx.Styles(carouselContainerElement, {transition: Fx.Transitions.expoOut});
  356.             this.carouselContainer.normalHeight = carouselContainerElement.offsetHeight;
  357.             this.carouselContainer.set({'opacity': this.options.carouselMinimizedOpacity, 'top': (this.options.carouselMinimizedHeight - this.carouselContainer.normalHeight)});
  358.             this.carouselBtn = new Element('a').addClass('carouselBtn').setProperties({
  359.                 title: this.options.textShowCarousel
  360.             }).injectInside(carouselContainerElement);
  361.             if(this.options.carouselPreloader)
  362.                 this.carouselBtn.setHTML(this.options.textPreloadingCarousel);
  363.             else
  364.                 this.carouselBtn.setHTML(this.options.textShowCarousel);
  365.             this.carouselBtn.addEvent(
  366.                 'click',
  367.                 function () {
  368.                     this.carouselContainer.clearTimer();
  369.                     this.toggleCarousel();
  370.                 }.bind(this)
  371.             );
  372.             this.carouselActive = false;
  373.    
  374.             carouselElement = new Element('div').addClass('carousel').injectInside(carouselContainerElement);
  375.             this.carousel = new Fx.Styles(carouselElement);
  376.         } else {
  377.             carouselElement = $(this.options.carouselElement).addClass('jdExtCarousel');
  378.         }
  379.         this.carouselElement = new Fx.Styles(carouselElement, {transition: Fx.Transitions.expoOut});
  380.         this.carouselElement.normalHeight = carouselElement.offsetHeight;
  381.         if (this.options.showCarouselLabel)
  382.             this.carouselLabel = new Element('p').addClass('label').injectInside(carouselElement);
  383.         carouselWrapper = new Element('div').addClass('carouselWrapper').injectInside(carouselElement);
  384.         this.carouselWrapper = new Fx.Styles(carouselWrapper, {transition: Fx.Transitions.expoOut});
  385.         this.carouselWrapper.normalHeight = carouselWrapper.offsetHeight;
  386.         this.carouselInner = new Element('div').addClass('carouselInner').injectInside(carouselWrapper);
  387.         if (this.options.activateCarouselScroller)
  388.         {
  389.             this.carouselWrapper.scroller = new Scroller(carouselWrapper, {
  390.                 area: 100,
  391.                 velocity: 0.2
  392.             })
  393.            
  394.             this.carouselWrapper.elementScroller = new Fx.Scroll(carouselWrapper, {
  395.                 duration: 400,
  396.                 onStart: this.carouselWrapper.scroller.stop.bind(this.carouselWrapper.scroller),
  397.                 onComplete: this.carouselWrapper.scroller.start.bind(this.carouselWrapper.scroller)
  398.             });
  399.         }
  400.     },
  401.     fillCarousel: function() {
  402.         this.constructThumbnails();
  403.         this.carouselInner.normalWidth = ((this.maxIter * (this.options.thumbWidth + this.options.thumbSpacing + 2))+this.options.thumbSpacing) + "px";
  404.         this.carouselInner.style.width = this.carouselInner.normalWidth;
  405.     },
  406.     initCarousel: function () {
  407.         this.createCarousel();
  408.         this.fillCarousel();
  409.         if (this.options.carouselPreloader)
  410.             this.preloadThumbnails();
  411.     },
  412.     flushCarousel: function() {
  413.         this.thumbnailElements.each(function(myFx) {
  414.             myFx.element.remove();
  415.             myFx = myFx.element = null;
  416.         });
  417.         this.thumbnailElements = [];
  418.     },
  419.     toggleCarousel: function() {
  420.         if (this.carouselActive)
  421.             this.hideCarousel();
  422.         else
  423.             this.showCarousel();
  424.     },
  425.     showCarousel: function () {
  426.         this.fireEvent('onShowCarousel');
  427.         this.carouselContainer.start({
  428.             'opacity': this.options.carouselMaximizedOpacity,
  429.             'top': 0
  430.         }).chain(function() {
  431.             this.carouselActive = true;
  432.             this.carouselWrapper.scroller.start();
  433.             this.fireEvent('onCarouselShown');
  434.             this.carouselContainer.options.onComplete = null;
  435.         }.bind(this));
  436.     },
  437.     hideCarousel: function () {
  438.         this.fireEvent('onHideCarousel');
  439.         var targetTop = this.options.carouselMinimizedHeight - this.carouselContainer.normalHeight;
  440.         this.carouselContainer.start({
  441.             'opacity': this.options.carouselMinimizedOpacity,
  442.             'top': targetTop
  443.         }).chain(function() {
  444.             this.carouselActive = false;
  445.             this.carouselWrapper.scroller.stop();
  446.             this.fireEvent('onCarouselHidden');
  447.             this.carouselContainer.options.onComplete = null;
  448.         }.bind(this));
  449.     },
  450.     constructThumbnails: function () {
  451.         element = this.carouselInner;
  452.         for(i=0;i<this.galleryData.length;i++)
  453.         {
  454.             var currentImg = new Fx.Style(new Element ('div').addClass("thumbnail").setStyles({
  455.                     backgroundImage: "url('" + this.galleryData[i].thumbnail + "')",
  456.                     backgroundPosition: "center center",
  457.                     backgroundRepeat: 'no-repeat',
  458.                     marginLeft: this.options.thumbSpacing + "px",
  459.                     width: this.options.thumbWidth + "px",
  460.                     height: this.options.thumbHeight + "px"
  461.                 }).injectInside(element), "opacity", {duration: 200}).set(this.options.thumbIdleOpacity);
  462.             currentImg.element.addEvents({
  463.                 'mouseover': function (myself) {
  464.                     myself.clearTimer();
  465.                     myself.start(0.99);
  466.                     if (this.options.showCarouselLabel)
  467.                         $(this.carouselLabel).setHTML('<span class="number">' + (myself.relatedImage.number + 1) + "/" + this.maxIter + ":</span> " + myself.relatedImage.title);
  468.                 }.pass(currentImg, this),
  469.                 'mouseout': function (myself) {
  470.                     myself.clearTimer();
  471.                     myself.start(this.options.thumbIdleOpacity);
  472.                 }.pass(currentImg, this),
  473.                 'click': function (myself) {
  474.                     this.goTo(myself.relatedImage.number);
  475.                     if (this.options.thumbCloseCarousel)
  476.                         this.hideCarousel();
  477.                 }.pass(currentImg, this)
  478.             });
  479.            
  480.             currentImg.relatedImage = this.galleryData[i];
  481.             this.thumbnailElements[parseInt(i)] = currentImg;
  482.         }
  483.     },
  484.     log: function(value) {
  485.         if(console.log)
  486.             console.log(value);
  487.     },
  488.     preloadThumbnails: function() {
  489.         var thumbnails = [];
  490.         for(i=0;i<this.galleryData.length;i++)
  491.         {
  492.             thumbnails[parseInt(i)] = this.galleryData[i].thumbnail;
  493.         }
  494.         this.thumbnailPreloader = new Preloader();
  495.         this.thumbnailPreloader.addEvent('onComplete', function() {
  496.             var textShowCarousel = formatString(this.options.textShowCarousel, this.currentIter+1, this.maxIter);
  497.             this.carouselBtn.setHTML(textShowCarousel).setProperty('title', textShowCarousel);
  498.         }.bind(this));
  499.         this.thumbnailPreloader.load(thumbnails);
  500.     },
  501.     clearThumbnailsHighlights: function()
  502.     {
  503.         for(i=0;i<this.galleryData.length;i++)
  504.         {
  505.             this.thumbnailElements[i].clearTimer();
  506.             this.thumbnailElements[i].start(0.2);
  507.         }
  508.     },
  509.     changeThumbnailsSize: function(width, height)
  510.     {
  511.         for(i=0;i<this.galleryData.length;i++)
  512.         {
  513.             this.thumbnailElements[i].clearTimer();
  514.             this.thumbnailElements[i].element.setStyles({
  515.                 'width': width + "px",
  516.                 'height': height + "px"
  517.             });
  518.         }
  519.     },
  520.     centerCarouselOn: function(num) {
  521.         if (!this.carouselWallMode)
  522.         {
  523.             var carouselElement = this.thumbnailElements[num];
  524.             var position = carouselElement.element.offsetLeft + (carouselElement.element.offsetWidth / 2);
  525.             var carouselWidth = this.carouselWrapper.element.offsetWidth;
  526.             var carouselInnerWidth = this.carouselInner.offsetWidth;
  527.             var diffWidth = carouselWidth / 2;
  528.             var scrollPos = position-diffWidth;
  529.             try {
  530.             this.carouselWrapper.elementScroller.scrollTo(scrollPos,0);
  531.             }
  532.             catch(e) {
  533.             this.carouselWrapper.elementScroller.scrollTo = (scrollPos,0);
  534.             }
  535.         }
  536.     },
  537.     initInfoSlideshow: function() {
  538.         /*if (this.slideInfoZone.element)
  539.             this.slideInfoZone.element.remove();*/
  540.         this.slideInfoZone = new Fx.Styles(new Element('div').addClass('slideInfoZone').injectInside($(this.galleryElement))).set({'opacity':0});
  541.         var slideInfoZoneTitle = new Element('h2').injectInside(this.slideInfoZone.element);
  542.         var slideInfoZoneDescription = new Element('p').injectInside(this.slideInfoZone.element);
  543.         this.slideInfoZone.normalHeight = this.slideInfoZone.element.offsetHeight;
  544.         this.slideInfoZone.element.setStyle('opacity',0);
  545.     },
  546.     changeInfoSlideShow: function()
  547.     {
  548.         this.hideInfoSlideShow.delay(10, this);
  549.         this.showInfoSlideShow.delay(500, this);
  550.     },
  551.     showInfoSlideShow: function() {
  552.         this.fireEvent('onShowInfopane');
  553.         this.slideInfoZone.clearTimer();
  554.         element = this.slideInfoZone.element;
  555.         element.getElement('h2').setHTML(this.galleryData[this.currentIter].title);
  556.         element.getElement('p').setHTML(this.galleryData[this.currentIter].description);
  557.         if(this.options.slideInfoZoneSlide)
  558.             this.slideInfoZone.start({'opacity': [0, this.options.slideInfoZoneOpacity], 'height': [0, this.slideInfoZone.normalHeight]});
  559.         else
  560.             this.slideInfoZone.start({'opacity': [0, this.options.slideInfoZoneOpacity]});
  561.         if (this.options.showCarousel)
  562.             this.slideInfoZone.chain(this.centerCarouselOn.pass(this.currentIter, this));
  563.         return this.slideInfoZone;
  564.     },
  565.     hideInfoSlideShow: function() {
  566.         this.fireEvent('onHideInfopane');
  567.         this.slideInfoZone.clearTimer();
  568.         if(this.options.slideInfoZoneSlide)
  569.             this.slideInfoZone.start({'opacity': 0, 'height': 0});
  570.         else
  571.             this.slideInfoZone.start({'opacity': 0});
  572.         return this.slideInfoZone;
  573.     },
  574.     makeLink: function(num) {
  575.         this.currentLink.setProperties({
  576.             href: this.galleryData[num].link,
  577.             title: this.galleryData[num].linkTitle
  578.         })
  579.         if (!((this.options.embedLinks) && (!this.options.showArrows) && (!this.options.showCarousel)))
  580.             this.currentLink.setStyle('display', 'block');
  581.     },
  582.     clearLink: function() {
  583.         this.currentLink.setProperties({href: '', title: ''});
  584.         if (!((this.options.embedLinks) && (!this.options.showArrows) && (!this.options.showCarousel)))
  585.             this.currentLink.setStyle('display', 'none');
  586.     },
  587.     /* To change the gallery data, those two functions : */
  588.     flushGallery: function() {
  589.         this.galleryElements.each(function(myFx) {
  590.             myFx.element.remove();
  591.             myFx = myFx.element = null;
  592.         });
  593.         this.galleryElements = [];
  594.     },
  595.     changeData: function(data) {
  596.         this.galleryData = data;
  597.         this.clearTimer();
  598.         this.flushGallery();
  599.         if (this.options.showCarousel) this.flushCarousel();
  600.         this.constructElements();
  601.         if (this.options.showCarousel) this.fillCarousel();
  602.         if (this.options.showInfopane) this.hideInfoSlideShow();
  603.         this.galleryInit=1;
  604.         this.lastIter=0;
  605.         this.currentIter=0;
  606.         this.doSlideShow(1);
  607.     },
  608.     /* Plugins: HistoryManager */
  609.     initHistory: function() {
  610.         this.fireEvent('onHistoryInit');
  611.         this.historyKey = this.galleryElement.id + '-picture';
  612.         if (this.options.customHistoryKey)
  613.             this.historyKey = this.options.customHistoryKey();
  614.         this.history = HistoryManager.register(
  615.             this.historyKey,
  616.             [1],
  617.             function(values) {
  618.                 if (parseInt(values[0])-1 < this.maxIter)
  619.                     this.goTo(parseInt(values[0])-1);
  620.             }.bind(this),
  621.             function(values) {
  622.                 return [this.historyKey, '(', values[0], ')'].join('');
  623.             }.bind(this),
  624.             this.historyKey + '\\((\\d+)\\)');
  625.         this.addEvent('onChanged', function(){
  626.             this.history.setValue(0, this.currentIter+1);
  627.         }.bind(this));
  628.         this.fireEvent('onHistoryInited');
  629.     }
  630. };
  631. gallery = new Class(gallery);
  632. gallery.implement(new Events);
  633. gallery.implement(new Options);
  634.  
  635. gallery.Transitions = new Abstract ({
  636.     fade: function(oldFx, newFx, oldPos, newPos){
  637.         oldFx.options.transition = newFx.options.transition = Fx.Transitions.linear;
  638.         oldFx.options.duration = newFx.options.duration = this.options.fadeDuration;
  639.         if (newPos > oldPos) newFx.start({opacity: 1});
  640.         else
  641.         {
  642.             newFx.set({opacity: 1});
  643.             oldFx.start({opacity: 0});
  644.         }
  645.     },
  646.     crossfade: function(oldFx, newFx, oldPos, newPos){
  647.         oldFx.options.transition = newFx.options.transition = Fx.Transitions.linear;
  648.         oldFx.options.duration = newFx.options.duration = this.options.fadeDuration;
  649.         newFx.start({opacity: 1});
  650.         oldFx.start({opacity: 0});
  651.     },
  652.     fadebg: function(oldFx, newFx, oldPos, newPos){
  653.         oldFx.options.transition = newFx.options.transition = Fx.Transitions.linear;
  654.         oldFx.options.duration = newFx.options.duration = this.options.fadeDuration / 2;
  655.         oldFx.start({opacity: 0}).chain(newFx.start.pass([{opacity: 1}], newFx));
  656.     }
  657. });
  658.  
  659. /* All code copyright 2007 Jonathan Schemoul */
  660.  
  661. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  662.  * Follows: Preloader (class)
  663.  * Simple class for preloading images with support for progress reporting
  664.  * Copyright 2007 Tomocchino.
  665.  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  666.  
  667. var Preloader = new Class({
  668.  
  669.   Implements: [Events, Options],
  670.  
  671.   options: {
  672.     root        : '',
  673.     period      : 100
  674.   },
  675.  
  676.   initialize: function(options){
  677.     this.setOptions(options);
  678.   },
  679.  
  680.   load: function(sources) {
  681.     this.index = 0;
  682.     this.images = [];
  683.     this.sources = this.temps = sources;
  684.     this.total = this. sources.length;
  685.    
  686.     this.fireEvent('onStart', [this.index, this.total]);
  687.     this.timer = this.progress.periodical(this.options.period, this);
  688.    
  689.     this.sources.each(function(source, index){
  690.       this.images[index] = new Asset.image(this.options.root + source, {
  691.         'onload'  : function(){ this.index++; if(this.images[index]) this.fireEvent('onLoad', [this.images[index], index, source]); }.bind(this),
  692.         'onerror' : function(){ this.index++; this.fireEvent('onError', [this.images.splice(index, 1), index, source]); }.bind(this),
  693.         'onabort' : function(){ this.index++; this.fireEvent('onError', [this.images.splice(index, 1), index, source]); }.bind(this)
  694.       });
  695.     }, this);
  696.   },
  697.  
  698.   progress: function() {
  699.     this.fireEvent('onProgress', [Math.min(this.index, this.total), this.total]);
  700.     if(this.index >= this.total) this.complete();
  701.   },
  702.  
  703.   complete: function(){
  704.     $clear(this.timer);
  705.     this.fireEvent('onComplete', [this.images]);
  706.   },
  707.  
  708.   cancel: function(){
  709.     $clear(this.timer);
  710.   }
  711.  
  712. });
  713.  
  714. Preloader.implement(new Events, new Options);
  715.  
  716. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  717.  * Follows: formatString (function)
  718.  * Original name: Yahoo.Tools.printf
  719.  * Copyright Yahoo.
  720.  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  721.  
  722. function formatString() {
  723.     var num = arguments.length;
  724.     var oStr = arguments[0];
  725.     for (var i = 1; i < num; i++) {
  726.         var pattern = "\\{" + (i-1) + "\\}";
  727.         var re = new RegExp(pattern, "g");
  728.         oStr = oStr.replace(re, arguments[i]);
  729.     }
  730.     return oStr;
  731. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement