fullpagejs-rails 2.7.5.1

This diff has not been reviewed by any users.
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e13697c046407366f1a7cf9f6a5b033ab2e5bfa4
4
+ data.tar.gz: bd520138707aa333d7a08f1290bfcda90d8ee4e1
5
+ SHA512:
6
+ metadata.gz: 82270c9582f1a6fd1bdeb6eae03df376a6b410c819f516e644f942d386be2c4cd60fc531992c7dbebaa8fad10ecb86d0482ad5ba4c7bc84443f8171e42cebcda
7
+ data.tar.gz: f7f887fd67e2c628cb88f48faee96463999c0e3371b735cdc45edf0358445bc2967e4978b5625113b69556780123c6ba198167548abaf4c6de88891a29436b86
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.5
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at wangqsh999@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fullpagejs-rails.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 rocLv
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,56 @@
1
+ # Fullpagejs::Rails
2
+
3
+ This is fullpagejs' wrap. For more information, please forward to [fullpagejs](https://github.com/alvarotrigo/fullpage.js)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'fullpagejs-rails'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install fullpagejs-rails
20
+
21
+ ## Usage
22
+
23
+ Add this line to your application's app/assets/stylesheets/application.scss file:
24
+
25
+ ```scss
26
+ @import 'jquery.fullpage';
27
+ ```
28
+ Or add this line to your applications's app/assets/stylesheets/application.css
29
+ file:
30
+
31
+ ```css
32
+ *= require jquery.fullpage
33
+ ```
34
+
35
+ Add this line to your applications's app/assets/javascripts/application.js file:
36
+
37
+ ```javascript
38
+ //= require jquery
39
+ //= require jquery_ujs
40
+ //= require jquery.fullpage
41
+ ```
42
+ ## Development
43
+
44
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
45
+
46
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
47
+
48
+ ## Contributing
49
+
50
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/fullpagejs-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
51
+
52
+
53
+ ## License
54
+
55
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
56
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "fullpagejs/rails"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fullpagejs/rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fullpagejs-rails"
8
+ spec.version = Fullpagejs::Rails::VERSION
9
+ spec.authors = ["rocLv"]
10
+ spec.email = ["wangqsh999@gmail.com"]
11
+
12
+ spec.summary = %q{ This is fullpagejs' wrap. }
13
+ spec.description = %q{ This is fullpagejs' wrap. For more information, please forward to https://github.com/alvarotrigo/fullpage.js }
14
+ spec.homepage = "https://github.com/roclv/fullpagejs-rails"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.12"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_development_dependency "rspec", "~> 3.0"
23
+
24
+ spec.add_dependency "railties", '> 3.1'
25
+ end
@@ -0,0 +1,7 @@
1
+ require "fullpagejs/rails/version"
2
+ require "fullpagejs/rails/engine"
3
+
4
+ module Fullpagejs
5
+ module Rails
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ module Fullpagejs
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Fullpagejs
2
+ module Rails
3
+ VERSION = "2.7.5.1"
4
+ end
5
+ end
@@ -0,0 +1,2929 @@
1
+ /*!
2
+ * fullPage 2.8.2
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
+
30
+ // util
31
+ var RESPONSIVE = 'fp-responsive';
32
+ var NO_TRANSITION = 'fp-notransition';
33
+ var DESTROYED = 'fp-destroyed';
34
+ var ENABLED = 'fp-enabled';
35
+ var VIEWING_PREFIX = 'fp-viewing';
36
+ var ACTIVE = 'active';
37
+ var ACTIVE_SEL = '.' + ACTIVE;
38
+ var COMPLETELY = 'fp-completely';
39
+ var COMPLETELY_SEL = '.' + COMPLETELY;
40
+
41
+ // section
42
+ var SECTION_DEFAULT_SEL = '.section';
43
+ var SECTION = 'fp-section';
44
+ var SECTION_SEL = '.' + SECTION;
45
+ var SECTION_ACTIVE_SEL = SECTION_SEL + ACTIVE_SEL;
46
+ var SECTION_FIRST_SEL = SECTION_SEL + ':first';
47
+ var SECTION_LAST_SEL = SECTION_SEL + ':last';
48
+ var TABLE_CELL = 'fp-tableCell';
49
+ var TABLE_CELL_SEL = '.' + TABLE_CELL;
50
+ var AUTO_HEIGHT = 'fp-auto-height';
51
+ var AUTO_HEIGHT_SEL = '.fp-auto-height';
52
+ var NORMAL_SCROLL = 'fp-normal-scroll';
53
+ var NORMAL_SCROLL_SEL = '.fp-normal-scroll';
54
+
55
+ // section nav
56
+ var SECTION_NAV = 'fp-nav';
57
+ var SECTION_NAV_SEL = '#' + SECTION_NAV;
58
+ var SECTION_NAV_TOOLTIP = 'fp-tooltip';
59
+ var SECTION_NAV_TOOLTIP_SEL='.'+SECTION_NAV_TOOLTIP;
60
+ var SHOW_ACTIVE_TOOLTIP = 'fp-show-active';
61
+
62
+ // slide
63
+ var SLIDE_DEFAULT_SEL = '.slide';
64
+ var SLIDE = 'fp-slide';
65
+ var SLIDE_SEL = '.' + SLIDE;
66
+ var SLIDE_ACTIVE_SEL = SLIDE_SEL + ACTIVE_SEL;
67
+ var SLIDES_WRAPPER = 'fp-slides';
68
+ var SLIDES_WRAPPER_SEL = '.' + SLIDES_WRAPPER;
69
+ var SLIDES_CONTAINER = 'fp-slidesContainer';
70
+ var SLIDES_CONTAINER_SEL = '.' + SLIDES_CONTAINER;
71
+ var TABLE = 'fp-table';
72
+
73
+ // slide nav
74
+ var SLIDES_NAV = 'fp-slidesNav';
75
+ var SLIDES_NAV_SEL = '.' + SLIDES_NAV;
76
+ var SLIDES_NAV_LINK_SEL = SLIDES_NAV_SEL + ' a';
77
+ var SLIDES_ARROW = 'fp-controlArrow';
78
+ var SLIDES_ARROW_SEL = '.' + SLIDES_ARROW;
79
+ var SLIDES_PREV = 'fp-prev';
80
+ var SLIDES_PREV_SEL = '.' + SLIDES_PREV;
81
+ var SLIDES_ARROW_PREV = SLIDES_ARROW + ' ' + SLIDES_PREV;
82
+ var SLIDES_ARROW_PREV_SEL = SLIDES_ARROW_SEL + SLIDES_PREV_SEL;
83
+ var SLIDES_NEXT = 'fp-next';
84
+ var SLIDES_NEXT_SEL = '.' + SLIDES_NEXT;
85
+ var SLIDES_ARROW_NEXT = SLIDES_ARROW + ' ' + SLIDES_NEXT;
86
+ var SLIDES_ARROW_NEXT_SEL = SLIDES_ARROW_SEL + SLIDES_NEXT_SEL;
87
+
88
+ var $window = $(window);
89
+ var $document = $(document);
90
+
91
+ // Default options for iScroll.js used when using scrollOverflow
92
+ var iscrollOptions = {
93
+ scrollbars: true,
94
+ mouseWheel: true,
95
+ hideScrollbars: false,
96
+ fadeScrollbars: false,
97
+ disableMouse: true
98
+ };
99
+
100
+ $.fn.fullpage = function(options) {
101
+ //only once my friend!
102
+ if($('html').hasClass(ENABLED)){ displayWarnings(); return; }
103
+
104
+ // common jQuery objects
105
+ var $htmlBody = $('html, body');
106
+ var $body = $('body');
107
+
108
+ var FP = $.fn.fullpage;
109
+
110
+ // Create some defaults, extending them with any options that were provided
111
+ options = $.extend({
112
+ //navigation
113
+ menu: false,
114
+ anchors:[],
115
+ lockAnchors: false,
116
+ navigation: false,
117
+ navigationPosition: 'right',
118
+ navigationTooltips: [],
119
+ showActiveTooltip: false,
120
+ slidesNavigation: false,
121
+ slidesNavPosition: 'bottom',
122
+ scrollBar: false,
123
+ hybrid: false,
124
+
125
+ //scrolling
126
+ css3: true,
127
+ scrollingSpeed: 700,
128
+ autoScrolling: true,
129
+ fitToSection: true,
130
+ fitToSectionDelay: 1000,
131
+ easing: 'easeInOutCubic',
132
+ easingcss3: 'ease',
133
+ loopBottom: false,
134
+ loopTop: false,
135
+ loopHorizontal: true,
136
+ continuousVertical: false,
137
+ normalScrollElements: null,
138
+ scrollOverflow: false,
139
+ scrollOverflowHandler: iscrollHandler,
140
+ scrollOverflowOptions: null,
141
+ touchSensitivity: 5,
142
+ normalScrollElementTouchThreshold: 5,
143
+ bigSectionsDestination: null,
144
+
145
+ //Accessibility
146
+ keyboardScrolling: true,
147
+ animateAnchor: true,
148
+ recordHistory: true,
149
+
150
+ //design
151
+ controlArrows: true,
152
+ controlArrowColor: '#fff',
153
+ verticalCentered: true,
154
+ sectionsColor : [],
155
+ paddingTop: 0,
156
+ paddingBottom: 0,
157
+ fixedElements: null,
158
+ responsive: 0, //backwards compabitility with responsiveWiddth
159
+ responsiveWidth: 0,
160
+ responsiveHeight: 0,
161
+
162
+ //Custom selectors
163
+ sectionSelector: SECTION_DEFAULT_SEL,
164
+ slideSelector: SLIDE_DEFAULT_SEL,
165
+
166
+
167
+ //events
168
+ afterLoad: null,
169
+ onLeave: null,
170
+ afterRender: null,
171
+ afterResize: null,
172
+ afterReBuild: null,
173
+ afterSlideLoad: null,
174
+ onSlideLeave: null
175
+ }, options);
176
+
177
+ //flag to avoid very fast sliding for landscape sliders
178
+ var slideMoving = false;
179
+
180
+ var isTouchDevice = navigator.userAgent.match(/(iPhone|iPod|iPad|Android|playbook|silk|BlackBerry|BB10|Windows Phone|Tizen|Bada|webOS|IEMobile|Opera Mini)/);
181
+ var isTouch = (('ontouchstart' in window) || (navigator.msMaxTouchPoints > 0) || (navigator.maxTouchPoints));
182
+ var container = $(this);
183
+ var windowsHeight = $window.height();
184
+ var isResizing = false;
185
+ var isWindowFocused = true;
186
+ var lastScrolledDestiny;
187
+ var lastScrolledSlide;
188
+ var canScroll = true;
189
+ var scrollings = [];
190
+ var controlPressed;
191
+ var isScrollAllowed = {};
192
+ isScrollAllowed.m = { 'up':true, 'down':true, 'left':true, 'right':true };
193
+ isScrollAllowed.k = $.extend(true,{}, isScrollAllowed.m);
194
+
195
+ //timeouts
196
+ var resizeId;
197
+ var afterSectionLoadsId;
198
+ var afterSlideLoadsId;
199
+ var scrollId;
200
+ var scrollId2;
201
+ var keydownId;
202
+ var originals = $.extend(true, {}, options); //deep copy
203
+
204
+ displayWarnings();
205
+
206
+ //fixing bug in iScroll with links: https://github.com/cubiq/iscroll/issues/783
207
+ iscrollOptions.click = isTouch; // see #2035
208
+
209
+ //extending iScroll options with the user custom ones
210
+ iscrollOptions = $.extend(iscrollOptions, options.scrollOverflowOptions);
211
+
212
+ //easeInOutCubic animation included in the plugin
213
+ $.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;}});
214
+
215
+ /**
216
+ * Sets the autoScroll option.
217
+ * It changes the scroll bar visibility and the history of the site as a result.
218
+ */
219
+ FP.setAutoScrolling = function(value, type){
220
+ setVariableState('autoScrolling', value, type);
221
+
222
+ var element = $(SECTION_ACTIVE_SEL);
223
+
224
+ if(options.autoScrolling && !options.scrollBar){
225
+ $htmlBody.css({
226
+ 'overflow' : 'hidden',
227
+ 'height' : '100%'
228
+ });
229
+
230
+ FP.setRecordHistory(originals.recordHistory, 'internal');
231
+
232
+ //for IE touch devices
233
+ container.css({
234
+ '-ms-touch-action': 'none',
235
+ 'touch-action': 'none'
236
+ });
237
+
238
+ if(element.length){
239
+ //moving the container up
240
+ silentScroll(element.position().top);
241
+ }
242
+
243
+ }else{
244
+ $htmlBody.css({
245
+ 'overflow' : 'visible',
246
+ 'height' : 'initial'
247
+ });
248
+
249
+ FP.setRecordHistory(false, 'internal');
250
+
251
+ //for IE touch devices
252
+ container.css({
253
+ '-ms-touch-action': '',
254
+ 'touch-action': ''
255
+ });
256
+
257
+ silentScroll(0);
258
+
259
+ //scrolling the page to the section with no animation
260
+ if (element.length) {
261
+ $htmlBody.scrollTop(element.position().top);
262
+ }
263
+ }
264
+ };
265
+
266
+ /**
267
+ * Defines wheter to record the history for each hash change in the URL.
268
+ */
269
+ FP.setRecordHistory = function(value, type){
270
+ setVariableState('recordHistory', value, type);
271
+ };
272
+
273
+ /**
274
+ * Defines the scrolling speed
275
+ */
276
+ FP.setScrollingSpeed = function(value, type){
277
+ setVariableState('scrollingSpeed', value, type);
278
+ };
279
+
280
+ /**
281
+ * Sets fitToSection
282
+ */
283
+ FP.setFitToSection = function(value, type){
284
+ setVariableState('fitToSection', value, type);
285
+ };
286
+
287
+ /**
288
+ * Sets lockAnchors
289
+ */
290
+ FP.setLockAnchors = function(value){
291
+ options.lockAnchors = value;
292
+ };
293
+
294
+ /**
295
+ * Adds or remove the possiblity of scrolling through sections by using the mouse wheel or the trackpad.
296
+ */
297
+ FP.setMouseWheelScrolling = function (value){
298
+ if(value){
299
+ addMouseWheelHandler();
300
+ addMiddleWheelHandler();
301
+ }else{
302
+ removeMouseWheelHandler();
303
+ removeMiddleWheelHandler();
304
+ }
305
+ };
306
+
307
+ /**
308
+ * Adds or remove the possiblity of scrolling through sections by using the mouse wheel/trackpad or touch gestures.
309
+ * Optionally a second parameter can be used to specify the direction for which the action will be applied.
310
+ *
311
+ * @param directions string containing the direction or directions separated by comma.
312
+ */
313
+ FP.setAllowScrolling = function (value, directions){
314
+ if(typeof directions !== 'undefined'){
315
+ directions = directions.replace(/ /g,'').split(',');
316
+
317
+ $.each(directions, function (index, direction){
318
+ setIsScrollAllowed(value, direction, 'm');
319
+ });
320
+ }
321
+ else if(value){
322
+ FP.setMouseWheelScrolling(true);
323
+ addTouchHandler();
324
+ }else{
325
+ FP.setMouseWheelScrolling(false);
326
+ removeTouchHandler();
327
+ }
328
+ };
329
+
330
+ /**
331
+ * Adds or remove the possiblity of scrolling through sections by using the keyboard arrow keys
332
+ */
333
+ FP.setKeyboardScrolling = function (value, directions){
334
+ if(typeof directions !== 'undefined'){
335
+ directions = directions.replace(/ /g,'').split(',');
336
+
337
+ $.each(directions, function (index, direction){
338
+ setIsScrollAllowed(value, direction, 'k');
339
+ });
340
+ }else{
341
+ options.keyboardScrolling = value;
342
+ }
343
+ };
344
+
345
+ /**
346
+ * Moves the page up one section.
347
+ */
348
+ FP.moveSectionUp = function(){
349
+ var prev = $(SECTION_ACTIVE_SEL).prev(SECTION_SEL);
350
+
351
+ //looping to the bottom if there's no more sections above
352
+ if (!prev.length && (options.loopTop || options.continuousVertical)) {
353
+ prev = $(SECTION_SEL).last();
354
+ }
355
+
356
+ if (prev.length) {
357
+ scrollPage(prev, null, true);
358
+ }
359
+ };
360
+
361
+ /**
362
+ * Moves the page down one section.
363
+ */
364
+ FP.moveSectionDown = function (){
365
+ var next = $(SECTION_ACTIVE_SEL).next(SECTION_SEL);
366
+
367
+ //looping to the top if there's no more sections below
368
+ if(!next.length &&
369
+ (options.loopBottom || options.continuousVertical)){
370
+ next = $(SECTION_SEL).first();
371
+ }
372
+
373
+ if(next.length){
374
+ scrollPage(next, null, false);
375
+ }
376
+ };
377
+
378
+ /**
379
+ * Moves the page to the given section and slide with no animation.
380
+ * Anchors or index positions can be used as params.
381
+ */
382
+ FP.silentMoveTo = function(sectionAnchor, slideAnchor){
383
+ FP.setScrollingSpeed (0, 'internal');
384
+ FP.moveTo(sectionAnchor, slideAnchor);
385
+ FP.setScrollingSpeed (originals.scrollingSpeed, 'internal');
386
+ };
387
+
388
+ /**
389
+ * Moves the page to the given section and slide.
390
+ * Anchors or index positions can be used as params.
391
+ */
392
+ FP.moveTo = function (sectionAnchor, slideAnchor){
393
+ var destiny = getSectionByAnchor(sectionAnchor);
394
+
395
+ if (typeof slideAnchor !== 'undefined'){
396
+ scrollPageAndSlide(sectionAnchor, slideAnchor);
397
+ }else if(destiny.length > 0){
398
+ scrollPage(destiny);
399
+ }
400
+ };
401
+
402
+ /**
403
+ * Slides right the slider of the active section.
404
+ * Optional `section` param.
405
+ */
406
+ FP.moveSlideRight = function(section){
407
+ moveSlide('next', section);
408
+ };
409
+
410
+ /**
411
+ * Slides left the slider of the active section.
412
+ * Optional `section` param.
413
+ */
414
+ FP.moveSlideLeft = function(section){
415
+ moveSlide('prev', section);
416
+ };
417
+
418
+ /**
419
+ * When resizing is finished, we adjust the slides sizes and positions
420
+ */
421
+ FP.reBuild = function(resizing){
422
+ if(container.hasClass(DESTROYED)){ return; } //nothing to do if the plugin was destroyed
423
+
424
+ isResizing = true;
425
+
426
+ windowsHeight = $window.height(); //updating global var
427
+
428
+ $(SECTION_SEL).each(function(){
429
+ var slidesWrap = $(this).find(SLIDES_WRAPPER_SEL);
430
+ var slides = $(this).find(SLIDE_SEL);
431
+
432
+ //adjusting the height of the table-cell for IE and Firefox
433
+ if(options.verticalCentered){
434
+ $(this).find(TABLE_CELL_SEL).css('height', getTableHeight($(this)) + 'px');
435
+ }
436
+
437
+ $(this).css('height', windowsHeight + 'px');
438
+
439
+ //resizing the scrolling divs
440
+ if(options.scrollOverflow){
441
+ if(slides.length){
442
+ slides.each(function(){
443
+ createSlimScrolling($(this));
444
+ });
445
+ }else{
446
+ createSlimScrolling($(this));
447
+ }
448
+ }
449
+
450
+ //adjusting the position fo the FULL WIDTH slides...
451
+ if (slides.length > 1) {
452
+ landscapeScroll(slidesWrap, slidesWrap.find(SLIDE_ACTIVE_SEL));
453
+ }
454
+ });
455
+
456
+ var activeSection = $(SECTION_ACTIVE_SEL);
457
+ var sectionIndex = activeSection.index(SECTION_SEL);
458
+
459
+ //isn't it the first section?
460
+ if(sectionIndex){
461
+ //adjusting the position for the current section
462
+ FP.silentMoveTo(sectionIndex + 1);
463
+ }
464
+
465
+ isResizing = false;
466
+ $.isFunction( options.afterResize ) && resizing && options.afterResize.call(container);
467
+ $.isFunction( options.afterReBuild ) && !resizing && options.afterReBuild.call(container);
468
+ };
469
+
470
+ /**
471
+ * Turns fullPage.js to normal scrolling mode when the viewport `width` or `height`
472
+ * are smaller than the set limit values.
473
+ */
474
+ FP.setResponsive = function (active){
475
+ var isResponsive = $body.hasClass(RESPONSIVE);
476
+
477
+ if(active){
478
+ if(!isResponsive){
479
+ FP.setAutoScrolling(false, 'internal');
480
+ FP.setFitToSection(false, 'internal');
481
+ $(SECTION_NAV_SEL).hide();
482
+ $body.addClass(RESPONSIVE);
483
+ }
484
+ }
485
+ else if(isResponsive){
486
+ FP.setAutoScrolling(originals.autoScrolling, 'internal');
487
+ FP.setFitToSection(originals.autoScrolling, 'internal');
488
+ $(SECTION_NAV_SEL).show();
489
+ $body.removeClass(RESPONSIVE);
490
+ }
491
+ };
492
+
493
+ if($(this).length){
494
+ init();
495
+ bindEvents();
496
+ }
497
+
498
+ function init(){
499
+ //if css3 is not supported, it will use jQuery animations
500
+ if(options.css3){
501
+ options.css3 = support3d();
502
+ }
503
+
504
+ options.scrollBar = options.scrollBar || options.hybrid;
505
+
506
+
507
+ setOptionsFromDOM();
508
+
509
+ prepareDom();
510
+ FP.setAllowScrolling(true);
511
+
512
+ FP.setAutoScrolling(options.autoScrolling, 'internal');
513
+
514
+ //the starting point is a slide?
515
+ var activeSlide = $(SECTION_ACTIVE_SEL).find(SLIDE_ACTIVE_SEL);
516
+
517
+ //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.
518
+ if( activeSlide.length && ($(SECTION_ACTIVE_SEL).index(SECTION_SEL) !== 0 || ($(SECTION_ACTIVE_SEL).index(SECTION_SEL) === 0 && activeSlide.index() !== 0))){
519
+ silentLandscapeScroll(activeSlide);
520
+ }
521
+
522
+ responsive();
523
+
524
+ //setting the class for the body element
525
+ setBodyClass();
526
+
527
+ if(document.readyState === 'complete'){
528
+ scrollToAnchor();
529
+ }
530
+ $window.on('load', scrollToAnchor);
531
+ }
532
+
533
+ function bindEvents(){
534
+ $window
535
+ //when scrolling...
536
+ .on('scroll', scrollHandler)
537
+
538
+ //detecting any change on the URL to scroll to the given anchor link
539
+ //(a way to detect back history button as we play with the hashes on the URL)
540
+ .on('hashchange', hashChangeHandler)
541
+
542
+ //when opening a new tab (ctrl + t), `control` won't be pressed when comming back.
543
+ .blur(blurHandler)
544
+
545
+ //when resizing the site, we adjust the heights of the sections, slimScroll...
546
+ .resize(resizeHandler);
547
+
548
+ $document
549
+ //Sliding with arrow keys, both, vertical and horizontal
550
+ .keydown(keydownHandler)
551
+
552
+ //to prevent scrolling while zooming
553
+ .keyup(keyUpHandler)
554
+
555
+ //Scrolls to the section when clicking the navigation bullet
556
+ .on('click touchstart', SECTION_NAV_SEL + ' a', sectionBulletHandler)
557
+
558
+ //Scrolls the slider to the given slide destination for the given section
559
+ .on('click touchstart', SLIDES_NAV_LINK_SEL, slideBulletHandler)
560
+
561
+ .on('click', SECTION_NAV_TOOLTIP_SEL, tooltipTextHandler);
562
+
563
+ //Scrolling horizontally when clicking on the slider controls.
564
+ $(SECTION_SEL).on('click touchstart', SLIDES_ARROW_SEL, slideArrowHandler);
565
+
566
+ /**
567
+ * Applying normalScroll elements.
568
+ * Ignoring the scrolls over the specified selectors.
569
+ */
570
+ if(options.normalScrollElements){
571
+ $document.on('mouseenter', options.normalScrollElements, function () {
572
+ FP.setMouseWheelScrolling(false);
573
+ });
574
+
575
+ $document.on('mouseleave', options.normalScrollElements, function(){
576
+ FP.setMouseWheelScrolling(true);
577
+ });
578
+ }
579
+ }
580
+
581
+ /**
582
+ * Setting options from DOM elements if they are not provided.
583
+ */
584
+ function setOptionsFromDOM(){
585
+ var sections = container.find(options.sectionSelector);
586
+
587
+ //no anchors option? Checking for them in the DOM attributes
588
+ if(!options.anchors.length){
589
+ options.anchors = sections.filter('[data-anchor]').map(function(){
590
+ return $(this).data('anchor').toString();
591
+ }).get();
592
+ }
593
+
594
+ //no tooltipos option? Checking for them in the DOM attributes
595
+ if(!options.navigationTooltips.length){
596
+ options.navigationTooltips = sections.filter('[data-tooltip]').map(function(){
597
+ return $(this).data('tooltip').toString();
598
+ }).get();
599
+ }
600
+ }
601
+
602
+ /**
603
+ * Works over the DOM structure to set it up for the current fullpage optionss.
604
+ */
605
+ function prepareDom(){
606
+ container.css({
607
+ 'height': '100%',
608
+ 'position': 'relative'
609
+ });
610
+
611
+ //adding a class to recognize the container internally in the code
612
+ container.addClass(WRAPPER);
613
+ $('html').addClass(ENABLED);
614
+
615
+ //due to https://github.com/alvarotrigo/fullPage.js/issues/1502
616
+ windowsHeight = $window.height();
617
+
618
+ container.removeClass(DESTROYED); //in case it was destroyed before initilizing it again
619
+
620
+ addInternalSelectors();
621
+
622
+ //styling the sections / slides / menu
623
+ $(SECTION_SEL).each(function(index){
624
+ var section = $(this);
625
+ var slides = section.find(SLIDE_SEL);
626
+ var numSlides = slides.length;
627
+
628
+ styleSection(section, index);
629
+ styleMenu(section, index);
630
+
631
+ // if there's any slide
632
+ if (numSlides > 0) {
633
+ styleSlides(section, slides, numSlides);
634
+ }else{
635
+ if(options.verticalCentered){
636
+ addTableClass(section);
637
+ }
638
+ }
639
+ });
640
+
641
+ //fixed elements need to be moved out of the plugin container due to problems with CSS3.
642
+ if(options.fixedElements && options.css3){
643
+ $(options.fixedElements).appendTo($body);
644
+ }
645
+
646
+ //vertical centered of the navigation + active bullet
647
+ if(options.navigation){
648
+ addVerticalNavigation();
649
+ }
650
+
651
+ enableYoutubeAPI();
652
+ enableVidemoAPI();
653
+
654
+ if(options.scrollOverflow){
655
+ if(document.readyState === 'complete'){
656
+ createSlimScrollingHandler();
657
+ }
658
+ //after DOM and images are loaded
659
+ $window.on('load', createSlimScrollingHandler);
660
+ }else{
661
+ afterRenderActions();
662
+ }
663
+ }
664
+
665
+ /**
666
+ * Styles the horizontal slides for a section.
667
+ */
668
+ function styleSlides(section, slides, numSlides){
669
+ var sliderWidth = numSlides * 100;
670
+ var slideWidth = 100 / numSlides;
671
+
672
+ slides.wrapAll('<div class="' + SLIDES_CONTAINER + '" />');
673
+ slides.parent().wrap('<div class="' + SLIDES_WRAPPER + '" />');
674
+
675
+ section.find(SLIDES_CONTAINER_SEL).css('width', sliderWidth + '%');
676
+
677
+ if(numSlides > 1){
678
+ if(options.controlArrows){
679
+ createSlideArrows(section);
680
+ }
681
+
682
+ if(options.slidesNavigation){
683
+ addSlidesNavigation(section, numSlides);
684
+ }
685
+ }
686
+
687
+ slides.each(function(index) {
688
+ $(this).css('width', slideWidth + '%');
689
+
690
+ if(options.verticalCentered){
691
+ addTableClass($(this));
692
+ }
693
+ });
694
+
695
+ var startingSlide = section.find(SLIDE_ACTIVE_SEL);
696
+
697
+ //if the slide won't be an starting point, the default will be the first one
698
+ //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.
699
+ if( startingSlide.length && ($(SECTION_ACTIVE_SEL).index(SECTION_SEL) !== 0 || ($(SECTION_ACTIVE_SEL).index(SECTION_SEL) === 0 && startingSlide.index() !== 0))){
700
+ silentLandscapeScroll(startingSlide);
701
+ }else{
702
+ slides.eq(0).addClass(ACTIVE);
703
+ }
704
+ }
705
+
706
+ /**
707
+ * Styling vertical sections
708
+ */
709
+ function styleSection(section, index){
710
+ //if no active section is defined, the 1st one will be the default one
711
+ if(!index && $(SECTION_ACTIVE_SEL).length === 0) {
712
+ section.addClass(ACTIVE);
713
+ }
714
+
715
+ section.css('height', windowsHeight + 'px');
716
+
717
+ if(options.paddingTop){
718
+ section.css('padding-top', options.paddingTop);
719
+ }
720
+
721
+ if(options.paddingBottom){
722
+ section.css('padding-bottom', options.paddingBottom);
723
+ }
724
+
725
+ if (typeof options.sectionsColor[index] !== 'undefined') {
726
+ section.css('background-color', options.sectionsColor[index]);
727
+ }
728
+
729
+ if (typeof options.anchors[index] !== 'undefined') {
730
+ section.attr('data-anchor', options.anchors[index]);
731
+ }
732
+ }
733
+
734
+ /**
735
+ * Sets the data-anchor attributes to the menu elements and activates the current one.
736
+ */
737
+ function styleMenu(section, index){
738
+ if (typeof options.anchors[index] !== 'undefined') {
739
+ //activating the menu / nav element on load
740
+ if(section.hasClass(ACTIVE)){
741
+ activateMenuAndNav(options.anchors[index], index);
742
+ }
743
+ }
744
+
745
+ //moving the menu outside the main container if it is inside (avoid problems with fixed positions when using CSS3 tranforms)
746
+ if(options.menu && options.css3 && $(options.menu).closest(WRAPPER_SEL).length){
747
+ $(options.menu).appendTo($body);
748
+ }
749
+ }
750
+
751
+ /**
752
+ * Adds internal classes to be able to provide customizable selectors
753
+ * keeping the link with the style sheet.
754
+ */
755
+ function addInternalSelectors(){
756
+ //adding internal class names to void problem with common ones
757
+ container.find(options.sectionSelector).each(function(){
758
+ $(this).addClass(SECTION);
759
+ });
760
+ container.find(options.slideSelector).each(function(){
761
+ $(this).addClass(SLIDE);
762
+ });
763
+ }
764
+
765
+ /**
766
+ * Creates the control arrows for the given section
767
+ */
768
+ function createSlideArrows(section){
769
+ section.find(SLIDES_WRAPPER_SEL).after('<div class="' + SLIDES_ARROW_PREV + '"></div><div class="' + SLIDES_ARROW_NEXT + '"></div>');
770
+
771
+ if(options.controlArrowColor!='#fff'){
772
+ section.find(SLIDES_ARROW_NEXT_SEL).css('border-color', 'transparent transparent transparent '+options.controlArrowColor);
773
+ section.find(SLIDES_ARROW_PREV_SEL).css('border-color', 'transparent '+ options.controlArrowColor + ' transparent transparent');
774
+ }
775
+
776
+ if(!options.loopHorizontal){
777
+ section.find(SLIDES_ARROW_PREV_SEL).hide();
778
+ }
779
+ }
780
+
781
+ /**
782
+ * Creates a vertical navigation bar.
783
+ */
784
+ function addVerticalNavigation(){
785
+ $body.append('<div id="' + SECTION_NAV + '"><ul></ul></div>');
786
+ var nav = $(SECTION_NAV_SEL);
787
+
788
+ nav.addClass(function() {
789
+ return options.showActiveTooltip ? SHOW_ACTIVE_TOOLTIP + ' ' + options.navigationPosition : options.navigationPosition;
790
+ });
791
+
792
+ for (var i = 0; i < $(SECTION_SEL).length; i++) {
793
+ var link = '';
794
+ if (options.anchors.length) {
795
+ link = options.anchors[i];
796
+ }
797
+
798
+ var li = '<li><a href="#' + link + '"><span></span></a>';
799
+
800
+ // Only add tooltip if needed (defined by user)
801
+ var tooltip = options.navigationTooltips[i];
802
+
803
+ if (typeof tooltip !== 'undefined' && tooltip !== '') {
804
+ li += '<div class="' + SECTION_NAV_TOOLTIP + ' ' + options.navigationPosition + '">' + tooltip + '</div>';
805
+ }
806
+
807
+ li += '</li>';
808
+
809
+ nav.find('ul').append(li);
810
+ }
811
+
812
+ //centering it vertically
813
+ $(SECTION_NAV_SEL).css('margin-top', '-' + ($(SECTION_NAV_SEL).height()/2) + 'px');
814
+
815
+ //activating the current active section
816
+ $(SECTION_NAV_SEL).find('li').eq($(SECTION_ACTIVE_SEL).index(SECTION_SEL)).find('a').addClass(ACTIVE);
817
+ }
818
+
819
+ /**
820
+ * Creates the slim scroll scrollbar for the sections and slides inside them.
821
+ */
822
+ function createSlimScrollingHandler(){
823
+ $(SECTION_SEL).each(function(){
824
+ var slides = $(this).find(SLIDE_SEL);
825
+
826
+ if(slides.length){
827
+ slides.each(function(){
828
+ createSlimScrolling($(this));
829
+ });
830
+ }else{
831
+ createSlimScrolling($(this));
832
+ }
833
+
834
+ });
835
+ afterRenderActions();
836
+ }
837
+
838
+ /*
839
+ * Enables the Youtube videos API so we can control their flow if necessary.
840
+ */
841
+ function enableYoutubeAPI(){
842
+ container.find('iframe[src*="youtube.com/embed/"]').each(function(){
843
+ var sign = getUrlParamSign($(this).attr('src'));
844
+ $(this).attr('src', $(this).attr('src') + sign + 'enablejsapi=1');
845
+ });
846
+ }
847
+
848
+ /*
849
+ * Enables the Vimeo videos API so we can control their flow if necessary.
850
+ */
851
+ function enableVidemoAPI(){
852
+ container.find('iframe[src*="player.vimeo.com/"]').each(function(){
853
+ var sign = getUrlParamSign($(this).attr('src'));
854
+ $(this).attr('src', $(this).attr('src') + sign + 'api=1');
855
+ });
856
+ }
857
+
858
+ /*
859
+ * Returns the prefix sign to use for a new parameter in an existen URL.
860
+ *
861
+ * @return {String} ? | &
862
+ */
863
+ function getUrlParamSign(url){
864
+ return ( !/\?/.test( url ) ) ? '?' : '&';
865
+ }
866
+
867
+ /**
868
+ * Actions and callbacks to fire afterRender
869
+ */
870
+ function afterRenderActions(){
871
+ var section = $(SECTION_ACTIVE_SEL);
872
+
873
+ section.addClass(COMPLETELY);
874
+
875
+ if(options.scrollOverflowHandler.afterRender){
876
+ options.scrollOverflowHandler.afterRender(section);
877
+ }
878
+ lazyLoad(section);
879
+ playMedia(section);
880
+
881
+ $.isFunction( options.afterLoad ) && options.afterLoad.call(section, section.data('anchor'), (section.index(SECTION_SEL) + 1));
882
+ $.isFunction( options.afterRender ) && options.afterRender.call(container);
883
+ }
884
+
885
+
886
+ var isScrolling = false;
887
+ var lastScroll = 0;
888
+
889
+ //when scrolling...
890
+ function scrollHandler(){
891
+ var currentSection;
892
+
893
+ if(!options.autoScrolling || options.scrollBar){
894
+ var currentScroll = $window.scrollTop();
895
+ var scrollDirection = getScrollDirection(currentScroll);
896
+ var visibleSectionIndex = 0;
897
+ var screen_mid = currentScroll + ($window.height() / 2.0);
898
+ var isAtBottom = $body.height() - $window.height() === currentScroll;
899
+ var sections = document.querySelectorAll(SECTION_SEL);
900
+
901
+ //when using `auto-height` for a small last section it won't take most of the viewport
902
+ if(isAtBottom){
903
+ visibleSectionIndex = sections.length - 1;
904
+ }
905
+
906
+ //taking the section which is showing more content in the viewport
907
+ else{
908
+ for (var i = 0; i < sections.length; ++i) {
909
+ var section = sections[i];
910
+
911
+ // Pick the the last section which passes the middle line of the screen.
912
+ if (section.offsetTop <= screen_mid)
913
+ {
914
+ visibleSectionIndex = i;
915
+ }
916
+ }
917
+ }
918
+
919
+ if(isCompletelyInViewPort(scrollDirection)){
920
+ if(!$(SECTION_ACTIVE_SEL).hasClass(COMPLETELY)){
921
+ $(SECTION_ACTIVE_SEL).addClass(COMPLETELY).siblings().removeClass(COMPLETELY);
922
+ }
923
+ }
924
+
925
+ //geting the last one, the current one on the screen
926
+ currentSection = $(sections).eq(visibleSectionIndex);
927
+
928
+ //setting the visible section as active when manually scrolling
929
+ //executing only once the first time we reach the section
930
+ if(!currentSection.hasClass(ACTIVE)){
931
+ isScrolling = true;
932
+ var leavingSection = $(SECTION_ACTIVE_SEL);
933
+ var leavingSectionIndex = leavingSection.index(SECTION_SEL) + 1;
934
+ var yMovement = getYmovement(currentSection);
935
+ var anchorLink = currentSection.data('anchor');
936
+ var sectionIndex = currentSection.index(SECTION_SEL) + 1;
937
+ var activeSlide = currentSection.find(SLIDE_ACTIVE_SEL);
938
+
939
+ if(activeSlide.length){
940
+ var slideAnchorLink = activeSlide.data('anchor');
941
+ var slideIndex = activeSlide.index();
942
+ }
943
+
944
+ if(canScroll){
945
+ currentSection.addClass(ACTIVE).siblings().removeClass(ACTIVE);
946
+
947
+ $.isFunction( options.onLeave ) && options.onLeave.call( leavingSection, leavingSectionIndex, sectionIndex, yMovement);
948
+ $.isFunction( options.afterLoad ) && options.afterLoad.call( currentSection, anchorLink, sectionIndex);
949
+
950
+ stopMedia(leavingSection);
951
+ lazyLoad(currentSection);
952
+ playMedia(currentSection);
953
+
954
+ activateMenuAndNav(anchorLink, sectionIndex - 1);
955
+
956
+ if(options.anchors.length){
957
+ //needed to enter in hashChange event when using the menu with anchor links
958
+ lastScrolledDestiny = anchorLink;
959
+
960
+ setState(slideIndex, slideAnchorLink, anchorLink, sectionIndex);
961
+ }
962
+ }
963
+
964
+ //small timeout in order to avoid entering in hashChange event when scrolling is not finished yet
965
+ clearTimeout(scrollId);
966
+ scrollId = setTimeout(function(){
967
+ isScrolling = false;
968
+ }, 100);
969
+ }
970
+
971
+ if(options.fitToSection){
972
+ //for the auto adjust of the viewport to fit a whole section
973
+ clearTimeout(scrollId2);
974
+
975
+ scrollId2 = setTimeout(function(){
976
+ //checking fitToSection again in case it was set to false before the timeout delay
977
+ if(canScroll && options.fitToSection){
978
+ //allows to scroll to an active section and
979
+ //if the section is already active, we prevent firing callbacks
980
+ if($(SECTION_ACTIVE_SEL).is(currentSection)){
981
+ isResizing = true;
982
+ }
983
+ scrollPage($(SECTION_ACTIVE_SEL));
984
+
985
+ isResizing = false;
986
+ }
987
+ }, options.fitToSectionDelay);
988
+ }
989
+ }
990
+ }
991
+
992
+ /**
993
+ * Determines whether the active section has seen in its whole or not.
994
+ */
995
+ function isCompletelyInViewPort(movement){
996
+ var top = $(SECTION_ACTIVE_SEL).position().top;
997
+ var bottom = top + $window.height();
998
+
999
+ if(movement == 'up'){
1000
+ return bottom >= ($window.scrollTop() + $window.height());
1001
+ }
1002
+ return top <= $window.scrollTop();
1003
+ }
1004
+
1005
+ /**
1006
+ * Gets the directon of the the scrolling fired by the scroll event.
1007
+ */
1008
+ function getScrollDirection(currentScroll){
1009
+ var direction = currentScroll > lastScroll ? 'down' : 'up';
1010
+
1011
+ lastScroll = currentScroll;
1012
+
1013
+ //needed for auto-height sections to determine if we want to scroll to the top or bottom of the destination
1014
+ previousDestTop = currentScroll;
1015
+
1016
+ return direction;
1017
+ }
1018
+
1019
+ /**
1020
+ * Determines the way of scrolling up or down:
1021
+ * by 'automatically' scrolling a section or by using the default and normal scrolling.
1022
+ */
1023
+ function scrolling(type, scrollable){
1024
+ if (!isScrollAllowed.m[type]){
1025
+ return;
1026
+ }
1027
+ var check, scrollSection;
1028
+
1029
+ if(type == 'down'){
1030
+ check = 'bottom';
1031
+ scrollSection = FP.moveSectionDown;
1032
+ }else{
1033
+ check = 'top';
1034
+ scrollSection = FP.moveSectionUp;
1035
+ }
1036
+
1037
+ if(scrollable.length > 0 ){
1038
+ //is the scrollbar at the start/end of the scroll?
1039
+ if(options.scrollOverflowHandler.isScrolled(check, scrollable)){
1040
+ scrollSection();
1041
+ }else{
1042
+ return true;
1043
+ }
1044
+ }else{
1045
+ // moved up/down
1046
+ scrollSection();
1047
+ }
1048
+ }
1049
+
1050
+
1051
+ var touchStartY = 0;
1052
+ var touchStartX = 0;
1053
+ var touchEndY = 0;
1054
+ var touchEndX = 0;
1055
+
1056
+ /* Detecting touch events
1057
+
1058
+ * As we are changing the top property of the page on scrolling, we can not use the traditional way to detect it.
1059
+ * This way, the touchstart and the touch moves shows an small difference between them which is the
1060
+ * used one to determine the direction.
1061
+ */
1062
+ function touchMoveHandler(event){
1063
+ var e = event.originalEvent;
1064
+
1065
+ // additional: if one of the normalScrollElements isn't within options.normalScrollElementTouchThreshold hops up the DOM chain
1066
+ if (!checkParentForNormalScrollElement(event.target) && isReallyTouch(e) ) {
1067
+
1068
+ if(options.autoScrolling){
1069
+ //preventing the easing on iOS devices
1070
+ event.preventDefault();
1071
+ }
1072
+
1073
+ var activeSection = $(SECTION_ACTIVE_SEL);
1074
+ var scrollable = options.scrollOverflowHandler.scrollable(activeSection);
1075
+
1076
+ if (canScroll && !slideMoving) { //if theres any #
1077
+ var touchEvents = getEventsPage(e);
1078
+
1079
+ touchEndY = touchEvents.y;
1080
+ touchEndX = touchEvents.x;
1081
+
1082
+ //if movement in the X axys is greater than in the Y and the currect section has slides...
1083
+ if (activeSection.find(SLIDES_WRAPPER_SEL).length && Math.abs(touchStartX - touchEndX) > (Math.abs(touchStartY - touchEndY))) {
1084
+
1085
+ //is the movement greater than the minimum resistance to scroll?
1086
+ if (Math.abs(touchStartX - touchEndX) > ($window.outerWidth() / 100 * options.touchSensitivity)) {
1087
+ if (touchStartX > touchEndX) {
1088
+ if(isScrollAllowed.m.right){
1089
+ FP.moveSlideRight(); //next
1090
+ }
1091
+ } else {
1092
+ if(isScrollAllowed.m.left){
1093
+ FP.moveSlideLeft(); //prev
1094
+ }
1095
+ }
1096
+ }
1097
+ }
1098
+
1099
+ //vertical scrolling (only when autoScrolling is enabled)
1100
+ else if(options.autoScrolling){
1101
+
1102
+ //is the movement greater than the minimum resistance to scroll?
1103
+ if (Math.abs(touchStartY - touchEndY) > ($window.height() / 100 * options.touchSensitivity)) {
1104
+ if (touchStartY > touchEndY) {
1105
+ scrolling('down', scrollable);
1106
+ } else if (touchEndY > touchStartY) {
1107
+ scrolling('up', scrollable);
1108
+ }
1109
+ }
1110
+ }
1111
+ }
1112
+ }
1113
+
1114
+ }
1115
+
1116
+ /**
1117
+ * recursive function to loop up the parent nodes to check if one of them exists in options.normalScrollElements
1118
+ * Currently works well for iOS - Android might need some testing
1119
+ * @param {Element} el target element / jquery selector (in subsequent nodes)
1120
+ * @param {int} hop current hop compared to options.normalScrollElementTouchThreshold
1121
+ * @return {boolean} true if there is a match to options.normalScrollElements
1122
+ */
1123
+ function checkParentForNormalScrollElement (el, hop) {
1124
+ hop = hop || 0;
1125
+ var parent = $(el).parent();
1126
+
1127
+ if (hop < options.normalScrollElementTouchThreshold &&
1128
+ parent.is(options.normalScrollElements) ) {
1129
+ return true;
1130
+ } else if (hop == options.normalScrollElementTouchThreshold) {
1131
+ return false;
1132
+ } else {
1133
+ return checkParentForNormalScrollElement(parent, ++hop);
1134
+ }
1135
+ }
1136
+
1137
+ /**
1138
+ * As IE >= 10 fires both touch and mouse events when using a mouse in a touchscreen
1139
+ * this way we make sure that is really a touch event what IE is detecting.
1140
+ */
1141
+ function isReallyTouch(e){
1142
+ //if is not IE || IE is detecting `touch` or `pen`
1143
+ return typeof e.pointerType === 'undefined' || e.pointerType != 'mouse';
1144
+ }
1145
+
1146
+ /**
1147
+ * Handler for the touch start event.
1148
+ */
1149
+ function touchStartHandler(event){
1150
+ var e = event.originalEvent;
1151
+
1152
+ //stopping the auto scroll to adjust to a section
1153
+ if(options.fitToSection){
1154
+ $htmlBody.stop();
1155
+ }
1156
+
1157
+ if(isReallyTouch(e)){
1158
+ var touchEvents = getEventsPage(e);
1159
+ touchStartY = touchEvents.y;
1160
+ touchStartX = touchEvents.x;
1161
+ }
1162
+ }
1163
+
1164
+ /**
1165
+ * Gets the average of the last `number` elements of the given array.
1166
+ */
1167
+ function getAverage(elements, number){
1168
+ var sum = 0;
1169
+
1170
+ //taking `number` elements from the end to make the average, if there are not enought, 1
1171
+ var lastElements = elements.slice(Math.max(elements.length - number, 1));
1172
+
1173
+ for(var i = 0; i < lastElements.length; i++){
1174
+ sum = sum + lastElements[i];
1175
+ }
1176
+
1177
+ return Math.ceil(sum/number);
1178
+ }
1179
+
1180
+ /**
1181
+ * Detecting mousewheel scrolling
1182
+ *
1183
+ * http://blogs.sitepointstatic.com/examples/tech/mouse-wheel/index.html
1184
+ * http://www.sitepoint.com/html5-javascript-mouse-wheel/
1185
+ */
1186
+ var prevTime = new Date().getTime();
1187
+
1188
+ function MouseWheelHandler(e) {
1189
+ var curTime = new Date().getTime();
1190
+ var isNormalScroll = $(COMPLETELY_SEL).hasClass(NORMAL_SCROLL);
1191
+
1192
+ //autoscrolling and not zooming?
1193
+ if(options.autoScrolling && !controlPressed && !isNormalScroll){
1194
+ // cross-browser wheel delta
1195
+ e = e || window.event;
1196
+ var value = e.wheelDelta || -e.deltaY || -e.detail;
1197
+ var delta = Math.max(-1, Math.min(1, value));
1198
+
1199
+ var horizontalDetection = typeof e.wheelDeltaX !== 'undefined' || typeof e.deltaX !== 'undefined';
1200
+ var isScrollingVertically = (Math.abs(e.wheelDeltaX) < Math.abs(e.wheelDelta)) || (Math.abs(e.deltaX ) < Math.abs(e.deltaY) || !horizontalDetection);
1201
+
1202
+ //Limiting the array to 150 (lets not waste memory!)
1203
+ if(scrollings.length > 149){
1204
+ scrollings.shift();
1205
+ }
1206
+
1207
+ //keeping record of the previous scrollings
1208
+ scrollings.push(Math.abs(value));
1209
+
1210
+ //preventing to scroll the site on mouse wheel when scrollbar is present
1211
+ if(options.scrollBar){
1212
+ e.preventDefault ? e.preventDefault() : e.returnValue = false;
1213
+ }
1214
+
1215
+ var activeSection = $(SECTION_ACTIVE_SEL);
1216
+ var scrollable = options.scrollOverflowHandler.scrollable(activeSection);
1217
+
1218
+ //time difference between the last scroll and the current one
1219
+ var timeDiff = curTime-prevTime;
1220
+ prevTime = curTime;
1221
+
1222
+ //haven't they scrolled in a while?
1223
+ //(enough to be consider a different scrolling action to scroll another section)
1224
+ if(timeDiff > 200){
1225
+ //emptying the array, we dont care about old scrollings for our averages
1226
+ scrollings = [];
1227
+ }
1228
+
1229
+ if(canScroll){
1230
+ var averageEnd = getAverage(scrollings, 10);
1231
+ var averageMiddle = getAverage(scrollings, 70);
1232
+ var isAccelerating = averageEnd >= averageMiddle;
1233
+
1234
+ //to avoid double swipes...
1235
+ if(isAccelerating && isScrollingVertically){
1236
+ //scrolling down?
1237
+ if (delta < 0) {
1238
+ scrolling('down', scrollable);
1239
+
1240
+ //scrolling up?
1241
+ }else {
1242
+ scrolling('up', scrollable);
1243
+ }
1244
+ }
1245
+ }
1246
+
1247
+ return false;
1248
+ }
1249
+
1250
+ if(options.fitToSection){
1251
+ //stopping the auto scroll to adjust to a section
1252
+ $htmlBody.stop();
1253
+ }
1254
+ }
1255
+
1256
+ /**
1257
+ * Slides a slider to the given direction.
1258
+ * Optional `section` param.
1259
+ */
1260
+ function moveSlide(direction, section){
1261
+ var activeSection = typeof section === 'undefined' ? $(SECTION_ACTIVE_SEL) : section;
1262
+ var slides = activeSection.find(SLIDES_WRAPPER_SEL);
1263
+ var numSlides = slides.find(SLIDE_SEL).length;
1264
+
1265
+ // more than one slide needed and nothing should be sliding
1266
+ if (!slides.length || slideMoving || numSlides < 2) {
1267
+ return;
1268
+ }
1269
+
1270
+ var currentSlide = slides.find(SLIDE_ACTIVE_SEL);
1271
+ var destiny = null;
1272
+
1273
+ if(direction === 'prev'){
1274
+ destiny = currentSlide.prev(SLIDE_SEL);
1275
+ }else{
1276
+ destiny = currentSlide.next(SLIDE_SEL);
1277
+ }
1278
+
1279
+ //isn't there a next slide in the secuence?
1280
+ if(!destiny.length){
1281
+ //respect loopHorizontal settin
1282
+ if (!options.loopHorizontal) return;
1283
+
1284
+ if(direction === 'prev'){
1285
+ destiny = currentSlide.siblings(':last');
1286
+ }else{
1287
+ destiny = currentSlide.siblings(':first');
1288
+ }
1289
+ }
1290
+
1291
+ slideMoving = true;
1292
+
1293
+ landscapeScroll(slides, destiny);
1294
+ }
1295
+
1296
+ /**
1297
+ * Maintains the active slides in the viewport
1298
+ * (Because he `scroll` animation might get lost with some actions, such as when using continuousVertical)
1299
+ */
1300
+ function keepSlidesPosition(){
1301
+ $(SLIDE_ACTIVE_SEL).each(function(){
1302
+ silentLandscapeScroll($(this), 'internal');
1303
+ });
1304
+ }
1305
+
1306
+ var previousDestTop = 0;
1307
+ /**
1308
+ * Returns the destination Y position based on the scrolling direction and
1309
+ * the height of the section.
1310
+ */
1311
+ function getDestinationPosition(element){
1312
+ var elemPosition = element.position();
1313
+
1314
+ //top of the desination will be at the top of the viewport
1315
+ var position = elemPosition.top;
1316
+ var isScrollingDown = elemPosition.top > previousDestTop;
1317
+ var sectionBottom = position - windowsHeight + element.outerHeight();
1318
+ var bigSectionsDestination = options.bigSectionsDestination;
1319
+
1320
+ //is the destination element bigger than the viewport?
1321
+ if(element.outerHeight() > windowsHeight){
1322
+ //scrolling up?
1323
+ if(!isScrollingDown && !bigSectionsDestination || bigSectionsDestination === 'bottom' ){
1324
+ position = sectionBottom;
1325
+ }
1326
+ }
1327
+
1328
+ //sections equal or smaller than the viewport height && scrolling down? || is resizing and its in the last section
1329
+ else if(isScrollingDown || (isResizing && element.is(':last-child')) ){
1330
+ //The bottom of the destination will be at the bottom of the viewport
1331
+ position = sectionBottom;
1332
+ }
1333
+
1334
+ /*
1335
+ Keeping record of the last scrolled position to determine the scrolling direction.
1336
+ No conventional methods can be used as the scroll bar might not be present
1337
+ AND the section might not be active if it is auto-height and didnt reach the middle
1338
+ of the viewport.
1339
+ */
1340
+ previousDestTop = position;
1341
+ return position;
1342
+ }
1343
+
1344
+ /**
1345
+ * Scrolls the site to the given element and scrolls to the slide if a callback is given.
1346
+ */
1347
+ function scrollPage(element, callback, isMovementUp){
1348
+ if(typeof element === 'undefined'){ return; } //there's no element to scroll, leaving the function
1349
+
1350
+ var dtop = getDestinationPosition(element);
1351
+
1352
+ //local variables
1353
+ var v = {
1354
+ element: element,
1355
+ callback: callback,
1356
+ isMovementUp: isMovementUp,
1357
+ dtop: dtop,
1358
+ yMovement: getYmovement(element),
1359
+ anchorLink: element.data('anchor'),
1360
+ sectionIndex: element.index(SECTION_SEL),
1361
+ activeSlide: element.find(SLIDE_ACTIVE_SEL),
1362
+ activeSection: $(SECTION_ACTIVE_SEL),
1363
+ leavingSection: $(SECTION_ACTIVE_SEL).index(SECTION_SEL) + 1,
1364
+
1365
+ //caching the value of isResizing at the momment the function is called
1366
+ //because it will be checked later inside a setTimeout and the value might change
1367
+ localIsResizing: isResizing
1368
+ };
1369
+
1370
+ //quiting when destination scroll is the same as the current one
1371
+ if((v.activeSection.is(element) && !isResizing) || (options.scrollBar && $window.scrollTop() === v.dtop && !element.hasClass(AUTO_HEIGHT) )){ return; }
1372
+
1373
+ if(v.activeSlide.length){
1374
+ var slideAnchorLink = v.activeSlide.data('anchor');
1375
+ var slideIndex = v.activeSlide.index();
1376
+ }
1377
+
1378
+ // If continuousVertical && we need to wrap around
1379
+ if (options.autoScrolling && options.continuousVertical && typeof (v.isMovementUp) !== "undefined" &&
1380
+ ((!v.isMovementUp && v.yMovement == 'up') || // Intending to scroll down but about to go up or
1381
+ (v.isMovementUp && v.yMovement == 'down'))) { // intending to scroll up but about to go down
1382
+
1383
+ v = createInfiniteSections(v);
1384
+ }
1385
+
1386
+ //callback (onLeave) if the site is not just resizing and readjusting the slides
1387
+ if($.isFunction(options.onLeave) && !v.localIsResizing){
1388
+ if(options.onLeave.call(v.activeSection, v.leavingSection, (v.sectionIndex + 1), v.yMovement) === false){
1389
+ return;
1390
+ }
1391
+ }
1392
+
1393
+ stopMedia(v.activeSection);
1394
+
1395
+ element.addClass(ACTIVE).siblings().removeClass(ACTIVE);
1396
+ lazyLoad(element);
1397
+ options.scrollOverflowHandler.onLeave();
1398
+
1399
+
1400
+ //preventing from activating the MouseWheelHandler event
1401
+ //more than once if the page is scrolling
1402
+ canScroll = false;
1403
+
1404
+ setState(slideIndex, slideAnchorLink, v.anchorLink, v.sectionIndex);
1405
+
1406
+ performMovement(v);
1407
+
1408
+ //flag to avoid callingn `scrollPage()` twice in case of using anchor links
1409
+ lastScrolledDestiny = v.anchorLink;
1410
+
1411
+ //avoid firing it twice (as it does also on scroll)
1412
+ activateMenuAndNav(v.anchorLink, v.sectionIndex);
1413
+ }
1414
+
1415
+ /**
1416
+ * Performs the movement (by CSS3 or by jQuery)
1417
+ */
1418
+ function performMovement(v){
1419
+ // using CSS3 translate functionality
1420
+ if (options.css3 && options.autoScrolling && !options.scrollBar) {
1421
+ var translate3d = 'translate3d(0px, -' + v.dtop + 'px, 0px)';
1422
+ transformContainer(translate3d, true);
1423
+
1424
+ //even when the scrollingSpeed is 0 there's a little delay, which might cause the
1425
+ //scrollingSpeed to change in case of using silentMoveTo();
1426
+ if(options.scrollingSpeed){
1427
+ afterSectionLoadsId = setTimeout(function () {
1428
+ afterSectionLoads(v);
1429
+ }, options.scrollingSpeed);
1430
+ }else{
1431
+ afterSectionLoads(v);
1432
+ }
1433
+ }
1434
+
1435
+ // using jQuery animate
1436
+ else{
1437
+ var scrollSettings = getScrollSettings(v);
1438
+
1439
+ $(scrollSettings.element).animate(
1440
+ scrollSettings.options,
1441
+ options.scrollingSpeed, options.easing).promise().done(function () { //only one single callback in case of animating `html, body`
1442
+ if(options.scrollBar){
1443
+
1444
+ /* Hack!
1445
+ The timeout prevents setting the most dominant section in the viewport as "active" when the user
1446
+ scrolled to a smaller section by using the mousewheel (auto scrolling) rather than draging the scroll bar.
1447
+
1448
+ When using scrollBar:true It seems like the scroll events still getting propagated even after the scrolling animation has finished.
1449
+ */
1450
+ setTimeout(function(){
1451
+ afterSectionLoads(v);
1452
+ },30);
1453
+ }else{
1454
+ afterSectionLoads(v);
1455
+ }
1456
+ });
1457
+ }
1458
+ }
1459
+
1460
+ /**
1461
+ * Gets the scrolling settings depending on the plugin autoScrolling option
1462
+ */
1463
+ function getScrollSettings(v){
1464
+ var scroll = {};
1465
+
1466
+ if(options.autoScrolling && !options.scrollBar){
1467
+ scroll.options = { 'top': -v.dtop};
1468
+ scroll.element = WRAPPER_SEL;
1469
+ }else{
1470
+ scroll.options = { 'scrollTop': v.dtop};
1471
+ scroll.element = 'html, body';
1472
+ }
1473
+
1474
+ return scroll;
1475
+ }
1476
+
1477
+ /**
1478
+ * Adds sections before or after the current one to create the infinite effect.
1479
+ */
1480
+ function createInfiniteSections(v){
1481
+ // Scrolling down
1482
+ if (!v.isMovementUp) {
1483
+ // Move all previous sections to after the active section
1484
+ $(SECTION_ACTIVE_SEL).after(v.activeSection.prevAll(SECTION_SEL).get().reverse());
1485
+ }
1486
+ else { // Scrolling up
1487
+ // Move all next sections to before the active section
1488
+ $(SECTION_ACTIVE_SEL).before(v.activeSection.nextAll(SECTION_SEL));
1489
+ }
1490
+
1491
+ // Maintain the displayed position (now that we changed the element order)
1492
+ silentScroll($(SECTION_ACTIVE_SEL).position().top);
1493
+
1494
+ // Maintain the active slides visible in the viewport
1495
+ keepSlidesPosition();
1496
+
1497
+ // save for later the elements that still need to be reordered
1498
+ v.wrapAroundElements = v.activeSection;
1499
+
1500
+ // Recalculate animation variables
1501
+ v.dtop = v.element.position().top;
1502
+ v.yMovement = getYmovement(v.element);
1503
+
1504
+ return v;
1505
+ }
1506
+
1507
+ /**
1508
+ * Fix section order after continuousVertical changes have been animated
1509
+ */
1510
+ function continuousVerticalFixSectionOrder (v) {
1511
+ // If continuousVertical is in effect (and autoScrolling would also be in effect then),
1512
+ // finish moving the elements around so the direct navigation will function more simply
1513
+ if (!v.wrapAroundElements || !v.wrapAroundElements.length) {
1514
+ return;
1515
+ }
1516
+
1517
+ if (v.isMovementUp) {
1518
+ $(SECTION_FIRST_SEL).before(v.wrapAroundElements);
1519
+ }
1520
+ else {
1521
+ $(SECTION_LAST_SEL).after(v.wrapAroundElements);
1522
+ }
1523
+
1524
+ silentScroll($(SECTION_ACTIVE_SEL).position().top);
1525
+
1526
+ // Maintain the active slides visible in the viewport
1527
+ keepSlidesPosition();
1528
+ }
1529
+
1530
+
1531
+ /**
1532
+ * Actions to do once the section is loaded.
1533
+ */
1534
+ function afterSectionLoads (v){
1535
+ continuousVerticalFixSectionOrder(v);
1536
+
1537
+ //callback (afterLoad) if the site is not just resizing and readjusting the slides
1538
+ $.isFunction(options.afterLoad) && !v.localIsResizing && options.afterLoad.call(v.element, v.anchorLink, (v.sectionIndex + 1));
1539
+ options.scrollOverflowHandler.afterLoad();
1540
+
1541
+ playMedia(v.element);
1542
+ v.element.addClass(COMPLETELY).siblings().removeClass(COMPLETELY);
1543
+
1544
+ canScroll = true;
1545
+
1546
+ $.isFunction(v.callback) && v.callback.call(this);
1547
+ }
1548
+
1549
+ /**
1550
+ * Lazy loads image, video and audio elements.
1551
+ */
1552
+ function lazyLoad(destiny){
1553
+ var destiny = getSlideOrSection(destiny);
1554
+
1555
+ destiny.find('img[data-src], source[data-src], audio[data-src], iframe[data-src]').each(function(){
1556
+ $(this).attr('src', $(this).data('src'));
1557
+ $(this).removeAttr('data-src');
1558
+
1559
+ if($(this).is('source')){
1560
+ $(this).closest('video').get(0).load();
1561
+ }
1562
+ });
1563
+ }
1564
+
1565
+ /**
1566
+ * Plays video and audio elements.
1567
+ */
1568
+ function playMedia(destiny){
1569
+ var destiny = getSlideOrSection(destiny);
1570
+
1571
+ //playing HTML5 media elements
1572
+ destiny.find('video, audio').each(function(){
1573
+ var element = $(this).get(0);
1574
+
1575
+ if( element.hasAttribute('data-autoplay') && typeof element.play === 'function' ) {
1576
+ element.play();
1577
+ }
1578
+ });
1579
+
1580
+ //youtube videos
1581
+ destiny.find('iframe[src*="youtube.com/embed/"]').each(function(){
1582
+ var element = $(this).get(0);
1583
+
1584
+ if( /youtube\.com\/embed\//.test($(this).attr('src')) && element.hasAttribute('data-autoplay')){
1585
+ element.contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}', '*');
1586
+ }
1587
+ });
1588
+ }
1589
+
1590
+ /**
1591
+ * Stops video and audio elements.
1592
+ */
1593
+ function stopMedia(destiny){
1594
+ var destiny = getSlideOrSection(destiny);
1595
+
1596
+ //stopping HTML5 media elements
1597
+ destiny.find('video, audio').each(function(){
1598
+ var element = $(this).get(0);
1599
+
1600
+ if( !element.hasAttribute('data-keepplaying') && typeof element.pause === 'function' ) {
1601
+ element.pause();
1602
+ }
1603
+ });
1604
+
1605
+ //youtube videos
1606
+ destiny.find('iframe[src*="youtube.com/embed/"]').each(function(){
1607
+ var element = $(this).get(0);
1608
+
1609
+ if( /youtube\.com\/embed\//.test($(this).attr('src')) && !element.hasAttribute('data-keepplaying')){
1610
+ $(this).get(0).contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}','*');
1611
+ }
1612
+ });
1613
+ }
1614
+
1615
+ /**
1616
+ * Gets the active slide (or section) for the given section
1617
+ */
1618
+ function getSlideOrSection(destiny){
1619
+ var slide = destiny.find(SLIDE_ACTIVE_SEL);
1620
+ if( slide.length ) {
1621
+ destiny = $(slide);
1622
+ }
1623
+
1624
+ return destiny;
1625
+ }
1626
+
1627
+ /**
1628
+ * Scrolls to the anchor in the URL when loading the site
1629
+ */
1630
+ function scrollToAnchor(){
1631
+ //getting the anchor link in the URL and deleting the `#`
1632
+ var value = window.location.hash.replace('#', '').split('/');
1633
+ var section = decodeURIComponent(value[0]);
1634
+ var slide = decodeURIComponent(value[1]);
1635
+
1636
+ if(section){ //if theres any #
1637
+ if(options.animateAnchor){
1638
+ scrollPageAndSlide(section, slide);
1639
+ }else{
1640
+ FP.silentMoveTo(section, slide);
1641
+ }
1642
+ }
1643
+ }
1644
+
1645
+ /**
1646
+ * Detecting any change on the URL to scroll to the given anchor link
1647
+ * (a way to detect back history button as we play with the hashes on the URL)
1648
+ */
1649
+ function hashChangeHandler(){
1650
+ if(!isScrolling && !options.lockAnchors){
1651
+ var value = window.location.hash.replace('#', '').split('/');
1652
+ var section = decodeURIComponent(value[0]);
1653
+ var slide = decodeURIComponent(value[1]);
1654
+
1655
+ //when moving to a slide in the first section for the first time (first time to add an anchor to the URL)
1656
+ var isFirstSlideMove = (typeof lastScrolledDestiny === 'undefined');
1657
+ var isFirstScrollMove = (typeof lastScrolledDestiny === 'undefined' && typeof slide === 'undefined' && !slideMoving);
1658
+
1659
+
1660
+ if(section.length){
1661
+ /*in order to call scrollpage() only once for each destination at a time
1662
+ It is called twice for each scroll otherwise, as in case of using anchorlinks `hashChange`
1663
+ event is fired on every scroll too.*/
1664
+ if ((section && section !== lastScrolledDestiny) && !isFirstSlideMove || isFirstScrollMove || (!slideMoving && lastScrolledSlide != slide )) {
1665
+ scrollPageAndSlide(section, slide);
1666
+ }
1667
+ }
1668
+ }
1669
+ }
1670
+
1671
+ //Sliding with arrow keys, both, vertical and horizontal
1672
+ function keydownHandler(e) {
1673
+
1674
+ clearTimeout(keydownId);
1675
+
1676
+ var activeElement = $(':focus');
1677
+
1678
+ if(!activeElement.is('textarea') && !activeElement.is('input') && !activeElement.is('select') &&
1679
+ activeElement.attr('contentEditable') !== "true" && activeElement.attr('contentEditable') !== '' &&
1680
+ options.keyboardScrolling && options.autoScrolling){
1681
+ var keyCode = e.which;
1682
+
1683
+ //preventing the scroll with arrow keys & spacebar & Page Up & Down keys
1684
+ var keyControls = [40, 38, 32, 33, 34];
1685
+ if($.inArray(keyCode, keyControls) > -1){
1686
+ e.preventDefault();
1687
+ }
1688
+
1689
+ controlPressed = e.ctrlKey;
1690
+
1691
+ keydownId = setTimeout(function(){
1692
+ onkeydown(e);
1693
+ },150);
1694
+ }
1695
+ }
1696
+
1697
+ function tooltipTextHandler(){
1698
+ $(this).prev().trigger('click');
1699
+ }
1700
+
1701
+ //to prevent scrolling while zooming
1702
+ function keyUpHandler(e){
1703
+ if(isWindowFocused){ //the keyup gets fired on new tab ctrl + t in Firefox
1704
+ controlPressed = e.ctrlKey;
1705
+ }
1706
+ }
1707
+
1708
+ //binding the mousemove when the mouse's middle button is released
1709
+ function mouseDownHandler(e){
1710
+ //middle button
1711
+ if (e.which == 2){
1712
+ oldPageY = e.pageY;
1713
+ container.on('mousemove', mouseMoveHandler);
1714
+ }
1715
+ }
1716
+
1717
+ //unbinding the mousemove when the mouse's middle button is released
1718
+ function mouseUpHandler(e){
1719
+ //middle button
1720
+ if (e.which == 2){
1721
+ container.off('mousemove');
1722
+ }
1723
+ }
1724
+
1725
+ //Scrolling horizontally when clicking on the slider controls.
1726
+ function slideArrowHandler(){
1727
+ var section = $(this).closest(SECTION_SEL);
1728
+
1729
+ if ($(this).hasClass(SLIDES_PREV)) {
1730
+ if(isScrollAllowed.m.left){
1731
+ FP.moveSlideLeft(section);
1732
+ }
1733
+ } else {
1734
+ if(isScrollAllowed.m.right){
1735
+ FP.moveSlideRight(section);
1736
+ }
1737
+ }
1738
+ }
1739
+
1740
+ //when opening a new tab (ctrl + t), `control` won't be pressed when comming back.
1741
+ function blurHandler(){
1742
+ isWindowFocused = false;
1743
+ controlPressed = false;
1744
+ }
1745
+
1746
+ //Scrolls to the section when clicking the navigation bullet
1747
+ function sectionBulletHandler(e){
1748
+ e.preventDefault();
1749
+ var index = $(this).parent().index();
1750
+ scrollPage($(SECTION_SEL).eq(index));
1751
+ }
1752
+
1753
+ //Scrolls the slider to the given slide destination for the given section
1754
+ function slideBulletHandler(e){
1755
+ e.preventDefault();
1756
+ var slides = $(this).closest(SECTION_SEL).find(SLIDES_WRAPPER_SEL);
1757
+ var destiny = slides.find(SLIDE_SEL).eq($(this).closest('li').index());
1758
+
1759
+ landscapeScroll(slides, destiny);
1760
+ }
1761
+
1762
+ /**
1763
+ * Keydown event
1764
+ */
1765
+ function onkeydown(e){
1766
+ var shiftPressed = e.shiftKey;
1767
+
1768
+ switch (e.which) {
1769
+ //up
1770
+ case 38:
1771
+ case 33:
1772
+ if(isScrollAllowed.k.up){
1773
+ FP.moveSectionUp();
1774
+ }
1775
+ break;
1776
+
1777
+ //down
1778
+ case 32: //spacebar
1779
+ if(shiftPressed && isScrollAllowed.k.up){
1780
+ FP.moveSectionUp();
1781
+ break;
1782
+ }
1783
+ case 40:
1784
+ case 34:
1785
+ if(isScrollAllowed.k.down){
1786
+ FP.moveSectionDown();
1787
+ }
1788
+ break;
1789
+
1790
+ //Home
1791
+ case 36:
1792
+ if(isScrollAllowed.k.up){
1793
+ FP.moveTo(1);
1794
+ }
1795
+ break;
1796
+
1797
+ //End
1798
+ case 35:
1799
+ if(isScrollAllowed.k.down){
1800
+ FP.moveTo( $(SECTION_SEL).length );
1801
+ }
1802
+ break;
1803
+
1804
+ //left
1805
+ case 37:
1806
+ if(isScrollAllowed.k.left){
1807
+ FP.moveSlideLeft();
1808
+ }
1809
+ break;
1810
+
1811
+ //right
1812
+ case 39:
1813
+ if(isScrollAllowed.k.right){
1814
+ FP.moveSlideRight();
1815
+ }
1816
+ break;
1817
+
1818
+ default:
1819
+ return; // exit this handler for other keys
1820
+ }
1821
+ }
1822
+
1823
+ /**
1824
+ * Detecting the direction of the mouse movement.
1825
+ * Used only for the middle button of the mouse.
1826
+ */
1827
+ var oldPageY = 0;
1828
+ function mouseMoveHandler(e){
1829
+ if(canScroll){
1830
+ // moving up
1831
+ if (e.pageY < oldPageY && isScrollAllowed.m.up){
1832
+ FP.moveSectionUp();
1833
+ }
1834
+
1835
+ // moving down
1836
+ else if(e.pageY > oldPageY && isScrollAllowed.m.down){
1837
+ FP.moveSectionDown();
1838
+ }
1839
+ }
1840
+ oldPageY = e.pageY;
1841
+ }
1842
+
1843
+ /**
1844
+ * Scrolls horizontal sliders.
1845
+ */
1846
+ function landscapeScroll(slides, destiny){
1847
+ var destinyPos = destiny.position();
1848
+ var slideIndex = destiny.index();
1849
+ var section = slides.closest(SECTION_SEL);
1850
+ var sectionIndex = section.index(SECTION_SEL);
1851
+ var anchorLink = section.data('anchor');
1852
+ var slidesNav = section.find(SLIDES_NAV_SEL);
1853
+ var slideAnchor = getAnchor(destiny);
1854
+ var prevSlide = section.find(SLIDE_ACTIVE_SEL);
1855
+
1856
+ //caching the value of isResizing at the momment the function is called
1857
+ //because it will be checked later inside a setTimeout and the value might change
1858
+ var localIsResizing = isResizing;
1859
+
1860
+ if(options.onSlideLeave){
1861
+ var prevSlideIndex = prevSlide.index();
1862
+ var xMovement = getXmovement(prevSlideIndex, slideIndex);
1863
+
1864
+ //if the site is not just resizing and readjusting the slides
1865
+ if(!localIsResizing && xMovement!=='none'){
1866
+ if($.isFunction( options.onSlideLeave )){
1867
+ if(options.onSlideLeave.call( prevSlide, anchorLink, (sectionIndex + 1), prevSlideIndex, xMovement, slideIndex ) === false){
1868
+ slideMoving = false;
1869
+ return;
1870
+ }
1871
+ }
1872
+ }
1873
+ }
1874
+ stopMedia(prevSlide);
1875
+
1876
+ destiny.addClass(ACTIVE).siblings().removeClass(ACTIVE);
1877
+ if(!localIsResizing){
1878
+ lazyLoad(destiny);
1879
+ }
1880
+
1881
+ if(!options.loopHorizontal && options.controlArrows){
1882
+ //hidding it for the fist slide, showing for the rest
1883
+ section.find(SLIDES_ARROW_PREV_SEL).toggle(slideIndex!==0);
1884
+
1885
+ //hidding it for the last slide, showing for the rest
1886
+ section.find(SLIDES_ARROW_NEXT_SEL).toggle(!destiny.is(':last-child'));
1887
+ }
1888
+
1889
+ //only changing the URL if the slides are in the current section (not for resize re-adjusting)
1890
+ if(section.hasClass(ACTIVE)){
1891
+ setState(slideIndex, slideAnchor, anchorLink, sectionIndex);
1892
+ }
1893
+
1894
+ var afterSlideLoads = function(){
1895
+ //if the site is not just resizing and readjusting the slides
1896
+ if(!localIsResizing){
1897
+ $.isFunction( options.afterSlideLoad ) && options.afterSlideLoad.call( destiny, anchorLink, (sectionIndex + 1), slideAnchor, slideIndex);
1898
+ }
1899
+ playMedia(destiny);
1900
+
1901
+ //letting them slide again
1902
+ slideMoving = false;
1903
+ };
1904
+
1905
+ if(options.css3){
1906
+ var translate3d = 'translate3d(-' + Math.round(destinyPos.left) + 'px, 0px, 0px)';
1907
+
1908
+ addAnimation(slides.find(SLIDES_CONTAINER_SEL), options.scrollingSpeed>0).css(getTransforms(translate3d));
1909
+
1910
+ afterSlideLoadsId = setTimeout(function(){
1911
+ afterSlideLoads();
1912
+ }, options.scrollingSpeed, options.easing);
1913
+ }else{
1914
+ slides.animate({
1915
+ scrollLeft : Math.round(destinyPos.left)
1916
+ }, options.scrollingSpeed, options.easing, function() {
1917
+
1918
+ afterSlideLoads();
1919
+ });
1920
+ }
1921
+
1922
+ slidesNav.find(ACTIVE_SEL).removeClass(ACTIVE);
1923
+ slidesNav.find('li').eq(slideIndex).find('a').addClass(ACTIVE);
1924
+ }
1925
+
1926
+ var previousHeight = windowsHeight;
1927
+
1928
+ //when resizing the site, we adjust the heights of the sections, slimScroll...
1929
+ function resizeHandler(){
1930
+ //checking if it needs to get responsive
1931
+ responsive();
1932
+
1933
+ // rebuild immediately on touch devices
1934
+ if (isTouchDevice) {
1935
+ var activeElement = $(document.activeElement);
1936
+
1937
+ //if the keyboard is NOT visible
1938
+ if (!activeElement.is('textarea') && !activeElement.is('input') && !activeElement.is('select')) {
1939
+ var currentHeight = $window.height();
1940
+
1941
+ //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)
1942
+ if( Math.abs(currentHeight - previousHeight) > (20 * Math.max(previousHeight, currentHeight) / 100) ){
1943
+ FP.reBuild(true);
1944
+ previousHeight = currentHeight;
1945
+ }
1946
+ }
1947
+ }else{
1948
+ //in order to call the functions only when the resize is finished
1949
+ //http://stackoverflow.com/questions/4298612/jquery-how-to-call-resize-event-only-once-its-finished-resizing
1950
+ clearTimeout(resizeId);
1951
+
1952
+ resizeId = setTimeout(function(){
1953
+ FP.reBuild(true);
1954
+ }, 350);
1955
+ }
1956
+ }
1957
+
1958
+ /**
1959
+ * Checks if the site needs to get responsive and disables autoScrolling if so.
1960
+ * A class `fp-responsive` is added to the plugin's container in case the user wants to use it for his own responsive CSS.
1961
+ */
1962
+ function responsive(){
1963
+ var widthLimit = options.responsive || options.responsiveWidth; //backwards compatiblity
1964
+ var heightLimit = options.responsiveHeight;
1965
+
1966
+ //only calculating what we need. Remember its called on the resize event.
1967
+ var isBreakingPointWidth = widthLimit && $window.outerWidth() < widthLimit;
1968
+ var isBreakingPointHeight = heightLimit && $window.height() < heightLimit;
1969
+
1970
+ if(widthLimit && heightLimit){
1971
+ FP.setResponsive(isBreakingPointWidth || isBreakingPointHeight);
1972
+ }
1973
+ else if(widthLimit){
1974
+ FP.setResponsive(isBreakingPointWidth);
1975
+ }
1976
+ else if(heightLimit){
1977
+ FP.setResponsive(isBreakingPointHeight);
1978
+ }
1979
+ }
1980
+
1981
+ /**
1982
+ * Adds transition animations for the given element
1983
+ */
1984
+ function addAnimation(element){
1985
+ var transition = 'all ' + options.scrollingSpeed + 'ms ' + options.easingcss3;
1986
+
1987
+ element.removeClass(NO_TRANSITION);
1988
+ return element.css({
1989
+ '-webkit-transition': transition,
1990
+ 'transition': transition
1991
+ });
1992
+ }
1993
+
1994
+ /**
1995
+ * Remove transition animations for the given element
1996
+ */
1997
+ function removeAnimation(element){
1998
+ return element.addClass(NO_TRANSITION);
1999
+ }
2000
+
2001
+ /**
2002
+ * Activating the website navigation dots according to the given slide name.
2003
+ */
2004
+ function activateNavDots(name, sectionIndex){
2005
+ if(options.navigation){
2006
+ $(SECTION_NAV_SEL).find(ACTIVE_SEL).removeClass(ACTIVE);
2007
+ if(name){
2008
+ $(SECTION_NAV_SEL).find('a[href="#' + name + '"]').addClass(ACTIVE);
2009
+ }else{
2010
+ $(SECTION_NAV_SEL).find('li').eq(sectionIndex).find('a').addClass(ACTIVE);
2011
+ }
2012
+ }
2013
+ }
2014
+
2015
+ /**
2016
+ * Activating the website main menu elements according to the given slide name.
2017
+ */
2018
+ function activateMenuElement(name){
2019
+ if(options.menu){
2020
+ $(options.menu).find(ACTIVE_SEL).removeClass(ACTIVE);
2021
+ $(options.menu).find('[data-menuanchor="'+name+'"]').addClass(ACTIVE);
2022
+ }
2023
+ }
2024
+
2025
+ /**
2026
+ * Sets to active the current menu and vertical nav items.
2027
+ */
2028
+ function activateMenuAndNav(anchor, index){
2029
+ activateMenuElement(anchor);
2030
+ activateNavDots(anchor, index);
2031
+ }
2032
+
2033
+ /**
2034
+ * Retuns `up` or `down` depending on the scrolling movement to reach its destination
2035
+ * from the current section.
2036
+ */
2037
+ function getYmovement(destiny){
2038
+ var fromIndex = $(SECTION_ACTIVE_SEL).index(SECTION_SEL);
2039
+ var toIndex = destiny.index(SECTION_SEL);
2040
+ if( fromIndex == toIndex){
2041
+ return 'none';
2042
+ }
2043
+ if(fromIndex > toIndex){
2044
+ return 'up';
2045
+ }
2046
+ return 'down';
2047
+ }
2048
+
2049
+ /**
2050
+ * Retuns `right` or `left` depending on the scrolling movement to reach its destination
2051
+ * from the current slide.
2052
+ */
2053
+ function getXmovement(fromIndex, toIndex){
2054
+ if( fromIndex == toIndex){
2055
+ return 'none';
2056
+ }
2057
+ if(fromIndex > toIndex){
2058
+ return 'left';
2059
+ }
2060
+ return 'right';
2061
+ }
2062
+
2063
+ /**
2064
+ * Checks if the element needs scrollbar and if the user wants to apply it.
2065
+ * If so it creates it.
2066
+ *
2067
+ * @param {Object} element jQuery object of the section or slide
2068
+ */
2069
+ function createSlimScrolling(element){
2070
+ //User doesn't want scrollbar here? Sayonara baby!
2071
+ if(element.hasClass('fp-noscroll')) return;
2072
+
2073
+ //needed to make `scrollHeight` work under Opera 12
2074
+ element.css('overflow', 'hidden');
2075
+
2076
+ var scrollOverflowHandler = options.scrollOverflowHandler;
2077
+ var wrap = scrollOverflowHandler.wrapContent();
2078
+ //in case element is a slide
2079
+ var section = element.closest(SECTION_SEL);
2080
+ var scrollable = scrollOverflowHandler.scrollable(element);
2081
+ var contentHeight;
2082
+
2083
+ //if there was scroll, the contentHeight will be the one in the scrollable section
2084
+ if(scrollable.length){
2085
+ contentHeight = scrollOverflowHandler.scrollHeight(element);
2086
+ }else{
2087
+ contentHeight = element.get(0).scrollHeight;
2088
+ if(options.verticalCentered){
2089
+ contentHeight = element.find(TABLE_CELL_SEL).get(0).scrollHeight;
2090
+ }
2091
+ }
2092
+
2093
+ var scrollHeight = windowsHeight - parseInt(section.css('padding-bottom')) - parseInt(section.css('padding-top'));
2094
+
2095
+ //needs scroll?
2096
+ if ( contentHeight > scrollHeight) {
2097
+ //did we already have an scrollbar ? Updating it
2098
+ if(scrollable.length){
2099
+ scrollOverflowHandler.update(element, scrollHeight);
2100
+ }
2101
+ //creating the scrolling
2102
+ else{
2103
+ if(options.verticalCentered){
2104
+ element.find(TABLE_CELL_SEL).wrapInner(wrap);
2105
+ }else{
2106
+ element.wrapInner(wrap);
2107
+ }
2108
+ scrollOverflowHandler.create(element, scrollHeight);
2109
+ }
2110
+ }
2111
+ //removing the scrolling when it is not necessary anymore
2112
+ else{
2113
+ scrollOverflowHandler.remove(element);
2114
+ }
2115
+
2116
+ //undo
2117
+ element.css('overflow', '');
2118
+ }
2119
+
2120
+ function addTableClass(element){
2121
+ element.addClass(TABLE).wrapInner('<div class="' + TABLE_CELL + '" style="height:' + getTableHeight(element) + 'px;" />');
2122
+ }
2123
+
2124
+ function getTableHeight(element){
2125
+ var sectionHeight = windowsHeight;
2126
+
2127
+ if(options.paddingTop || options.paddingBottom){
2128
+ var section = element;
2129
+ if(!section.hasClass(SECTION)){
2130
+ section = element.closest(SECTION_SEL);
2131
+ }
2132
+
2133
+ var paddings = parseInt(section.css('padding-top')) + parseInt(section.css('padding-bottom'));
2134
+ sectionHeight = (windowsHeight - paddings);
2135
+ }
2136
+
2137
+ ret