PageSourceSearch

https://www.kilchomandistillery.com/wp-content/themes/kilchoman/js/jquery.fullpage.js?ver=1790922002

js kilchomandistillery.com collected 2026-10-02 06:20:54 UTC 109,948 bytes, 2,927 lines download raw bytes

1/*!
2 * fullPage 2.9.7
3 * https://github.com/alvarotrigo/fullPage.js
4 * @license MIT licensed
5 *
6 * Copyright (C) 2015 alvarotrigo.com - A project by Alvaro Trigo
7 */
8(function(global, factory) {
9    'use strict';
10    if (typeof define === 'function' && define.amd) {
11        define(['jquery'], function($) {
12            return factory($, global, global.document, global.Math);
13        });
14    } else if (typeof exports === "object" && exports) {
15        module.exports = factory(require('jquery'), global, global.document, global.Math);
16    } else {
17        factory(jQuery, global, global.document, global.Math);
18    }
19})(typeof window !== 'undefined' ? window : this, function($, window, document, Math, undefined) {
20    'use strict';
21
22    // keeping central set of classnames and selectors
23    var WRAPPER =               'fullpage-wrapper';
24    var WRAPPER_SEL =           '.' + WRAPPER;
25
26    // slimscroll
27    var SCROLLABLE =            'fp-scrollable';
28    var SCROLLABLE_SEL =        '.' + SCROLLABLE;
29
30    // util
31    var RESPONSIVE =            'fp-responsive';
32    var NO_TRANSITION =         'fp-notransition';
33    var DESTROYED =             'fp-destroyed';
34    var ENABLED =               'fp-enabled';
35    var VIEWING_PREFIX =        'fp-viewing';
36    var ACTIVE =                'active';
37    var ACTIVE_SEL =            '.' + ACTIVE;
38    var COMPLETELY =            'fp-completely';
39    var COMPLETELY_SEL =        '.' + COMPLETELY;
40
41    // section
42    var SECTION_DEFAULT_SEL =   '.section';
43    var SECTION =               'fp-section';
44    var SECTION_SEL =           '.' + SECTION;
45    var SECTION_ACTIVE_SEL =    SECTION_SEL + ACTIVE_SEL;
46    var SECTION_FIRST_SEL =     SECTION_SEL + ':first';
47    var SECTION_LAST_SEL =      SECTION_SEL + ':last';
48    var TABLE_CELL =            'fp-tableCell';
49    var TABLE_CELL_SEL =        '.' + TABLE_CELL;
50    var AUTO_HEIGHT =           'fp-auto-height';
51    var AUTO_HEIGHT_SEL =       '.fp-auto-height';
52    var NORMAL_SCROLL =         'fp-normal-scroll';
53    var NORMAL_SCROLL_SEL =     '.fp-normal-scroll';
54
55    // section nav
56    var SECTION_NAV =           'fp-nav';
57    var SECTION_NAV_SEL =       '#' + SECTION_NAV;
58    var SECTION_NAV_TOOLTIP =   'fp-tooltip';
59    var SECTION_NAV_TOOLTIP_SEL='.'+SECTION_NAV_TOOLTIP;
60    var SHOW_ACTIVE_TOOLTIP =   'fp-show-active';
61
62    // slide
63    var SLIDE_DEFAULT_SEL =     '.slide';
64    var SLIDE =                 'fp-slide';
65    var SLIDE_SEL =             '.' + SLIDE;
66    var SLIDE_ACTIVE_SEL =      SLIDE_SEL + ACTIVE_SEL;
67    var SLIDES_WRAPPER =        'fp-slides';
68    var SLIDES_WRAPPER_SEL =    '.' + SLIDES_WRAPPER;
69    var SLIDES_CONTAINER =      'fp-slidesContainer';
70    var SLIDES_CONTAINER_SEL =  '.' + SLIDES_CONTAINER;
71    var TABLE =                 'fp-table';
72
73    // slide nav
74    var SLIDES_NAV =            'fp-slidesNav';
75    var SLIDES_NAV_SEL =        '.' + SLIDES_NAV;
76    var SLIDES_NAV_LINK_SEL =   SLIDES_NAV_SEL + ' a';
77    var SLIDES_ARROW =          'fp-controlArrow';
78    var SLIDES_ARROW_SEL =      '.' + SLIDES_ARROW;
79    var SLIDES_PREV =           'fp-prev';
80    var SLIDES_PREV_SEL =       '.' + SLIDES_PREV;
81    var SLIDES_ARROW_PREV =     SLIDES_ARROW + ' ' + SLIDES_PREV;
82    var SLIDES_ARROW_PREV_SEL = SLIDES_ARROW_SEL + SLIDES_PREV_SEL;
83    var SLIDES_NEXT =           'fp-next';
84    var SLIDES_NEXT_SEL =       '.' + SLIDES_NEXT;
85    var SLIDES_ARROW_NEXT =     SLIDES_ARROW + ' ' + SLIDES_NEXT;
86    var SLIDES_ARROW_NEXT_SEL = SLIDES_ARROW_SEL + SLIDES_NEXT_SEL;
87
88    var $window = $(window);
89    var $document = $(document);
90
91    $.fn.fullpage = function(options) {
92        //only once my friend!
93        if($('html').hasClass(ENABLED)){ displayWarnings(); return; }
94
95        // common jQuery objects
96        var $htmlBody = $('html, body');
97        var $body = $('body');
98
99        var FP = $.fn.fullpage;
100
101        // Creating some defaults, extending them with any options that were provided
102        options = $.extend({
103            //navigation
104            menu: false,
105            anchors:[],
106            lockAnchors: false,
107            navigation: false,
108            navigationPosition: 'right',
109            navigationTooltips: [],
110            showActiveTooltip: false,
111            slidesNavigation: false,
112            slidesNavPosition: 'bottom',
113            scrollBar: false,
114            hybrid: false,
115
116            //scrolling
117            css3: true,
118            scrollingSpeed: 700,
119            autoScrolling: true,
120            fitToSection: true,
121            fitToSectionDelay: 1000,
122            easing: 'easeInOutCubic',
123            easingcss3: 'ease',
124            loopBottom: false,
125            loopTop: false,
126            loopHorizontal: true,
127            continuousVertical: false,
128            continuousHorizontal: false,
129            scrollHorizontally: false,
130            interlockedSlides: false,
131            dragAndMove: false,
132            offsetSections: false,
133            resetSliders: false,
134            fadingEffect: false,
135            normalScrollElements: null,
136            scrollOverflow: false,
137            scrollOverflowReset: false,
138            scrollOverflowHandler: $.fn.fp_scrolloverflow ? $.fn.fp_scrolloverflow.iscrollHandler : null,
139            scrollOverflowOptions: null,
140            touchSensitivity: 5,
141            normalScrollElementTouchThreshold: 5,
142            bigSectionsDestination: null,
143
144            //Accessibility
145            keyboardScrolling: true,
146            animateAnchor: true,
147            recordHistory: true,
148
149            //design
150            controlArrows: true,
151            controlArrowColor: '#fff',
152            verticalCentered: true,
153            sectionsColor : [],
154            paddingTop: 0,
155            paddingBottom: 0,
156            fixedElements: null,
157            responsive: 0, //backwards compabitility with responsiveWiddth
158            responsiveWidth: 0,
159            responsiveHeight: 0,
160            responsiveSlides: false,
161            parallax: false,
162            parallaxOptions: {
163                type: 'reveal',
164                percentage: 62,
165                property: 'translate'
166            },
167
168            //Custom selectors
169            sectionSelector: SECTION_DEFAULT_SEL,
170            slideSelector: SLIDE_DEFAULT_SEL,
171
172            //events
173            afterLoad: null,
174            onLeave: null,
175            afterRender: null,
176            afterResize: null,
177            afterReBuild: null,
178            afterSlideLoad: null,
179            onSlideLeave: null,
180            afterResponsive: null,
181
182            lazyLoading: true
183        }, options);
184
185        //flag to avoid very fast sliding for landscape sliders
186        var slideMoving = false;
187
188        var isTouchDevice = navigator.userAgent.match(/(iPhone|iPod|iPad|Android|playbook|silk|BlackBerry|BB10|Windows Phone|Tizen|Bada|webOS|IEMobile|Opera Mini)/);
189        var isTouch = (('ontouchstart' in window) || (navigator.msMaxTouchPoints > 0) || (navigator.maxTouchPoints));
190        var container = $(this);
191        var windowsHeight = $window.height();
192        var isResizing = false;
193        var isWindowFocused = true;
194        var lastScrolledDestiny;
195        var lastScrolledSlide;
196        var canScroll = true;
197        var scrollings = [];
198        var controlPressed;
199        var startingSection;
200        var isScrollAllowed = {};
201        isScrollAllowed.m = {  'up':true, 'down':true, 'left':true, 'right':true };
202        isScrollAllowed.k = $.extend(true,{}, isScrollAllowed.m);
203        var MSPointer = getMSPointer();
204        var events = {
205            touchmove: 'ontouchmove' in window ? 'touchmove' :  MSPointer.move,
206            touchstart: 'ontouchstart' in window ? 'touchstart' :  MSPointer.down
207        };
208        var scrollBarHandler;
209
210        // taken from https://github.com/udacity/ud891/blob/gh-pages/lesson2-focus/07-modals-and-keyboard-traps/solution/modal.js
211        var focusableElementsString = 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [tabindex="0"], [contenteditable]';
212
213        //timeouts
214        var resizeId;
215        var afterSectionLoadsId;
216        var afterSlideLoadsId;
217        var scrollId;
218        var scrollId2;
219        var keydownId;
220        var originals = $.extend(true, {}, options); //deep copy
221
222        displayWarnings();
223
224        //easeInOutCubic animation included in the plugin
225        $.extend($.easing,{ easeInOutCubic: function (x, t, b, c, d) {if ((t/=d/2) < 1) return c/2*t*t*t + b;return c/2*((t-=2)*t*t + 2) + b;}});
226
227        /**
228         * Sets the autoScroll option.
229         * It changes the scroll bar visibility and the history of the site as a result.
230         */
231        function setAutoScrolling(value, type){
232            //removing the transformation
233            if(!value){
234                silentScroll(0);
235            }
236
237            setVariableState('autoScrolling', value, type);
238
239            var element = $(SECTION_ACTIVE_SEL);
240
241            if(options.autoScrolling && !options.scrollBar){
242                $htmlBody.css({
243                    'overflow' : 'hidden',
244                    'height' : '100%'
245                });
246
247                setRecordHistory(originals.recordHistory, 'internal');
248
249                //for IE touch devices
250                container.css({
251                    '-ms-touch-action': 'none',
252                    'touch-action': 'none'
253                });
254
255                if(element.length){
256                    //moving the container up
257                    silentScroll(element.position().top);
258                }
259
260            }else{
261                $htmlBody.css({
262                    'overflow' : 'visible',
263                    'height' : 'initial'
264                });
265
266                setRecordHistory(false, 'internal');
267
268                //for IE touch devices
269                container.css({
270                    '-ms-touch-action': '',
271                    'touch-action': ''
272                });
273
274                //scrolling the page to the section with no animation
275                if (element.length) {
276                    $htmlBody.scrollTop(element.position().top);
277                }
278            }
279        }
280
281        /**
282         * Defines wheter to record the history for each hash change in the URL.
283         */
284        function setRecordHistory(value, type){
285            setVariableState('recordHistory', value, type);
286        }
287
288        /**
289         * Defines the scrolling speed
290         */
291        function setScrollingSpeed(value, type){
292            setVariableState('scrollingSpeed', value, type);
293        }
294
295        /**
296         * Sets fitToSection
297         */
298        function setFitToSection(value, type){
299            setVariableState('fitToSection', value, type);
300        }
301
302        /**
303         * Sets lockAnchors
304         */
305        function setLockAnchors(value){
306            options.lockAnchors = value;
307        }
308
309        /**
310         * Adds or remove the possibility of scrolling through sections by using the mouse wheel or the trackpad.
311         */
312        function setMouseWheelScrolling(value){
313            if(value){
314                addMouseWheelHandler();
315                addMiddleWheelHandler();
316            }else{
317                removeMouseWheelHandler();
318                removeMiddleWheelHandler();
319            }
320        }
321
322        /**
323         * Adds or remove the possibility of scrolling through sections by using the mouse wheel/trackpad or touch gestures.
324         * Optionally a second parameter can be used to specify the direction for which the action will be applied.
325         *
326         * @param directions string containing the direction or directions separated by comma.
327         */
328        function setAllowScrolling(value, directions){
329            if(typeof directions !== 'undefined'){
330                directions = directions.replace(/ /g,'').split(',');
331
332                $.each(directions, function (index, direction){
333                    setIsScrollAllowed(value, direction, 'm');
334                });
335            }
336            else{
337                setIsScrollAllowed(value, 'all', 'm');
338
339                if(value){
340                    setMouseWheelScrolling(true);
341                    addTouchHandler();
342                }else{
343                    setMouseWheelScrolling(false);
344                    removeTouchHandler();
345                }
346            }
347        }
348
349        /**
350         * Adds or remove the possibility of scrolling through sections by using the keyboard arrow keys
351         */
352        function setKeyboardScrolling(value, directions){
353            if(typeof directions !== 'undefined'){
354                directions = directions.replace(/ /g,'').split(',');
355
356                $.each(directions, function (index, direction){
357                    setIsScrollAllowed(value, direction, 'k');
358                });
359            }else{
360                setIsScrollAllowed(value, 'all', 'k');
361                options.keyboardScrolling = value;
362            }
363        }
364
365        /**
366         * Moves the page up one section.
367         */
368        function moveSectionUp(){
369            var prev = $(SECTION_ACTIVE_SEL).prev(SECTION_SEL);
370
371            //looping to the bottom if there's no more sections above
372            if (!prev.length && (options.loopTop || options.continuousVertical)) {
373                prev = $(SECTION_SEL).last();
374            }
375
376            if (prev.length) {
377                scrollPage(prev, null, true);
378            }
379        }
380
381        /**
382         * Moves the page down one section.
383         */
384        function moveSectionDown(){
385            var next = $(SECTION_ACTIVE_SEL).next(SECTION_SEL);
386
387            //looping to the top if there's no more sections below
388            if(!next.length &&
389                (options.loopBottom || options.continuousVertical)){
390                next = $(SECTION_SEL).first();
391            }
392
393            if(next.length){
394                scrollPage(next, null, false);
395            }
396        }
397
398        /**
399         * Moves the page to the given section and slide with no animation.
400         * Anchors or index positions can be used as params.
401         */
402        function silentMoveTo(sectionAnchor, slideAnchor){
403            setScrollingSpeed (0, 'internal');
404            moveTo(sectionAnchor, slideAnchor);
405            setScrollingSpeed (originals.scrollingSpeed, 'internal');
406        }
407
408        /**
409         * Moves the page to the given section and slide.
410         * Anchors or index positions can be used as params.
411         */
412        function moveTo(sectionAnchor, slideAnchor){
413            var destiny = getSectionByAnchor(sectionAnchor);
414
415            if (typeof slideAnchor !== 'undefined'){
416                scrollPageAndSlide(sectionAnchor, slideAnchor);
417            }else if(destiny.length > 0){
418                scrollPage(destiny);
419            }
420        }
421
422        /**
423         * Slides right the slider of the active section.
424         * Optional `section` param.
425         */
426        function moveSlideRight(section){
427            moveSlide('right', section);
428        }
429
430        /**
431         * Slides left the slider of the active section.
432         * Optional `section` param.
433         */
434        function moveSlideLeft(section){
435            moveSlide('left', section);
436        }
437
438        /**
439         * When resizing is finished, we adjust the slides sizes and positions
440         */
441        function reBuild(resizing){
442            if(container.hasClass(DESTROYED)){ return; }  //nothing to do if the plugin was destroyed
443
444            isResizing = true;
445
446            windowsHeight = $window.height();  //updating global var
447
448            $(SECTION_SEL).each(function(){
449                var slidesWrap = $(this).find(SLIDES_WRAPPER_SEL);
450                var slides = $(this).find(SLIDE_SEL);
451
452                //adjusting the height of the table-cell for IE and Firefox
453                if(options.verticalCentered){
454                    $(this).find(TABLE_CELL_SEL).css('height', getTableHeight($(this)) + 'px');
455                }
456
457                $(this).css('height', windowsHeight + 'px');
458
459                //adjusting the position fo the FULL WIDTH slides...
460                if (slides.length > 1) {
461                    landscapeScroll(slidesWrap, slidesWrap.find(SLIDE_ACTIVE_SEL));
462                }
463            });
464
465            if(options.scrollOverflow){
466                scrollBarHandler.createScrollBarForAll();
467            }
468
469            var activeSection = $(SECTION_ACTIVE_SEL);
470            var sectionIndex = activeSection.index(SECTION_SEL);
471
472            //isn't it the first section?
473            if(sectionIndex){
474                //adjusting the position for the current section
475                silentMoveTo(sectionIndex + 1);
476            }
477
478            isResizing = false;
479            $.isFunction( options.afterResize ) && resizing && options.afterResize.call(container);
480            $.isFunction( options.afterReBuild ) && !resizing && options.afterReBuild.call(container);
481        }
482
483        /**
484         * Turns fullPage.js to normal scrolling mode when the viewport `width` or `height`
485         * are smaller than the set limit values.
486         */
487        function setResponsive(active){
488            var isResponsive = $body.hasClass(RESPONSIVE);
489
490            if(active){
491                if(!isResponsive){
492                    setAutoScrolling(false, 'internal');
493                    setFitToSection(false, 'internal');
494                    $(SECTION_NAV_SEL).hide();
495                    $body.addClass(RESPONSIVE);
496                    $.isFunction( options.afterResponsive ) && options.afterResponsive.call( container, active);
497                }
498            }
499            else if(isResponsive){
500                setAutoScrolling(originals.autoScrolling, 'internal');
501                setFitToSection(originals.autoScrolling, 'internal');
502                $(SECTION_NAV_SEL).show();
503                $body.removeClass(RESPONSIVE);
504                $.isFunction( options.afterResponsive ) && options.afterResponsive.call( container, active);
505            }
506        }
507
508        if($(this).length){
509            //public functions
510            FP.version = '2.9.7';
511            FP.setAutoScrolling = setAutoScrolling;
512            FP.setRecordHistory = setRecordHistory;
513            FP.setScrollingSpeed = setScrollingSpeed;
514            FP.setFitToSection = setFitToSection;
515            FP.setLockAnchors = setLockAnchors;
516            FP.setMouseWheelScrolling = setMouseWheelScrolling;
517            FP.setAllowScrolling = setAllowScrolling;
518            FP.setKeyboardScrolling = setKeyboardScrolling;
519            FP.moveSectionUp = moveSectionUp;
520            FP.moveSectionDown = moveSectionDown;
521            FP.silentMoveTo = silentMoveTo;
522            FP.moveTo = moveTo;
523            FP.moveSlideRight = moveSlideRight;
524            FP.moveSlideLeft = moveSlideLeft;
525            FP.fitToSection = fitToSection;
526            FP.reBuild = reBuild;
527            FP.setResponsive = setResponsive;
528            FP.destroy = destroy;
529
530            //functions we want to share across files but which are not
531            //mean to be used on their own by developers
532            FP.shared ={
533                afterRenderActions: afterRenderActions
534            };
535
536            init();
537
538            bindEvents();
539        }
540
541        function init(){
542            //if css3 is not supported, it will use jQuery animations
543            if(options.css3){
544                options.css3 = support3d();
545            }
546
547            options.scrollBar = options.scrollBar || options.hybrid;
548
549            setOptionsFromDOM();
550            prepareDom();
551            setAllowScrolling(true);
552            setAutoScrolling(options.autoScrolling, 'internal');
553            responsive();
554
555            //setting the class for the body element
556            setBodyClass();
557
558            if(document.readyState === 'complete'){
559                scrollToAnchor();
560            }
561            $window.on('load', scrollToAnchor);
562            window.sharedVar = 1;
563            $(document).trigger('customEvent');
564        }
565
566        function bindEvents(){
567            $window
568                //when scrolling...
569                .on('scroll', scrollHandler)
570
571                //detecting any change on the URL to scroll to the given anchor link
572                //(a way to detect back history button as we play with the hashes on the URL)
573                .on('hashchange', hashChangeHandler)
574
575                //when opening a new tab (ctrl + t), `control` won't be pressed when coming back.
576                .blur(blurHandler)
577
578                //when resizing the site, we adjust the heights of the sections, slimScroll...
579                .resize(resizeHandler);
580
581            $document
582                //Sliding with arrow keys, both, vertical and horizontal
583                .keydown(keydownHandler)
584
585                //to prevent scrolling while zooming
586                .keyup(keyUpHandler)
587
588                //Scrolls to the section when clicking the navigation bullet
589                .on('click touchstart', SECTION_NAV_SEL + ' a', sectionBulletHandler)
590
591                //Scrolls the slider to the given slide destination for the given section
592                .on('click touchstart', SLIDES_NAV_LINK_SEL, slideBulletHandler)
593
594                .on('click', SECTION_NAV_TOOLTIP_SEL, tooltipTextHandler);
595
596            //Scrolling horizontally when clicking on the slider controls.
597            $(SECTION_SEL).on('click touchstart', SLIDES_ARROW_SEL, slideArrowHandler);
598
599            /**
600             * Applying normalScroll elements.
601             * Ignoring the scrolls over the specified selectors.
602             */
603            if(options.normalScrollElements){
604                $document.on('mouseenter touchstart', options.normalScrollElements, function () {
605                    setAllowScrolling(false);
606                });
607
608                $document.on('mouseleave touchend', options.normalScrollElements, function(){
609                    setAllowScrolling(true);
610                });
611            }
612        }
613
614        /**
615         * Setting options from DOM elements if they are not provided.
616         */
617        function setOptionsFromDOM(){
618            var sections = container.find(options.sectionSelector);
619
620            //no anchors option? Checking for them in the DOM attributes
621            if(!options.anchors.length){
622                options.anchors = sections.filter('[data-anchor]').map(function(){
623                    return $(this).data('anchor').toString();
624                }).get();
625            }
626
627            //no tooltips option? Checking for them in the DOM attributes
628            if(!options.navigationTooltips.length){
629                options.navigationTooltips = sections.filter('[data-tooltip]').map(function(){
630                    return $(this).data('tooltip').toString();
631                }).get();
632            }
633        }
634
635        /**
636         * Works over the DOM structure to set it up for the current fullpage options.
637         */
638        function prepareDom(){
639            container.css({
640                'height': '100%',
641                'position': 'relative'
642            });
643
644            //adding a class to recognize the container internally in the code
645            container.addClass(WRAPPER);
646            $('html').addClass(ENABLED);
647
648            //due to https://github.com/alvarotrigo/fullPage.js/issues/1502
649            windowsHeight = $window.height();
650
651            container.removeClass(DESTROYED); //in case it was destroyed before initializing it again
652
653            addInternalSelectors();
654
655            //styling the sections / slides / menu
656            $(SECTION_SEL).each(function(index){
657                var section = $(this);
658                var slides = section.find(SLIDE_SEL);
659                var numSlides = slides.length;
660
661                //caching the original styles to add them back on destroy('all')
662                section.data('fp-styles', section.attr('style'));
663
664                styleSection(section, index);
665                styleMenu(section, index);
666
667                // if there's any slide
668                if (numSlides > 0) {
669                    styleSlides(section, slides, numSlides);
670                }else{
671                    if(options.verticalCentered){
672                        addTableClass(section);
673                    }
674                }
675            });
676
677            //fixed elements need to be moved out of the plugin container due to problems with CSS3.
678            if(options.fixedElements && options.css3){
679                $(options.fixedElements).appendTo($body);
680            }
681
682            //vertical centered of the navigation + active bullet
683            if(options.navigation){
684                addVerticalNavigation();
685            }
686
687            enableYoutubeAPI();
688
689            if(options.scrollOverflow){
690                scrollBarHandler = options.scrollOverflowHandler.init(options);
691            }else{
692                afterRenderActions();
693            }
694        }
695
696        /**
697         * Styles the horizontal slides for a section.
698         */
699        function styleSlides(section, slides, numSlides){
700            var sliderWidth = numSlides * 100;
701            var slideWidth = 100 / numSlides;
702
703            slides.wrapAll('<div class="' + SLIDES_CONTAINER + '" />');
704            slides.parent().wrap('<div class="' + SLIDES_WRAPPER + '" />');
705
706            section.find(SLIDES_CONTAINER_SEL).css('width', sliderWidth + '%');
707
708            if(numSlides > 1){
709                if(options.controlArrows){
710                    createSlideArrows(section);
711                }
712
713                if(options.slidesNavigation){
714                    addSlidesNavigation(section, numSlides);
715                }
716            }
717
718            slides.each(function(index) {
719                $(this).css('width', slideWidth + '%');
720
721                if(options.verticalCentered){
722                    addTableClass($(this));
723                }
724            });
725
726            var startingSlide = section.find(SLIDE_ACTIVE_SEL);
727
728            //if the slide won't be an starting point, the default will be the first one
729            //the active section isn't the first one? Is not the first slide of the first section? Then we load that section/sl
729ide by default.
730            if( startingSlide.length &&  ($(SECTION_ACTIVE_SEL).index(SECTION_SEL) !== 0 || ($(SECTION_ACTIVE_SEL).index(SECTION_SEL) === 0 && startingSlide.index() !== 0))){
731                silentLandscapeScroll(startingSlide, 'internal');
732            }else{
733                slides.eq(0).addClass(ACTIVE);
734            }
735        }
736
737        /**
738         * Styling vertical sections
739         */
740        function styleSection(section, index){
741            //if no active section is defined, the 1st one will be the default one
742            if(!index && $(SECTION_ACTIVE_SEL).length === 0) {
743                section.addClass(ACTIVE);
744            }
745            startingSection = $(SECTION_ACTIVE_SEL);
746
747            section.css('height', windowsHeight + 'px');
748
749            if(options.paddingTop){
750                section.css('padding-top', options.paddingTop);
751            }
752
753            if(options.paddingBottom){
754                section.css('padding-bottom', options.paddingBottom);
755            }
756
757            if (typeof options.sectionsColor[index] !==  'undefined') {
758                section.css('background-color', options.sectionsColor[index]);
759            }
760
761            if (typeof options.anchors[index] !== 'undefined') {
762                section.attr('data-anchor', options.anchors[index]);
763            }
764        }
765
766        /**
767         * Sets the data-anchor attributes to the menu elements and activates the current one.
768         */
769        function styleMenu(section, index){
770            if (typeof options.anchors[index] !== 'undefined') {
771                //activating the menu / nav element on load
772                if(section.hasClass(ACTIVE)){
773                    activateMenuAndNav(options.anchors[index], index);
774                }
775            }
776
777            //moving the menu outside the main container if it is inside (avoid problems with fixed positions when using CSS3 tranforms)
778            if(options.menu && options.css3 && $(options.menu).closest(WRAPPER_SEL).length){
779                $(options.menu).appendTo($body);
780            }
781        }
782
783        /**
784         * Adds internal classes to be able to provide customizable selectors
785         * keeping the link with the style sheet.
786         */
787        function addInternalSelectors(){
788            container.find(options.sectionSelector).addClass(SECTION);
789            container.find(options.slideSelector).addClass(SLIDE);
790        }
791
792        /**
793         * Creates the control arrows for the given section
794         */
795        function createSlideArrows(section){
796            section.find(SLIDES_WRAPPER_SEL).after('<div class="' + SLIDES_ARROW_PREV + '"></div><div class="' + SLIDES_ARROW_NEXT + '"></div>');
797
798            if(options.controlArrowColor!='#fff'){
799                section.find(SLIDES_ARROW_NEXT_SEL).css('border-color', 'transparent transparent transparent '+options.controlArrowColor);
800                section.find(SLIDES_ARROW_PREV_SEL).css('border-color', 'transparent '+ options.controlArrowColor + ' transparent transparent');
801            }
802
803            if(!options.loopHorizontal){
804                section.find(SLIDES_ARROW_PREV_SEL).hide();
805            }
806        }
807
808        /**
809         * Creates a vertical navigation bar.
810         */
811        function addVerticalNavigation(){
812            $body.append('<div id="' + SECTION_NAV + '"><ul></ul></div>');
813            var nav = $(SECTION_NAV_SEL);
814
815            nav.addClass(function() {
816                return options.showActiveTooltip ? SHOW_ACTIVE_TOOLTIP + ' ' + options.navigationPosition : options.navigationPosition;
817            });
818
819            for (var i = 0; i < $(SECTION_SEL).length; i++) {
820                var link = '';
821                if (options.anchors.length) {
822                    link = options.anchors[i];
823                }
824
825                var li = '<li><a href="#' + link + '"><span></span></a>';
826
827                // Only add tooltip if needed (defined by user)
828                var tooltip = options.navigationTooltips[i];
829
830                if (typeof tooltip !== 'undefined' && tooltip !== '') {
831                    li += '<div class="' + SECTION_NAV_TOOLTIP + ' ' + options.navigationPosition + '">' + tooltip + '</div>';
832                }
833
834                li += '</li>';
835
836                nav.find('ul').append(li);
837            }
838
839            //centering it vertically
840            $(SECTION_NAV_SEL).css('margin-top', '-' + ($(SECTION_NAV_SEL).height()/2) + 'px');
841
842            //activating the current active section
843            $(SECTION_NAV_SEL).find('li').eq($(SECTION_ACTIVE_SEL).index(SECTION_SEL)).find('a').addClass(ACTIVE);
844        }
845
846        /*
847        * Enables the Youtube videos API so we can control their flow if necessary.
848        */
849        function enableYoutubeAPI(){
850            container.find('iframe[src*="youtube.com/embed/"]').each(function(){
851                addURLParam($(this), 'enablejsapi=1');
852            });
853        }
854
855        /**
856         * Adds a new parameter and its value to the `src` of a given element
857         */
858        function addURLParam(element, newParam){
859            var originalSrc = element.attr('src');
860            element.attr('src', originalSrc + getUrlParamSign(originalSrc) + newParam);
861        }
862
863        /*
864        * Returns the prefix sign to use for a new parameter in an existen URL.
865        *
866        * @return {String}  ? | &
867        */
868        function getUrlParamSign(url){
869            return ( !/\?/.test( url ) ) ? '?' : '&';
870        }
871
872        /**
873         * Actions and callbacks to fire afterRender
874         */
875        function afterRenderActions(){
876            var section = $(SECTION_ACTIVE_SEL);
877
878            section.addClass(COMPLETELY);
879
880            lazyLoad(section);
881            playMedia(section);
882
883            if(options.scrollOverflow){
884                options.scrollOverflowHandler.afterLoad();
885            }
886
887            if(isDestinyTheStartingSection()){
888                $.isFunction( options.afterLoad ) && options.afterLoad.call(section, section.data('anchor'), (section.index(SECTION_SEL) + 1));
889            }
890
891            $.isFunction( options.afterRender ) && options.afterRender.call(container);
892        }
893
894        /**
895         * Determines if the URL anchor destiny is the starting section (the one using 'active' class before initialization)
896         */
897        function isDestinyTheStartingSection(){
898            var destinationSection = getSectionByAnchor(getAnchorsURL().section);
899            return !destinationSection || destinationSection.length && destinationSection.index() === startingSection.index();
900        }
901
902
903        var isScrolling = false;
904        var lastScroll = 0;
905
906        //when scrolling...
907        function scrollHandler(){
908            var currentSection;
909
910            if(!options.autoScrolling || options.scrollBar){
911                var currentScroll = $window.scrollTop();
912                var scrollDirection = getScrollDirection(currentScroll);
913                var visibleSectionIndex = 0;
914                var screen_mid = currentScroll + ($window.height() / 2.0);
915                var isAtBottom = $body.height() - $window.height() === currentScroll;
916                var sections =  document.querySelectorAll(SECTION_SEL);
917
918                //when using `auto-height` for a small last section it won't be centered in the viewport
919                if(isAtBottom){
920                    visibleSectionIndex = sections.length - 1;
921                }
922                //is at top? when using `auto-height` for a small first section it won't be centered in the viewport
923                else if(!currentScroll){
924                    visibleSectionIndex = 0;
925                }
926
927                //taking the section which is showing more content in the viewport
928                else{
929                    for (var i = 0; i < sections.length; ++i) {
930                        var section = sections[i];
931
932                        // Pick the the last section which passes the middle line of the screen.
933                        if (section.offsetTop <= screen_mid)
934                        {
935                            visibleSectionIndex = i;
936                        }
937                    }
938                }
939
940                if(isCompletelyInViewPort(scrollDirection)){
941                    if(!$(SECTION_ACTIVE_SEL).hasClass(COMPLETELY)){
942                        $(SECTION_ACTIVE_SEL).addClass(COMPLETELY).siblings().removeClass(COMPLETELY);
943                    }
944                }
945
946                //geting the last one, the current one on the screen
947                currentSection = $(sections).eq(visibleSectionIndex);
948
949                //setting the visible section as active when manually scrolling
950                //executing only once the first time we reach the section
951                if(!currentSection.hasClass(ACTIVE)){
952                    isScrolling = true;
953                    var leavingSection = $(SECTION_ACTIVE_SEL);
954                    var leavingSectionIndex = leavingSection.index(SECTION_SEL) + 1;
955                    var yMovement = getYmovement(currentSection);
956                    var anchorLink  = currentSection.data('anchor');
957                    var sectionIndex = currentSection.index(SECTION_SEL) + 1;
958                    var activeSlide = currentSection.find(SLIDE_ACTIVE_SEL);
959                    var slideIndex;
960                    var slideAnchorLink;
961
962                    if(activeSlide.length){
963                        slideAnchorLink = activeSlide.data('anchor');
964                        slideIndex = activeSlide.index();
965                    }
966
967                    if(canScroll){
968                        currentSection.addClass(ACTIVE).siblings().removeClass(ACTIVE);
969
970                        $.isFunction( options.onLeave ) && options.onLeave.call( leavingSection, leavingSectionIndex, sectionIndex, yMovement);
971                        $.isFunction( options.afterLoad ) && options.afterLoad.call( currentSection, anchorLink, sectionIndex);
972
973                        stopMedia(leavingSection);
974                        lazyLoad(currentSection);
975                        playMedia(currentSection);
976
977                        activateMenuAndNav(anchorLink, sectionIndex - 1);
978
979                        if(options.anchors.length){
980                            //needed to enter in hashChange event when using the menu with anchor links
981                            lastScrolledDestiny = anchorLink;
982                        }
983                        setState(slideIndex, slideAnchorLink, anchorLink, sectionIndex);
984                    }
985
986                    //small timeout in order to avoid entering in hashChange event when scrolling is not finished yet
987                    clearTimeout(scrollId);
988                    scrollId = setTimeout(function(){
989                        isScrolling = false;
990                    }, 100);
991                }
992
993                if(options.fitToSection){
994                    //for the auto adjust of the viewport to fit a whole section
995                    clearTimeout(scrollId2);
996
997                    scrollId2 = setTimeout(function(){
998                        //checking it again in case it changed during the delay
999                        if(options.fitToSection &&
1000
1001                            //is the destination element bigger than the viewport?
1002                            $(SECTION_ACTIVE_SEL).outerHeight() <= windowsHeight
1003                        ){
1004                            fitToSection();
1005                        }
1006                    }, options.fitToSectionDelay);
1007                }
1008            }
1009        }
1010
1011        /**
1012         * Fits the site to the nearest active section
1013         */
1014        function fitToSection(){
1015            //checking fitToSection again in case it was set to false before the timeout delay
1016            if(canScroll){
1017                //allows to scroll to an active section and
1018                //if the section is already active, we prevent firing callbacks
1019                isResizing = true;
1020
1021                scrollPage($(SECTION_ACTIVE_SEL));
1022                isResizing = false;
1023            }
1024        }
1025
1026        /**
1027         * Determines whether the active section has seen in its whole or not.
1028         */
1029        function isCompletelyInViewPort(movement){
1030            var top = $(SECTION_ACTIVE_SEL).position().top;
1031            var bottom = top + $window.height();
1032
1033            if(movement == 'up'){
1034                return bottom >= ($window.scrollTop() + $window.height());
1035            }
1036            return top <= $window.scrollTop();
1037        }
1038
1039        /**
1040         * Gets the directon of the the scrolling fired by the scroll event.
1041         */
1042        function getScrollDirection(currentScroll){
1043            var direction = currentScroll > lastScroll ? 'down' : 'up';
1044
1045            lastScroll = currentScroll;
1046
1047            //needed for auto-height sections to determine if we want to scroll to the top or bottom of the destination
1048            previousDestTop = currentScroll;
1049
1050            return direction;
1051        }
1052
1053        /**
1054         * Determines the way of scrolling up or down:
1055         * by 'automatically' scrolling a section or by using the default and normal scrolling.
1056         */
1057        function scrolling(type){
1058            if (!isScrollAllowed.m[type]){
1059                return;
1060            }
1061
1062            var scrollSection = (type === 'down') ? moveSectionDown : moveSectionUp;
1063
1064            if(options.scrollOverflow){
1065                var scrollable = options.scrollOverflowHandler.scrollable($(SECTION_ACTIVE_SEL));
1066                var check = (type === 'down') ? 'bottom' : 'top';
1067
1068                if(scrollable.length > 0 ){
1069                    //is the scrollbar at the start/end of the scroll?
1070                    if(options.scrollOverflowHandler.isScrolled(check, scrollable)){
1071                        scrollSection();
1072                    }else{
1073                        return true;
1074                    }
1075                }else{
1076                    // moved up/down
1077                    scrollSection();
1078                }
1079            }else{
1080                // moved up/down
1081                scrollSection();
1082            }
1083        }
1084
1085        /*
1086        * Preventing bouncing in iOS #2285
1087        */
1088        function preventBouncing(event){
1089            var e = event.originalEvent;
1090            if(options.autoScrolling && isReallyTouch(e)){
1091                //preventing the easing on iOS devices
1092                event.preventDefault();
1093            }
1094        }
1095
1096        var touchStartY = 0;
1097        var touchStartX = 0;
1098        var touchEndY = 0;
1099        var touchEndX = 0;
1100
1101        /* Detecting touch events
1102
1103        * As we are changing the top property of the page on scrolling, we can not use the traditional way to detect it.
1104        * This way, the touchstart and the touch moves shows an small difference between them which is the
1105        * used one to determine the direction.
1106        */
1107        function touchMoveHandler(event){
1108            var e = event.originalEvent;
1109            var activeSection = $(e.target).closest(SECTION_SEL);
1110
1111            // additional: if one of the normalScrollElements isn't within options.normalScrollElementTouchThreshold hops up the DOM chain
1112            if (isReallyTouch(e) ) {
1113
1114                if(options.autoScrolling){
1115                    //preventing the easing on iOS devices
1116                    event.preventDefault();
1117                }
1118
1119                var touchEvents = getEventsPage(e);
1120
1121                touchEndY = touchEvents.y;
1122                touchEndX = touchEvents.x;
1123
1124                //if movement in the X axys is greater than in the Y and the currect section has slides...
1125                if (activeSection.find(SLIDES_WRAPPER_SEL).length && Math.abs(touchStartX - touchEndX) > (Math.abs(touchStartY - touchEndY))) {
1126
1127                    //is the movement greater than the minimum resistance to scroll?
1128                    if (!slideMoving && Math.abs(touchStartX - touchEndX) > ($window.outerWidth() / 100 * options.touchSensitivity)) {
1129                        if (touchStartX > touchEndX) {
1130                            if(isScrollAllowed.m.right){
1131                                moveSlideRight(activeSection); //next
1132                            }
1133                        } else {
1134                            if(isScrollAllowed.m.left){
1135                                moveSlideLeft(activeSection); //prev
1136                            }
1137                        }
1138                    }
1139                }
1140
1141                //vertical scrolling (only when autoScrolling is enabled)
1142                else if(options.autoScrolling && canScroll){
1143
1144                    //is the movement greater than the minimum resistance to scroll?
1145                    if (Math.abs(touchStartY - touchEndY) > ($window.height() / 100 * options.touchSensitivity)) {
1146                        if (touchStartY > touchEndY) {
1147                            scrolling('down');
1148                        } else if (touchEndY > touchStartY) {
1149                            scrolling('up');
1150                        }
1151                    }
1152                }
1153            }
1154        }
1155
1156        /**
1157         * As IE >= 10 fires both touch and mouse events when using a mouse in a touchscreen
1158         * this way we make sure that is really a touch event what IE is detecting.
1159         */
1160        function isReallyTouch(e){
1161            //if is not IE   ||  IE is detecting `touch` or `pen`
1162            return typeof e.pointerType === 'undefined' || e.pointerType != 'mouse';
1163        }
1164
1165        /**
1166         * Handler for the touch start event.
1167         */
1168        function touchStartHandler(event){
1169            var e = event.originalEvent;
1170
1171            //stopping the auto scroll to adjust to a section
1172            if(options.fitToSection){
1173                $htmlBody.stop();
1174            }
1175
1176            if(isReallyTouch(e)){
1177                var touchEvents = getEventsPage(e);
1178                touchStartY = touchEvents.y;
1179                touchStartX = touchEvents.x;
1180            }
1181        }
1182
1183        /**
1184         * Gets the average of the last `number` elements of the given array.
1185         */
1186        function getAverage(elements, number){
1187            var sum = 0;
1188
1189            //taking `number` elements from the end to make the average, if there are not enought, 1
1190            var lastElements = elements.slice(Math.max(elements.length - number, 1));
1191
1192            for(var i = 0; i < lastElements.length; i++){
1193                sum = sum + lastElements[i];
1194            }
1195
1196            return Math.ceil(sum/number);
1197        }
1198
1199        /**
1200         * Detecting mousewheel scrolling
1201         *
1202         * http://blogs.sitepointstatic.com/examples/tech/mouse-wheel/index.html
1203         * http://www.sitepoint.com/html5-javascript-mouse-wheel/
1204         */
1205        var prevTime = new Date().getTime();
1206
1207        function MouseWheelHandler(e) {
1208            var curTime = new Date().getTime();
1209            var isNormalScroll = $(COMPLETELY_SEL).hasClass(NORMAL_SCROLL);
1210
1211            //autoscrolling and not zooming?
1212            if(options.autoScrolling && !controlPressed && !isNormalScroll){
1213                // cross-browser wheel delta
1214                e = e || window.event;
1215                var value = e.wheelDelta || -e.deltaY || -e.detail;
1216                var delta = Math.max(-1, Math.min(1, value));
1217
1218                var horizontalDetection = typeof e.wheelDeltaX !== 'undefined' || typeof e.deltaX !== 'undefined';
1219                var isScrollingVertically = (Math.abs(e.wheelDeltaX) < Math.abs(e.wheelDelta)) || (Math.abs(e.deltaX ) < Math.abs(e.deltaY) || !horizontalDetection);
1220
1221                //Limiting the array to 150 (lets not waste memory!)
1222                if(scrollings.length > 149){
1223                    scrollings.shift();
1224                }
1225
1226                //keeping record of the previous scrollings
1227                scrollings.push(Math.abs(value));
1228
1229                //preventing to scroll the site on mouse wheel when scrollbar is present
1230                if(options.scrollBar){
1231                    e.preventDefault ? e.preventDefault() : e.returnValue = false;
1232                }
1233
1234                //time difference between the last scroll and the current one
1235                var timeDiff = curTime-prevTime;
1236                prevTime = curTime;
1237
1238                //haven't they scrolled in a while?
1239                //(enough to be consider a different scrolling action to scroll another section)
1240                if(timeDiff > 200){
1241                    //emptying the array, we dont care about old scrollings for our averages
1242                    scrollings = [];
1243                }
1244
1245                if(canScroll){
1246                    var averageEnd = getAverage(scrollings, 10);
1247                    var averageMiddle = getAverage(scrollings, 70);
1248                    var isAccelerating = averageEnd >= averageMiddle;
1249
1250                    //to avoid double swipes...
1251                    if(isAccelerating && isScrollingVertically){
1252                        //scrolling down?
1253                        if (delta < 0) {
1254                            scrolling('down');
1255
1256                            //scrolling up?
1257                        }else {
1258                            scrolling('up');
1259                        }
1260                    }
1261                }
1262
1263                return false;
1264            }
1265
1266            if(options.fitToSection){
1267                //stopping the auto scroll to adjust to a section
1268                $htmlBody.stop();
1269            }
1270        }
1271
1272        /**
1273         * Slides a slider to the given direction.
1274         * Optional `section` param.
1275         */
1276        function moveSlide(direction, section){
1277            var activeSection = typeof section === 'undefined' ? $(SECTION_ACTIVE_SEL) : section;
1278            var slides = activeSection.find(SLIDES_WRAPPER_SEL);
1279            var numSlides = slides.find(SLIDE_SEL).length;
1280
1281            // more than one slide needed and nothing should be sliding
1282            if (!slides.length || slideMoving || numSlides < 2) {
1283                return;
1284            }
1285
1286            var currentSlide = slides.find(SLIDE_ACTIVE_SEL);
1287            var destiny = null;
1288
1289            if(direction === 'left'){
1290                destiny = currentSlide.prev(SLIDE_SEL);
1291            }else{
1292                destiny = currentSlide.next(SLIDE_SEL);
1293            }
1294
1295            //isn't there a next slide in the secuence?
1296            if(!destiny.length){
1297                //respect loopHorizontal settin
1298                if (!options.loopHorizontal) return;
1299
1300                if(direction === 'left'){
1301                    destiny = currentSlide.siblings(':last');
1302                }else{
1303                    destiny = currentSlide.siblings(':first');
1304                }
1305            }
1306
1307            slideMoving = true;
1308
1309            landscapeScroll(slides, destiny, direction);
1310        }
1311
1312        /**
1313         * Maintains the active slides in the viewport
1314         * (Because the `scroll` animation might get lost with some actions, such as when using continuousVertical)
1315         */
1316        function keepSlidesPosition(){
1317            $(SLIDE_ACTIVE_SEL).each(function(){
1318                silentLandscapeScroll($(this), 'internal');
1319            });
1320        }
1321
1322        var previousDestTop = 0;
1323        /**
1324         * Returns the destination Y position based on the scrolling direction and
1325         * the height of the section.
1326         */
1327        function getDestinationPosition(element){
1328            var elemPosition = element.position();
1329
1330            //top of the desination will be at the top of the viewport
1331            var position = elemPosition.top;
1332            var isScrollingDown =  elemPosition.top > previousDestTop;
1333            var sectionBottom = position - windowsHeight + element.outerHeight();
1334            var bigSectionsDestination = options.bigSectionsDestination;
1335
1336            //is the destination element bigger than the viewport?
1337            if(element.outerHeight() > windowsHeight){
1338                //scrolling up?
1339                if(!isScrollingDown && !bigSectionsDestination || bigSectionsDestination === 'bottom' ){
1340                    position = sectionBottom;
1341                }
1342            }
1343
1344            //sections equal or smaller than the viewport height && scrolling down? ||  is resizing and its in the last section
1345            else if(isScrollingDown || (isResizing && element.is(':last-child')) ){
1346                //The bottom of the destination will be at the bottom of the viewport
1347                position = sectionBottom;
1348            }
1349
1350            /*
1351            Keeping record of the last scrolled position to determine the scrolling direction.
1352            No conventional methods can be used as the scroll bar might not be present
1353            AND the section might not be active if it is auto-height and didnt reach the middle
1354            of the viewport.
1355            */
1356            previousDestTop = position;
1357            return position;
1358        }
1359
1360        /**
1361         * Scrolls the site to the given element and scrolls to the slide if a callback is given.
1362         */
1363        function scrollPage(element, callback, isMovementUp){
1364            if(typeof element === 'undefined'){ return; } //there's no element to scroll, leaving the function
1365
1366            var dtop = getDestinationPosition(element);
1367            var slideAnchorLink;
1368            var slideIndex;
1369
1370            //local variables
1371            var v = {
1372                element: element,
1373                callback: callback,
1374                isMovementUp: isMovementUp,
1375                dtop: dtop,
1376                yMovement: getYmovement(element),
1377                anchorLink: element.data('anchor'),
1378                sectionIndex: element.index(SECTION_SEL),
1379                activeSlide: element.find(SLIDE_ACTIVE_SEL),
1380                activeSection: $(SECTION_ACTIVE_SEL),
1381                leavingSection: $(SECTION_ACTIVE_SEL).index(SECTION_SEL) + 1,
1382
1383                //caching the value of isResizing at the momment the function is called
1384                //because it will be checked later inside a setTimeout and the value might change
1385                localIsResizing: isResizing
1386            };
1387
1388            //quiting when destination scroll is the same as the current one
1389            if((v.activeSection.is(element) && !isResizing) || (options.scrollBar && $window.scrollTop() === v.dtop && !element.hasClass(AUTO_HEIGHT) )){ return; }
1390
1391            if(v.activeSlide.length){
1392                slideAnchorLink = v.activeSlide.data('anchor');
1393                slideIndex = v.activeSlide.index();
1394            }
1395
1396            //callback (onLeave) if the site is not just resizing and readjusting the slides
1397            if($.isFunction(options.onLeave) && !v.localIsResizing){
1398                var direction = v.yMovement;
1399
1400                //required for continousVertical
1401                if(typeof isMovementUp !== 'undefined'){
1402                    direction = isMovementUp ? 'up' : 'down';
1403                }
1404
1405                if(options.onLeave.call(v.activeSection, v.leavingSection, (v.sectionIndex + 1), direction) === false){
1406                    return;
1407                }
1408            }
1409
1410            // If continuousVertical && we need to wrap around
1411            if (options.autoScrolling && options.continuousVertical && typeof (v.isMovementUp) !== "undefined" &&
1412                ((!v.isMovementUp && v.yMovement == 'up') || // Intending to scroll down but about to go up or
1413                    (v.isMovementUp && v.yMovement == 'down'))) { // intending to scroll up but about to go down
1414
1415                v = createInfiniteSections(v);
1416            }
1417
1418            //pausing media of the leaving section (if we are not just resizing, as destinatino will be the same one)
1419            if(!v.localIsResizing){
1420                stopMedia(v.activeSection);
1421            }
1422
1423            if(options.scrollOverflow){
1424                options.scrollOverflowHandler.beforeLeave();
1425            }
1426
1427            element.addClass(ACTIVE).siblings().removeClass(ACTIVE);
1428            lazyLoad(element);
1429
1430            if(options.scrollOverflow){
1431                options.scrollOverflowHandler.onLeave();
1432            }
1433
1434            //preventing from activating the MouseWheelHandler event
1435            //more than once if the page is scrolling
1436            canScroll = false;
1437
1438            setState(slideIndex, slideAnchorLink, v.anchorLink, v.sectionIndex);
1439
1440            performMovement(v);
1441
1442            //flag to avoid callingn `scrollPage()` twice in case of using anchor links
1443            lastScrolledDestiny = v.anchorLink;
1444
1445            //avoid firing it twice (as it does also on scroll)
1446            activateMenuAndNav(v.anchorLink, v.sectionIndex);
1447        }
1448
1449        /**
1450         * Performs the vertical movement (by CSS3 or by jQuery)
1451         */
1452        function performMovement(v){
1453            // using CSS3 translate functionality
1454            if (options.css3 && options.autoScrolling && !options.scrollBar) {
1455                $(document).trigger('customEvent');
1456                window.sharedVar = v.dtop;
1457                // The first section can have a negative value in iOS 10. Not quite sure why: -0.0142822265625
1458                // that's why we round it to 0.
1459                var translate3d = 'translate3d(0px, -' + Math.round(v.dtop) + 'px, 0px)';
1460                transformContainer(translate3d, true);
1461
1462                //even when the scrollingSpeed is 0 there's a little delay, which might cause the
1463                //scrollingSpeed to change in case of using silentMoveTo();
1464                if(options.scrollingSpeed){
1465                    clearTimeout(afterSectionLoadsId);
1466                    afterSectionLoadsId = setTimeout(function () {
1467                        afterSectionLoads(v);
1468                    }, options.scrollingSpeed);
1469                }else{
1470                    afterSectionLoads(v);
1471                }
1472            }
1473
1474            // using jQuery animate
1475            else{
1476                var scrollSettings = getScrollSettings(v);
1477
1478                $(scrollSettings.element).animate(
1479                    scrollSettings.options,
1480                    options.scrollingSpeed, options.easing).promise().done(function () { //only one single callback in case of animating  `html, body`
1481                    if(options.scrollBar){
1482
1483                        /* Hack!
1484                        The timeout prevents setting the most dominant section in the viewport as "active" when the user
1485                        scrolled to a smaller section by using the mousewheel (auto scrolling) rather than draging the scroll bar.
1486
1487                        When using scrollBar:true It seems like the scroll events still getting propagated even after the scrolling animation has finished.
1488                        */
1489                        setTimeout(function(){
1490                            afterSectionLoads(v);
1491                        },30);
1492                    }else{
1493                        afterSectionLoads(v);
1494                    }
1495                });
1496            }
1497        }
1498
1499        /**
1500         * Gets the scrolling settings depending on the plugin autoScrolling option
1501         */
1502        function getScrollSettings(v){
1503            var scroll = {};
1504
1505            if(options.autoScrolling && !options.scrollBar){
1506                scroll.options = { 'top': -v.dtop};
1507                scroll.element = WRAPPER_SEL;
1508            }else{
1509                scroll.options = { 'scrollTop': v.dtop};
1510                scroll.element = 'html, body';
1511            }
1512
1513            return scroll;
1514        }
1515
1516        /**
1517         * Adds sections before or after the current one to create the infinite effect.
1518         */
1519        function createInfiniteSections(v){
1520            // Scrolling down
1521            if (!v.isMovementUp) {
1522                // Move all previous sections to after the active section
1523                $(SECTION_ACTIVE_SEL).after(v.activeSection.prevAll(SECTION_SEL).get().reverse());
1524            }
1525            else { // Scrolling up
1526                // Move all next sections to before the active section
1527                $(SECTION_ACTIVE_SEL).before(v.activeSection.nextAll(SECTION_SEL));
1528            }
1529
1530            // Maintain the displayed position (now that we changed the element order)
1531            silentScroll($(SECTION_ACTIVE_SEL).position().top);
1532
1533            // Maintain the active slides visible in the viewport
1534            keepSlidesPosition();
1535
1536            // save for later the elements that still need to be reordered
1537            v.wrapAroundElements = v.activeSection;
1538
1539            // Recalculate animation variables
1540            v.dtop = v.element.position().top;
1541            v.yMovement = getYmovement(v.element);
1542
1543            //sections will temporally have another position in the DOM
1544            //updating this values in case we need them
1545            v.leavingSection = v.activeSection.index(SECTION_SEL) + 1;
1546            v.sectionIndex = v.element.index(SECTION_SEL);
1547
1548            return v;
1549        }
1550
1551        /**
1552         * Fix section order after continuousVertical changes have been animated
1553         */
1554        function continuousVerticalFixSectionOrder (v) {
1555            // If continuousVertical is in effect (and autoScrolling would also be in effect then),
1556            // finish moving the elements around so the direct navigation will function more simply
1557            if (!v.wrapAroundElements || !v.wrapAroundElements.length) {
1558                return;
1559            }
1560
1561            if (v.isMovementUp) {
1562                $(SECTION_FIRST_SEL).before(v.wrapAroundElements);
1563            }
1564            else {
1565                $(SECTION_LAST_SEL).after(v.wrapAroundElements);
1566            }
1567
1568            silentScroll($(SECTION_ACTIVE_SEL).position().top);
1569
1570            // Maintain the active slides visible in the viewport
1571            keepSlidesPosition();
1572        }
1573
1574
1575        /**
1576         * Actions to do once the section is loaded.
1577         */
1578        function afterSectionLoads (v){
1579            continuousVerticalFixSectionOrder(v);
1580
1581            //callback (afterLoad) if the site is not just resizing and readjusting the slides
1582            $.isFunction(options.afterLoad) && !v.localIsResizing && options.afterLoad.call(v.element, v.anchorLink, (v.sectionIndex + 1));
1583
1584            if(options.scrollOverflow){
1585                options.scrollOverflowHandler.afterLoad();
1586            }
1587
1588            if(!v.localIsResizing){
1589                playMedia(v.element);
1590            }
1591
1592            v.element.addClass(COMPLETELY).siblings().removeClass(COMPLETELY);
1593
1594            canScroll = true;
1595
1596            $.isFunction(v.callback) && v.callback.call(this);
1597        }
1598
1599        /**
1600         * Sets the value for the given attribute from the `data-` attribute with the same suffix
1601         * ie: data-srcset ==> srcset  |  data-src ==> src
1602         */
1603        function setSrc(element, attribute){
1604            element
1605                .attr(attribute, element.data(attribute))
1606                .removeAttr('data-' + attribute);
1607        }
1608
1609        /**
1610         * Lazy loads image, video and audio elements.
1611         */
1612        function lazyLoad(destiny){
1613            if (!options.lazyLoading){
1614                return;
1615            }
1616
1617            var panel = getSlideOrSection(destiny);
1618            var element;
1619
1620            panel.find('img[data-src], img[data-srcset], source[data-src], source[data-srcset], video[data-src], audio[data-src], iframe[data-src]').each(function(){
1621                element = $(this);
1622
1623                $.each(['src', 'srcset'], function(index, type){
1624                    var attribute = element.attr('data-' + type);
1625                    if(typeof attribute !== 'undefined' && attribute){
1626                        setSrc(element, type);
1627                    }
1628                });
1629
1630                if(element.is('source')){
1631                    var typeToPlay = element.closest('video').length ? 'video' : 'audio';
1632                    element.closest(typeToPlay).get(0).load();
1633                }
1634            });
1635        }
1636
1637        /**
1638         * Plays video and audio elements.
1639         */
1640        function playMedia(destiny){
1641            var panel = getSlideOrSection(destiny);
1642
1643            //playing HTML5 media elements
1644            panel.find('video, audio').each(function(){
1645                var element = $(this).get(0);
1646
1647                if( element.hasAttribute('data-autoplay') && typeof element.play === 'function' ) {
1648                    element.play();
1649                }
1650            });
1651
1652            //youtube videos
1653            panel.find('iframe[src*="youtube.com/embed/"]').each(function(){
1654                var element = $(this).get(0);
1655
1656                if ( element.hasAttribute('data-autoplay') ){
1657                    playYoutube(element);
1658                }
1659
1660                //in case the URL was not loaded yet. On page load we need time for the new URL (with the API string) to load.
1661                element.onload = function() {
1662                    if ( element.hasAttribute('data-autoplay') ){
1663                        playYoutube(element);
1664                    }
1665                };
1666            });
1667        }
1668
1669        /**
1670         * Plays a youtube video
1671         */
1672        function playYoutube(element){
1673            element.contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}', '*');
1674        }
1675
1676        /**
1677         * Stops video and audio elements.
1678         */
1679        function stopMedia(destiny){
1680            var panel = getSlideOrSection(destiny);
1681
1682            //stopping HTML5 media elements
1683            panel.find('video, audio').each(function(){
1684                var element = $(this).get(0);
1685
1686                if( !element.hasAttribute('data-keepplaying') && typeof element.pause === 'function' ) {
1687                    element.pause();
1688                }
1689            });
1690
1691            //youtube videos
1692            panel.find('iframe[src*="youtube.com/embed/"]').each(function(){
1693                var element = $(this).get(0);
1694
1695                if( /youtube\.com\/embed\//.test($(this).attr('src')) && !element.hasAttribute('data-keepplaying')){
1696                    $(this).get(0).contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}','*');
1697                }
1698            });
1699        }
1700
1701        /**
1702         * Gets the active slide (or section) for the given section
1703         */
1704        function getSlideOrSection(destiny){
1705            var slide = destiny.find(SLIDE_ACTIVE_SEL);
1706            if( slide.length ) {
1707                destiny = $(slide);
1708            }
1709
1710            return destiny;
1711        }
1712
1713        /**
1714         * Scrolls to the anchor in the URL when loading the site
1715         */
1716        function scrollToAnchor(){
1717            var anchors =  getAnchorsURL();
1718            var sectionAnchor = anchors.section;
1719            var slideAnchor = anchors.slide;
1720
1721            if(sectionAnchor){  //if theres any #
1722                if(options.animateAnchor){
1723                    scrollPageAndSlide(sectionAnchor, slideAnchor);
1724                }else{
1725                    silentMoveTo(sectionAnchor, slideAnchor);
1726                }
1727            }
1728        }
1729
1730        /**
1731         * Detecting any change on the URL to scroll to the given anchor link
1732         * (a way to detect back history button as we play with the hashes on the URL)
1733         */
1734        function hashChangeHandler(){
1735            if(!isScrolling && !options.lockAnchors){
1736                var anchors = getAnchorsURL();
1737                var sectionAnchor = anchors.section;
1738                var slideAnchor = anchors.slide;
1739
1740                //when moving to a slide in the first section for the first time (first time to add an anchor to the URL)
1741                var isFirstSlideMove =  (typeof lastScrolledDestiny === 'undefined');
1742                var isFirstScrollMove = (typeof lastScrolledDestiny === 'undefined' && typeof slideAnchor === 'undefined' && !slideMoving);
1743
1744                if(sectionAnchor && sectionAnchor.length){
1745                    /*in order to call scrollpage() only once for each destination at a time
1746                    It is called twice for each scroll otherwise, as in case of using anchorlinks `hashChange`
1747                    event is fired on every scroll too.*/
1748                    if ((sectionAnchor && sectionAnchor !== lastScrolledDestiny) && !isFirstSlideMove
1749                        || isFirstScrollMove
1750                        || (!slideMoving && lastScrolledSlide != slideAnchor )){
1751
1752                        scrollPageAndSlide(sectionAnchor, slideAnchor);
1753                    }
1754                }
1755            }
1756        }
1757
1758        //gets the URL anchors (section and slide)
1759        function getAnchorsURL(){
1760            var section;
1761            var slide;
1762            var hash = window.location.hash;
1763
1764            if(hash.length){
1765                //getting the anchor link in the URL and deleting the `#`
1766                var anchorsParts =  hash.replace('#', '').split('/');
1767
1768                //using / for visual reasons and not as a section/slide separator #2803
1769                var isFunkyAnchor = hash.indexOf('#/') > -1;
1770
1771                section = isFunkyAnchor ? '/' + anchorsParts[1] : decodeURIComponent(anchorsParts[0]);
1772
1773                var slideAnchor = isFunkyAnchor ? anchorsParts[2] : anchorsParts[1];
1774                if(slideAnchor && slideAnchor.length){
1775                    slide = decodeURIComponent(slideAnchor);
1776                }
1777            }
1778
1779            return {
1780                section: section,
1781                slide: slide
1782            }
1783        }
1784
1785        //Sliding with arrow keys, both, vertical and horizontal
1786        function keydownHandler(e) {
1787            clearTimeout(keydownId);
1788
1789            var activeElement = $(':focus');
1790            var keyCode = e.which;
1791
1792            //tab?
1793            if(keyCode === 9){
1794                onTab(e);
1795            }
1796
1797            else if(!activeElement.is('textarea') && !activeElement.is('input') && !activeElement.is('select') &&
1798                activeElement.attr('contentEditable') !== "true" && activeElement.attr('contentEditable') !== '' &&
1799                options.keyboardScrolling && options.autoScrolling){
1800
1801                //preventing the scroll with arrow keys & spacebar & Page Up & Down keys
1802                var keyControls = [40, 38, 32, 33, 34];
1803                if($.inArray(keyCode, keyControls) > -1){
1804                    e.preventDefault();
1805                }
1806
1807                controlPressed = e.ctrlKey;
1808
1809                keydownId = setTimeout(function(){
1810                    onkeydown(e);
1811                },150);
1812            }
1813        }
1814
1815        function tooltipTextHandler(){
1816            $(this).prev().trigger('click');
1817        }
1818
1819        //to prevent scrolling while zooming
1820        function keyUpHandler(e){
1821            if(isWindowFocused){ //the keyup gets fired on new tab ctrl + t in Firefox
1822                controlPressed = e.ctrlKey;
1823            }
1824        }
1825
1826        //binding the mousemove when the mouse's middle button is released
1827        function mouseDownHandler(e){
1828            //middle button
1829            if (e.which == 2){
1830                oldPageY = e.pageY;
1831                container.on('mousemove', mouseMoveHandler);
1832            }
1833        }
1834
1835        //unbinding the mousemove when the mouse's middle button is released
1836        function mouseUpHandler(e){
1837            //middle button
1838            if (e.which == 2){
1839                container.off('mousemove');
1840            }
1841        }
1842
1843        //Scrolling horizontally when clicking on the slider controls.
1844        function slideArrowHandler(){
1845            var section = $(this).closest(SECTION_SEL);
1846
1847            if ($(this).hasClass(SLIDES_PREV)) {
1848                if(isScrollAllowed.m.left){
1849                    moveSlideLeft(section);
1850                }
1851            } else {
1852                if(isScrollAllowed.m.right){
1853                    moveSlideRight(section);
1854                }
1855            }
1856        }
1857
1858        //when opening a new tab (ctrl + t), `control` won't be pressed when coming back.
1859        function blurHandler(){
1860            isWindowFocused = false;
1861            controlPressed = false;
1862        }
1863
1864        //Scrolls to the section when clicking the navigation bullet
1865        function sectionBulletHandler(e){
1866            e.preventDefault();
1867            var index = $(this).parent().index();
1868            scrollPage($(SECTION_SEL).eq(index));
1869        }
1870
1871        //Scrolls the slider to the given slide destination for the given section
1872        function slideBulletHandler(e){
1873            e.preventDefault();
1874            var slides = $(this).closest(SECTION_SEL).find(SLIDES_WRAPPER_SEL);
1875            var destiny = slides.find(SLIDE_SEL).eq($(this).closest('li').index());
1876
1877            landscapeScroll(slides, destiny);
1878        }
1879
1880        /**
1881         * Keydown event
1882         */
1883        function onkeydown(e){
1884            var shiftPressed = e.shiftKey;
1885
1886            //do nothing if we can not scroll or we are not using horizotnal key arrows.
1887            if(!canScroll && [37,39].indexOf(e.which) < 0){
1888                return;
1889            }
1890
1891            switch (e.which) {
1892                //up
1893                case 38:
1894                case 33:
1895                    if(isScrollAllowed.k.up){
1896                        moveSectionUp();
1897                    }
1898                    break;
1899
1900                //down
1901                case 32: //spacebar
1902                    if(shiftPressed && isScrollAllowed.k.up){
1903                        moveSectionUp();
1904                        break;
1905                    }
1906                /* falls through */
1907                case 40:
1908                case 34:
1909                    if(isScrollAllowed.k.down){
1910                        moveSectionDown();
1911                    }
1912                    break;
1913
1914                //Home
1915                case 36:
1916                    if(isScrollAllowed.k.up){
1917                        moveTo(1);
1918                    }
1919                    break;
1920
1921                //End
1922                case 35:
1923                    if(isScrollAllowed.k.down){
1924                        moveTo( $(SECTION_SEL).length );
1925                    }
1926                    break;
1927
1928                //left
1929                case 37:
1930                    if(isScrollAllowed.k.left){
1931                        moveSlideLeft();
1932                    }
1933                    break;
1934
1935                //right
1936                case 39:
1937                    if(isScrollAllowed.k.right){
1938                        moveSlideRight();
1939                    }
1940                    break;
1941
1942                default:
1943                    return; // exit this handler for other keys
1944            }
1945        }
1946
1947        /**
1948         * Makes sure the tab key will only focus elements within the current section/slide
1949         * preventing this way from breaking the page.
1950         * Based on "Modals and keyboard traps"
1951         * from https://developers.google.com/web/fundamentals/accessibility/focus/using-tabindex
1952         */
1953        function onTab(e){
1954            var isShiftPressed = e.shiftKey;
1955            var activeElement = $(':focus');
1956            var activeSection = $(SECTION_ACTIVE_SEL);
1957            var activeSlide = activeSection.find(SLIDE_ACTIVE_SEL);
1958            var focusableWrapper = activeSlide.length ? activeSlide : activeSection;
1959            var focusableElements = focusableWrapper.find(focusableElementsString).not('[tabindex="-1"]');
1960
1961            function preventAndFocusFirst(e){
1962                e.preventDefault();
1963                return focusableElements.first().focus();
1964            }
1965
1966            //is there an element with focus?
1967            if(activeElement.length){
1968                if(!activeElement.closest(SECTION_ACTIVE_SEL, SLIDE_ACTIVE_SEL).length){
1969                    activeElement = preventAndFocusFirst(e);
1970                }
1971            }
1972
1973            //no element if focused? Let's focus the first one of the section/slide
1974            else{
1975                preventAndFocusFirst(e);
1976            }
1977
1978            //when reached the first or last focusable element of the section/slide
1979            //we prevent the tab action to keep it in the last focusable element
1980            if(!isShiftPressed && activeElement.is(focusableElements.last()) ||
1981                isShiftPressed && activeElement.is(focusableElements.first())
1982            ){
1983                e.preventDefault();
1984            }
1985        }
1986
1987        /**
1988         * Detecting the direction of the mouse movement.
1989         * Used only for the middle button of the mouse.
1990         */
1991        var oldPageY = 0;
1992        function mouseMoveHandler(e){
1993            if(canScroll){
1994                // moving up
1995                if (e.pageY < oldPageY && isScrollAllowed.m.up){
1996                    moveSectionUp();
1997                }
1998
1999                // moving down
2000                else if(e.pageY > oldPageY && isScrollAllowed.m.down){
2001                    moveSectionDown();
2002                }
2003            }
2004            oldPageY = e.pageY;
2005        }
2006
2007        /**
2008         * Scrolls horizontal sliders.
2009         */
2010        function landscapeScroll(slides, destiny, direction){
2011            var section = slides.closest(SECTION_SEL);
2012            var v = {
2013                slides: slides,
2014                destiny: destiny,
2015                direction: direction,
2016                destinyPos: destiny.position(),
2017                slideIndex: destiny.index(),
2018                section: section,
2019                sectionIndex: section.index(SECTION_SEL),
2020                anchorLink: section.data('anchor'),
2021                slidesNav: section.find(SLIDES_NAV_SEL),
2022                slideAnchor:  getAnchor(destiny),
2023                prevSlide: section.find(SLIDE_ACTIVE_SEL),
2024                prevSlideIndex: section.find(SLIDE_ACTIVE_SEL).index(),
2025
2026                //caching the value of isResizing at the momment the function is called
2027                //because it will be checked later inside a setTimeout and the value might change
2028                localIsResizing: isResizing
2029            };
2030            v.xMovement = getXmovement(v.prevSlideIndex, v.slideIndex);
2031
2032            //important!! Only do it when not resizing
2033            if(!v.localIsResizing){
2034                //preventing from scrolling to the next/prev section when using scrollHorizontally
2035                canScroll = false;
2036            }
2037
2038            if(options.onSlideLeave){
2039
2040                //if the site is not just resizing and readjusting the slides
2041                if(!v.localIsResizing && v.xMovement!=='none'){
2042                    if($.isFunction( options.onSlideLeave )){
2043                        if(options.onSlideLeave.call( v.prevSlide, v.anchorLink, (v.sectionIndex + 1), v.prevSlideIndex, v.direction, v.slideIndex ) === false){
2044                            slideMoving = false;
2045                            return;
2046                        }
2047                    }
2048                }
2049            }
2050
2051            destiny.addClass(ACTIVE).siblings().removeClass(ACTIVE);
2052
2053            if(!v.localIsResizing){
2054                stopMedia(v.prevSlide);
2055                lazyLoad(destiny);
2056            }
2057
2058            if(!options.loopHorizontal && options.controlArrows){
2059                //hidding it for the fist slide, showing for the rest
2060                section.find(SLIDES_ARROW_PREV_SEL).toggle(v.slideIndex!==0);
2061
2062                //hidding it for the last slide, showing for the rest
2063                section.find(SLIDES_ARROW_NEXT_SEL).toggle(!destiny.is(':last-child'));
2064            }
2065
2066            //only changing the URL if the slides are in the current section (not for resize re-adjusting)
2067            if(section.hasClass(ACTIVE) && !v.localIsResizing){
2068                setState(v.slideIndex, v.slideAnchor, v.anchorLink, v.sectionIndex);
2069            }
2070
2071            performHorizontalMove(slides, v, true);
2072        }
2073
2074
2075        function afterSlideLoads(v){
2076            activeSlidesNavigation(v.slidesNav, v.slideIndex);
2077
2078            //if the site is not just resizing and readjusting the slides
2079            if(!v.localIsResizing){
2080                $.isFunction( options.afterSlideLoad ) && options.afterSlideLoad.call( v.destiny, v.anchorLink, (v.sectionIndex + 1), v.slideAnchor, v.slideIndex);
2081
2082                //needs to be inside the condition to prevent problems with continuousVertical and scrollHorizontally
2083                //and to prevent double scroll right after a windows resize
2084                canScroll = true;
2085
2086                playMedia(v.destiny);
2087            }
2088
2089            //letting them slide again
2090            slideMoving = false;
2091        }
2092
2093        /**
2094         * Performs the horizontal movement. (CSS3 or jQuery)
2095         *
2096         * @param fireCallback {Bool} - determines whether or not to fire the callback
2097         */
2098        function performHorizontalMove(slides, v, fireCallback){
2099            var destinyPos = v.destinyPos;
2100
2101            if(options.css3){
2102                var translate3d = 'translate3d(-' + Math.round(destinyPos.left) + 'px, 0px, 0px)';
2103
2104                addAnimation(slides.find(SLIDES_CONTAINER_SEL)).css(getTransforms(translate3d));
2105
2106                afterSlideLoadsId = setTimeout(function(){
2107                    fireCallback && afterSlideLoads(v);
2108                }, options.scrollingSpeed, options.easing);
2109            }else{
2110                slides.animate({
2111                    scrollLeft : Math.round(destinyPos.left)
2112                }, options.scrollingSpeed, options.easing, function() {
2113
2114                    fireCallback && afterSlideLoads(v);
2115                });
2116            }
2117        }
2118
2119        /**
2120         * Sets the state for the horizontal bullet navigations.
2121         */
2122        function activeSlidesNavigation(slidesNav, slideIndex){
2123            slidesNav.find(ACTIVE_SEL).removeClass(ACTIVE);
2124            slidesNav.find('li').eq(slideIndex).find('a').addClass(ACTIVE);
2125        }
2126
2127        var previousHeight = windowsHeight;
2128
2129        //when resizing the site, we adjust the heights of the sections, slimScroll...
2130        function resizeHandler(){
2131            //checking if it needs to get responsive
2132            responsive();
2133
2134            // rebuild immediately on touch devices
2135            if (isTouchDevice) {
2136                var activeElement = $(document.activeElement);
2137
2138                //if the keyboard is NOT visible
2139                if (!activeElement.is('textarea') && !activeElement.is('input') && !activeElement.is('select')) {
2140                    var currentHeight = $window.height();
2141
2142                    //making sure the change in the viewport size is enough to force a rebuild. (20 % of the window to avoid problems when hidding scroll bars)
2143                    if( Math.abs(currentHeight - previousHeight) > (20 * Math.max(previousHeight, currentHeight) / 100) ){
2144                        reBuild(true);
2145                        previousHeight = currentHeight;
2146                    }
2147                }
2148            }else{
2149                //in order to call the functions only when the resize is finished
2150                //http://stackoverflow.com/questions/4298612/jquery-how-to-call-resize-event-only-once-its-finished-resizing
2151                clearTimeout(resizeId);
2152
2153                resizeId = setTimeout(function(){
2154                    reBuild(true);
2155                }, 350);
2156            }
2157        }
2158
2159        /**
2160         * Checks if the site needs to get responsive and disables autoScrolling if so.
2161         * A class `fp-responsive` is added to the plugin's container in case the user wants to use it for his own responsive CSS.
2162         */
2163        function responsive(){
2164            var widthLimit = options.responsive || options.responsiveWidth; //backwards compatiblity
2165            var heightLimit = options.responsiveHeight;
2166
2167            //only calculating what we need. Remember its called on the resize event.
2168            var isBreakingPointWidth = widthLimit && $window.outerWidth() < widthLimit;
2169            var isBreakingPointHeight = heightLimit && $window.height() < heightLimit;
2170
2171            if(widthLimit && heightLimit){
2172                console.log("has width & height");
2173                setResponsive(isBreakingPointWidth || isBreakingPointHeight);
2174            }
2175            else if(widthLimit){
2176                setResponsive(isBreakingPointWidth);
2177            }
2178            else if(heightLimit){
2179                setResponsive(isBreakingPointHeight);
2180            }
2181        }
2182
2183        /**
2184         * Adds transition animations for the given element
2185         */
2186        function addAnimation(element){
2187            var transition = 'all ' + options.scrollingSpeed + 'ms ' + options.easingcss3;
2188
2189            element.removeClass(NO_TRANSITION);
2190            return element.css({
2191                '-webkit-transition': transition,
2192                'transition': transition
2193            });
2194        }
2195
2196        /**
2197         * Remove transition animations for the given element
2198         */
2199        function removeAnimation(element){
2200            return element.addClass(NO_TRANSITION);
2201        }
2202
2203        /**
2204         * Activating the vertical navigation bullets according to the given slide name.
2205         */
2206        function activateNavDots(name, sectionIndex){
2207            if(options.navigation){
2208                $(SECTION_NAV_SEL).find(ACTIVE_SEL).removeClass(ACTIVE);
2209                if(name){
2210                    $(SECTION_NAV_SEL).find('a[href="#' + name + '"]').addClass(ACTIVE);
2211                }else{
2212                    $(SECTION_NAV_SEL).find('li').eq(sectionIndex).find('a').addClass(ACTIVE);
2213                }
2214            }
2215        }
2216
2217        /**
2218         * Activating the website main menu elements according to the given slide name.
2219         */
2220        function activateMenuElement(name){
2221            if(options.menu){
2222                $(options.menu).find(ACTIVE_SEL).removeClass(ACTIVE);
2223                $(options.menu).find('[data-menuanchor="'+name+'"]').addClass(ACTIVE);
2224            }
2225        }
2226
2227        /**
2228         * Sets to active the current menu and vertical nav items.
2229         */
2230        function activateMenuAndNav(anchor, index){
2231            activateMenuElement(anchor);
2232            activateNavDots(anchor, index);
2233        }
2234
2235        /**
2236         * Retuns `up` or `down` depending on the scrolling movement to reach its destination
2237         * from the current section.
2238         */
2239        function getYmovement(destiny){
2240            var fromIndex = $(SECTION_ACTIVE_SEL).index(SECTION_SEL);
2241            var toIndex = destiny.index(SECTION_SEL);
2242            if( fromIndex == toIndex){
2243                return 'none';
2244            }
2245            if(fromIndex > toIndex){
2246                return 'up';
2247            }
2248            return 'down';
2249        }
2250
2251        /**
2252         * Retuns `right` or `left` depending on the scrolling movement to reach its destination
2253         * from the current slide.
2254         */
2255        function getXmovement(fromIndex, toIndex){
2256            if( fromIndex == toIndex){
2257                return 'none';
2258            }
2259            if(fromIndex > toIndex){
2260                return 'left';
2261            }
2262            return 'right';
2263        }
2264
2265        function addTableClass(element){
2266            //In case we are styling for the 2nd time as in with reponsiveSlides
2267            if(!element.hasClass(TABLE)){
2268                var wrapper = $('<div class="' + TABLE_CELL + '" />').height(getTableHeight(element));
2269                element.addClass(TABLE).wrapInner(wrapper);
2270            }
2271        }
2272
2273        function getTableHeight(element){
2274            var sectionHeight = windowsHeight;
2275
2276            if(options.paddingTop || options.paddingBottom){
2277                var section = element;
2278                if(!section.hasClass(SECTION)){
2279                    section = element.closest(SECTION_SEL);
2280                }
2281
2282                var paddings = parseInt(section.css('padding-top')) + parseInt(section.css('padding-bottom'));
2283                sectionHeight = (windowsHeight - paddings);
2284            }
2285
2286            return sectionHeight;
2287        }
2288
2289        /**
2290         * Adds a css3 transform property to the container class with or without animation depending on the animated param.
2291         */
2292        function transformContainer(translate3d, animated){
2293            if(animated){
2294                addAnimation(container);
2295            }else{
2296                removeAnimation(container);
2297            }
2298
2299            container.css(getTransforms(translate3d));
2300
2301            //syncronously removing the class after the animation has been applied.
2302            setTimeout(function(){
2303                container.removeClass(NO_TRANSITION);
2304            },10);
2305        }
2306
2307        /**
2308         * Gets a section by its anchor / index
2309         */
2310        function getSectionByAnchor(sectionAnchor){
2311            var section = container.find(SECTION_SEL + '[data-anchor="'+sectionAnchor+'"]');
2312            if(!section.length){
2313                var sectionIndex = typeof sectionAnchor !== 'undefined' ? sectionAnchor -1 : 0;
2314                section = $(SECTION_SEL).eq(sectionIndex);
2315            }
2316
2317            return section;
2318        }
2319
2320        /**
2321         * Gets a slide inside a given section by its anchor / index
2322         */
2323        function getSlideByAnchor(slideAnchor, section){
2324            var slide = section.find(SLIDE_SEL + '[data-anchor="'+slideAnchor+'"]');
2325            if(!slide.length){
2326                slideAnchor = typeof slideAnchor !== 'undefined' ? slideAnchor : 0;
2327                slide = section.find(SLIDE_SEL).eq(slideAnchor);
2328            }
2329
2330            return slide;
2331        }
2332
2333        /**
2334         * Scrolls to the given section and slide anchors
2335         */
2336        function scrollPageAndSlide(sectionAnchor, slideAnchor){
2337            var section = getSectionByAnchor(sectionAnchor);
2338
2339            //do nothing if there's no section with the given anchor name
2340            if(!section.length) return;
2341
2342            var slide = getSlideByAnchor(slideAnchor, section);
2343
2344            //we need to scroll to the section and then to the slide
2345            if (sectionAnchor !== lastScrolledDestiny && !section.hasClass(ACTIVE)){
2346                scrollPage(section, function(){
2347                    scrollSlider(slide);
2348                });
2349            }
2350            //if we were already in the section
2351            else{
2352                scrollSlider(slide);
2353            }
2354        }
2355
2356        /**
2357         * Scrolls the slider to the given slide destination for the given section
2358         */
2359        function scrollSlider(slide){
2360            if(slide.length){
2361                landscapeScroll(slide.closest(SLIDES_WRAPPER_SEL), slide);
2362            }
2363        }
2364
2365        /**
2366         * Creates a landscape navigation bar with dots for horizontal sliders.
2367         */
2368        function addSlidesNavigation(section, numSlides){
2369            section.append('<div class="' + SLIDES_NAV + '"><ul></ul></div>');
2370            var nav = section.find(SLIDES_NAV_SEL);
2371
2372            //top or bottom
2373            nav.addClass(options.slidesNavPosition);
2374
2375            for(var i=0; i< numSlides; i++){
2376                nav.find('ul').append('<li><a href="#"><span></span></a></li>');
2377            }
2378
2379            //centering it
2380            nav.css('margin-left', '-' + (nav.width()/2) + 'px');
2381
2382            nav.find('li').first().find('a').addClass(ACTIVE);
2383        }
2384
2385
2386        /**
2387         * Sets the state of the website depending on the active section/slide.
2388         * It changes the URL hash when needed and updates the body class.
2389         */
2390        function setState(slideIndex, slideAnchor, anchorLink, sectionIndex){
2391            var sectionHash = '';
2392
2393            if(options.anchors.length && !options.lockAnchors){
2394
2395                //isn't it the first slide?
2396                if(slideIndex){
2397                    if(typeof anchorLink !== 'undefined'){
2398                        sectionHash = anchorLink;
2399                    }
2400
2401                    //slide without anchor link? We take the index instead.
2402                    if(typeof slideAnchor === 'undefined'){
2403                        slideAnchor = slideIndex;
2404                    }
2405
2406                    lastScrolledSlide = slideAnchor;
2407                    setUrlHash(sectionHash + '/' + slideAnchor);
2408
2409                    //first slide won't have slide anchor, just the section one
2410                }else if(typeof slideIndex !== 'undefined'){
2411                    lastScrolledSlide = slideAnchor;
2412                    setUrlHash(anchorLink);
2413                }
2414
2415                //section without slides
2416                else{
2417                    setUrlHash(anchorLink);
2418                }
2419            }
2420
2421            setBodyClass();
2422        }
2423
2424        /**
2425         * Sets the URL hash.
2426         */
2427        function setUrlHash(url){
2428            if(options.recordHistory){
2429                location.hash = url;
2430            }else{
2431                //Mobile Chrome doesn't work the normal way, so... lets use HTML5 for phones :)
2432                if(isTouchDevice || isTouch){
2433                    window.history.replaceState(undefined, undefined, '#' + url);
2434                }else{
2435                    var baseUrl = window.location.href.split('#')[0];
2436                    window.location.replace( baseUrl + '#' + url );
2437                }
2438            }
2439        }
2440
2441        /**
2442         * Gets the anchor for the given slide / section. Its index will be used if there's none.
2443         */
2444        function getAnchor(element){
2445            var anchor = element.data('anchor');
2446            var index = element.index();
2447
2448            //Slide without anchor link? We take the index instead.
2449            if(typeof anchor === 'undefined'){
2450                anchor = index;
2451            }
2452
2453            return anchor;
2454        }
2455
2456        /**
2457         * Sets a class for the body of the page depending on the active section / slide
2458         */
2459        function setBodyClass(){
2460            var section = $(SECTION_ACTIVE_SEL);
2461            var slide = section.find(SLIDE_ACTIVE_SEL);
2462
2463            var sectionAnchor = getAnchor(section);
2464            var slideAnchor = getAnchor(slide);
2465
2466            var text = String(sectionAnchor);
2467
2468            if(slide.length){
2469                text = text + '-' + slideAnchor;
2470            }
2471
2472            //changing slash for dash to make it a valid CSS style
2473            text = text.replace('/', '-').replace('#','');
2474
2475            //removing previous anchor classes
2476            var classRe = new RegExp('\\b\\s?' + VIEWING_PREFIX + '-[^\\s]+\\b', "g");
2477            $body[0].className = $body[0].className.replace(classRe, '');
2478
2479            //adding the current anchor
2480            $body.addClass(VIEWING_PREFIX + '-' + text);
2481        }
2482
2483        /**
2484         * Checks for translate3d support
2485         * @return boolean
2486         * http://stackoverflow.com/questions/5661671/detecting-transform-translate3d-support
2487         */
2488        function support3d() {
2489            var el = document.createElement('p'),
2490                has3d,
2491                transforms = {
2492                    'webkitTransform':'-webkit-transform',
2493                    'OTransform':'-o-transform',
2494                    'msTransform':'-ms-transform',
2495                    'MozTransform':'-moz-transform',
2496                    'transform':'transform'
2497                };
2498
2499            // Add it to the body to get the computed style.
2500            document.body.insertBefore(el, null);
2501
2502            for (var t in transforms) {
2503                if (el.style[t] !== undefined) {
2504                    el.style[t] = 'translate3d(1px,1px,1px)';
2505                    has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]);
2506                }
2507            }
2508
2509            document.body.removeChild(el);
2510
2511            return (has3d !== undefined && has3d.length > 0 && has3d !== 'none');
2512        }
2513
2514        /**
2515         * Removes the auto scrolling action fired by the mouse wheel and trackpad.
2516         * After this function is called, the mousewheel and trackpad movements won't scroll through sections.
2517         */
2518        function removeMouseWheelHandler(){
2519            if (document.addEventListener) {
2520                document.removeEventListener('mousewheel', MouseWheelHandler, false); //IE9, Chrome, Safari, Oper
2521                document.removeEventListener('wheel', MouseWheelHandler, false); //Firefox
2522                document.removeEventListener('MozMousePixelScroll', MouseWheelHandler, false); //old Firefox
2523            } else {
2524                document.detachEvent('onmousewheel', MouseWheelHandler); //IE 6/7/8
2525            }
2526        }
2527
2528        /**
2529         * Adds the auto scrolling action for the mouse wheel and trackpad.
2530         * After this function is called, the mousewheel and trackpad movements will scroll through sections
2531         * https://developer.mozilla.org/en-US/docs/Web/Events/wheel
2532         */
2533        function addMouseWheelHandler(){
2534            var prefix = '';
2535            var _addEventListener;
2536
2537            if (window.addEventListener){
2538                _addEventListener = "addEventListener";
2539            }else{
2540                _addEventListener = "attachEvent";
2541                prefix = 'on';
2542            }
2543
2544            // detect available wheel event
2545            var support = 'onwheel' in document.createElement('div') ? 'wheel' : // Modern browsers support "wheel"
2546                document.onmousewheel !== undefined ? 'mousewheel' : // Webkit and IE support at least "mousewheel"
2547                    'DOMMouseScroll'; // let's assume that remaining browsers are older Firefox
2548
2549
2550            if(support == 'DOMMouseScroll'){
2551                document[ _addEventListener ](prefix + 'MozMousePixelScroll', MouseWheelHandler, false);
2552            }
2553
2554            //handle MozMousePixelScroll in older Firefox
2555            else{
2556                document[ _addEventListener ](prefix + support, MouseWheelHandler, false);
2557            }
2558        }
2559
2560        /**
2561         * Binding the mousemove when the mouse's middle button is pressed
2562         */
2563        function addMiddleWheelHandler(){
2564            container
2565                .on('mousedown', mouseDownHandler)
2566                .on('mouseup', mouseUpHandler);
2567        }
2568
2569        /**
2570         * Unbinding the mousemove when the mouse's middle button is released
2571         */
2572        function removeMiddleWheelHandler(){
2573            container
2574                .off('mousedown', mouseDownHandler)
2575                .off('mouseup', mouseUpHandler);
2576        }
2577
2578        /**
2579         * Adds the possibility to auto scroll through sections on touch devices.
2580         */
2581        function addTouchHandler(){
2582            if(isTouchDevice || isTouch){
2583                if(options.autoScrolling){
2584                    $body.off(events.touchmove).on(events.touchmove, preventBouncing);
2585                }
2586
2587                $(WRAPPER_SEL)
2588                    .off(events.touchstart).on(events.touchstart, touchStartHandler)
2589                    .off(events.touchmove).on(events.touchmove, touchMoveHandler);
2590            }
2591        }
2592
2593        /**
2594         * Removes the auto scrolling for touch devices.
2595         */
2596        function removeTouchHandler(){
2597            if(isTouchDevice || isTouch){
2598                if(options.autoScrolling){
2599                    $body.off(events.touchmove);
2600                }
2601
2602                $(WRAPPER_SEL)
2603                    .off(events.touchstart)
2604                    .off(events.touchmove);
2605            }
2606        }
2607
2608        /*
2609        * Returns and object with Microsoft pointers (for IE<11 and for IE >= 11)
2610        * http://msdn.microsoft.com/en-us/library/ie/dn304886(v=vs.85).aspx
2611        */
2612        function getMSPointer(){
2613            var pointer;
2614
2615            //IE >= 11 & rest of browsers
2616            if(window.PointerEvent){
2617                pointer = { down: 'pointerdown', move: 'pointermove'};
2618            }
2619
2620            //IE < 11
2621            else{
2622                pointer = { down: 'MSPointerDown', move: 'MSPointerMove'};
2623            }
2624
2625            return pointer;
2626        }
2627
2628        /**
2629         * Gets the pageX and pageY properties depending on the browser.
2630         * https://github.com/alvarotrigo/fullPage.js/issues/194#issuecomment-34069854
2631         */
2632        function getEventsPage(e){
2633            var events = [];
2634
2635            events.y = (typeof e.pageY !== 'undefined' && (e.pageY || e.pageX) ? e.pageY : e.touches[0].pageY);
2636            events.x = (typeof e.pageX !== 'undefined' && (e.pageY || e.pageX) ? e.pageX : e.touches[0].pageX);
2637
2638            //in touch devices with scroll bar, e.pageY is detected, but we have to deal with touch events. #1008
2639            if(isTouch && isReallyTouch(e) && (options.scrollBar || !options.autoScrolling)){
2640                events.y = e.touches[0].pageY;
2641                events.x = e.touches[0].pageX;
2642            }
2643
2644            return events;
2645        }
2646
2647        /**
2648         * Slides silently (with no animation) the active slider to the given slide.
2649         * @param noCallback {bool} true or defined -> no callbacks
2650         */
2651        function silentLandscapeScroll(activeSlide, noCallbacks){
2652            setScrollingSpeed (0, 'internal');
2653
2654            if(typeof noCallbacks !== 'undefined'){
2655                //preventing firing callbacks afterSlideLoad etc.
2656                isResizing = true;
2657            }
2658
2659            landscapeScroll(activeSlide.closest(SLIDES_WRAPPER_SEL), activeSlide);
2660
2661            if(typeof noCallbacks !== 'undefined'){
2662                isResizing = false;
2663            }
2664
2665            setScrollingSpeed(originals.scrollingSpeed, 'internal');
2666        }
2667
2668        /**
2669         * Scrolls silently (with no animation) the page to the given Y position.
2670         */
2671        function silentScroll(top){
2672            // The first section can have a negative value in iOS 10. Not quite sure why: -0.0142822265625
2673            // that's why we round it to 0.
2674            var roundedTop = Math.round(top);
2675
2676            if (options.css3 && options.autoScrolling && !options.scrollBar){
2677                var translate3d = 'translate3d(0px, -' + roundedTop + 'px, 0px)';
2678                transformContainer(translate3d, false);
2679            }
2680            else if(options.autoScrolling && !options.scrollBar){
2681                container.css('top', -roundedTop);
2682            }
2683            else{
2684                $htmlBody.scrollTop(roundedTop);
2685            }
2686        }
2687
2688        /**
2689         * Returns the cross-browser transform string.
2690         */
2691        function getTransforms(translate3d){
2692            return {
2693                '-webkit-transform': translate3d,
2694                '-moz-transform': translate3d,
2695                '-ms-transform':translate3d,
2696                'transform': translate3d
2697            };
2698        }
2699
2700        /**
2701         * Allowing or disallowing the mouse/swipe scroll in a given direction. (not for keyboard)
2702         * @type  m (mouse) or k (keyboard)
2703         */
2704        function setIsScrollAllowed(value, direction, type){
2705            //up, down, left, right
2706            if(direction !== 'all'){
2707                isScrollAllowed[type][direction] = value;
2708            }
2709
2710            //all directions?
2711            else{
2712                $.each(Object.keys(isScrollAllowed[type]), function(index, key){
2713                    isScrollAllowed[type][key] = value;
2714                });
2715            }
2716        }
2717
2718        /*
2719        * Destroys fullpage.js plugin events and optinally its html markup and styles
2720        */
2721        function destroy(all){
2722            setAutoScrolling(false, 'internal');
2723            setAllowScrolling(false);
2724            setKeyboardScrolling(false);
2725            container.addClass(DESTROYED);
2726
2727            clearTimeout(afterSlideLoadsId);
2728            clearTimeout(afterSectionLoadsId);
2729            clearTimeout(resizeId);
2730            clearTimeout(scrollId);
2731            clearTimeout(scrollId2);
2732
2733            $window
2734                .off('scroll', scrollHandler)
2735                .off('hashchange', hashChangeHandler)
2736                .off('resize', resizeHandler);
2737
2738            $document
2739                .off('keydown', keydownHandler)
2740                .off('keyup', keyUpHandler)
2741                .off('click touchstart', SECTION_NAV_SEL + ' a')
2742                .off('mouseenter', SECTION_NAV_SEL + ' li')
2743                .off('mouseleave', SECTION_NAV_SEL + ' li')
2744                .off('click touchstart', SLIDES_NAV_LINK_SEL)
2745                .off('mouseover', options.normalScrollElements)
2746                .off('mouseout', options.normalScrollElements);
2747
2748            $(SECTION_SEL)
2749                .off('click touchstart', SLIDES_ARROW_SEL);
2750
2751            clearTimeout(afterSlideLoadsId);
2752            clearTimeout(afterSectionLoadsId);
2753
2754            //lets make a mess!
2755            if(all){
2756                destroyStructure();
2757            }
2758        }
2759
2760        /*
2761        * Removes inline styles added by fullpage.js
2762        */
2763        function destroyStructure(){
2764            //reseting the `top` or `translate` properties to 0
2765            silentScroll(0);
2766
2767            //loading all the lazy load content
2768            container.find('img[data-src], source[data-src], audio[data-src], iframe[data-src]').each(function(){
2769                setSrc($(this), 'src');
2770            });
2771
2772            container.find('img[data-srcset]').each(function(){
2773                setSrc($(this), 'srcset');
2774            });
2775
2776            $(SECTION_NAV_SEL + ', ' + SLIDES_NAV_SEL +  ', ' + SLIDES_ARROW_SEL).remove();
2777
2778            //removing inline styles
2779            $(SECTION_SEL).css( {
2780                'height': '',
2781                'background-color' : '',
2782                'padding': ''
2783            });
2784
2785            $(SLIDE_SEL).css( {
2786                'width': ''
2787            });
2788
2789            container.css({
2790                'height': '',
2791                'position': '',
2792                '-ms-touch-action': '',
2793                'touch-action': ''
2794            });
2795
2796            $htmlBody.css({
2797                'overflow': '',
2798                'height': ''
2799            });
2800
2801            // remove .fp-enabled class
2802            $('html').removeClass(ENABLED);
2803
2804            // remove .fp-responsive class
2805            $body.removeClass(RESPONSIVE);
2806
2807            // remove all of the .fp-viewing- classes
2808            $.each($body.get(0).className.split(/\s+/), function (index, className) {
2809                if (className.indexOf(VIEWING_PREFIX) === 0) {
2810                    $body.removeClass(className);
2811                }
2812            });
2813
2814            //removing added classes
2815            $(SECTION_SEL + ', ' + SLIDE_SEL).each(function(){
2816                if(options.scrollOverflowHandler){
2817                    options.scrollOverflowHandler.remove($(this));
2818                }
2819                $(this).removeClass(TABLE + ' ' + ACTIVE);
2820                $(this).attr('style', $(this).data('fp-styles'));
2821            });
2822
2823            removeAnimation(container);
2824
2825            //Unwrapping content
2826            container.find(TABLE_CELL_SEL + ', ' + SLIDES_CONTAINER_SEL + ', ' + SLIDES_WRAPPER_SEL).each(function(){
2827                //unwrap not being use in case there's no child element inside and its just text
2828                $(this).replaceWith(this.childNodes);
2829            });
2830
2831            //removing the applied transition from the fullpage wrapper
2832            container.css({
2833                '-webkit-transition': 'none',
2834                'transition': 'none'
2835            });
2836
2837            //scrolling the page to the top with no animation
2838            $htmlBody.scrollTop(0);
2839
2840            //removing selectors
2841            /*  var usedSelectors = [SECTION, SLIDE, SLIDES_CONTAINER];
2842             $.each(usedSelectors, function(index, value){
2843                 $('.' + value).removeClass(value);
2844             }); */
2845        }
2846
2847        /*
2848        * Sets the state for a variable with multiple states (original, and temporal)
2849        * Some variables such as `autoScrolling` or `recordHistory` might change automatically its state when using `responsive` or `autoScrolling:false`.
2850        * This function is used to keep track of both states, the original and the temporal one.
2851        * If type is not 'internal', then we assume the user is globally changing the variable.
2852        */
2853        function setVariableState(variable, value, type){
2854            options[variable] = value;
2855            if(type !== 'internal'){
2856                originals[variable] = value;
2857            }
2858        }
2859
2860        /**
2861         * Displays warnings
2862         */
2863        function displayWarnings(){
2864            var extensions = ['fadingEffect', 'continuousHorizontal', 'scrollHorizontally', 'interlockedSlides', 'resetSliders', 'responsiveSlides', 'offsetSections', 'dragAndMove', 'scrollOverflowReset', 'parallax'];
2865            if($('html').hasClass(ENABLED)){
2866                showError('error', 'Fullpage.js can only be initialized once and you are doing it multiple times!');
2867                return;
2868            }
2869
2870            // Disable mutually exclusive settings
2871            if (options.continuousVertical &&
2872                (options.loopTop || options.loopBottom)) {
2873                options.continuousVertical = false;
2874                showError('warn', 'Option `loopTop/loopBottom` is mutually exclusive with `continuousVertical`; `continuousVertical` disabled');
2875            }
2876
2877            if(options.scrollBar && options.scrollOverflow){
2878                showError('warn', 'Option `scrollBar` is mutually exclusive with `scrollOverflow`. Sections with scrollOverflow might not work well in Firefox');
2879            }
2880
2881            if(options.continuousVertical && (options.scrollBar || !options.autoScrolling)){
2882                options.continuousVertical = false;
2883                showError('warn', 'Scroll bars (`scrollBar:true` or `autoScrolling:false`) are mutually exclusive with `continuousVertical`; `continuousVertical` disabled');
2884            }
2885
2886            if(options.scrollOverflow && !options.scrollOverflowHandler){
2887                options.scrollOverflow = false;
2888                showError('error', 'The option `scrollOverflow:true` requires the file `scrolloverflow.min.js`. Please include it before fullPage.js.');
2889            }
2890
2891            //using extensions? Wrong file!
2892            $.each(extensions, function(index, extension){
2893                //is the option set to true?
2894                if(options[extension]){
2895                    showError('warn', 'fullpage.js extensions require jquery.fullpage.extensions.min.js file instead of the usual jquery.fullpage.js. Requested: '+ extension);
2896                }
2897            });
2898
2899            //anchors can not have the same value as any element ID or NAME
2900            $.each(options.anchors, function(index, name){
2901
2902                //case insensitive selectors (http://stackoverflow.com/a/19465187/1081396)
2903                var nameAttr = $document.find('[name]').filter(function() {
2904                    return $(this).attr('name') && $(this).attr('name').toLowerCase() == name.toLowerCase();
2905                });
2906
2907                var idAttr = $document.find('[id]').filter(function() {
2908                    return $(this).attr('id') && $(this).attr('id').toLowerCase() == name.toLowerCase();
2909                });
2910
2911                if(idAttr.length || nameAttr.length ){
2912                    showError('error', 'data-anchor tags can not have the same value as any `id` element on the site (or `name` element for IE).');
2913                    idAttr.length && showError('error', '"' + name + '" is is being used by another element `id` property');
2914                    nameAttr.length && showError('error', '"' + name + '" is is being used by another element `name` property');
2915                }
2916            });
2917        }
2918
2919        /**
2920         * Shows a message in the console of the given type.
2921         */
2922        function showError(type, text){
2923            console && console[type] && console[type]('fullPage: ' + text);
2924        }
2925
2926    }; //end of $.fn.fullpage
2927});

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.