fullpage-rails 0.0.1

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