/*! * jquery slider evolution - for jquery 1.3+ * http://codecanyon.net/user/aeroalquimia/portfolio?ref=aeroalquimia * * copyright 2011, eduardo daniel sada * http://codecanyon.net/wiki/buying/howto-buying/licensing/ * * version: 1.1.5 (08 jun 2011) * * includes jquery easing v1.3 * http://gsgd.co.uk/sandbox/jquery/easing/ * copyright (c) 2008 george mcginley smith * jquery easing released under the bsd license. */ (function ($) { var u = (jquery.browser.msie && parseint(jquery.browser.version, 10) < 7 && parseint(jquery.browser.version, 10) > 4); if (u) { try { document.execcommand("backgroundimagecache", false, true) } catch (err) {} }; if ($.proxy === undefined) { $.extend({ proxy: function (a, b) { if (a) { proxy = function () { return a.apply(b || this, arguments) } }; return proxy } }) }; $.extend($.easing, { easeoutcubic: function (x, t, b, c, d) { return c * ((t = t / d - 1) * t * t + 1) + b } }); sliderobject = function (a, b) { this.create(a, b) }; $.extend(sliderobject.prototype, { version: "1.1.4", create: function (a, b) { this.defaults = { name: 'jquery-slider', navigation: true, selector: true, timer: true, control: true, pauseonclick: true, pauseonhover: true, loop: true, slideshow: true, delay: 4500, duration: 400, bars: 9, columns: 7, rows: 3, speed: 80, padding: 8, easing: "easeoutcubic", transition: 'random', oncomplete: function () {}, onslideshowend: function () {} }; this.options = {}; this.transitions = ['fade', 'square', 'bar', 'squarerandom', 'fountain', 'rain', ]; this.dom = {}; this.img = []; this.titles = []; this.links = []; this.imginc = 0; this.imginterval = 0; this.inc = 0; this.order = []; this.resto = 0; this.selectores = []; this.direction = 0; this.degrees = 0; this.timer = 0; this.slides = []; this.esqueleto = { wrapper: [], navigation: [], timer: [], selector: [], control: [], clock: [] }; this.events = { clicked: false, hovered: false, playing: false, paused: false, stopped: false }; this.element = $(a); var c = this.options; var d = this; var e = this.element.children("div"); if (e.length < 2) { return false } if (!b['width']) { b['width'] = 0; b['height'] = 0; var f = {}; e.children().each(function () { if ($(this).is("img")) { f['width'] = $(this).outerwidth(); f['height'] = $(this).outerheight(); b['width'] = (f['width'] >= b['width']) ? f['width'] : 0; b['height'] = (f['height'] >= b['height']) ? f['height'] : 0 } }); delete f; if (b['width'] == 0 || b['height'] == 0) { delete b['width']; delete b['height'] } } this.options = $.extend(true, this.defaults, b); var g = this.options.name + '-option'; $.each(['navigation', 'selector', 'control', 'timer'], function (i, s) { if (d.options[s]) { g += '-' + s } }); this.esqueleto.wrapper = this.element.wrap('
').parent(); this.esqueleto.wrapper.css({ 'width': this.options.width, 'height': this.options.height }); this.element.css({ 'width': this.options.width, 'height': this.options.height, 'overflow': 'hidden', 'position': 'relative' }); e.each(function (i) { if (i == 0) { $(this).addclass(d.options.name + '-slide-current') } $(this).addclass(d.options.name + '-slide'); $(this).addclass(d.options.name + '-slide-' + (i + 1)); d.selectores = $(d.selectores).add($('' + (i + 1) + '')); if (i == 0) { $(d.selectores).addclass(d.options.name + '-selector-current') } }); this.esqueleto.selector = $('
').insertafter(a); this.esqueleto.selector.append(this.selectores); if (!this.options.selector) { this.esqueleto.selector.hide() } else { if (this.rgbtohex(this.esqueleto.selector.css("color")) == "#ffffff") { var h = $('.' + this.options.name + '-selector').outerwidth(true); h = -((h * e.length) / 2); this.esqueleto.selector.css({ "margin-left": h }) } } if (this.options.navigation) { this.esqueleto.navigation = $('
').insertafter(a); var j = $('prev'); var k = $('next'); this.esqueleto.navigation.append(j, k) } if (this.options.control) { this.esqueleto.control = $('play/pause').insertafter(a) } if (this.options.timer) { this.esqueleto.timer = $('
').insertafter(a); this.esqueleto.clock.mask = $('
'); this.esqueleto.clock.rotator = $('
'); this.esqueleto.clock.bar = $('
'); this.esqueleto.clock.command = this.rgbtohex(this.esqueleto.timer.css("color")); this.esqueleto.timer.append(this.esqueleto.clock.mask.append(this.esqueleto.clock.rotator), this.esqueleto.clock.bar) } this.addevents(); if (this.options.slideshow) { this.starttimer() } else { this.stoptimer() } }, addevents: function () { var c = this; var d = this.esqueleto.wrapper; var e = this.options; d.hover(function () { d.addclass(e.name + '-hovered'); if (e.pauseonhover && !c.events.paused) { c.events.hovered = true; c.pausetimer() } }, function () { d.removeclass(e.name + '-hovered'); if (e.pauseonhover && c.events.hovered) { c.starttimer() } c.events.hovered = false }); this.esqueleto.selector.children("a").click(function (a) { if (c.events.playing == false) { if ($(this).hasclass(e.name + '-selector-current') == false) { var b = c.events.stopped; c.stoptimer(); c.callslide($(this).attr('rel')); if (!e.pauseonclick && !b) { c.starttimer() } } } a.preventdefault() }); if (e.navigation) { this.esqueleto.navigation.children("a").click(function (a) { if (c.events.playing == false) { var b = c.events.stopped; c.stoptimer(); c.callslide($(this).attr("rel")); if (!e.pauseonclick && !b) { c.starttimer() } } a.preventdefault() }) }; if (e.control) { this.esqueleto.control.click($.proxy(function (a) { if (this.events.stopped) { this.starttimer() } else { this.stoptimer() } this.events.hovered = false; a.preventdefault() }, this)) } }, starttimer: function () { if (this.options.timer) { if (this.esqueleto.clock.command == "#000000") { this.esqueleto.clock.bar.animate({ "width": "100%" }, (this.resto > 0 ? this.resto : this.options.delay), "linear", $.proxy(function () { this.callslide("+1"); this.resto = 0; this.esqueleto.clock.bar.css({ "width": 0 }); this.starttimer() }, this)) } else if (this.esqueleto.clock.command = "#ffffff") { this.timer = setinterval($.proxy(function () { var a = "rotate(" + this.degrees + "deg)"; this.degrees += 2; this.esqueleto.clock.rotator.css({ "-webkit-transform": a, "-moz-transform": a, "-o-transform": a, "transform": a }); if (jquery.browser.msie) { this.esqueleto.clock.rotator.get(0).style['mstransform'] = a } if (this.degrees > 180) { this.esqueleto.clock.rotator.addclass(this.options.name + '-timer-rotator-move'); this.esqueleto.clock.mask.addclass(this.options.name + '-timer-mask-move') } if (this.degrees > 360) { this.esqueleto.clock.rotator.removeclass(this.options.name + '-timer-rotator-move'); this.esqueleto.clock.mask.removeclass(this.options.name + '-timer-mask-move'); this.degrees = 0; this.callslide("+1"); this.resto = 0 } }, this), this.options.delay / 180) } if (this.options.control) { this.esqueleto.control.removeclass(this.options.name + '-control-play'); this.esqueleto.control.addclass(this.options.name + '-control-pause') } } else { if (!this.timer) { this.timer = setinterval($.proxy(function () { this.callslide("+1") }, this), this.options.delay) } } this.events.paused = false; this.events.stopped = false; this.element.trigger("sliderplay") }, pausetimer: function () { clearinterval(this.timer); this.timer = ""; if (this.options.timer) { this.esqueleto.clock.bar.stop(true); var a = 100 - (parseint(this.esqueleto.clock.bar.css("width"), 10) * 100 / this.options.width); this.resto = this.options.delay * a / 100 } this.events.paused = true; if (this.options.control && !this.events.hovered) { this.esqueleto.control.removeclass(this.options.name + '-control-pause'); this.esqueleto.control.addclass(this.options.name + '-control-play') } this.element.trigger("sliderpause") }, stoptimer: function () { clearinterval(this.timer); this.timer = ""; if (this.options.timer) { this.esqueleto.clock.bar.stop(); this.resto = 0; if (this.esqueleto.clock.command == "#000000") { this.esqueleto.clock.bar.css({ "width": 0 }) } else if (this.esqueleto.clock.command == "#ffffff") { this.esqueleto.clock.rotator.removeclass(this.options.name + '-timer-rotator-move'); this.esqueleto.clock.mask.removeclass(this.options.name + '-timer-mask-move'); this.degrees = 0; var a = "rotate(" + this.degrees + "deg)"; this.esqueleto.clock.rotator.css({ "-webkit-transform": a, "-moz-transform": a, "-o-transform": a, "transform": a }); if (jquery.browser.msie) { this.esqueleto.clock.rotator.get(0).style['mstransform'] = a } } } this.events.paused = true; this.events.stopped = true; this.events.hovered = false; if (this.options.control) { this.esqueleto.control.removeclass(this.options.name + '-control-pause'); this.esqueleto.control.addclass(this.options.name + '-control-play') } this.element.trigger("sliderstop") }, shuffle: function (a) { for (var j, x, i = a.length; i; j = parseint(math.random() * i, 10), x = a[--i], a[i] = a[j], a[j] = x) {} return a }, rgbtohex: function (b) { if (b.match(/^#[0-9a-fa-f]{6}$/)) { return b.touppercase() } var c = /rgb\((.+),(.+),(.+)\)/i.exec(b); if (!c) { return b.touppercase() } var d = parseint(c[1]); var e = parseint(c[2]); var f = parseint(c[3]); var g = function (a) { return ((a.length < 2 ? '0' : '') + a).touppercase() }; return ('#' + g(d.tostring(16)) + g(e.tostring(16)) + g(f.tostring(16))).touppercase() }, callslide: function (a) { if (this.events.playing) { return false } var b = this.element.children("." + this.options.name + '-slide-current'); var c = this.esqueleto.selector.children("." + this.options.name + '-selector-current'); if (a == "+1") { var d = b.next("." + this.options.name + '-slide'); var e = c.next(); if (d.length <= 0) { if (this.options.loop) { d = this.element.children("." + this.options.name + '-slide').first(); e = this.selectores.first("a") } else { this.stoptimer(); return false } } } else if (a == "-1") { var d = b.prev("." + this.options.name + '-slide'); var e = c.prev("a"); if (d.length <= 0) { d = this.element.children("." + this.options.name + '-slide').last(); e = this.selectores.last("a") } } else { var d = this.element.children("." + this.options.name + '-slide-' + a); var e = this.esqueleto.selector.children("." + this.options.name + '-selector[rel=' + a + ']') } this.transition(b, c, d, e); this.element.trigger("sliderchange", d) }, transition: function (a, b, c, d) { if ($.isarray(this.options.transition)) { this.transitions = this.options.transition; this.options.transition = "random" } var e = c.attr('class').split(" ")[0].split(this.options.name + "-trans-")[1]; if (e === undefined) { e = this.options.transition } if (e == "random") { var f = ''; while (f == this.lasttransition || f == '') { f = this.shuffle(this.transitions)[0].tolowercase() } e = f } e = e.tolowercase(); this.lasttransition = e; this["trans" + e](a, b, c, d) }, transfade: function (a, b, c, d) { this.events.playing = true; c.css({ "opacity": 1 }).addclass(this.options.name + '-slide-next'); b.removeclass(this.options.name + '-selector-current'); d.addclass(this.options.name + '-selector-current'); a.stop().animate({ "opacity": 0 }, this.options.duration, $.proxy(function () { a.removeclass(this.options.name + '-slide-current'); c.addclass(this.options.name + '-slide-current'); c.removeclass(this.options.name + '-slide-next'); this.element.trigger("slidertransitionfinishes", c); this.events.playing = false }, this)) }, transbar: function (b, d, e, f, g) { g = $.extend(true, { 'direction': 'left' }, g); this.events.playing = true; var h = { 'width': math.round(this.options.width / this.options.bars), 'height': this.options.height }; bar_array = new array(this.options.bars); if (g['direction'] == "right") { c = 0; for (i = this.options.bars; i > 0; i--) { bar_array[c] = i; c++ } } else if (g['direction'] == "left") { for (i = 1; i <= this.options.bars; i++) { bar_array[i] = i } } else if (g['direction'] == "fountain" || g['direction'] == "rain") { var j = 1; var k = parseint(this.options.bars / 2); for (i = 1; i <= this.options.bars; i++) { bar_array[i - 1] = (k - (parseint((i) / 2) * j)) + 1; j *= -1 } } $.each(bar_array, $.proxy(function (i, a) { position = (a * h.width) - h.width; bar = $('
'); bar.css({ 'position': 'absolute', 'overflow': 'hidden', 'left': position, 'z-index': 3, 'opacity': 0, 'background-position': '-' + position + 'px top' }).css(h); if (g['direction'] == "fountain") { bar.css({ 'top': this.options.height }) } else if (g['direction'] == "rain") { bar.css({ 'top': -this.options.height }) } bar.append('
' + e.html() + '
'); this.element.append(bar); delay = this.options.speed * i; bar.animate({ 'opacity': 0 }, delay).animate({ 'opacity': 1, 'top': 0 }, { duration: this.options.duration }) }, this)); d.removeclass(this.options.name + '-selector-current'); f.addclass(this.options.name + '-selector-current'); settimeout($.proxy(function () { e.css({ "opacity": 1 }).addclass(this.options.name + '-slide-current'); b.css({ "opacity": 0 }).removeclass(this.options.name + '-slide-current'); this.element.children("." + this.options.name + '-bar').remove(); this.events.playing = false; this.element.trigger("slidertransitionfinishes", e) }, this), delay + this.options.duration) }, transbarleft: function (a, b, c, d) { return this.transbar(a, b, c, d) }, transbarright: function (a, b, c, d) { return this.transbar(a, b, c, d, { "direction": "right" }) }, transsquare: function (b, c, d, e, f) { f = $.extend(true, { 'mode': 'acumulative', 'effect': 'rain' }, f); this.events.playing = true; d.css({ "opacity": 1 }); c.removeclass(this.options.name + '-selector-current'); e.addclass(this.options.name + '-selector-current'); var g = math.round(this.options.width / this.options.columns); var h = math.round(this.options.height / this.options.rows); var j = []; var k = d.html(); for (irow = 1; irow <= this.options.rows; irow++) { for (icol = 1; icol <= this.options.columns; icol++) { j.push(icol + '' + irow); var l = ((irow * h) - h); var m = ((icol * g) - g); var n = (g * icol) - g; var o = (h * irow) - h; var p = $('
'); p.css({ 'overflow': 'hidden', 'position': 'absolute', 'width': g, 'height': h, 'z-index': 3, 'top': l, 'left': m, 'opacity': 0, 'background-position': '-' + n + 'px -' + o + 'px' }); p.append('
' + k + '
'); this.element.append(p) } } if (f['effect'] == 'random') { j = this.shuffle(j) } else if (f['effect'] == 'swirl') { j = this.arrayswirl(j) } if (f['mode'] == 'acumulative') { var q = 0; for (irow = 1; irow <= this.options.rows; irow++) { colrow = irow; for (icol = 1; icol <= this.options.columns; icol++) { delay = this.options.speed * colrow; this.element.children('.' + this.options.name + '-block-' + j[q]).animate({ 'width': g }, delay).animate({ 'opacity': 1 }, this.options.duration); q++; colrow++ } } } else if (f['mode'] == 'dual') { $.each(j, $.proxy(function (i, a) { delay = this.options.speed * i; this.element.children('.' + this.options.name + '-block-' + a).animate({ 'width': g }, delay).animate({ 'opacity': 1 }, this.options.duration) }, this)) } else if (f['mode'] == 'lineal') { $.each(j, $.proxy(function (i, a) { delay = this.options.speed * i; this.element.children('.' + this.options.name + '-block-' + a).animate({ 'width': g }, delay).animate({ 'opacity': 1 }, this.options.duration) }, this)) } settimeout($.proxy(function () { d.css({ "opacity": 1 }).addclass(this.options.name + '-slide-current'); b.css({ "opacity": 0 }).removeclass(this.options.name + '-slide-current'); this.element.children("." + this.options.name + '-block').remove(); this.events.playing = false; this.element.trigger("slidertransitionfinishes", d) }, this), delay + this.options.duration) }, transsquarerandom: function (a, b, c, d) { return this.transsquare(a, b, c, d, { 'effect': 'random' }) }, transslide: function (a, b, c, d, e) { e = $.extend(true, { 'direction': 'left' }, e); this.events.playing = true; c.css({ "opacity": 1 }); b.removeclass(this.options.name + '-selector-current'); d.addclass(this.options.name + '-selector-current'); a.removeclass(this.options.name + '-slide-current'); a.addclass(this.options.name + '-slide-next'); c.addclass(this.options.name + '-slide-current'); if (e.direction == "left") { c.css({ "left": this.options.width }) } else if (e.direction == "right") { c.css({ "left": -this.options.width }) } else if (e.direction == "top") { c.css({ "top": -this.options.height }) } else if (e.direction == "bottom") { c.css({ "top": this.options.height }) } c.stop().animate({ "left": 0, "top": 0 }, this.options.duration, this.options.easing, $.proxy(function () { a.removeclass(this.options.name + '-slide-next'); a.css({ "opacity": 0 }); this.events.playing = false; this.element.trigger("slidertransitionfinishes", c) }, this)) }, transslideleft: function (a, b, c, d) { return this.transslide(a, b, c, d, { 'direction': 'left' }) }, transslideright: function (a, b, c, d) { return this.transslide(a, b, c, d, { 'direction': 'right' }) }, transslidetop: function (a, b, c, d) { return this.transslide(a, b, c, d, { 'direction': 'top' }) }, transslidebottom: function (a, b, c, d) { return this.transslide(a, b, c, d, { 'direction': 'bottom' }) }, transfountain: function (a, b, c, d) { return this.transbar(a, b, c, d, { 'direction': 'fountain' }) }, transrain: function (a, b, c, d) { return this.transbar(a, b, c, d, { 'direction': 'rain' }) }, transexplode: function (a, b, c, d, e) { e = $.extend(true, { 'mode': 'acumulative', 'effect': 'rain' }, e); this.events.playing = true; c.css({ "opacity": 0 }); b.removeclass(this.options.name + '-selector-current'); d.addclass(this.options.name + '-selector-current'); var f = math.round(this.options.width / this.options.columns); var g = math.round(this.options.height / this.options.rows); var h = []; var i = c.html(); for (irow = 1; irow <= this.options.rows; irow++) { for (icol = 1; icol <= this.options.columns; icol++) { h.push(icol + '' + irow); var j = ((irow * g) - g); var k = ((icol * f) - f); var l = (f * icol) - f; var m = (g * irow) - g; var n = (icol - parseint((this.options.columns + 1) / 2)) * this.options.padding; var o = (irow - parseint((this.options.rows + 1) / 2)) * this.options.padding; var p = $('
'); p.css({ 'overflow': 'hidden', 'position': 'absolute', 'width': f, 'height': g, 'z-index': 2, 'top': j + o, 'left': k + n, 'opacity': 0, 'background-position': '-' + l + 'px -' + m + 'px' }); p.append('
' + i + '
'); this.element.append(p); var p = $('
'); p.css({ 'overflow': 'hidden', 'position': 'absolute', 'width': f, 'height': g, 'z-index': 3, 'top': j, 'left': k, 'opacity': 1, 'background-position': '-' + l + 'px -' + m + 'px' }); p.append('
' + a.html() + '
'); this.element.append(p) } } a.css({ "opacity": 0 }); if (e['effect'] == 'random') { h = this.shuffle(h) } else if (e['effect'] == 'swirl') { h = this.arrayswirl(h) } for (irow = 1; irow <= this.options.rows; irow++) { colrow = irow; for (icol = 1; icol <= this.options.columns; icol++) { delay = this.options.speed * colrow; var n = (icol - parseint((this.options.columns + 1) / 2)) * this.options.padding; var o = (irow - parseint((this.options.rows + 1) / 2)) * this.options.padding; this.element.children('.' + this.options.name + '-block-' + icol + '' + irow).animate({ 'left': '+=' + n, 'top': '+=' + o }, this.options.duration); colrow++ } } var q = delay; var r = 0; for (irow = 1; irow <= this.options.rows; irow++) { colrow = irow; for (icol = 1; icol <= this.options.columns; icol++) { delay = this.options.speed * colrow; this.element.children('.' + this.options.name + '-block-' + h[r]).animate({ 'opacity': 0 }, delay); this.element.children('.' + this.options.name + '-block-clon-' + h[r]).animate({ 'width': f }, this.options.duration).animate({ 'opacity': 1 }, delay).animate({ 'width': f }, q - delay); r++; colrow++ } } for (irow = 1; irow <= this.options.rows; irow++) { colrow = irow; for (icol = 1; icol <= this.options.columns; icol++) { delay = this.options.speed * colrow; var n = (icol - parseint((this.options.columns + 1) / 2)) * this.options.padding; var o = (irow - parseint((this.options.rows + 1) / 2)) * this.options.padding; this.element.children('.' + this.options.name + '-block-clon-' + icol + '' + irow).animate({ 'left': '-=' + n, 'top': '-=' + o }, this.options.duration); colrow++ } } settimeout($.proxy(function () { c.css({ "opacity": 1 }).addclass(this.options.name + '-slide-current'); a.css({ "opacity": 0 }).removeclass(this.options.name + '-slide-current'); this.element.children("." + this.options.name + '-block').remove(); this.element.children("." + this.options.name + '-block-clon').remove(); this.events.playing = false; this.element.trigger("slidertransitionfinishes", c) }, this), (q + (this.options.duration * 2))) }, transexploderandom: function (a, b, c, d) { return this.transexplode(a, b, c, d, { 'effect': 'random' }) } }); $.fn.slideshow = function (a, b) { if (parsefloat($.fn.jquery) > 1.2) { var d = {}; this.each(function () { var s = $(this); d = s.data("slider"); if (!d) { d = new sliderobject(this, a, b); s.data("slider", d) } }); return d } else { throw "the jquery version that was loaded is too old. slider evolution requires jquery 1.3+"; } } })(jquery);