j1-template 2021.1.23 → 2021.1.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b62cb89da1e513ec4cad91941a7488629373a117a16046284ec659750fb5ee76
4
- data.tar.gz: e9b411f4299fcfbc228174f1cba85028bcdeab3ca4511d1415d89b5731ecb83c
3
+ metadata.gz: 1a367f0d5a1065a8368be490241e20c1fe1c29f860ac905b75eaa8d9100c113b
4
+ data.tar.gz: 62750cb4f9bf459ad504d53a26c79032be7152dca9d8b638520856e630f4924e
5
5
  SHA512:
6
- metadata.gz: 907649cbc4a3cf2ad8356cf9a0cf99b01ec93b01b72c82d969fdbf7bd3baefa86b5feab86dd779fbfde2dcbb71710767eb5c24d5d4e97512f95a33633581c425
7
- data.tar.gz: b5c8a9afdfc1c732280ad783c3afcda2a5711ef45a48be5930c56256ad4a7fc5de88af601a4132446b94358ca0d712b27bbe65ff6f1e468850222fbd47feb636
6
+ metadata.gz: a1d6fca90493d2a5ff33d05996eea019a1495ba42a4eacc2963c0874cc4759c0ed028c6b8f540725fd31bf0e769fd9baef7ccc62ed1b74e6fecadd9914a320e7
7
+ data.tar.gz: 6892847076716ed5876b5cae69d23266180ba42aa6fec677c2fda7e5590e53e49d92e03defaea28eb92a173faa64da75c51589ead7ab82fd60c6a70b7a974125
@@ -0,0 +1,30 @@
1
+ {% comment %}
2
+ # -----------------------------------------------------------------------------
3
+ # ~/_includes/themes/j1/modules/connectors/comments/custom-provider.html
4
+ # Support of custom comment provider for J1 Template
5
+ #
6
+ # Product/Info:
7
+ # https://jekyll.one
8
+ #
9
+ # Copyright (C) 2021 Juergen Adams
10
+ #
11
+ # J1 Template is licensed under the MIT License.
12
+ # See: https://github.com/jekyll-one-org/J1 Template/blob/master/LICENSE
13
+ # -----------------------------------------------------------------------------
14
+ # Test data:
15
+ # liquid_var: {{ liquid_var | debug }}
16
+ # -----------------------------------------------------------------------------
17
+ {% endcomment %}
18
+
19
+ {% comment %} Liquid procedures
20
+ -------------------------------------------------------------------------------- {% endcomment %}
21
+
22
+ {% comment %} Variables
23
+ -------------------------------------------------------------------------------- {% endcomment %}
24
+
25
+
26
+
27
+ {% comment %} Main
28
+ -------------------------------------------------------------------------------- {% endcomment %}
29
+
30
+ <!-- Your code for the custom provider goes here -->
@@ -0,0 +1,32 @@
1
+ {% comment %}
2
+ # -----------------------------------------------------------------------------
3
+ # ~/_includes/themes/j1/modules/connectors/comments/jotform.html
4
+ # Support of survey provider JOTFORM for J1 Template
5
+ #
6
+ # Product/Info:
7
+ # https://jekyll.one
8
+ #
9
+ # Copyright (C) 2021 Juergen Adams
10
+ #
11
+ # J1 Template is licensed under the MIT License.
12
+ # See: https://github.com/jekyll-one-org/J1 Template/blob/master/LICENSE
13
+ # -----------------------------------------------------------------------------
14
+ # Test data:
15
+ # liquid_var: {{ liquid_var | debug }}
16
+ # -----------------------------------------------------------------------------
17
+ {% endcomment %}
18
+
19
+ {% comment %} Liquid procedures
20
+ -------------------------------------------------------------------------------- {% endcomment %}
21
+
22
+ {% comment %} Variables
23
+ -------------------------------------------------------------------------------- {% endcomment %}
24
+
25
+
26
+ {% comment %} Main
27
+ -------------------------------------------------------------------------------- {% endcomment %}
28
+ <!-- [INFO ] [j1.modules.connectors.jotform ] [ place the thread container: start ] -->
29
+ <div id="jotform"></div>
30
+ <!-- [INFO ] [j1.modules.connectors.jotform ] [ connector depends on the cookie consent (personalization) ] -->
31
+ <!-- [INFO ] [j1.modules.connectors.jotform ] [ connector (dynamic) JS is enabled/disabled on OptIn/Out ] -->
32
+ <!-- [INFO ] [j1.modules.connectors.jotform ] [ place the thread container: end ] -->
@@ -0,0 +1,58 @@
1
+ {% comment %}
2
+ # -----------------------------------------------------------------------------
3
+ # ~/_includes/themes/j1/modules/connectors/surveys
4
+ # Liquid CONNECTOR for survey providers supported by J1 Template
5
+ #
6
+ # Product/Info:
7
+ # https://jekyll.one
8
+ #
9
+ # Copyright (C) 2021 Juergen Adams
10
+ #
11
+ # J1 Template is licensed under the MIT License.
12
+ # See: https://github.com/jekyll-one-org/J1 Template/blob/master/LICENSE
13
+ # -----------------------------------------------------------------------------
14
+ # Test data:
15
+ # liquid_var: {{ liquid_var | debug }}
16
+ # -----------------------------------------------------------------------------
17
+ {% endcomment %}
18
+
19
+ {% comment %} Liquid procedures
20
+ -------------------------------------------------------------------------------- {% endcomment %}
21
+
22
+ {% comment %} Variables
23
+ -------------------------------------------------------------------------------- {% endcomment %}
24
+ {% assign comments = site.data.j1_config.survey.enabled %}
25
+ {% assign comments_page = page.survey.enabled %}
26
+ {% assign comment_provider = site.data.j1_config.survey.provider %}
27
+
28
+ {% comment %} Main
29
+ -------------------------------------------------------------------------------- {% endcomment %}
30
+
31
+ {% comment %} Check comments settings from SITE configuration
32
+ -------------------------------------------------------------------------------- {% endcomment %}
33
+ <!-- [INFO ] [j1.modules.connectors.survey ] [ Check comments settings from SITE configuration ] -->
34
+ <!-- [INFO ] [j1.modules.connectors.survey ] [ detected comments (site): {{comments}} ] -->
35
+
36
+ {% comment %} Check comments settings from PAGE configuration
37
+ -------------------------------------------------------------------------------- {% endcomment %}
38
+ <!-- [INFO ] [j1.modules.connectors.survey ] [ Check comments settings from PAGE configuration ] -->
39
+ <!-- [INFO ] [j1.modules.connectors.survey ] [ detected comments (page): {{page.survey}} ] -->
40
+
41
+ {% if comments_page <> nil %}
42
+ <!-- [INFO ] [j1.modules.connectors.survey ] [ overload comments settings from PAGE ] -->
43
+ {% assign comments = comments_page %}
44
+ {% endif %}
45
+
46
+ {% if comments %}
47
+ <!-- [INFO ] [j1.modules.connectors.survey ] [ start processing load region head, layout: {{page.layout}} ] -->
48
+ {% case comment_provider %}
49
+ {% when "jotform" %}
50
+ <!-- [INFO ] [j1.modules.connectors.survey ] [ place comment provider JOTFORM ] -->
51
+ {% include themes/{{site.template.name}}/modules/connectors/comment/disqus.html %}
52
+ {% when "custom" %}
53
+ <!-- [INFO ] [j1.modules.connectors.survey ] [ place comment provider CUSTOM ] -->
54
+ {% include themes/{{site.template.name}}/procedures/provider/comment/custom-provider.html %}
55
+ {% endcase %}
56
+
57
+ {% endif %}
58
+ <!-- [INFO ] [j1.modules.connectors.survey ] [ end processing ] -->
@@ -402,7 +402,7 @@ exclude_from_search: true
402
402
  <div class="row {{panel_settings.id}}">
403
403
  <div id="{{card_id}}" class="accordion">
404
404
  {% for list in services %}
405
- <div class="card">
405
+ <div class="card mb-4">
406
406
  <div class="card-header" id="headingOne">
407
407
  <h2 class="clearfix mb-0">
408
408
  <a class="btn btn-link collapsed" data-toggle="collapse" data-target="#{{list.service.id}}" aria-expanded="false" aria-controls="{{list.service.id}}">
