Вход Регистрация
Файл: CloudBox-main/doc/js/waypoints.js
Строк: 751
<?php
// Generated by CoffeeScript 1.6.2
/*
jQuery Waypoints - v2.0.3
Copyright (c) 2011-2013 Caleb Troughton
Dual licensed under the MIT license and GPL license.
https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt
*/


(function() {
  var 
__indexOf = [].indexOf || function(item) { for (var 0this.lengthli++) { if (i in this && this[i] === item) return i; } return -1; },
    
__slice = [].slice;

  (function(
rootfactory) {
    if (
typeof define === 'function' && define.amd) {
      return 
define('waypoints', ['jquery'], function($) {
        return 
factory($, root);
      });
    } else {
      return 
factory(root.jQueryroot);
    }
  })(
this, function($, window) {
    var 
$wContextWaypointallWaypointscontextCountercontextKeycontextsisTouchjQMethodsmethodsresizeEventscrollEventwaypointCounterwaypointKeywpwps;

    
$w = $(window);
    
isTouch __indexOf.call(window'ontouchstart') >= 0;
    
allWaypoints = {
      
horizontal: {},
      
vertical: {}
    };
    
contextCounter 1;
    
contexts = {};
    
contextKey 'waypoints-context-id';
    
resizeEvent 'resize.waypoints';
    
scrollEvent 'scroll.waypoints';
    
waypointCounter 1;
    
waypointKey 'waypoints-waypoint-ids';
    
wp 'waypoint';
    
wps 'waypoints';
    
Context = (function() {
      function 
Context($element) {
        var 
_this this;

        
this.$element $element;
        
this.element $element[0];
        
this.didResize false;
        
this.didScroll false;
        
this.id 'context' contextCounter++;
        
this.oldScroll = {
          
x$element.scrollLeft(),
          
y$element.scrollTop()
        };
        
this.waypoints = {
          
horizontal: {},
          
vertical: {}
        };
        
$element.data(contextKeythis.id);
        
contexts[this.id] = this;
        
$element.bind(scrollEvent, function() {
          var 
scrollHandler;

          if (!(
_this.didScroll || isTouch)) {
            
_this.didScroll true;
            
scrollHandler = function() {
              
_this.doScroll();
              return 
_this.didScroll false;
            };
            return 
window.setTimeout(scrollHandler, $[wps].settings.scrollThrottle);
          }
        });
        
$element.bind(resizeEvent, function() {
          var 
resizeHandler;

          if (!
_this.didResize) {
            
_this.didResize true;
            
resizeHandler = function() {
              $[
wps]('refresh');
              return 
_this.didResize false;
            };
            return 
window.setTimeout(resizeHandler, $[wps].settings.resizeThrottle);
          }
        });
      }

      
Context.prototype.doScroll = function() {
        var 
axes,
          
_this this;

        
axes = {
          
horizontal: {
            
newScrollthis.$element.scrollLeft(),
            
oldScrollthis.oldScroll.x,
            
forward'right',
            
backward'left'
          
},
          
vertical: {
            
newScrollthis.$element.scrollTop(),
            
oldScrollthis.oldScroll.y,
            
forward'down',
            
backward'up'
          
}
        };
        if (
isTouch && (!axes.vertical.oldScroll || !axes.vertical.newScroll)) {
          $[
wps]('refresh');
        }
        $.
each(axes, function(aKeyaxis) {
          var 
directionisForwardtriggered;

          
triggered = [];
          
isForward axis.newScroll axis.oldScroll;
          
direction isForward axis.forward axis.backward;
          $.
each(_this.waypoints[aKey], function(wKeywaypoint) {
            var 
_ref_ref1;

            if ((
axis.oldScroll < (_ref waypoint.offset) && _ref <= axis.newScroll)) {
              return 
triggered.push(waypoint);
            } else if ((
axis.newScroll < (_ref1 waypoint.offset) && _ref1 <= axis.oldScroll)) {
              return 
triggered.push(waypoint);
            }
          });
          
triggered.sort(function(ab) {
            return 
a.offset b.offset;
          });
          if (!
isForward) {
            
triggered.reverse();
          }
          return $.
each(triggered, function(iwaypoint) {
            if (
waypoint.options.continuous || === triggered.length 1) {
              return 
waypoint.trigger([direction]);
            }
          });
        });
        return 
this.oldScroll = {
          
xaxes.horizontal.newScroll,
          
yaxes.vertical.newScroll
        
};
      };

      
Context.prototype.refresh = function() {
        var 
axescOffsetisWin,
          
_this this;

        
isWin = $.isWindow(this.element);
        
cOffset this.$element.offset();
        
this.doScroll();
        
axes = {
          
horizontal: {
            
contextOffsetisWin cOffset.left,
            
contextScrollisWin this.oldScroll.x,
            
contextDimensionthis.$element.width(),
            
oldScrollthis.oldScroll.x,
            
forward'right',
            
backward'left',
            
offsetProp'left'
          
},
          
vertical: {
            
contextOffsetisWin cOffset.top,
            
contextScrollisWin this.oldScroll.y,
            
contextDimensionisWin ? $[wps]('viewportHeight') : this.$element.height(),
            
oldScrollthis.oldScroll.y,
            
forward'down',
            
backward'up',
            
offsetProp'top'
          
}
        };
        return $.
each(axes, function(aKeyaxis) {
          return $.
each(_this.waypoints[aKey], function(iwaypoint) {
            var 
adjustmentelementOffsetoldOffset_ref_ref1;

            
adjustment waypoint.options.offset;
            
oldOffset waypoint.offset;
            
elementOffset = $.isWindow(waypoint.element) ? waypoint.$element.offset()[axis.offsetProp];
            if ($.
isFunction(adjustment)) {
              
adjustment adjustment.apply(waypoint.element);
            } else if (
typeof adjustment === 'string') {
              
adjustment parseFloat(adjustment);
              if (
waypoint.options.offset.indexOf('%') > -1) {
                
adjustment Math.ceil(axis.contextDimension adjustment 100);
              }
            }
            
waypoint.offset elementOffset axis.contextOffset axis.contextScroll adjustment;
            if ((
waypoint.options.onlyOnScroll && (oldOffset != null)) || !waypoint.enabled) {
              return;
            }
            if (
oldOffset !== null && (oldOffset < (_ref axis.oldScroll) && _ref <= waypoint.offset)) {
              return 
waypoint.trigger([axis.backward]);
            } else if (
oldOffset !== null && (oldOffset > (_ref1 axis.oldScroll) && _ref1 >= waypoint.offset)) {
              return 
waypoint.trigger([axis.forward]);
            } else if (
oldOffset === null && axis.oldScroll >= waypoint.offset) {
              return 
waypoint.trigger([axis.forward]);
            }
          });
        });
      };

      
Context.prototype.checkEmpty = function() {
        if ($.
isEmptyObject(this.waypoints.horizontal) && $.isEmptyObject(this.waypoints.vertical)) {
          
this.$element.unbind([resizeEventscrollEvent].join(' '));
          return 
delete contexts[this.id];
        }
      };

      return 
Context;

    })();
    
Waypoint = (function() {
      function 
Waypoint($elementcontextoptions) {
        var 
idList_ref;

        
options = $.extend({}, $.fn[wp].defaultsoptions);
        if (
options.offset === 'bottom-in-view') {
          
options.offset = function() {
            var 
contextHeight;

            
contextHeight = $[wps]('viewportHeight');
            if (!$.
isWindow(context.element)) {
              
contextHeight context.$element.height();
            }
            return 
contextHeight - $(this).outerHeight();
          };
        }
        
this.$element $element;
        
this.element $element[0];
        
this.axis options.horizontal 'horizontal' 'vertical';
        
this.callback options.handler;
        
this.context context;
        
this.enabled options.enabled;
        
this.id 'waypoints' waypointCounter++;
        
this.offset null;
        
this.options options;
        
context.waypoints[this.axis][this.id] = this;
        
allWaypoints[this.axis][this.id] = this;
        
idList = (_ref $element.data(waypointKey)) != null _ref : [];
        
idList.push(this.id);
        
$element.data(waypointKeyidList);
      }

      
Waypoint.prototype.trigger = function(args) {
        if (!
this.enabled) {
          return;
        }
        if (
this.callback != null) {
          
this.callback.apply(this.elementargs);
        }
        if (
this.options.triggerOnce) {
          return 
this.destroy();
        }
      };

      
Waypoint.prototype.disable = function() {
        return 
this.enabled false;
      };

      
Waypoint.prototype.enable = function() {
        
this.context.refresh();
        return 
this.enabled true;
      };

      
Waypoint.prototype.destroy = function() {
        
delete allWaypoints[this.axis][this.id];
        
delete this.context.waypoints[this.axis][this.id];
        return 
this.context.checkEmpty();
      };

      
Waypoint.getWaypointsByElement = function(element) {
        var 
allids;

        
ids = $(element).data(waypointKey);
        if (!
ids) {
          return [];
        }
        
all = $.extend({}, allWaypoints.horizontalallWaypoints.vertical);
        return $.
map(ids, function(id) {
          return 
all[id];
        });
      };

      return 
Waypoint;

    })();
    
methods = {
      
init: function(foptions) {
        var 
_ref;

        if (
options == null) {
          
options = {};
        }
        if ((
_ref options.handler) == null) {
          
options.handler f;
        }
        
this.each(function() {
          var 
$thiscontextcontextElement_ref1;

          
$this = $(this);
          
contextElement = (_ref1 options.context) != null _ref1 : $.fn[wp].defaults.context;
          if (!$.
isWindow(contextElement)) {
            
contextElement $this.closest(contextElement);
          }
          
contextElement = $(contextElement);
          
context contexts[contextElement.data(contextKey)];
          if (!
context) {
            
context = new Context(contextElement);
          }
          return new 
Waypoint($thiscontextoptions);
        });
        $[
wps]('refresh');
        return 
this;
      },
      
disable: function() {
        return 
methods._invoke(this'disable');
      },
      
enable: function() {
        return 
methods._invoke(this'enable');
      },
      
destroy: function() {
        return 
methods._invoke(this'destroy');
      },
      
prev: function(axisselector) {
        return 
methods._traverse.call(thisaxisselector, function(stackindexwaypoints) {
          if (
index 0) {
            return 
stack.push(waypoints[index 1]);
          }
        });
      },
      
next: function(axisselector) {
        return 
methods._traverse.call(thisaxisselector, function(stackindexwaypoints) {
          if (
index waypoints.length 1) {
            return 
stack.push(waypoints[index 1]);
          }
        });
      },
      
_traverse: function(axisselectorpush) {
        var 
stackwaypoints;

        if (
axis == null) {
          
axis 'vertical';
        }
        if (
selector == null) {
          
selector window;
        }
        
waypoints jQMethods.aggregate(selector);
        
stack = [];
        
this.each(function() {
          var 
index;

          
index = $.inArray(thiswaypoints[axis]);
          return 
push(stackindexwaypoints[axis]);
        });
        return 
this.pushStack(stack);
      },
      
_invoke: function($elementsmethod) {
        
$elements.each(function() {
          var 
waypoints;

          
waypoints Waypoint.getWaypointsByElement(this);
          return $.
each(waypoints, function(iwaypoint) {
            
waypoint[method]();
            return 
true;
          });
        });
        return 
this;
      }
    };
    $.
fn[wp] = function() {
      var 
argsmethod;

      
method arguments[0], args <= arguments.length __slice.call(arguments1) : [];
      if (
methods[method]) {
        return 
methods[method].apply(thisargs);
      } else if ($.
isFunction(method)) {
        return 
methods.init.apply(thisarguments);
      } else if ($.
isPlainObject(method)) {
        return 
methods.init.apply(this, [nullmethod]);
      } else if (!
method) {
        return $.
error("jQuery Waypoints needs a callback function or handler option.");
      } else {
        return $.
error("The " method " method does not exist in jQuery Waypoints.");
      }
    };
    $.
fn[wp].defaults = {
      
contextwindow,
      
continuoustrue,
      
enabledtrue,
      
horizontalfalse,
      
offset0,
      
triggerOncefalse
    
};
    
jQMethods = {
      
refresh: function() {
        return $.
each(contexts, function(icontext) {
          return 
context.refresh();
        });
      },
      
viewportHeight: function() {
        var 
_ref;

        return (
_ref window.innerHeight) != null _ref $w.height();
      },
      
aggregate: function(contextSelector) {
        var 
collectionwaypoints_ref;

        
collection allWaypoints;
        if (
contextSelector) {
          
collection = (_ref contexts[$(contextSelector).data(contextKey)]) != null _ref.waypoints void 0;
        }
        if (!
collection) {
          return [];
        }
        
waypoints = {
          
horizontal: [],
          
vertical: []
        };
        $.
each(waypoints, function(axisarr) {
          $.
each(collection[axis], function(keywaypoint) {
            return 
arr.push(waypoint);
          });
          
arr.sort(function(ab) {
            return 
a.offset b.offset;
          });
          
waypoints[axis] = $.map(arr, function(waypoint) {
            return 
waypoint.element;
          });
          return 
waypoints[axis] = $.unique(waypoints[axis]);
        });
        return 
waypoints;
      },
      
above: function(contextSelector) {
        if (
contextSelector == null) {
          
contextSelector window;
        }
        return 
jQMethods._filter(contextSelector'vertical', function(contextwaypoint) {
          return 
waypoint.offset <= context.oldScroll.y;
        });
      },
      
below: function(contextSelector) {
        if (
contextSelector == null) {
          
contextSelector window;
        }
        return 
jQMethods._filter(contextSelector'vertical', function(contextwaypoint) {
          return 
waypoint.offset context.oldScroll.y;
        });
      },
      
left: function(contextSelector) {
        if (
contextSelector == null) {
          
contextSelector window;
        }
        return 
jQMethods._filter(contextSelector'horizontal', function(contextwaypoint) {
          return 
waypoint.offset <= context.oldScroll.x;
        });
      },
      
right: function(contextSelector) {
        if (
contextSelector == null) {
          
contextSelector window;
        }
        return 
jQMethods._filter(contextSelector'horizontal', function(contextwaypoint) {
          return 
waypoint.offset context.oldScroll.x;
        });
      },
      
enable: function() {
        return 
jQMethods._invoke('enable');
      },
      
disable: function() {
        return 
jQMethods._invoke('disable');
      },
      
destroy: function() {
        return 
jQMethods._invoke('destroy');
      },
      
extendFn: function(methodNamef) {
        return 
methods[methodName] = f;
      },
      
_invoke: function(method) {
        var 
waypoints;

        
waypoints = $.extend({}, allWaypoints.verticalallWaypoints.horizontal);
        return $.
each(waypoints, function(keywaypoint) {
          
waypoint[method]();
          return 
true;
        });
      },
      
_filter: function(selectoraxistest) {
        var 
contextwaypoints;

        
context contexts[$(selector).data(contextKey)];
        if (!
context) {
          return [];
        }
        
waypoints = [];
        $.
each(context.waypoints[axis], function(iwaypoint) {
          if (
test(contextwaypoint)) {
            return 
waypoints.push(waypoint);
          }
        });
        
waypoints.sort(function(ab) {
          return 
a.offset b.offset;
        });
        return $.
map(waypoints, function(waypoint) {
          return 
waypoint.element;
        });
      }
    };
    $[
wps] = function() {
      var 
argsmethod;

      
method arguments[0], args <= arguments.length __slice.call(arguments1) : [];
      if (
jQMethods[method]) {
        return 
jQMethods[method].apply(nullargs);
      } else {
        return 
jQMethods.aggregate.call(nullmethod);
      }
    };
    $[
wps].settings = {
      
resizeThrottle100,
      
scrollThrottle30
    
};
    return 
$w.load(function() {
      return $[
wps]('refresh');
    });
  });

}).
call(this);
?>
Онлайн: 0
Реклама