PageSourceSearch

https://www.ctu.edu.vn/media/nextend/smartslider-frontend/smartslider-frontend.js?1636823641

js ctu.edu.vn collected 2026-09-24 09:02:39 UTC 200,482 bytes, 5,187 lines download raw bytes

1(function ($, scope, undefined) {
2    function NextendSmartSliderBackgroundImages(slider) {
3        this.device = null;
4
5        this.load = $.Deferred();
6
7        this.slider = slider;
8        this.slides = this.slider.realSlides;
9
10        this.lazyLoad = slider.parameters.lazyLoad;
11        this.lazyLoadNeighbor = slider.parameters.lazyLoadNeighbor;
12
13        this.deviceDeferred = $.Deferred();
14
15        /**
16         * @type {NextendSmartSliderBackgroundImage[]}
17         */
18        this.backgroundImages = [];
19        for (var i = 0; i < this.slides.length; i++) {
20            var image = this.slides.eq(i).find('.n2-ss-slide-background');
21            if (image.length > 0) {
22                this.backgroundImages[i] = new NextendSmartSliderBackgroundImage(i, image, this);
23            } else {
24                this.backgroundImages[i] = false;
25            }
26            this.slides.eq(i).data('slideBackground', this.backgroundImages[i]);
27        }
28
29        this.slider.sliderElement.one('SliderDevice', $.proxy(this.onSlideDeviceChangedFirst, this));
30
31    };
32
33    NextendSmartSliderBackgroundImages.prototype.getBackgroundImages = function () {
34        return this.backgroundImages;
35    };
36
37    NextendSmartSliderBackgroundImages.prototype.onSlideDeviceChangedFirst = function (e, device) {
38        this.onSlideDeviceChanged(e, device);
39        this.deviceDeferred.resolve();
40        this.slider.sliderElement.on('SliderDevice', $.proxy(this.onSlideDeviceChanged, this));
41
42        if (this.lazyLoad == 1) {
43            this.preLoad = this.preLoadLazyNeighbor;
44
45            this.load = $.when(this.preLoad(this.slider.currentSlideIndex));
46        } else if (this.lazyLoad == 2) { // delayed
47            $(window).load($.proxy(this.preLoadAll, this));
48
49            this.load = $.when(this.preLoad(this.slider.currentSlideIndex));
50        } else {
51            this.load = $.when.apply($, this.preLoadAll());
52        }
53    };
54
55    NextendSmartSliderBackgroundImages.prototype.onSlideDeviceChanged = function (e, device) {
56        this.device = device;
57        for (var i = 0; i < this.backgroundImages.length; i++) {
58            if (this.backgroundImages[i]) {
59                this.backgroundImages[i].onSlideDeviceChanged(device);
60            }
61        }
62    };
63
64    NextendSmartSliderBackgroundImages.prototype.changed = function (i) {
65        if (this.lazyLoad == 1 || this.lazyLoad == 2) {
66            if (i == this.slider.currentSlideIndex) {
67                this.preLoad(i);
68            }
69        } else {
70            this.preLoad(i);
71        }
72    };
73
74    NextendSmartSliderBackgroundImages.prototype.preLoadCurrent = function () {
75        this.preLoad(this.slider.currentSlideIndex);
76    };
77
78    NextendSmartSliderBackgroundImages.prototype.preLoadAll = function () {
79        var deferreds = [];
80        for (var i = 0; i < this.backgroundImages.length; i++) {
81            deferreds.push(this._preLoad(i));
82        }
83        return deferreds;
84    };
85
86    NextendSmartSliderBackgroundImages.prototype.preLoad = function (i) {
87        return this._preLoad(i);
88    };
89
90    NextendSmartSliderBackgroundImages.prototype.preLoadLazyNeighbor = function (i) {
91
92        var lazyLoadNeighbor = this.lazyLoadNeighbor,
93            deferreds = [this._preLoad(i)];
94
95        if (lazyLoadNeighbor) {
96            var j = 0,
97                k = i;
98            while (j < lazyLoadNeighbor) {
99                k--;
100                if (k < 0) {
101                    k = this.backgroundImages.length - 1;
102                }
103                deferreds.push(this._preLoad(k));
104                j++;
105            }
106            j = 0;
107            k = i;
108            while (j < lazyLoadNeighbor) {
109                k++;
110                if (k >= this.backgroundImages.length) {
111                    k = 0;
112                }
113                deferreds.push(this._preLoad(k));
114                j++;
115            }
116        }
117        this.slider.load.showSpinner('backgroundImage' + i);
118        return $.when.apply($, deferreds).done($.proxy(function () {
119            this.slider.load.removeSpinner('backgroundImage' + i);
120        }, this));
121    };
122
123    NextendSmartSliderBackgroundImages.prototype._preLoad = function (i) {
124        if (this.backgroundImages[i]) {
125            return this.backgroundImages[i].preLoad();
126        } else {
127            return true
128        }
129    };
130
131    NextendSmartSliderBackgroundImages.prototype.hack = function () {
132        for (var i = 0; i < this.backgroundImages.length; i++) {
133            if (this.backgroundImages[i]) {
134                this.backgroundImages[i].hack();
135            }
136        }
137    };
138
139    scope.NextendSmartSliderBackgroundImages = NextendSmartSliderBackgroundImages;
140
141    function NextendSmartSliderBackgroundImage(i, element, manager) {
142        this.responsiveElement = false;
143        this.loadStarted = false;
144
145        this.i = i;
146        this.element = element;
147        this.manager = manager;
148        this.loadDeferred = $.Deferred();
149
150        var image = element.find('.n2-ss-slide-background-image');
151        this.image = image;
152        if (image.hasClass('n2-ss-slide-simple')) {
153            this.mode = 'simple';
154            this.currentSrc = image.attr('src');
155        } else if (image.hasClass('n2-ss-slide-fill')) {
156            this.mode = 'fill';
157            this.currentSrc = image.attr('src');
158        } else if (image.hasClass('n2-ss-slide-fit')) {
159            this.mode = 'fit';
160            this.currentSrc = image.attr('src');
161        } else if (image.hasClass('n2-ss-slide-stretch')) {
162            this.mode = 'stretch';
163            this.currentSrc = image.attr('src');
164        } else if (image.hasClass('n2-ss-slide-center')) {
165            this.mode = 'center';
166            var matches = image.css('backgroundImage').match(/url\(["]*([^)"]+)["]*\)/i);
167            if (matches.length > 0) {
168                this.currentSrc = matches[1];
169            }
170        } else if (image.hasClass('n2-ss-slide-tile')) {
171            this.mode = 'tile';
172            var matches = image.css('backgroundImage').match(/url\(["]*([^)"]+)["]*\)/i);
173            if (matches.length > 0) {
174                this.currentSrc = matches[1];
175            }
176        } else {
177            this.mode = 'fill';
178            this.currentSrc = '';
179        }
180
181        this.hash = element.data('hash');
182        this.desktopSrc = element.data('desktop');
183        this.tabletSrc = element.data('tablet');
184        this.mobileSrc = element.data('mobile');
185        var opacity = element.data('opacity');
186        if (opacity >= 0 && opacity < 1) {
187            this.opacity = opacity;
188        }
189
190        if (manager.slider.isAdmin) {
191            this._change = this.change;
192            this.change = this.changeAdmin;
193        }
194
195        this.listenImageManager();
196
197    };
198
199    NextendSmartSliderBackgroundImage.prototype.fixNatural = function (DOMelement) {
200        var img = new Image();
201        img.src = DOMelement.src;
202        DOMelement.naturalWidth = img.width;
203        DOMelement.naturalHeight = img.height;
204    };
205
206    NextendSmartSliderBackgroundImage.prototype.preLoad = function () {
207        if (this.loadDeferred.state() == 'pending') {
208            this.loadStarted = true;
209            this.manager.deviceDeferred.done($.proxy(function () {
210                this.onSlideDeviceChanged(this.manager.device);
211                this.element.imagesLoaded($.proxy(function () {
212                    this.isLoaded = true;
213                    var imageNode = this.image[0];
214                    if (imageNode.tagName == 'IMG' && typeof imageNode.naturalWidth === 'undefined') {
215                        this.fixNatural(imageNode);
216                    }
217                    this.loadDeferred.resolve(this.element);
218                }, this));
219            }, this));
220        }
221        return this.loadDeferred;
222    };
223
224    NextendSmartSliderBackgroundImage.prototype.afterLoaded = function () {
225        return $.when(this.loadDeferred, this.manager.slider.responsive.ready);
226    };
227
228    NextendSmartSliderBackgroundImage.prototype.onSlideDeviceChanged = function (device) {
229        var newSrc = this.desktopSrc;
230        if (device.device == 'mobile') {
231            if (this.mobileSrc) {
232                newSrc = this.mobileSrc;
233            } else if (this.tabletSrc) {
234                newSrc = this.tabletSrc;
235            }
236        } else if (device.device == 'tablet') {
237            if (this.tabletSrc) {
238                newSrc = this.tabletSrc;
239            }
240        }
241        this.change(newSrc, '', this.mode);
242    };
243
244    /**
245     * @param {NextendSmartSliderResponsiveElementBackgroundImage} responsiveElement
246     */
247    NextendSmartSliderBackgroundImage.prototype.addResponsiveElement = function (responsiveElement) {
248        this.responsiveElement = responsiveElement;
249    };
250
251    NextendSmartSliderBackgroundImage.prototype.listenImageManager = function () {
252        if (this.hash != '') {
253            $(window).on(this.hash, $.proxy(this.onImageManagerChanged, this));
254        }
255    };
256
257    NextendSmartSliderBackgroundImage.prototype.notListenImageManager = function () {
258        if (this.hash != '') {
259            $(window).off(this.hash, null, $.proxy(this.onImageManagerChanged, this));
260        }
261    };
262
263    NextendSmartSliderBackgroundImage.prototype.onImageManagerChanged = function (e, imageData) {
264        this.tabletSrc = imageData.tablet.image;
265        this.mobileSrc = imageData.mobile.image;
266        if (this.manager.device.device == 'tablet' || this.manager.device.device == 'mobile') {
267            this.onSlideDeviceChanged(this.manager.device);
268        }
269    };
270
271    NextendSmartSliderBackgroundImage.prototype.changeDesktop = function (src, alt, newMode) {
272        this.notListenImageManager();
273        this.desktopSrc = src;
274        this.hash = md5(src);
275        this.change(src, alt, newMode);
276
277        if (src != '') {
278            var img = new Image();
279            img.addEventListener("load", $.proxy(function () {
280                $.when(nextend.imageManager.getVisual(src))
281                    .done($.proxy(function (visual) {
282                        this.onImageManagerChanged(null, visual.value);
283                        this.listenImageManager();
284                    }, this));
285            }, this), false);
286            img.src = nextend.imageHelper.fixed(src);
287        } else {
288            this.tabletSrc = '';
289            this.mobileSrc = '';
290        }
291    };
292
293    NextendSmartSliderBackgroundImage.prototype.changeAdmin = function (src, alt, newMode) {
294        if (this.manager.slider.parameters.dynamicHeight) {
295            newMode = 'simple';
296        }
297        this._change(nextend.imageHelper.fixed(src), alt, newMode);
298    };
299
300    NextendSmartSliderBackgroundImage.prototype.change = function (src, alt, newMode) {
301        if (this.currentSrc != src || this.mode != newMode) {
302            if (this.loadStarted) {
303                n2c.log('Slide background changed: ', src);
304                var node = null;
305                switch (newMode) {
306                    case 'simple':
307                        node = $('<img src="' + src + '" class="n2-ss-slide-background-image n2-ss-slide-simple" />');
308                        break;
309                    case 'fill':
310                        node = $('<img src="' + src + '" class="n2-ss-slide-background-image n2-ss-slide-fill" />');
311                        this.responsiveElement.setCentered();
312                        break;
313                    case 'fit':
314                        node = $('<img src="' + src + '" class="n2-ss-slide-background-image n2-ss-slide-fit" />');
315                        this.responsiveElement.setCentered();
316                        break;
317                    case 'stretch':
318                        node = $('<img src="' + src + '" class="n2-ss-slide-background-image n2-ss-slide-stretch" />');
319                        this.responsiveElement.unsetCentered();
320                        break;
321                    case 'center':
322                        node = $('<div style="background-image: url(\'' + src + '\');" class="n2-ss-slide-background-image n2-ss-slide-center"></div>');
323                        this.responsiveElement.unsetCentered();
324                        break;
325                    case 'tile':
326                        node = $('<div style="background-image: url(\'' + src + '\');" class="n2-ss-slide-background-image n2-ss-slide-tile"></div>');
327                        this.responsiveElement.unsetCentered();
328                        break;
329                }
330                if (src == '') {
331                    node.css('display', 'none');
332                }
333                node.css('opacity', this.opacity);
334                this.image
335                    .replaceWith(node)
336                    .remove();
337                this.responsiveElement.element = this.image = node;
338                this.currentSrc = src;
339                this.mode = newMode;
340
341                if (this.loadDeferred.state() == 'pending') {
342                    this.loadDeferred.resolve();
343                }
344                this.loadDeferred = $.Deferred();
345                this.manager.changed(this.i);
346
347                switch (newMode) {
348                    case 'fill':
349                    case 'fit':
350                        this.afterLoaded().done($.proxy(function () {
351                            this.responsiveElement.afterLoaded();
352                            this.responsiveElement.refreshRatio();
353                            this.responsiveElement._refreshResize();
354                        }, this));
355                        break;
356                    case 'stretch':
357                    case 'center':
358                    case 'tile':
359                    case 'simple':
360                        this.responsiveElement._refreshResize();
361                        break;
362                }
363            }
364        }
365    };
366
367    NextendSmartSliderBackgroundImage.prototype.setOpacity = function (opacity) {
368        this.opacity = opacity;
369        this.image.css('opacity', opacity);
370    };
371
372    NextendSmartSliderBackgroundImage.prototype.hack = function () {
373        NextendTween.set(this.element, {
374            rotation: 0.0001
375        });
376    };
377
378    scope.NextendSmartSliderBackgroundImage = NextendSmartSliderBackgroundImage;
379
380})(n2, window);
381(function ($, scope, undefined) {
382
383    function NextendSmartSliderLoad(smartSlider, parameters) {
384        this.smartSlider = smartSlider;
385        this.spinnerKey = '';
386
387        this.id = smartSlider.sliderElement.attr('id');
388
389        this.parameters = $.extend({
390            fade: 1,
391            scroll: 0,
392            spinner: ''
393        }, parameters);
394
395        this.spinner = $(this.parameters.spinner);
396
397        this.deferred = $.Deferred();
398    };
399
400
401    NextendSmartSliderLoad.prototype.start = function () {
402        if (this.parameters.scroll) {
403
404            var $window = $(window);
405            $window.on('scroll.' + this.id, $.proxy(this.onScroll, this));
406            this.onScroll();
407
408        } else if (this.parameters.fade) {
409            this.loadingArea = $('#' + this.id + '-placeholder').eq(0);
410            this.showSpinner('fadePlaceholder');
411            n2c.log('Fade on load - start wait');
412
413            $.when(this.smartSlider.responsive.ready, this.smartSlider.backgroundImages.load).done($.proxy(this.showSlider, this));
414
415        } else {
416            this.smartSlider.responsive.ready.done($.proxy(function () {
417                this.showSlider();
418            }, this));
419        }
420    };
421
422    NextendSmartSliderLoad.prototype.onScroll = function () {
423        var $window = $(window);
424        if (($window.scrollTop() + $window.height() > (this.smartSlider.sliderElement.offset().top + 100))) {
425
426            n2c.log('Fade on scroll - reached');
427
428            $.when(this.smartSlider.responsive.ready, this.smartSlider.backgroundImages.load).done($.proxy(this.showSlider, this));
429            $window.off('scroll.' + this.id);
430        }
431    };
432
433    NextendSmartSliderLoad.prototype.showSlider = function () {
434        n2c.log('Images loaded');
435
436        $.when.apply($, this.smartSlider.widgetDeferreds).done($.proxy(function () {
437            n2c.log('Event: BeforeVisible');
438            this.smartSlider.responsive.doResize();
439            this.smartSlider.sliderElement.trigger('BeforeVisible');
440
441            n2c.log('Fade start');
442            this.smartSlider.sliderElement.addClass('n2-ss-loaded');
443
444            this.removeSpinner('fadePlaceholder');
445            $('#' + this.id + '-placeholder').remove();
446            this.loadingArea = this.smartSlider.sliderElement;
447
448            this.deferred.resolve();
449        }, this));
450    };
451
452    NextendSmartSliderLoad.prototype.loaded = function (fn) {
453        this.deferred.done(fn);
454    },
455
456        NextendSmartSliderLoad.prototype.showSpinner = function (spinner
456Key) {
457            this.spinnerKey = spinnerKey;
458            this.spinner.appendTo(this.loadingArea);
459        };
460
461    NextendSmartSliderLoad.prototype.removeSpinner = function (spinnerKey) {
462        if (this.spinnerKey == spinnerKey) {
463            this.spinner.detach();
464            this.spinnerKey = '';
465        }
466    };
467
468    scope.NextendSmartSliderLoad = NextendSmartSliderLoad;
469
470})(n2, window);
471(function ($, scope, undefined) {
472    function NextendSmartSlider() {
473        this.sliders = {};
474        this.readys = {};
475
476        this._resetCounters = [];
477    }
478
479    NextendSmartSlider.prototype.makeReady = function (id, slider) {
480        this.sliders[id] = slider;
481        if (typeof this.readys[id] !== 'undefined') {
482            for (var i = 0; i < this.readys[id].length; i++) {
483                this.readys[id][i].call(slider, slider, slider.sliderElement);
484            }
485        }
486    };
487
488    NextendSmartSlider.prototype.ready = function (id, callback) {
489        if (typeof this.sliders[id] !== 'undefined') {
490            callback.call(this.sliders[id], this.sliders[id], this.sliders[id].sliderElement);
491        } else {
492            if (typeof this.readys[id] == 'undefined') {
493                this.readys[id] = [];
494            }
495            this.readys[id].push(callback);
496        }
497    };
498
499    NextendSmartSlider.prototype.trigger = function (el, event) {
500        var $el = n2(el),
501            split = event.split(','),
502            slide = $el.closest('.n2-ss-slide,.n2-ss-static-slide');
503
504        if (split.length > 1) {
505            if ($.inArray(el, this._resetCounters) == -1) {
506                this._resetCounters.push(el);
507
508                slide.on('layerAnimationSetStart.resetCounter', function () {
509                    $el.data('eventCounter', 0);
510                });
511            }
512            var counter = $el.data('eventCounter') || 0
513            event = split[counter];
514            counter++;
515            if (counter > split.length - 1) {
516                counter = 0;
517            }
518            $el.data('eventCounter', counter);
519        }
520        slide.triggerHandler(event);
521    };
522
523    NextendSmartSlider.prototype.applyAction = function (el, action) {
524        var ss = n2(el).closest('.n2-ss-slider').data('ss');
525        ss[action].apply(ss, Array.prototype.slice.call(arguments, 2));
526    };
527
528    window.n2ss = new NextendSmartSlider();
529})(n2, window);
530(function ($, scope, undefined) {
531
532    function NextendSmartSliderAbstract(sliderElement, parameters) {
533        this.startedDeferred = $.Deferred();
534
535        var id = sliderElement.attr('id');
536        if (window[id] && window[id] instanceof NextendSmartSliderAbstract) {
537            return false;
538        }
539        // Register our object to a global variable
540        window[id] = this;
541
542        // Store them as we might need to change them back
543        this.nextCarousel = this.next;
544        this.previousCarousel = this.previous;
545
546        if (sliderElement.prop('tagName') == 'SCRIPT') {
547            var dependency = sliderElement.data('dependency'),
548                rocketLoad = $.proxy(function () {
549                    var rocketSlider = $(sliderElement.html().replace(/<_s_c_r_i_p_t/g, '<script').replace(/<_\/_s_c_r_i_p_t/g, '</script'));
550                    sliderElement.replaceWith(rocketSlider);
551                    this.postInit(id, $('#' + id), parameters);
552                    $(window).triggerHandler('n2Rocket', [this.sliderElement]);
553                }, this);
554            if ($('#n2-ss-' + dependency).length) {
555                n2ss.ready(dependency, $.proxy(function (slider) {
556                    slider.ready(rocketLoad);
557                }, this));
558            } else {
559                rocketLoad();
560            }
561        } else {
562            this.postInit(id, sliderElement, parameters);
563        }
564    }
565
566    NextendSmartSliderAbstract.prototype.postInit = function (id, sliderElement, parameters) {
567        this.killed = false;
568        this.isAdmin = false;
569        this.currentSlideIndex = 0;
570        this.responsive = false;
571        this.layerMode = true;
572        this._lastChangeTime = 0;
573        n2c.log('Slider init: ', id);
574        this.id = parseInt(id.replace('n2-ss-', ''));
575
576        this.sliderElement = sliderElement.data('ss', this);
577        this.readyDeferred = $.Deferred();
578
579        this.parameters = $.extend({
580            admin: false,
581            playWhenVisible: 1,
582            isStaticEdited: false,
583            callbacks: '',
584            autoplay: {},
585            blockrightclick: false,
586            maintainSession: 0,
587            controls: {
588                drag: false,
589                touch: 'horizontal',
590                keyboard: false,
591                scroll: false,
592                tilt: false
593            },
594            hardwareAcceleration: true,
595            layerMode: {
596                playOnce: 0,
597                playFirstLayer: 1,
598                mode: 'skippable',
599                inAnimation: 'mainInEnd'
600            },
601            parallax: {
602                enabled: 0,
603                mobile: 0,
604                horizontal: 'mouse',
605                vertical: 'mouse',
606                origin: 'enter'
607            },
608            load: {},
609            mainanimation: {},
610            randomize: {},
611            responsive: {},
612            lazyload: {
613                enabled: 0
614            },
615            postBackgroundAnimations: false,
616            initCallbacks: [],
617            dynamicHeight: 0
618        }, parameters);
619
620        try {
621            eval(this.parameters.callbacks);
622        } catch (e) {
623            console.error(e);
624        }
625
626        this.startVisibilityCheck();
627        n2ss.makeReady(this.id, this);
628
629
630        this.widgetDeferreds = [];
631        this.sliderElement.on('addWidget', $.proxy(this.addWidget, this));
632
633        this.isAdmin = !!this.parameters.admin;
634        if (this.isAdmin) {
635            this.changeTo = function () {
636            };
637        }
638
639        this.load = new NextendSmartSliderLoad(this, this.parameters.load);
640
641        this.findSlides();
642
643        this.currentSlideIndex = this.__getActiveSlideIndex();
644
645        var forceActiveSlideIndex = typeof window['ss' + this.id] !== 'undefined' ? parseInt(window['ss' + this.id]) : null;
646        if (forceActiveSlideIndex !== null) {
647            this.changeActiveBeforeLoad(forceActiveSlideIndex);
648        }
649
650        if (!this.isAdmin && this.parameters.maintainSession && typeof sessionStorage !== 'undefined') {
651            var sessionIndex = parseInt(sessionStorage.getItem('ss-' + this.id));
652            if (forceActiveSlideIndex === null && sessionIndex !== null) {
653                this.changeActiveBeforeLoad(sessionIndex);
654            }
655            this.sliderElement.on('mainAnimationComplete', $.proxy(function (e, animation, previous, next) {
656                sessionStorage.setItem('ss-' + this.id, next);
657            }, this));
658        }
659
660        this.backgroundImages = new NextendSmartSliderBackgroundImages(this);
661
662        n2c.log('First slide index: ', this.currentSlideIndex);
663
664        for (var i = 0; i < this.parameters.initCallbacks.length; i++) {
665            (new Function(this.parameters.initCallbacks[i]))(this);
666        }
667
668        this.initSlides();
669
670        this.widgets = new NextendSmartSliderWidgets(this);
671
672        this.sliderElement.on('universalenter', $.proxy(function () {
673            this.sliderElement.addClass('n2-hover');
674        }, this)).on('universalleave', $.proxy(function (e) {
675            e.stopPropagation();
676            this.sliderElement.removeClass('n2-hover');
677        }, this));
678
679
680        this.controls = {};
681
682        if (this.layerMode) {
683            this.initMainAnimationWithLayerAnimation();
684        }
685
686        if (this.parameters.blockrightclick) {
687            this.sliderElement.bind("contextmenu", function (e) {
688                e.preventDefault();
689            });
690        }
691
692        this.initMainAnimation();
693        this.initResponsiveMode();
694
695        if (this.killed) {
696            return;
697        }
698
699        this.initControls();
700
701        this.startedDeferred.resolve(this);
702
703        if (!this.isAdmin) {
704            var event = 'click';
705            if (this.parameters.controls.touch != '0' && this.parameters.controls.touch) {
706                event = 'n2click';
707            }
708            this.sliderElement.find('[n2click]').each(function (i, el) {
709                var el = $(el);
710                el.on(event, function () {
711                    eval(el.attr('n2click'));
712                });
713            });
714
715            this.sliderElement.find('[data-click]').each(function (i, el) {
716                var el = $(el).on('click', function () {
717                    eval(el.data('click'));
718                }).css('cursor', 'pointer');
719            });
720
721            this.sliderElement.find('[data-mouseenter]').each(function (i, el) {
722                var el = $(el).on('mouseenter', function () {
723                    eval(el.data('mouseenter'));
724                });
725            });
726
727            this.sliderElement.find('[data-mouseleave]').each(function (i, el) {
728                var el = $(el).on('mouseleave', function () {
729                    eval(el.data('mouseleave'));
730                });
731            });
732
733            this.sliderElement.find('[data-play]').each(function (i, el) {
734                var el = $(el).on('n2play', function () {
735                    eval(el.data('play'));
736                });
737            });
738
739            this.sliderElement.find('[data-pause]').each(function (i, el) {
740                var el = $(el).on('n2pause', function () {
741                    eval(el.data('pause'));
742                });
743            });
744
745            this.sliderElement.find('[data-stop]').each(function (i, el) {
746                var el = $(el).on('n2stop', function () {
747                    eval(el.data('stop'));
748                });
749            });
750
751            var preventFocus = false;
752            this.slides.find('a').on('mousedown', function (e) {
753                preventFocus = true;
754                setTimeout(function () {
755                    preventFocus = false;
756                }, 100);
757            });
758
759            this.slides.find('a').on('focus', $.proxy(function (e) {
760                if (!preventFocus) {
761                    var slideIndex = this.findSlideIndexByElement(e.currentTarget);
762                    if (slideIndex != -1 && slideIndex != this.currentSlideIndex) {
763                        this.changeTo(slideIndex, false, false);
764                    }
765                }
766            }, this));
767        }
768
769        this.preReadyResolve();
770
771        this.initCarousel();
772    };
773
774    NextendSmartSliderAbstract.prototype.initSlides = function () {
775        if (this.layerMode) {
776            if (this.isAdmin && this.type != 'showcase') {
777                new NextendSmartSliderSlide(this, this.slides.eq(this.currentSlideIndex), 1);
778            } else {
779                for (var i = 0; i < this.slides.length; i++) {
780                    new NextendSmartSliderSlide(this, this.slides.eq(i), this.currentSlideIndex == i);
781                }
782            }
783
784            var staticSlide = this.findStaticSlide();
785            if (staticSlide.length) {
786                new NextendSmartSliderSlide(this, staticSlide, true, true);
787            }
788        }
789    };
790
791    NextendSmartSliderAbstract.prototype.getRealIndex = function (index) {
792        return index;
793    };
794
795    NextendSmartSliderAbstract.prototype.changeActiveBeforeLoad = function (index) {
796        if (index > 0 && index < this.slides.length && this.currentSlideIndex != index) {
797            this.unsetActiveSlide(this.slides.eq(this.currentSlideIndex));
798            this.setActiveSlide(this.slides.eq(index));
799            this.currentSlideIndex = index;
800            this.ready($.proxy(function () {
801                this.sliderElement.trigger('sliderSwitchTo', [index, this.getRealIndex(index)]);
802            }, this));
803        }
804    };
805
806    NextendSmartSliderAbstract.prototype.kill = function () {
807        this.killed = true;
808        $('#' + this.sliderElement.attr('id') + '-placeholder').remove();
809        this.sliderElement.closest('.n2-ss-align').remove();
810    };
811
812    NextendSmartSliderAbstract.prototype.findSlides = function () {
813
814        this.realSlides = this.slides = this.sliderElement.find('.n2-ss-slide');
815    };
816
817    NextendSmartSliderAbstract.prototype.findStaticSlide = function () {
818        return this.sliderElement.find('.n2-ss-static-slide');
819    };
820
821    NextendSmartSliderAbstract.prototype.addWidget = function (e, deferred) {
822        this.widgetDeferreds.push(deferred);
823    };
824
825    NextendSmartSliderAbstract.prototype.started = function (fn) {
826        this.startedDeferred.done($.proxy(fn, this));
827    };
828
829    NextendSmartSliderAbstract.prototype.preReadyResolve = function () {
830        // Hack to allow time to widgets to register
831        setTimeout($.proxy(this._preReadyResolve, this), 1);
832    };
833
834    NextendSmartSliderAbstract.prototype._preReadyResolve = function () {
835
836        this.load.start();
837        this.load.loaded($.proxy(this.readyResolve, this));
838    };
839
840    NextendSmartSliderAbstract.prototype.readyResolve = function () {
841        n2c.log('Slider ready');
842        $(window).scroll(); // To force other sliders to recalculate the scroll position
843
844        this.readyDeferred.resolve();
845    };
846
847    NextendSmartSliderAbstract.prototype.ready = function (fn) {
848        this.readyDeferred.done($.proxy(fn, this));
849    };
850
851    NextendSmartSliderAbstract.prototype.startVisibilityCheck = function () {
852        this.visibleDeferred = $.Deferred();
853        if (this.parameters.playWhenVisible) {
854            this.ready($.proxy(function () {
855                $(window).on('scroll.n2-ss-visible' + this.id + ' resize.n2-ss-visible' + this.id, $.proxy(this.checkIfVisible, this));
856                this.checkIfVisible();
857            }, this));
858        } else {
859            this.ready($.proxy(function () {
860                this.visibleDeferred.resolve();
861            }, this));
862        }
863    };
864
865    NextendSmartSliderAbstract.prototype.checkIfVisible = function () {
866        var TopView = $(window).scrollTop(),
867            BotView = TopView + $(window).height(),
868            middlePoint = this.sliderElement.offset().top + this.sliderElement.height() / 2;
869        if (TopView <= middlePoint && BotView >= middlePoint) {
870            $(window).off('scroll.n2-ss-visible' + this.id + ' resize.n2-ss-visible' + this.id, $.proxy(this.checkIfVisible, this));
871            this.visibleDeferred.resolve();
872        }
873    };
874
875    NextendSmartSliderAbstract.prototype.visible = function (fn) {
876        this.visibleDeferred.done($.proxy(fn, this));
877    };
878
879    NextendSmartSliderAbstract.prototype.isPlaying = function () {
880        if (this.mainAnimation.getState() != 'ended') {
881            return true;
882        }
883        return false;
884    };
885
886    NextendSmartSliderAbstract.prototype.focus = function (isSystem) {
887        var deferred = $.Deferred();
888        if (typeof isSystem == 'undefined') {
889            isSystem = 0;
890        }
891        if (this.responsive.parameters.focusUser && !isSystem || this.responsive.parameters.focusAutoplay && isSystem) {
892            var top = this.sliderElement.offset().top - this.responsive.verticalOffsetSelectors.height();
893            if ($(window).scrollTop() != top) {
894                $("html, body").animate({scrollTop: top}, 400, $.proxy(function () {
895                    deferred.resolve();
896                }, this));
897            } else {
898                deferred.resolve();
899            }
900        } else {
901            deferred.resolve();
902        }
903        return deferred;
904    };
905
906    NextendSmartSliderAbstract.prototype.initCarousel = function () {
907        if (!parseInt(this.parameters.carousel)) {
908            // Replace the methods
909            this.next = this.nextNotCarousel;
910            this.previous = this.previousNotCarousel;
911
912            var slides = this.slides.length;
913            var previousArrowOpacity = 1,
914                previousArrow = this.sliderElement.find('.nextend-arrow-previous'),
915                previous = function (opacity) {
916                    if (opacity != previousArrowOpacity) {
917                        NextendTween.to(previousArrow, 0.4, {opacity: opacity}).play();
918                        previousArrowOpacity = opacity;
919                    }
920                };
921            var nextArrowOpacity = 1,
922                nextArrow = this.sliderElement.find('.nextend-arrow-next'),
923                next = function (opacity) {
924                    if (opacity != nextArrowOpacity) {
925                        NextendTween.to(nextArrow, 0.4, {opacity: opacity}).play();
926                        nextArrowOpacity = opacity;
927                    }
928                };
929
930            var process = function (i) {
931                if (i == 0) {
932                    previous(0);
933                } else {
934                    previous(1);
935                }
936                if (i == slides - 1) {
937                    next(0);
938                } else {
939                    next(1);
940                }
941            };
942
943            process(this.__getActiveSlideIndex())
944
945            this.sliderElement.on('sliderSwitchTo', function (e, i) {
946                process(i);
947            });
948        }
949    };
950
951    NextendSmartSliderAbstract.prototype.next = function (isSystem, customAnimation) {
952        var nextIndex = this.currentSlideIndex + 1;
953        if (nextIndex >= this.slides.length) {
954            nextIndex = 0;
955        }
956        return this.changeTo(nextIndex, false, isSystem, customAnimation);
957    };
958
959    NextendSmartSliderAbstract.prototype.previous = function (isSystem, customAnimation) {
960        var nextIndex = this.currentSlideIndex - 1;
961        if (nextIndex < 0) {
962            nextIndex = this.slides.length - 1;
963        }
964        return this.changeTo(nextIndex, true, isSystem, customAnimation);
965    };
966
967    NextendSmartSliderAbstract.prototype.nextNotCarousel = function (isSystem, customAnimation) {
968        var nextIndex = this.currentSlideIndex + 1;
969        if (nextIndex < this.slides.length) {
970            return this.changeTo(nextIndex, false, isSystem, customAnimation);
971        }
972        return false;
973    };
974
975    NextendSmartSliderAbstract.prototype.previousNotCarousel = function (isSystem, customAnimation) {
976        var nextIndex = this.currentSlideIndex - 1;
977        if (nextIndex >= 0) {
978            return this.changeTo(nextIndex, true, isSystem, customAnimation);
979        }
980        return false;
981    };
982
983    NextendSmartSliderAbstract.prototype.directionalChangeToReal = function (nextSlideIndex) {
984        this.directionalChangeTo(nextSlideIndex);
985    };
986
987    NextendSmartSliderAbstract.prototype.directionalChangeTo = function (nextSlideIndex) {
988        if (nextSlideIndex > this.currentSlideIndex) {
989            this.changeTo(nextSlideIndex, false);
990        } else {
991            this.changeTo(nextSlideIndex, true);
992        }
993    };
994
995    NextendSmartSliderAbstract.prototype.changeTo = function (nextSlideIndex, reversed, isSystem, customAnimation) {
996        nextSlideIndex = parseInt(nextSlideIndex);
997
998        if (nextSlideIndex != this.currentSlideIndex) {
999            n2c.log('Event: sliderSwitchTo: ', 'targetSlideIndex');
1000            this.sliderElement.trigger('sliderSwitchTo', [nextSlideIndex, this.getRealIndex(nextSlideIndex)]);
1001            var time = $.now();
1002            $.when(this.backgroundImages.preLoad(nextSlideIndex), this.focus(isSystem)).done($.proxy(function () {
1003
1004                if (this._lastChangeTime <= time) {
1005                    this._lastChangeTime = time;
1006                    // If the current main animation haven't finished yet or the prefered next slide is the same as our current slide we have nothing to do
1007                    var state = this.mainAnimation.getState();
1008                    if (state == 'ended') {
1009
1010                        if (typeof isSystem === 'undefined') {
1011                            isSystem = false;
1012                        }
1013
1014                        var animation = this.mainAnimation;
1015                        if (typeof customAnimation !== 'undefined') {
1016                            animation = customAnimation;
1017                        }
1018
1019                        this._changeTo(nextSlideIndex, reversed, isSystem, customAnimation);
1020
1021                        n2c.log('Change From:', this.currentSlideIndex, ' To: ', nextSlideIndex, ' Reversed: ', reversed, ' System: ', isSystem);
1022                        animation.changeTo(this.currentSlideIndex, this.slides.eq(this.currentSlideIndex), nextSlideIndex, this.slides.eq(nextSlideIndex), reversed, isSystem);
1023
1024                        this.currentSlideIndex = nextSlideIndex;
1025
1026                    } else if (state == 'playing') {
1027                        this.sliderElement.off('.fastChange').one('mainAnimationComplete.fastChange', $.proxy(function () {
1028                            this.changeTo.call(this, nextSlideIndex, reversed, isSystem, customAnimation);
1029                        }, this));
1030                        this.mainAnimation.timeScale(this.mainAnimation.timeScale() * 2);
1031                    }
1032                }
1033            }, this));
1034            return true;
1035        }
1036        return false;
1037    };
1038
1039    NextendSmartSliderAbstract.prototype._changeTo = function (nextSlideIndex, reversed, isSystem, customAnimation) {
1040
1041    };
1042
1043    NextendSmartSliderAbstract.prototype.__getActiveSlideIndex = function () {
1044        var index = this.slides.index(this.slides.filter('.n2-ss-slide-active'));
1045        if (index === -1) {
1046            index = 0;
1047        }
1048        return index;
1049    };
1050
1051    NextendSmartSliderAbstract.prototype.setActiveSlide = function (slide) {
1052        slide.addClass('n2-ss-slide-active');
1053    };
1054
1055    NextendSmartSliderAbstract.prototype.unsetActiveSlide = function (slide) {
1056        slide.removeClass('n2-ss-slide-active');
1057    };
1058
1059    NextendSmartSliderAbstract.prototype.initMainAnimationWithLayerAnimation = function () {
1060
1061        if (this.parameters.layerMode.mode == 'forced') {
1062            this.sliderElement.on('preChangeToPlay', $.proxy(function (e, deferred, deferredHandled, currentSlide, nextSlide) {
1063                deferredHandled.handled = true;
1064                currentSlide.on('layerAnimationCompleteOut.layers', function () {
1065                    currentSlide.off('layerAnimationCompleteOut.layers');
1066                    deferred.resolve();
1067                });
1068                this.callOnSlide(currentSlide, 'playOut');
1069            }, this));
1070        }
1071        this.sliderElement.on('mainAnimationStart', $.proxy(this.onMainAnimationStartSyncLayers, this, this.parameters.layerMode));
1072
1073    };
1074
1075    NextendSmartSliderAbstract.prototype.onMainAnimationStartSyncLayers = function (layerMode, e, animation, previousSlideIndex, currentSlideIndex) {
1076        var inSlide = this.slides.eq(currentSlideIndex),
1077            outSlide = this.slides.eq(previousSlideIndex);
1078        if (layerMode.inAnimation == 'mainInStart') {
1079            inSlide.on('mainAnimationStartIn.layers', $.proxy(function () {
1080                inSlide.off('mainAnimationStartIn.layers');
1081                this.callOnSlide(inSlide, 'playIn');
1082            }, this));
1083        } else if (layerMode.inAnimation == 'mainInEnd') {
1084            inSlide.on('mainAnimationCompleteIn.layers', $.proxy(function () {
1085                inSlide.off('mainAnimationCompleteIn.layers');
1086                this.callOnSlide(inSlide, 'playIn');
1087            }, this));
1088        }
1089
1090        if (layerMode.mode == 'skippable') {
1091            outSlide.on('mainAnimationCompleteOut.layers', $.proxy(function () {
1092                outSlide.off('mainAnimationCompleteOut.layers');
1093                if (layerMode.playOnce) {
1094                    this.callOnSlide(outSlide, 'pause');
1095                } else {
1096                    this.callOnSlide(outSlide, 'reset');
1097                }
1098            }, this));
1099        }
1100    };
1101
1102    NextendSmartSliderAbstract.prototype.callOnSlide = function (slide, functionName) {
1103        slide.data('slide')[functionName]();
1104    };
1105
1106    NextendSmartSliderAbstract.prototype.findSlideIndexByElement = function (element) {
1107        element = $(element);
1108        for (var i = 0; i < this.slides.length; i++) {
1109            if (this.slides.eq(i).has(element).length === 1) {
1110                return i;
1111            }
1112        }
1113        return -1;
1114    };
1115
1116    NextendSmartSliderAbstract.prototype.initMainAnimation = function () {
1117    };
1118
1119    NextendSmartSliderAbstract.prototype.initResponsiveMode = function () {
1120        new scope[this.responsiveClass](this, this.parameters.responsive);
1121        this.dimensions = this.responsive.responsiveDimensions;
1122    };
1123
1124    NextendSmartSliderAbstract.prototype.initControls = function () {
1125
1126        if (!this.parameters.admin) {
1127            if (this.parameters.controls.touch != '0') {
1128                new NextendSmartSliderControlTouch(this, this.parameters.controls.touch, {
1129                    fallbackToMouseEvents: this.parameters.controls.drag
1130                });
1131            }
1132
1133            if (this.parameters.controls.keyboard) {
1134                new NextendSmartSliderControlKeyboard(this, 'horizontal');
1135            }
1136
1137            if (this.parameters.controls.scroll) {
1138                new NextendSmartSliderControlScroll(this);
1139            }
1140
1141            if (this.parameters.controls.tilt) {
1142                new NextendSmartSliderControlTilt(this);
1143            }
1144
1145            new NextendSmartSliderControlAutoplay(this, this.parameters.autoplay);
1146
1147        }
1148    };
1149
1150    NextendSmartSliderAbstract.prototype.slideToID = function (id) {
1151        var index = this.slides.index(this.slides.filter('[data-id="' + id + '"]'));
1152        return this.slide(index);
1153    };
1154
1155    NextendSmartSliderAbstract.prototype.slide = function (index) {
1156        if (index >= 0 && index < this.slides.length) {
1157            return this.changeTo(index);
1158        }
1159        return false;
1160    };
1161
1162    NextendSmartSliderAbstract.prototype.adminGetCurrentSlideElement = function () {
1163
1164        if (this.parameters.isStaticEdited) {
1165            return this.findStaticSlide();
1166        }
1167        return this.slides.eq(this.currentSlideIndex);
1168    };
1169
1170    scope.NextendSmartSliderAbstract = NextendSmartSliderAbstract;
1171
1172})(n2, window);
1173(function ($, scope, undefined) {
1174
1175    function NextendSmartSliderWidgets(slider) {
1176        this.slider = slider;
1177        this.sliderElement = slider.sliderElement.on('BeforeVisible', $.proxy(this.onReady, this));
1178
1179        this.initExcludeSlides();
1180    }
1181
1182    NextendSmartSliderWidgets.prototype.onReady = function () {
1183        this.dimensions = this.slider.dimensions;
1184
1185        this.widgets = {
1186            previous: this.sliderElement.find('.nextend-arrow-previous'),
1187            next: this.sliderElement.find('.nextend-arrow-next'),
1188            bullet: this.sliderElement.find('.nextend-bullet-bar'),
1189            autoplay: this.sliderElement.find('.nextend-autoplay'),
1190            indicator: this.sliderElement.find('.nextend-indicator'),
1191            bar: this.sliderElement.find('.nextend-bar'),
1192            thumbnail: this.sliderElement.find('.nextend-thumbnail'),
1193            shadow: this.sliderElement.find('.nextend-shadow'),
1194            fullscreen: this.sliderElement.find('.nextend-fullscreen'),
1195            html: this.sliderElement.find('.nextend-widget-html')
1196        };
1197
1198        this.variableElementsDimension = {
1199            width: this.sliderElement.find('[data-sswidth]'),
1200            height: this.sliderElement.find('[data-ssheight]')
1201        };
1202
1203        this.variableElements = {
1204            top: this.sliderElement.find('[data-sstop]'),
1205            right: this.sliderElement.find('[data-ssright]'),
1206            bottom: this.sliderElement.find('[data-ssbottom]'),
1207            left: this.sliderElement.find('[data-ssleft]')
1208        };
1209
1210        this.slider.sliderElement.on('SliderAnimatedResize', $.proxy(this.onAnimatedResize, this));
1211        this.slider.sliderElement.on('SliderResize', $.proxy(this.onResize, this));
1212        this.slider.sliderElement.one('slideCountChanged', $.proxy(function () {
1213            this.onResize(this.slider.responsive.lastRatios);
1214        }, this));
1215
1216        //this.slider.ready($.proxy(function () {
1217        this.onResize(this.slider.responsive.lastRatios);
1218        //}, this));
1219        this.initHover();
1220    };
1221
1222    NextendSmartSliderWidgets.prototype.initHover = function () {
1223        var timeout = null,
1224            widgets = this.sliderElement.find('.n2-ss-widget-hover');
1225        if (widgets.length > 0) {
1226            this.sliderElement.on('universalenter', function (e) {
1227                var slider = $(this);
1228                if (timeout) clearTimeout(timeout);
1229                widgets.css('visibility', 'visible');
1230                setTimeout(function () {
1231                    slider.addClass('n2-ss-widget-hover-show');
1232                }, 50);
1233            }).on('universalleave', function () {
1234                var slide = this;
1235                if (timeout) clearTimeout(timeout);
1236                timeout = setTimeout(function () {
1237                    $(slide).removeClass('n2-ss-widget-hover-show');
1238                    timeout = setTimeout(function () {
1239                        widgets.css('visibility', 'hidden');
1240                    }, 400);
1241                }, 500);
1242            });
1243        }
1244    };
1245
1246    NextendSmartSliderWidgets.prototype.initExcludeSlides = function () {
1247        var widgets = this.sliderElement.find('.n2-ss-widget[data-exclude-slides]'),
1248            hideOrShow = function (widget, excludedSlides, currentSlideIndex) {
1249                if ($.inArray((currentSlideIndex + 1) + '', excludedSlides) != -1) {
1250                    widget.addClass('n2-ss-widget-hidden');
1251                } else {
1252                    widget.removeClass('n2-ss-widget-hidden');
1253                }
1254            };
1255        widgets.each($.proxy(function (i, el) {
1256            var widget = $(el),
1257                excludedSlides = widget.attr('data-exclude-slides').split(',');
1258            for (var i = excludedSlides.length - 1; i >= 0; i--) {
1259                var parts = excludedSlides[i].split('-');
1260                if (parts.length == 2 && parseInt(parts[0]) <= parseInt(parts[1])) {
1261                    excludedSlides[i] = parts[0];
1262                    parts[0] = parseInt(parts[0]);
1263                    parts[1] = parseInt(parts[1]);
1264                    for (var j = parts[0] + 1; j <= parts[1]; j++) {
1265                        excludedSlides.push(j + '');
1266                    }
1267                }
1268            }
1269            hideOrShow(widget, excludedSlides, this.slider.currentSlideIndex);
1270            this.slider.sliderElement
1271                .on('sliderSwitchTo', function (e, targetSlideIndex) {
1272                    hideOrShow(widget, excludedSlides, targetSlideIndex);
1273                });
1274        }, this));
1275    };
1276
1277    NextendSmartSliderWidgets.prototype.onAnimatedResize = function (e, ratios, timeline, duration) {
1278        for (var key in this.widgets) {
1279            var el = this.widgets[key],
1280                visible = el.is(":visible");
1281            this.dimensions[key + 'width'] = visible ? el.outerWidth(false) : 0;
1282            this.dimensions[key + 'height'] = visible ? el.outerHeight(false) : 0;
1283        }
1284
1285        // Compatibility variables for the old version
1286        this.dimensions['width'] = this.dimensions.slider.width;
1287        this.dimensions['height'] = this.dimensions.slider.height;
1288        this.dimensions['outerwidth'] = this.sliderElement.parent().width();
1289        this.dimensions['outerheight'] = this.sliderElement.parent().height();
1290        this.dimensions['canvaswidth'] = this.dimensions.slide.width;
1291        this.dimensions['canvasheight'] = this.dimensions.slide.height;
1292        this.dimensions['margintop'] = this.dimensions.slider.marginTop;
1293        this.dimensions['marginright'] = this.dimensions.slider.marginRight;
1294        this.dimensions['marginbottom'] = this.dimensions.slider.marginBottom;
1295        this.dimensions['marginleft'] = this.dimensions.slider.marginLeft;
1296
1297        var variableText = '';
1298        for (var key in this.dimensions) {
1299            var value = this.dimensions[key];
1300            if (typeof value == "object") {
1301                for (var key2 in value) {
1302                    variableText += "var " + key + key2 + " = " + value[key2] + ";";
1303                }
1304            } else {
1305                variableText += "var " + key + " = " + value + ";";
1306            }
1307        }
1308        eval(variableText);
1309
1310        for (var k in this.variableElementsDimension) {
1311            for (var i = 0; i < this.variableElementsDimension[k].length; i++) {
1312                var el = this.variableElementsDimension[k].eq(i);
1313                if (el.is(':visible')) {
1314                    var to = {};
1315                    try {
1316                        to[k] = eval(el.data('ss' + k)) + 'px';
1317                        for (var widget in this.widgets) {
1318                            if (this.widgets[widget].filter(el).length) {
1319                                if (k == 'width') {
1320                                    this.dimensions[widget + k] = el.outerWidth(false);
1321                                } else if (k == 'height') {
1322                                    this.dimensions[widget + k] = el.outerHeight(false);
1323                                }
1324                                eval(widget + k + " = " + this.dimensions[widget + k] + ";");
1325                            }
1326                        }
1327                    } catch (e) {
1328                        console.log(el, ' position variable: ' + e.message + ': ', el.data('ss' + k));
1329                    }
1330                    timeline.to(el, duration, to, 0);
1331                }
1332            }
1333        }
1334
1335        for (var k in this.variableElements) {
1336            for (var i = 0; i < this.variableElements[k].length; i++) {
1337                var el = this.variableElements[k].eq(i);
1338                try {
1339                    var to = {};
1340                    to[k] = eval(el.data('ss' + k)) + 'px';
1341                    timeline.to(el, duration, to, 0);
1342                } catch (e) {
1343                    console.log(el, ' position variable: ' + e.message + ': ', el.data('ss' + k));
1344                }
1345            }
1346        }
1347    };
1348
1349
1350    NextendSmartSliderWidgets.prototype.onResize = function (e, ratios, responsive, timeline) {
1351        if (timeline) {
1352            return;
1353        }
1354        for (var key in this.widgets) {
1355            var el = this.widgets[key],
1356                visible = el.is(":visible");
1357            this.dimensions[key + 'width'] = visible ? el.outerWidth(false) : 0;
1358            this.dimensions[key + 'height'] = visible ? el.outerHeight(false) : 0;
1359        }
1360
1361        // Compatibility variables for the old version
1362        this.dimensions['width'] = this.dimensions.slider.width;
1363        this.dimensions['height'] = this.dimensions.slider.height;
1364        this.dimensions['outerwidth'] = this.sliderElement.parent().width();
1365        this.dimensions['outerheight'] = this.sliderElement.parent().height();
1366        this.dimensions['canvaswidth'] = this.dimensions.slide.width;
1367        this.dimensions['canvasheight'] = this.dimensions.slide.height;
1368        this.dimensions['margintop'] = this.dimensions.slider.marginTop;
1369        this.dimensions['marginright'] = this.dimensions.slider.marginRight;
1370        this.dimensions['marginbottom'] = this.dimensions.slider.marginBottom;
1371        this.dimensions['marginleft'] = this.dimensions.slider.marginLeft;
1372
1373        var variableText = '';
1374        for (var key in this.dimensions) {
1375            var value = this.dimensions[key];
1376            if (typeof value == "object") {
1377                for (var key2 in value) {
1378                    variableText += "var " + key + key2 + " = " + value[key2] + ";";
1379                }
1380            } else {
1381                variableText += "var " + key + " = " + value + ";";
1382            }
1383        }
1384        eval(variableText);
1385
1386        for (var k in this.variableElementsDimension) {
1387            for (var i = 0; i < this.variableElementsDimension[k].length; i++) {
1388                var el = this.variableElementsDimension[k].eq(i);
1389                if (el.is(':visible')) {
1390                    try {
1391                        el.css(k, eval(el.data('ss' + k)) + 'px');
1392                        for (var widget in this.widgets) {
1393                            if (this.widgets[widget].filter(el).length) {
1394                                if (k == 'width') {
1395                                    this.dimensions[widget + k] = el.outerWidth(false);
1396                                } else if (k == 'height') {
1397                                    this.dimensions[widget + k] = el.outerHeight(false);
1398                                }
1399                                eval(widget + k + " = " + this.dimensions[widget + k] + ";");
1400                            }
1401                        }
1402                    } catch (e) {
1403                        console.log(el, ' position variable: ' + e.message + ': ', el.data('ss' + k));
1404                    }
1405                }
1406            }
1407        }
1408
1409        for (var k in this.variableElements) {
1410            for (var i = 0; i < this.variableElements[k].length; i++) {
1411                var el = this.variableElements[k].eq(i);
1412                try {
1413                    el.css(k, eval(el.data('ss' + k)) + 'px');
1414                } catch (e) {
1415                    console.log(el, ' position variable: ' + e.message + ': ', el.data('ss' + k));
1416                }
1417            }
1418        }
1419    };
1420
1421    scope.NextendSmartSliderWidgets = NextendSmartSliderWidgets;
1422
1423})(n2, window);
1424(function ($, scope, undefined) {
1425    function NextendSmartSliderBackgroundAnimationAbstract(sliderBackgroundAnimation, currentImage, nextImage, animationProperties, durationMultiplier, reversed) {
1426
1427        this.durationMultiplier = durationMultiplier;
1428
1429        this.original = {
1430            currentImage: currentImage,
1431            nextImage: nextImage
1432        };
1433
1434        this.animationProperties = animationProperties;
1435
1436        this.reversed = reversed;
1437
1438        this.timeline = sliderBackgroundAnimation.timeline;
1439
1440        this.containerElement = sliderBackgroundAnimation.bgAnimationElement;
1441
1442        this.shiftedBackgroundAnimation = sliderBackgroundAnimation.parameters.shiftedBackgroundAnimation;
1443
1444        this.clonedImages = {};
1445
1446    };
1447
1448    NextendSmartSliderBackgroundAnimationAbstract.prototype.postSetup = function () {
1449    };
1450
1451    NextendSmartSliderBackgroundAnimationAbstract.prototype.ended = function () {
1452
1453    };
1454
1455    NextendSmartSliderBackgroundAnimationAbstract.prototype.placeNextImage = function () {
1456        this.clonedImages.nextImage = this.original.nextImage.clone().css({
1457            position: 'absolute',
1458            top: 0,
1459            left: 0
1460        });
1461
1462        this.containerElement.append(this.clonedImages.nextImage);
1463    };
1464
1465    NextendSmartSliderBackgroundAnimationAbstract.prototype.placeCurrentImage = function () {
1466        this.clonedImages.currentImage = this.original.currentImage.clone().css({
1467            position: 'absolute',
1468            top: 0,
1469            left: 0
1470        });
1471
1472        this.containerElement.append(this.clonedImages.currentImage);
1473    };
1474
1475    NextendSmartSliderBackgroundAnimationAbstract.prototype.hideOriginals = function () {
1476        this.original.currentImage.css('opacity', 0);
1477        this.original.nextImage.css('opacity', 0);
1478    };
1479
1480    NextendSmartSliderBackgroundAnimationAbstract.prototype.resetAll = function () {
1481        this.original.currentImage.css('opacity', 1);
1482        this.original.nextImage.css('opacity', 1);
1483        this.containerElement.html('');
1484    };
1485
1486    NextendSmartSliderBackgroundAnimationAbstract.prototype.getExtraDelay = function () {
1487        return 0;
1488    };
1489
1490    scope.NextendSmartSliderBackgroundAnimationAbstract = NextendSmartSliderBackgroundAnimationAbstract;
1491})(n2, window);
1492
1493(function ($, scope, undefined) {
1494
1495    function NextendSmartSliderBackgroundAnimationFluxAbstract() {
1496        this.shiftedPreSetup = false;
1497        this._clonedCurrent = false;
1498        this._clonedNext = false;
1499
1500        NextendSmartSliderBackgroundAnimationAbstract.prototype.constructor.apply(this, arguments);
1501
1502        this.w = this.original.currentImage.width();
1503        this.h = this.original.currentImage.height();
1504    };
1505
1506    NextendSmartSliderBackgroundAnimationFluxAbstract.prototype = Object.create(NextendSmartSliderBackgroundAnimationAbstract.prototype);
1507    NextendSmartSliderBackgroundAnimationFluxAbstract.prototype.constructor = NextendSmartSliderBackgroundAnimationFluxAbstract;
1508
1509    NextendSmartSliderBackgroundAnimationFluxAbstract.prototype.clonedCurrent = function () {
1510        if (!this._clonedCurrent) {
1511            this._clonedCurrent = this.original.currentImage
1512                .clone()
1513                .css({
1514                    width: this.w,
1515                    height: this.h
1516                });
1517        }
1518        return this._clonedCurrent;
1519    };
1520
1521    NextendSmartSliderBackgroundAnimationFluxAbstract.prototype.clonedNext = function () {
1522        if (!this._clonedNext) {
1523            this._clonedNext = this.original.nextImage
1524                .clone()
1525                .css({
1526                    width: this.w,
1527                    height: this.h
1528                });
1529        }
1530        return this._clonedNext;
1531    };
1532
1533    NextendSmartSliderBackgroundAnimationFluxAbstract.prototype.preSetup = function () {
1534        if (this.shiftedBackgroundAnimation != 0) {
1535            this.shiftedPreSetup = true;
1536        } else {
1537            this._preSetup();
1538        }
1539    };
1540
1541    NextendSmartSliderBackgroundAnimationFluxAbstract.prototype._preSetup = function (skipFadeOut) {
1542        this.timeline.to(this.original.currentImage.get(0), this.getExtraDelay(), {
1543            opacity: 0
1544        }, 0);
1545
1546        this.original.nextImage.css('opacity', 0);
1547    };
1548
1549    NextendSmartSliderBackgroundAnimationFluxAbstract.prototype.postSetup = function () {
1550        this.timeline.to(this.original.nextImage.get(0), this.getExtraDelay(), {
1551            opacity: 1
1552        });
1553    };
1554
1555    NextendSmartSliderBackgroundAnimationFluxAbstract.prototype.getExtraDelay = function () {
1556        return .2;
1557    };
1558
1559    NextendSmartSliderBackgroundAnimationFluxAbstract.prototype.ended = function () {
1560        this.original.currentImage.css('opacity', 1);
1561        this.containerElement.html('');
1562    };
1563
1564    scope.NextendSmartSliderBackgroundAnimationFluxAbstract = NextendSmartSliderBackgroundAnimationFluxAbstract;
1565
1566
1567    function NextendSmartSliderBackgroundAnimationTiled() {
1568        NextendSmartSliderBackgroundAnimationFluxAbstract.prototype.constructor.apply(this, arguments);
1569
1570        this.setup();
1571    };
1572
1573    NextendSmartSliderBackgroundAnimationTiled.prototype = Object.create(NextendSmartSliderBackgroundAnimationFluxAbstract.prototype);
1574    NextendSmartSliderBackgroundAnimationTiled.prototype.constructor = NextendSmartSliderBackgroundAnimationTiled;
1575
1576    NextendSmartSliderBackgroundAnimationTiled.prototype.setup = function (animation) {
1577
1578        var container = $('<div></div>').css({
1579            position: 'absolute',
1580            left: 0,
1581            top: 0,
1582            width: this.w,
1583            height: this.h/*,
1584             overflow: 'hidden'*/
1585        });
1586        this.container = container;
1587        NextendTween.set(container.get(0), {
1588            force3D: true,
1589            perspective: 1000
1590        });
1591
1592        var animatablesMulti = [],
1593            animatables = [];
1594
1595        var columns = animation.columns,
1596            rows = animation.rows,
1597            colWidth = Math.floor(this.w / columns),
1598            rowHeight = Math.floor(this.h / rows);
1599
1600        var colRemainder = this.w - (columns * colWidth),
1601            colAddPerLoop = Math.ceil(colRemainder / columns),
1602            rowRemainder = this.h - (rows * rowHeight),
1603            rowAddPerLoop = Math.ceil(rowRemainder / rows),
1604            totalLeft = 0;
1605
1606        for (var col = 0; col < columns; col++) {
1607            animatablesMulti[col] = [];
1608            var thisColWidth = colWidth,
1609                totalTop = 0;
1610
1611            if (colRemainder > 0) {
1612                var add = colRemainder >= colAddPerLoop ? colAddPerLoop : colRemainder;
1613                thisColWidth += add;
1614                colRemainder -= add;
1615            }
1616
1617            var thisRowRemainder = rowRemainder;
1618
1619            for (var row = 0; row < rows; row++) {
1620                var thisRowHeight = rowHeight;
1621
1622                if (thisRowRemainder > 0) {
1623                    var add = thisRowRemainder >= rowAddPerLoop ? rowAddPerLoop : thisRowRemainder;
1624                    thisRowHeight += add;
1625                    thisRowRemainder -= add;
1626                }
1627                var tile = $('<div class="tile tile-' + col + '-' + row + '"></div>').css({
1628                    position: 'absolute',
1629                    top: totalTop + 'px',
1630                    left: totalLeft + 'px',
1631                    width: thisColWidth + 'px',
1632                    height: thisRowHeight + 'px',
1633                    zIndex: -Math.abs(col - parseInt(columns / 2)) + columns - Math.abs(row - parseInt(rows / 2))
1634                }).appendTo(container);
1635
1636                var animatable = this.renderTile(tile, thisColWidth, thisRowHeight, animation, totalLeft, totalTop);
1637                animatables.push(animatable);
1638                animatablesMulti[col][row] = animatable;
1639
1640                totalTop += thisRowHeight;
1641            }
1642            totalLeft += thisColWidth;
1643        }
1644
1645        container.appendTo(this.containerElement);
1646
1647        this.preSetup();
1648
1649        this.animate(animation, animatables, animatablesMulti);
1650    };
1651
1652    NextendSmartSliderBackgroundAnimationTiled.prototype.animate = function (animation, animatables, animatablesMulti) {
1653        this['sequence' + animation.tiles.sequence]($.proxy(this.transform, this, animation), animatables, animatablesMulti, animation.tiles.delay * this.durationMultiplier);
1654    };
1655
1656    NextendSmartSliderBackgroundAnimationTiled.prototype.sequenceParallel = function (transform, cuboids) {
1657        transform(cuboids, null);
1658    };
1659
1660    NextendSmartSliderBackgroundAnimationTiled.prototype.sequenceRandom = function (transform, cuboids, cuboidsMulti, delay) {
1661        var total = this.timeline.totalDuration();
1662        for (var i = 0; i < cuboids.length; i++) {
1663            transform(cuboids[i], total + Math.random() * delay);
1664        }
1665    };
1666
1667    NextendSmartSliderBackgroundAnimationTiled.prototype.sequenceForwardCol = function (transform, cuboids, cuboidsMulti, delay) {
1668        var total = this.timeline.totalDuration();
1669        for (var i = 0; i < cuboids.length; i++) {
1670            transform(cuboids[i], total + delay * i);
1671        }
1672    };
1673
1674    NextendSmartSliderBackgroundAnimationTiled.prototype.sequenceBackwardCol = function (transform, cuboids, cuboidsMulti, delay) {
1675        var total = this.timeline.totalDuration(),
1676            length = cuboids.length - 1;
1677        for (var i = 0; i < cuboids.length; i++) {
1678            transform(cuboids[i], total + delay * (length - i));
1679        }
1680    };
1681
1682    NextendSmartSliderBackgroundAnimationTiled.prototype.sequenceForwardRow = function (transform, cuboids, cuboidsMulti, delay) {
1683        var total = this.timeline.totalDuration(),
1684            i = 0;
1685        for (var row = 0; row < cuboidsMulti[0].length; row++) {
1686            for (var col = 0; col < cuboidsMulti.length; col++) {
1687                transform(cuboidsMulti[col][row], total + delay * i);
1688                i++;
1689            }
1690        }
1691    };
1692
1693    NextendSmartSliderBackgroundAnimationTiled.prototype.sequenceBackwardRow = function (transform, cuboids, cuboidsMulti, delay) {
1694        var total = this.timeline.totalDuration(),
1695            i = cuboids.length - 1;
1696        for (var row = 0; row < cuboidsMulti[0].length; row++) {
1697            for (var col = 0; col < cuboidsMulti.length; col++) {
1698                transform(cuboidsMulti[col][row], total + delay * i);
1699                i--;
1700            }
1701        }
1702    };
1703
1704    NextendSmartSliderBackgroundAnimationTiled.prototype.sequenceForwardDiagonal = function (transform, cuboids, cuboidsMulti, delay) {
1705        var total = this.timeline.totalDuration();
1706        for (var row = 0; row < cuboidsMulti[0].length; row++) {
1707            for (var col = 0; col < cuboidsMulti.length; col++) {
1708                transform(cuboidsMulti[col][row], total + delay * (col + row));
1709            }
1710        }
1711    };
1712
1713    NextendSmartSliderBackgroundAnimationTiled.prototype.sequenceBackwardDiagonal = function (transform, cuboids, cuboidsMulti, delay) {
1714        var total = this.timeline.totalDuration(),
1715            length = cuboidsMulti[0].length + cuboidsMulti.length - 2;
1716        for (var row = 0; row < cuboidsMulti[0].length; row++) {
1717            for (var col = 0; col < cuboidsMulti.length; col++) {
1718                transform(cuboidsMulti[col][row], total + delay * (length - col - row));
1719            }
1720        }
1721    };
1722
1723    scope.NextendSmartSliderBackgroundAnimationTiled = NextendSmartSliderBackgroundAnimationTiled;
1724
1725
1726    function NextendSmartSliderBackgroundAnimationFlat() {
1727        NextendSmartSliderBackgroundAnimationTiled.prototype.constructor.apply(this, arguments);
1728    };
1729
1730    NextendSmartSliderBackgroundAnimationFlat.prototype = Object.create(NextendSmartSliderBackgroundAnimationTiled.prototype);
1731    NextendSmartSliderBackgroundAnimationFlat.prototype.constructor = NextendSmartSliderBackgroundAnimationFlat;
1732
1733    NextendSmartSliderBackgroundAnimationFlat.prototype.setup = function () {
1734
1735        var animation = $.extend(true, {
1736            columns: 1,
1737            rows: 1,
1738            tiles: {
1739                cropOuter: false,
1740                crop: true,
1741                delay: 0, // Delay between the starting of the tiles sequence. Ex.: #1 batch start: 0s, #2: .2s, #3: .4s
1742                sequence: 'Parallel' // Parallel, Random, ForwardCol, BackwardCol, ForwardRow, BackwardRow, ForwardDiagonal, BackwardDiagonal
1743            },
1744            main: {
1745                type: 'next',  // Enable animation on the specified tile: current, next, both
1746                duration: 0.5,
1747                real3D: true, // Enable perspective
1748                zIndex: 1, // z-index of the current image. Change it to 2 to show it over the second image.
1749                current: { // Animation of the current tile
1750                    ease: 'easeInOutCubic'
1751                },
1752                next: { // Animation of the next tile
1753                    ease: 'easeInOutCubic'
1754                }
1755            }
1756        }, this.animationProperties);
1757
1758        if (this.reversed) {
1759            if (typeof animation.invert !== 'undefined') {
1760                $.extend(true, animation.main, animation.invert);
1761            }
1762
1763            if (typeof animation.invertTiles !== 'undefined') {
1764                $.extend(animation.tiles, animation.invertTiles);
1765            }
1766        }
1767
1768        NextendSmartSliderBackgroundAnimationTiled.prototype.setup.call(this, animation);
1769
1770        if (animation.tiles.cropOuter) {
1771            this.container.css('overflow', 'hidden');
1772        }
1773    };
1774
1775    NextendSmartSliderBackgroundAnimationFlat.prototype.renderTile = function (tile, w, h, animation, totalLeft, totalTop) {
1776
1777        if (animation.tiles.crop) {
1778            tile.css('overflow', 'hidden');
1779        }
1780
1781        var current = $('<div></div>')
1782            .css({
1783                position: 'absolute',
1784                left: 0,
1785                top: 0,
1786                width: w,
1787                height: h,
1788                overflow: 'hidden',
1789                zIndex: animation.main.zIndex
1790            })
1791            .append(this.clonedCurrent().clone().css({
1792                position: 'absolute',
1793                top: -totalTop + 'px',
1794                left: -totalLeft + 'px'
1795            }))
1796            .appendTo(tile);
1797        var next = $('<div></div>')
1798            .css({
1799                position: 'absolute',
1800                left: 0,
1801                top: 0,
1802                width: w,
1803                height: h,
1804                overflow: 'hidden',
1805                zIndex: 1
1806            })
1807            .append(this.clonedNext().clone().css({
1808                position: 'absolute',
1809                top: -totalTop + 'px',
1810                left: -totalLeft + 'px'
1811            }))
1812            .appendTo(tile);
1813
1814        if (animation.main.real3D) {
1815            NextendTween.set(tile.get(0), {
1816                transformStyle: "preserve-3d"
1817            });
1818            NextendTween.set(current.get(0), {
1819                transformStyle: "preserve-3d"
1820            });
1821            NextendTween.set(next.get(0), {
1822                transformStyle: "preserve-3d"
1823            });
1824        }
1825
1826        return {
1827            current: current,
1828            next: next
1829        }
1830    };
1831
1832    NextendSmartSliderBackgroundAnimationFlat.prototype.transform = function (animation, animatable, total) {
1833
1834        var main = animation.main;
1835
1836        if (main.type == 'current' || main.type == 'both') {
1837            this.timeline.to(animatable.current, main.duration * this.durationMultiplier, main.current, total);
1838        }
1839
1840        if (main.type == 'next' || main.type == 'both') {
1841            this.timeline.from(animatable.next, main.duration * this.durationMultiplier, main.next, total);
1842        }
1843    };
1844    scope.NextendSmartSliderBackgroundAnimationFlat = NextendSmartSliderBackgroundAnimationFlat;
1845
1846
1847    function NextendSmartSliderBackgroundAnimationCubic() {
1848        NextendSmartSliderBackgroundAnimationTiled.prototype.constructor.apply(this, arguments);
1849    };
1850
1851    NextendSmartSliderBackgroundAnimationCubic.prototype = Object.create(NextendSmartSliderBackgroundAnimationTiled.prototype);
1852    NextendSmartSliderBackgroundAnimationCubic.prototype.constructor = NextendSmartSliderBackgroundAnimationCubic;
1853
1854
1855    NextendSmartSliderBackgroundAnimationCubic.prototype.setup = function () {
1856        var animation = $.extend(true, {
1857            columns: 1,
1858            rows: 1,
1859            fullCube: true,
1860            tiles: {
1861                delay: 0.2,  // Delay between the starting of the tiles sequence. Ex.: #1 batch start: 0s, #2: .2s, #3: .4s
1862                sequence: 'Parallel' // Parallel, Random, ForwardCol, BackwardCol, ForwardRow, BackwardRow, ForwardDiagonal, BackwardDiagonal
1863            },
1864            depth: 50, // Used only when side is "Back"
1865            main: {
1866                side: 'Left', // Left, Right, Top, Bottom, Back, BackInvert
1867                duration: 0.5,
1868                ease: 'easeInOutCubic',
1869                direction: 'horizontal', // horizontal, vertical // Used when side points to Back
1870                real3D: true // Enable perspective
1871            },
1872            pre: [], // Animations to play on tiles before main
1873            post: [] // Animations to play on tiles after main
1874        }, this.animationProperties);
1875        animation.fullCube = true;
1876
1877        if (this.reversed) {
1878            if (typeof animation.invert !== 'undefined') {
1879                $.extend(true, animation.main, animation.invert);
1880            }
1881
1882            if (typeof animation.invertTiles !== 'undefined') {
1883                $.extend(animation.tiles, animation.invertTiles);
1884            }
1885        }
1886
1887        NextendSmartSliderBackgroundAnimationTiled.prototype.setup.call(this, animation);
1888    };
1889
1890    NextendSmartSliderBackgroundAnimationCubic.prototype.renderTile = function (tile, w, h, animation, totalLeft, totalTop) {
1891
1892        var d = animation.depth;
1893
1894        switch (d) {
1895            case 'width':
1896                d = w;
1897                break;
1898            case 'height':
1899                d = h;
1900                break;
1901        }
1902        switch (animation.main.side) {
1903            case 'Top':
1904            case 'Bottom':
1905                d = h;
1906                break;
1907            case 'Left':
1908            case 'Right':
1909                d = w;
1910                break;
1911        }
1912
1913        if (animation.main.real3D) {
1914            NextendTween.set(tile.get(0), {
1915                transformStyle: "preserve-3d"
1916            });
1917        }
1918        var cuboid = $('<div class="cuboid"></div>').css({
1919            position: 'absolute',
1920            left: '0',
1921            top: '0',
1922            width: '100%',
1923            height: '100%'
1924        }).appendTo(tile);
1925        NextendTween.set(cuboid.get(0), {
1926            transformStyle: "preserve-3d",
1927            z: -d / 2
1928        });
1929
1930        var backRotationZ = 0;
1931        if (animation.main.direction == 'horizontal') {
1932            backRotationZ = 180;
1933        }
1934        var back = this.getSide(cuboid, w, h, 0, 0, -d / 2, 180, 0, backRotationZ),
1935            sides = {
1936                Back: back,
1937                BackInvert: back
1938            };
1939        if (animation.fullCube || animation.main.direction == 'vertical') {
1940            sides.Bottom = this.getSide(cuboid, w, d, 0, h - d / 2, 0, -90, 0, 0);
1941            sides.Top = this.getSide(cuboid, w, d, 0, -d / 2, 0, 90, 0, 0);
1942        }
1943
1944        sides.Front = this.getSide(cuboid, w, h, 0, 0, d / 2, 0, 0, 0);
1945        if (animation.fullCube || animation.main.direction == 'horizontal') {
1946            sides.Left = this.getSide(cuboid, d, h, -d / 2, 0, 0, 0, -90, 0);
1947            sides.Right = this.getSide(cuboid, d, h, w - d / 2, 0, 0, 0, 90, 0);
1948        }
1949
1950        sides.Front.append(this.clonedCurrent().clone().css({
1951            position: 'absolute',
1952            top: -totalTop + 'px',
1953            left: -totalLeft + 'px'
1954        }));
1955
1956        sides[animation.main.side].append(this.clonedNext().clone().css({
1957            position: 'absolute',
1958            top: -totalTop + 'px',
1959            left: -totalLeft + 'px'
1960        }));
1961
1962        return cuboid;
1963    };
1964
1965    NextendSmartSliderBackgroundAnimationCubic.prototype.getSide = function (cuboid, w, h, x, y, z, rX, rY, rZ) {
1966        var side = $('<div class="n2-3d-side"></div>')
1967            .css({
1968                width: w,
1969                height: h
1970            })
1971            .appendTo(cuboid);
1972        NextendTween.set(side.get(0), {
1973            x: x,
1974            y: y,
1975            z: z,
1976            rotationX: rX,
1977            rotationY: rY,
1978            rotationZ: rZ,
1979            backfaceVisibility: "hidden"
1980        });
1981        return side;
1982    };
1983
1984    NextendSmartSliderBackgroundAnimationCubic.prototype.addAnimation = function (animation, cuboids) {
1985        var duration = animation.duration;
1986        delete animation.duration;
1987        this.timeline.to(cuboids, duration * this.durationMultiplier, animation);
1988    };
1989
1990    NextendSmartSliderBackgroundAnimationCubic.prototype.transform = function (animation, cuboid, position) {
1991
1992        for (var i = 0; i < animation.pre.length; i++) {
1993            var _a = animation.pre[i];
1994            var duration = _a.duration * this.durationMultiplier;
1995            this.timeline.to(cuboid, duration, _a, position);
1996            position += duration;
1997        }
1998
1999        this['transform' + animation.main.side](animation.main, cuboid, position);
2000        position += animation.main.duration;
2001
2002        for (var i = 0; i < animation.post.length; i++) {
2003            var _a = animation.post[i];
2004            var duration = _a.duration * this.durationMultiplier;
2005            this.timeline.to(cuboid, duration, _a, position);
2006            position += duration;
2007        }
2008    };
2009
2010    NextendSmartSliderBackgroundAnimationCubic.prototype.transformLeft = function (main, cuboid, total) {
2011        this._transform(main, cuboid, total, 0, 90, 0);
2012    };
2013
2014    NextendSmartSliderBackgroundAnimationCubic.prototype.transformRight = function (main, cuboid, total) {
2015        this._transform(main, cuboid, total, 0, -90, 0);
2016    };
2017
2018    NextendSmartSliderBackgroundAnimationCubic.prototype.transformTop = function (main, cuboid, total) {
2019        this._transform(main, cuboid, total, -90, 0, 0);
2020    };
2021
2022    NextendSmartSliderBackgroundAnimationCubic.prototype.transformBottom = function (main, cuboid, total) {
2023        this._transform(main, cuboid, total, 90, 0, 0);
2024    };
2025
2026    NextendSmartSliderBackgroundAnimationCubic.prototype.transformBack = function (main, cuboid, total) {
2027        if (main.direction == 'horizontal') {
2028            this._transform(main, cuboid, total, 0, 180, 0);
2029        } else {
2030            this._transform(main, cuboid, total, 180, 0, 0);
2031        }
2032    };
2033
2034    NextendSmartSliderBackgroundAnimationCubic.prototype.transformBackInvert = function (main, cuboid, total) {
2035        if (main.direction == 'horizontal') {
2036            this._transform(main, cuboid, total, 0, -180, 0);
2037        } else {
2038            this._transform(main, cuboid, total, -180, 0, 0);
2039        }
2040    };
2041
2042    NextendSmartSliderBackgroundAnimationCubic.prototype._transform = function (main, cuboid, total, rX, rY, rZ) {
2043        this.timeline.to(cuboid, main.duration * this.durationMultiplier, {
2044            rotationX: rX,
2045            rotationY: rY,
2046            rotationZ: rZ,
2047            ease: main.ease
2048        }, total);
2049    };
2050
2051    scope.NextendSmartSliderBackgroundAnimationCubic = NextendSmartSliderBackgroundAnimationCubic;
2052
2053
2054    function NextendSmartSliderBackgroundAnimationTurn() {
2055        NextendSmartSliderBackgroundAnimationFluxAbstract.prototype.constructor.apply(this, arguments);
2056
2057        var animation = $.extend(true, {
2058            perspective: this.w * 1.5,
2059            duration: 0.8,
2060            direction: 'left'
2061        }, this.animationProperties);
2062
2063        if (this.reversed) {
2064            if (animation.direction == 'left') {
2065                animation.direction = 'right';
2066            } else {
2067                animation.direction = 'left';
2068            }
2069        }
2070
2071        var w2 = parseInt(this.w / 2);
2072
2073        this.clonedCurrent().css({
2074            'position': 'absolute',
2075            'top': 0,
2076            'left': (animation.direction == 'left' ? -1 * (this.w / 2) : 0)
2077        });
2078
2079        this.clonedNext().css({
2080            'position': 'absolute',
2081            'top': 0,
2082            'left': (animation.direction == 'left' ? 0 : -1 * (this.w / 2))
2083        });
2084
2085        var tab = $('<div class="tab"></div>').css({
2086            width: w2,
2087            height: this.h,
2088            position: 'absolute',
2089            top: '0px',
2090            left: animation.direction == 'left' ? w2 : '0',
2091            'z-index': 101
2092        });
2093
2094        NextendTween.set(tab, {
2095            transformStyle: 'preserve-3d',
2096            transformOrigin: animation.direction == 'left' ? '0px 0px' : w2 + 'px 0px'
2097        });
2098
2099        var front = $('<div class="n2-ff-3d"></div>').append(this.clonedCurrent())
2100            .css({
2101                width: w2,
2102                height: this.h,
2103                position: 'absolute',
2104                top: 0,
2105                left: 0,
2106                '-webkit-transform': 'translateZ(0.1px)',
2107                overflow: 'hidden'
2108            })
2109            .appendTo(tab);
2110
2111        NextendTween.set(front, {
2112            backfaceVisibility: 'hidden',
2113            transformStyle: 'preserve-3d'
2114        });
2115
2116
2117        var back = $('<div class="n2-ff-3d"></div>')
2118            .append(this.clonedNext())
2119            .appendTo(tab)
2120            .css({
2121                width: w2,
2122                height: this.h,
2123                position: 'absolute',
2124                top: 0,
2125                left: 0,
2126                overflow: 'hidden'
2127            });
2128
2129        NextendTween.set(back, {
2130            backfaceVisibility: 'hidden',
2131            transformStyle: 'preserve-3d',
2132            rotationY: 180,
2133            rotationZ: 0
2134        });
2135
2136        var current = $('<div></div>')
2137                .append(this.clonedCurrent().clone().css('left', (animation.direction == 'left' ? 0 : -w2))).css({
2138                    position: 'absolute',
2139                    top: 0,
2140                    left: animation.direction == 'left' ? '0' : w2,
2141                    width: w2,
2142                    height: this.h,
2143                    zIndex: 100,
2144                    overflow: 'hidden'
2145                }),
2146            overlay = $('<div class="overlay"></div>').css({
2147                position: 'absolute',
2148                top: 0,
2149                left: animation.direction == 'left' ? w2 : 0,
2150                width: w2,
2151                height: this.h,
2152                background: '#000',
2153                opacity: 1,
2154                overflow: 'hidden'
2155            }),
2156
2157            container = $('<div></div>').css({
2158                width: this.w,
2159                height: this.h,
2160                position: 'absolute',
2161                top: 0,
2162                left: 0
2163            }).append(tab).append(current).append(overlay);
2164
2165
2166        NextendTween.set(container, {
2167            perspective: animation.perspective,
2168            perspectiveOrigin: '50% 50%'
2169        });
2170
2171        this.placeNextImage();
2172        this.clonedImages.nextImage.css({
2173            overflow: 'hidden',
2174            width: '100%',
2175            height: '100%'
2176        });
2177
2178        this.containerElement.append(container);
2179
2180        this.preSetup();
2181
2182        this.timeline.to(tab.get(0), animation.duration * this.durationMultiplier, {
2183            rotationY: (animation.direction == 'left' ? -180 : 180)
2184        }, 0);
2185
2186        this.timeline.to(overlay.get(0), animation.duration * this.durationMultiplier, {
2187            opacity: 0
2188        }, 0);
2189    };
2190
2191    NextendSmartSliderBackgroundAnimationTurn.prototype = Object.create(NextendSmartSliderBackgroundAnimationFluxAbstract.prototype);
2192    NextendSmartSliderBackgroundAnimationTurn.prototype.constructor = NextendSmartSliderBackgroundAnimationTurn;
2193
2194
2195    NextendSmartSliderBackgroundAnimationTurn.prototype.getExtraDelay = function () {
2196        return 0;
2197    };
2198
2199    scope.NextendSmartSliderBackgroundAnimationTurn = NextendSmartSliderBackgroundAnimationTurn;
2200
2201
2202    function NextendSmartSliderBackgroundAnimationExplode() {
2203        NextendSmartSliderBackgroundAnimationTiled.prototype.constructor.apply(this, arguments);
2204    };
2205
2206    NextendSmartSliderBackgroundAnimationExplode.prototype = Object.create(NextendSmartSliderBackgroundAnimationTiled.prototype);
2207    NextendSmartSliderBackgroundAnimationExplode.prototype.constructor = NextendSmartSliderBackgroundAnimationExplode;
2208
2209
2210    NextendSmartSliderBackgroundAnimationExplode.prototype.setup = function () {
2211
2212        var animation = $.extend(true, {
2213            columns: 1,
2214            rows: 1,
2215            reverse: false,
2216            tiles: {
2217                delay: 0, // Delay between the starting of the tiles sequence. Ex.: #1 batch start: 0s, #2: .2s, #3: .4s
2218                sequence: 'Parallel' // Parallel, Random, ForwardCol, BackwardCol, ForwardRow, BackwardRow, ForwardDiagonal, BackwardDiagonal
2219            },
2220            main: {
2221                duration: 0.5,
2222                zIndex: 2, // z-index of the current image. Change it to 2 to show it over the second image.
2223                current: { // Animation of the current tile
2224                    ease: 'easeInOutCubic'
2225                }
2226            }
2227        }, this.animationProperties);
2228
2229        this.placeNextImage();
2230        this.clonedImages.nextImage.css({
2231            overflow: 'hidden',
2232            width: '100%',
2233            height: '100%'
2234        });
2235
2236        NextendSmartSliderBackgroundAnimationTiled.prototype.setup.call(this, animation);
2237    };
2238
2239    NextendSmartSliderBackgroundAnimationExplode.prototype.renderTile = function (tile, w, h, animation, totalLeft, totalTop) {
2240
2241        var current = $('<div></div>')
2242            .css({
2243                position: 'absolute',
2244                left: 0,
2245                top: 0,
2246                width: w,
2247                height: h,
2248                overflow: 'hidden',
2249                zIndex: animation.main.zIndex
2250            })
2251            .append(this.clonedCurrent().clone().css({
2252                position: 'absolute',
2253                top: -totalTop + 'px',
2254                left: -totalLeft + 'px'
2255            }))
2256            .appendTo(tile);
2257
2258        NextendTween.set(tile.get(0), {
2259            transformPerspective: 1000,
2260            transformStyle: "preserve-3d"
2261        });
2262
2263        return {
2264            current: current,
2265            tile: tile
2266        }
2267    };
2268
2269    NextendSmartSliderBackgroundAnimationExplode.prototype.transform = function (animation, animatable, total) {
2270
2271        var current = $.extend(true, {}, animation.main.current);
2272
2273        current.rotationX = (Math.random() * 3 - 1) * 90;
2274        current.rotationY = (Math.random() * 3 - 1) * 90;
2275        current.rotationZ = (Math.random() * 3 - 1) * 90;
2276        this.timeline.to(animatable.tile, animation.main.duration * this.durationMultiplier, current, total);
2277    };
2278
2279    scope.NextendSmartSliderBackgroundAnimationExplode = NextendSmartSliderBackgroundAnimationExplode;
2280
2281
2282    function NextendSmartSliderBackgroundAnimationExplodeReversed() {
2283        NextendSmartSliderBackgroundAnimationTiled.prototype.constructor.apply(this, arguments);
2284    };
2285
2286    NextendSmartSliderBackgroundAnimationExplodeReversed.prototype = Object.create(NextendSmartSliderBackgroundAnimationTiled.prototype);
2287    NextendSmartSliderBackgroundAnimationExplodeReversed.prototype.constructor = NextendSmartSliderBackgroundAnimationExplodeReversed;
2288
2289
2290    NextendSmartSliderBackgroundAnimationExplodeReversed.prototype.setup = function () {
2291
2292        var animation = $.extend(true, {
2293            columns: 1,
2294            rows: 1,
2295            reverse: false,
2296            tiles: {
2297                delay: 0, // Delay between the starting of the tiles sequence. Ex.: #1 batch start: 0s, #2: .2s, #3: .4s
2298                sequence: 'Parallel' // Parallel, Random, ForwardCol, BackwardCol, ForwardRow, BackwardRow, ForwardDiagonal, BackwardDiagonal
2299            },
2300            main: {
2301                duration: 0.5,
2302                zIndex: 2, // z-index of the current image. Change it to 2 to show it over the second image.
2303                current: { // Animation of the current tile
2304                    ease: 'easeInOutCubic'
2305                }
2306            }
2307        }, this.animationProperties);
2308
2309        this.placeCurrentImage();
2310        this.clonedImages.currentImage.css({
2311            overflow: 'hidden',
2312            width: '100%',
2313            height: '100%'
2314        });
2315
2316        NextendSmartSliderBackgroundAnimationTiled.prototype.setup.call(this, animation);
2317    };
2318
2319    NextendSmartSliderBackgroundAnimationExplodeReversed.prototype.renderTile = function (tile, w, h, animation, totalLeft, totalTop) {
2320
2321        var next = $('<div></div>')
2322            .css({
2323                position: 'absolute',
2324                left: 0,
2325                top: 0,
2326                width: w,
2327                height: h,
2328                overflow: 'hidden',
2329                zIndex: animation.main.zIndex
2330            })
2331            .append(this.clonedNext().clone().css({
2332                position: 'absolute',
2333                top: -totalTop + 'px',
2334                left: -totalLeft + 'px'
2335            }))
2336            .appendTo(tile);
2337
2338        NextendTween.set(tile.get(0), {
2339            transformPerspective: 1000,
2340            transformStyle: "preserve-3d"
2341        });
2342
2343        return {
2344            next: next,
2345            tile: tile
2346        }
2347    };
2348
2349    NextendSmartSliderBackgroundAnimationExplodeReversed.prototype.transform = function (animation, animatable, total) {
2350
2351        var current = $.extend(true, {}, animation.main.current);
2352
2353        current.rotationX = (Math.random() * 3 - 1) * 90;
2354        current.rotationY = (Math.random() * 3 - 1) * 90;
2355        current.rotationZ = (Math.random() * 3 - 1) * 30;
2356        this.timeline.from(animatable.tile, animation.main.duration * this.durationMultiplier, current, total);
2357    };
2358
2359    scope.NextendSmartSliderBackgroundAnimationExplodeReversed = NextendSmartSliderBackgroundAnimationExplodeReversed;
2360
2361
2362    function NextendSmartSliderBackgroundAnimationSlixes() {
2363        NextendSmartSliderBackgroundAnimationTiled.prototype.constructor.apply(this, arguments);
2364    };
2365
2366    NextendSmartSliderBackgroundAnimationSlixes.prototype = Object.create(NextendSmartSliderBackgroundAnimationTiled.prototype);
2367    NextendSmartSliderBackgroundAnimationSlixes.prototype.constructor = NextendSmartSliderBackgroun
2367dAnimationSlixes;
2368
2369
2370    NextendSmartSliderBackgroundAnimationSlixes.prototype.setup = function () {
2371
2372        var animation = $.extend(true, {
2373            columns: 2,
2374            rows: 2,
2375            main: {
2376                duration: 2,
2377                zIndex: 2 // z-index of the current image. Change it to 2 to show it over the second image.
2378            }
2379        }, this.animationProperties);
2380
2381        this.placeNextImage();
2382        this.clonedImages.nextImage.css({
2383            overflow: 'hidden',
2384            width: '100%',
2385            height: '100%'
2386        });
2387
2388        NextendSmartSliderBackgroundAnimationTiled.prototype.setup.call(this, animation);
2389    };
2390
2391    NextendSmartSliderBackgroundAnimationSlixes.prototype.renderTile = function (tile, w, h, animation, totalLeft, totalTop) {
2392        this.container.css('overflow', 'hidden');
2393
2394        var current = $('<div></div>')
2395            .css({
2396                position: 'absolute',
2397                left: 0,
2398                top: 0,
2399                width: w,
2400                height: h,
2401                overflow: 'hidden',
2402                zIndex: animation.main.zIndex
2403            })
2404            .append(this.clonedCurrent().clone().css({
2405                position: 'absolute',
2406                top: -totalTop + 'px',
2407                left: -totalLeft + 'px'
2408            }))
2409            .appendTo(tile);
2410
2411        NextendTween.set(tile.get(0), {
2412            transformPerspective: 1000,
2413            transformStyle: "preserve-3d"
2414        });
2415
2416        return {
2417            current: current,
2418            tile: tile
2419        }
2420    };
2421
2422    NextendSmartSliderBackgroundAnimationSlixes.prototype.animate = function (animation, animatables, animatablesMulti) {
2423
2424        this.timeline.to(animatablesMulti[0][0].tile, animation.main.duration * this.durationMultiplier, {
2425            left: '-50%',
2426            ease: 'easeInOutCubic'
2427        }, 0);
2428        this.timeline.to(animatablesMulti[0][1].tile, animation.main.duration * this.durationMultiplier, {
2429            left: '-50%',
2430            ease: 'easeInOutCubic'
2431        }, 0.3);
2432
2433        this.timeline.to(animatablesMulti[1][0].tile, animation.main.duration * this.durationMultiplier, {
2434            left: '100%',
2435            ease: 'easeInOutCubic'
2436        }, 0.15);
2437        this.timeline.to(animatablesMulti[1][1].tile, animation.main.duration * this.durationMultiplier, {
2438            left: '100%',
2439            ease: 'easeInOutCubic'
2440        }, 0.45);
2441
2442        $('<div />').css({
2443            position: 'absolute',
2444            left: 0,
2445            top: 0,
2446            width: '100%',
2447            height: '100%',
2448            overflow: 'hidden'
2449        }).prependTo(this.clonedImages.nextImage.parent()).append(this.clonedImages.nextImage);
2450
2451        this.timeline.fromTo(this.clonedImages.nextImage, animation.main.duration * this.durationMultiplier, {
2452            scale: 1.3
2453        }, {
2454            scale: 1
2455        }, 0.45);
2456    };
2457    scope.NextendSmartSliderBackgroundAnimationSlixes = NextendSmartSliderBackgroundAnimationSlixes;
2458
2459})
2460(n2, window);
2461/**
2462 * Abstract class for all the main animations
2463 * @type {NextendSmartSliderMainAnimationAbstract}
2464 * @abstract
2465 */
2466(function ($, scope, undefined) {
2467    function NextendSmartSliderMainAnimationAbstract(slider, parameters) {
2468
2469        this.state = 'ended';
2470        this.isTouch = false;
2471
2472        this.slider = slider;
2473
2474        this.parameters = $.extend({
2475            duration: 1500,
2476            ease: 'easeInOutQuint'
2477        }, parameters);
2478
2479        this.parameters.duration /= 1000;
2480
2481        this.sliderElement = slider.sliderElement;
2482
2483        this.timeline = new NextendTimeline({
2484            paused: true
2485        });
2486    };
2487
2488    NextendSmartSliderMainAnimationAbstract.prototype.setTouch = function (direction) {
2489        this.isTouch = direction;
2490    };
2491
2492    NextendSmartSliderMainAnimationAbstract.prototype.getState = function () {
2493        return this.state;
2494    };
2495
2496    NextendSmartSliderMainAnimationAbstract.prototype.timeScale = function () {
2497        if (arguments.length > 0) {
2498            this.timeline.timeScale(arguments[0]);
2499            return this;
2500        }
2501        return this.timeline.timeScale();
2502    };
2503
2504    NextendSmartSliderMainAnimationAbstract.prototype.preChangeToPlay = function (deferred, currentSlide, nextSlide) {
2505        var deferredHandled = {
2506            handled: false
2507        };
2508
2509        this.sliderElement.trigger('preChangeToPlay', [deferred, deferredHandled, currentSlide, nextSlide]);
2510
2511        if (!deferredHandled.handled) {
2512            deferred.resolve();
2513        }
2514    };
2515
2516    NextendSmartSliderMainAnimationAbstract.prototype.changeTo = function (currentSlideIndex, currentSlide, nextSlideIndex, nextSlide, reversed, isSystem) {
2517
2518        this._initAnimation(currentSlideIndex, currentSlide, nextSlideIndex, nextSlide, reversed);
2519
2520        this.state = 'initAnimation';
2521
2522        this.timeline.paused(true);
2523        this.timeline.eventCallback('onStart', this.onChangeToStart, [currentSlideIndex, nextSlideIndex, isSystem], this);
2524        this.timeline.eventCallback('onComplete', this.onChangeToComplete, [currentSlideIndex, nextSlideIndex, isSystem], this);
2525
2526        if (this.slider.parameters.dynamicHeight) {
2527            var tl = new NextendTimeline();
2528            this.slider.responsive.doResize(false, tl, nextSlideIndex, 0.6);
2529            this.timeline.add(tl);
2530        }
2531
2532
2533        // If the animation is in touch mode, we do not need to play the timeline as the touch will set the actual progress and also play later...
2534        if (!this.isTouch) {
2535            var deferred = $.Deferred();
2536
2537            deferred.done($.proxy(function () {
2538                this.play();
2539            }, this.timeline));
2540
2541            this.preChangeToPlay(deferred, currentSlide, nextSlide);
2542        } else {
2543            this.slider.callOnSlide(currentSlide, 'onOutAnimationsPlayed');
2544        }
2545    };
2546
2547    /**
2548     * @abstract
2549     * @param currentSlideIndex
2550     * @param currentSlide
2551     * @param nextSlideIndex
2552     * @param nextSlide
2553     * @param reversed
2554     * @private
2555     */
2556    NextendSmartSliderMainAnimationAbstract.prototype._initAnimation = function (currentSlideIndex, currentSlide, nextSlideIndex, nextSlide, reversed) {
2557
2558    };
2559
2560    NextendSmartSliderMainAnimationAbstract.prototype.onChangeToStart = function (previousSlideIndex, currentSlideIndex, isSystem) {
2561
2562        this.state = 'playing';
2563
2564        var parameters = [this, previousSlideIndex, currentSlideIndex, isSystem];
2565
2566        n2c.log('Event: mainAnimationStart: ', parameters, '{NextendSmartSliderMainAnimationAbstract}, previousSlideIndex, currentSlideIndex, isSystem');
2567        this.sliderElement.trigger('mainAnimationStart', parameters);
2568
2569        this.slider.slides.eq(previousSlideIndex).trigger('mainAnimationStartOut', parameters);
2570        this.slider.slides.eq(currentSlideIndex).trigger('mainAnimationStartIn', parameters);
2571    };
2572
2573    NextendSmartSliderMainAnimationAbstract.prototype.onChangeToComplete = function (previousSlideIndex, currentSlideIndex, isSystem) {
2574        var parameters = [this, previousSlideIndex, currentSlideIndex, isSystem];
2575
2576        // When the animation done, clear the timeline
2577        this.timeline.clear();
2578        this.timeline.timeScale(1);
2579
2580        this.slider.slides.eq(previousSlideIndex).trigger('mainAnimationCompleteOut', parameters);
2581        this.slider.slides.eq(currentSlideIndex).trigger('mainAnimationCompleteIn', parameters);
2582
2583        this.state = 'ended';
2584
2585        n2c.log('Event: mainAnimationComplete: ', parameters, '{NextendSmartSliderMainAnimationAbstract}, previousSlideIndex, currentSlideIndex, isSystem');
2586        this.sliderElement.trigger('mainAnimationComplete', parameters);
2587    };
2588
2589    NextendSmartSliderMainAnimationAbstract.prototype.getEase = function () {
2590        if (this.isTouch) {
2591            return 'linear';
2592        }
2593        return this.parameters.ease;
2594    };
2595    scope.NextendSmartSliderMainAnimationAbstract = NextendSmartSliderMainAnimationAbstract;
2596})(n2, window);
2597(function ($, scope, undefined) {
2598    function NextendSmartSliderControlAutoplay(slider, parameters) {
2599        this._inited = false;
2600        this._active = false;
2601        this._disabled = false;
2602        this._currentCount = 0;
2603        this._progressEnabled = false;
2604        this.timeline = null;
2605
2606        this.deferredsMediaPlaying = null;
2607        this.deferredMouseLeave = null;
2608        this.deferredMouseEnter = null;
2609        this.mainAnimationDeferred = true;
2610        this.autoplayDeferred = null;
2611
2612        this.slider = slider;
2613
2614        this.parameters = $.extend({
2615            enabled: 0,
2616            start: 1,
2617            duration: 8000,
2618            autoplayToSlide: 0,
2619            pause: {
2620                mouse: 'enter',
2621                click: true,
2622                mediaStarted: true
2623            },
2624            resume: {
2625                click: 0,
2626                mouse: 0,
2627                mediaEnded: true
2628            }
2629        }, parameters);
2630
2631        if (this.parameters.enabled) {
2632
2633            this.parameters.duration /= 1000;
2634
2635            slider.controls.autoplay = this;
2636
2637            this.deferredsExtraPlaying = {};
2638
2639            this.slider.visible($.proxy(this.onReady, this));
2640
2641        } else {
2642            this.disable();
2643        }
2644
2645        slider.controls.autoplay = this;
2646    };
2647
2648    NextendSmartSliderControlAutoplay.prototype.onReady = function () {
2649        this.autoplayDeferred = $.Deferred();
2650
2651        var obj = {
2652            _progress: 0
2653        };
2654        this.timeline = NextendTween.to(obj, this.getSlideDuration(this.slider.currentSlideIndex), {
2655            _progress: 1,
2656            paused: true,
2657            onComplete: $.proxy(this.next, this)
2658        });
2659
2660        if (this._progressEnabled) {
2661            this.enableProgress();
2662        }
2663
2664
2665        var sliderElement = this.slider.sliderElement;
2666
2667        if (this.parameters.start) {
2668            this.continueAutoplay();
2669        }
2670
2671        sliderElement.on('mainAnimationStart.autoplay', $.proxy(this.onMainAnimationStart, this));
2672
2673        if (this.parameters.pause.mouse != '0') {
2674            switch (this.parameters.pause.mouse) {
2675                case 'enter':
2676                    sliderElement.on('mouseenter.autoplay', $.proxy(this.pauseAutoplayMouseEnter, this));
2677                    sliderElement.on('mouseleave.autoplay', $.proxy(this.pauseAutoplayMouseEnterEnded, this));
2678                    break;
2679                case 'leave':
2680                    sliderElement.on('mouseleave.autoplay', $.proxy(this.pauseAutoplayMouseLeave, this));
2681                    sliderElement.on('mouseenter.autoplay', $.proxy(this.pauseAutoplayMouseLeaveEnded, this));
2682                    break;
2683            }
2684        }
2685        if (this.parameters.pause.click && !this.parameters.resume.click) {
2686            sliderElement.on('universalclick.autoplay', $.proxy(this.pauseAutoplayUniversal, this));
2687        } else if (!this.parameters.pause.click && this.parameters.resume.click) {
2688            sliderElement.on('universalclick.autoplay', $.proxy(this.continueAutoplay, this));
2689        } else {
2690            sliderElement.on('universalclick.autoplay', $.proxy(function (e) {
2691                if (this._active) {
2692                    this.pauseAutoplayUniversal(e);
2693                } else {
2694                    this.continueAutoplay(e);
2695                }
2696            }, this));
2697        }
2698        if (this.parameters.pause.mediaStarted) {
2699            this.deferredsMediaPlaying = {};
2700            sliderElement.on('mediaStarted.autoplay', $.proxy(this.pauseAutoplayMediaPlaying, this));
2701            sliderElement.on('mediaEnded.autoplay', $.proxy(this.pauseAutoplayMediaPlayingEnded, this));
2702        }
2703
2704        if (this.parameters.resume.mouse != '0') {
2705            switch (this.parameters.resume.mouse) {
2706                case 'enter':
2707                    sliderElement.on('mouseenter.autoplay', $.proxy(this.continueAutoplay, this));
2708                    break;
2709                case 'leave':
2710                    sliderElement.on('mouseleave.autoplay', $.proxy(this.continueAutoplay, this));
2711                    break;
2712            }
2713        }
2714
2715        if (this.parameters.resume.mediaEnded) {
2716            sliderElement.on('mediaEnded.autoplay', $.proxy(this.continueAutoplay, this));
2717        }
2718        sliderElement.on('autoplayExtraWait.autoplay', $.proxy(this.pauseAutoplayExtraPlaying, this));
2719        sliderElement.on('autoplayExtraContinue.autoplay', $.proxy(this.pauseAutoplayExtraPlayingEnded, this));
2720
2721    };
2722
2723    NextendSmartSliderControlAutoplay.prototype.enableProgress = function () {
2724        if (this.timeline) {
2725            this.timeline.eventCallback('onUpdate', $.proxy(this.onUpdate, this));
2726        }
2727        this._progressEnabled = true;
2728    };
2729
2730
2731    NextendSmartSliderControlAutoplay.prototype.onMainAnimationStart = function (e, animation, previousSlideIndex, currentSlideIndex, isSystem) {
2732        this.mainAnimationDeferred = $.Deferred();
2733        this.deActivate(0);
2734    };
2735
2736    NextendSmartSliderControlAutoplay.prototype.onMainAnimationComplete = function (e, animation, previousSlideIndex, currentSlideIndex) {
2737        this.timeline.duration(this.getSlideDuration(currentSlideIndex));
2738
2739        this.mainAnimationDeferred.resolve();
2740
2741        this.continueAutoplay();
2742    };
2743
2744    NextendSmartSliderControlAutoplay.prototype.getSlideDuration = function (index) {
2745        var slide = this.slider.realSlides.eq(this.slider.getRealIndex(index)).data('slide'),
2746            duration = slide.minimumSlideDuration;
2747
2748        if (duration < 0.3 && duration < this.parameters.duration) {
2749            duration = this.parameters.duration;
2750        }
2751        return duration;
2752    };
2753
2754    NextendSmartSliderControlAutoplay.prototype.continueAutoplay = function (e) {
2755        if (this.autoplayDeferred.state() == 'pending') {
2756            this.autoplayDeferred.reject();
2757        }
2758        var deferreds = [];
2759        for (var k in this.deferredsExtraPlaying) {
2760            deferreds.push(this.deferredsExtraPlaying[k]);
2761        }
2762        for (var k in this.deferredsMediaPlaying) {
2763            deferreds.push(this.deferredsMediaPlaying[k]);
2764        }
2765        deferreds.push(this.deferredMouseEnter);
2766        deferreds.push(this.mainAnimationDeferred);
2767
2768        this.autoplayDeferred = $.Deferred();
2769        this.autoplayDeferred.done($.proxy(this._continueAutoplay, this));
2770
2771        $.when.apply($, deferreds).done($.proxy(function () {
2772            if (this.autoplayDeferred.state() == 'pending') {
2773                this.autoplayDeferred.resolve();
2774            }
2775        }, this));
2776    };
2777
2778    NextendSmartSliderControlAutoplay.prototype._continueAutoplay = function () {
2779        if (!this._active && !this._disabled) {
2780            this._active = true;
2781            if (!this._inited) {
2782                this.slider.sliderElement.on('mainAnimationComplete.auto
2782play', $.proxy(this.onMainAnimationComplete, this));
2783                this._inited = true;
2784            }
2785            n2c.log('Event: autoplayStarted');
2786            this.slider.sliderElement.triggerHandler('autoplayStarted');
2787
2788            if (this.timeline.progress() == 1) {
2789                this.timeline.pause(0, false);
2790            }
2791
2792            this.startTimeout(null);
2793        }
2794    };
2795
2796    NextendSmartSliderControlAutoplay.prototype.pauseAutoplayUniversal = function () {
2797        this.autoplayDeferred.reject();
2798        this.deActivate(null);
2799    };
2800
2801    NextendSmartSliderControlAutoplay.prototype.pauseAutoplayMouseEnter = function () {
2802        this.autoplayDeferred.reject();
2803        this.deferredMouseEnter = $.Deferred();
2804        this.deActivate(null);
2805    };
2806
2807    NextendSmartSliderControlAutoplay.prototype.pauseAutoplayMouseEnterEnded = function () {
2808        if (this.deferredMouseEnter) {
2809            this.deferredMouseEnter.resolve();
2810        }
2811    };
2812
2813    NextendSmartSliderControlAutoplay.prototype.pauseAutoplayMouseLeave = function () {
2814        this.autoplayDeferred.reject();
2815        this.deferredMouseLeave = $.Deferred();
2816        this.deActivate(null);
2817    };
2818
2819    NextendSmartSliderControlAutoplay.prototype.pauseAutoplayMouseLeaveEnded = function () {
2820        if (this.deferredMouseLeave) {
2821            this.deferredMouseLeave.resolve();
2822        }
2823    };
2824
2825    NextendSmartSliderControlAutoplay.prototype.pauseAutoplayMediaPlaying = function (e, obj) {
2826        if (typeof this.deferredsMediaPlaying[obj] !== 'undefined') {
2827            this.autoplayDeferred.reject();
2828        }
2829        this.deferredsMediaPlaying[obj] = $.Deferred();
2830        this.deActivate(null);
2831    };
2832
2833    NextendSmartSliderControlAutoplay.prototype.pauseAutoplayMediaPlayingEnded = function (e, obj) {
2834        if (typeof this.deferredsMediaPlaying[obj] !== 'undefined') {
2835            this.autoplayDeferred.reject();
2836            this.deferredsMediaPlaying[obj].resolve();
2837            delete this.deferredsMediaPlaying[obj];
2838        }
2839    };
2840
2841    NextendSmartSliderControlAutoplay.prototype.pauseAutoplayExtraPlaying = function (e, obj) {
2842        if (typeof this.deferredsExtraPlaying[obj] !== 'undefined') {
2843            this.autoplayDeferred.reject();
2844        }
2845        this.deferredsExtraPlaying[obj] = $.Deferred();
2846        this.deActivate(null);
2847    };
2848
2849    NextendSmartSliderControlAutoplay.prototype.pauseAutoplayExtraPlayingEnded = function (e, obj) {
2850        if (typeof this.deferredsExtraPlaying[obj] !== 'undefined') {
2851            this.autoplayDeferred.reject();
2852            this.deferredsExtraPlaying[obj].resolve();
2853            delete this.deferredsExtraPlaying[obj];
2854        }
2855        this.continueAutoplay();
2856    };
2857
2858    NextendSmartSliderControlAutoplay.prototype.deActivate = function (seekTo) {
2859        if (this._active) {
2860            this._active = false;
2861            if (seekTo !== 0) {
2862                n2c.log('Event: autoplayPaused');
2863                this.slider.sliderElement.triggerHandler('autoplayPaused');
2864            }
2865        }
2866
2867        if (this.timeline) {
2868            this.timeline.pause(seekTo, false);
2869        }
2870    };
2871
2872    NextendSmartSliderControlAutoplay.prototype.disable = function () {
2873        this.deActivate(0);
2874        this.slider.sliderElement.triggerHandler('autoplayPaused');
2875        this.slider.sliderElement.triggerHandler('autoplayDisabled');
2876        this.slider.sliderElement.off('.autoplay');
2877        n2c.log('Autoplay: disable');
2878        this._disabled = true;
2879    };
2880
2881    NextendSmartSliderControlAutoplay.prototype.startTimeout = function (time) {
2882        if (this._active && !this._disabled) {
2883            this.timeline.play(time);
2884        }
2885    };
2886
2887    NextendSmartSliderControlAutoplay.prototype.next = function () {
2888        this.timeline.pause();
2889        this._currentCount++;
2890        /**
2891         * We have reached the maximum slides in the autoplay so disable it completely
2892         */
2893        if (this.parameters.autoplayToSlide > 0 && this._currentCount >= this.parameters.autoplayToSlide) {
2894            n2c.log('Autoplay: auto play to slide value reached');
2895            this.disable();
2896        }
2897
2898        this.slider.nextCarousel(true);
2899    };
2900
2901    NextendSmartSliderControlAutoplay.prototype.onUpdate = function () {
2902        this.slider.sliderElement.triggerHandler('autoplay', this.timeline.progress());
2903    };
2904
2905    scope.NextendSmartSliderControlAutoplay = NextendSmartSliderControlAutoplay;
2906})(n2, window);
2907(function ($, scope, undefined) {
2908    "use strict";
2909    function NextendSmartSliderControlKeyboard(slider, direction, parameters) {
2910
2911        this.slider = slider;
2912
2913        this.parameters = $.extend({}, parameters);
2914
2915        if (direction == 'vertical') {
2916            this.parseEvent = NextendSmartSliderControlKeyboard.prototype.parseEventVertical;
2917        } else {
2918            this.parseEvent = NextendSmartSliderControlKeyboard.prototype.parseEventHorizontal;
2919        }
2920
2921        $(document).on('keydown', $.proxy(this.onKeyDown, this));
2922
2923        slider.controls.keyboard = this;
2924    };
2925
2926    NextendSmartSliderControlKeyboard.prototype.onKeyDown = function (e) {
2927
2928        if (e.target.tagName.match(/BODY|DIV|IMG/)) {
2929            e = e || window.event;
2930            if (this.parseEvent.call(this, e)) {
2931                e.preventDefault();
2932            }
2933        }
2934    };
2935
2936    NextendSmartSliderControlKeyboard.prototype.parseEventHorizontal = function (e) {
2937        switch (e.keyCode) {
2938            case 39: // right arrow
2939                this.slider.next();
2940                return true;
2941            case 37: // left arrow
2942                this.slider.previous();
2943                return true;
2944            default:
2945                return false;
2946        }
2947    };
2948
2949    NextendSmartSliderControlKeyboard.prototype.parseEventVertical = function (e) {
2950        switch (e.keyCode) {
2951            case 40: // down arrow
2952                this.slider.next();
2953                return true;
2954            case 38: // up arrow
2955                this.slider.previous();
2956                return true;
2957            default:
2958                return false;
2959        }
2960    };
2961    scope.NextendSmartSliderControlKeyboard = NextendSmartSliderControlKeyboard;
2962})(n2, window);
2963(function ($, scope, undefined) {
2964    "use strict";
2965    function NextendSmartSliderControlScroll(slider) {
2966
2967        this.preventScroll = false
2968
2969        this.slider = slider;
2970
2971        // handled by jquery.mousewheel.js
2972        slider.sliderElement.on('mousewheel', $.proxy(this.onMouseWheel, this));
2973
2974        slider.controls.scroll = this;
2975    };
2976
2977    NextendSmartSliderControlScroll.prototype.onMouseWheel = function (e) {
2978        if (!this.preventScroll) {
2979            this.preventScroll = true;
2980            if (e.deltaY > 0) {
2981                if (this.slider.previous()) {
2982                    // Stops the browser normal scroll
2983                    e.preventDefault();
2984                }
2985            } else {
2986                if (this.slider.next()) {
2987                    // Stops the browser normal scroll
2988                    e.preventDefault();
2989                }
2990            }
2991            setTimeout($.proxy(function () {
2992                this.preventScroll = false;
2993            }, this), 400);
2994        } else {
2995            e.preventDefault();
2996        }
2997    };
2998    scope.NextendSmartSliderControlScroll = NextendSmartSliderControlScroll;
2999})(n2, window);
3000(function ($, scope, undefined) {
3001    "use strict";
3002    function NextendSmartSliderControlTilt(slider, parameters) {
3003
3004        if (typeof window.DeviceOrientationEvent == 'undefined' || typeof window.orientation == 'undefined') {
3005            return "Not supported";
3006        }
3007        this.timeout = null;
3008
3009        this.slider = slider;
3010
3011        this.parameters = $.extend({
3012            duration: 2000
3013        }, parameters);
3014
3015        this.orientationchange();
3016
3017        window.addEventListener('orientationchange', $.proxy(this.orientationchange, this));
3018
3019        window.addEventListener("deviceorientation", $.proxy(this.handleOrientation, this), true);
3020
3021        slider.controls.tilt = this;
3022    };
3023
3024    NextendSmartSliderControlTilt.prototype.orientationchange = function () {
3025        switch (window.orientation) {
3026            case -90:
3027            case 90:
3028                this.parseEvent = NextendSmartSliderControlTilt.prototype.parseEventHorizontalLandscape;
3029                break;
3030            default:
3031                this.parseEvent = NextendSmartSliderControlTilt.prototype.parseEventHorizontal;
3032                break;
3033        }
3034    };
3035
3036    NextendSmartSliderControlTilt.prototype.clearTimeout = function () {
3037        this.timeout = null;
3038    };
3039
3040    NextendSmartSliderControlTilt.prototype.handleOrientation = function (e) {
3041        if (this.timeout == null && this.parseEvent.call(this, e)) {
3042            this.timeout = setTimeout($.proxy(this.clearTimeout, this), this.parameters.duration);
3043
3044            e.preventDefault();
3045        }
3046    };
3047
3048    NextendSmartSliderControlTilt.prototype.parseEventHorizontal = function (e) {
3049        if (e.gamma > 10) { // right tilt
3050            this.slider.next();
3051            return true;
3052        } else if (e.gamma < -10) { // left tilt
3053            this.slider.previous();
3054            return true;
3055        }
3056        return false;
3057    };
3058
3059    NextendSmartSliderControlTilt.prototype.parseEventHorizontalLandscape = function (e) {
3060        if (e.beta < -10) { // right tilt
3061            this.slider.next();
3062            return true;
3063        } else if (e.beta > 10) { // left tilt
3064            this.slider.previous();
3065            return true;
3066        }
3067        return false;
3068    };
3069
3070    scope.NextendSmartSliderControlTilt = NextendSmartSliderControlTilt;
3071
3072})(n2, window);
3073(function ($, scope, undefined) {
3074    "use strict";
3075    var pointer = window.navigator.pointerEnabled || window.navigator.msPointerEnabled;
3076
3077    function NextendSmartSliderControlTouch(slider, direction, parameters) {
3078        this.currentAnimation = null;
3079        this.slider = slider;
3080
3081        this._animation = slider.mainAnimation;
3082
3083        this.parameters = $.extend({
3084            fallbackToMouseEvents: true
3085        }, parameters);
3086
3087        this.swipeElement = this.slider.sliderElement.find('> div').eq(0);
3088
3089        if (direction == 'vertical') {
3090            this.setVertical();
3091        } else if (direction == 'horizontal') {
3092            this.setHorizontal();
3093        }
3094
3095        this.swipeElement.addClass('unselectable').swipe({
3096            axis: this._direction.axis,
3097            threshold: 10,
3098            preventDefaultEvents: false,
3099            triggerOnTouchLeave: true,
3100            fallbackToMouseEvents: this.parameters.fallbackToMouseEvents,
3101            swipeStatus: $.proxy(this.onSwipeStatus, this),
3102            tap: $.proxy(this.onTap, this)
3103        }).on('dragstart', function (e) {
3104            e.preventDefault();
3105        });
3106
3107        if (!this.parameters.fallbackToMouseEvents) {
3108            this.swipeElement.on('click', $.proxy(this.onTap, this));
3109        }
3110
3111        if (this.parameters.fallbackToMouseEvents) {
3112            this.swipeElement.addClass('n2-grab');
3113        }
3114
3115        slider.controls.touch = this;
3116    };
3117
3118    NextendSmartSliderControlTouch.prototype.setHorizontal = function () {
3119
3120        this._property = 'width';
3121
3122        this._direction = {
3123            left: 'next',
3124            right: 'previous',
3125            up: null,
3126            down: null,
3127            axis: 'horizontal'
3128        };
3129
3130        if (pointer) {
3131            this.swipeElement.css('-ms-touch-action', 'pan-y');
3132            this.swipeElement.css('touch-action', 'pan-y');
3133        }
3134    };
3135
3136    NextendSmartSliderControlTouch.prototype.setVertical = function () {
3137
3138        this._property = 'height';
3139
3140        this._direction = {
3141            left: null,
3142            right: null,
3143            up: 'next',
3144            down: 'previous',
3145            axis: 'vertical'
3146        };
3147
3148        if (pointer) {
3149            this.swipeElement.css('-ms-touch-action', 'pan-x');
3150            this.swipeElement.css('touch-action', 'pan-x');
3151        }
3152    };
3153
3154    NextendSmartSliderControlTouch.prototype.onSwipeStatus = function (event, phase, direction, distance, duration, fingers) {
3155        if (distance > 10 && direction != null && this._direction[direction] !== null) {
3156            event.preventDefault();
3157            if (this.currentAnimation === null) {
3158                if (this._animation.state != 'ended') {
3159                    // skip the event as the current animation is still playing
3160                    return;
3161                }
3162                this.swipeElement.addClass('n2-grabbing');
3163
3164                // Force the main animation into touch mode horizontal/vertical
3165                this._animation.setTouch(this._direction.axis);
3166
3167                this.currentAnimation = {
3168                    direction: direction,
3169                    percent: 0
3170                };
3171                this.slider[this._direction[direction]](false);
3172
3173            }
3174            if (this.currentAnimation.percent < 1 && this.currentAnimation.direction == direction) {
3175                var percent = distance / this.slider.dimensions.slider[this._property];
3176                if (percent <= 1) {
3177                    this.currentAnimation.percent = percent;
3178                    this._animation.timeline.progress(percent);
3179                }
3180            }
3181        }
3182
3183        /**
3184         * The direction can be different for the last "action", so this block can't be in the previous if statement
3185         */
3186        if (this.currentAnimation !== null && (phase == "end" || phase == "cancel")) {
3187            var progress = this._animation.timeline.progress();
3188            if (progress != 1) {
3189                var totalDuration = this._animation.timeline.totalDuration(),
3190                    modifiedDuration = Math.max(totalDuration / 3, Math.min(totalDuration, duration / progress / 1000));
3191                if (modifiedDuration != totalDuration) {
3192                    this._animation.timeline.totalDuration(modifiedDuration);
3193                }
3194                this._animation.timeline.play();
3195            }
3196            this.swipeElement.removeClass('n2-grabbing');
3197
3198            // Switch back the animation into the original mode when our touch is ended
3199            this._animation.setTouch(false);
3200            this.currentAnimation = null;
3201        }
3202    };
3203
3204    NextendSmartSliderControlTouch.prototype.onTap = function (e) {
3205        if ((e.type != 'mouseup' || e.which == 1) && e.type != 'mouseout') {
3206            $(e.target).trigger('n2click');
3207        }
3208    };
3209
3210    scope.NextendSmartSliderControlTouch = NextendSmartSliderControlTouch;
3211
3212})(n2, window);
3213(function ($, scope, undefined) {
3214
3215    /**
3216     * NOT_INITIALIZED -> INITIALIZED -> READY_TO_START -> PLAYING -> ENDED
3217     *                          <-----------------------------/
3218     */
3219    var SlideStatus = {
3220            NOT_INITIALIZED: -1,
3221            INITIALIZED: 0,
3222            READY_TO_START: 1,
3223            PLAYING: 2,
3224            ENDED: 3
3225        },
3226        TimelineMode = {
3227            event: 0,
3228            linear: 1
3229        },
3230        LayerStatus = {
3231            NOT_INITIALIZED: -1,
3232            INITIALIZED: 1,
3233            PLAY_IN_DISABLED: 2,
3234            PLAY_IN_STARTED: 3,
3235            PLAY_IN_PAUSED: 4,
3236            PLAY_IN_ENDED: 5,
3237            PLAY_LOOP_STARTED: 6,
3238            PLAY_LOOP_PAUSED: 7,
3239            PLAY_LOOP_ENDED: 8,
3240            PLAY_OUT_STARTED: 9,
3241            PLAY_OUT_PAUSED: 10,
3242            PLAY_OUT_ENDED: 11
3243        },
3244        In = {
3245            NOT_INITIALIZED: -1,
3246            NO: 0,
3247            INITIALIZED: 1
3248        },
3249        Loop = {
3250            NOT_INITIALIZED: -1,
3251            NO: 0,
3252            INITIALIZED: 1
3253        },
3254        Out = {
3255            NOT_INITIALIZED: -1,
3256            NO: 0,
3257            INITIALIZED: 1
3258        },
3259        zero = {
3260            opacity: 1,
3261            x: 0,
3262            y: 0,
3263            z: 0,
3264            rotationX: 0,
3265            rotationY: 0,
3266            rotationZ: 0,
3267            scaleX: 1,
3268            scaleY: 1,
3269            scaleZ: 1,
3270            skewX: 0
3271        },
3272        responsiveProperties = ['left', 'top', 'width', 'height'];
3273
3274
3275    if (/(MSIE\ [0-7]\.\d+)/.test(navigator.userAgent)) {
3276        function getPos($element) {
3277            return $element.position();
3278        }
3279    } else {
3280        function getPos($element) {
3281            return {
3282                left: $element.prop('offsetLeft'),
3283                top: $element.prop('offsetTop')
3284            }
3285        }
3286    }
3287
3288    function Slide(slider, $slideElement, isFirstSlide, isStaticSlide) {
3289        if (typeof isStaticSlide === 'undefined') {
3290            isStaticSlide = false;
3291        }
3292        this.isStaticSlide = isStaticSlide;
3293        this.status = SlideStatus.NOT_INITIALIZED;
3294        this.slider = slider;
3295        this.slider.isFirstSlide = true;
3296
3297        this.$slideElement = $slideElement;
3298
3299        $slideElement.data('slide', this);
3300
3301        if (!slider.parameters.admin) {
3302            this.minimumSlideDuration = $slideElement.data('slide-duration');
3303            if (!$.isNumeric(this.minimumSlideDuration)) {
3304                this.minimumSlideDuration = 0;
3305            }
3306        } else {
3307            this.minimumSlideDuration = 0;
3308        }
3309
3310        this.findLayers();
3311
3312        if (!this.slider.parameters.admin || !$slideElement.is(this.slider.adminGetCurrentSlideElement())) {
3313            this.initResponsiveMode();
3314        }
3315
3316        this.status = SlideStatus.INITIALIZED;
3317
3318        this.playOnce = (!this.slider.isAdmin && this.slider.parameters.layerMode.playOnce);
3319    };
3320
3321    Slide.prototype.isActive = function () {
3322        return this.$slideElement.hasClass('n2-ss-slide-active');
3323    };
3324
3325    Slide.prototype.findLayers = function () {
3326        this.$layers = this.$slideElement.find('.n2-ss-layer')
3327            .each($.proxy(function (i, el) {
3328                var $el = $(el);
3329                for (var j = 0; j < responsiveProperties.length; j++) {
3330                    var property = responsiveProperties[j];
3331                    $el.data('desktop' + property, parseFloat(el.style[property]));
3332                }
3333                var parent = this.getLayerProperty($el, 'parentid');
3334                if (typeof parent !== 'undefined' && parent) {
3335                    parent = $('#' + parent);
3336                    if (parent.length > 0) {
3337                        $el.data('parent', parent);
3338                    }
3339                } else {
3340                    $el.data('parent', false);
3341                }
3342            }, this));
3343        this.$parallax = this.$layers.filter('[data-parallax]');
3344    };
3345
3346    Slide.prototype.getLayerResponsiveProperty = function (layer, mode, property) {
3347        var value = layer.data(mode + property);
3348        if (typeof value != 'undefined') {
3349            return value;
3350        }
3351        if (mode != 'desktopportrait') {
3352            return layer.data('desktopportrait' + property);
3353        }
3354        return 0;
3355    };
3356
3357    Slide.prototype.getLayerProperty = function (layer, property) {
3358        return layer.data(property);
3359    };
3360
3361    Slide.prototype.initResponsiveMode = function () {
3362        this.slider.sliderElement.on('SliderDeviceOrientation', $.proxy(function (e, modes) {
3363            var mode = modes.device + modes.orientation.toLowerCase();
3364            this.currentMode = mode;
3365            this.$layers.each($.proxy(function (i, el) {
3366                var layer = $(el),
3367                    show = layer.data(mode),
3368                    parent = layer.data('parent');
3369                if ((typeof show == 'undefined' || parseInt(show))) {
3370                    if (this.getLayerProperty(layer, 'adaptivefont')) {
3371                        layer.css('font-size', (16 * this.getLayerResponsiveProperty(layer, this.currentMode, 'fontsize') / 100) + 'px');
3372                    } else {
3373                        layer.css('font-size', this.getLayerResponsiveProperty(layer, this.currentMode, 'fontsize') + '%');
3374                    }
3375                    layer.data('shows', 1);
3376                    layer.css('display', 'block');
3377                } else {
3378                    layer.data('shows', 0);
3379                    layer.css('display', 'none');
3380                }
3381            }, this));
3382        }, this))
3383            .on('SliderResize', $.proxy(function (e, ratios, responsive) {
3384
3385                var dimensions = responsive.responsiveDimensions;
3386
3387                this.$layers.each($.proxy(function (i, el) {
3388                    this.repositionLayer($(el), ratios, dimensions);
3389                }, this));
3390            }, this));
3391    };
3392
3393    Slide.prototype.isDimensionPropertyAccepted = function (value) {
3394        if ((value + '').match(/[0-9]+%/) || value == 'auto') {
3395            return true;
3396        }
3397        return false;
3398    };
3399
3400    Slide.prototype.repositionLayer = function (layer, ratios, dimensions) {
3401        var ratioPositionH = ratios.slideW,
3402            ratioSizeH = ratioPositionH,
3403            ratioPositionV = ratios.slideH,
3404            ratioSizeV = ratioPositionV;
3405
3406        if (!parseInt(this.getLayerProperty(layer, 'responsivesize'))) {
3407            ratioSizeH = ratioSizeV = 1;
3408        }
3409
3410        var width = this.getLayerResponsiveProperty(layer, this.currentMode, 'width');
3411        layer.css('width', this.isDimensionPropertyAccepted(width) ? width : (width * ratioSizeH) + 'px');
3412        var height = this.getLayerResponsiveProperty(layer, this.currentMode, 'height');
3413        layer.css('height', this.isDimensionPropertyAccepted(height) ? height : (height * ratioSizeV) + 'px');
3414
3415        if (!parseInt(this.getLayerProperty(layer, 'responsiveposition'))) {
3416            ratioPositionH = ratioPositionV = 1;
3417        }
3418
3419
3420        var left = this.getLayerResponsiveProperty(layer, this.currentMode, 'left') * ratioPositionH,
3421            top = this.getLayerResponsiveProperty(layer, this.currentMode, 'top') * ratioPositionV,
3422            align = this.getLayerResponsiveProperty(layer, this.currentMode, 'align'),
3423            valign = this.getLayerResponsiveProperty(layer, this.currentMode, 'valign');
3424
3425
3426        var positionCSS = {
3427                left: 'auto',
3428                top: 'auto',
3429                right: 'auto',
3430                bottom: 'auto'
3431            },
3432            parent = this.getLayerProperty(layer, 'parent');
3433
3434        if (parent && parent.data('shows')) {
3435            var position = getPos(parent),
3436                p = {left: 0, top: 0};
3437
3438            switch (this.getLayerResponsiveProperty(layer, this.currentMode, 'parentalign')) {
3439                case 'right':
3440                    p.left = position.left + parent.width();
3441                    break;
3442                case 'center':
3443                    p.left = position.left + parent.width() / 2;
3444                    break;
3445                default:
3446                    p.left = position.left;
3447            }
3448
3449            switch (align) {
3450                case 'right':
3451                    positionCSS.right = (layer.parent().width() - p.left - left) + 'px';
3452                    break;
3453                case 'center':
3454                    positionCSS.left = (p.left + left - layer.width() / 2) + 'px';
3455                    break;
3456                default:
3457                    positionCSS.left = (p.left + left) + 'px';
3458                    break;
3459            }
3460
3461
3462            switch (this.getLayerResponsiveProperty(layer, this.currentMode, 'parentvalign')) {
3463                case 'bottom':
3464                    p.top = position.top + parent.height();
3465                    break;
3466                case 'middle':
3467                    p.top = position.top + parent.height() / 2;
3468                    break;
3469                default:
3470                    p.top = position.top;
3471            }
3472
3473            switch (valign) {
3474                case 'bottom':
3475                    positionCSS.bottom = (layer.parent().height() - p.top - top) + 'px';
3476                    break;
3477                case 'middle':
3478                    positionCSS.top = (p.top + top - layer.height() / 2) + 'px';
3479                    break;
3480                default:
3481                    positionCSS.top = (p.top + top) + 'px';
3482                    break;
3483            }
3484
3485
3486        } else {
3487            switch (align) {
3488                case 'right':
3489                    positionCSS.right = -left + 'px';
3490                    break;
3491                case 'center':
3492                    positionCSS.left = ((this.isStaticSlide ? layer.parent().width() : dimensions.slide.width) / 2 + left - layer.width() / 2) + 'px';
3493                    break;
3494                default:
3495                    positionCSS.left = left + 'px';
3496                    break;
3497            }
3498
3499            switch (valign) {
3500                case 'bottom':
3501                    positionCSS.bottom = -top + 'px';
3502                    break;
3503                case 'middle':
3504                    positionCSS.top = ((this.isStaticSlide ? layer.parent().height() : dimensions.slide.height) / 2 + top - layer.height() / 2) + 'px';
3505                    break;
3506                default:
3507                    positionCSS.top = top + 'px';
3508                    break;
3509            }
3510        }
3511        layer.css(positionCSS);
3512    };
3513
3514    Slide.prototype.setZero = function () {
3515        this.$slideElement.trigger('layerSetZero', this);
3516    };
3517
3518    Slide.prototype.setZeroAll = function () {
3519        this.$slideElement.trigger('layerSetZeroAll', this);
3520    };
3521
3522    Slide.prototype.setStart = function () {
3523        if (this.status == SlideStatus.INITIALIZED) {
3524            this.$slideElement.trigger('layerAnimationSetStart');
3525            this.status = SlideStatus.READY_TO_START;
3526        }
3527    };
3528
3529    Slide.prototype.playIn = function () {
3530        if (this.status == SlideStatus.READY_TO_START) {
3531            this.status = SlideStatus.PLAYING;
3532            this.$slideElement.trigger('layerAnimationPlayIn');
3533        }
3534    };
3535
3536    Slide.prototype.playOut = function () {
3537        if (this.status == SlideStatus.PLAYING) {
3538            var deferreds = [];
3539            this.$slideElement.triggerHandler('beforeMainSwitch', [deferreds]);
3540
3541            $.when.apply($, deferreds)
3542                .done($.proxy(function () {
3543                    this.onOutAnimationsPlayed();
3544                }, this));
3545        } else {
3546            this.onOutAnimationsPlayed();
3547        }
3548    };
3549
3550    Slide.prototype.onOutAnimationsPlayed = function () {
3551        if (!this.playOnce) {
3552            this.status = SlideStatus.INITIALIZED;
3553        } else {
3554            this.status = SlideStatus.ENDED;
3555        }
3556        this.$slideElement.trigger('layerAnimationCompleteOut');
3557    };
3558
3559    Slide.prototype.pause = function () {
3560        this.$slideElement.triggerHandler('layerPause');
3561    };
3562
3563    Slide.prototype.reset = function () {
3564        this.$slideElement.triggerHandler('layerReset');
3565        this.status = SlideStatus.INITIALIZED;
3566    };
3567
3568    Slide.prototype.getTimeline = function () {
3569        return this.layers.getTimeline();
3570    };
3571
3572    scope.NextendSmartSliderSlide = Slide;
3573
3574    function SlideLayers(slide, $layers, mode, ratios) {
3575        this.layerAnimations = [];
3576        this.slide = slide;
3577        slide.$slideElement.off(".n2-ss-animations");
3578        for (var i = 0; i < $layers.length; i++) {
3579            var $layer = $layers.eq(i);
3580            this.layerAnimations.push(new SlideLayerAnimations(slide, this, $layer, $layer.find('.n2-ss-layer-mask, .n2-ss-layer-parallax').addBack().last(
3580), mode, ratios));
3581        }
3582    };
3583
3584    SlideLayers.prototype.refresh = function (ratios) {
3585        for (var i = 0; i < this.layerAnimations.length; i++) {
3586            this.layerAnimations[i].refresh(ratios);
3587        }
3588    };
3589
3590    SlideLayers.prototype.getTimeline = function () {
3591        var timeline = new NextendTimeline({
3592            paused: 1
3593        });
3594        for (var i = 0; i < this.layerAnimations.length; i++) {
3595            var animation = this.layerAnimations[i];
3596            timeline.add(animation.linearTimeline, 0);
3597            animation.linearTimeline.paused(false);
3598
3599        }
3600        return timeline;
3601    };
3602    scope.NextendSmartSliderSlideLayers = SlideLayers;
3603
3604})(n2, window);
3605(function ($, scope, undefined) {
3606
3607    var isTablet = null,
3608        isMobile = null;
3609
3610    function NextendSmartSliderResponsive(slider, parameters) {
3611        if (slider.isAdmin) {
3612            this.doResize = NextendThrottle(this.doResize, 50);
3613        }
3614
3615        if (typeof nextend.fontsDeferred === 'undefined') {
3616            this.triggerResize = this._triggerResize;
3617        }
3618
3619
3620        this.fixedEditRatio = 1;
3621        this.normalizeTimeout = null;
3622        this.delayedResizeAdded = false;
3623
3624        this.deviceMode = NextendSmartSliderResponsive.DeviceMode.UNKNOWN;
3625        this.orientationMode = NextendSmartSliderResponsive.OrientationMode.SCREEN;
3626        this.orientation = NextendSmartSliderResponsive.DeviceOrientation.UNKNOWN;
3627        this.lastRatios = {
3628            ratio: -1
3629        };
3630        this.normalizedMode = 'unknownUnknown';
3631
3632        slider.responsive = this;
3633
3634        this.widgetMargins = {
3635            Top: [],
3636            Right: [],
3637            Bottom: [],
3638            Left: []
3639        };
3640        this.staticSizes = {
3641            paddingTop: 0,
3642            paddingRight: 0,
3643            paddingBottom: 0,
3644            paddingLeft: 0
3645        };
3646        this.enabledWidgetMargins = [];
3647
3648        this.slider = slider;
3649        this.sliderElement = slider.sliderElement;
3650
3651        var ready = this.ready = $.Deferred();
3652        this.sliderElement.one('SliderResize', function () {
3653            ready.resolve();
3654        });
3655
3656        this.containerElementPadding = this.sliderElement.parent();
3657        this.containerElement = this.containerElementPadding.parent();
3658        this.parameters = $.extend({
3659            desktop: 1,
3660            tablet: 1,
3661            mobile: 1,
3662
3663            onResizeEnabled: true,
3664            type: 'auto',
3665            downscale: true,
3666            upscale: false,
3667            minimumHeight: 0,
3668            maximumHeight: 0,
3669            minimumHeightRatio: 0,
3670            maximumHeightRatio: {
3671                desktopLandscape: 0,
3672                desktopPortrait: 0,
3673                mobileLandscape: 0,
3674                mobilePortrait: 0,
3675                tabletLandscape: 0,
3676                tabletPortrait: 0
3677            },
3678            maximumSlideWidth: 0,
3679            maximumSlideWidthLandscape: 0,
3680            maximumSlideWidthRatio: -1,
3681            maximumSlideWidthTablet: 0,
3682            maximumSlideWidthTabletLandscape: 0,
3683            maximumSlideWidthMobile: 0,
3684            maximumSlideWidthMobileLandscape: 0,
3685            maximumSlideWidthConstrainHeight: 0,
3686            forceFull: 0,
3687            verticalOffsetSelectors: '',
3688
3689            focusUser: 0,
3690            focusAutoplay: 0,
3691
3692            deviceModes: {
3693                desktopLandscape: 1,
3694                desktopPortrait: 0,
3695                mobileLandscape: 0,
3696                mobilePortrait: 0,
3697                tabletLandscape: 0,
3698                tabletPortrait: 0
3699            },
3700            normalizedDeviceModes: {
3701                unknownUnknown: ["unknown", "Unknown"],
3702                desktopPortrait: ["desktop", "Portrait"]
3703            },
3704            verticalRatioModifiers: {
3705                unknownUnknown: 1,
3706                desktopLandscape: 1,
3707                desktopPortrait: 1,
3708                mobileLandscape: 1,
3709                mobilePortrait: 1,
3710                tabletLandscape: 1,
3711                tabletPortrait: 1
3712            },
3713            minimumFontSizes: {
3714                desktopLandscape: 0,
3715                desktopPortrait: 0,
3716                mobileLandscape: 0,
3717                mobilePortrait: 0,
3718                tabletLandscape: 0,
3719                tabletPortrait: 0
3720            },
3721            ratioToDevice: {
3722                Portrait: {
3723                    tablet: 0,
3724                    mobile: 0
3725                },
3726                Landscape: {
3727                    tablet: 0,
3728                    mobile: 0
3729                }
3730            },
3731            sliderWidthToDevice: {
3732                desktopLandscape: 0,
3733                desktopPortrait: 0,
3734                mobileLandscape: 0,
3735                mobilePortrait: 0,
3736                tabletLandscape: 0,
3737                tabletPortrait: 0
3738            },
3739
3740            basedOn: 'combined',
3741            desktopPortraitScreenWidth: 1200,
3742            tabletPortraitScreenWidth: 800,
3743            mobilePortraitScreenWidth: 440,
3744            tabletLandscapeScreenWidth: 1024,
3745            mobileLandscapeScreenWidth: 740,
3746            orientationMode: 'width_and_height'
3747        }, parameters);
3748
3749        if (this.parameters.orientationMode == 'width') {
3750            this.orientationMode = NextendSmartSliderResponsive.OrientationMode.SCREEN_WIDTH_ONLY;
3751        }
3752
3753        nextend.smallestZoom = Math.min(Math.max(parameters.sliderWidthToDevice.mobilePortrait, 120), 380);
3754
3755        switch (this.parameters.basedOn) {
3756            case 'screen':
3757                break;
3758            default:
3759                if (isTablet == null) {
3760                    var md = new MobileDetect(window.navigator.userAgent);
3761                    isTablet = !!md.tablet();
3762                    isMobile = !!md.phone();
3763                }
3764        }
3765
3766        if (!this.slider.isAdmin) {
3767            if (!this.parameters.desktop || !this.parameters.tablet || !this.parameters.mobile) {
3768                if (isTablet == null) {
3769                    var md = new MobileDetect(window.navigator.userAgent);
3770                    isTablet = !!md.tablet();
3771                    isMobile = !!md.phone();
3772                }
3773                if (!this.parameters.mobile && isMobile || !this.parameters.tablet && isTablet || !this.parameters.desktop && !isTablet && !isMobile) {
3774                    this.slider.kill();
3775                    return;
3776                }
3777            }
3778        }
3779
3780        this.verticalOffsetSelectors = $(this.parameters.verticalOffsetSelectors);
3781
3782        n2c.log('Responsive: Store defaults');
3783        this.storeDefaults();
3784
3785        if (this.parameters.minimumHeight > 0) {
3786            this.parameters.minimumHeightRatio = this.parameters.minimumHeight / this.responsiveDimensions.startHeight;
3787        }
3788
3789        if (this.parameters.maximumHeight > 0 && this.parameters.maximumHeight >= this.parameters.minimumHeight) {
3790            this.parameters.maximumHeightRatio = {
3791                desktopPortrait: this.parameters.maximumHeight / this.responsiveDimensions.startHeight
3792            };
3793            this.parameters.maximumHeightRatio.desktopLandscape = this.parameters.maximumHeightRatio.desktopPortrait;
3794            this.parameters.maximumHeightRatio.tabletPortrait = this.parameters.maximumHeightRatio.desktopPortrait;
3795            this.parameters.maximumHeightRatio.tabletLandscape = this.parameters.maximumHeightRatio.desktopPortrait;
3796            this.parameters.maximumHeightRatio.mobilePortrait = this.parameters.maximumHeightRatio.desktopPortrait;
3797            this.parameters.maximumHeightRatio.mobileLandscape = this.parameters.maximumHeightRatio.desktopPortrait;
3798        }
3799
3800        if (this.parameters.maximumSlideWidth > 0) {
3801            this.parameters.maximumSlideWidthRatio = {
3802                desktopPortrait: this.parameters.maximumSlideWidth / this.responsiveDimensions.startSlideWidth,
3803                desktopLandscape: this.parameters.maximumSlideWidthLandscape / this.responsiveDimensions.startSlideWidth,
3804                tabletPortrait: this.parameters.maximumSlideWidthTablet / this.responsiveDimensions.startSlideWidth,
3805                tabletLandscape: this.parameters.maximumSlideWidthTabletLandscape / this.responsiveDimensions.startSlideWidth,
3806                mobilePortrait: this.parameters.maximumSlideWidthMobile / this.responsiveDimensions.startSlideWidth,
3807                mobileLandscape: this.parameters.maximumSlideWidthMobileLandscape / this.responsiveDimensions.startSlideWidth
3808            }
3809
3810            if (this.parameters.maximumSlideWidthConstrainHeight) {
3811                this.parameters.maximumHeightRatio = this.parameters.maximumSlideWidthRatio;
3812            }
3813        }
3814
3815        n2c.log('Responsive: First resize');
3816        if (typeof nextend !== 'undefined' && typeof nextend['ssBeforeResponsive'] !== 'undefined') {
3817            nextend['ssBeforeResponsive'].call(this);
3818        }
3819
3820        this.onResize();
3821        if (this.parameters.onResizeEnabled || this.parameters.type == 'adaptive') {
3822            $(window).on('resize', $.proxy(this.onResize, this));
3823        }
3824    };
3825
3826    NextendSmartSliderResponsive.OrientationMode = {
3827        SCREEN: 0,
3828        ADMIN_LANDSCAPE: 1,
3829        ADMIN_PORTRAIT: 2,
3830        SCREEN_WIDTH_ONLY: 3
3831    };
3832    NextendSmartSliderResponsive.DeviceOrientation = {
3833        UNKNOWN: 0,
3834        LANDSCAPE: 1,
3835        PORTRAIT: 2
3836    };
3837    NextendSmartSliderResponsive._DeviceOrientation = {
3838        0: 'Unknown',
3839        1: 'Landscape',
3840        2: 'Portrait'
3841    };
3842    NextendSmartSliderResponsive.DeviceMode = {
3843        UNKNOWN: 0,
3844        DESKTOP: 1,
3845        TABLET: 2,
3846        MOBILE: 3
3847    };
3848    NextendSmartSliderResponsive._DeviceMode = {
3849        0: 'unknown',
3850        1: 'desktop',
3851        2: 'tablet',
3852        3: 'mobile'
3853    };
3854
3855    NextendSmartSliderResponsive.prototype.getOuterWidth = function () {
3856        var rd = this.responsiveDimensions;
3857        return rd.startSliderWidth + rd.startSliderMarginLeft + rd.startSliderMarginRight;
3858    };
3859
3860    NextendSmartSliderResponsive.prototype.storeDefaults = function () {
3861
3862        // We should use outerWidth(true) as we need proper margin calculation for the ratio
3863        this.responsiveDimensions = {
3864            startWidth: this.sliderElement.outerWidth(true),
3865            startHeight: this.sliderElement.outerHeight(true)
3866        };
3867
3868        /**
3869         * @type {NextendSmartSliderResponsiveElement[]}
3870         */
3871        this.responsiveElements = [];
3872
3873        this.helperElements = {};
3874
3875        this.addResponsiveElements();
3876
3877        this.margins = {
3878            top: this.responsiveDimensions.startSliderMarginTop,
3879            right: this.responsiveDimensions.startSliderMarginRight,
3880            bottom: this.responsiveDimensions.startSliderMarginBottom,
3881            left: this.responsiveDimensions.startSliderMarginLeft
3882        }
3883    };
3884
3885    /**
3886     * @abstract
3887     */
3888    NextendSmartSliderResponsive.prototype.addResponsiveElements = function () {
3889    };
3890
3891    /**
3892     * Add an element list as a single element. Other elements in the list will get the same property as the first element.
3893     * @param element
3894     * @param cssproperties
3895     * @param name
3896     */
3897    NextendSmartSliderResponsive.prototype.addResponsiveElement = function (element, cssproperties, group, name) {
3898        if (typeof group === 'undefined' || !group) {
3899            group = 'ratio';
3900        }
3901        var responsiveElement = new NextendSmartSliderResponsiveElement(this, group, element, cssproperties, name);
3902        this.responsiveElements.push(responsiveElement);
3903        return responsiveElement;
3904    };
3905
3906    NextendSmartSliderResponsive.prototype.addResponsiveElementBackgroundImage = function (element, backgroundImage, cssproperties, group, name) {
3907        if (typeof group === 'undefined' || !group) {
3908            group = 'ratio';
3909        }
3910        var responsiveElement = new NextendSmartSliderResponsiveElementBackgroundImage(this, backgroundImage, group, element, cssproperties, name);
3911        this.responsiveElements.push(responsiveElement);
3912        return responsiveElement;
3913    };
3914
3915    /**
3916     * Add each element from the list as a single element. It is good for image list as every image might have different dimensions
3917     * @param elements
3918     * @param cssproperties
3919     * @param name
3920     */
3921    NextendSmartSliderResponsive.prototype.addResponsiveElementAsSingle = function (elements, cssproperties, group, name) {
3922        var responsiveElements = [];
3923        for (var i = 0; i < elements.length; i++) {
3924            responsiveElements.push(this.addResponsiveElement(elements.eq(i), cssproperties.slice(0), group, name));
3925        }
3926        return responsiveElements;
3927    };
3928
3929    NextendSmartSliderResponsive.prototype.addResponsiveElementBackgroundImageAsSingle = function (elements, backgroundImage, cssproperties, group, name) {
3930        var responsiveElements = [];
3931        for (var i = 0; i < elements.length; i++) {
3932            responsiveElements.push(this.addResponsiveElementBackgroundImage(elements.eq(i), backgroundImage, cssproperties.slice(0), group, name));
3933        }
3934        return responsiveElements;
3935    };
3936
3937    NextendSmartSliderResponsive.prototype.resizeResponsiveElements = function (ratios, timeline, duration) {
3938        for (var i = 0; i < this.responsiveElements.length; i++) {
3939            var responsiveElement = this.responsiveElements[i];
3940            if (typeof ratios[responsiveElement.group] === 'undefined') {
3941                console.log('error with ' + responsiveElement.group);
3942            }
3943            responsiveElement.resize(this.responsiveDimensions, ratios[responsiveElement.group], timeline, duration);
3944        }
3945    };
3946
3947    NextendSmartSliderResponsive.prototype.getDeviceMode = function () {
3948        return NextendSmartSliderResponsive._DeviceMode[this.deviceMode];
3949    };
3950
3951    NextendSmartSliderResponsive.prototype.getDeviceModeOrientation = function () {
3952        return NextendSmartSliderResponsive._DeviceMode[this.deviceMode] + NextendSmartSliderResponsive._DeviceOrientation[this.orientation];
3953    };
3954
3955    NextendSmartSliderResponsive.prototype.onResize = function () {
3956        if (this.slider.mainAnimation.getState() == 'ended') {
3957            this.doResize();
3958        } else if (!this.delayedResizeAdded) {
3959            this.delayedResizeAdded = true;
3960            this.sliderElement.on('mainAnimationComplete.responsive', $.proxy(this._doDelayedResize, this));
3961        }
3962    };
3963
3964    NextendSmartSliderResponsive.prototype._doDelayedResize = function () {
3965        this.doResize();
3966        this.delayedResizeAdded = false;
3967    };
3968
3969
3970    NextendSmartSliderResponsive.prototype.doNormalizedResize = function () {
3971        if (this.normalizeTimeout) {
3972            clearTimeout(this.normalizeTimeout);
3973        }
3974
3975        this.normalizeTimeout = setTimeout($.proxy(this.doResize, this), 10);
3976    };
3977
3978    NextendSmartSliderResponsive.prototype._getOrientation = function () {
3979        if (this.orientationMode == NextendSmartSliderResponsive.OrientationMode.SCREEN) {
3980            if (window.innerHeight <= window.innerWidth) {
3981                return NextendSmartSliderResponsive.DeviceOrientation.LANDSCAPE;
3982            } else {
3983                return NextendSmartSliderResponsive.DeviceOrientation.PORTRAIT;
3984            }
3985        } else if (this.orientationMode == NextendSmartSliderResponsive.OrientationMode.ADMIN_PORTRAIT) {
3986            return NextendSmartSliderResponsive.DeviceOrientation.PORTRAIT;
3987        } else if (this.orientationMode == NextendSmartSliderResponsive.OrientationMode.ADMIN_LANDSCAPE) {
3988            return NextendSmartSliderResponsive.DeviceOrientation.LANDSCAPE;
3989        }
3990    };
3991
3992    NextendSmartSliderResponsive.prototype._getDevice = function () {
3993        switch (this.parameters.basedOn) {
3994            case 'combined':
3995                return this._getDeviceDevice(this._getDeviceScreenWidth());
3996            case 'device':
3997                return this._getDeviceDevice(NextendSmartSliderResponsive.DeviceMode.DESKTOP);
3998            case 'screen':
3999                return this._getDeviceScreenWidth();
4000        }
4001    };
4002
4003    NextendSmartSliderResponsive.prototype._getDeviceScreenWidth = function () {
4004        var viewportWidth = window.innerWidth;
4005        if (this.orientation == NextendSmartSliderResponsive.DeviceOrientation.PORTRAIT) {
4006            if (viewportWidth < this.parameters.mobilePortraitScreenWidth) {
4007                return NextendSmartSliderResponsive.DeviceMode.MOBILE;
4008            } else if (viewportWidth < this.parameters.tabletPortraitScreenWidth) {
4009                return NextendSmartSliderResponsive.DeviceMode.TABLET;
4010            }
4011        } else {
4012            if (viewportWidth < this.parameters.mobileLandscapeScreenWidth) {
4013                return NextendSmartSliderResponsive.DeviceMode.MOBILE;
4014            } else if (viewportWidth < this.parameters.tabletLandscapeScreenWidth) {
4015                return NextendSmartSliderResponsive.DeviceMode.TABLET;
4016            }
4017        }
4018        return NextendSmartSliderResponsive.DeviceMode.DESKTOP;
4019    };
4020
4021    NextendSmartSliderResponsive.prototype._getDeviceAndOrientationByScreenWidth = function () {
4022        var viewportWidth = window.innerWidth;
4023        if (viewportWidth < this.parameters.mobilePortraitScreenWidth) {
4024            return [NextendSmartSliderResponsive.DeviceMode.MOBILE, NextendSmartSliderResponsive.DeviceOrientation.PORTRAIT];
4025        } else if (viewportWidth < this.parameters.mobileLandscapeScreenWidth) {
4026            return [NextendSmartSliderResponsive.DeviceMode.MOBILE, NextendSmartSliderResponsive.DeviceOrientation.LANDSCAPE];
4027        } else if (viewportWidth < this.parameters.tabletPortraitScreenWidth) {
4028            return [NextendSmartSliderResponsive.DeviceMode.TABLET, NextendSmartSliderResponsive.DeviceOrientation.PORTRAIT];
4029        } else if (viewportWidth < this.parameters.tabletLandscapeScreenWidth) {
4030            return [NextendSmartSliderResponsive.DeviceMode.TABLET, NextendSmartSliderResponsive.DeviceOrientation.LANDSCAPE];
4031        } else if (viewportWidth < this.parameters.desktopPortraitScreenWidth) {
4032            return [NextendSmartSliderResponsive.DeviceMode.DESKTOP, NextendSmartSliderResponsive.DeviceOrientation.PORTRAIT];
4033        }
4034        return [NextendSmartSliderResponsive.DeviceMode.DESKTOP, NextendSmartSliderResponsive.DeviceOrientation.LANDSCAPE];
4035    };
4036
4037    NextendSmartSliderResponsive.prototype._getDeviceDevice = function (device) {
4038        if (isMobile === true) {
4039            return NextendSmartSliderResponsive.DeviceMode.MOBILE;
4040        } else if (isTablet && device != NextendSmartSliderResponsive.DeviceMode.MOBILE) {
4041            return NextendSmartSliderResponsive.DeviceMode.TABLET;
4042        }
4043        return device;
4044    };
4045
4046    NextendSmartSliderResponsive.prototype._getDeviceZoom = function (ratio) {
4047        var orientation;
4048        if (this.orientationMode == NextendSmartSliderResponsive.OrientationMode.ADMIN_PORTRAIT) {
4049            orientation = NextendSmartSliderResponsive.DeviceOrientation.PORTRAIT;
4050        } else if (this.orientationMode == NextendSmartSliderResponsive.OrientationMode.ADMIN_LANDSCAPE) {
4051            orientation = NextendSmartSliderResponsive.DeviceOrientation.LANDSCAPE;
4052        }
4053        var targetMode = NextendSmartSliderResponsive.DeviceMode.DESKTOP;
4054        if (ratio <= this.parameters.ratioToDevice[NextendSmartSliderResponsive._DeviceOrientation[orientation]].mobile) {
4055            targetMode = NextendSmartSliderResponsive.DeviceMode.MOBILE;
4056        } else if (ratio <= this.parameters.ratioToDevice[NextendSmartSliderResponsive._DeviceOrientation[orientation]].tablet) {
4057            targetMode = NextendSmartSliderResponsive.DeviceMode.TABLET;
4058        }
4059        return targetMode;
4060    };
4061
4062    NextendSmartSliderResponsive.prototype.reTriggerSliderDeviceOrientation = function () {
4063        var normalized = this._normalizeMode(NextendSmartSliderResponsive._DeviceMode[this.deviceMode], NextendSmartSliderResponsive._DeviceOrientation[this.orientation]);
4064        this.sliderElement.trigger('SliderDeviceOrientation', {
4065            lastDevice: normalized[0],
4066            lastOrientation: normalized[1],
4067            device: normalized[0],
4068            orientation: normalized[1]
4069        });
4070    };
4071
4072    NextendSmartSliderResponsive.prototype.doResize = function (fixedMode, timeline, nextSlideIndex, duration) {
4073
4074        // required to force recalculate if the thumbnails widget get hidden.
4075        this.refreshMargin();
4076
4077        if (!this.slider.isAdmin) {
4078            if (this.parameters.forceFull) {
4079                $('body').css('overflow-x', 'hidden');
4080                var outerEl = this.containerElement.parent();
4081                this.containerElement.css('marginLeft', -outerEl.offset().left - parseInt(outerEl.css('paddingLeft')) - parseInt(outerEl.css('borderLeftWidth'))).width(document.body.clientWidth || document.documentElement.clientWidth);
4082            }
4083        }
4084        var ratio = this.containerElementPadding.width() / this.getOuterWidth();
4085
4086
4087        var hasOrientationOrDeviceChange = false,
4088            lastOrientation = this.orientation,
4089            lastDevice = this.deviceMode,
4090            targetOrientation = null,
4091            targetMode = null;
4092
4093        if (this.orientationMode == NextendSmartSliderResponsive.OrientationMode.SCREEN_WIDTH_ONLY) {
4094            var deviceOrientation = this._getDeviceAndOrientationByScreenWidth();
4095            targetMode = deviceOrientation[0]
4096            targetOrientation = deviceOrientation[1];
4097        } else {
4098            targetOrientation = this._getOrientation()
4099        }
4100
4101        if (this.orientation != targetOrientation) {
4102            this.orientation = targetOrientation;
4103            hasOrientationOrDeviceChange = true;
4104            n2c.log('Event: SliderOrientation', {
4105                lastOrientation: NextendSmartSliderResponsive._DeviceOrientation[lastOrientation],
4106                orientation: NextendSmartSliderResponsive._DeviceOrientation[targetOrientation]
4107            });
4108            this.sliderElement.trigger('SliderOrientation', {
4109                lastOrientation: NextendSmartSliderResponsive._DeviceOrientation[lastOrientation],
4110                orientation: NextendSmartSliderResponsive._DeviceOrientation[targetOrientation]
4111            });
4112        }
4113
4114        if (!fixedMode) {
4115            if (this.orientationMode != NextendSmartSliderResponsive.OrientationMode.SCREEN_WIDTH_ONLY) {
4116                targetMode = this._getDevice(ratio);
4117            }
4118
4119            if (this.deviceMode != targetMode) {
4120                this.deviceMode = targetMode;
4121                this.sliderElement.removeClass('n2-ss-' + NextendSmartSliderResponsive._DeviceMode[lastDevice])
4122                    .addClass('n2-ss-' + NextendSmartSliderResponsive._DeviceMode[targetMode]);
4123                n2c.log('Event: SliderDevice', {
4124                    lastDevice: NextendSmartSliderResponsive._DeviceMode[lastDevice],
4125                    device: NextendSmartSliderResponsive._DeviceMode[targetMode]
4126                });
4127                this.sliderElement.trigger('SliderDevice', {
4128                    lastDevice: NextendSmartSliderResponsive._DeviceMode[lastDevice],
4129                    device: NextendSmartSliderResponsive._DeviceMode[targetMode]
4130                });
4131                hasOrientationOrDeviceChange = true;
4132            }
4133        }
4134
4135        if (!this.slider.isAdmin) {
4136            if (this.parameters.type == 'fullpage') {
4137                this.parameters.maximumHeightRatio[this.getDeviceModeOrientation()] = this.parameters.minimumHeightRatio = ((document.documentElement.clientHeight || document.body.clientHeight) - this.getVerticalOffsetHeight()) / this.responsiveDimensions.startHeight;
4138            }
4139        }
4140
4141        if (hasOrientationOrDeviceChange) {
4142            var lastNormalized = this._normalizeMode(NextendSmartSliderResponsive._DeviceMode[lastDevice], NextendSmartSliderResponsive._DeviceOrientation[lastOrientation]),
4143                normalized = this._normalizeMode(NextendSmartSliderResponsive._DeviceMode[this.deviceMode], NextendSmartSliderResponsive._DeviceOrientation[this.orientation]);
4144
4145            if (lastNormalized[0] != normalized[0] || lastNormalized[1] != normalized[1]) {
4146                this.normalizedMode = normalized[0] + normalized[1];
4147                n2c.log('Event: SliderDeviceOrientation', {
4148                    lastDevice: lastNormalized[0],
4149                    lastOrientation: lastNormalized[1],
4150                    device: normalized[0],
4151                    orientation: normalized[1]
4152                });
4153                this.sliderElement.trigger('SliderDeviceOrientation', {
4154                    lastDevice: lastNormalized[0],
4155                    lastOrientation: lastNormalized[1],
4156                    device: normalized[0],
4157                    orientation: normalized[1]
4158                });
4159            }
4160        }
4161        /*
4162         if (this.parameters.type == 'adaptive') {
4163         this._doResize(this.parameters.sliderWidthToDevice[this.normalizedMode] / this.parameters.sliderWidthToDevice.desktopPortrait);
4164         } else {
4165         */
4166        var zeroRatio = this.parameters.sliderWidthToDevice[this.normalizedMode] / this.parameters.sliderWidthToDevice.desktopPortrait;
4167        if (!this.parameters.downscale && ratio < zeroRatio) {
4168            ratio = zeroRatio;
4169        } else if (!this.parameters.upscale && ratio > zeroRatio) {
4170            ratio = zeroRatio;
4171        }
4172        this._doResize(ratio, timeline, nextSlideIndex, duration);
4173        //}
4174    };
4175
4176    NextendSmartSliderResponsive.prototype._normalizeMode = function (device, orientation) {
4177        return this.parameters.normalizedDeviceModes[device + orientation];
4178    };
4179
4180    NextendSmartSliderResponsive.prototype.getNormalizedModeString = function () {
4181        var normalized = this._normalizeMode(NextendSmartSliderResponsive._DeviceMode[this.deviceMode], NextendSmartSliderResponsive._DeviceOrientation[this.orientation]);
4182        return normalized.join('');
4183    };
4184
4185    NextendSmartSliderResponsive.prototype.getModeString = function () {
4186        return NextendSmartSliderResponsive._DeviceMode[this.deviceMode] + NextendSmartSliderResponsive._DeviceOrientation[this.orientation];
4187    };
4188
4189    NextendSmartSliderResponsive.prototype.isEnabled = function (device, orientation) {
4190        return this.parameters.deviceModes[device + orientation];
4191    };
4192
4193    NextendSmartSliderResponsive.prototype._doResize = function (ratio, timeline, nextSlideIndex, duration) {
4194        var ratios = {
4195            ratio: ratio,
4196            w: ratio,
4197            h: ratio,
4198            slideW: ratio,
4199            slideH: ratio,
4200            fontRatio: 1
4201        };
4202
4203        this._buildRatios(ratios, this.slider.parameters.dynamicHeight, nextSlideIndex);
4204        /*
4205         if (this.fixedEditRatio && this.slider.isAdmin) {
4206         ratios.w = ratios.slideW;
4207         ratios.h = ratios.slideH;
4208         }
4209         */
4210        ratios.fontRatio = ratios.slideW;
4211
4212
4213        var isChanged = false;
4214        for (var k in ratios) {
4215            if (ratios[k] != this.lastRatios[k]) {
4216                isChanged = true;
4217                break;
4218            }
4219        }
4220
4221        if (isChanged) {
4222            this.resizeResponsiveElements(ratios, timeline, duration);
4223            this.lastRatios = ratios;
4224
4225            if (timeline) {
4226                this.sliderElement.trigger('SliderAnimatedResize', [ratios, timeline, duration]);
4227                timeline.eventCallback("onComplete", function () {
4228                    this.triggerResize(ratios, timeline);
4229                }, [], this);
4230            } else {
4231                this.triggerResize(ratios, timeline);
4232            }
4233        }
4234    };
4235
4236    NextendSmartSliderResponsive.prototype.triggerResize = function (ratios, timeline) {
4237        nextend.fontsDeferred.done($.proxy(function () {
4238            this.triggerResize = this._triggerResize;
4239            this._triggerResize(ratios, timeline);
4240        }, this));
4241    };
4242
4243    NextendSmartSliderResponsive.prototype._triggerResize = function (ratios, timeline) {
4244        n2c.log('Event: SliderResize', ratios);
4245        this.sliderElement.trigger('SliderResize', [ratios, this, timeline]);
4246    };
4247
4248    NextendSmartSliderResponsive.prototype._buildRatios = function (ratios, dynamicHeight, nextSlideIndex) {
4249        if (this.parameters.minimumHeightRatio > 0) {
4250            ratios.h = Math.max(ratios.h, this.parameters.minimumHeightRatio);
4251        }
4252
4253        var deviceModeOrientation = this.getDeviceModeOrientation();
4254
4255        if (this.parameters.maximumHeightRatio[deviceModeOrientation] > 0) {
4256            ratios.h = Math.min(ratios.h, this.parameters.maximumHeightRatio[deviceModeOrientation]);
4257        }
4258
4259        if (this.parameters.maximumSlideWidthRatio[deviceModeOrientation] > 0 && ratios.slideW > this.parameters.maximumSlideWidthRatio[deviceModeOrientation]) {
4260            ratios.slideW = this.parameters.maximumSlideWidthRatio[deviceModeOrientation];
4261        }
4262
4263        ratios.slideW = ratios.slideH = Math.min(ratios.slideW, ratios.slideH);
4264
4265        var verticalRatioModifier = this.parameters.verticalRatioModifiers[deviceModeOrientation];
4266        ratios.slideH *= verticalRatioModifier;
4267        if (this.parameters.type == 'fullpage') {
4268            if (ratios.slideH > ratios.h) {
4269                ratios.slideW /= ratios.slideH / ratios.h;
4270            }
4271            ratios.slideH = Math.min(ratios.slideH, ratios.h);
4272
4273            if (this.slider.isAdmin) {
4274                ratios.w = ratios.slideW;
4275                ratios.h = ratios.slideH;
4276            }
4277        } else {
4278            ratios.h *= verticalRatioModifier;
4279            ratios.slideH = Math.min(ratios.slideH, ratios.h);
4280            //if (this.parameters.type == 'showcase') {
4281            // Constrain slide ratio in showcase type
4282            ratios.slideW = ratios.slideH / verticalRatioModifier;
4283            //}
4284        }
4285
4286        var slideIndex = this.slider.currentSlideIndex;
4287        if (typeof nextSlideIndex !== 'undefined') {
4288            slideIndex = nextSlideIndex;
4289        }
4290
4291        if (dynamicHeight) {
4292            var backgroundRatio = this.slider.backgroundImages.backgroundImages[slideIndex].responsiveElement.relativeRatio;
4293            if (backgroundRatio != -1) {
4294                ratios.slideH *= backgroundRatio;
4295                ratios.h *= backgroundRatio;
4296            }
4297        }
4298
4299        this.sliderElement.triggerHandler('responsiveBuildRatios', [ratios]);
4300    };
4301
4302    NextendSmartSliderResponsive.prototype.setOrientation = function (newOrientation) {
4303        if (newOrientation == 'portrait') {
4304            this.orientationMode = NextendSmartSliderResponsive.OrientationMode.ADMIN_PORTRAIT;
4305        } else if (newOrientation == 'landscape') {
4306            this.orientationMode = NextendSmartSliderResponsive.OrientationMode.ADMIN_LANDSCAPE;
4307        }
4308    };
4309
4310    NextendSmartSliderResponsive.prototype.setMode = function (newMode) {
4311        var orientation;
4312        if (this.orientationMode == NextendSmartSliderResponsive.OrientationMode.ADMIN_PORTRAIT) {
4313            orientation = NextendSmartSliderResponsive.DeviceOrientation.PORTRAIT;
4314        } else if (this.orientationMode == NextendSmartSliderResponsive.OrientationMode.ADMIN_LANDSCAPE) {
4315            orientation = NextendSmartSliderResponsive.DeviceOrientation.LANDSCAPE;
4316        }
4317        var width = this.parameters.sliderWidthToDevice[newMode + NextendSmartSliderResponsive._DeviceOrientation[orientation]];
4318        width = nextend.smallestZoom + (((this.parameters.sliderWidthToDevice['desktopPortrait'] - nextend.smallestZoom)) / 50) * Math.floor((width - nextend.smallestZoom) / (((this.parameters.sliderWidthToDevice['desktopPortrait'] - nextend.smallestZoom)) / 50));
4319        this.setSize(width);
4320        if (this.containerElement.width() > width) {
4321            // We have to find a proper value for the zoom slider - backend only
4322            width = this.parameters.sliderWidthToDevice[newMode + NextendSmartSliderResponsive._DeviceOrientation[orientation]] - (this.parameters.sliderWidthToDevice['desktopPortrait'] - nextend.smallestZoom) / 50;
4323            this.setSize(width);
4324        }
4325    };
4326
4327    NextendSmartSliderResponsive.prototype.setSize = function (targetWidth) {
4328        this.containerElement.width(targetWidth);
4329
4330        this.doResize();
4331    };
4332
4333    /**
4334     * Required for maximum slide width calculation
4335     * @returns {null}
4336     */
4337    NextendSmartSliderResponsive.prototype.getCanvas = function () {
4338        return null;
4339    };
4340
4341    NextendSmartSliderResponsive.prototype.getVerticalOffsetHeight = function () {
4342        var h = 0;
4343        for (var i = 0; i < this.verticalOffsetSelectors.length; i++) {
4344            h += this.verticalOffsetSelectors.eq(i).outerHeight();
4345        }
4346        return h;
4347    };
4348
4349    NextendSmartSliderResponsive.prototype.addMargin = function (side, widget) {
4350        this.widgetMargins[side].push(widget);
4351        if (widget.isVisible()) {
4352            this._addMarginSize(side, widget.getSize());
4353            this.enabledWidgetMargins.push(widget);
4354        }
4355        this.doNormalizedResize();
4356    };
4357
4358    NextendSmartSliderResponsive.prototype.addStaticMargin = function (side, widget) {
4359        if (!this.widgetStaticMargins) {
4360            this.widgetStaticMargins = {
4361                Top: [],
4362                Right: [],
4363                Bottom: [],
4364                Left: []
4365            };
4366        }
4367        this.widgetStaticMargins[side].push(widget);
4368        this.doNormalizedResize();
4369    };
4370
4371    NextendSmartSliderResponsive.prototype.refreshMargin = function () {
4372        for (var side in this.widgetMargins) {
4373            var widgets = this.widgetMargins[side];
4374            for (var i = widgets.length - 1; i >= 0; i--) {
4375                var widget = widgets[i];
4376                if (widget.isVisible()) {
4377                    if ($.inArray(widget, this.enabledWidgetMargins) == -1) {
4378                        this._addMarginSize(side, widget.getSize());
4379                        this.enabledWidgetMargins.push(widget);
4380                    }
4381                } else {
4382                    var index = $.inArray(widget, this.enabledWidgetMargins);
4383                    if (index != -1) {
4384                        this._addMarginSize(side, -widget.getSize());
4385                        this.enabledWidgetMargins.splice(index, 1);
4386                    }
4387                }
4388            }
4389        }
4390        if (this.widgetStaticMargins) {
4391            var staticSizes = {
4392                paddingTop: 0,
4393                paddingRight: 0,
4394                paddingBottom: 0,
4395                paddingLeft: 0
4396            };
4397            for (var side in this.widgetStaticMargins) {
4398                var widgets = this.widgetStaticMargins[side];
4399                for (var i = widgets.length - 1; i >= 0; i--) {
4400                    var widget = widgets[i];
4401                    if (widget.isVisible()) {
4402                        staticSizes['padding' + side] += widget.getSize();
4403                    }
4404                }
4405            }
4406            for (var k in staticSizes) {
4407                this.containerElementPadding.css(staticSizes);
4408            }
4409            this.staticSizes = staticSizes;
4410        }
4411    };
4412
4413    NextendSmartSliderResponsive.prototype._addMarginSize = function (side, size) {
4414        var axis = null;
4415        switch (side) {
4416            case 'Top':
4417            case 'Bottom':
4418                axis = this._sliderVertical;
4419                break;
4420            default:
4421                axis = this._sliderHorizontal;
4422        }
4423        axis.data['margin' + side] += size;
4424        this.responsiveDimensions['startSliderMargin' + side] += size;
4425    };
4426
4427    scope.NextendSmartSliderResponsive = NextendSmartSliderResponsive;
4428})(n2, window);
4429(function ($, scope, undefined) {
4430
4431    function capitalize(str) {
4432        return str.charAt(0).toUpperCase() + str.slice(1);
4433    }
4434
4435    /**
4436     * @constructor
4437     * @param responsive {NextendSmartSliderResponsive} caller object
4438     * @param group {String}
4439     * @param element {jQuery}
4440     * @param cssProperties {Array} Array of properties which will be responsive
4441     * @param name {String} we will register the changed values for this namespace in the global NextendSmartSliderResponsive objects' responsiveDimensions property
4442     */
4443    function NextendSmartSliderResponsiveElement(responsive, group, element, cssProperties, name) {
4444        this.loadDefaults();
4445        this._lastRatio = 1;
4446        this.responsive = responsive;
4447
4448        this.group = group;
4449
4450        this.element = element;
4451
4452        this.lazyload = this.responsive.slider.parameters.lazyload.enabled;
4453
4454        this._readyDeferred = $.Deferred();
4455
4456        if (typeof name !== 'undefined') {
4457            this.name = name;
4458        } else {
4459            this.name = null;
4460        }
4461
4462        this.tagName = element.prop("tagName");
4463
4464        this.data = {};
4465
4466        this.helper = {
4467            /**
4468             * Holds the current element's parent element, which is required for the centered mode
4469             */
4470            parent: null,
4471            /**
4472             * Holds the current element's parent original width and height for images
4473             */
4474            parentProps: null,
4475            /**
4476             * If font size is enabled for the current element, this will hold the different font sized for the different devices
4477             */
4478            fontSize: false,
4479            /**
4480             * If this is enabled, the responsive mode will try to position the actual element into the center of the parent element
4481             */
4482            centered: false
4483        };
4484
4485        if (!this.customLoad) {
4486            switch (this.tagName) {
4487                case 'IMG':
4488                    var parent = element.parent();
4489                    // The images doesn't have their original(not the real dimension, it is the place
4490                    // what was taken right after the load) width and height values in the future.
4491                    // So we will calculate the original size from the parent element size
4492                    // We will assume that the image was 100% width to its parent
4493                    this.helper.parentProps = {
4494                        width: parent.width(),
4495                        height: parent.height()
4496                    }
4497                    // Images might not have proper height and width values when not loaded
4498                    // Let's wait for them
4499                    if (this.lazyload) {
4500                        // Lazy load happens much later than the imagesloaded, but this is why it is lazy :)
4501                        element.on('lazyloaded', $.proxy(this._lateInitIMG, this, cssProperties));
4502                    } else {
4503                        element.imagesLoaded($.proxy(this._lateInitIMG, this, cssProperties));
4504                    }
4505                    break;
4506                // We don't have anything to wait so we can start our later initialization
4507                default:
4508                    this._lateInit(cssProperties);
4509            }
4510        } else {
4511            this.customLoad(cssProperties);
4512        }
4513
4514    };
4515
4516    NextendSmartSliderResponsiveElement.prototype.loadDefaults = function () {
4517        this.customLoad = false;
4518        this.lazyload = false;
4519    };
4520
4521    NextendSmartSliderResponsiveElement.prototype._lateInit = function (cssProperties) {
4522
4523        this._cssProperties = cssProperties;
4524
4525        this.reloadDefault();
4526
4527        /**
4528         * If font-size is responsive on the element, we init this feature on the element.
4529         */
4530        if ($.inArray('fontSize', cssProperties) != -1) {
4531
4532            this.data['fontSize'] = this.element.data('fontsize');
4533
4534            this.helper.fontSize = {
4535                fontSize: this.element.data('fontsize'),
4536                desktopPortrait: this.element.data('minfontsizedesktopportrait'),
4537                desktopLandscape: this.element.data('minfontsizedesktoplandscape'),
4538                tabletPortrait: this.element.data('minfontsizetabletportrait'),
4539                tabletLandscape: this.element.data('minfontsizetabletlandscape'),
4540                mobilePortrait: this.element.data('minfontsizemobileportrait'),
4541                mobileLandscape: this.element.data('minfontsizemobilelandscape')
4542            };
4543
4544            // Sets the proper font size for the current mode
4545            //this.setFontSizeByMode(this.responsive.mode.mode);
4546
4547            // When the mode changes we have to adjust the original font size value in the data
4548            this.responsive.sliderElement.on('SliderDeviceOrientation', $.proxy(this.onModeChange, this));
4549        }
4550
4551        // Our resource is finished with the loading, so we can enable the normal resize method.
4552        this.resize = this._resize;
4553
4554        // We are ready
4555        this._readyDeferred.resolve();
4556    };
4557
4558    NextendSmartSliderResponsiveElement.prototype.reloadDefault = function () {
4559
4560        for (var i = 0; i < this._cssProperties.length; i++) {
4561            var propName = this._cssProperties[i];
4562            this.data[propName] = parseInt(this.element.css(propName));
4563        }
4564        if (this.name) {
4565            var d = this.responsive.responsiveDimensions;
4566            for (var k in this.data) {
4567                d['start' + capitalize(this.name) + capitalize(k)] = this.data[k];
4568            }
4569        }
4570    };
4571
4572    NextendSmartSliderResponsiveElement.prototype._lateInitIMG = function (cssProperties, e) {
4573
4574        // As our background images has 100% width, we know that the original img size was the same as the parent's width.
4575        // Then we can calculate the original height of the img as the parent element's ratio might not the same as the background image
4576
4577        var width = this.element.width(),
4578            height = this.element.height();
4579
4580        height = parseInt(this.helper.parentProps.width / width * height);
4581        width = this.helper.parentProps.width;
4582
4583        var widthIndex = $.inArray('width', cssProperties);
4584        if (widthIndex != -1) {
4585            cssProperties.splice(widthIndex, 1);
4586            this.data['width'] = width;
4587        }
4588        var heightIndex = $.inArray('height', cssProperties);
4589        if (heightIndex != -1) {
4590            cssProperties.splice(heightIndex, 1);
4591            this.data['height'] = height;
4592        }
4593        this._lateInit(cssProperties);
4594    };
4595
4596    /**
4597     * You can use it as the normal jQuery ready, except it check for the current element list
4598     * @param {function} fn
4599     */
4600    NextendSmartSliderResponsiveElement.prototype.ready = function (fn) {
4601        this._readyDeferred.done(fn);
4602    };
4603
4604    /**
4605     * When the element list is not loaded yet, we have to add the current resize call to the ready event.
4606     * @example You have an image which is not loaded yet, but a resize happens on the browser. We have to make the resize later when the image is ready!
4607     * @param responsiveDimensions
4608     * @param ratio
4609     */
4610    NextendSmartSliderResponsiveElement.prototype.resize = function (responsiveDimensions, ratio) {
4611        this.ready($.proxy(this.resize, this, responsiveDimensions, ratio));
4612        this._lastRatio = ratio;
4613    };
4614
4615    NextendSmartSliderResponsiveElement.prototype._resize = function (responsiveDimensions, ratio, timeline, duration) {
4616        if (this.name && typeof responsiveDimensions[this.name] === 'undefined') {
4617            responsiveDimensions[this.name] = {};
4618        }
4619
4620        var to = {};
4621        for (var propName in this.data) {
4622            var value = this.data[propName] * ratio;
4623            if (typeof this[propName + 'Prepare'] == 'function') {
4624                value = this[propName + 'Prepare'](value);
4625            }
4626
4627            if (this.name) {
4628                responsiveDimensions[this.name][propName] = value;
4629            }
4630            to[propName] = value;
4631        }
4632        if (timeline) {
4633            timeline.to(this.element, duration, to, 0);
4634        } else {
4635            this.element.css(to);
4636
4637            if (this.helper.centered) {
4638                // when centered feature enabled we have to set the proper margins for the element to make it centered
4639                if (n2const.isIOS && this.tagName == 'IMG') {
4640                    // If this fix not applied, IOS might not calculate the correct width and height for the image
4641                    this.element.css({
4642                        marginLeft: 1,
4643                        marginTop: 1
4644                    });
4645                }
4646                this.element.css({
4647                    marginLeft: parseInt((this.helper.parent.width() - this.element.width()) / 2),
4648                    marginTop: parseInt((this.helper.parent.height() - this.element.height()) / 2)
4649                });
4650            }
4651        }
4652        this._lastRatio = ratio;
4653    };
4654
4655    NextendSmartSliderResponsiveElement.prototype._refreshResize = function () {
4656        this.responsive.ready.done($.proxy(function () {
4657            this._resize(this.responsive.responsiveDimensions, this.responsive.lastRatios[this.group]);
4658        }, this));
4659    };
4660
4661    NextendSmartSliderResponsiveElement.prototype.widthPrepare = function (value) {
4662        return Math.round(value);
4663    };
4664
4665    NextendSmartSliderResponsiveElement.prototype.heightPrepare = function (value) {
4666        return Math.round(value);
4667    };
4668
4669    NextendSmartSliderResponsiveElement.prototype.marginLeftPrepare = function (value) {
4670        return parseInt(value);
4671    };
4672
4673    NextendSmartSliderResponsiveElement.prototype.marginRightPrepare = function (value) {
4674        return parseInt(value);
4675    };
4676
4677    NextendSmartSliderResponsiveElement.prototype.lineHeightPrepare = function (value) {
4678        return value + 'px';
4679    };
4680
4681    NextendSmartSliderResponsiveElement.prototype.fontSizePrepare = function (value) {
4682        var mode = this.responsive.getNormalizedModeString();
4683        if (value < this.helper.fontSize[mode]) {
4684            return this.helper.fontSize[mode];
4685        }
4686        return value;
4687    };
4688
4689    /**
4690     * Enables the centered feature on the current element.
4691     */
4692    NextendSmartSliderResponsiveElement.prototype.setCentered = function () {
4693        this.helper.parent = this.element.parent();
4694        this.helper.centered = true;
4695    };
4696    NextendSmartSliderResponsiveElement.prototype.unsetCentered = function () {
4697        this.helper.centered = false;
4698    };
4699    NextendSmartSliderResponsiveElement.prototype.onModeChange = function () {
4700        this.setFontSizeByMode();
4701    };
4702
4703    /**
4704     * Changes the original font size based on the current mode and also updates the current value on the element.
4705     * @param mode
4706     */
4707    NextendSmartSliderResponsiveElement.prototype.setFontSizeByMode = function () {
4708        this.element.css('fontSize', this.fontSizePrepare(this.data['fontSize'] * this._lastRatio));
4709    };
4710    scope.NextendSmartSliderResponsiveElement = NextendSmartSliderResponsiveElement;
4711
4712
4713    function NextendSmartSliderResponsiveElementBackgroundImage(responsive, backgroundImage, group, element, cssProperties, name) {
4714
4715        this.ratio = -1;
4716        this.relativeRatio = 1;
4717
4718        this.backgroundImage = backgroundImage;
4719
4720        NextendSmartSliderResponsiveElement.prototype.constructor.call(this, responsive, group, element, cssProperties, name);
4721
4722        backgroundImage.addResponsiveElement(this);
4723    };
4724
4725    NextendSmartSliderResponsiveElementBackgroundImage.prototype = Object.create(NextendSmartSliderResponsiveElement.prototype);
4726    NextendSmartSliderResponsiveElementBackgroundImage.prototype.constructor = NextendSmartSliderResponsiveElementBackgroundImage;
4727
4728    NextendSmartSliderResponsiveElementBackgroundImage.prototype.customLoad = function (cssProperties) {
4729        var parent = this.element.parent();
4730        // The images doesn't have their original(not the real dimension, it is the place
4731        // what was taken right after the load) width and height values in the future.
4732        // So we will calculate the original size from the parent element size
4733        // We will assume that the image was 100% width to its parent
4734        this.helper.parentProps = {
4735            width: parent.width(),
4736            height: parent.height()
4737        }
4738        this.backgroundImage.afterLoaded().done($.proxy(function () {
4739            this._lateInitIMG(cssProperties);
4740        }, this));
4741    };
4742
4743    NextendSmartSliderResponsiveElementBackgroundImage.prototype._lateInitIMG = function (cssProperties, e) {
4744        if (this.backgroundImage.mode == 'fill' || this.backgroundImage.mode == 'fit' || this.backgroundImage.mode == 'simple') {
4745            this.refreshRatio();
4746            if (!this.responsive.slider.parameters.dynamicHeight) {
4747                this.setCentered();
4748            }
4749        }
4750
4751        this._lateInit(cssProperties);
4752    };
4753
4754    NextendSmartSliderResponsiveElementBackgroundImage.prototype.afterLoaded = function () {
4755        if (this.backgroundImage.mode == 'fill' || this.backgroundImage.mode == 'fit' || this.backgroundImage.mode == 'simple') {
4756            this.refreshRatio();
4757            if (!this.responsive.slider.parameters.dynamicHeight) {
4758                this.setCentered();
4759            }
4760        }
4761    };
4762
4763    NextendSmartSliderResponsiveElementBackgroundImage.prototype._resize = function (responsiveDimensions, ratio, timeline, duration) {
4764        if (this.responsive.slider.parameters.dynamicHeight) {
4765            this.element.css({
4766                width: '100%',
4767                height: '100%'
4768            });
4769        } else {
4770            var slideOuter = responsiveDimensions.slideouter || responsiveDimensions.slide;
4771
4772            var slideOuterRatio = slideOuter.width / slideOuter.height;
4773            if (this.backgroundImage.mode == 'fill') {
4774                if (slideOuterRatio > this.ratio) {
4775                    this.element.css({
4776                        width: '100%',
4777                        height: 'auto'
4778                    });
4779                } else {
4780                    this.element.css({
4781                        width: 'auto',
4782                        height: '100%'
4783                    });
4784                }
4785            } else if (this.backgroundImage.mode == 'fit') {
4786                if (slideOuterRatio < this.ratio) {
4787                    this.element.css({
4788                        width: '100%',
4789                        height: 'auto'
4790                    });
4791                } else {
4792                    this.element.css({
4793                        width: 'auto',
4794                        height: '100%'
4795                    });
4796                }
4797            }
4798        }
4799
4800        NextendSmartSliderResponsiveElement.prototype._resize.call(this, responsiveDimensions, ratio, timeline, duration);
4801    };
4802
4803    NextendSmartSliderResponsiveElementBackgroundImage.prototype.refreshRatio = function () {
4804        var w = this.element.prop('naturalWidth'),
4805            h = this.element.prop('naturalHeight');
4806        this.ratio = w / h;
4807        var slideW = this.responsive.responsiveDimensions.startSlideWidth,
4808            slideH = this.responsive.responsiveDimensions.startSlideHeight;
4809        this.relativeRatio = (slideW / slideH) / this.ratio;
4810    };
4811
4812    scope.NextendSmartSliderResponsiveElementBackgroundImage = NextendSmartSliderResponsiveElementBackgroundImage;
4813
4814})(n2, window);
4815(function ($, scope, undefined) {
4816
4817    function NextendSmartSliderVimeoItem(slider, id, sliderid, parameters, hasImage) {
4818        this.readyDeferred = $.Deferred();
4819
4820        this.slider = slider;
4821        this.playerId = id;
4822
4823        this.parameters = $.extend({
4824            vimeourl: "//vimeo.com/144598279",
4825            center: 0,
4826            autoplay: "0",
4827            reset: "0",
4828            title: "1",
4829            byline: "1",
4830            portrait: "0",
4831            loop: "0",
4832            color: "00adef",
4833            volume: "-1"
4834        }, parameters);
4835
4836        if (navigator.userAgent.toLowerCase().indexOf("android") > -1) {
4837            this.parameters.autoplay = 0;
4838        }
4839
4840        if (this.parameters.autoplay == 1 || !hasImage) {
4841            this.ready($.proxy(this.initVimeoPlayer, this));
4842        } else {
4843            $("#" + this.playerId).on('click', $.proxy(function () {
4844                this.ready($.proxy(function () {
4845                    this.readyDeferred.done($.proxy(function () {
4846                        this.play();
4847                    }, this));
4848                    this.initVimeoPlayer();
4849                }, this));
4850            }, this));
4851        }
4852    };
4853
4854    NextendSmartSliderVimeoItem.vimeoDeferred = null;
4855
4856    NextendSmartSliderVimeoItem.prototype.ready = function (callback) {
4857        if (NextendSmartSliderVimeoItem.vimeoDeferred === null) {
4858            NextendSmartSliderVimeoItem.vimeoDeferred = $.getScript((window.location.protocol == "https:" ? 'https://secure-a.vimeocdn.com/js/froogaloop2.min.js' : 'http://a.vimeocdn.com/js/froogaloop2.min.js'));
4859        }
4860        NextendSmartSliderVimeoItem.vimeoDeferred.done(callback);
4861    };
4862
4863    NextendSmartSliderVimeoItem.prototype.initVimeoPlayer = function () {
4864        var playerElement = n2('<iframe id="' + this.playerId + '_video" src="//player.vimeo.com/video/' + this.parameters.vimeocode + '?api=1&autoplay=0&player_id=' + this.playerId +
4865        '_video&title=' + this.parameters.title + '&byline=' + this.parameters.byline + '&portrait=' + this.parameters.portrait + '&color=' + this.parameters.color +
4866        '&loop=' + this.parameters.loop + '" style="position: absolute; top:0; left: 0; width: 100%; height: 100%;" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>');
4867        $("#" + this.playerId).append(playerElement);
4868
4869        this.player = $f(playerElement[0]);
4870        this.playerElement = $(this.player.element);
4871        this.player.addEvent('ready', $.proxy(this.onReady, this));
4872    };
4873
4874    NextendSmartSliderVimeoItem.prototype.onReady = function () {
4875        var volume = parseFloat(this.parameters.volume);
4876        if (volume >= 0) {
4877            this.setVolume(volume);
4878        }
4879
4880        this.slideIndex = this.slider.findSlideIndexByElement(this.playerElement);
4881
4882        if (this.parameters.center == 1) {
4883            this.onResize();
4884
4885            this.slider.sliderElement.on('SliderResize', $.proxy(this.onResize, this))
4886        }
4887        var layer = this.playerElement.parent().parent();
4888
4889        this.player.addEvent('play', $.proxy(function () {
4890            this.slider.sliderElement.trigger('mediaStarted', this);
4891            layer.triggerHandler('n2play');
4892        }, this));
4893
4894        this.player.addEvent('pause', $.proxy(function () {
4895            layer.triggerHandler('n2pause');
4896        }));
4897
4898        this.player.addEvent('finish', $.proxy(function () {
4899            this.slider.sliderElement.trigger('mediaEnded', this);
4900            layer.triggerHandler('n2stop');
4901        }, this));
4902
4903        //pause video when slide changed
4904        this.slider.sliderElement.on("mainAnimationStart", $.proxy(function (e, mainAnimation, previousSlideIndex, currentSlideIndex, isSystem) {
4905            if (currentSlideIndex != this.slideIndex) {
4906                if (parseInt(this.parameters.reset)) {
4907                    this.reset();
4908                } else {
4909                    this.pause();
4910                }
4911            }
4912        }, this));
4913
4914        if (this.parameters.autoplay == 1) {
4915            this.slider.visible($.proxy(this.initAutoplay, this));
4916        }
4917        this.readyDeferred.resolve();
4918    };
4919
4920    NextendSmartSliderVimeoItem.prototype.onResize = function () {
4921        var controls = 52,
4922            parent = this.playerElement.parent(),
4923            width = parent.width() + controls,
4924            height = parent.height() + controls,
4925            aspectRatio = 16 / 9,
4926            css = {
4927                width: width,
4928                height: height,
4929                marginLeft: 0,
4930                marginTop: 0
4931            };
4932        if (width / height > aspectRatio) {
4933            css.height = width * aspectRatio;
4934            css.marginTop = (height - css.height) / 2;
4935        } else {
4936            css.width = height * aspectRatio;
4937            css.marginLeft = (width - css.width) / 2;
4938        }
4939        this.playerElement.css(css);
4940    };
4941
4942    NextendSmartSliderVimeoItem.prototype.initAutoplay = function () {
4943
4944        //change slide
4945        this.slider.sliderElement.on("mainAnimationComplete", $.proxy(function (e, mainAnimation, previousSlideIndex, currentSlideIndex, isSystem) {
4946            if (currentSlideIndex == this.slideIndex) {
4947                this.play();
4948            }
4949        }, this));
4950
4951        if (this.slider.currentSlideIndex == this.slideIndex) {
4952            this.play();
4953        }
4954    };
4955
4956    NextendSmartSliderVimeoItem.prototype.play = function () {
4957        this.slider.sliderElement.trigger('mediaStarted', this);
4958        this.player.api("play");
4959    };
4960
4961    NextendSmartSliderVimeoItem.prototype.pause = function () {
4962        this.player.api("pause");
4963    };
4964
4965    NextendSmartSliderVimeoItem.prototype.reset = function () {
4966        this.player.api("seekTo", 0);
4967    };
4968
4969    NextendSmartSliderVimeoItem.prototype.setVolume = function (volume) {
4970        this.player.api('setVolume', volume);
4971    };
4972
4973    scope.NextendSmartSliderVimeoItem = NextendSmartSliderVimeoItem;
4974
4975})(n2, window);
4976(function ($, scope, undefined) {
4977
4978    function NextendSmartSliderYouTubeItem(slider, id, parameters, hasImage) {
4979        this.readyDeferred = $.Deferred();
4980        this.slider = slider;
4981        this.playerId = id;
4982
4983        this.parameters = $.extend({
4984            youtubeurl: "//www.youtube.com/watch?v=MKmIwHAFjSU",
4985            youtubecode: "MKmIwHAFjSU",
4986            center: 0,
4987            autoplay: "1",
4988            theme: "dark",
4989            related: "1",
4990            vq: "default",
4991            volume: "-1",
4992            loop: 0
4993        }, parameters);
4994
4995        if (navigator.userAgent.toLowerCase().indexOf("android") > -1) {
4996            this.parameters.autoplay = 0;
4997        }
4998
4999        if (this.parameters.autoplay == 1 || !hasImage) {
5000            this.ready($.proxy(this.initYoutubePlayer, this));
5001        } else {
5002            $("#" + this.playerId).on('click', $.proxy(function () {
5003                this.ready($.proxy(function () {
5004                    this.readyDeferred.done($.proxy(function () {
5005                        this.play();
5006                    }, this));
5007                    this.initYoutubePlayer();
5008                }, this));
5009            }, this));
5010        }
5011    }
5012
5013    NextendSmartSliderYouTubeItem.YTDeferred = null;
5014    NextendSmartSliderYouTubeItem.prototype.ready = function (callback) {
5015        if (NextendSmartSliderYouTubeItem.YTDeferred === null) {
5016            NextendSmartSliderYouTubeItem.YTDeferred = $.Deferred();
5017            window.onYouTubeIframeAPIReady = $.proxy(NextendSmartSliderYouTubeItem.YTDeferred.resolve, NextendSmartSliderYouTubeItem.YTDeferred);
5018            $.getScript("//www.youtube.com/iframe_api");
5019        }
5020        NextendSmartSliderYouTubeItem.YTDeferred.done(callback);
5021    };
5022
5023
5024    NextendSmartSliderYouTubeItem.prototype.initYoutubePlayer = function () {
5025        var player = $("#" + this.playerId);
5026        var layer = player.closest(".n2-ss-layer");
5027
5028        var vars = {
5029            enablejsapi: 1,
5030            origin: window.location.protocol + "//" + window.location.host,
5031            theme: this.parameters.theme,
5032            modestbranding: 1,
5033            wmode: "opaque",
5034            rel: this.parameters.related,
5035            vq: this.parameters.vq,
5036            start: this.parameters.start
5037        };
5038
5039        if (this.parameters.center == 1) {
5040            vars.controls = 0;
5041            vars.showinfo = 0;
5042        }
5043        if (this.parameters.controls != 1) {
5044            vars.autohide = 1;
5045            vars.controls = 0;
5046            vars.showinfo = 0;
5047        }
5048
5049        if (+(navigator.platform.toUpperCase().indexOf('MAC') >= 0 && navigator.userAgent.search("Firefox") > -1))
5050            vars.html5 = 1;
5051
5052        this.player = new YT.Player(this.playerId, {
5053            videoId: this.parameters.youtubecode,
5054            wmode: 'opaque',
5055            playerVars: vars,
5056            events: {
5057                onReady: $.proxy(this.onReady, this),
5058                onStateChange: $.proxy(function (state) {
5059                    switch (state.data) {
5060                        case YT.PlayerState.PLAYING:
5061                            this.slider.sliderElement.trigger('mediaStarted', this);
5062                            layer.triggerHandler('n2play');
5063                            break;
5064                        case YT.PlayerState.PAUSED:
5065                            layer.triggerHandler('n2pause');
5066                            break;
5067                        case YT.PlayerState.ENDED:
5068                            if (this.parameters.loop == 1) {
5069                                this.player.seekTo(0);
5070                                this.player.playVideo();
5071                            } else {
5072                                this.slider.sliderElement.trigger('mediaEnded', this);
5073                                layer.triggerHandler('n2stop');
5074                            }
5075                            break;
5076
5077                    }
5078                }, this)
5079            }
5080        });
5081
5082        this.playerElement = $("#" + this.playerId);
5083
5084        this.slideIndex = this.slider.findSlideIndexByElement(this.playerElement);
5085        if (this.parameters.center == 1) {
5086            this.onResize();
5087
5088            this.slider.sliderElement.on('SliderResize', $.proxy(this.onResize, this))
5089        }
5090
5091    };
5092
5093    NextendSmartSliderYouTubeItem.prototype.onReady = function (state) {
5094
5095        var volume = parseFloat(this.parameters.volume);
5096        if (volume >= 0) {
5097            this.setVolume(volume);
5098        }
5099
5100        if (this.parameters.autoplay == 1) {
5101            this.slider.visible($.proxy(this.initAutoplay, this));
5102        }
5103
5104        //pause video when slide changed
5105        this.slider.sliderElement.on("mainAnimationStart", $.proxy(function (e, mainAnimation, previousSlideIndex, currentSlideIndex, isSystem) {
5106            if (currentSlideIndex != this.slideIndex) {
5107                this.pause();
5108            }
5109        }, this));
5110        this.readyDeferred.resolve();
5111    };
5112
5113    NextendSmartSliderYouTubeItem.prototype.onResize = function () {
5114        var controls = 100,
5115            parent = this.playerElement.parent(),
5116            width = parent.width(),
5117            height = parent.height() + controls,
5118            aspectRatio = 16 / 9,
5119            css = {
5120                width: width,
5121                height: height,
5122                marginLeft: 0,
5123                marginTop: 0
5124            };
5125        if (width / height > aspectRatio) {
5126            css.height = width * aspectRatio;
5127            css.marginTop = (height - css.height) / 2;
5128        } else {
5129            css.width = height * aspectRatio;
5130            css.marginLeft = (width - css.width) / 2;
5131        }
5132        this.playerElement.css(css);
5133    };
5134
5135    NextendSmartSliderYouTubeItem.prototype.initAutoplay = function () {
5136
5137        //change slide
5138        this.slider.sliderElement.on("mainAnimationComplete", $.proxy(function (e, mainAnimation, previousSlideIndex, currentSlideIndex, isSystem) {
5139            if (currentSlideIndex == this.slideIndex) {
5140                this.play();
5141            }
5142        }, this));
5143
5144        if (this.slider.currentSlideIndex == this.slideIndex) {
5145            this.play();
5146        }
5147    };
5148
5149    NextendSmartSliderYouTubeItem.prototype.play = function () {
5150        if (this.isStopped()) {
5151            this.slider.sliderElement.trigger('mediaStarted', this);
5152            this.player.playVideo();
5153        }
5154    };
5155
5156    NextendSmartSliderYouTubeItem.prototype.pause = function () {
5157        if (!this.isStopped()) {
5158            this.player.pauseVideo();
5159        }
5160    };
5161
5162    NextendSmartSliderYouTubeItem.prototype.stop = function () {
5163        this.player.stopVideo();
5164    };
5165
5166    NextendSmartSliderYouTubeItem.prototype.isStopped = function () {
5167        var state = this.player.getPlayerState();
5168        switch (state) {
5169            case -1:
5170            case 0:
5171            case 2:
5172            case 5:
5173                return true;
5174                break;
5175            default:
5176                return false;
5177                break;
5178        }
5179    };
5180
5181    NextendSmartSliderYouTubeItem.prototype.setVolume = function (volume) {
5182        this.player.setVolume(volume * 100);
5183    };
5184
5185    scope.NextendSmartSliderYouTubeItem = NextendSmartSliderYouTubeItem;
5186
5187})(n2, window);

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.