mirror of
https://github.com/documize/community.git
synced 2025-08-02 20:15:26 +02:00
new doc sidebar add section -- initial commit
This commit is contained in:
parent
20f9272d46
commit
003fbacd32
24 changed files with 1322 additions and 112 deletions
158
app/vendor/hoverIntent.js
vendored
Executable file
158
app/vendor/hoverIntent.js
vendored
Executable file
|
@ -0,0 +1,158 @@
|
|||
/*!
|
||||
* hoverIntent v1.8.1 // 2014.08.11 // jQuery v1.9.1+
|
||||
* http://briancherne.github.io/jquery-hoverIntent/
|
||||
*
|
||||
* You may use hoverIntent under the terms of the MIT license. Basically that
|
||||
* means you are free to use hoverIntent as long as this header is left intact.
|
||||
* Copyright 2007, 2014 Brian Cherne
|
||||
*/
|
||||
|
||||
/* hoverIntent is similar to jQuery's built-in "hover" method except that
|
||||
* instead of firing the handlerIn function immediately, hoverIntent checks
|
||||
* to see if the user's mouse has slowed down (beneath the sensitivity
|
||||
* threshold) before firing the event. The handlerOut function is only
|
||||
* called after a matching handlerIn.
|
||||
*
|
||||
* // basic usage ... just like .hover()
|
||||
* .hoverIntent( handlerIn, handlerOut )
|
||||
* .hoverIntent( handlerInOut )
|
||||
*
|
||||
* // basic usage ... with event delegation!
|
||||
* .hoverIntent( handlerIn, handlerOut, selector )
|
||||
* .hoverIntent( handlerInOut, selector )
|
||||
*
|
||||
* // using a basic configuration object
|
||||
* .hoverIntent( config )
|
||||
*
|
||||
* @param handlerIn function OR configuration object
|
||||
* @param handlerOut function OR selector for delegation OR undefined
|
||||
* @param selector selector OR undefined
|
||||
* @author Brian Cherne <brian(at)cherne(dot)net>
|
||||
*/
|
||||
|
||||
(function(factory) {
|
||||
'use strict';
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['jquery'], factory);
|
||||
} else if (jQuery && !jQuery.fn.hoverIntent) {
|
||||
factory(jQuery);
|
||||
}
|
||||
})(function($) {
|
||||
'use strict';
|
||||
|
||||
// default configuration values
|
||||
var _cfg = {
|
||||
interval: 100,
|
||||
sensitivity: 6,
|
||||
timeout: 0
|
||||
};
|
||||
|
||||
// counter used to generate an ID for each instance
|
||||
var INSTANCE_COUNT = 0;
|
||||
|
||||
// current X and Y position of mouse, updated during mousemove tracking (shared across instances)
|
||||
var cX, cY;
|
||||
|
||||
// saves the current pointer position coordinates based on the given mousemove event
|
||||
var track = function(ev) {
|
||||
cX = ev.pageX;
|
||||
cY = ev.pageY;
|
||||
};
|
||||
|
||||
// compares current and previous mouse positions
|
||||
var compare = function(ev,$el,s,cfg) {
|
||||
// compare mouse positions to see if pointer has slowed enough to trigger `over` function
|
||||
if ( Math.sqrt( (s.pX-cX)*(s.pX-cX) + (s.pY-cY)*(s.pY-cY) ) < cfg.sensitivity ) {
|
||||
$el.off(s.event,track);
|
||||
delete s.timeoutId;
|
||||
// set hoverIntent state as active for this element (permits `out` handler to trigger)
|
||||
s.isActive = true;
|
||||
// overwrite old mouseenter event coordinates with most recent pointer position
|
||||
ev.pageX = cX; ev.pageY = cY;
|
||||
// clear coordinate data from state object
|
||||
delete s.pX; delete s.pY;
|
||||
return cfg.over.apply($el[0],[ev]);
|
||||
} else {
|
||||
// set previous coordinates for next comparison
|
||||
s.pX = cX; s.pY = cY;
|
||||
// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
|
||||
s.timeoutId = setTimeout( function(){compare(ev, $el, s, cfg);} , cfg.interval );
|
||||
}
|
||||
};
|
||||
|
||||
// triggers given `out` function at configured `timeout` after a mouseleave and clears state
|
||||
var delay = function(ev,$el,s,out) {
|
||||
delete $el.data('hoverIntent')[s.id];
|
||||
return out.apply($el[0],[ev]);
|
||||
};
|
||||
|
||||
$.fn.hoverIntent = function(handlerIn,handlerOut,selector) {
|
||||
// instance ID, used as a key to store and retrieve state information on an element
|
||||
var instanceId = INSTANCE_COUNT++;
|
||||
|
||||
// extend the default configuration and parse parameters
|
||||
var cfg = $.extend({}, _cfg);
|
||||
if ( $.isPlainObject(handlerIn) ) {
|
||||
cfg = $.extend(cfg, handlerIn);
|
||||
if ( !$.isFunction(cfg.out) ) {
|
||||
cfg.out = cfg.over;
|
||||
}
|
||||
} else if ( $.isFunction(handlerOut) ) {
|
||||
cfg = $.extend(cfg, { over: handlerIn, out: handlerOut, selector: selector } );
|
||||
} else {
|
||||
cfg = $.extend(cfg, { over: handlerIn, out: handlerIn, selector: handlerOut } );
|
||||
}
|
||||
|
||||
// A private function for handling mouse 'hovering'
|
||||
var handleHover = function(e) {
|
||||
// cloned event to pass to handlers (copy required for event object to be passed in IE)
|
||||
var ev = $.extend({},e);
|
||||
|
||||
// the current target of the mouse event, wrapped in a jQuery object
|
||||
var $el = $(this);
|
||||
|
||||
// read hoverIntent data from element (or initialize if not present)
|
||||
var hoverIntentData = $el.data('hoverIntent');
|
||||
if (!hoverIntentData) { $el.data('hoverIntent', (hoverIntentData = {})); }
|
||||
|
||||
// read per-instance state from element (or initialize if not present)
|
||||
var state = hoverIntentData[instanceId];
|
||||
if (!state) { hoverIntentData[instanceId] = state = { id: instanceId }; }
|
||||
|
||||
// state properties:
|
||||
// id = instance ID, used to clean up data
|
||||
// timeoutId = timeout ID, reused for tracking mouse position and delaying "out" handler
|
||||
// isActive = plugin state, true after `over` is called just until `out` is called
|
||||
// pX, pY = previously-measured pointer coordinates, updated at each polling interval
|
||||
// event = string representing the namespaced event used for mouse tracking
|
||||
|
||||
// clear any existing timeout
|
||||
if (state.timeoutId) { state.timeoutId = clearTimeout(state.timeoutId); }
|
||||
|
||||
// namespaced event used to register and unregister mousemove tracking
|
||||
var mousemove = state.event = 'mousemove.hoverIntent.hoverIntent'+instanceId;
|
||||
|
||||
// handle the event, based on its type
|
||||
if (e.type === 'mouseenter') {
|
||||
// do nothing if already active
|
||||
if (state.isActive) { return; }
|
||||
// set "previous" X and Y position based on initial entry point
|
||||
state.pX = ev.pageX; state.pY = ev.pageY;
|
||||
// update "current" X and Y position based on mousemove
|
||||
$el.off(mousemove,track).on(mousemove,track);
|
||||
// start polling interval (self-calling timeout) to compare mouse coordinates over time
|
||||
state.timeoutId = setTimeout( function(){compare(ev,$el,state,cfg);} , cfg.interval );
|
||||
} else { // "mouseleave"
|
||||
// do nothing if not already active
|
||||
if (!state.isActive) { return; }
|
||||
// unbind expensive mousemove event
|
||||
$el.off(mousemove,track);
|
||||
// if hoverIntent state is true, then call the mouseOut function after the specified delay
|
||||
state.timeoutId = setTimeout( function(){delay(ev,$el,state,cfg.out);} , cfg.timeout );
|
||||
}
|
||||
};
|
||||
|
||||
// listen for mouseenter and mouseleave
|
||||
return this.on({'mouseenter.hoverIntent':handleHover,'mouseleave.hoverIntent':handleHover}, cfg.selector);
|
||||
};
|
||||
});
|
939
app/vendor/waypoints.js
vendored
Normal file
939
app/vendor/waypoints.js
vendored
Normal file
|
@ -0,0 +1,939 @@
|
|||
/*!
|
||||
Waypoints - 4.0.1
|
||||
Copyright © 2011-2016 Caleb Troughton
|
||||
Licensed under the MIT license.
|
||||
https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
|
||||
*/
|
||||
(function() {
|
||||
'use strict'
|
||||
|
||||
var keyCounter = 0
|
||||
var allWaypoints = {}
|
||||
|
||||
/* http://imakewebthings.com/waypoints/api/waypoint */
|
||||
function Waypoint(options) {
|
||||
if (!options) {
|
||||
throw new Error('No options passed to Waypoint constructor')
|
||||
}
|
||||
if (!options.element) {
|
||||
throw new Error('No element option passed to Waypoint constructor')
|
||||
}
|
||||
if (!options.handler) {
|
||||
throw new Error('No handler option passed to Waypoint constructor')
|
||||
}
|
||||
|
||||
this.key = 'waypoint-' + keyCounter
|
||||
this.options = Waypoint.Adapter.extend({}, Waypoint.defaults, options)
|
||||
this.element = this.options.element
|
||||
this.adapter = new Waypoint.Adapter(this.element)
|
||||
this.callback = options.handler
|
||||
this.axis = this.options.horizontal ? 'horizontal' : 'vertical'
|
||||
this.enabled = this.options.enabled
|
||||
this.triggerPoint = null
|
||||
this.group = Waypoint.Group.findOrCreate({
|
||||
name: this.options.group,
|
||||
axis: this.axis
|
||||
})
|
||||
this.context = Waypoint.Context.findOrCreateByElement(this.options.context)
|
||||
|
||||
if (Waypoint.offsetAliases[this.options.offset]) {
|
||||
this.options.offset = Waypoint.offsetAliases[this.options.offset]
|
||||
}
|
||||
this.group.add(this)
|
||||
this.context.add(this)
|
||||
allWaypoints[this.key] = this
|
||||
keyCounter += 1
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Waypoint.prototype.queueTrigger = function(direction) {
|
||||
this.group.queueTrigger(this, direction)
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Waypoint.prototype.trigger = function(args) {
|
||||
if (!this.enabled) {
|
||||
return
|
||||
}
|
||||
if (this.callback) {
|
||||
this.callback.apply(this, args)
|
||||
}
|
||||
}
|
||||
|
||||
/* Public */
|
||||
/* http://imakewebthings.com/waypoints/api/destroy */
|
||||
Waypoint.prototype.destroy = function() {
|
||||
this.context.remove(this)
|
||||
this.group.remove(this)
|
||||
delete allWaypoints[this.key]
|
||||
}
|
||||
|
||||
/* Public */
|
||||
/* http://imakewebthings.com/waypoints/api/disable */
|
||||
Waypoint.prototype.disable = function() {
|
||||
this.enabled = false
|
||||
return this
|
||||
}
|
||||
|
||||
/* Public */
|
||||
/* http://imakewebthings.com/waypoints/api/enable */
|
||||
Waypoint.prototype.enable = function() {
|
||||
this.context.refresh()
|
||||
this.enabled = true
|
||||
return this
|
||||
}
|
||||
|
||||
/* Public */
|
||||
/* http://imakewebthings.com/waypoints/api/next */
|
||||
Waypoint.prototype.next = function() {
|
||||
return this.group.next(this)
|
||||
}
|
||||
|
||||
/* Public */
|
||||
/* http://imakewebthings.com/waypoints/api/previous */
|
||||
Waypoint.prototype.previous = function() {
|
||||
return this.group.previous(this)
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Waypoint.invokeAll = function(method) {
|
||||
var allWaypointsArray = []
|
||||
for (var waypointKey in allWaypoints) {
|
||||
allWaypointsArray.push(allWaypoints[waypointKey])
|
||||
}
|
||||
for (var i = 0, end = allWaypointsArray.length; i < end; i++) {
|
||||
allWaypointsArray[i][method]()
|
||||
}
|
||||
}
|
||||
|
||||
/* Public */
|
||||
/* http://imakewebthings.com/waypoints/api/destroy-all */
|
||||
Waypoint.destroyAll = function() {
|
||||
Waypoint.invokeAll('destroy')
|
||||
}
|
||||
|
||||
/* Public */
|
||||
/* http://imakewebthings.com/waypoints/api/disable-all */
|
||||
Waypoint.disableAll = function() {
|
||||
Waypoint.invokeAll('disable')
|
||||
}
|
||||
|
||||
/* Public */
|
||||
/* http://imakewebthings.com/waypoints/api/enable-all */
|
||||
Waypoint.enableAll = function() {
|
||||
Waypoint.Context.refreshAll()
|
||||
for (var waypointKey in allWaypoints) {
|
||||
allWaypoints[waypointKey].enabled = true
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
/* Public */
|
||||
/* http://imakewebthings.com/waypoints/api/refresh-all */
|
||||
Waypoint.refreshAll = function() {
|
||||
Waypoint.Context.refreshAll()
|
||||
}
|
||||
|
||||
/* Public */
|
||||
/* http://imakewebthings.com/waypoints/api/viewport-height */
|
||||
Waypoint.viewportHeight = function() {
|
||||
return window.innerHeight || document.documentElement.clientHeight
|
||||
}
|
||||
|
||||
/* Public */
|
||||
/* http://imakewebthings.com/waypoints/api/viewport-width */
|
||||
Waypoint.viewportWidth = function() {
|
||||
return document.documentElement.clientWidth
|
||||
}
|
||||
|
||||
Waypoint.adapters = []
|
||||
|
||||
Waypoint.defaults = {
|
||||
context: window,
|
||||
continuous: true,
|
||||
enabled: true,
|
||||
group: 'default',
|
||||
horizontal: false,
|
||||
offset: 0
|
||||
}
|
||||
|
||||
Waypoint.offsetAliases = {
|
||||
'bottom-in-view': function() {
|
||||
return this.context.innerHeight() - this.adapter.outerHeight()
|
||||
},
|
||||
'right-in-view': function() {
|
||||
return this.context.innerWidth() - this.adapter.outerWidth()
|
||||
}
|
||||
}
|
||||
|
||||
window.Waypoint = Waypoint
|
||||
}())
|
||||
;(function() {
|
||||
'use strict'
|
||||
|
||||
function requestAnimationFrameShim(callback) {
|
||||
window.setTimeout(callback, 1000 / 60)
|
||||
}
|
||||
|
||||
var keyCounter = 0
|
||||
var contexts = {}
|
||||
var Waypoint = window.Waypoint
|
||||
var oldWindowLoad = window.onload
|
||||
|
||||
/* http://imakewebthings.com/waypoints/api/context */
|
||||
function Context(element) {
|
||||
this.element = element
|
||||
this.Adapter = Waypoint.Adapter
|
||||
this.adapter = new this.Adapter(element)
|
||||
this.key = 'waypoint-context-' + keyCounter
|
||||
this.didScroll = false
|
||||
this.didResize = false
|
||||
this.oldScroll = {
|
||||
x: this.adapter.scrollLeft(),
|
||||
y: this.adapter.scrollTop()
|
||||
}
|
||||
this.waypoints = {
|
||||
vertical: {},
|
||||
horizontal: {}
|
||||
}
|
||||
|
||||
element.waypointContextKey = this.key
|
||||
contexts[element.waypointContextKey] = this
|
||||
keyCounter += 1
|
||||
if (!Waypoint.windowContext) {
|
||||
Waypoint.windowContext = true
|
||||
Waypoint.windowContext = new Context(window)
|
||||
}
|
||||
|
||||
this.createThrottledScrollHandler()
|
||||
this.createThrottledResizeHandler()
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Context.prototype.add = function(waypoint) {
|
||||
var axis = waypoint.options.horizontal ? 'horizontal' : 'vertical'
|
||||
this.waypoints[axis][waypoint.key] = waypoint
|
||||
this.refresh()
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Context.prototype.checkEmpty = function() {
|
||||
var horizontalEmpty = this.Adapter.isEmptyObject(this.waypoints.horizontal)
|
||||
var verticalEmpty = this.Adapter.isEmptyObject(this.waypoints.vertical)
|
||||
var isWindow = this.element == this.element.window
|
||||
if (horizontalEmpty && verticalEmpty && !isWindow) {
|
||||
this.adapter.off('.waypoints')
|
||||
delete contexts[this.key]
|
||||
}
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Context.prototype.createThrottledResizeHandler = function() {
|
||||
var self = this
|
||||
|
||||
function resizeHandler() {
|
||||
self.handleResize()
|
||||
self.didResize = false
|
||||
}
|
||||
|
||||
this.adapter.on('resize.waypoints', function() {
|
||||
if (!self.didResize) {
|
||||
self.didResize = true
|
||||
Waypoint.requestAnimationFrame(resizeHandler)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Context.prototype.createThrottledScrollHandler = function() {
|
||||
var self = this
|
||||
function scrollHandler() {
|
||||
self.handleScroll()
|
||||
self.didScroll = false
|
||||
}
|
||||
|
||||
this.adapter.on('scroll.waypoints', function() {
|
||||
if (!self.didScroll || Waypoint.isTouch) {
|
||||
self.didScroll = true
|
||||
Waypoint.requestAnimationFrame(scrollHandler)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Context.prototype.handleResize = function() {
|
||||
Waypoint.Context.refreshAll()
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Context.prototype.handleScroll = function() {
|
||||
var triggeredGroups = {}
|
||||
var axes = {
|
||||
horizontal: {
|
||||
newScroll: this.adapter.scrollLeft(),
|
||||
oldScroll: this.oldScroll.x,
|
||||
forward: 'right',
|
||||
backward: 'left'
|
||||
},
|
||||
vertical: {
|
||||
newScroll: this.adapter.scrollTop(),
|
||||
oldScroll: this.oldScroll.y,
|
||||
forward: 'down',
|
||||
backward: 'up'
|
||||
}
|
||||
}
|
||||
|
||||
for (var axisKey in axes) {
|
||||
var axis = axes[axisKey]
|
||||
var isForward = axis.newScroll > axis.oldScroll
|
||||
var direction = isForward ? axis.forward : axis.backward
|
||||
|
||||
for (var waypointKey in this.waypoints[axisKey]) {
|
||||
var waypoint = this.waypoints[axisKey][waypointKey]
|
||||
if (waypoint.triggerPoint === null) {
|
||||
continue
|
||||
}
|
||||
var wasBeforeTriggerPoint = axis.oldScroll < waypoint.triggerPoint
|
||||
var nowAfterTriggerPoint = axis.newScroll >= waypoint.triggerPoint
|
||||
var crossedForward = wasBeforeTriggerPoint && nowAfterTriggerPoint
|
||||
var crossedBackward = !wasBeforeTriggerPoint && !nowAfterTriggerPoint
|
||||
if (crossedForward || crossedBackward) {
|
||||
waypoint.queueTrigger(direction)
|
||||
triggeredGroups[waypoint.group.id] = waypoint.group
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var groupKey in triggeredGroups) {
|
||||
triggeredGroups[groupKey].flushTriggers()
|
||||
}
|
||||
|
||||
this.oldScroll = {
|
||||
x: axes.horizontal.newScroll,
|
||||
y: axes.vertical.newScroll
|
||||
}
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Context.prototype.innerHeight = function() {
|
||||
/*eslint-disable eqeqeq */
|
||||
if (this.element == this.element.window) {
|
||||
return Waypoint.viewportHeight()
|
||||
}
|
||||
/*eslint-enable eqeqeq */
|
||||
return this.adapter.innerHeight()
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Context.prototype.remove = function(waypoint) {
|
||||
delete this.waypoints[waypoint.axis][waypoint.key]
|
||||
this.checkEmpty()
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Context.prototype.innerWidth = function() {
|
||||
/*eslint-disable eqeqeq */
|
||||
if (this.element == this.element.window) {
|
||||
return Waypoint.viewportWidth()
|
||||
}
|
||||
/*eslint-enable eqeqeq */
|
||||
return this.adapter.innerWidth()
|
||||
}
|
||||
|
||||
/* Public */
|
||||
/* http://imakewebthings.com/waypoints/api/context-destroy */
|
||||
Context.prototype.destroy = function() {
|
||||
var allWaypoints = []
|
||||
for (var axis in this.waypoints) {
|
||||
for (var waypointKey in this.waypoints[axis]) {
|
||||
allWaypoints.push(this.waypoints[axis][waypointKey])
|
||||
}
|
||||
}
|
||||
for (var i = 0, end = allWaypoints.length; i < end; i++) {
|
||||
allWaypoints[i].destroy()
|
||||
}
|
||||
}
|
||||
|
||||
/* Public */
|
||||
/* http://imakewebthings.com/waypoints/api/context-refresh */
|
||||
Context.prototype.refresh = function() {
|
||||
/*eslint-disable eqeqeq */
|
||||
var isWindow = this.element == this.element.window
|
||||
/*eslint-enable eqeqeq */
|
||||
var contextOffset = isWindow ? undefined : this.adapter.offset()
|
||||
var triggeredGroups = {}
|
||||
var axes
|
||||
|
||||
this.handleScroll()
|
||||
axes = {
|
||||
horizontal: {
|
||||
contextOffset: isWindow ? 0 : contextOffset.left,
|
||||
contextScroll: isWindow ? 0 : this.oldScroll.x,
|
||||
contextDimension: this.innerWidth(),
|
||||
oldScroll: this.oldScroll.x,
|
||||
forward: 'right',
|
||||
backward: 'left',
|
||||
offsetProp: 'left'
|
||||
},
|
||||
vertical: {
|
||||
contextOffset: isWindow ? 0 : contextOffset.top,
|
||||
contextScroll: isWindow ? 0 : this.oldScroll.y,
|
||||
contextDimension: this.innerHeight(),
|
||||
oldScroll: this.oldScroll.y,
|
||||
forward: 'down',
|
||||
backward: 'up',
|
||||
offsetProp: 'top'
|
||||
}
|
||||
}
|
||||
|
||||
for (var axisKey in axes) {
|
||||
var axis = axes[axisKey]
|
||||
for (var waypointKey in this.waypoints[axisKey]) {
|
||||
var waypoint = this.waypoints[axisKey][waypointKey]
|
||||
var adjustment = waypoint.options.offset
|
||||
var oldTriggerPoint = waypoint.triggerPoint
|
||||
var elementOffset = 0
|
||||
var freshWaypoint = oldTriggerPoint == null
|
||||
var contextModifier, wasBeforeScroll, nowAfterScroll
|
||||
var triggeredBackward, triggeredForward
|
||||
|
||||
if (waypoint.element !== waypoint.element.window) {
|
||||
elementOffset = waypoint.adapter.offset()[axis.offsetProp]
|
||||
}
|
||||
|
||||
if (typeof adjustment === 'function') {
|
||||
adjustment = adjustment.apply(waypoint)
|
||||
}
|
||||
else if (typeof adjustment === 'string') {
|
||||
adjustment = parseFloat(adjustment)
|
||||
if (waypoint.options.offset.indexOf('%') > - 1) {
|
||||
adjustment = Math.ceil(axis.contextDimension * adjustment / 100)
|
||||
}
|
||||
}
|
||||
|
||||
contextModifier = axis.contextScroll - axis.contextOffset
|
||||
waypoint.triggerPoint = Math.floor(elementOffset + contextModifier - adjustment)
|
||||
wasBeforeScroll = oldTriggerPoint < axis.oldScroll
|
||||
nowAfterScroll = waypoint.triggerPoint >= axis.oldScroll
|
||||
triggeredBackward = wasBeforeScroll && nowAfterScroll
|
||||
triggeredForward = !wasBeforeScroll && !nowAfterScroll
|
||||
|
||||
if (!freshWaypoint && triggeredBackward) {
|
||||
waypoint.queueTrigger(axis.backward)
|
||||
triggeredGroups[waypoint.group.id] = waypoint.group
|
||||
}
|
||||
else if (!freshWaypoint && triggeredForward) {
|
||||
waypoint.queueTrigger(axis.forward)
|
||||
triggeredGroups[waypoint.group.id] = waypoint.group
|
||||
}
|
||||
else if (freshWaypoint && axis.oldScroll >= waypoint.triggerPoint) {
|
||||
waypoint.queueTrigger(axis.forward)
|
||||
triggeredGroups[waypoint.group.id] = waypoint.group
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Waypoint.requestAnimationFrame(function() {
|
||||
for (var groupKey in triggeredGroups) {
|
||||
triggeredGroups[groupKey].flushTriggers()
|
||||
}
|
||||
})
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Context.findOrCreateByElement = function(element) {
|
||||
return Context.findByElement(element) || new Context(element)
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Context.refreshAll = function() {
|
||||
for (var contextId in contexts) {
|
||||
contexts[contextId].refresh()
|
||||
}
|
||||
}
|
||||
|
||||
/* Public */
|
||||
/* http://imakewebthings.com/waypoints/api/context-find-by-element */
|
||||
Context.findByElement = function(element) {
|
||||
return contexts[element.waypointContextKey]
|
||||
}
|
||||
|
||||
window.onload = function() {
|
||||
if (oldWindowLoad) {
|
||||
oldWindowLoad()
|
||||
}
|
||||
Context.refreshAll()
|
||||
}
|
||||
|
||||
|
||||
Waypoint.requestAnimationFrame = function(callback) {
|
||||
var requestFn = window.requestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
requestAnimationFrameShim
|
||||
requestFn.call(window, callback)
|
||||
}
|
||||
Waypoint.Context = Context
|
||||
}())
|
||||
;(function() {
|
||||
'use strict'
|
||||
|
||||
function byTriggerPoint(a, b) {
|
||||
return a.triggerPoint - b.triggerPoint
|
||||
}
|
||||
|
||||
function byReverseTriggerPoint(a, b) {
|
||||
return b.triggerPoint - a.triggerPoint
|
||||
}
|
||||
|
||||
var groups = {
|
||||
vertical: {},
|
||||
horizontal: {}
|
||||
}
|
||||
var Waypoint = window.Waypoint
|
||||
|
||||
/* http://imakewebthings.com/waypoints/api/group */
|
||||
function Group(options) {
|
||||
this.name = options.name
|
||||
this.axis = options.axis
|
||||
this.id = this.name + '-' + this.axis
|
||||
this.waypoints = []
|
||||
this.clearTriggerQueues()
|
||||
groups[this.axis][this.name] = this
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Group.prototype.add = function(waypoint) {
|
||||
this.waypoints.push(waypoint)
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Group.prototype.clearTriggerQueues = function() {
|
||||
this.triggerQueues = {
|
||||
up: [],
|
||||
down: [],
|
||||
left: [],
|
||||
right: []
|
||||
}
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Group.prototype.flushTriggers = function() {
|
||||
for (var direction in this.triggerQueues) {
|
||||
var waypoints = this.triggerQueues[direction]
|
||||
var reverse = direction === 'up' || direction === 'left'
|
||||
waypoints.sort(reverse ? byReverseTriggerPoint : byTriggerPoint)
|
||||
for (var i = 0, end = waypoints.length; i < end; i += 1) {
|
||||
var waypoint = waypoints[i]
|
||||
if (waypoint.options.continuous || i === waypoints.length - 1) {
|
||||
waypoint.trigger([direction])
|
||||
}
|
||||
}
|
||||
}
|
||||
this.clearTriggerQueues()
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Group.prototype.next = function(waypoint) {
|
||||
this.waypoints.sort(byTriggerPoint)
|
||||
var index = Waypoint.Adapter.inArray(waypoint, this.waypoints)
|
||||
var isLast = index === this.waypoints.length - 1
|
||||
return isLast ? null : this.waypoints[index + 1]
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Group.prototype.previous = function(waypoint) {
|
||||
this.waypoints.sort(byTriggerPoint)
|
||||
var index = Waypoint.Adapter.inArray(waypoint, this.waypoints)
|
||||
return index ? this.waypoints[index - 1] : null
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Group.prototype.queueTrigger = function(waypoint, direction) {
|
||||
this.triggerQueues[direction].push(waypoint)
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Group.prototype.remove = function(waypoint) {
|
||||
var index = Waypoint.Adapter.inArray(waypoint, this.waypoints)
|
||||
if (index > -1) {
|
||||
this.waypoints.splice(index, 1)
|
||||
}
|
||||
}
|
||||
|
||||
/* Public */
|
||||
/* http://imakewebthings.com/waypoints/api/first */
|
||||
Group.prototype.first = function() {
|
||||
return this.waypoints[0]
|
||||
}
|
||||
|
||||
/* Public */
|
||||
/* http://imakewebthings.com/waypoints/api/last */
|
||||
Group.prototype.last = function() {
|
||||
return this.waypoints[this.waypoints.length - 1]
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Group.findOrCreate = function(options) {
|
||||
return groups[options.axis][options.name] || new Group(options)
|
||||
}
|
||||
|
||||
Waypoint.Group = Group
|
||||
}())
|
||||
;(function() {
|
||||
'use strict'
|
||||
|
||||
var $ = window.jQuery
|
||||
var Waypoint = window.Waypoint
|
||||
|
||||
function JQueryAdapter(element) {
|
||||
this.$element = $(element)
|
||||
}
|
||||
|
||||
$.each([
|
||||
'innerHeight',
|
||||
'innerWidth',
|
||||
'off',
|
||||
'offset',
|
||||
'on',
|
||||
'outerHeight',
|
||||
'outerWidth',
|
||||
'scrollLeft',
|
||||
'scrollTop'
|
||||
], function(i, method) {
|
||||
JQueryAdapter.prototype[method] = function() {
|
||||
var args = Array.prototype.slice.call(arguments)
|
||||
return this.$element[method].apply(this.$element, args)
|
||||
}
|
||||
})
|
||||
|
||||
$.each([
|
||||
'extend',
|
||||
'inArray',
|
||||
'isEmptyObject'
|
||||
], function(i, method) {
|
||||
JQueryAdapter[method] = $[method]
|
||||
})
|
||||
|
||||
Waypoint.adapters.push({
|
||||
name: 'jquery',
|
||||
Adapter: JQueryAdapter
|
||||
})
|
||||
Waypoint.Adapter = JQueryAdapter
|
||||
}())
|
||||
;(function() {
|
||||
'use strict'
|
||||
|
||||
var Waypoint = window.Waypoint
|
||||
|
||||
function createExtension(framework) {
|
||||
return function() {
|
||||
var waypoints = []
|
||||
var overrides = arguments[0]
|
||||
|
||||
if (framework.isFunction(arguments[0])) {
|
||||
overrides = framework.extend({}, arguments[1])
|
||||
overrides.handler = arguments[0]
|
||||
}
|
||||
|
||||
this.each(function() {
|
||||
var options = framework.extend({}, overrides, {
|
||||
element: this
|
||||
})
|
||||
if (typeof options.context === 'string') {
|
||||
options.context = framework(this).closest(options.context)[0]
|
||||
}
|
||||
waypoints.push(new Waypoint(options))
|
||||
})
|
||||
|
||||
return waypoints
|
||||
}
|
||||
}
|
||||
|
||||
if (window.jQuery) {
|
||||
window.jQuery.fn.waypoint = createExtension(window.jQuery)
|
||||
}
|
||||
if (window.Zepto) {
|
||||
window.Zepto.fn.waypoint = createExtension(window.Zepto)
|
||||
}
|
||||
}())
|
||||
;
|
||||
|
||||
/*!
|
||||
Waypoints Sticky Element Shortcut - 4.0.1
|
||||
Copyright © 2011-2016 Caleb Troughton
|
||||
Licensed under the MIT license.
|
||||
https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
|
||||
*/
|
||||
(function() {
|
||||
'use strict'
|
||||
|
||||
var $ = window.jQuery
|
||||
var Waypoint = window.Waypoint
|
||||
|
||||
/* http://imakewebthings.com/waypoints/shortcuts/sticky-elements */
|
||||
function Sticky(options) {
|
||||
this.options = $.extend({}, Waypoint.defaults, Sticky.defaults, options)
|
||||
this.element = this.options.element
|
||||
this.$element = $(this.element)
|
||||
this.createWrapper()
|
||||
this.createWaypoint()
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Sticky.prototype.createWaypoint = function() {
|
||||
var originalHandler = this.options.handler
|
||||
|
||||
this.waypoint = new Waypoint($.extend({}, this.options, {
|
||||
element: this.wrapper,
|
||||
handler: $.proxy(function(direction) {
|
||||
var shouldBeStuck = this.options.direction.indexOf(direction) > -1
|
||||
var wrapperHeight = shouldBeStuck ? this.$element.outerHeight(true) : ''
|
||||
|
||||
this.$wrapper.height(wrapperHeight)
|
||||
this.$element.toggleClass(this.options.stuckClass, shouldBeStuck)
|
||||
|
||||
if (originalHandler) {
|
||||
originalHandler.call(this, direction)
|
||||
}
|
||||
}, this)
|
||||
}))
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Sticky.prototype.createWrapper = function() {
|
||||
if (this.options.wrapper) {
|
||||
this.$element.wrap(this.options.wrapper)
|
||||
}
|
||||
this.$wrapper = this.$element.parent()
|
||||
this.wrapper = this.$wrapper[0]
|
||||
}
|
||||
|
||||
/* Public */
|
||||
Sticky.prototype.destroy = function() {
|
||||
if (this.$element.parent()[0] === this.wrapper) {
|
||||
this.waypoint.destroy()
|
||||
this.$element.removeClass(this.options.stuckClass)
|
||||
if (this.options.wrapper) {
|
||||
this.$element.unwrap()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Sticky.defaults = {
|
||||
wrapper: '<div class="sticky-wrapper" />',
|
||||
stuckClass: 'stuck',
|
||||
direction: 'down right'
|
||||
}
|
||||
|
||||
Waypoint.Sticky = Sticky
|
||||
}())
|
||||
;
|
||||
|
||||
/*!
|
||||
Waypoints Inview Shortcut - 4.0.1
|
||||
Copyright © 2011-2016 Caleb Troughton
|
||||
Licensed under the MIT license.
|
||||
https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
|
||||
*/
|
||||
(function() {
|
||||
'use strict'
|
||||
|
||||
function noop() {}
|
||||
|
||||
var Waypoint = window.Waypoint
|
||||
|
||||
/* http://imakewebthings.com/waypoints/shortcuts/inview */
|
||||
function Inview(options) {
|
||||
this.options = Waypoint.Adapter.extend({}, Inview.defaults, options)
|
||||
this.axis = this.options.horizontal ? 'horizontal' : 'vertical'
|
||||
this.waypoints = []
|
||||
this.element = this.options.element
|
||||
this.createWaypoints()
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Inview.prototype.createWaypoints = function() {
|
||||
var configs = {
|
||||
vertical: [{
|
||||
down: 'enter',
|
||||
up: 'exited',
|
||||
offset: '100%'
|
||||
}, {
|
||||
down: 'entered',
|
||||
up: 'exit',
|
||||
offset: 'bottom-in-view'
|
||||
}, {
|
||||
down: 'exit',
|
||||
up: 'entered',
|
||||
offset: 0
|
||||
}, {
|
||||
down: 'exited',
|
||||
up: 'enter',
|
||||
offset: function() {
|
||||
return -this.adapter.outerHeight()
|
||||
}
|
||||
}],
|
||||
horizontal: [{
|
||||
right: 'enter',
|
||||
left: 'exited',
|
||||
offset: '100%'
|
||||
}, {
|
||||
right: 'entered',
|
||||
left: 'exit',
|
||||
offset: 'right-in-view'
|
||||
}, {
|
||||
right: 'exit',
|
||||
left: 'entered',
|
||||
offset: 0
|
||||
}, {
|
||||
right: 'exited',
|
||||
left: 'enter',
|
||||
offset: function() {
|
||||
return -this.adapter.outerWidth()
|
||||
}
|
||||
}]
|
||||
}
|
||||
|
||||
for (var i = 0, end = configs[this.axis].length; i < end; i++) {
|
||||
var config = configs[this.axis][i]
|
||||
this.createWaypoint(config)
|
||||
}
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Inview.prototype.createWaypoint = function(config) {
|
||||
var self = this
|
||||
this.waypoints.push(new Waypoint({
|
||||
context: this.options.context,
|
||||
element: this.options.element,
|
||||
enabled: this.options.enabled,
|
||||
handler: (function(config) {
|
||||
return function(direction) {
|
||||
self.options[config[direction]].call(self, direction)
|
||||
}
|
||||
}(config)),
|
||||
offset: config.offset,
|
||||
horizontal: this.options.horizontal
|
||||
}))
|
||||
}
|
||||
|
||||
/* Public */
|
||||
Inview.prototype.destroy = function() {
|
||||
for (var i = 0, end = this.waypoints.length; i < end; i++) {
|
||||
this.waypoints[i].destroy()
|
||||
}
|
||||
this.waypoints = []
|
||||
}
|
||||
|
||||
Inview.prototype.disable = function() {
|
||||
for (var i = 0, end = this.waypoints.length; i < end; i++) {
|
||||
this.waypoints[i].disable()
|
||||
}
|
||||
}
|
||||
|
||||
Inview.prototype.enable = function() {
|
||||
for (var i = 0, end = this.waypoints.length; i < end; i++) {
|
||||
this.waypoints[i].enable()
|
||||
}
|
||||
}
|
||||
|
||||
Inview.defaults = {
|
||||
context: window,
|
||||
enabled: true,
|
||||
enter: noop,
|
||||
entered: noop,
|
||||
exit: noop,
|
||||
exited: noop
|
||||
}
|
||||
|
||||
Waypoint.Inview = Inview
|
||||
}())
|
||||
;
|
||||
|
||||
/*!
|
||||
Waypoints Infinite Scroll Shortcut - 4.0.1
|
||||
Copyright © 2011-2016 Caleb Troughton
|
||||
Licensed under the MIT license.
|
||||
https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
|
||||
*/
|
||||
(function() {
|
||||
'use strict'
|
||||
|
||||
var $ = window.jQuery
|
||||
var Waypoint = window.Waypoint
|
||||
|
||||
/* http://imakewebthings.com/waypoints/shortcuts/infinite-scroll */
|
||||
function Infinite(options) {
|
||||
this.options = $.extend({}, Infinite.defaults, options)
|
||||
this.container = this.options.element
|
||||
if (this.options.container !== 'auto') {
|
||||
this.container = this.options.container
|
||||
}
|
||||
this.$container = $(this.container)
|
||||
this.$more = $(this.options.more)
|
||||
|
||||
if (this.$more.length) {
|
||||
this.setupHandler()
|
||||
this.waypoint = new Waypoint(this.options)
|
||||
}
|
||||
}
|
||||
|
||||
/* Private */
|
||||
Infinite.prototype.setupHandler = function() {
|
||||
this.options.handler = $.proxy(function() {
|
||||
this.options.onBeforePageLoad()
|
||||
this.destroy()
|
||||
this.$container.addClass(this.options.loadingClass)
|
||||
|
||||
$.get($(this.options.more).attr('href'), $.proxy(function(data) {
|
||||
var $data = $($.parseHTML(data))
|
||||
var $newMore = $data.find(this.options.more)
|
||||
|
||||
var $items = $data.find(this.options.items)
|
||||
if (!$items.length) {
|
||||
$items = $data.filter(this.options.items)
|
||||
}
|
||||
|
||||
this.$container.append($items)
|
||||
this.$container.removeClass(this.options.loadingClass)
|
||||
|
||||
if (!$newMore.length) {
|
||||
$newMore = $data.filter(this.options.more)
|
||||
}
|
||||
if ($newMore.length) {
|
||||
this.$more.replaceWith($newMore)
|
||||
this.$more = $newMore
|
||||
this.waypoint = new Waypoint(this.options)
|
||||
}
|
||||
else {
|
||||
this.$more.remove()
|
||||
}
|
||||
|
||||
this.options.onAfterPageLoad($items)
|
||||
}, this))
|
||||
}, this)
|
||||
}
|
||||
|
||||
/* Public */
|
||||
Infinite.prototype.destroy = function() {
|
||||
if (this.waypoint) {
|
||||
this.waypoint.destroy()
|
||||
}
|
||||
}
|
||||
|
||||
Infinite.defaults = {
|
||||
container: 'auto',
|
||||
items: '.infinite-item',
|
||||
more: '.infinite-more-link',
|
||||
offset: 'bottom-in-view',
|
||||
loadingClass: 'infinite-loading',
|
||||
onBeforePageLoad: $.noop,
|
||||
onAfterPageLoad: $.noop
|
||||
}
|
||||
|
||||
Waypoint.Infinite = Infinite
|
||||
}())
|
||||
;
|
Loading…
Add table
Add a link
Reference in a new issue