source: pro-violet-viettel/www/deploy/20150304/assets/js/jquery.slides.js @ 804

Last change on this file since 804 was 790, checked in by quyenla, 10 years ago

preview

File size: 18.9 KB
Line 
1/*
2  SlidesJS 3.0.3 http://slidesjs.com
3  (c) 2013 by Nathan Searles http://nathansearles.com
4  Updated: March 15th, 2013
5  Apache License: http://www.apache.org/licenses/LICENSE-2.0
6*/
7(function () {
8    (function (a, b, c) {
9        var d,
10        e,
11        f;
12        return f = 'slidesjs',
13        e = {
14            width: 940,
15            height: 528,
16            start: 1,
17            navigation: {
18                active: !0,
19                effect: 'slide'
20            },
21            pagination: {
22                active: !0,
23                effect: 'slide'
24            },
25            play: {
26                active: !1,
27                effect: 'slide',
28                interval: 5000,
29                auto: !1,
30                swap: !0,
31                pauseOnHover: !1,
32                restartDelay: 2500
33            },
34            effect: {
35                slide: {
36                    speed: 500
37                },
38                fade: {
39                    speed: 300,
40                    crossfade: !0
41                }
42            },
43            callback: {
44                loaded: function () {
45                },
46                start: function () {
47                },
48                complete: function () {
49                }
50            }
51        },
52        d = function () {
53            function b(b, c) {
54                this.element = b,
55                this.options = a.extend(!0, {
56                }, e, c),
57                this._defaults = e,
58                this._name = f,
59                this.init()
60            }
61            return b
62        }(),
63        d.prototype.init = function () {
64            var c,
65            d,
66            e,
67            f,
68            g,
69            h,
70            i = this;
71            return c = a(this.element),
72            this.data = a.data(this),
73            a.data(this, 'animating', !1),
74            a.data(this, 'total', c.children() .not('.slidesjs-navigation', c) .length),
75            a.data(this, 'current', this.options.start - 1),
76            a.data(this, 'vendorPrefix', this._getVendorPrefix()),
77            'undefined' != typeof TouchEvent && (a.data(this, 'touch', !0), this.options.effect.slide.speed = this.options.effect.slide.speed / 2),
78            c.css({
79                overflow: 'hidden'
80            }),
81            c.slidesContainer = c.children() .not('.slidesjs-navigation', c) .wrapAll('<div class=\'slidesjs-container\'>', c) .parent() .css({
82                overflow: 'hidden',
83                position: 'relative'
84            }),
85            a('.slidesjs-container', c) .wrapInner('<div class=\'slidesjs-control\'>', c) .children(),
86            a('.slidesjs-control', c) .css({
87                position: 'relative',
88                left: 0
89            }),
90            a('.slidesjs-control', c) .children() .addClass('slidesjs-slide') .css({
91                position: 'absolute',
92                top: 0,
93                left: 0,
94                width: '100%',
95                zIndex: 0,
96                display: 'none',
97                webkitBackfaceVisibility: 'hidden'
98            }),
99            a.each(a('.slidesjs-control', c) .children(), function (b) {
100                var c;
101                return c = a(this),
102                c.attr('slidesjs-index', b)
103            }),
104            this.data.touch && (a('.slidesjs-control', c) .on('touchstart', function (a) {
105                return i._touchstart(a)
106            }), a('.slidesjs-control', c) .on('touchmove', function (a) {
107                return i._touchmove(a)
108            }), a('.slidesjs-control', c) .on('touchend', function (a) {
109                return i._touchend(a)
110            })),
111            c.fadeIn(0),
112            this.update(),
113            this.data.touch && this._setuptouch(),
114            a('.slidesjs-control', c) .children(':eq(' + this.data.current + ')') .eq(0) .fadeIn(0, function () {
115                return a(this) .css({
116                    zIndex: 10
117                })
118            }),
119            this.options.navigation.active && (g = a('<a>', {
120                'class': 'slidesjs-previous slidesjs-navigation',
121                href: '#',
122                title: 'Previous',
123                text: 'Previous'
124            }) .appendTo(c), d = a('<a>', {
125                'class': 'slidesjs-next slidesjs-navigation',
126                href: '#',
127                title: 'Next',
128                text: 'Next'
129            }) .appendTo(c)),
130            a('.slidesjs-next', c) .click(function (a) {
131                return a.preventDefault(),
132                i.stop(!0),
133                i.next(i.options.navigation.effect)
134            }),
135            a('.slidesjs-previous', c) .click(function (a) {
136                return a.preventDefault(),
137                i.stop(!0),
138                i.previous(i.options.navigation.effect)
139            }),
140            this.options.play.active && (f = a('<a>', {
141                'class': 'slidesjs-play slidesjs-navigation',
142                href: '#',
143                title: 'Play',
144                text: 'Play'
145            }) .appendTo(c), h = a('<a>', {
146                'class': 'slidesjs-stop slidesjs-navigation',
147                href: '#',
148                title: 'Stop',
149                text: 'Stop'
150            }) .appendTo(c), f.click(function (a) {
151                return a.preventDefault(),
152                i.play(!0)
153            }), h.click(function (a) {
154                return a.preventDefault(),
155                i.stop(!0)
156            }), this.options.play.swap && h.css({
157                display: 'none'
158            })),
159            this.options.pagination.active && (e = a('<ul>', {
160                'class': 'slidesjs-pagination'
161            }) .appendTo(c), a.each(Array(this.data.total), function (b) {
162                var c,
163                d;
164                return c = a('<li>', {
165                    'class': 'slidesjs-pagination-item'
166                }) .appendTo(e),
167                d = a('<a>', {
168                    href: '#',
169                    'data-slidesjs-item': b,
170                    html: b + 1
171                }) .appendTo(c),
172                d.click(function (b) {
173                    return b.preventDefault(),
174                    i.stop(!0),
175                    i.goto(1 * a(b.currentTarget) .attr('data-slidesjs-item') + 1)
176                })
177            })),
178            a(b) .bind('resize', function () {
179                return i.update()
180            }),
181            this._setActive(),
182            this.options.play.auto && this.play(),
183            this.options.callback.loaded(this.options.start)
184        },
185        d.prototype._setActive = function (b) {
186            var c,
187            d;
188            return c = a(this.element),
189            this.data = a.data(this),
190            d = b > - 1 ? b : this.data.current,
191            a('.active', c) .removeClass('active'),
192            a('li:eq(' + d + ') a', c) .addClass('active')
193        },
194        d.prototype.update = function () {
195            var b,
196            c,
197            d;
198            return b = a(this.element),
199            this.data = a.data(this),
200            a('.slidesjs-control', b) .children(':not(:eq(' + this.data.current + '))') .css({
201                display: 'none',
202                left: 0,
203                zIndex: 0
204            }),
205            d = b.width(),
206            c = this.options.height / this.options.width * d,
207            this.options.width = d,
208            this.options.height = c,
209            a('.slidesjs-control, .slidesjs-container', b) .css({
210                width: d,
211                height: c
212            })
213        },
214        d.prototype.next = function (b) {
215            var c;
216            return c = a(this.element),
217            this.data = a.data(this),
218            a.data(this, 'direction', 'next'),
219            void 0 === b && (b = this.options.navigation.effect),
220            'fade' === b ? this._fade()  : this._slide()
221        },
222        d.prototype.previous = function (b) {
223            var c;
224            return c = a(this.element),
225            this.data = a.data(this),
226            a.data(this, 'direction', 'previous'),
227            void 0 === b && (b = this.options.navigation.effect),
228            'fade' === b ? this._fade()  : this._slide()
229        },
230        d.prototype.goto = function (b) {
231            var c,
232            d;
233            if (c = a(this.element), this.data = a.data(this), void 0 === d && (d = this.options.pagination.effect), b > this.data.total ? b = this.data.total : 1 > b && (b = 1), 'number' == typeof b) return 'fade' === d ? this._fade(b)  : this._slide(b);
234            if ('string' == typeof b) {
235                if ('first' === b) return 'fade' === d ? this._fade(0)  : this._slide(0);
236                if ('last' === b) return 'fade' === d ? this._fade(this.data.total)  : this._slide(this.data.total)
237            }
238        },
239        d.prototype._setuptouch = function () {
240            var b,
241            c,
242            d,
243            e;
244            return b = a(this.element),
245            this.data = a.data(this),
246            e = a('.slidesjs-control', b),
247            c = this.data.current + 1,
248            d = this.data.current - 1,
249            0 > d && (d = this.data.total - 1),
250            c > this.data.total - 1 && (c = 0),
251            e.children(':eq(' + c + ')') .css({
252                display: 'block',
253                left: this.options.width
254            }),
255            e.children(':eq(' + d + ')') .css({
256                display: 'block',
257                left: - this.options.width
258            })
259        },
260        d.prototype._touchstart = function (b) {
261            var c,
262            d;
263            return c = a(this.element),
264            this.data = a.data(this),
265            d = b.originalEvent.touches[0],
266            this._setuptouch(),
267            a.data(this, 'touchtimer', Number(new Date)),
268            a.data(this, 'touchstartx', d.pageX),
269            a.data(this, 'touchstarty', d.pageY),
270            b.stopPropagation()
271        },
272        d.prototype._touchend = function (b) {
273            var c,
274            d,
275            e,
276            f,
277            g,
278            h,
279            i,
280            j = this;
281            return c = a(this.element),
282            this.data = a.data(this),
283            h = b.originalEvent.touches[0],
284            f = a('.slidesjs-control', c),
285            f.position() .left > 0.5 * this.options.width || f.position() .left > 0.1 * this.options.width && 250 > Number(new Date) - this.data.touchtimer ? (a.data(this, 'direction', 'previous'), this._slide())  : f.position() .left < - (0.5 * this.options.width) || f.position() .left < - (0.1 * this.options.width) && 250 > Number(new Date) - this.data.touchtimer ? (a.data(this, 'direction', 'next'), this._slide())  : (e = this.data.vendorPrefix, i = e + 'Transform', d = e + 'TransitionDuration', g = e + 'TransitionTimingFunction', f[0].style[i] = 'translateX(0px)', f[0].style[d] = 0.85 * this.options.effect.slide.speed + 'ms'),
286            f.on('transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd', function () {
287                return e = j.data.vendorPrefix,
288                i = e + 'Transform',
289                d = e + 'TransitionDuration',
290                g = e + 'TransitionTimingFunction',
291                f[0].style[i] = '',
292                f[0].style[d] = '',
293                f[0].style[g] = ''
294            }),
295            b.stopPropagation()
296        },
297        d.prototype._touchmove = function (b) {
298            var c,
299            d,
300            e,
301            f,
302            g;
303            return c = a(this.element),
304            this.data = a.data(this),
305            f = b.originalEvent.touches[0],
306            d = this.data.vendorPrefix,
307            e = a('.slidesjs-control', c),
308            g = d + 'Transform',
309            a.data(this, 'scrolling', Math.abs(f.pageX - this.data.touchstartx) < Math.abs(f.pageY - this.data.touchstarty)),
310            this.data.animating || this.data.scrolling || (b.preventDefault(), this._setuptouch(), e[0].style[g] = 'translateX(' + (f.pageX - this.data.touchstartx) + 'px)'),
311            b.stopPropagation()
312        },
313        d.prototype.play = function (b) {
314            var c,
315            d,
316            e,
317            f = this;
318            return c = a(this.element),
319            this.data = a.data(this),
320            !this.data.playInterval && (b && (d = this.data.current, this.data.direction = 'next', 'fade' === this.options.play.effect ? this._fade()  : this._slide()), a.data(this, 'playInterval', setInterval(function () {
321                return d = f.data.current,
322                f.data.direction = 'next',
323                'fade' === f.options.play.effect ? f._fade()  : f._slide()
324            }, this.options.play.interval)), e = a('.slidesjs-container', c), this.options.play.pauseOnHover && (e.unbind(), e.bind('mouseenter', function () {
325                return f.stop()
326            }), e.bind('mouseleave', function () {
327                return f.options.play.restartDelay ? a.data(f, 'restartDelay', setTimeout(function () {
328                    return f.play(!0)
329                }, f.options.play.restartDelay))  : f.play()
330            })), a.data(this, 'playing', !0), a('.slidesjs-play', c) .addClass('slidesjs-playing'), this.options.play.swap) ? (a('.slidesjs-play', c) .hide(), a('.slidesjs-stop', c) .show())  : void 0
331        },
332        d.prototype.stop = function (b) {
333            var c;
334            return c = a(this.element),
335            this.data = a.data(this),
336            clearInterval(this.data.playInterval),
337            this.options.play.pauseOnHover && b && a('.slidesjs-container', c) .unbind(),
338            a.data(this, 'playInterval', null),
339            a.data(this, 'playing', !1),
340            a('.slidesjs-play', c) .removeClass('slidesjs-playing'),
341            this.options.play.swap ? (a('.slidesjs-stop', c) .hide(), a('.slidesjs-play', c) .show())  : void 0
342        },
343        d.prototype._slide = function (b) {
344            var c,
345            d,
346            e,
347            f,
348            g,
349            h,
350            i,
351            j,
352            k,
353            l,
354            m = this;
355            return c = a(this.element),
356            this.data = a.data(this),
357            this.data.animating || b === this.data.current + 1 ? void 0 : (a.data(this, 'animating', !0), d = this.data.current, b > - 1 ? (b -= 1, l = b > d ? 1 : - 1, e = b > d ? - this.options.width : this.options.width, g = b)  : (l = 'next' === this.data.direction ? 1 : - 1, e = 'next' === this.data.direction ? - this.options.width : this.options.width, g = d + l), - 1 === g && (g = this.data.total - 1), g === this.data.total && (g = 0), this._setActive(g), i = a('.slidesjs-control', c), b > - 1 && i.children(':not(:eq(' + d + '))') .css({
358                display: 'none',
359                left: 0,
360                zIndex: 0
361            }), i.children(':eq(' + g + ')') .css({
362                display: 'block',
363                left: l * this.options.width,
364                zIndex: 10
365            }), this.options.callback.start(d + 1), this.data.vendorPrefix ? (h = this.data.vendorPrefix, k = h + 'Transform', f = h + 'TransitionDuration', j = h + 'TransitionTimingFunction', i[0].style[k] = 'translateX(' + e + 'px)', i[0].style[f] = this.options.effect.slide.speed + 'ms', i.on('transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd', function () {
366                return i[0].style[k] = '',
367                i[0].style[f] = '',
368                i.children(':eq(' + g + ')') .css({
369                    left: 0
370                }),
371                i.children(':eq(' + d + ')') .css({
372                    display: 'none',
373                    left: 0,
374                    zIndex: 0
375                }),
376                a.data(m, 'current', g),
377                a.data(m, 'animating', !1),
378                i.unbind('transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd'),
379                i.children(':not(:eq(' + g + '))') .css({
380                    display: 'none',
381                    left: 0,
382                    zIndex: 0
383                }),
384                m.data.touch && m._setuptouch(),
385                m.options.callback.complete(g + 1)
386            }))  : i.stop() .animate({
387                left: e
388            }, this.options.effect.slide.speed, function () {
389                return i.css({
390                    left: 0
391                }),
392                i.children(':eq(' + g + ')') .css({
393                    left: 0
394                }),
395                i.children(':eq(' + d + ')') .css({
396                    display: 'none',
397                    left: 0,
398                    zIndex: 0
399                }, a.data(m, 'current', g), a.data(m, 'animating', !1), m.options.callback.complete(g + 1))
400            }))
401        },
402        d.prototype._fade = function (b) {
403            var c,
404            d,
405            e,
406            f,
407            g,
408            h = this;
409            return c = a(this.element),
410            this.data = a.data(this),
411            this.data.animating || b === this.data.current + 1 ? void 0 : (a.data(this, 'animating', !0), d = this.data.current, b ? (b -= 1, g = b > d ? 1 : - 1, e = b)  : (g = 'next' === this.data.direction ? 1 : - 1, e = d + g), - 1 === e && (e = this.data.total - 1), e === this.data.total && (e = 0), this._setActive(e), f = a('.slidesjs-control', c), f.children(':eq(' + e + ')') .css({
412                display: 'none',
413                left: 0,
414                zIndex: 10
415            }), this.options.callback.start(d + 1), this.options.effect.fade.crossfade ? (f.children(':eq(' + this.data.current + ')') .stop() .fadeOut(this.options.effect.fade.speed), f.children(':eq(' + e + ')') .stop() .fadeIn(this.options.effect.fade.speed, function () {
416                return f.children(':eq(' + e + ')') .css({
417                    zIndex: 0
418                }),
419                a.data(h, 'animating', !1),
420                a.data(h, 'current', e),
421                h.options.callback.complete(e + 1)
422            }))  : f.children(':eq(' + d + ')') .stop() .fadeOut(this.options.effect.fade.speed, function () {
423                return f.children(':eq(' + e + ')') .stop() .fadeIn(h.options.effect.fade.speed, function () {
424                    return f.children(':eq(' + e + ')') .css({
425                        zIndex: 10
426                    })
427                }),
428                a.data(h, 'animating', !1),
429                a.data(h, 'current', e),
430                h.options.callback.complete(e + 1)
431            }))
432        },
433        d.prototype._getVendorPrefix = function () {
434            var a,
435            b,
436            d,
437            e,
438            f;
439            for (a = c.body || c.documentElement, d = a.style, e = 'transition', f = [
440                'Moz',
441                'Webkit',
442                'Khtml',
443                'O',
444                'ms'
445            ], e = e.charAt(0) .toUpperCase() + e.substr(1), b = 0; f.length > b; ) {
446                if ('string' == typeof d[f[b] + e]) return f[b];
447                b++
448            }
449            return !1
450        },
451        a.fn[f] = function (b) {
452            return this.each(function () {
453                return a.data(this, 'plugin_' + f) ? void 0 : a.data(this, 'plugin_' + f, new d(this, b))
454            })
455        }
456    }) (jQuery, window, document)
457}) .call(this);
Note: See TracBrowser for help on using the repository browser.