PageSourceSearch

https://srilankancatering.com/media/nextend/smartslider-frontend/smartslider-frontend.js?1713529013

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