/** # mod_jcslide - JV Slide # @version 1.6.x and 1.5.x # ------------------------------------------------------------------------ # author Open Source Code Solutions Co # copyright Copyright (C) 2011 joomlavi.com. All Rights Reserved. # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL or later. # Websites: http://www.joomlavi.com # Technical Support: http://www.joomlavi.com/my-tickets.html -------------------------------------------------------------------------*/ var JVSlide = window.JVSlide = new Class({ options: {}, Implements: [Events,Options], initialize: function (options) { this.setOptions(options); options = this.options; // install options var This = this, selector = options.panel = $$(options.panel)[0], itemspanel = selector.getElement('.JVSlide_pics'), descpanel = selector.getElement('.JVSlide_paneldesc'), controls = selector.getElement('.JVSlide_control'), items = itemspanel.getChildren(), imagelinks = [] ; items.each(function (el) { imagelinks.push(el.getElement('img').src); el.fx = new Fx.Morph(el, { duration: options.duration }); el.setStyles({ opacity: 0, width: 0, height: 0, display: 'block' }); el.addEvent('click', function (e) { var index = items.indexOf(this), bol = false ; if(index === showingIndex) return; if (this.slidePos == 'left') bol = true; new Event(e).stop(); select(index, bol); }); el.desc = el.getElement('.JVSlide_description'); el.desc.setStyles({ opacity: 0 }) el.desc.fx = new Fx.Morph(el.desc, { duration: options.duration }); descpanel.adopt(el.desc); }); // install setup var preloadImage = function () { Asset.images(imagelinks, { onComplete: function () { select(0); } }); } ; controls.getElement('.JVSlide_prev').addEvent('click', function (e) { new Event(e).stop(); prev(); }); controls.getElement('.JVSlide_next').addEvent('click', function (e) { new Event(e).stop(); next(); }); // install action var showingIndex = false, isFx = false, leftOfLarge = -options.largeSize.width / 2, leftOfSmall = -options.smallSize.width / 2, leftOfLeftSmall = -options.space + leftOfLarge, leftOfRightSmall = -leftOfLeftSmall - options.smallSize.width, next = function () { select(showingIndex + 1); }, prev = function () { select(showingIndex - 1, true); }, select = function (index, dir) { if (isFx || index === showingIndex) return; isFx = true; var waitShow = items[curentindex(index)], waitLeft = items[curentindex(index - 1)], waitRight = items[curentindex(index + 1)], waitHide = items[curentindex(index - 2)], showingDesc = showingIndex === false || items[showingIndex].desc, waitShowDesc = items[curentindex(index)].desc, showObj = { left: [waitShow.getStyle('left').toInt()||0,leftOfLarge], width: [waitShow.getStyle('width').toInt(),options.largeSize.width], height: [waitShow.getStyle('height').toInt(),options.largeSize.height], opacity: [0.7,1] }, leftObj = { left: [waitLeft.getStyle('left').toInt()||0,leftOfLeftSmall], opacity: [1,0.7], width: [waitLeft.getStyle('width').toInt(),options.smallSize.width], height: [waitLeft.getStyle('height').toInt(),options.smallSize.height] }, rightObj = { left: [waitRight.getStyle('left').toInt()||0,leftOfRightSmall], opacity: [0.7,1], width: [waitRight.getStyle('width').toInt(),options.smallSize.width], height: [waitRight.getStyle('height').toInt(),options.smallSize.height] }, hideObj = { left: [waitHide.getStyle('left').toInt()||0,leftOfSmall], opacity: [0.7,0] } ; if (dir) { waitHide = items[curentindex(index + 2)] } waitShow.fx.stop().start(showObj).chain(function () { isFx = false; showingIndex = curentindex(index); }); waitLeft.fx.stop().start(leftObj); waitRight.fx.stop().start(rightObj); if (waitLeft != waitHide || waitRight != waitHide) { waitHide.fx.stop().start(hideObj); } setTimeout(function () { waitShow.setStyle('z-index', 3); waitLeft.setStyle('z-index', 2); waitRight.setStyle('z-index', 2); }, options.duration / 2); waitLeft.slidePos = 'left'; waitRight.slidePos = 'right'; if (!(showingDesc === true)) { showingDesc.setStyle('z-index', 1); showingDesc.fx.start({ opacity: 0 }); } waitShowDesc.setStyle('z-index', 2); waitShowDesc.fx.start({ opacity: 1 }); }, curentindex = function (index) { index = index % items.length; return index < 0 ? items.length + index : index; } $extend(this, { }); preloadImage(); selector.setStyle('height', options.panelHeight); } });