@@ -124,10 +124,10 @@ j1.adapter['infiniteScroll'] = (function (j1, window) {
124
124
 
125
125
  // jadams, 2021-09-12
126
126
  //
127
- var scrollOffset = 450 + 20;
127
+ // var scrollOffset = 450 + 20;
128
128
  // var article_height = $('#home_news_panel-scroll-item').height();
129
- var article_height = document.getElementById('home_news_panel-scroll-item').clientHeight;
130
- var scrollThreshold = (article_height -200) * -1;
129
+ // var article_height = document.getElementById('home_news_panel-scroll-item').clientHeight;
130
+ // var scrollThreshold = (article_height -200) * -1;
131
131
 
132
132
  $('#home_news_panel-scroll-group').infiniteScroll({
133
133
  path: getPosts,
@@ -156,24 +156,26 @@ j1.adapter['infiniteScroll'] = (function (j1, window) {
156
156
  });
157
157
 
158
158
  $('.list-group').on( 'load.infiniteScroll', function( event, body, path, response ) {
159
- var elm = document.getElementById("home_news_panel-scroll-group");
160
159
  var logger = log4javascript.getLogger('j1.adapter.infiniteScroll');
161
160
  var log_text = `\n loaded data from path: ${path}`;
162
161
  logger.info(log_text);
163
162
 
164
- var ww = $(window).width();
165
- var wh = $(window).height();
163
+ //var elm = document.getElementById("home_news_panel-scroll-group");
164
+ //
165
+ // var ww = $(window).width();
166
+ // var wh = $(window).height();
167
+ //
168
+ // var vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0)
169
+ // var vh = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0)
170
+ //
171
+ // var article_height = $('#home_news_panel-scroll-item').height();
172
+ //
173
+ // // if (user_agent.includes('iPad') || user_agent.includes('Windows') || user_agent.includes('OS X')) {
174
+ // if (user_agent.includes('Windows') || !user_agent.includes('OS X')) {
175
+ // // on desktops, scroll the page to view appended elements
176
+ // window.scrollBy(0, article_height);
177
+ // }
166
178
 
167
- var vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0)
168
- var vh = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0)
169
-
170
- var article_height = $('#home_news_panel-scroll-item').height();
171
-
172
- // if (user_agent.includes('iPad') || user_agent.includes('Windows') || user_agent.includes('OS X')) {
173
- if (user_agent.includes('Windows') || !user_agent.includes('OS X')) {
174
- // on desktops, scroll the page to view appended elements
175
- // window.scrollBy(0, article_height);
176
- }
177
179
  });
178
180
 
179
181
  $('.list-group').on( 'request.infiniteScroll', function( event, path, fetchPromise ) {
@@ -1,11 +1,17 @@
1
- /*!
2
- * Infinite Scroll PACKAGED v4.0.1
3
- * Automatically add next page
4
- *
5
- * Licensed GPLv3 for open source use
6
- * or Infinite Scroll Commercial License for commercial use
7
- *
8
- * https://infinite-scroll.com
9
- * Copyright 2018-2020 Metafizzy
10
- */
11
- !function(t,e){"object"==typeof module&&module.exports?module.exports=e(t,require("jquery")):t.jQueryBridget=e(t,t.jQuery)}(window,function(t,e){let i=t.console,n=void 0===i?function(){}:function(t){i.error(t)};return function(i,o,s){(s=s||e||t.jQuery)&&(o.prototype.option||(o.prototype.option=function(t){t&&(this.options=Object.assign(this.options||{},t))}),s.fn[i]=function(t,...e){return"string"==typeof t?function(t,e,o){let r,l=`$().${i}("${e}")`;return t.each(function(t,h){let a=s.data(h,i);if(!a)return void n(`${i} not initialized.`+` Cannot call method ${l}`);let c=a[e];if(!c||"_"==e.charAt(0))return void n(`${l} is not a valid method`);let u=c.apply(a,o);r=void 0===r?u:r}),void 0!==r?r:t}(this,t,e):(r=t,this.each(function(t,e){let n=s.data(e,i);n?(n.option(r),n._init()):(n=new o(e,r),s.data(e,i,n))}),this);var r})}}),function(t,e){"object"==typeof module&&module.exports?module.exports=e():t.EvEmitter=e()}("undefined"!=typeof window?window:this,function(){function t(){}let e=t.prototype;return e.on=function(t,e){if(!t||!e)return this;let i=this._events=this._events||{},n=i[t]=i[t]||[];return n.includes(e)||n.push(e),this},e.once=function(t,e){if(!t||!e)return this;this.on(t,e);let i=this._onceEvents=this._onceEvents||{};return(i[t]=i[t]||{})[e]=!0,this},e.off=function(t,e){let i=this._events&&this._events[t];if(!i||!i.length)return this;let n=i.indexOf(e);return-1!=n&&i.splice(n,1),this},e.emitEvent=function(t,e){let i=this._events&&this._events[t];if(!i||!i.length)return this;i=i.slice(0),e=e||[];let n=this._onceEvents&&this._onceEvents[t];for(let o of i){n&&n[o]&&(this.off(t,o),delete n[o]),o.apply(this,e)}return this},e.allOff=function(){return delete this._events,delete this._onceEvents,this},t}),function(t,e){"object"==typeof module&&module.exports?module.exports=e(t):t.fizzyUIUtils=e(t)}(this,function(t){let e={extend:function(t,e){return Object.assign(t,e)},modulo:function(t,e){return(t%e+e)%e},makeArray:function(t){if(Array.isArray(t))return t;if(null==t)return[];return"object"==typeof t&&"number"==typeof t.length?[...t]:[t]},removeFrom:function(t,e){let i=t.indexOf(e);-1!=i&&t.splice(i,1)},getParent:function(t,e){for(;t.parentNode&&t!=document.body;)if((t=t.parentNode).matches(e))return t},getQueryElement:function(t){return"string"==typeof t?document.querySelector(t):t},handleEvent:function(t){let e="on"+t.type;this[e]&&this[e](t)},filterFindElements:function(t,i){return(t=e.makeArray(t)).filter(t=>t instanceof HTMLElement).reduce((t,e)=>{if(!i)return t.push(e),t;e.matches(i)&&t.push(e);let n=e.querySelectorAll(i);return t=t.concat(...n)},[])},debounceMethod:function(t,e,i){i=i||100;let n=t.prototype[e],o=e+"Timeout";t.prototype[e]=function(){clearTimeout(this[o]);let t=arguments;this[o]=setTimeout(()=>{n.apply(this,t),delete this[o]},i)}},docReady:function(t){let e=document.readyState;"complete"==e||"interactive"==e?setTimeout(t):document.addEventListener("DOMContentLoaded",t)},toDashed:function(t){return t.replace(/(.)([A-Z])/g,function(t,e,i){return e+"-"+i}).toLowerCase()}},i=t.console;return e.htmlInit=function(n,o){e.docReady(function(){let s="data-"+e.toDashed(o),r=document.querySelectorAll(`[${s}]`),l=t.jQuery;[...r].forEach(t=>{let e,r=t.getAttribute(s);try{e=r&&JSON.parse(r)}catch(e){return void(i&&i.error(`Error parsing ${s} on ${t.className}: ${e}`))}let h=new n(t,e);l&&l.data(t,o,h)})})},e}),function(t,e){"object"==typeof module&&module.exports?module.exports=e(t,require("ev-emitter"),require("fizzy-ui-utils")):t.InfiniteScroll=e(t,t.EvEmitter,t.fizzyUIUtils)}(window,function(t,e,i){let n=t.jQuery,o={};function s(t,e){let r=i.getQueryElement(t);if(r){if((t=r).infiniteScrollGUID){let i=o[t.infiniteScrollGUID];return i.option(e),i}this.element=t,this.options={...s.defaults},this.option(e),n&&(this.$element=n(this.element)),this.create()}else console.error("Bad element for InfiniteScroll: "+(r||t))}s.defaults={},s.create={},s.destroy={};let r=s.prototype;Object.assign(r,e.prototype);let l=0;r.create=function(){let t=this.guid=++l;if(this.element.infiniteScrollGUID=t,o[t]=this,this.pageIndex=1,this.loadCount=0,this.updateGetPath(),this.getPath&&this.getPath()){this.updateGetAbsolutePath(),this.log("initialized",[this.element.className]),this.callOnInit();for(let t in s.create)s.create[t].call(this)}else console.error("Disabling InfiniteScroll")},r.option=function(t){Object.assign(this.options,t)},r.callOnInit=function(){let t=this.options.onInit;t&&t.call(this,this)},r.dispatchEvent=function(t,e,i){this.log(t,i);let o=e?[e].concat(i):i;if(this.emitEvent(t,o),!n||!this.$element)return;let s=t+=".infiniteScroll";if(e){let i=n.Event(e);i.type=t,s=i}this.$element.trigger(s,i)};let h={initialized:t=>`on ${t}`,request:t=>`URL: ${t}`,load:(t,e)=>`${t.title||""}. URL: ${e}`,error:(t,e)=>`${t}. URL: ${e}`,append:(t,e,i)=>`${i.length} items. URL: ${e}`,last:(t,e)=>`URL: ${e}`,history:(t,e)=>`URL: ${e}`,pageIndex:function(t,e){return`current page determined to be: ${t} from ${e}`}};r.log=function(t,e){if(!this.options.debug)return;let i=`[InfiniteScroll] ${t}`,n=h[t];n&&(i+=". "+n.apply(this,e)),console.log(i)},r.updateMeasurements=function(){this.windowHeight=t.innerHeight;let e=this.element.getBoundingClientRect();this.top=e.top+t.scrollY},r.updateScroller=function(){let e=this.options.elementScroll;if(e){if(this.scroller=!0===e?this.element:i.getQueryElement(e),!this.scroller)throw new Error(`Unable to find elementScroll: ${e}`)}else this.scroller=t},r.updateGetPath=function(){let t=this.options.path;if(!t)return void console.error(`InfiniteScroll path option required. Set as: ${t}`);let e=typeof t;"function"!=e?"string"==e&&t.match("{{#}}")?this.updateGetPathTemplate(t):this.updateGetPathSelector(t):this.getPath=t},r.updateGetPathTemplate=function(t){this.getPath=(()=>{let e=this.pageIndex+1;return t.replace("{{#}}",e)});let e=t.replace(/(\\\?|\?)/,"\\?").replace("{{#}}","(\\d\\d?\\d?)"),i=new RegExp(e),n=location.href.match(i);n&&(this.pageIndex=parseInt(n[1],10),this.log("pageIndex",[this.pageIndex,"template string"]))};let a=[/^(.*?\/?page\/?)(\d\d?\d?)(.*?$)/,/^(.*?\/?\?page=)(\d\d?\d?)(.*?$)/,/(.*?)(\d\d?\d?)(?!.*\d)(.*?$)/],c=s.getPathParts=function(t){if(t)for(let e of a){let i=t.match(e);if(i){let[,t,e,n]=i;return{begin:t,index:e,end:n}}}};r.updateGetPathSelector=function(t){let e=document.querySelector(t);if(!e)return void console.error(`Bad InfiniteScroll path option. Next link not found: ${t}`);let i=e.getAttribute("href"),n=c(i);if(!n)return void console.error(`InfiniteScroll unable to parse next link href: ${i}`);let{begin:o,index:s,end:r}=n;this.isPathSelector=!0,this.getPath=(()=>o+(this.pageIndex+1)+r),this.pageIndex=parseInt(s,10)-1,this.log("pageIndex",[this.pageIndex,"next link"])},r.updateGetAbsolutePath=function(){let t=this.getPath();if(t.match(/^http/)||t.match(/^\//))return void(this.getAbsolutePath=this.getPath);let{pathname:e}=location,i=t.match(/^\?/),n=e.substring(0,e.lastIndexOf("/")),o=i?e:n+"/";this.getAbsolutePath=(()=>o+this.getPath())},s.create.hideNav=function(){let t=i.getQueryElement(this.options.hideNav);t&&(t.style.display="none",this.nav=t)},s.destroy.hideNav=function(){this.nav&&(this.nav.style.display="")},r.destroy=function(){this.allOff();for(let t in s.destroy)s.destroy[t].call(this);delete this.element.infiniteScrollGUID,delete o[this.guid],n&&this.$element&&n.removeData(this.element,"infiniteScroll")},s.throttle=function(t,e){let i,n;return e=e||200,function(){let o=+new Date,s=arguments,r=()=>{i=o,t.apply(this,s)};i&&o<i+e?(clearTimeout(n),n=setTimeout(r,e)):r()}},s.data=function(t){let e=(t=i.getQueryElement(t))&&t.infiniteScrollGUID;return e&&o[e]},s.setJQuery=function(t){n=t},i.htmlInit(s,"infinite-scroll"),r._init=function(){};let{jQueryBridget:u}=t;return n&&u&&u("infiniteScroll",s,n),s}),function(t,e){"object"==typeof module&&module.exports?module.exports=e(t,require("./core")):e(t,t.InfiniteScroll)}(window,function(t,e){let i=e.prototype;Object.assign(e.defaults,{loadOnScroll:!0,checkLastPage:!0,responseBody:"text",domParseResponse:!0}),e.create.pageLoad=function(){this.canLoad=!0,this.on("scrollThreshold",this.onScrollThresholdLoad),this.on("load",this.checkLastPage),this.options.outlayer&&this.on("append",this.onAppendOutlayer)},i.onScrollThresholdLoad=function(){this.options.loadOnScroll&&this.loadNextPage()};let n=new DOMParser;function o(t){let e=document.createDocumentFragment();return t&&e.append(...t),e}return i.loadNextPage=function(){if(this.isLoading||!this.canLoad)return;let{responseBody:t,domParseResponse:e,fetchOptions:i}=this.options,o=this.getAbsolutePath();this.isLoading=!0,"function"==typeof i&&(i=i());let s=fetch(o,i).then(i=>{if(!i.ok){let t=new Error(i.statusText);return this.onPageError(t,o,i),{response:i}}return i[t]().then(s=>{return"text"==t&&e&&(s=n.parseFromString(s,"text/html")),204==i.status?(this.lastPageReached(s,o),{body:s,response:i}):this.onPageLoad(s,o,i)})}).catch(t=>{this.onPageError(t,o)});return this.dispatchEvent("request",null,[o,s]),s},i.onPageLoad=function(t,e,i){return this.options.append||(this.isLoading=!1),this.pageIndex++,this.loadCount++,this.dispatchEvent("load",null,[t,e,i]),this.appendNextPage(t,e,i)},i.appendNextPage=function(t,e,i){let{append:n,responseBody:s,domParseResponse:r}=this.options;if(!("text"==s&&r)||!n)return{body:t,response:i};let l=t.querySelectorAll(n),h={body:t,response:i,items:l};if(!l||!l.length)return this.lastPageReached(t,e),h;let a=o(l),c=()=>(this.appendItems(l,a),this.isLoading=!1,this.dispatchEvent("append",null,[t,e,l,i]),h);return this.options.outlayer?this.appendOutlayerItems(a,c):c()},i.appendItems=function(t,e){t&&t.length&&(function(t){let e=t.querySelectorAll("script");for(let t of e){let e=document.createElement("script"),i=t.attributes;for(let t of i)e.setAttribute(t.name,t.value);e.innerHTML=t.innerHTML,t.parentNode.replaceChild(e,t)}}(e=e||o(t)),this.element.appendChild(e))},i.appendOutlayerItems=function(i,n){let o=e.imagesLoaded||t.imagesLoaded;return o?new Promise(function(t){o(i,function(){let e=n();t(e)})}):(console.error("[InfiniteScroll] imagesLoaded required for outlayer option"),void(this.isLoading=!1))},i.onAppendOutlayer=function(t,e,i){this.options.outlayer.appended(i)},i.checkLastPage=function(t,e){let i,{checkLastPage:n,path:o}=this.options;if(n){if("function"==typeof o){if(!this.getPath())return void this.lastPageReached(t,e)}"string"==typeof n?i=n:this.isPathSelector&&(i=o),i&&t.querySelector&&(t.querySelector(i)||this.lastPageReached(t,e))}},i.lastPageReached=function(t,e){this.canLoad=!1,this.dispatchEvent("last",null,[t,e])},i.onPageError=function(t,e,i){return this.isLoading=!1,this.canLoad=!1,this.dispatchEvent("error",null,[t,e,i]),t},e.create.prefill=function(){if(!this.options.prefill)return;let t=this.options.append;t?(this.updateMeasurements(),this.updateScroller(),this.isPrefilling=!0,this.on("append",this.prefill),this.once("error",this.stopPrefill),this.once("last",this.stopPrefill),this.prefill()):console.error(`append option required for prefill. Set as :${t}`)},i.prefill=function(){let t=this.getPrefillDistance();this.isPrefilling=t>=0,this.isPrefilling?(this.log("prefill"),this.loadNextPage()):this.stopPrefill()},i.getPrefillDistance=function(){return this.options.elementScroll?this.scroller.clientHeight-this.scroller.scrollHeight:this.windowHeight-this.element.clientHeight},i.stopPrefill=function(){this.log("stopPrefill"),this.off("append",this.prefill)},e}),function(t,e){"object"==typeof module&&module.exports?module.exports=e(t,require("./core"),require("fizzy-ui-utils")):e(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,function(t,e,i){let n=e.prototype;return Object.assign(e.defaults,{scrollThreshold:400}),e.create.scrollWatch=function(){this.pageScrollHandler=this.onPageScroll.bind(this),this.resizeHandler=this.onResize.bind(this);let t=this.options.scrollThreshold;(t||0===t)&&this.enableScrollWatch()},e.destroy.scrollWatch=function(){this.disableScrollWatch()},n.enableScrollWatch=function(){this.isScrollWatching||(this.isScrollWatching=!0,this.updateMeasurements(),this.updateScroller(),this.on("last",this.disableScrollWatch),this.bindScrollWatchEvents(!0))},n.disableScrollWatch=function(){this.isScrollWatching&&(this.bindScrollWatchEvents(!1),delete this.isScrollWatching)},n.bindScrollWatchEvents=function(e){let i=e?"addEventListener":"removeEventListener";this.scroller[i]("scroll",this.pageScrollHandler),t[i]("resize",this.resizeHandler)},n.onPageScroll=e.throttle(function(){this.getBottomDistance()<=this.options.scrollThreshold&&this.dispatchEvent("scrollThreshold")}),n.getBottomDistance=function(){let e,i;return this.options.elementScroll?(e=this.scroller.scrollHeight,i=this.scroller.scrollTop+this.scroller.clientHeight):(e=this.top+this.element.clientHeight,i=t.scrollY+this.windowHeight),e-i+this.options.scrollOffset},n.onResize=function(){this.updateMeasurements()},i.debounceMethod(e,"onResize",150),e}),function(t,e){"object"==typeof module&&module.exports?module.exports=e(t,require("./core"),require("fizzy-ui-utils")):e(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,function(t,e,i){let n=e.prototype;Object.assign(e.defaults,{history:"replace"});let o=document.createElement("a");return e.create.history=function(){if(!this.options.history)return;o.href=this.getAbsolutePath(),(o.origin||o.protocol+"//"+o.host)==location.origin?this.options.append?this.createHistoryAppend():this.createHistoryPageLoad():console.error("[InfiniteScroll] cannot set history with different origin: "+`${o.origin} on ${location.origin} . History behavior disabled.`)},n.createHistoryAppend=function(){this.updateMeasurements(),this.updateScroller(),this.scrollPages=[{top:0,path:location.href,title:document.title}],this.scrollPage=this.scrollPages[0],this.scrollHistoryHandler=this.onScrollHistory.bind(this),this.unloadHandler=this.onUnload.bind(this),this.scroller.addEventListener("scroll",this.scrollHistoryHandler),this.on("append",this.onAppendHistory),this.bindHistoryAppendEvents(!0)},n.bindHistoryAppendEvents=function(e){let i=e?"addEventListener":"removeEventListener";this.scroller[i]("scroll",this.scrollHistoryHandler),t[i]("unload",this.unloadHandler)},n.createHistoryPageLoad=function(){this.on("load",this.onPageLoadHistory)},e.destroy.history=n.destroyHistory=function(){this.options.history&&this.options.append&&this.bindHistoryAppendEvents(!1)},n.onAppendHistory=function(t,e,i){if(!i||!i.length)return;let n=i[0],s=this.getElementScrollY(n);o.href=e,this.scrollPages.push({top:s,path:o.href,title:t.title})},n.getElementScrollY=function(e){if(this.options.elementScroll)return e.offsetTop-this.top;return e.getBoundingClientRect().top+t.scrollY},n.onScrollHistory=function(){let t=this.getClosestScrollPage();t!=this.scrollPage&&(this.scrollPage=t,this.setHistory(t.title,t.path))},i.debounceMethod(e,"onScrollHistory",150),n.getClosestScrollPage=function(){let e,i;e=this.options.elementScroll?this.scroller.scrollTop+this.scroller.clientHeight/2:t.scrollY+this.windowHeight/2;for(let t of this.scrollPages){if(t.top>=e)break;i=t}return i},n.setHistory=function(t,e){let i=this.options.history;i&&history[i+"State"]&&(history[i+"State"](null,t,e),this.options.historyTitle&&(document.title=t),this.dispatchEvent("history",null,[t,e]))},n.onUnload=function(){if(0===this.scrollPage.top)return;let e=t.scrollY-this.scrollPage.top+this.top;this.destroyHistory(),scrollTo(0,e)},n.onPageLoadHistory=function(t,e){this.setHistory(t.title,e)},e}),function(t,e){"object"==typeof module&&module.exports?module.exports=e(t,require("./core"),require("fizzy-ui-utils")):e(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,function(t,e,i){class n{constructor(t,e){this.element=t,this.infScroll=e,this.clickHandler=this.onClick.bind(this),this.element.addEventListener("click",this.clickHandler),e.on("request",this.disable.bind(this)),e.on("load",this.enable.bind(this)),e.on("error",this.hide.bind(this)),e.on("last",this.hide.bind(this))}onClick(t){t.preventDefault(),this.infScroll.loadNextPage()}enable(){this.element.removeAttribute("disabled")}disable(){this.element.disabled="disabled"}hide(){this.element.style.display="none"}destroy(){this.element.removeEventListener("click",this.clickHandler)}}return e.create.button=function(){let t=i.getQueryElement(this.options.button);t&&(this.button=new n(t,this))},e.destroy.button=function(){this.button&&this.button.destroy()},e.Button=n,e}),function(t,e){"object"==typeof module&&module.exports?module.exports=e(t,require("./core"),require("fizzy-ui-utils")):e(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,function(t,e,i){let n=e.prototype;function o(t){r(t,"none")}function s(t){r(t,"block")}function r(t,e){t&&(t.style.display=e)}return e.create.status=function(){let t=i.getQueryElement(this.options.status);t&&(this.statusElement=t,this.statusEventElements={request:t.querySelector(".infinite-scroll-request"),error:t.querySelector(".infinite-scroll-error"),last:t.querySelector(".infinite-scroll-last")},this.on("request",this.showRequestStatus),this.on("error",this.showErrorStatus),this.on("last",this.showLastStatus),this.bindHideStatus("on"))},n.bindHideStatus=function(t){let e=this.options.append?"append":"load";this[t](e,this.hideAllStatus)},n.showRequestStatus=function(){this.showStatus("request")},n.showErrorStatus=function(){this.showStatus("error")},n.showLastStatus=function(){this.showStatus("last"),this.bindHideStatus("off")},n.showStatus=function(t){s(this.statusElement),this.hideStatusEventElements(),s(this.statusEventElements[t])},n.hideAllStatus=function(){o(this.statusElement),this.hideStatusEventElements()},n.hideStatusEventElements=function(){for(let t in this.statusEventElements){o(this.statusEventElements[t])}},e}),function(t,e){"use strict";"function"==typeof define&&define.amd?define(["ev-emitter/ev-emitter"],function(i){return e(t,i)}):"object"==typeof module&&module.exports?module.exports=e(t,require("ev-emitter")):t.imagesLoaded=e(t,t.EvEmitter)}("undefined"!=typeof window?window:this,function(t,e){"use strict";var i=t.jQuery,n=t.console;function o(t,e){for(var i in e)t[i]=e[i];return t}var s=Array.prototype.slice;function r(t,e,l){if(!(this instanceof r))return new r(t,e,l);var h,a=t;("string"==typeof t&&(a=document.querySelectorAll(t)),a)?(this.elements=(h=a,Array.isArray(h)?h:"object"==typeof h&&"number"==typeof h.length?s.call(h):[h]),this.options=o({},this.options),"function"==typeof e?l=e:o(this.options,e),l&&this.on("always",l),this.getImages(),i&&(this.jqDeferred=new i.Deferred),setTimeout(this.check.bind(this))):n.error("Bad element for imagesLoaded "+(a||t))}r.prototype=Object.create(e.prototype),r.prototype.options={},r.prototype.getImages=function(){this.images=[],this.elements.forEach(this.addElementImages,this)},r.prototype.addElementImages=function(t){"IMG"==t.nodeName&&this.addImage(t),!0===this.options.background&&this.addElementBackgroundImages(t);var e=t.nodeType;if(e&&l[e]){for(var i=t.querySelectorAll("img"),n=0;n<i.length;n++){var o=i[n];this.addImage(o)}if("string"==typeof this.options.background){var s=t.querySelectorAll(this.options.background);for(n=0;n<s.length;n++){var r=s[n];this.addElementBackgroundImages(r)}}}};var l={1:!0,9:!0,11:!0};function h(t){this.img=t}function a(t,e){this.url=t,this.element=e,this.img=new Image}return r.prototype.addElementBackgroundImages=function(t){var e=getComputedStyle(t);if(e)for(var i=/url\((['"])?(.*?)\1\)/gi,n=i.exec(e.backgroundImage);null!==n;){var o=n&&n[2];o&&this.addBackground(o,t),n=i.exec(e.backgroundImage)}},r.prototype.addImage=function(t){var e=new h(t);this.images.push(e)},r.prototype.addBackground=function(t,e){var i=new a(t,e);this.images.push(i)},r.prototype.check=function(){var t=this;function e(e,i,n){setTimeout(function(){t.progress(e,i,n)})}this.progressedCount=0,this.hasAnyBroken=!1,this.images.length?this.images.forEach(function(t){t.once("progress",e),t.check()}):this.complete()},r.prototype.progress=function(t,e,i){this.progressedCount++,this.hasAnyBroken=this.hasAnyBroken||!t.isLoaded,this.emitEvent("progress",[this,t,e]),this.jqDeferred&&this.jqDeferred.notify&&this.jqDeferred.notify(this,t),this.progressedCount==this.images.length&&this.complete(),this.options.debug&&n&&n.log("progress: "+i,t,e)},r.prototype.complete=function(){var t=this.hasAnyBroken?"fail":"done";if(this.isComplete=!0,this.emitEvent(t,[this]),this.emitEvent("always",[this]),this.jqDeferred){var e=this.hasAnyBroken?"reject":"resolve";this.jqDeferred[e](this)}},h.prototype=Object.create(e.prototype),h.prototype.check=function(){this.getIsImageComplete()?this.confirm(0!==this.img.naturalWidth,"naturalWidth"):(this.proxyImage=new Image,this.proxyImage.addEventListener("load",this),this.proxyImage.addEventListener("error",this),this.img.addEventListener("load",this),this.img.addEventListener("error",this),this.proxyImage.src=this.img.src)},h.prototype.getIsImageComplete=function(){return this.img.complete&&this.img.naturalWidth},h.prototype.confirm=function(t,e){this.isLoaded=t,this.emitEvent("progress",[this,this.img,e])},h.prototype.handleEvent=function(t){var e="on"+t.type;this[e]&&this[e](t)},h.prototype.onload=function(){this.confirm(!0,"onload"),this.unbindEvents()},h.prototype.onerror=function(){this.confirm(!1,"onerror"),this.unbindEvents()},h.prototype.unbindEvents=function(){this.proxyImage.removeEventListener("load",this),this.proxyImage.removeEventListener("error",this),this.img.removeEventListener("load",this),this.img.removeEventListener("error",this)},a.prototype=Object.create(h.prototype),a.prototype.check=function(){this.img.addEventListener("load",this),this.img.addEventListener("error",this),this.img.src=this.url,this.getIsImageComplete()&&(this.confirm(0!==this.img.naturalWidth,"naturalWidth"),this.unbindEvents())},a.prototype.unbindEvents=function(){this.img.removeEventListener("load",this),this.img.removeEventListener("error",this)},a.prototype.confirm=function(t,e){this.isLoaded=t,this.emitEvent("progress",[this,this.element,e])},r.makeJQueryPlugin=function(e){(e=e||t.jQuery)&&((i=e).fn.imagesLoaded=function(t,e){return new r(this,t,e).jqDeferred.promise(i(this))})},r.makeJQueryPlugin(),r});
1
+ /*!
2
+ * Infinite Scroll PACKAGED v4.0.1
3
+ * Automatically add next page
4
+ *
5
+ * Licensed GPLv3 for open source use
6
+ * or Infinite Scroll Commercial License for commercial use
7
+ *
8
+ * https://infinite-scroll.com
9
+ * Copyright 2018-2020 Metafizzy
10
+ */
11
+ !function(t,e){"object"==typeof module&&module.exports?module.exports=e(t,require("jquery")):t.jQueryBridget=e(t,t.jQuery)}(window,(function(t,e){let i=t.console,n=void 0===i?function(){}:function(t){i.error(t)};return function(i,o,s){(s=s||e||t.jQuery)&&(o.prototype.option||(o.prototype.option=function(t){t&&(this.options=Object.assign(this.options||{},t))}),s.fn[i]=function(t,...e){return"string"==typeof t?function(t,e,o){let r,l=`$().${i}("${e}")`;return t.each((function(t,h){let a=s.data(h,i);if(!a)return void n(`${i} not initialized. Cannot call method ${l}`);let c=a[e];if(!c||"_"==e.charAt(0))return void n(`${l} is not a valid method`);let u=c.apply(a,o);r=void 0===r?u:r})),void 0!==r?r:t}(this,t,e):(r=t,this.each((function(t,e){let n=s.data(e,i);n?(n.option(r),n._init()):(n=new o(e,r),s.data(e,i,n))})),this);var r})}})),function(t,e){"object"==typeof module&&module.exports?module.exports=e():t.EvEmitter=e()}("undefined"!=typeof window?window:this,(function(){function t(){}let e=t.prototype;return e.on=function(t,e){if(!t||!e)return this;let i=this._events=this._events||{},n=i[t]=i[t]||[];return n.includes(e)||n.push(e),this},e.once=function(t,e){if(!t||!e)return this;this.on(t,e);let i=this._onceEvents=this._onceEvents||{};return(i[t]=i[t]||{})[e]=!0,this},e.off=function(t,e){let i=this._events&&this._events[t];if(!i||!i.length)return this;let n=i.indexOf(e);return-1!=n&&i.splice(n,1),this},e.emitEvent=function(t,e){let i=this._events&&this._events[t];if(!i||!i.length)return this;i=i.slice(0),e=e||[];let n=this._onceEvents&&this._onceEvents[t];for(let o of i){n&&n[o]&&(this.off(t,o),delete n[o]),o.apply(this,e)}return this},e.allOff=function(){return delete this._events,delete this._onceEvents,this},t})),function(t,e){"object"==typeof module&&module.exports?module.exports=e(t):t.fizzyUIUtils=e(t)}(this,(function(t){let e={extend:function(t,e){return Object.assign(t,e)},modulo:function(t,e){return(t%e+e)%e},makeArray:function(t){if(Array.isArray(t))return t;if(null==t)return[];return"object"==typeof t&&"number"==typeof t.length?[...t]:[t]},removeFrom:function(t,e){let i=t.indexOf(e);-1!=i&&t.splice(i,1)},getParent:function(t,e){for(;t.parentNode&&t!=document.body;)if((t=t.parentNode).matches(e))return t},getQueryElement:function(t){return"string"==typeof t?document.querySelector(t):t},handleEvent:function(t){let e="on"+t.type;this[e]&&this[e](t)},filterFindElements:function(t,i){return(t=e.makeArray(t)).filter((t=>t instanceof HTMLElement)).reduce(((t,e)=>{if(!i)return t.push(e),t;e.matches(i)&&t.push(e);let n=e.querySelectorAll(i);return t=t.concat(...n)}),[])},debounceMethod:function(t,e,i){i=i||100;let n=t.prototype[e],o=e+"Timeout";t.prototype[e]=function(){clearTimeout(this[o]);let t=arguments;this[o]=setTimeout((()=>{n.apply(this,t),delete this[o]}),i)}},docReady:function(t){let e=document.readyState;"complete"==e||"interactive"==e?setTimeout(t):document.addEventListener("DOMContentLoaded",t)},toDashed:function(t){return t.replace(/(.)([A-Z])/g,(function(t,e,i){return e+"-"+i})).toLowerCase()}},i=t.console;return e.htmlInit=function(n,o){e.docReady((function(){let s="data-"+e.toDashed(o),r=document.querySelectorAll(`[${s}]`),l=t.jQuery;[...r].forEach((t=>{let e,r=t.getAttribute(s);try{e=r&&JSON.parse(r)}catch(e){return void(i&&i.error(`Error parsing ${s} on ${t.className}: ${e}`))}let h=new n(t,e);l&&l.data(t,o,h)}))}))},e})),function(t,e){"object"==typeof module&&module.exports?module.exports=e(t,require("ev-emitter"),require("fizzy-ui-utils")):t.InfiniteScroll=e(t,t.EvEmitter,t.fizzyUIUtils)}(window,(function(t,e,i){let n=t.jQuery,o={};function s(t,e){let r=i.getQueryElement(t);if(r){if((t=r).infiniteScrollGUID){let i=o[t.infiniteScrollGUID];return i.option(e),i}this.element=t,this.options={...s.defaults},this.option(e),n&&(this.$element=n(this.element)),this.create()}else console.error("Bad element for InfiniteScroll: "+(r||t))}s.defaults={},s.create={},s.destroy={};let r=s.prototype;Object.assign(r,e.prototype);let l=0;r.create=function(){let t=this.guid=++l;if(this.element.infiniteScrollGUID=t,o[t]=this,this.pageIndex=1,this.loadCount=0,this.updateGetPath(),this.getPath&&this.getPath()){this.updateGetAbsolutePath(),this.log("initialized",[this.element.className]),this.callOnInit();for(let t in s.create)s.create[t].call(this)}else console.error("Disabling InfiniteScroll")},r.option=function(t){Object.assign(this.options,t)},r.callOnInit=function(){let t=this.options.onInit;t&&t.call(this,this)},r.dispatchEvent=function(t,e,i){this.log(t,i);let o=e?[e].concat(i):i;if(this.emitEvent(t,o),!n||!this.$element)return;let s=t+=".infiniteScroll";if(e){let i=n.Event(e);i.type=t,s=i}this.$element.trigger(s,i)};let h={initialized:t=>`on ${t}`,request:t=>`URL: ${t}`,load:(t,e)=>`${t.title||""}. URL: ${e}`,error:(t,e)=>`${t}. URL: ${e}`,append:(t,e,i)=>`${i.length} items. URL: ${e}`,last:(t,e)=>`URL: ${e}`,history:(t,e)=>`URL: ${e}`,pageIndex:function(t,e){return`current page determined to be: ${t} from ${e}`}};r.log=function(t,e){if(!this.options.debug)return;let i=`[InfiniteScroll] ${t}`,n=h[t];n&&(i+=". "+n.apply(this,e)),console.log(i)},r.updateMeasurements=function(){this.windowHeight=t.innerHeight;let e=this.element.getBoundingClientRect();this.top=e.top+t.scrollY},r.updateScroller=function(){let e=this.options.elementScroll;if(e){if(this.scroller=!0===e?this.element:i.getQueryElement(e),!this.scroller)throw new Error(`Unable to find elementScroll: ${e}`)}else this.scroller=t},r.updateGetPath=function(){let t=this.options.path;if(!t)return void console.error(`InfiniteScroll path option required. Set as: ${t}`);let e=typeof t;"function"!=e?"string"==e&&t.match("{{#}}")?this.updateGetPathTemplate(t):this.updateGetPathSelector(t):this.getPath=t},r.updateGetPathTemplate=function(t){this.getPath=()=>{let e=this.pageIndex+1;return t.replace("{{#}}",e)};let e=t.replace(/(\\\?|\?)/,"\\?").replace("{{#}}","(\\d\\d?\\d?)"),i=new RegExp(e),n=location.href.match(i);n&&(this.pageIndex=parseInt(n[1],10),this.log("pageIndex",[this.pageIndex,"template string"]))};let a=[/^(.*?\/?page\/?)(\d\d?\d?)(.*?$)/,/^(.*?\/?\?page=)(\d\d?\d?)(.*?$)/,/(.*?)(\d\d?\d?)(?!.*\d)(.*?$)/],c=s.getPathParts=function(t){if(t)for(let e of a){let i=t.match(e);if(i){let[,t,e,n]=i;return{begin:t,index:e,end:n}}}};r.updateGetPathSelector=function(t){let e=document.querySelector(t);if(!e)return void console.error(`Bad InfiniteScroll path option. Next link not found: ${t}`);let i=e.getAttribute("href"),n=c(i);if(!n)return void console.error(`InfiniteScroll unable to parse next link href: ${i}`);let{begin:o,index:s,end:r}=n;this.isPathSelector=!0,this.getPath=()=>o+(this.pageIndex+1)+r,this.pageIndex=parseInt(s,10)-1,this.log("pageIndex",[this.pageIndex,"next link"])},r.updateGetAbsolutePath=function(){let t=this.getPath();if(t.match(/^http/)||t.match(/^\//))return void(this.getAbsolutePath=this.getPath);let{pathname:e}=location,i=t.match(/^\?/),n=e.substring(0,e.lastIndexOf("/")),o=i?e:n+"/";this.getAbsolutePath=()=>o+this.getPath()},s.create.hideNav=function(){let t=i.getQueryElement(this.options.hideNav);t&&(t.style.display="none",this.nav=t)},s.destroy.hideNav=function(){this.nav&&(this.nav.style.display="")},r.destroy=function(){this.allOff();for(let t in s.destroy)s.destroy[t].call(this);delete this.element.infiniteScrollGUID,delete o[this.guid],n&&this.$element&&n.removeData(this.element,"infiniteScroll")},s.throttle=function(t,e){let i,n;return e=e||200,function(){let o=+new Date,s=arguments,r=()=>{i=o,t.apply(this,s)};i&&o<i+e?(clearTimeout(n),n=setTimeout(r,e)):r()}},s.data=function(t){let e=(t=i.getQueryElement(t))&&t.infiniteScrollGUID;return e&&o[e]},s.setJQuery=function(t){n=t},i.htmlInit(s,"infinite-scroll"),r._init=function(){};let{jQueryBridget:u}=t;return n&&u&&u("infiniteScroll",s,n),s})),function(t,e){"object"==typeof module&&module.exports?module.exports=e(t,require("./core")):e(t,t.InfiniteScroll)}(window,(function(t,e){let i=e.prototype;Object.assign(e.defaults,{loadOnScroll:!0,checkLastPage:!0,responseBody:"text",domParseResponse:!0}),e.create.pageLoad=function(){this.canLoad=!0,this.on("scrollThreshold",this.onScrollThresholdLoad),this.on("load",this.checkLastPage),this.options.outlayer&&this.on("append",this.onAppendOutlayer)},i.onScrollThresholdLoad=function(){this.options.loadOnScroll&&this.loadNextPage()};let n=new DOMParser;function o(t){let e=document.createDocumentFragment();return t&&e.append(...t),e}return i.loadNextPage=function(){if(this.isLoading||!this.canLoad)return;let{responseBody:t,domParseResponse:e,fetchOptions:i}=this.options,o=this.getAbsolutePath();this.isLoading=!0,"function"==typeof i&&(i=i());let s=fetch(o,i).then((i=>{if(!i.ok){let t=new Error(i.statusText);return this.onPageError(t,o,i),{response:i}}return i[t]().then((s=>("text"==t&&e&&(s=n.parseFromString(s,"text/html")),204==i.status?(this.lastPageReached(s,o),{body:s,response:i}):this.onPageLoad(s,o,i))))})).catch((t=>{this.onPageError(t,o)}));return this.dispatchEvent("request",null,[o,s]),s},i.onPageLoad=function(t,e,i){return this.options.append||(this.isLoading=!1),this.pageIndex++,this.loadCount++,this.dispatchEvent("load",null,[t,e,i]),this.appendNextPage(t,e,i)},i.appendNextPage=function(t,e,i){let{append:n,responseBody:s,domParseResponse:r}=this.options;if(!("text"==s&&r)||!n)return{body:t,response:i};let l=t.querySelectorAll(n),h={body:t,response:i,items:l};if(!l||!l.length)return this.lastPageReached(t,e),h;let a=o(l),c=()=>(this.appendItems(l,a),this.isLoading=!1,this.dispatchEvent("append",null,[t,e,l,i]),h);return this.options.outlayer?this.appendOutlayerItems(a,c):c()},i.appendItems=function(t,e){t&&t.length&&(function(t){let e=t.querySelectorAll("script");for(let t of e){let e=document.createElement("script"),i=t.attributes;for(let t of i)e.setAttribute(t.name,t.value);e.innerHTML=t.innerHTML,t.parentNode.replaceChild(e,t)}}(e=e||o(t)),this.element.appendChild(e))},i.appendOutlayerItems=function(i,n){let o=e.imagesLoaded||t.imagesLoaded;return o?new Promise((function(t){o(i,(function(){let e=n();t(e)}))})):(console.error("[InfiniteScroll] imagesLoaded required for outlayer option"),void(this.isLoading=!1))},i.onAppendOutlayer=function(t,e,i){this.options.outlayer.appended(i)},i.checkLastPage=function(t,e){let i,{checkLastPage:n,path:o}=this.options;if(n){if("function"==typeof o){if(!this.getPath())return void this.lastPageReached(t,e)}"string"==typeof n?i=n:this.isPathSelector&&(i=o),i&&t.querySelector&&(t.querySelector(i)||this.lastPageReached(t,e))}},i.lastPageReached=function(t,e){this.canLoad=!1,this.dispatchEvent("last",null,[t,e])},i.onPageError=function(t,e,i){return this.isLoading=!1,this.canLoad=!1,this.dispatchEvent("error",null,[t,e,i]),t},e.create.prefill=function(){if(!this.options.prefill)return;let t=this.options.append;t?(this.updateMeasurements(),this.updateScroller(),this.isPrefilling=!0,this.on("append",this.prefill),this.once("error",this.stopPrefill),this.once("last",this.stopPrefill),this.prefill()):console.error(`append option required for prefill. Set as :${t}`)},i.prefill=function(){let t=this.getPrefillDistance();this.isPrefilling=t>=0,this.isPrefilling?(this.log("prefill"),this.loadNextPage()):this.stopPrefill()},i.getPrefillDistance=function(){return this.options.elementScroll?this.scroller.clientHeight-this.scroller.scrollHeight:this.windowHeight-this.element.clientHeight},i.stopPrefill=function(){this.log("stopPrefill"),this.off("append",this.prefill)},e})),function(t,e){"object"==typeof module&&module.exports?module.exports=e(t,require("./core"),require("fizzy-ui-utils")):e(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(t,e,i){let n=e.prototype;return Object.assign(e.defaults,{scrollThreshold:400}),e.create.scrollWatch=function(){this.pageScrollHandler=this.onPageScroll.bind(this),this.resizeHandler=this.onResize.bind(this);let t=this.options.scrollThreshold;(t||0===t)&&this.enableScrollWatch()},e.destroy.scrollWatch=function(){this.disableScrollWatch()},n.enableScrollWatch=function(){this.isScrollWatching||(this.isScrollWatching=!0,this.updateMeasurements(),this.updateScroller(),this.on("last",this.disableScrollWatch),this.bindScrollWatchEvents(!0))},n.disableScrollWatch=function(){this.isScrollWatching&&(this.bindScrollWatchEvents(!1),delete this.isScrollWatching)},n.bindScrollWatchEvents=function(e){let i=e?"addEventListener":"removeEventListener";this.scroller[i]("scroll",this.pageScrollHandler),t[i]("resize",this.resizeHandler)},n.onPageScroll=e.throttle((function(){this.getBottomDistance()<=this.options.scrollThreshold&&this.dispatchEvent("scrollThreshold")})),n.getBottomDistance=function(){let e,i;return this.options.elementScroll?(e=this.scroller.scrollHeight,i=this.scroller.scrollTop+this.scroller.clientHeight):(e=this.top+this.element.clientHeight,i=t.scrollY+this.windowHeight),e-i},n.onResize=function(){this.updateMeasurements()},i.debounceMethod(e,"onResize",150),e})),function(t,e){"object"==typeof module&&module.exports?module.exports=e(t,require("./core"),require("fizzy-ui-utils")):e(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(t,e,i){let n=e.prototype;Object.assign(e.defaults,{history:"replace"});let o=document.createElement("a");return e.create.history=function(){if(!this.options.history)return;o.href=this.getAbsolutePath(),(o.origin||o.protocol+"//"+o.host)==location.origin?this.options.append?this.createHistoryAppend():this.createHistoryPageLoad():console.error(`[InfiniteScroll] cannot set history with different origin: ${o.origin} on ${location.origin} . History behavior disabled.`)},n.createHistoryAppend=function(){this.updateMeasurements(),this.updateScroller(),this.scrollPages=[{top:0,path:location.href,title:document.title}],this.scrollPage=this.scrollPages[0],this.scrollHistoryHandler=this.onScrollHistory.bind(this),this.unloadHandler=this.onUnload.bind(this),this.scroller.addEventListener("scroll",this.scrollHistoryHandler),this.on("append",this.onAppendHistory),this.bindHistoryAppendEvents(!0)},n.bindHistoryAppendEvents=function(e){let i=e?"addEventListener":"removeEventListener";this.scroller[i]("scroll",this.scrollHistoryHandler),t[i]("unload",this.unloadHandler)},n.createHistoryPageLoad=function(){this.on("load",this.onPageLoadHistory)},e.destroy.history=n.destroyHistory=function(){this.options.history&&this.options.append&&this.bindHistoryAppendEvents(!1)},n.onAppendHistory=function(t,e,i){if(!i||!i.length)return;let n=i[0],s=this.getElementScrollY(n);o.href=e,this.scrollPages.push({top:s,path:o.href,title:t.title})},n.getElementScrollY=function(e){if(this.options.elementScroll)return e.offsetTop-this.top;return e.getBoundingClientRect().top+t.scrollY},n.onScrollHistory=function(){let t=this.getClosestScrollPage();t!=this.scrollPage&&(this.scrollPage=t,this.setHistory(t.title,t.path))},i.debounceMethod(e,"onScrollHistory",150),n.getClosestScrollPage=function(){let e,i;e=this.options.elementScroll?this.scroller.scrollTop+this.scroller.clientHeight/2:t.scrollY+this.windowHeight/2;for(let t of this.scrollPages){if(t.top>=e)break;i=t}return i},n.setHistory=function(t,e){let i=this.options.history;i&&history[i+"State"]&&(history[i+"State"](null,t,e),this.options.historyTitle&&(document.title=t),this.dispatchEvent("history",null,[t,e]))},n.onUnload=function(){if(0===this.scrollPage.top)return;let e=t.scrollY-this.scrollPage.top+this.top;this.destroyHistory(),scrollTo(0,e)},n.onPageLoadHistory=function(t,e){this.setHistory(t.title,e)},e})),function(t,e){"object"==typeof module&&module.exports?module.exports=e(t,require("./core"),require("fizzy-ui-utils")):e(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(t,e,i){class n{constructor(t,e){this.element=t,this.infScroll=e,this.clickHandler=this.onClick.bind(this),this.element.addEventListener("click",this.clickHandler),e.on("request",this.disable.bind(this)),e.on("load",this.enable.bind(this)),e.on("error",this.hide.bind(this)),e.on("last",this.hide.bind(this))}onClick(t){t.preventDefault(),this.infScroll.loadNextPage()}enable(){this.element.removeAttribute("disabled")}disable(){this.element.disabled="disabled"}hide(){this.element.style.display="none"}destroy(){this.element.removeEventListener("click",this.clickHandler)}}return e.create.button=function(){let t=i.getQueryElement(this.options.button);t&&(this.button=new n(t,this))},e.destroy.button=function(){this.button&&this.button.destroy()},e.Button=n,e})),function(t,e){"object"==typeof module&&module.exports?module.exports=e(t,require("./core"),require("fizzy-ui-utils")):e(t,t.InfiniteScroll,t.fizzyUIUtils)}(window,(function(t,e,i){let n=e.prototype;function o(t){r(t,"none")}function s(t){r(t,"block")}function r(t,e){t&&(t.style.display=e)}return e.create.status=function(){let t=i.getQueryElement(this.options.status);t&&(this.statusElement=t,this.statusEventElements={request:t.querySelector(".infinite-scroll-request"),error:t.querySelector(".infinite-scroll-error"),last:t.querySelector(".infinite-scroll-last")},this.on("request",this.showRequestStatus),this.on("error",this.showErrorStatus),this.on("last",this.showLastStatus),this.bindHideStatus("on"))},n.bindHideStatus=function(t){let e=this.options.append?"append":"load";this[t](e,this.hideAllStatus)},n.showRequestStatus=function(){this.showStatus("request")},n.showErrorStatus=function(){this.showStatus("error")},n.showLastStatus=function(){this.showStatus("last"),this.bindHideStatus("off")},n.showStatus=function(t){s(this.statusElement),this.hideStatusEventElements(),s(this.statusEventElements[t])},n.hideAllStatus=function(){o(this.statusElement),this.hideStatusEventElements()},n.hideStatusEventElements=function(){for(let t in this.statusEventElements){o(this.statusEventElements[t])}},e})),
12
+ /*!
13
+ * imagesLoaded v4.1.4
14
+ * JavaScript is all like "You images are done yet or what?"
15
+ * MIT License
16
+ */
17
+ function(t,e){"use strict";"function"==typeof define&&define.amd?define(["ev-emitter/ev-emitter"],(function(i){return e(t,i)})):"object"==typeof module&&module.exports?module.exports=e(t,require("ev-emitter")):t.imagesLoaded=e(t,t.EvEmitter)}("undefined"!=typeof window?window:this,(function(t,e){"use strict";var i=t.jQuery,n=t.console;function o(t,e){for(var i in e)t[i]=e[i];return t}var s=Array.prototype.slice;function r(t,e,l){if(!(this instanceof r))return new r(t,e,l);var h,a=t;("string"==typeof t&&(a=document.querySelectorAll(t)),a)?(this.elements=(h=a,Array.isArray(h)?h:"object"==typeof h&&"number"==typeof h.length?s.call(h):[h]),this.options=o({},this.options),"function"==typeof e?l=e:o(this.options,e),l&&this.on("always",l),this.getImages(),i&&(this.jqDeferred=new i.Deferred),setTimeout(this.check.bind(this))):n.error("Bad element for imagesLoaded "+(a||t))}r.prototype=Object.create(e.prototype),r.prototype.options={},r.prototype.getImages=function(){this.images=[],this.elements.forEach(this.addElementImages,this)},r.prototype.addElementImages=function(t){"IMG"==t.nodeName&&this.addImage(t),!0===this.options.background&&this.addElementBackgroundImages(t);var e=t.nodeType;if(e&&l[e]){for(var i=t.querySelectorAll("img"),n=0;n<i.length;n++){var o=i[n];this.addImage(o)}if("string"==typeof this.options.background){var s=t.querySelectorAll(this.options.background);for(n=0;n<s.length;n++){var r=s[n];this.addElementBackgroundImages(r)}}}};var l={1:!0,9:!0,11:!0};function h(t){this.img=t}function a(t,e){this.url=t,this.element=e,this.img=new Image}return r.prototype.addElementBackgroundImages=function(t){var e=getComputedStyle(t);if(e)for(var i=/url\((['"])?(.*?)\1\)/gi,n=i.exec(e.backgroundImage);null!==n;){var o=n&&n[2];o&&this.addBackground(o,t),n=i.exec(e.backgroundImage)}},r.prototype.addImage=function(t){var e=new h(t);this.images.push(e)},r.prototype.addBackground=function(t,e){var i=new a(t,e);this.images.push(i)},r.prototype.check=function(){var t=this;function e(e,i,n){setTimeout((function(){t.progress(e,i,n)}))}this.progressedCount=0,this.hasAnyBroken=!1,this.images.length?this.images.forEach((function(t){t.once("progress",e),t.check()})):this.complete()},r.prototype.progress=function(t,e,i){this.progressedCount++,this.hasAnyBroken=this.hasAnyBroken||!t.isLoaded,this.emitEvent("progress",[this,t,e]),this.jqDeferred&&this.jqDeferred.notify&&this.jqDeferred.notify(this,t),this.progressedCount==this.images.length&&this.complete(),this.options.debug&&n&&n.log("progress: "+i,t,e)},r.prototype.complete=function(){var t=this.hasAnyBroken?"fail":"done";if(this.isComplete=!0,this.emitEvent(t,[this]),this.emitEvent("always",[this]),this.jqDeferred){var e=this.hasAnyBroken?"reject":"resolve";this.jqDeferred[e](this)}},h.prototype=Object.create(e.prototype),h.prototype.check=function(){this.getIsImageComplete()?this.confirm(0!==this.img.naturalWidth,"naturalWidth"):(this.proxyImage=new Image,this.proxyImage.addEventListener("load",this),this.proxyImage.addEventListener("error",this),this.img.addEventListener("load",this),this.img.addEventListener("error",this),this.proxyImage.src=this.img.src)},h.prototype.getIsImageComplete=function(){return this.img.complete&&this.img.naturalWidth},h.prototype.confirm=function(t,e){this.isLoaded=t,this.emitEvent("progress",[this,this.img,e])},h.prototype.handleEvent=function(t){var e="on"+t.type;this[e]&&this[e](t)},h.prototype.onload=function(){this.confirm(!0,"onload"),this.unbindEvents()},h.prototype.onerror=function(){this.confirm(!1,"onerror"),this.unbindEvents()},h.prototype.unbindEvents=function(){this.proxyImage.removeEventListener("load",this),this.proxyImage.removeEventListener("error",this),this.img.removeEventListener("load",this),this.img.removeEventListener("error",this)},a.prototype=Object.create(h.prototype),a.prototype.check=function(){this.img.addEventListener("load",this),this.img.addEventListener("error",this),this.img.src=this.url,this.getIsImageComplete()&&(this.confirm(0!==this.img.naturalWidth,"naturalWidth"),this.unbindEvents())},a.prototype.unbindEvents=function(){this.img.removeEventListener("load",this),this.img.removeEventListener("error",this)},a.prototype.confirm=function(t,e){this.isLoaded=t,this.emitEvent("progress",[this,this.element,e])},r.makeJQueryPlugin=function(e){(e=e||t.jQuery)&&((i=e).fn.imagesLoaded=function(t,e){return new r(this,t,e).jqDeferred.promise(i(this))})},r.makeJQueryPlugin(),r}));
data/lib/j1/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module J1
2
- VERSION = '2021.1.23'
2
+ VERSION = '2021.1.24'
3
3
  end
@@ -53,7 +53,7 @@ gem 'jekyll', '~> 4.2'
53
53
 
54
54
  # Theme Rubies, default: J1 Template (NOT used for the development system)
55
55
  #
56
- gem 'j1-template', '~> 2021.1.23'
56
+ gem 'j1-template', '~> 2021.1.24'
57
57
 
58
58
  # ------------------------------------------------------------------------------
59
59
  # PRODUCTION: Gem needed for the Jekyll and J1 prod environment
@@ -53,7 +53,7 @@ environment: production
53
53
  # ------------------------------------------------------------------------------
54
54
  # Sets the build version of J1 Template Gem
55
55
  #
56
- version: 2021.1.23
56
+ version: 2021.1.24
57
57
 
58
58
  # version
59
59
  # ------------------------------------------------------------------------------
@@ -423,7 +423,7 @@ end::tables[]
423
423
  // -----------------------------------------------------------------------------
424
424
  tag::products[]
425
425
  :j1--license: MIT License
426
- :j1--version: 2021.1.23
426
+ :j1--version: 2021.1.24
427
427
  :j1--site-name: Jekyll One
428
428
  end::products[]
429
429
 
@@ -364,6 +364,6 @@ end
364
364
 
365
365
  module Jekyll
366
366
  module J1LunrSearch
367
- VERSION = '2021.1.23'
367
+ VERSION = '2021.1.24'
368
368
  end
369
369
  end
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": true,
3
3
  "name": "j1_starter",
4
- "version": "2021.1.23",
4
+ "version": "2021.1.24",
5
5
  "description": "J1 Template Starter Web",
6
6
  "homepage": "https://your.site",
7
7
  "author": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": true,
3
3
  "name": "utls",
4
- "version": "2021.1.23",
4
+ "version": "2021.1.24",
5
5
  "description": "J1 Template Utility Server",
6
6
  "homepage": "https://jekyll.one",
7
7
  "author": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": true,
3
3
  "name": "utls",
4
- "version": "2021.1.23",
4
+ "version": "2021.1.24",
5
5
  "description": "J1 Template Utility Server",
6
6
  "homepage": "https://jekyll.one",
7
7
  "author": {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: j1-template
3
3
  version: !ruby/object:Gem::Version
4
- version: 2021.1.23
4
+ version: 2021.1.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - juergen_jekyll_one
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-14 00:00:00.000000000 Z
11
+ date: 2021-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -285,6 +285,9 @@ files:
285
285
  - _includes/themes/j1/modules/connectors/comment/just-comments.html
286
286
  - _includes/themes/j1/modules/connectors/comments
287
287
  - _includes/themes/j1/modules/connectors/sharing
288
+ - _includes/themes/j1/modules/connectors/survey/custom-provider.html
289
+ - _includes/themes/j1/modules/connectors/survey/jotform.html
290
+ - _includes/themes/j1/modules/connectors/surveys
288
291
  - _includes/themes/j1/modules/connectors/translator
289
292
  - _includes/themes/j1/modules/connectors/translators/custom-translator.html
290
293
  - _includes/themes/j1/modules/connectors/translators/google-translator.html
@@ -542,7 +545,6 @@ files:
542
545
  - assets/themes/j1/modules/infiniteScroll/css/theme/uno.min.css
543
546
  - assets/themes/j1/modules/infiniteScroll/js/infiniteScroll.js
544
547
  - assets/themes/j1/modules/infiniteScroll/js/infiniteScroll.min.js
545
- - assets/themes/j1/modules/infiniteScroll/js/infiniteScroll.modified.js
546
548
  - assets/themes/j1/modules/jquery/css/jqueryUI/theme.css
547
549
  - assets/themes/j1/modules/jquery/css/jqueryUI/theme.min.css
548
550
  - assets/themes/j1/modules/jquery/js/jquery-3.5.1.min.map
@@ -1,1913 +0,0 @@
1
- /*!
2
- * Infinite Scroll PACKAGED v4.0.1
3
- * Automatically add next page
4
- *
5
- * Licensed GPLv3 for open source use
6
- * or Infinite Scroll Commercial License for commercial use
7
- *
8
- * https://infinite-scroll.com
9
- * Copyright 2018-2020 Metafizzy
10
- */
11
-
12
- /**
13
- * Bridget makes jQuery widgets
14
- * v3.0.0
15
- * MIT license
16
- */
17
-
18
- ( function( window, factory ) {
19
- // module definition
20
- if ( typeof module == 'object' && module.exports ) {
21
- // CommonJS
22
- module.exports = factory(
23
- window,
24
- require('jquery'),
25
- );
26
- } else {
27
- // browser global
28
- window.jQueryBridget = factory(
29
- window,
30
- window.jQuery,
31
- );
32
- }
33
-
34
- }( window, function factory( window, jQuery ) {
35
-
36
- // ----- utils ----- //
37
-
38
- // helper function for logging errors
39
- // $.error breaks jQuery chaining
40
- let console = window.console;
41
- let logError = typeof console == 'undefined' ? function() {} :
42
- function( message ) {
43
- console.error( message );
44
- };
45
-
46
- // ----- jQueryBridget ----- //
47
-
48
- function jQueryBridget( namespace, PluginClass, $ ) {
49
- $ = $ || jQuery || window.jQuery;
50
- if ( !$ ) {
51
- return;
52
- }
53
-
54
- // add option method -> $().plugin('option', {...})
55
- if ( !PluginClass.prototype.option ) {
56
- // option setter
57
- PluginClass.prototype.option = function( opts ) {
58
- if ( !opts ) return;
59
-
60
- this.options = Object.assign( this.options || {}, opts );
61
- };
62
- }
63
-
64
- // make jQuery plugin
65
- $.fn[ namespace ] = function( arg0, ...args ) {
66
- if ( typeof arg0 == 'string' ) {
67
- // method call $().plugin( 'methodName', { options } )
68
- return methodCall( this, arg0, args );
69
- }
70
- // just $().plugin({ options })
71
- plainCall( this, arg0 );
72
- return this;
73
- };
74
-
75
- // $().plugin('methodName')
76
- function methodCall( $elems, methodName, args ) {
77
- let returnValue;
78
- let pluginMethodStr = `$().${namespace}("${methodName}")`;
79
-
80
- $elems.each( function( i, elem ) {
81
- // get instance
82
- let instance = $.data( elem, namespace );
83
- if ( !instance ) {
84
- logError( `${namespace} not initialized.` +
85
- ` Cannot call method ${pluginMethodStr}` );
86
- return;
87
- }
88
-
89
- let method = instance[ methodName ];
90
- if ( !method || methodName.charAt( 0 ) == '_' ) {
91
- logError(`${pluginMethodStr} is not a valid method`);
92
- return;
93
- }
94
-
95
- // apply method, get return value
96
- let value = method.apply( instance, args );
97
- // set return value if value is returned, use only first value
98
- returnValue = returnValue === undefined ? value : returnValue;
99
- } );
100
-
101
- return returnValue !== undefined ? returnValue : $elems;
102
- }
103
-
104
- function plainCall( $elems, options ) {
105
- $elems.each( function( i, elem ) {
106
- let instance = $.data( elem, namespace );
107
- if ( instance ) {
108
- // set options & init
109
- instance.option( options );
110
- instance._init();
111
- } else {
112
- // initialize new instance
113
- instance = new PluginClass( elem, options );
114
- $.data( elem, namespace, instance );
115
- }
116
- } );
117
- }
118
-
119
- }
120
-
121
- // ----- ----- //
122
-
123
- return jQueryBridget;
124
-
125
- } ) );
126
- /**
127
- * EvEmitter v2.0.0
128
- * Lil' event emitter
129
- * MIT License
130
- */
131
-
132
- ( function( global, factory ) {
133
- // universal module definition
134
- if ( typeof module == 'object' && module.exports ) {
135
- // CommonJS - Browserify, Webpack
136
- module.exports = factory();
137
- } else {
138
- // Browser globals
139
- global.EvEmitter = factory();
140
- }
141
-
142
- }( typeof window != 'undefined' ? window : this, function() {
143
-
144
- function EvEmitter() {}
145
-
146
- let proto = EvEmitter.prototype;
147
-
148
- proto.on = function( eventName, listener ) {
149
- if ( !eventName || !listener ) return this;
150
-
151
- // set events hash
152
- let events = this._events = this._events || {};
153
- // set listeners array
154
- let listeners = events[ eventName ] = events[ eventName ] || [];
155
- // only add once
156
- if ( !listeners.includes( listener ) ) {
157
- listeners.push( listener );
158
- }
159
-
160
- return this;
161
- };
162
-
163
- proto.once = function( eventName, listener ) {
164
- if ( !eventName || !listener ) return this;
165
-
166
- // add event
167
- this.on( eventName, listener );
168
- // set once flag
169
- // set onceEvents hash
170
- let onceEvents = this._onceEvents = this._onceEvents || {};
171
- // set onceListeners object
172
- let onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || {};
173
- // set flag
174
- onceListeners[ listener ] = true;
175
-
176
- return this;
177
- };
178
-
179
- proto.off = function( eventName, listener ) {
180
- let listeners = this._events && this._events[ eventName ];
181
- if ( !listeners || !listeners.length ) return this;
182
-
183
- let index = listeners.indexOf( listener );
184
- if ( index != -1 ) {
185
- listeners.splice( index, 1 );
186
- }
187
-
188
- return this;
189
- };
190
-
191
- proto.emitEvent = function( eventName, args ) {
192
- let listeners = this._events && this._events[ eventName ];
193
- if ( !listeners || !listeners.length ) return this;
194
-
195
- // copy over to avoid interference if .off() in listener
196
- listeners = listeners.slice( 0 );
197
- args = args || [];
198
- // once stuff
199
- let onceListeners = this._onceEvents && this._onceEvents[ eventName ];
200
-
201
- for ( let listener of listeners ) {
202
- let isOnce = onceListeners && onceListeners[ listener ];
203
- if ( isOnce ) {
204
- // remove listener
205
- // remove before trigger to prevent recursion
206
- this.off( eventName, listener );
207
- // unset once flag
208
- delete onceListeners[ listener ];
209
- }
210
- // trigger listener
211
- listener.apply( this, args );
212
- }
213
-
214
- return this;
215
- };
216
-
217
- proto.allOff = function() {
218
- delete this._events;
219
- delete this._onceEvents;
220
- return this;
221
- };
222
-
223
- return EvEmitter;
224
-
225
- } ) );
226
- /**
227
- * Fizzy UI utils v3.0.0
228
- * MIT license
229
- */
230
-
231
- ( function( global, factory ) {
232
- // universal module definition
233
- if ( typeof module == 'object' && module.exports ) {
234
- // CommonJS
235
- module.exports = factory( global );
236
- } else {
237
- // browser global
238
- global.fizzyUIUtils = factory( global );
239
- }
240
-
241
- }( this, function factory( global ) {
242
-
243
- let utils = {};
244
-
245
- // ----- extend ----- //
246
-
247
- // extends objects
248
- utils.extend = function( a, b ) {
249
- return Object.assign( a, b );
250
- };
251
-
252
- // ----- modulo ----- //
253
-
254
- utils.modulo = function( num, div ) {
255
- return ( ( num % div ) + div ) % div;
256
- };
257
-
258
- // ----- makeArray ----- //
259
-
260
- // turn element or nodeList into an array
261
- utils.makeArray = function( obj ) {
262
- // use object if already an array
263
- if ( Array.isArray( obj ) ) return obj;
264
-
265
- // return empty array if undefined or null. #6
266
- if ( obj === null || obj === undefined ) return [];
267
-
268
- let isArrayLike = typeof obj == 'object' && typeof obj.length == 'number';
269
- // convert nodeList to array
270
- if ( isArrayLike ) return [ ...obj ];
271
-
272
- // array of single index
273
- return [ obj ];
274
- };
275
-
276
- // ----- removeFrom ----- //
277
-
278
- utils.removeFrom = function( ary, obj ) {
279
- let index = ary.indexOf( obj );
280
- if ( index != -1 ) {
281
- ary.splice( index, 1 );
282
- }
283
- };
284
-
285
- // ----- getParent ----- //
286
-
287
- utils.getParent = function( elem, selector ) {
288
- while ( elem.parentNode && elem != document.body ) {
289
- elem = elem.parentNode;
290
- if ( elem.matches( selector ) ) return elem;
291
- }
292
- };
293
-
294
- // ----- getQueryElement ----- //
295
-
296
- // use element as selector string
297
- utils.getQueryElement = function( elem ) {
298
- if ( typeof elem == 'string' ) {
299
- return document.querySelector( elem );
300
- }
301
- return elem;
302
- };
303
-
304
- // ----- handleEvent ----- //
305
-
306
- // enable .ontype to trigger from .addEventListener( elem, 'type' )
307
- utils.handleEvent = function( event ) {
308
- let method = 'on' + event.type;
309
- if ( this[ method ] ) {
310
- this[ method ]( event );
311
- }
312
- };
313
-
314
- // ----- filterFindElements ----- //
315
-
316
- utils.filterFindElements = function( elems, selector ) {
317
- // make array of elems
318
- elems = utils.makeArray( elems );
319
-
320
- return elems
321
- // check that elem is an actual element
322
- .filter( ( elem ) => elem instanceof HTMLElement )
323
- .reduce( ( ffElems, elem ) => {
324
- // add elem if no selector
325
- if ( !selector ) {
326
- ffElems.push( elem );
327
- return ffElems;
328
- }
329
- // filter & find items if we have a selector
330
- // filter
331
- if ( elem.matches( selector ) ) {
332
- ffElems.push( elem );
333
- }
334
- // find children
335
- let childElems = elem.querySelectorAll( selector );
336
- // concat childElems to filterFound array
337
- ffElems = ffElems.concat( ...childElems );
338
- return ffElems;
339
- }, [] );
340
- };
341
-
342
- // ----- debounceMethod ----- //
343
-
344
- utils.debounceMethod = function( _class, methodName, threshold ) {
345
- threshold = threshold || 100;
346
- // original method
347
- let method = _class.prototype[ methodName ];
348
- let timeoutName = methodName + 'Timeout';
349
-
350
- _class.prototype[ methodName ] = function() {
351
- clearTimeout( this[ timeoutName ] );
352
-
353
- let args = arguments;
354
- this[ timeoutName ] = setTimeout( () => {
355
- method.apply( this, args );
356
- delete this[ timeoutName ];
357
- }, threshold );
358
- };
359
- };
360
-
361
- // ----- docReady ----- //
362
-
363
- utils.docReady = function( onDocReady ) {
364
- let readyState = document.readyState;
365
- if ( readyState == 'complete' || readyState == 'interactive' ) {
366
- // do async to allow for other scripts to run. metafizzy/flickity#441
367
- setTimeout( onDocReady );
368
- } else {
369
- document.addEventListener( 'DOMContentLoaded', onDocReady );
370
- }
371
- };
372
-
373
- // ----- htmlInit ----- //
374
-
375
- // http://bit.ly/3oYLusc
376
- utils.toDashed = function( str ) {
377
- return str.replace( /(.)([A-Z])/g, function( match, $1, $2 ) {
378
- return $1 + '-' + $2;
379
- } ).toLowerCase();
380
- };
381
-
382
- let console = global.console;
383
-
384
- // allow user to initialize classes via [data-namespace] or .js-namespace class
385
- // htmlInit( Widget, 'widgetName' )
386
- // options are parsed from data-namespace-options
387
- utils.htmlInit = function( WidgetClass, namespace ) {
388
- utils.docReady( function() {
389
- let dashedNamespace = utils.toDashed( namespace );
390
- let dataAttr = 'data-' + dashedNamespace;
391
- let dataAttrElems = document.querySelectorAll( `[${dataAttr}]` );
392
- let jQuery = global.jQuery;
393
-
394
- [ ...dataAttrElems ].forEach( ( elem ) => {
395
- let attr = elem.getAttribute( dataAttr );
396
- let options;
397
- try {
398
- options = attr && JSON.parse( attr );
399
- } catch ( error ) {
400
- // log error, do not initialize
401
- if ( console ) {
402
- console.error( `Error parsing ${dataAttr} on ${elem.className}: ${error}` );
403
- }
404
- return;
405
- }
406
- // initialize
407
- let instance = new WidgetClass( elem, options );
408
- // make available via $().data('namespace')
409
- if ( jQuery ) {
410
- jQuery.data( elem, namespace, instance );
411
- }
412
- } );
413
-
414
- } );
415
- };
416
-
417
- // ----- ----- //
418
-
419
- return utils;
420
-
421
- } ) );
422
- // core
423
- ( function( window, factory ) {
424
- // universal module definition
425
- if ( typeof module == 'object' && module.exports ) {
426
- // CommonJS
427
- module.exports = factory(
428
- window,
429
- require('ev-emitter'),
430
- require('fizzy-ui-utils'),
431
- );
432
- } else {
433
- // browser global
434
- window.InfiniteScroll = factory(
435
- window,
436
- window.EvEmitter,
437
- window.fizzyUIUtils,
438
- );
439
- }
440
-
441
- }( window, function factory( window, EvEmitter, utils ) {
442
-
443
- let jQuery = window.jQuery;
444
- // internal store of all InfiniteScroll intances
445
- let instances = {};
446
-
447
- function InfiniteScroll( element, options ) {
448
- let queryElem = utils.getQueryElement( element );
449
-
450
- if ( !queryElem ) {
451
- console.error( 'Bad element for InfiniteScroll: ' + ( queryElem || element ) );
452
- return;
453
- }
454
- element = queryElem;
455
- // do not initialize twice on same element
456
- if ( element.infiniteScrollGUID ) {
457
- let instance = instances[ element.infiniteScrollGUID ];
458
- instance.option( options );
459
- return instance;
460
- }
461
-
462
- this.element = element;
463
- // options
464
- this.options = { ...InfiniteScroll.defaults };
465
- this.option( options );
466
- // add jQuery
467
- if ( jQuery ) {
468
- this.$element = jQuery( this.element );
469
- }
470
-
471
- this.create();
472
- }
473
-
474
- // defaults
475
- InfiniteScroll.defaults = {
476
- // path: null,
477
- // hideNav: null,
478
- // debug: false,
479
- };
480
-
481
- // create & destroy methods
482
- InfiniteScroll.create = {};
483
- InfiniteScroll.destroy = {};
484
-
485
- let proto = InfiniteScroll.prototype;
486
- // inherit EvEmitter
487
- Object.assign( proto, EvEmitter.prototype );
488
-
489
- // -------------------------- -------------------------- //
490
-
491
- // globally unique identifiers
492
- let GUID = 0;
493
-
494
- proto.create = function() {
495
- // create core
496
- // add id for InfiniteScroll.data
497
- let id = this.guid = ++GUID;
498
- this.element.infiniteScrollGUID = id; // expando
499
- instances[ id ] = this; // associate via id
500
- // properties
501
- this.pageIndex = 1; // default to first page
502
- this.loadCount = 0;
503
- this.updateGetPath();
504
- // bail if getPath not set, or returns falsey #776
505
- let hasPath = this.getPath && this.getPath();
506
- if ( !hasPath ) {
507
- console.error('Disabling InfiniteScroll');
508
- return;
509
- }
510
- this.updateGetAbsolutePath();
511
- this.log( 'initialized', [ this.element.className ] );
512
- this.callOnInit();
513
- // create features
514
- for ( let method in InfiniteScroll.create ) {
515
- InfiniteScroll.create[ method ].call( this );
516
- }
517
- };
518
-
519
- proto.option = function( opts ) {
520
- Object.assign( this.options, opts );
521
- };
522
-
523
- // call onInit option, used for binding events on init
524
- proto.callOnInit = function() {
525
- let onInit = this.options.onInit;
526
- if ( onInit ) {
527
- onInit.call( this, this );
528
- }
529
- };
530
-
531
- // ----- events ----- //
532
-
533
- proto.dispatchEvent = function( type, event, args ) {
534
- this.log( type, args );
535
- let emitArgs = event ? [ event ].concat( args ) : args;
536
- this.emitEvent( type, emitArgs );
537
- // trigger jQuery event
538
- if ( !jQuery || !this.$element ) {
539
- return;
540
- }
541
- // namespace jQuery event
542
- type += '.infiniteScroll';
543
- let $event = type;
544
- if ( event ) {
545
- // create jQuery event
546
- /* eslint-disable-next-line new-cap */
547
- let jQEvent = jQuery.Event( event );
548
- jQEvent.type = type;
549
- $event = jQEvent;
550
- }
551
- this.$element.trigger( $event, args );
552
- };
553
-
554
- let loggers = {
555
- initialized: ( className ) => `on ${className}`,
556
- request: ( path ) => `URL: ${path}`,
557
- load: ( response, path ) => `${response.title || ''}. URL: ${path}`,
558
- error: ( error, path ) => `${error}. URL: ${path}`,
559
- append: ( response, path, items ) => `${items.length} items. URL: ${path}`,
560
- last: ( response, path ) => `URL: ${path}`,
561
- history: ( title, path ) => `URL: ${path}`,
562
- pageIndex: function( index, origin ) {
563
- return `current page determined to be: ${index} from ${origin}`;
564
- },
565
- };
566
-
567
- // log events
568
- proto.log = function( type, args ) {
569
- if ( !this.options.debug ) return;
570
-
571
- let message = `[InfiniteScroll] ${type}`;
572
- let logger = loggers[ type ];
573
- if ( logger ) message += '. ' + logger.apply( this, args );
574
- console.log( message );
575
- };
576
-
577
- // -------------------------- methods used amoung features -------------------------- //
578
-
579
- proto.updateMeasurements = function() {
580
- this.windowHeight = window.innerHeight;
581
- let rect = this.element.getBoundingClientRect();
582
- this.top = rect.top + window.scrollY;
583
- };
584
-
585
- proto.updateScroller = function() {
586
- let elementScroll = this.options.elementScroll;
587
- if ( !elementScroll ) {
588
- // default, use window
589
- this.scroller = window;
590
- return;
591
- }
592
- // if true, set to element, otherwise use option
593
- this.scroller = elementScroll === true ? this.element :
594
- utils.getQueryElement( elementScroll );
595
- if ( !this.scroller ) {
596
- throw new Error(`Unable to find elementScroll: ${elementScroll}`);
597
- }
598
- };
599
-
600
- // -------------------------- page path -------------------------- //
601
-
602
- proto.updateGetPath = function() {
603
- let optPath = this.options.path;
604
- if ( !optPath ) {
605
- console.error(`InfiniteScroll path option required. Set as: ${optPath}`);
606
- return;
607
- }
608
- // function
609
- let type = typeof optPath;
610
- if ( type == 'function' ) {
611
- this.getPath = optPath;
612
- return;
613
- }
614
- // template string: '/pages/{{#}}.html'
615
- let templateMatch = type == 'string' && optPath.match('{{#}}');
616
- if ( templateMatch ) {
617
- this.updateGetPathTemplate( optPath );
618
- return;
619
- }
620
- // selector: '.next-page-selector'
621
- this.updateGetPathSelector( optPath );
622
- };
623
-
624
- proto.updateGetPathTemplate = function( optPath ) {
625
- // set getPath with template string
626
- this.getPath = () => {
627
- let nextIndex = this.pageIndex + 1;
628
- return optPath.replace( '{{#}}', nextIndex );
629
- };
630
- // get pageIndex from location
631
- // convert path option into regex to look for pattern in location
632
- // escape query (?) in url, allows for parsing GET parameters
633
- let regexString = optPath
634
- .replace( /(\\\?|\?)/, '\\?' )
635
- .replace( '{{#}}', '(\\d\\d?\\d?)' );
636
- let templateRe = new RegExp( regexString );
637
- let match = location.href.match( templateRe );
638
-
639
- if ( match ) {
640
- this.pageIndex = parseInt( match[1], 10 );
641
- this.log( 'pageIndex', [ this.pageIndex, 'template string' ] );
642
- }
643
- };
644
-
645
- let pathRegexes = [
646
- // WordPress & Tumblr - example.com/page/2
647
- // Jekyll - example.com/page2
648
- /^(.*?\/?page\/?)(\d\d?\d?)(.*?$)/,
649
- // Drupal - example.com/?page=1
650
- /^(.*?\/?\?page=)(\d\d?\d?)(.*?$)/,
651
- // catch all, last occurence of a number
652
- /(.*?)(\d\d?\d?)(?!.*\d)(.*?$)/,
653
- ];
654
-
655
- // try matching href to pathRegexes patterns
656
- let getPathParts = InfiniteScroll.getPathParts = function( href ) {
657
- if ( !href ) return;
658
- for ( let regex of pathRegexes ) {
659
- let match = href.match( regex );
660
- if ( match ) {
661
- let [ , begin, index, end ] = match;
662
- return { begin, index, end };
663
- }
664
- }
665
- };
666
-
667
- proto.updateGetPathSelector = function( optPath ) {
668
- // parse href of link: '.next-page-link'
669
- let hrefElem = document.querySelector( optPath );
670
- if ( !hrefElem ) {
671
- console.error(`Bad InfiniteScroll path option. Next link not found: ${optPath}`);
672
- return;
673
- }
674
-
675
- let href = hrefElem.getAttribute('href');
676
- let pathParts = getPathParts( href );
677
- if ( !pathParts ) {
678
- console.error(`InfiniteScroll unable to parse next link href: ${href}`);
679
- return;
680
- }
681
-
682
- let { begin, index, end } = pathParts;
683
- this.isPathSelector = true; // flag for checkLastPage()
684
- this.getPath = () => begin + ( this.pageIndex + 1 ) + end;
685
- // get pageIndex from href
686
- this.pageIndex = parseInt( index, 10 ) - 1;
687
- this.log( 'pageIndex', [ this.pageIndex, 'next link' ] );
688
- };
689
-
690
- proto.updateGetAbsolutePath = function() {
691
- let path = this.getPath();
692
- // path doesn't start with http or /
693
- let isAbsolute = path.match( /^http/ ) || path.match( /^\// );
694
- if ( isAbsolute ) {
695
- this.getAbsolutePath = this.getPath;
696
- return;
697
- }
698
-
699
- let { pathname } = location;
700
- // query parameter #829. example.com/?pg=2
701
- let isQuery = path.match( /^\?/ );
702
- // /foo/bar/index.html => /foo/bar
703
- let directory = pathname.substring( 0, pathname.lastIndexOf('/') );
704
- let pathStart = isQuery ? pathname : directory + '/';
705
-
706
- this.getAbsolutePath = () => pathStart + this.getPath();
707
- };
708
-
709
- // -------------------------- nav -------------------------- //
710
-
711
- // hide navigation
712
- InfiniteScroll.create.hideNav = function() {
713
- let nav = utils.getQueryElement( this.options.hideNav );
714
- if ( !nav ) return;
715
-
716
- nav.style.display = 'none';
717
- this.nav = nav;
718
- };
719
-
720
- InfiniteScroll.destroy.hideNav = function() {
721
- if ( this.nav ) this.nav.style.display = '';
722
- };
723
-
724
- // -------------------------- destroy -------------------------- //
725
-
726
- proto.destroy = function() {
727
- this.allOff(); // remove all event listeners
728
- // call destroy methods
729
- for ( let method in InfiniteScroll.destroy ) {
730
- InfiniteScroll.destroy[ method ].call( this );
731
- }
732
-
733
- delete this.element.infiniteScrollGUID;
734
- delete instances[ this.guid ];
735
- // remove jQuery data. #807
736
- if ( jQuery && this.$element ) {
737
- jQuery.removeData( this.element, 'infiniteScroll' );
738
- }
739
- };
740
-
741
- // -------------------------- utilities -------------------------- //
742
-
743
- // https://remysharp.com/2010/07/21/throttling-function-calls
744
- InfiniteScroll.throttle = function( fn, threshold ) {
745
- threshold = threshold || 200;
746
- let last, timeout;
747
-
748
- return function() {
749
- let now = +new Date();
750
- let args = arguments;
751
- let trigger = () => {
752
- last = now;
753
- fn.apply( this, args );
754
- };
755
- if ( last && now < last + threshold ) {
756
- // hold on to it
757
- clearTimeout( timeout );
758
- timeout = setTimeout( trigger, threshold );
759
- } else {
760
- trigger();
761
- }
762
- };
763
- };
764
-
765
- InfiniteScroll.data = function( elem ) {
766
- elem = utils.getQueryElement( elem );
767
- let id = elem && elem.infiniteScrollGUID;
768
- return id && instances[ id ];
769
- };
770
-
771
- // set internal jQuery, for Webpack + jQuery v3
772
- InfiniteScroll.setJQuery = function( jqry ) {
773
- jQuery = jqry;
774
- };
775
-
776
- // -------------------------- setup -------------------------- //
777
-
778
- utils.htmlInit( InfiniteScroll, 'infinite-scroll' );
779
-
780
- // add noop _init method for jQuery Bridget. #768
781
- proto._init = function() {};
782
-
783
- let { jQueryBridget } = window;
784
- if ( jQuery && jQueryBridget ) {
785
- jQueryBridget( 'infiniteScroll', InfiniteScroll, jQuery );
786
- }
787
-
788
- // -------------------------- -------------------------- //
789
-
790
- return InfiniteScroll;
791
-
792
- } ) );
793
- // page-load
794
- ( function( window, factory ) {
795
- // universal module definition
796
- if ( typeof module == 'object' && module.exports ) {
797
- // CommonJS
798
- module.exports = factory(
799
- window,
800
- require('./core'),
801
- );
802
- } else {
803
- // browser global
804
- factory(
805
- window,
806
- window.InfiniteScroll,
807
- );
808
- }
809
-
810
- }( window, function factory( window, InfiniteScroll ) {
811
-
812
- let proto = InfiniteScroll.prototype;
813
-
814
- Object.assign( InfiniteScroll.defaults, {
815
- // append: false,
816
- loadOnScroll: true,
817
- checkLastPage: true,
818
- responseBody: 'text',
819
- domParseResponse: true,
820
- // prefill: false,
821
- // outlayer: null,
822
- } );
823
-
824
- InfiniteScroll.create.pageLoad = function() {
825
- this.canLoad = true;
826
- this.on( 'scrollThreshold', this.onScrollThresholdLoad );
827
- this.on( 'load', this.checkLastPage );
828
- if ( this.options.outlayer ) {
829
- this.on( 'append', this.onAppendOutlayer );
830
- }
831
- };
832
-
833
- proto.onScrollThresholdLoad = function() {
834
- if ( this.options.loadOnScroll ) this.loadNextPage();
835
- };
836
-
837
- let domParser = new DOMParser();
838
-
839
- proto.loadNextPage = function() {
840
- if ( this.isLoading || !this.canLoad ) return;
841
-
842
- let { responseBody, domParseResponse, fetchOptions } = this.options;
843
- let path = this.getAbsolutePath();
844
- this.isLoading = true;
845
- if ( typeof fetchOptions == 'function' ) fetchOptions = fetchOptions();
846
-
847
- let fetchPromise = fetch( path, fetchOptions )
848
- .then( ( response ) => {
849
- if ( !response.ok ) {
850
- let error = new Error( response.statusText );
851
- this.onPageError( error, path, response );
852
- return { response };
853
- }
854
-
855
- return response[ responseBody ]().then( ( body ) => {
856
- let canDomParse = responseBody == 'text' && domParseResponse;
857
- if ( canDomParse ) {
858
- body = domParser.parseFromString( body, 'text/html' );
859
- }
860
- if ( response.status == 204 ) {
861
- this.lastPageReached( body, path );
862
- return { body, response };
863
- } else {
864
- return this.onPageLoad( body, path, response );
865
- }
866
- } );
867
- } )
868
- .catch( ( error ) => {
869
- this.onPageError( error, path );
870
- } );
871
-
872
- this.dispatchEvent( 'request', null, [ path, fetchPromise ] );
873
-
874
- return fetchPromise;
875
- };
876
-
877
- proto.onPageLoad = function( body, path, response ) {
878
- // done loading if not appending
879
- if ( !this.options.append ) {
880
- this.isLoading = false;
881
- }
882
- this.pageIndex++;
883
- this.loadCount++;
884
- this.dispatchEvent( 'load', null, [ body, path, response ] );
885
- return this.appendNextPage( body, path, response );
886
- };
887
-
888
- proto.appendNextPage = function( body, path, response ) {
889
- let { append, responseBody, domParseResponse } = this.options;
890
- // do not append json
891
- let isDocument = responseBody == 'text' && domParseResponse;
892
- if ( !isDocument || !append ) return { body, response };
893
-
894
- let items = body.querySelectorAll( append );
895
- let promiseValue = { body, response, items };
896
- // last page hit if no items. #840
897
- if ( !items || !items.length ) {
898
- this.lastPageReached( body, path );
899
- return promiseValue;
900
- }
901
-
902
- let fragment = getItemsFragment( items );
903
- let appendReady = () => {
904
- this.appendItems( items, fragment );
905
- this.isLoading = false;
906
- this.dispatchEvent( 'append', null, [ body, path, items, response ] );
907
- return promiseValue;
908
- };
909
-
910
- // TODO add hook for option to trigger appendReady
911
- if ( this.options.outlayer ) {
912
- return this.appendOutlayerItems( fragment, appendReady );
913
- } else {
914
- return appendReady();
915
- }
916
- };
917
-
918
- proto.appendItems = function( items, fragment ) {
919
- if ( !items || !items.length ) return;
920
-
921
- // get fragment if not provided
922
- fragment = fragment || getItemsFragment( items );
923
- refreshScripts( fragment );
924
- this.element.appendChild( fragment );
925
- };
926
-
927
- function getItemsFragment( items ) {
928
- // add items to fragment
929
- let fragment = document.createDocumentFragment();
930
- if ( items ) fragment.append( ...items );
931
- return fragment;
932
- }
933
-
934
- // replace <script>s with copies so they load
935
- // <script>s added by InfiniteScroll will not load
936
- // similar to https://stackoverflow.com/questions/610995
937
- function refreshScripts( fragment ) {
938
- let scripts = fragment.querySelectorAll('script');
939
- for ( let script of scripts ) {
940
- let freshScript = document.createElement('script');
941
- // copy attributes
942
- let attrs = script.attributes;
943
- for ( let attr of attrs ) {
944
- freshScript.setAttribute( attr.name, attr.value );
945
- }
946
- // copy inner script code. #718, #782
947
- freshScript.innerHTML = script.innerHTML;
948
- script.parentNode.replaceChild( freshScript, script );
949
- }
950
- }
951
-
952
- // ----- outlayer ----- //
953
-
954
- proto.appendOutlayerItems = function( fragment, appendReady ) {
955
- let imagesLoaded = InfiniteScroll.imagesLoaded || window.imagesLoaded;
956
- if ( !imagesLoaded ) {
957
- console.error('[InfiniteScroll] imagesLoaded required for outlayer option');
958
- this.isLoading = false;
959
- return;
960
- }
961
- // append once images loaded
962
- return new Promise( function( resolve ) {
963
- imagesLoaded( fragment, function() {
964
- let bodyResponse = appendReady();
965
- resolve( bodyResponse );
966
- } );
967
- } );
968
- };
969
-
970
- proto.onAppendOutlayer = function( response, path, items ) {
971
- this.options.outlayer.appended( items );
972
- };
973
-
974
- // ----- checkLastPage ----- //
975
-
976
- // check response for next element
977
- proto.checkLastPage = function( body, path ) {
978
- let { checkLastPage, path: pathOpt } = this.options;
979
- if ( !checkLastPage ) return;
980
-
981
- // if path is function, check if next path is truthy
982
- if ( typeof pathOpt == 'function' ) {
983
- let nextPath = this.getPath();
984
- if ( !nextPath ) {
985
- this.lastPageReached( body, path );
986
- return;
987
- }
988
- }
989
- // get selector from checkLastPage or path option
990
- let selector;
991
- if ( typeof checkLastPage == 'string' ) {
992
- selector = checkLastPage;
993
- } else if ( this.isPathSelector ) {
994
- // path option is selector string
995
- selector = pathOpt;
996
- }
997
- // check last page for selector
998
- // bail if no selector or not document response
999
- if ( !selector || !body.querySelector ) return;
1000
-
1001
- // check if response has selector
1002
- let nextElem = body.querySelector( selector );
1003
- if ( !nextElem ) this.lastPageReached( body, path );
1004
- };
1005
-
1006
- proto.lastPageReached = function( body, path ) {
1007
- this.canLoad = false;
1008
- this.dispatchEvent( 'last', null, [ body, path ] );
1009
- };
1010
-
1011
- // ----- error ----- //
1012
-
1013
- proto.onPageError = function( error, path, response ) {
1014
- this.isLoading = false;
1015
- this.canLoad = false;
1016
- this.dispatchEvent( 'error', null, [ error, path, response ] );
1017
- return error;
1018
- };
1019
-
1020
- // -------------------------- prefill -------------------------- //
1021
-
1022
- InfiniteScroll.create.prefill = function() {
1023
- if ( !this.options.prefill ) return;
1024
-
1025
- let append = this.options.append;
1026
- if ( !append ) {
1027
- console.error(`append option required for prefill. Set as :${append}`);
1028
- return;
1029
- }
1030
- this.updateMeasurements();
1031
- this.updateScroller();
1032
- this.isPrefilling = true;
1033
- this.on( 'append', this.prefill );
1034
- this.once( 'error', this.stopPrefill );
1035
- this.once( 'last', this.stopPrefill );
1036
- this.prefill();
1037
- };
1038
-
1039
- proto.prefill = function() {
1040
- let distance = this.getPrefillDistance();
1041
- this.isPrefilling = distance >= 0;
1042
- if ( this.isPrefilling ) {
1043
- this.log('prefill');
1044
- this.loadNextPage();
1045
- } else {
1046
- this.stopPrefill();
1047
- }
1048
- };
1049
-
1050
- proto.getPrefillDistance = function() {
1051
- // element scroll
1052
- if ( this.options.elementScroll ) {
1053
- return this.scroller.clientHeight - this.scroller.scrollHeight;
1054
- }
1055
- // window
1056
- return this.windowHeight - this.element.clientHeight;
1057
- };
1058
-
1059
- proto.stopPrefill = function() {
1060
- this.log('stopPrefill');
1061
- this.off( 'append', this.prefill );
1062
- };
1063
-
1064
- // -------------------------- -------------------------- //
1065
-
1066
- return InfiniteScroll;
1067
-
1068
- } ) );
1069
- // scroll-watch
1070
- ( function( window, factory ) {
1071
- // universal module definition
1072
- if ( typeof module == 'object' && module.exports ) {
1073
- // CommonJS
1074
- module.exports = factory(
1075
- window,
1076
- require('./core'),
1077
- require('fizzy-ui-utils'),
1078
- );
1079
- } else {
1080
- // browser global
1081
- factory(
1082
- window,
1083
- window.InfiniteScroll,
1084
- window.fizzyUIUtils,
1085
- );
1086
- }
1087
-
1088
- }( window, function factory( window, InfiniteScroll, utils ) {
1089
-
1090
- let proto = InfiniteScroll.prototype;
1091
-
1092
- // default options
1093
- Object.assign( InfiniteScroll.defaults, {
1094
- scrollThreshold: 400,
1095
- // elementScroll: null,
1096
- } );
1097
-
1098
- InfiniteScroll.create.scrollWatch = function() {
1099
- // events
1100
- this.pageScrollHandler = this.onPageScroll.bind( this );
1101
- this.resizeHandler = this.onResize.bind( this );
1102
-
1103
- let scrollThreshold = this.options.scrollThreshold;
1104
- let isEnable = scrollThreshold || scrollThreshold === 0;
1105
- if ( isEnable ) this.enableScrollWatch();
1106
- };
1107
-
1108
- InfiniteScroll.destroy.scrollWatch = function() {
1109
- this.disableScrollWatch();
1110
- };
1111
-
1112
- proto.enableScrollWatch = function() {
1113
- if ( this.isScrollWatching ) return;
1114
-
1115
- this.isScrollWatching = true;
1116
- this.updateMeasurements();
1117
- this.updateScroller();
1118
- // TODO disable after error?
1119
- this.on( 'last', this.disableScrollWatch );
1120
- this.bindScrollWatchEvents( true );
1121
- };
1122
-
1123
- proto.disableScrollWatch = function() {
1124
- if ( !this.isScrollWatching ) return;
1125
-
1126
- this.bindScrollWatchEvents( false );
1127
- delete this.isScrollWatching;
1128
- };
1129
-
1130
- proto.bindScrollWatchEvents = function( isBind ) {
1131
- let addRemove = isBind ? 'addEventListener' : 'removeEventListener';
1132
- this.scroller[ addRemove ]( 'scroll', this.pageScrollHandler );
1133
- window[ addRemove ]( 'resize', this.resizeHandler );
1134
- };
1135
-
1136
- // jadams
1137
- proto.onPageScroll = InfiniteScroll.throttle( function() {
1138
- let distance = this.getBottomDistance();
1139
- // if ( distance > 0 && distance <= this.options.scrollThreshold ) {
1140
- if ( distance <= this.options.scrollThreshold ) {
1141
- this.dispatchEvent('scrollThreshold');
1142
- }
1143
- } );
1144
-
1145
- proto.getBottomDistance = function() {
1146
- let bottom, scrollY;
1147
- if ( this.options.elementScroll ) {
1148
- bottom = this.scroller.scrollHeight;
1149
- scrollY = this.scroller.scrollTop + this.scroller.clientHeight;
1150
- } else {
1151
- bottom = this.top + this.element.clientHeight;
1152
- scrollY = window.scrollY + this.windowHeight;
1153
- }
1154
- // jadams
1155
- // return bottom - scrollY + this.options.scrollOffset;
1156
- return bottom - scrollY;
1157
- };
1158
-
1159
- proto.onResize = function() {
1160
- this.updateMeasurements();
1161
- };
1162
-
1163
- utils.debounceMethod( InfiniteScroll, 'onResize', 150 );
1164
-
1165
- // -------------------------- -------------------------- //
1166
-
1167
- return InfiniteScroll;
1168
-
1169
- } ) );
1170
- // history
1171
- ( function( window, factory ) {
1172
- // universal module definition
1173
- if ( typeof module == 'object' && module.exports ) {
1174
- // CommonJS
1175
- module.exports = factory(
1176
- window,
1177
- require('./core'),
1178
- require('fizzy-ui-utils'),
1179
- );
1180
- } else {
1181
- // browser global
1182
- factory(
1183
- window,
1184
- window.InfiniteScroll,
1185
- window.fizzyUIUtils,
1186
- );
1187
- }
1188
-
1189
- }( window, function factory( window, InfiniteScroll, utils ) {
1190
-
1191
- let proto = InfiniteScroll.prototype;
1192
-
1193
- Object.assign( InfiniteScroll.defaults, {
1194
- history: 'replace',
1195
- // historyTitle: false,
1196
- } );
1197
-
1198
- let link = document.createElement('a');
1199
-
1200
- // ----- create/destroy ----- //
1201
-
1202
- InfiniteScroll.create.history = function() {
1203
- if ( !this.options.history ) return;
1204
-
1205
- // check for same origin
1206
- link.href = this.getAbsolutePath();
1207
- // MS Edge does not have origin on link
1208
- // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/12236493/
1209
- let linkOrigin = link.origin || link.protocol + '//' + link.host;
1210
- let isSameOrigin = linkOrigin == location.origin;
1211
- if ( !isSameOrigin ) {
1212
- console.error( '[InfiniteScroll] cannot set history with different origin: ' +
1213
- `${link.origin} on ${location.origin} . History behavior disabled.` );
1214
- return;
1215
- }
1216
-
1217
- // two ways to handle changing history
1218
- if ( this.options.append ) {
1219
- this.createHistoryAppend();
1220
- } else {
1221
- this.createHistoryPageLoad();
1222
- }
1223
- };
1224
-
1225
- proto.createHistoryAppend = function() {
1226
- this.updateMeasurements();
1227
- this.updateScroller();
1228
- // array of scroll positions of appended pages
1229
- this.scrollPages = [
1230
- // first page
1231
- {
1232
- top: 0,
1233
- path: location.href,
1234
- title: document.title,
1235
- },
1236
- ];
1237
- this.scrollPage = this.scrollPages[0];
1238
- // events
1239
- this.scrollHistoryHandler = this.onScrollHistory.bind( this );
1240
- this.unloadHandler = this.onUnload.bind( this );
1241
- this.scroller.addEventListener( 'scroll', this.scrollHistoryHandler );
1242
- this.on( 'append', this.onAppendHistory );
1243
- this.bindHistoryAppendEvents( true );
1244
- };
1245
-
1246
- proto.bindHistoryAppendEvents = function( isBind ) {
1247
- let addRemove = isBind ? 'addEventListener' : 'removeEventListener';
1248
- this.scroller[ addRemove ]( 'scroll', this.scrollHistoryHandler );
1249
- window[ addRemove ]( 'unload', this.unloadHandler );
1250
- };
1251
-
1252
- proto.createHistoryPageLoad = function() {
1253
- this.on( 'load', this.onPageLoadHistory );
1254
- };
1255
-
1256
- InfiniteScroll.destroy.history =
1257
- proto.destroyHistory = function() {
1258
- let isHistoryAppend = this.options.history && this.options.append;
1259
- if ( isHistoryAppend ) {
1260
- this.bindHistoryAppendEvents( false );
1261
- }
1262
- };
1263
-
1264
- // ----- append history ----- //
1265
-
1266
- proto.onAppendHistory = function( response, path, items ) {
1267
- // do not proceed if no items. #779
1268
- if ( !items || !items.length ) return;
1269
-
1270
- let firstItem = items[0];
1271
- let elemScrollY = this.getElementScrollY( firstItem );
1272
- // resolve path
1273
- link.href = path;
1274
- // add page data to hash
1275
- this.scrollPages.push({
1276
- top: elemScrollY,
1277
- path: link.href,
1278
- title: response.title,
1279
- });
1280
- };
1281
-
1282
- proto.getElementScrollY = function( elem ) {
1283
- if ( this.options.elementScroll ) {
1284
- return elem.offsetTop - this.top;
1285
- } else {
1286
- let rect = elem.getBoundingClientRect();
1287
- return rect.top + window.scrollY;
1288
- }
1289
- };
1290
-
1291
- proto.onScrollHistory = function() {
1292
- // cycle through positions, find biggest without going over
1293
- let scrollPage = this.getClosestScrollPage();
1294
- // set history if changed
1295
- if ( scrollPage != this.scrollPage ) {
1296
- this.scrollPage = scrollPage;
1297
- this.setHistory( scrollPage.title, scrollPage.path );
1298
- }
1299
- };
1300
-
1301
- utils.debounceMethod( InfiniteScroll, 'onScrollHistory', 150 );
1302
-
1303
- proto.getClosestScrollPage = function() {
1304
- let scrollViewY;
1305
- if ( this.options.elementScroll ) {
1306
- scrollViewY = this.scroller.scrollTop + this.scroller.clientHeight / 2;
1307
- } else {
1308
- scrollViewY = window.scrollY + this.windowHeight / 2;
1309
- }
1310
-
1311
- let scrollPage;
1312
- for ( let page of this.scrollPages ) {
1313
- if ( page.top >= scrollViewY ) break;
1314
-
1315
- scrollPage = page;
1316
- }
1317
- return scrollPage;
1318
- };
1319
-
1320
- proto.setHistory = function( title, path ) {
1321
- let optHistory = this.options.history;
1322
- let historyMethod = optHistory && history[ optHistory + 'State' ];
1323
- if ( !historyMethod ) return;
1324
-
1325
- history[ optHistory + 'State' ]( null, title, path );
1326
- if ( this.options.historyTitle ) document.title = title;
1327
- this.dispatchEvent( 'history', null, [ title, path ] );
1328
- };
1329
-
1330
- // scroll to top to prevent initial scroll-reset after page refresh
1331
- // https://stackoverflow.com/a/18633915/182183
1332
- proto.onUnload = function() {
1333
- if ( this.scrollPage.top === 0 ) return;
1334
-
1335
- // calculate where scroll position would be on refresh
1336
- let scrollY = window.scrollY - this.scrollPage.top + this.top;
1337
- // disable scroll event before setting scroll #679
1338
- this.destroyHistory();
1339
- scrollTo( 0, scrollY );
1340
- };
1341
-
1342
- // ----- load history ----- //
1343
-
1344
- // update URL
1345
- proto.onPageLoadHistory = function( response, path ) {
1346
- this.setHistory( response.title, path );
1347
- };
1348
-
1349
- // -------------------------- -------------------------- //
1350
-
1351
- return InfiniteScroll;
1352
-
1353
- } ) );
1354
- // button
1355
- ( function( window, factory ) {
1356
- // universal module definition
1357
- if ( typeof module == 'object' && module.exports ) {
1358
- // CommonJS
1359
- module.exports = factory(
1360
- window,
1361
- require('./core'),
1362
- require('fizzy-ui-utils'),
1363
- );
1364
- } else {
1365
- // browser global
1366
- factory(
1367
- window,
1368
- window.InfiniteScroll,
1369
- window.fizzyUIUtils,
1370
- );
1371
- }
1372
-
1373
- }( window, function factory( window, InfiniteScroll, utils ) {
1374
-
1375
- // -------------------------- InfiniteScrollButton -------------------------- //
1376
-
1377
- class InfiniteScrollButton {
1378
- constructor( element, infScroll ) {
1379
- this.element = element;
1380
- this.infScroll = infScroll;
1381
- // events
1382
- this.clickHandler = this.onClick.bind( this );
1383
- this.element.addEventListener( 'click', this.clickHandler );
1384
- infScroll.on( 'request', this.disable.bind( this ) );
1385
- infScroll.on( 'load', this.enable.bind( this ) );
1386
- infScroll.on( 'error', this.hide.bind( this ) );
1387
- infScroll.on( 'last', this.hide.bind( this ) );
1388
- }
1389
-
1390
- onClick( event ) {
1391
- event.preventDefault();
1392
- this.infScroll.loadNextPage();
1393
- }
1394
-
1395
- enable() {
1396
- this.element.removeAttribute('disabled');
1397
- }
1398
-
1399
- disable() {
1400
- this.element.disabled = 'disabled';
1401
- }
1402
-
1403
- hide() {
1404
- this.element.style.display = 'none';
1405
- }
1406
-
1407
- destroy() {
1408
- this.element.removeEventListener( 'click', this.clickHandler );
1409
- }
1410
-
1411
- }
1412
-
1413
- // -------------------------- InfiniteScroll methods -------------------------- //
1414
-
1415
- // InfiniteScroll.defaults.button = null;
1416
-
1417
- InfiniteScroll.create.button = function() {
1418
- let buttonElem = utils.getQueryElement( this.options.button );
1419
- if ( buttonElem ) {
1420
- this.button = new InfiniteScrollButton( buttonElem, this );
1421
- }
1422
- };
1423
-
1424
- InfiniteScroll.destroy.button = function() {
1425
- if ( this.button ) this.button.destroy();
1426
- };
1427
-
1428
- // -------------------------- -------------------------- //
1429
-
1430
- InfiniteScroll.Button = InfiniteScrollButton;
1431
-
1432
- return InfiniteScroll;
1433
-
1434
- } ) );
1435
- // status
1436
- ( function( window, factory ) {
1437
- // universal module definition
1438
- if ( typeof module == 'object' && module.exports ) {
1439
- // CommonJS
1440
- module.exports = factory(
1441
- window,
1442
- require('./core'),
1443
- require('fizzy-ui-utils'),
1444
- );
1445
- } else {
1446
- // browser global
1447
- factory(
1448
- window,
1449
- window.InfiniteScroll,
1450
- window.fizzyUIUtils,
1451
- );
1452
- }
1453
-
1454
- }( window, function factory( window, InfiniteScroll, utils ) {
1455
-
1456
- let proto = InfiniteScroll.prototype;
1457
-
1458
- // InfiniteScroll.defaults.status = null;
1459
-
1460
- InfiniteScroll.create.status = function() {
1461
- let statusElem = utils.getQueryElement( this.options.status );
1462
- if ( !statusElem ) return;
1463
-
1464
- // elements
1465
- this.statusElement = statusElem;
1466
- this.statusEventElements = {
1467
- request: statusElem.querySelector('.infinite-scroll-request'),
1468
- error: statusElem.querySelector('.infinite-scroll-error'),
1469
- last: statusElem.querySelector('.infinite-scroll-last'),
1470
- };
1471
- // events
1472
- this.on( 'request', this.showRequestStatus );
1473
- this.on( 'error', this.showErrorStatus );
1474
- this.on( 'last', this.showLastStatus );
1475
- this.bindHideStatus('on');
1476
- };
1477
-
1478
- proto.bindHideStatus = function( bindMethod ) {
1479
- let hideEvent = this.options.append ? 'append' : 'load';
1480
- this[ bindMethod ]( hideEvent, this.hideAllStatus );
1481
- };
1482
-
1483
- proto.showRequestStatus = function() {
1484
- this.showStatus('request');
1485
- };
1486
-
1487
- proto.showErrorStatus = function() {
1488
- this.showStatus('error');
1489
- };
1490
-
1491
- proto.showLastStatus = function() {
1492
- this.showStatus('last');
1493
- // prevent last then append event race condition from showing last status #706
1494
- this.bindHideStatus('off');
1495
- };
1496
-
1497
- proto.showStatus = function( eventName ) {
1498
- show( this.statusElement );
1499
- this.hideStatusEventElements();
1500
- let eventElem = this.statusEventElements[ eventName ];
1501
- show( eventElem );
1502
- };
1503
-
1504
- proto.hideAllStatus = function() {
1505
- hide( this.statusElement );
1506
- this.hideStatusEventElements();
1507
- };
1508
-
1509
- proto.hideStatusEventElements = function() {
1510
- for ( let type in this.statusEventElements ) {
1511
- let eventElem = this.statusEventElements[ type ];
1512
- hide( eventElem );
1513
- }
1514
- };
1515
-
1516
- // -------------------------- -------------------------- //
1517
-
1518
- function hide( elem ) {
1519
- setDisplay( elem, 'none' );
1520
- }
1521
-
1522
- function show( elem ) {
1523
- setDisplay( elem, 'block' );
1524
- }
1525
-
1526
- function setDisplay( elem, value ) {
1527
- if ( elem ) {
1528
- elem.style.display = value;
1529
- }
1530
- }
1531
-
1532
- // -------------------------- -------------------------- //
1533
-
1534
- return InfiniteScroll;
1535
-
1536
- } ) );
1537
- /*!
1538
- * imagesLoaded v4.1.4
1539
- * JavaScript is all like "You images are done yet or what?"
1540
- * MIT License
1541
- */
1542
-
1543
- ( function( window, factory ) { 'use strict';
1544
- // universal module definition
1545
-
1546
- /*global define: false, module: false, require: false */
1547
-
1548
- if ( typeof define == 'function' && define.amd ) {
1549
- // AMD
1550
- define( [
1551
- 'ev-emitter/ev-emitter'
1552
- ], function( EvEmitter ) {
1553
- return factory( window, EvEmitter );
1554
- });
1555
- } else if ( typeof module == 'object' && module.exports ) {
1556
- // CommonJS
1557
- module.exports = factory(
1558
- window,
1559
- require('ev-emitter')
1560
- );
1561
- } else {
1562
- // browser global
1563
- window.imagesLoaded = factory(
1564
- window,
1565
- window.EvEmitter
1566
- );
1567
- }
1568
-
1569
- })( typeof window !== 'undefined' ? window : this,
1570
-
1571
- // -------------------------- factory -------------------------- //
1572
-
1573
- function factory( window, EvEmitter ) {
1574
-
1575
- 'use strict';
1576
-
1577
- var $ = window.jQuery;
1578
- var console = window.console;
1579
-
1580
- // -------------------------- helpers -------------------------- //
1581
-
1582
- // extend objects
1583
- function extend( a, b ) {
1584
- for ( var prop in b ) {
1585
- a[ prop ] = b[ prop ];
1586
- }
1587
- return a;
1588
- }
1589
-
1590
- var arraySlice = Array.prototype.slice;
1591
-
1592
- // turn element or nodeList into an array
1593
- function makeArray( obj ) {
1594
- if ( Array.isArray( obj ) ) {
1595
- // use object if already an array
1596
- return obj;
1597
- }
1598
-
1599
- var isArrayLike = typeof obj == 'object' && typeof obj.length == 'number';
1600
- if ( isArrayLike ) {
1601
- // convert nodeList to array
1602
- return arraySlice.call( obj );
1603
- }
1604
-
1605
- // array of single index
1606
- return [ obj ];
1607
- }
1608
-
1609
- // -------------------------- imagesLoaded -------------------------- //
1610
-
1611
- /**
1612
- * @param {Array, Element, NodeList, String} elem
1613
- * @param {Object or Function} options - if function, use as callback
1614
- * @param {Function} onAlways - callback function
1615
- */
1616
- function ImagesLoaded( elem, options, onAlways ) {
1617
- // coerce ImagesLoaded() without new, to be new ImagesLoaded()
1618
- if ( !( this instanceof ImagesLoaded ) ) {
1619
- return new ImagesLoaded( elem, options, onAlways );
1620
- }
1621
- // use elem as selector string
1622
- var queryElem = elem;
1623
- if ( typeof elem == 'string' ) {
1624
- queryElem = document.querySelectorAll( elem );
1625
- }
1626
- // bail if bad element
1627
- if ( !queryElem ) {
1628
- console.error( 'Bad element for imagesLoaded ' + ( queryElem || elem ) );
1629
- return;
1630
- }
1631
-
1632
- this.elements = makeArray( queryElem );
1633
- this.options = extend( {}, this.options );
1634
- // shift arguments if no options set
1635
- if ( typeof options == 'function' ) {
1636
- onAlways = options;
1637
- } else {
1638
- extend( this.options, options );
1639
- }
1640
-
1641
- if ( onAlways ) {
1642
- this.on( 'always', onAlways );
1643
- }
1644
-
1645
- this.getImages();
1646
-
1647
- if ( $ ) {
1648
- // add jQuery Deferred object
1649
- this.jqDeferred = new $.Deferred();
1650
- }
1651
-
1652
- // HACK check async to allow time to bind listeners
1653
- setTimeout( this.check.bind( this ) );
1654
- }
1655
-
1656
- ImagesLoaded.prototype = Object.create( EvEmitter.prototype );
1657
-
1658
- ImagesLoaded.prototype.options = {};
1659
-
1660
- ImagesLoaded.prototype.getImages = function() {
1661
- this.images = [];
1662
-
1663
- // filter & find items if we have an item selector
1664
- this.elements.forEach( this.addElementImages, this );
1665
- };
1666
-
1667
- /**
1668
- * @param {Node} element
1669
- */
1670
- ImagesLoaded.prototype.addElementImages = function( elem ) {
1671
- // filter siblings
1672
- if ( elem.nodeName == 'IMG' ) {
1673
- this.addImage( elem );
1674
- }
1675
- // get background image on element
1676
- if ( this.options.background === true ) {
1677
- this.addElementBackgroundImages( elem );
1678
- }
1679
-
1680
- // find children
1681
- // no non-element nodes, #143
1682
- var nodeType = elem.nodeType;
1683
- if ( !nodeType || !elementNodeTypes[ nodeType ] ) {
1684
- return;
1685
- }
1686
- var childImgs = elem.querySelectorAll('img');
1687
- // concat childElems to filterFound array
1688
- for ( var i=0; i < childImgs.length; i++ ) {
1689
- var img = childImgs[i];
1690
- this.addImage( img );
1691
- }
1692
-
1693
- // get child background images
1694
- if ( typeof this.options.background == 'string' ) {
1695
- var children = elem.querySelectorAll( this.options.background );
1696
- for ( i=0; i < children.length; i++ ) {
1697
- var child = children[i];
1698
- this.addElementBackgroundImages( child );
1699
- }
1700
- }
1701
- };
1702
-
1703
- var elementNodeTypes = {
1704
- 1: true,
1705
- 9: true,
1706
- 11: true
1707
- };
1708
-
1709
- ImagesLoaded.prototype.addElementBackgroundImages = function( elem ) {
1710
- var style = getComputedStyle( elem );
1711
- if ( !style ) {
1712
- // Firefox returns null if in a hidden iframe https://bugzil.la/548397
1713
- return;
1714
- }
1715
- // get url inside url("...")
1716
- var reURL = /url\((['"])?(.*?)\1\)/gi;
1717
- var matches = reURL.exec( style.backgroundImage );
1718
- while ( matches !== null ) {
1719
- var url = matches && matches[2];
1720
- if ( url ) {
1721
- this.addBackground( url, elem );
1722
- }
1723
- matches = reURL.exec( style.backgroundImage );
1724
- }
1725
- };
1726
-
1727
- /**
1728
- * @param {Image} img
1729
- */
1730
- ImagesLoaded.prototype.addImage = function( img ) {
1731
- var loadingImage = new LoadingImage( img );
1732
- this.images.push( loadingImage );
1733
- };
1734
-
1735
- ImagesLoaded.prototype.addBackground = function( url, elem ) {
1736
- var background = new Background( url, elem );
1737
- this.images.push( background );
1738
- };
1739
-
1740
- ImagesLoaded.prototype.check = function() {
1741
- var _this = this;
1742
- this.progressedCount = 0;
1743
- this.hasAnyBroken = false;
1744
- // complete if no images
1745
- if ( !this.images.length ) {
1746
- this.complete();
1747
- return;
1748
- }
1749
-
1750
- function onProgress( image, elem, message ) {
1751
- // HACK - Chrome triggers event before object properties have changed. #83
1752
- setTimeout( function() {
1753
- _this.progress( image, elem, message );
1754
- });
1755
- }
1756
-
1757
- this.images.forEach( function( loadingImage ) {
1758
- loadingImage.once( 'progress', onProgress );
1759
- loadingImage.check();
1760
- });
1761
- };
1762
-
1763
- ImagesLoaded.prototype.progress = function( image, elem, message ) {
1764
- this.progressedCount++;
1765
- this.hasAnyBroken = this.hasAnyBroken || !image.isLoaded;
1766
- // progress event
1767
- this.emitEvent( 'progress', [ this, image, elem ] );
1768
- if ( this.jqDeferred && this.jqDeferred.notify ) {
1769
- this.jqDeferred.notify( this, image );
1770
- }
1771
- // check if completed
1772
- if ( this.progressedCount == this.images.length ) {
1773
- this.complete();
1774
- }
1775
-
1776
- if ( this.options.debug && console ) {
1777
- console.log( 'progress: ' + message, image, elem );
1778
- }
1779
- };
1780
-
1781
- ImagesLoaded.prototype.complete = function() {
1782
- var eventName = this.hasAnyBroken ? 'fail' : 'done';
1783
- this.isComplete = true;
1784
- this.emitEvent( eventName, [ this ] );
1785
- this.emitEvent( 'always', [ this ] );
1786
- if ( this.jqDeferred ) {
1787
- var jqMethod = this.hasAnyBroken ? 'reject' : 'resolve';
1788
- this.jqDeferred[ jqMethod ]( this );
1789
- }
1790
- };
1791
-
1792
- // -------------------------- -------------------------- //
1793
-
1794
- function LoadingImage( img ) {
1795
- this.img = img;
1796
- }
1797
-
1798
- LoadingImage.prototype = Object.create( EvEmitter.prototype );
1799
-
1800
- LoadingImage.prototype.check = function() {
1801
- // If complete is true and browser supports natural sizes,
1802
- // try to check for image status manually.
1803
- var isComplete = this.getIsImageComplete();
1804
- if ( isComplete ) {
1805
- // report based on naturalWidth
1806
- this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
1807
- return;
1808
- }
1809
-
1810
- // If none of the checks above matched, simulate loading on detached element.
1811
- this.proxyImage = new Image();
1812
- this.proxyImage.addEventListener( 'load', this );
1813
- this.proxyImage.addEventListener( 'error', this );
1814
- // bind to image as well for Firefox. #191
1815
- this.img.addEventListener( 'load', this );
1816
- this.img.addEventListener( 'error', this );
1817
- this.proxyImage.src = this.img.src;
1818
- };
1819
-
1820
- LoadingImage.prototype.getIsImageComplete = function() {
1821
- // check for non-zero, non-undefined naturalWidth
1822
- // fixes Safari+InfiniteScroll+Masonry bug infinite-scroll#671
1823
- return this.img.complete && this.img.naturalWidth;
1824
- };
1825
-
1826
- LoadingImage.prototype.confirm = function( isLoaded, message ) {
1827
- this.isLoaded = isLoaded;
1828
- this.emitEvent( 'progress', [ this, this.img, message ] );
1829
- };
1830
-
1831
- // ----- events ----- //
1832
-
1833
- // trigger specified handler for event type
1834
- LoadingImage.prototype.handleEvent = function( event ) {
1835
- var method = 'on' + event.type;
1836
- if ( this[ method ] ) {
1837
- this[ method ]( event );
1838
- }
1839
- };
1840
-
1841
- LoadingImage.prototype.onload = function() {
1842
- this.confirm( true, 'onload' );
1843
- this.unbindEvents();
1844
- };
1845
-
1846
- LoadingImage.prototype.onerror = function() {
1847
- this.confirm( false, 'onerror' );
1848
- this.unbindEvents();
1849
- };
1850
-
1851
- LoadingImage.prototype.unbindEvents = function() {
1852
- this.proxyImage.removeEventListener( 'load', this );
1853
- this.proxyImage.removeEventListener( 'error', this );
1854
- this.img.removeEventListener( 'load', this );
1855
- this.img.removeEventListener( 'error', this );
1856
- };
1857
-
1858
- // -------------------------- Background -------------------------- //
1859
-
1860
- function Background( url, element ) {
1861
- this.url = url;
1862
- this.element = element;
1863
- this.img = new Image();
1864
- }
1865
-
1866
- // inherit LoadingImage prototype
1867
- Background.prototype = Object.create( LoadingImage.prototype );
1868
-
1869
- Background.prototype.check = function() {
1870
- this.img.addEventListener( 'load', this );
1871
- this.img.addEventListener( 'error', this );
1872
- this.img.src = this.url;
1873
- // check if image is already complete
1874
- var isComplete = this.getIsImageComplete();
1875
- if ( isComplete ) {
1876
- this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
1877
- this.unbindEvents();
1878
- }
1879
- };
1880
-
1881
- Background.prototype.unbindEvents = function() {
1882
- this.img.removeEventListener( 'load', this );
1883
- this.img.removeEventListener( 'error', this );
1884
- };
1885
-
1886
- Background.prototype.confirm = function( isLoaded, message ) {
1887
- this.isLoaded = isLoaded;
1888
- this.emitEvent( 'progress', [ this, this.element, message ] );
1889
- };
1890
-
1891
- // -------------------------- jQuery -------------------------- //
1892
-
1893
- ImagesLoaded.makeJQueryPlugin = function( jQuery ) {
1894
- jQuery = jQuery || window.jQuery;
1895
- if ( !jQuery ) {
1896
- return;
1897
- }
1898
- // set local variable
1899
- $ = jQuery;
1900
- // $().imagesLoaded()
1901
- $.fn.imagesLoaded = function( options, callback ) {
1902
- var instance = new ImagesLoaded( this, options, callback );
1903
- return instance.jqDeferred.promise( $(this) );
1904
- };
1905
- };
1906
- // try making plugin
1907
- ImagesLoaded.makeJQueryPlugin();
1908
-
1909
- // -------------------------- -------------------------- //
1910
-
1911
- return ImagesLoaded;
1912
-
1913
- });