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