1/* 2 This file is part of JonDesign's SmoothGallery v2.1beta1. 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 - Harald Kirschner (digitarald: http://digitarald.de/) for all his great libs. Some used here as plugins. 28*/ 29 30/* some quirks to circumvent broken stuff in mt1.2 */ 31 32Array.prototype.from=function (item){ 33 if (item == null) return []; 34 return (typeof(item) == 'array') ? item : [item]; 35}; 36$A=function (i){return Array.prototype.from(i).slice();}; 37Array.prototype.extend=function (a){this.push.apply(this,a);return this} 38if(Function.prototype.passx==undefined){ 39 Function.prototype.passx=function (args, bind){ 40 var self = this; 41 if (args != null) args = Array.prototype.from(args); 42 return function(){ 43 return self.apply(bind, args || arguments); 44 }; 45 }; 46} 47Function.prototype.chain=function(f){f();return window.chainjdgallery;} 48window.chainjdgallery=function(){}; 49 50 51if(undefined == Function.prototype.bind){ 52 Function.prototype.bind=function(that){ 53 var self = this, 54 args = arguments.length > 1 ? Array.slice(arguments, 1) : null, 55 F = function(){}; 56 57 var bound = function(){ 58 var context = that, length = arguments.length; 59 if (this instanceof bound){ 60 F.prototype = self.prototype; 61 context = new F; 62 } 63 var result = (!args && !length) 64 ? self.call(context) 65 : self.apply(context, args && length ? args.concat(Array.slice(arguments)) : args || arguments); 66 return context == that ? result : context; 67 }; 68 return bound; 69 } 70}; 71Function.prototype.periodical=function (c,b,a){return setInterval(this.passx((a==null?[]:a),b),c);}; 72 73$defined=function (i){return(i!=null);}; 74$clear=function (i){clearTimeout(i);clearInterval(i);return null;}; 75Function.prototype.delay=function (b,c,a){return setTimeout(this.passx(a,c),b)} 76 77function morphx(elm,opts){ 78 this.element=elm; 79 this.complete=function(){}; 80 this.options={easing:'linear',duration:1000,complete:this.complete,queue:false}; 81 if(opts) this.options=jQuery.extend(this.options,opts); 82} 83morphx.prototype.data=function(){ 84 if(arguments.length==1) 85 return this.element.data(arguments[0]); 86 else if(arguments.length==2) 87 return this.element.data(arguments[0], arguments[0]); 88} 89morphx.prototype.start=function(obj,opts){ 90 //this.element.stop(); 91 //console.log(this.options.duration); 92 if(opts)this.options=jQuery.extend(this.options,opts); 93 this.element.animate(obj, this.options); 94 return this; 95} 96morphx.prototype.stop=function(){ 97 this.element.stop(); 98 return this; 99} 100morphx.prototype.cancel=function(){ 101 this.element.stop(); 102 return this; 103} 104morphx.prototype.chain=Function.prototype.chain; 105morphx.prototype.completefunc=function(f){ 106 107 this.options.complete=f.bind(this); 108 109 return this; 110 111} 112morphx.prototype.clearChain=function(){ 113 window.morphxchain=function(){}; 114} 115morphx.prototype.css=function(obj){ 116 this.element.css(obj); 117 return this; 118} 119 120var s5_dropdowntext2 = s5_dropdowntext; 121 122(function($){ 123 var Scroller = function(element, options){ 124 125 this.options= { 126 area: 20, 127 velocity: 1, 128 onChange: function(x, y){ 129 //console.log(x,y); 130 //this.element.scrollTo(x, y); 131 //window.scrollTo(x, y); 132 }.bind(this), 133 fps: 50 134 135 }; 136 this.element=null; 137 this.docBody=null; 138 this.listener=null; 139 this.timer=null; 140 this.bound={}; 141 this.initialize(element, options); 142} 143 144 Scroller.prototype.initialize= function(element, options){ 145 this.options=$.extend(this.options,options); 146 this.element = element[0]; 147 this.docBody = $('body')[0]; 148 if(this.element.nodeType!=1){ 149 this.listener = this.docBody ; 150 $(this.listener).attr('tag','body'); 151 }else{ 152 this.listener = this.element; 153 $(this.listener).attr('tag','elm'); 154 } 155 156 this.timer = null; 157 this.bound = { 158 attach: this.attach.bind(this), 159 detach: this.detach.bind(this), 160 getCoords: this.getCoords.bind(this) 161 }; 162 }; 163 164 Scroller.prototype.start= function(){ 165 $(this.listener).bind('mouseover', this.bound.attach); 166 $(this.listener).bind('mouseleave', this.bound.detach); 167 return this; 168 }; 169 170 Scroller.prototype.stop= function(){ 171 $(this.listener).unbind('mouseover'); 172 $(this.listener).unbind('mouseleave'); 173 this.detach(); 174 this.timer = clearInterval(this.timer); 175 return this; 176 }; 177 178 Scroller.prototype.attach= function(){ 179 $(this.listener).bind('mousemove', this.bound.getCoords); 180 }; 181 182 Scroller.prototype.detach= function(){ 183 $(this.listener).unbind('mousemove'); 184 this.timer = clearInterval(this.timer); 185 }, 186 187 Scroller.prototype.getCoords= function(event){ 188 event.client={x:event.clientX,y:event.clientY}; 189 event.page={x:event.pageX,y:event.pageY}; 190 this.page = ($(this.listener).attr('tag') == 'body') ? event.client : event.page; 191 if (!this.timer) this.timer = this.scroll.periodical(Math.round(1000 / this.options.fps), this); 192 }, 193 194 Scroller.prototype.scroll= function(){ 195 var size = {x:$(this.element).width(),y:$(this.element).height()}, 196 scroll = {x:$(this.element).scrollLeft(),y:$(this.element).scrollTop()}, 197 pos = this.element != this.docBody ? {x:$(this.element).offset().left,y:$(this.element).offset().top} : {x: 0, y:0}, 198 scrollSize = {x:$(this.element).children(0).width(),y: $(this.element).children(0).height()}, 199 change = {x: 0, y: 0}, 200 top = this.options.area.top || this.options.area, 201 bottom = this.options.area.bottom || this.options.area; 202 for (var z in this.page){ 203 if (this.page[z] < (top + pos[z]) && scroll[z] != 0){ 204 change[z] = (this.page[z] - top - pos[z]) * this.options.velocity; 205 } else if (this.page[z] + bottom > (size[z] + pos[z]) && scroll[z] + size[z] != scrollSize[z]){ 206 change[z] = (this.page[z] - size[z] + bottom - pos[z]) * this.options.velocity; 207 } 208 change[z] = Math.round(change[z]); 209 } 210 if (change.y || change.x) this.options.onChange(scroll.x + change.x, scroll.y + change.y); 211 } 212 213 214var s5_dropdowntext2 = s5_dropdowntext; 215var s5_verticalhorizontal2 = s5_verticalhorizontal; 216 217 218// declaring the class 219var gallery =window.gallery= function(element, options) { 220 this.options= { 221 embedLinks: true, 222 fadeDuration: 500, 223 timed: false, 224 preloader: true, 225 preloaderImage: true, 226 preloaderErrorImage: true, 227 /* Data retrieval */ 228 manualData: null,
229 populateFrom: false, 230 populateData: true, 231 destroyAfterPopulate: true, 232 elementSelector: "div.imageElement", 233 titleSelector: "h3", 234 subtitleSelector: "p", 235 linkSelector: "a.open", 236 imageSelector: "img.full", 237 thumbnailSelector: "img.thumbnail", 238 defaultTransition: "fade", 239 /* InfoPane options */ 240 slideInfoZoneOpacity: s5_slide_opacity, 241 slideInfoZoneSlide: true, 242 /* Carousel options */ 243 carouselMinimizedOpacity: 0.4, 244 carouselMinimizedHeight: 20, 245 carouselMaximizedOpacity: 0.9, 246 thumbHeight: 75, 247 thumbWidth: 100, 248 thumbSpacing: 10, 249 thumbIdleOpacity: 0.2, 250 textShowCarousel: s5_dropdowntext2, 251 showCarouselLabel: true, 252 thumbCloseCarousel: true, 253 useThumbGenerator: false, 254 thumbGenerator: 'resizer.php', 255 useExternalCarousel: false, 256 carouselElement: false, 257 carouselHorizontal: s5_verticalhorizontal2, 258 activateCarouselScroller: true, 259 carouselPreloader: true, 260 textPreloadingCarousel: 'Loading...', 261 /* CSS Classes */ 262 baseClass: 'jdGallery', 263 withArrowsClass: 'withArrows', 264 /* Plugins: HistoryManager */ 265 useHistoryManager: false, 266 customHistoryKey: false, 267 /* Plugins: ReMooz */ 268 useReMooz: false, 269 slideShowDuration:3000, 270 slideHideDuration:2000, 271 randomOrder: "no", 272 }; 273 274 this.initialize(element, options); 275} 276 gallery.prototype.initialize= function(element, options) { 277 this.options=$.extend(this.options, options); 278 279 $(this).trigger('onInit'); 280 this.currentIter = 0; 281 this.lastIter = 0; 282 this.maxIter = 0; 283 this.galleryElement = element; 284 this.galleryData = this.options.manualData; 285 this.galleryInit = 1; 286 this.galleryElements = Array(); 287 this.thumbnailElements = Array(); 288 $(this.galleryElement).addClass(this.options.baseClass); 289 290 if (this.options.useReMooz&&(this.options.defaultTransition=="fade")) 291 this.options.defaultTransition="crossfade"; 292 293 this.populateFrom = element; 294 if (this.options.populateFrom) 295 this.populateFrom = this.options.populateFrom; 296 if (this.options.populateData) 297 this.populateData(); 298 element.css('display',"block"); 299 300 if (this.options.useHistoryManager) 301 this.initHistory(); 302 303 if ((this.options.embedLinks)|(this.options.useReMooz)) 304 { 305 this.currentLink = $('<a class="open"></a>').attr({href:'#',title:''}).appendTo(element); 306 if ((!this.options.showArrows) && (!this.options.showCarousel)) 307 this.galleryElement = element = this.currentLink; 308 else 309 this.currentLink.css('display', 'none'); 310 } 311 312 this.constructElements(); 313 if ((this.galleryData.length>1)&&(this.options.showArrows)) 314 { 315 var leftArrow = $('<a class="left"></a>').bind( 316 'click', 317 this.prevItem.bind(this) 318 ).appendTo(element); 319 var rightArrow = $('<a class="right"></a>').bind( 320 'click', 321 this.nextItem.bind(this) 322 ).appendTo(element); 323 $(this.galleryElement).addClass(this.options.withArrowsClass); 324 } 325 this.loadingElement = $('<div class="loadingElement"></div>').appendTo(element); 326 if (this.options.showInfopane) this.initInfoSlideshow(); 327 if (this.options.showCarousel) this.initCarousel(); 328 this.doSlideShow(1); 329 } 330 gallery.prototype.populateData= function() { 331 currentArrayPlace = $(this.galleryData).length; 332 options = this.options; 333 var data = $A(this.galleryData); 334 data.extend(this.populateGallery(this.populateFrom, currentArrayPlace)); 335 this.galleryData = data; 336 $(this).trigger('onPopulated'); 337 }; 338 gallery.prototype.populateGallery= function(element, startNumber) { 339 var data = []; 340 options = this.options; 341 currentArrayPlace = parseInt(startNumber); 342 $(options.elementSelector,element).each(function(i,el) { 343 elementDict = new Object({ 344 image: $(options.imageSelector,el).attr('src'), 345 number: currentArrayPlace, 346 transition: this.options.defaultTransition 347 }); 348 if ((options.showInfopane) | (options.showCarousel)){ 349 if(s5_hideh2 == "true") { elementDict.title= $(options.titleSelector,el)[0].innerHTML; } 350 elementDict.description= $(options.subtitleSelector,el)[0].innerHTML 351 } 352 if ((options.embedLinks) | (options.useReMooz)){ 353 while($(options.linkSelector,el)[0] == undefined) 354 ; 355 elementDict.link=$(options.linkSelector,el)[0].href||false; 356 // hides false and open image tooltip popups // linkTitle: el.getElement(options.linkSelector).title||false, 357 elementDict.linkTarget= $(options.linkSelector,el).attr('target')||false; 358 }
359 if ((!options.useThumbGenerator) && (options.showCarousel)){ 360 elementDict.thumbnail=$(options.thumbnailSelector,el).attr('src'); 361 }else if (options.useThumbGenerator) 362 elementDict.thumbnail= options.thumbGenerator + '?imgfile=' + elementDict.image + '&max_width=' + options.thumbWidth + '&max_height=' + options.thumbHeight; 363 data.extend([elementDict]); 364 currentArrayPlace++; 365 if (this.options.destroyAfterPopulate) 366 $(el).remove(); 367 }.bind(this)); 368 return data; 369 }, 370 gallery.prototype.constructElements= function() { 371 el = this.galleryElement; 372 if (this.options.embedLinks && (!this.options.showArrows)) 373 el = this.currentLink; 374 this.maxIter = this.galleryData.length; 375 var currentImg; 376 for(i=0;i<$(this.galleryData).length;i++) 377 { 378 var currentImg = 379 new morphx($('<div class="slideElement"></div>').css({ 380 'position':'absolute', 381 'left':'0px', 382 'right':'0px', 383 'margin':'0px', 384 'padding':'0px', 385 'backgroundPosition':"center center", 386 'opacity':'0' 387 }).appendTo(el),{duration: this.options.fadeDuration}); 388 389 if (this.options.preloader) 390 { 391 392 currentImg.element.source = this.galleryData[i].image; 393 currentImg.element.loaded=false; 394 395 currentImg.element.load = function(params) { 396 var imageStyle=params[0]; 397 var i=params[1]; 398 399 if (!imageStyle.loaded) { 400 var imgx=new Image(); 401 this.galleryData[i].imgloader = imgx.onload=function(params2){ 402 img=params2[0]; 403 i=params2[1]; 404 img.css( 405 'backgroundImage', 406 "url('" + img.source + "')") 407 img.loaded = true; 408 img.width = this.galleryData[i].imgloader.width; 409 img.height = this.galleryData[i].imgloader.height; 410 }.passx([imageStyle, i], this); 411 imgx.src=imageStyle.source; 412 413 } 414 }.passx([currentImg.element, i],this); 415 } else { 416 currentImg.element.css('backgroundImage', 417 "url('" + this.galleryData[i].image + "')"); 418 } 419 this.galleryElements[parseInt(i)] = currentImg; 420 } 421 }, 422 gallery.prototype.destroySlideShow= function(element) { 423 var myClassName = element.className; 424 var newElement = $('div class="myClassName"></div>'); 425 element.parentNode.replaceChild(newElement, element); 426 }, 427 gallery.prototype.startSlideShow= function() { 428 $(this).trigger('onStart'); 429 this.loadingElement[0].style.display = "none"; 430 this.lastIter = this.maxIter - 1; 431 this.currentIter = 0; 432 this.galleryInit = 0; 433 this.galleryElements[parseInt(this.currentIter)].element.css({opacity: 1}); 434 if (this.options.showInfopane) 435 this.showInfoSlideShow.delay(1000, this); 436 if (this.options.useReMooz) 437 this.makeReMooz.delay(1000, this); 438 var textShowCarousel = formatString(this.options.textShowCarousel, this.currentIter+1, this.maxIter); 439 if (this.options.showCarousel&&(!this.options.carouselPreloader)&&(!this.options.useExternalCarousel)) 440 this.carouselBtn.html(textShowCarousel).attr('title', textShowCarousel); 441 this.prepareTimer(); 442 if (this.options.embedLinks) 443 this.makeLink(this.currentIter); 444 }, 445 gallery.prototype.random = function () { 446 function getRandomInt(min, max) { 447 return Math.floor(Math.random() * (max - min)) + min; 448 } 449 return getRandomInt(0, this.maxIter); 450 }, 451 gallery.prototype.nextRandom = function () { 452 var randomInt = this.random(); 453 this.goTo(randomInt); 454 }, 455 gallery.prototype.nextItem= function() { 456 $(this).trigger('onNextCalled'); 457 this.nextIter = this.currentIter+1; 458 if (this.nextIter >= this.maxIter) 459 this.nextIter = 0; 460 this.galleryInit = 0; 461 this.goTo(this.nextIter); 462 }, 463 gallery.prototype.prevItem= function() { 464 $(this).trigger('onPreviousCalled'); 465 this.nextIter = this.currentIter-1; 466 if (this.nextIter <= -1) 467 this.nextIter = this.maxIter - 1; 468 this.galleryInit = 0; 469 this.goTo(this.nextIter); 470 }, 471 gallery.prototype.goTo= function(num) { 472 //console.log(num); 473 this.clearTimer(); 474 if(this.options.preloader) 475 { 476 this.galleryElements[num].element.load(); 477 if (num==0) 478 this.galleryElements[this.maxIter - 1].element.load(); 479 else 480 this.galleryElements[num - 1].element.load(); 481 if (num==(this.maxIter - 1)) 482 this.galleryElements[0].element.load(); 483 else 484 this.galleryElements[num + 1].element.load(); 485 486 } 487 if (this.options.embedLinks) 488 this.clearLink(); 489 if (this.options.showInfopane) 490 { 491 this.slideInfoZone.clearChain(); 492 //this.hideInfoSlideShow().chain(this.changeItem.passx(num, this)); 493 this.hideInfoSlideShow(); 494 this.changeItem(num); 495 } else 496 this.currentChangeDelay = this.changeItem.delay(500, this, num); 497 if (this.options.embedLinks) 498 this.makeLink(num); 499 this.prepareTimer(); 500 /*if (this.options.showCarousel)
501 this.clearThumbnailsHighlights();*/ 502 }, 503 gallery.prototype.changeItem= function(num) { 504 //console.log(arguments.callee.caller); 505 $(this).trigger('onStartChanging'); 506 this.galleryInit = 0; 507 if (this.currentIter != num) 508 { 509 for(i=0;i<this.maxIter;i++) 510 { 511 if ((i != this.currentIter)) this.galleryElements[i].css({opacity: 0}); 512 } 513 //console.log(this.galleryData[num].transition); 514 gallery.Transitions[this.galleryData[num].transition].passx([ 515 this.galleryElements[this.currentIter], 516 this.galleryElements[num], 517 this.currentIter, 518 num], this)(); 519 this.currentIter = num; 520 if (this.options.useReMooz) 521 this.makeReMooz(); 522 } 523 var textShowCarousel = formatString(this.options.textShowCarousel, num+1, this.maxIter); 524 if ((this.options.showCarousel)&&(!this.options.useExternalCarousel)) 525 this.carouselBtn.html(textShowCarousel).attr('title', textShowCarousel); 526 this.doSlideShow.bind(this)(); 527 $(this).trigger('onChanged'); 528 }, 529 gallery.prototype.clearTimer= function() { 530 if (this.options.timed) 531 $clear(this.timer); 532 }, 533 gallery.prototype.prepareTimer = function () { 534 if (this.options.timed) { 535 if (this.timer) 536 this.clearTimer(); 537 if (this.options.randomOrder === "yes") { 538 this.timer = this.nextRandom.delay(this.options.delay, this); 539 } else { 540 this.timer = this.nextItem.delay(this.options.delay, this); 541 } 542 } 543 }, 544 gallery.prototype.doSlideShow= function(position) { 545 // start jv 546 if(this.carousel){ 547 var thumbs = $('.thumbnail',this.carousel.element); 548 thumbs.each(function(i,el){ 549 if($(el).hasClass('active')) $(el).removeClass('active'); 550 }); 551 552 $(thumbs[this.currentIter]).addClass('active'); 553 554 } 555 var images = $('.slideElement',this.galleryElement); 556 if(images.length){ 557 images.each(function(i,el){ 558 if($(el).hasClass('active')) $(el).removeClass('active'); 559 }); 560 $(images[this.currentIter]).addClass('active'); 561 } 562 //end jv 563 564 565 if (this.galleryInit == 1) 566 { 567 imgPreloader = new Image(); 568 imgPreloader.onload=function(){ 569 this.startSlideShow.delay(10, this); 570 }.bind(this); 571 imgPreloader.src = this.galleryData[0].image; 572 if(this.options.preloader) 573 this.galleryElements[0].element.load(); 574 } else { 575 576 if (this.options.showInfopane) 577 { 578 if (this.options.showInfopane) 579 { 580 this.showInfoSlideShow.delay((500 + this.options.fadeDuration), this); 581 //this.showInfoSlideShow(); 582 } else 583 if ((this.options.showCarousel)&&(this.options.activateCarouselScroller)) 584 this.centerCarouselOn(position); 585 } 586 } 587 588 }, 589 gallery.prototype.createCarousel= function() { 590 var carouselElement; 591 if (!this.options.useExternalCarousel) 592 { 593 var carouselContainerElement = $('<div class="carouselContainer"></div>').appendTo(this.galleryElement); 594 this.carouselContainer = new morphx(carouselContainerElement,{easing: 'easeOutExpo'}); 595 this.carouselContainer.element.normalHeight = carouselContainerElement.outerHeight(); 596 this.carouselContainer.element.css({'opacity': this.options.carouselMinimizedOpacity, 'top': (this.options.carouselMinimizedHeight - this.carouselContainer.element.normalHeight)}); 597 this.carouselBtn = $('<a class="carouselBtn"></a>').attr({ 598 title: this.options.textShowCarousel 599 }).appendTo(carouselContainerElement); 600 if(this.options.carouselPreloader) 601 this.carouselBtn.html(this.options.textPreloadingCarousel); 602 else 603 this.carouselBtn.html(this.options.textShowCarousel); 604 this.carouselBtn.bind( 605 'click', 606 (function () { 607 this.carouselContainer.cancel(); 608 this.toggleCarousel(); 609 }).bind(this) 610 ); 611 this.carouselActive = false; 612 613 carouselElement = $('<div class="carousel"></div>').appendTo(carouselContainerElement); 614 this.carousel = new morphx(carouselElement); 615 } else { 616 carouselElement = $(this.options.carouselElement).addClass('jdExtCarousel'); 617 } 618 this.carouselElement = new morphx(carouselElement,{easing:'easeOutExpo'}); 619 this.carouselElement.element.normalHeight = carouselElement.offsetHeight; 620 if (this.options.showCarouselLabel) 621 this.carouselLabel = $('<p class="label"></p>').appendTo(carouselElement);
622 carouselWrapper = $('<div class="carouselWrapper"></div>').appendTo(carouselElement); 623 this.carouselWrapper =new morphx(carouselWrapper,{easing:'easeOutExpo'}); 624 this.carouselWrapper.element.normalHeight = carouselWrapper.offsetHeight; 625 this.carouselInner = $('<div class="carouselInner"></div>').appendTo(carouselWrapper)[0]; 626 if (this.options.activateCarouselScroller) 627 { 628 this.carouselWrapper.element.scroller = new Scroller(carouselWrapper, { 629 area: 100, 630 velocity: 0.2 631 }) 632 633 /* this.carouselWrapper.elementScroller = new Fx.Scroll(carouselWrapper, { 634 duration: 400, 635 onStart: this.carouselWrapper.scroller.stop.bind(this.carouselWrapper.scroller), 636 onComplete: this.carouselWrapper.scroller.start.bind(this.carouselWrapper.scroller) 637 });*/ 638 639 this.carouselWrapper.element.elementScroller = (function(from,to){ 640 this.carouselWrapper.element.scroller.stop.bind(this.carouselWrapper.scroller); 641 this.carouselWrapper.element.animate({left:[from,to]},{duration:400,easing:'linear',queue:false,complete:this.carouselWrapper.element.scroller.start.bind(this.carouselWrapper.element.scroller)}).bind(this); 642 }).bind(this); 643 } 644 }, 645 gallery.prototype.fillCarousel= function() { 646 this.constructThumbnails(); 647 this.carouselInner.normalWidth = ((this.maxIter * (this.options.thumbWidth + this.options.thumbSpacing + 2))+this.options.thumbSpacing) + "px"; 648 if (this.options.carouselHorizontal) 649 this.carouselInner.style.width = this.carouselInner.normalWidth; 650 }, 651 gallery.prototype.initCarousel= function () { 652 this.createCarousel(); 653 this.fillCarousel(); 654 if (this.options.carouselPreloader) 655 this.preloadThumbnails(); 656 }, 657 gallery.prototype.flushCarousel= function() { 658 $(this.thumbnailElements).each(function(i,myFx) { 659 myFx.element.remove(); 660 myFx = myFx.element = null; 661 }); 662 this.thumbnailElements = []; 663 }, 664 gallery.prototype.toggleCarousel= function() { 665 if (this.carouselActive) 666 this.hideCarousel(); 667 else 668 this.showCarousel(); 669 }, 670 gallery.prototype.showCarousel= function () { 671 $(this).trigger('onShowCarousel'); 672 this.carouselContainer.completefunc(function() { 673 this.carouselActive = true; 674 this.carouselWrapper.element.scroller.start(); 675 $(this).trigger('onCarouselShown'); 676 //this.carouselContainer.options.onComplete = null; 677 }.bind(this)).start({ 678 'opacity': this.options.carouselMaximizedOpacity, 679 'top': 0 680 }); 681 }, 682 gallery.prototype.hideCarousel= function () { 683 $(this).trigger('onHideCarousel'); 684 var targetTop = this.options.carouselMinimizedHeight - this.carouselContainer.element.normalHeight; 685 this.carouselContainer.completefunc(function() { 686 this.carouselActive = false; 687 this.carouselWrapper.element.scroller.stop(); 688 $(this).trigger('onCarouselHidden'); 689 //this.carouselContainer.options.onComplete = null; 690 }.bind(this)).start({ 691 'opacity': this.options.carouselMinimizedOpacity, 692 'top': targetTop 693 }); 694 }, 695 gallery.prototype.constructThumbnails= function () { 696 element = this.carouselInner; 697 for(i=0;i<this.galleryData.length;i++) 698 { 699 var currentImg = new morphx($('<div class="thumbnail"></div>').css({ 700 backgroundImage: "url('" + this.galleryData[i].thumbnail + "')", 701 backgroundPosition: "center center", 702 backgroundRepeat: 'no-repeat', 703 marginLeft: this.options.thumbSpacing + "px", 704 width: this.options.thumbWidth + "px", 705 height: this.options.thumbHeight + "px" 706 }).appendTo(element),{duration: 200,easing:'linear'});//.animate({'opacity': this.options.thumbIdleOpacity}, ); 707 currentImg.element.bind( 708 'mouseover', function (myself) { 709 myself.cancel(); 710 myself.start({'opacity': 0.99}); 711 if (this.options.showCarouselLabel) 712 this.carouselLabel.html('<span class="number">' + (myself.element.data('relatedImage').number + 1) + "/" + this.maxIter + ":</span> " + myself.element.data('relatedImage').title); 713 }.passx(currentImg, this)); 714 currentImg.element.bind('mouseout', (function (myself) { 715 myself.cancel(); 716 myself.start({'opacity': this.options.thumbIdleOpacity}); 717 }).passx(currentImg, this)); 718 719 currentImg.element.bind('click', (function (myself) { 720 this.galleryInit = 0; 721 //console.log(myself.data('relatedImage').number); 722 this.goTo(myself.data('relatedImage').number); 723 if (this.options.thumbCloseCarousel&&(!this.options.useExternalCarousel)) 724 this.hideCarousel(); 725 }).passx(currentImg, this)); 726 727 currentImg.element.data('relatedImage', this.galleryData[i]); 728 this.thumbnailElements[parseInt(i)] = currentImg; 729 } 730 }, 731 gallery.prototype.log= function(value) { 732 //if(console.log) 733 //console.log(value); 734 }, 735 gallery.prototype.preloadThumbnails= function() { 736 var thumbnails = []; 737 for(i=0;i<this.galleryData.length;i++) 738 { 739 thumbnails[parseInt(i)] = this.galleryData[i].thumbnail; 740 } 741 this.thumbnailPreloader = new Preloader(); 742 if (!this.options.useExternalCarousel) 743 $(this.thumbnailPreloader).bind('onComplete', function() { 744 var textShowCarousel = formatString(this.options.textShowCarousel, this.currentIter+1, this.maxIter); 745 this.carouselBtn.html(textShowCarousel).attr('title', textShowCarousel); 746 }.bind(this)); 747 this.thumbnailPreloader.load(thumbnails); 748 },
749 gallery.prototype.clearThumbnailsHighlights= function() 750 { 751 for(i=0;i<this.galleryData.length;i++) 752 { 753 this.thumbnailElements[i].cancel(); 754 this.thumbnailElements[i].start(0.2); 755 } 756 }, 757 gallery.prototype.changeThumbnailsSize= function(width, height) 758 { 759 for(i=0;i<this.galleryData.length;i++) 760 { 761 this.thumbnailElements[i].cancel(); 762 this.thumbnailElements[i].element.css({ 763 'width': width + "px", 764 'height': height + "px" 765 }); 766 } 767 }, 768 gallery.prototype.centerCarouselOn= function(num) { 769 if (!this.carouselWallMode) 770 { 771 var carouselElement = this.thumbnailElements[num]; 772 var position = carouselElement.element.offsetLeft + (carouselElement.element.offsetWidth / 2); 773 var carouselWidth = this.carouselWrapper.element.offsetWidth; 774 var carouselInnerWidth = this.carouselInner.offsetWidth; 775 var diffWidth = carouselWidth / 2; 776 var scrollPos = position-diffWidth; 777 this.carouselWrapper.element.elementScroller(scrollPos,0); 778 } 779 }, 780 gallery.prototype.initInfoSlideshow= function() { 781 /*if (this.slideInfoZone.element) 782 this.slideInfoZone.element.remove();*/ 783 this.slideInfoZone = new morphx($('<div class="slideInfoZone"></div>').appendTo($(this.galleryElement)).css({'opacity':0})); 784 var slideInfoZoneTitle = ""; 785 if (s5_hideh2 == "true") { 786 slideInfoZoneTitle = $('<h2></h2>').appendTo(this.slideInfoZone.element); 787 } 788 var slideInfoZoneDescription = $('<p></p>').appendTo(this.slideInfoZone.element); 789 this.slideInfoZone.element.normalHeight = this.slideInfoZone.element[0].offsetHeight; 790 this.slideInfoZone.element.css('opacity',0); 791 }, 792 gallery.prototype.changeInfoSlideShow= function() 793 { 794 //this.hideInfoSlideShow.delay(10, this); 795 //this.showInfoSlideShow.delay(500, this); 796 this.hideInfoSlideShow.apply(this); 797 this.showInfoSlideShow.apply(this); 798 }, 799 gallery.prototype.showInfoSlideShow= function() { 800 $(this).trigger('onShowInfopane'); 801 $('.slideInfoZone').stop(); 802 element = this.slideInfoZone.element; 803 $('h2',element).html( this.galleryData[this.currentIter].title); 804 $('p',element).html( this.galleryData[this.currentIter].description); 805 //console.log(this.slideInfoZone.element); 806 if (element.className != 'slideInfoZone slideInfoZone_load') { 807 this.slideInfoZone.element[0].className = 'slideInfoZone'; 808 this.adjustclassname.delay(20, this); 809 } 810 this.slideInfoZone.options.duration = this.options.slideShowDuration; 811 if (this.options.showCarousel) 812 this.slideInfoZone.completefunc(this.centerCarouselOn.passx(this.currentIter, this)); 813 this.slideInfoZone.completefunc(function(){ 814 if(typeof s5_multibox_enabled !== 'undefined'){initMultibox('#myGallery .s5mb');} 815 if(typeof s5_page_scroll_enabled !== 'undefined'){initSmoothscroll();} 816 }); 817 if(this.options.slideInfoZoneSlide) 818 this.slideInfoZone.start({'opacity': this.options.slideInfoZoneOpacity, 'height': this.slideInfoZone.element.normalHeight},{easing:'easeOutExpo'}); 819 else 820 this.slideInfoZone.start({'opacity':this.options.slideInfoZoneOpacity}); 821 822 return this.slideInfoZone; 823 }, 824 gallery.prototype.adjustclassname= function() { 825 this.slideInfoZone.element[0].className = 'slideInfoZone slideInfoZone_load'; 826 }, 827 gallery.prototype.hideInfoSlideShow= function() { 828 $(this).trigger('onHideInfopane'); 829 this.slideInfoZone.cancel(); 830 this.slideInfoZone.element[0].className = 'slideInfoZone slideInfoZone_unload'; 831 this.slideInfoZone.options.duration = this.options.slideHideDuration; 832 //console.log(this.options.slideShowDuration); 833 if(this.options.slideInfoZoneSlide) 834 this.slideInfoZone.start({'opacity': 0, 'height': 0},{easing:'easeOutExpo'}); 835 else 836 this.slideInfoZone.start({'opacity': 0}); 837 return this.slideInfoZone; 838 }, 839 gallery.prototype.makeLink=function(num) { 840 this.currentLink.attr({ 841 href: this.galleryData[num].link, 842 title: this.galleryData[num].linkTitle 843 }); 844 if (!((this.options.embedLinks) && (!this.options.showArrows) && (!this.options.showCarousel))) 845 this.currentLink.css('display', 'block'); 846 }, 847 gallery.prototype.clearLink= function() { 848 this.currentLink.attr({href: '', title: ''}); 849 if (!((this.options.embedLinks) && (!this.options.showArrows) && (!this.options.showCarousel))) 850 this.currentLink.css('display', 'none'); 851 }, 852 gallery.prototype.makeReMooz= function() { 853 this.currentLink.attr({ 854 href: '#' 855 }); 856 this.currentLink.css({ 857 'display': 'block' 858 }); 859 860 this.galleryElements[this.currentIter].element.attr('title', this.galleryData[this.currentIter].title + ' :: ' + this.galleryData[this.currentIter].description); 861 this.ReMooz = new ReMooz(this.galleryElements[this.currentIter].element, { 862 link: this.galleryData[this.currentIter].link, 863 shadow: false, 864 dragging: false, 865 addClick: false, 866 resizeOpacity: 1 867 }); 868 var img = this.galleryElements[this.currentIter]; 869 var coords = img.element.offset(); 870 coords.width=img.element.width(); 871 coords.height=img.element.height(); 872 widthDiff = coords.width - img.width;
873 heightDiff = coords.height - img.height; 874 875 coords.width = img.width; 876 coords.height = img.height; 877 878 coords.left += Math.ceil(widthDiff/2)+1; 879 coords.top += Math.ceil(heightDiff/2)+1; 880 881 this.ReMooz.getOriginCoordinates = (function(coords) { 882 return coords; 883 }).bind(this, coords); 884 this.currentLink.onclick = function () { 885 this.ReMooz.open.bind(this.ReMooz)(); 886 return false; 887 }.bind(this); 888 }, 889 /* To change the gallery data, those two functions : */ 890 gallery.prototype.flushGallery= function() { 891 $(this.galleryElements).each(function(i,myFx) { 892 myFx.element.remove(); 893 myFx = myFx.element = null; 894 }); 895 this.galleryElements = []; 896 }, 897 gallery.prototype.changeData= function(data) { 898 this.galleryData = data; 899 this.clearTimer(); 900 this.flushGallery(); 901 if (this.options.showCarousel) this.flushCarousel(); 902 this.constructElements(); 903 if (this.options.showCarousel) this.fillCarousel(); 904 if (this.options.showInfopane) this.hideInfoSlideShow(); 905 this.galleryInit=1; 906 this.lastIter=0; 907 this.currentIter=0; 908 this.doSlideShow(1); 909 }, 910 /* Plugins: HistoryManager */ 911 gallery.prototype.initHistory= function() { 912 $(this).trigger('onHistoryInit'); 913 this.historyKey = this.galleryElement.id + '-picture'; 914 if (this.options.customHistoryKey) 915 this.historyKey = this.options.customHistoryKey; 916 917 this.history = new History.Route({ 918 defaults: [1], 919 pattern: this.historyKey + '\\((\\d+)\\)', 920 generate: function(values) { 921 return [this.historyKey, '(', values[0], ')'].join('') 922 }.bind(this), 923 onMatch: function(values, defaults) { 924 if (parseInt(values[0])-1 < this.maxIter) 925 this.goTo(parseInt(values[0])-1); 926 }.bind(this) 927 }); 928 this.bind('onChanged', function(){ 929 this.history.setValue(0, this.currentIter+1); 930 this.history.defaults=[this.currentIter+1]; 931 }.bind(this)); 932 $(this).trigger('onHistoryInited'); 933 } 934 935 936 937gallery.Transitions = new Object ({ 938 fade: function(/*oldFx, newFx, oldPos, newPos*/){ 939 //console.log(arguments); 940 oldFx=arguments[0][0]; 941 newFx=arguments[0][1]; 942 oldPos=arguments[0][2]; 943 newPos=arguments[0][3]; 944 oldFx.options.easing = newFx.options.easing = 'linear'; 945 //oldFx.options.duration = newFx.options.duration = this.options.fadeDuration; 946 if (newPos > oldPos) newFx.start({opacity: 1}); 947 else 948 { 949 newFx.element.css({opacity: 1}); 950 oldFx.start({opacity: 0}); 951 } 952 }, 953 slideleft: function (/*oldFx, newFx, oldPos, newPos*/) { 954 //console.log(arguments); 955 oldFx = arguments[0][0]; 956 newFx = arguments[0][1]; 957 oldPos = arguments[0][2]; 958 newPos = arguments[0][3]; 959 oldFx.options.easing = newFx.options.easing = 'linear'; 960 oldFx.options.duration = newFx.options.duration = this.options.fadeDuration; 961 //console.log(oldPos); 962 //console.log(newPos); 963 964 /* New element */ 965 newFx.element.css('z-index', 0); 966 newFx.element.css('opacity', 0); 967 newFx.element.css('left', 0); 968 969 /* Old Element */ 970 oldFx.element.css('z-index', 1); 971 oldFx.element.css('opacity', 1); 972 oldFx.element.css('left', 0); 973 974 oldFx.start({left: '100%', opacity: 0.1}, {duration: this.options.fadeDuration}); 975 newFx.element.css('left', 0); 976 newFx.element.css('opacity', 1); 977 }, 978 slideright: function (/*oldFx, newFx, oldPos, newPos*/) { 979 //console.log(arguments); 980 oldFx = arguments[0][0]; 981 newFx = arguments[0][1]; 982 oldPos = arguments[0][2]; 983 newPos = arguments[0][3]; 984 oldFx.options.easing = newFx.options.easing = 'linear'; 985 oldFx.options.duration = newFx.options.duration = this.options.fadeDuration; 986 //console.log(oldPos); 987 //console.log(newPos); 988 989 /* New element */ 990 newFx.element.css('z-index', 0); 991 newFx.element.css('opacity', 0); 992 newFx.element.css('left', 0); 993 994 /* Old Element */ 995 oldFx.element.css('z-index', 1); 996 oldFx.element.css('opacity', 1); 997 oldFx.element.css('left', 0); 998 999 oldFx.start({left: '-100%', opacity: 0.1}, {duration: this.options.fadeDuration}); 1000 newFx.element.css('left', 0); 1001 newFx.element.css('opacity', 1); 1002 }, 1003 crossfade: function(/*oldFx, newFx, oldPos, newPos*/){ 1004 oldFx=arguments[0][0]; 1005 newFx=arguments[0][1]; 1006 oldPos=arguments[0][2]; 1007 newPos=arguments[0][3]; 1008 oldFx.options.easing = newFx.options.easing = 'linear'; 1009 //oldFx.options.duration = newFx.options.duration = this.options.fadeDuration; 1010 newFx.start({opacity: 1}); 1011 oldFx.start({opacity: 0}); 1012 }, 1013 fadebg: function(/*oldFx, newFx, oldPos, newPos*/){ 1014 oldFx=arguments[0][0]; 1015 newFx=arguments[0][1]; 1016 oldPos=arguments[0][2]; 1017 newPos=arguments[0][3]; 1018 oldFx.options.easing = newFx.options.easing = 'linear'; 1019 //oldFx.options.duration = newFx.options.duration = this.options.fadeDuration / 2; 1020 oldFx.completefunc(newFx.start.passx([{opacity: 1}], newFx)).start({opacity: 0}); 1021 } 1022}); 1023 1024/* All code copyright 2007 Jonathan Schemoul */ 1025 1026/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 1027 * Follows: Preloader (class) 1028 * Simple class for preloading images with support for progress reporting 1029 * Copyright 2007 Tomocchino. 1030 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 1031 1032var Preloader = function(options){ 1033 1034 1035 this.options= { 1036 root : '', 1037 period : 100 1038 } 1039 if(options) this.options=$.extend(this.options,options); 1040} 1041 1042 Preloader.prototype.load= function(sources) { 1043 this.index = 0; 1044 this.images = []; 1045 this.sources = this.temps = sources; 1046 this.total = this. sources.length; 1047 1048 $(this).trigger('onStart', [this.index, this.total]); 1049 try{var per=this.options.period;}catch(e){return;}
1050 this.timer = this.progress.periodical(per, this); 1051 1052 $(this.sources).each((function( index, source){ 1053 this.images[index] = $('<img/>').attr('src',this.options.root + source); 1054 this.images[index].bind('load' ,function(){ this.index++; if(this.images[index]) $(this).trigger('onLoad', [this.images[index], index, source]); }.bind(this)).bind(this); 1055 this.images[index].bind('error' ,function(){ this.index++; $(this).trigger('onError', [this.images.splice(index, 1), index, source]); }.bind(this)).bind(this); 1056 this.images[index].bind('abort' ,function(){ this.index++; $(this).trigger('onError', [this.images.splice(index, 1), index, source]); }.bind(this)).bind(this); 1057 }).bind( this)); 1058 } 1059 1060 Preloader.prototype.progress= function() { 1061 $(this).trigger('onProgress', [Math.min(this.index, this.total), this.total]); 1062 if(this.index >= this.total) this.complete(); 1063 }, 1064 1065 Preloader.prototype.complete= function(){ 1066 $clear(this.timer); 1067 $(this).trigger('onComplete', [this.images]); 1068 }; 1069 1070 Preloader.prototype.cancel= function(){ 1071 $clear(this.timer); 1072 } 1073 1074})(jQuery); 1075/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 1076 * Follows: formatString (function) 1077 * Original name: Yahoo.Tools.printf 1078 * Copyright Yahoo. 1079 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 1080 1081function formatString() { 1082 var num = arguments.length; 1083 var oStr = arguments[0]; 1084 for (var i = 1; i < num; i++) { 1085 var pattern = "\\{" + (i-1) + "\\}"; 1086 var re = new RegExp(pattern, "g"); 1087 oStr = oStr.replace(re, arguments[i]); 1088 } 1089 return oStr; 1090}
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.