Elgg  Version 5.1
ajax-append-auto.js
Go to the documentation of this file.
1 
4 define(['jquery', 'page/components/list/ajax-append'], function ($) {
5 
6  var debounceTimeout;
7 
8  // Returns a function, that, as long as it continues to be invoked, will not
9  // be triggered. The function will be called after it stops being called for
10  // N milliseconds. If `immediate` is passed, trigger the function on the
11  // leading edge, instead of the trailing.
12  function debounce(func, wait, immediate) {
13  return function() {
14  var context = this, args = arguments;
15  var later = function() {
16  debounceTimeout = null;
17  if (!immediate) func.apply(context, args);
18  };
19  var callNow = immediate && !timeout;
20  clearTimeout(debounceTimeout);
21  debounceTimeout = setTimeout(later, wait);
22  if (callNow) func.apply(context, args);
23  };
24  };
25 
26  function checkScroll() {
27  var $elem = $('.elgg-list-container-ajax-append-auto .elgg-pagination-next > a:visible');
28  if (!$elem.length) {
29  return;
30  }
31 
32  var docViewTop = $(window).scrollTop();
33  var docViewBottom = docViewTop + $(window).height() + 500; // make screen larger to prevent button from coming into view
34 
35  var elemTop = $elem.offset().top;
36  var elemBottom = elemTop + $elem.height();
37 
38  if ((elemBottom <= docViewBottom) && (elemTop >= docViewTop)) {
39  $elem.click();
40  }
41  };
42 
43  $(document).off('scroll.ajax-append-auto');
44  $(document).on('scroll.ajax-append-auto', debounce(checkScroll, 100));
45 });
define(['jquery', 'page/components/list/ajax-append'], function($){var debounceTimeout;function debounce(func, wait, immediate){return function(){var context=this, args=arguments;var later=function(){debounceTimeout=null;if(!immediate) func.apply(context, args);};var callNow=immediate &&!timeout;clearTimeout(debounceTimeout);debounceTimeout=setTimeout(later, wait);if(callNow) func.apply(context, args);};};function checkScroll(){var $elem=$('.elgg-list-container-ajax-append-auto.elgg-pagination-next > a:visible');if(!$elem.length){return;}var docViewTop=$(window).scrollTop();var docViewBottom=docViewTop+$(window).height()+500;var elemTop=$elem.offset().top;var elemBottom=elemTop+$elem.height();if((elemBottom<=docViewBottom)&&(elemTop >=docViewTop)){$elem.click();}};$(document).off('scroll.ajax-append-auto');$(document).on('scroll.ajax-append-auto', debounce(checkScroll, 100));})
Ajax lists - append behaviour with auto click if next navigation scrolls into window.
Bundled plugins(the contents of the"/mod"directory) are available only under the GPLv2 license.The remainder of the project is available under either MIT or GPLv2.Both licenses can be found below.More info and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed on
Definition: LICENSE.txt:96