{ "version": 3, "sources": ["../../../node_modules/infinite-scroll/js/core.js", "../../../node_modules/infinite-scroll/js/page-load.js", "../../../node_modules/infinite-scroll/js/scroll-watch.js", "../../../node_modules/infinite-scroll/js/history.js", "../../../node_modules/infinite-scroll/js/button.js", "../../../node_modules/infinite-scroll/js/status.js", "../../../node_modules/infinite-scroll/js/index.js", "../../javascript/mobile/infinite-scroll.js"], "sourcesContent": ["// core\n( function( window, factory ) {\n // universal module definition\n /* globals define, module, require */\n if ( typeof define == 'function' && define.amd ) {\n // AMD\n define( [\n 'ev-emitter/ev-emitter',\n 'fizzy-ui-utils/utils',\n ], function( EvEmitter, utils) {\n return factory( window, EvEmitter, utils );\n });\n } else if ( typeof module == 'object' && module.exports ) {\n // CommonJS\n module.exports = factory(\n window,\n require('ev-emitter'),\n require('fizzy-ui-utils')\n );\n } else {\n // browser global\n window.InfiniteScroll = factory(\n window,\n window.EvEmitter,\n window.fizzyUIUtils\n );\n }\n\n}( window, function factory( window, EvEmitter, utils ) {\n\nvar jQuery = window.jQuery;\n// internal store of all InfiniteScroll intances\nvar instances = {};\n\nfunction InfiniteScroll( element, options ) {\n var queryElem = utils.getQueryElement( element );\n\n if ( !queryElem ) {\n console.error( 'Bad element for InfiniteScroll: ' + ( queryElem || element ) );\n return;\n }\n element = queryElem;\n // do not initialize twice on same element\n if ( element.infiniteScrollGUID ) {\n var instance = instances[ element.infiniteScrollGUID ];\n instance.option( options );\n return instance;\n }\n\n this.element = element;\n // options\n this.options = utils.extend( {}, InfiniteScroll.defaults );\n this.option( options );\n // add jQuery\n if ( jQuery ) {\n this.$element = jQuery( this.element );\n }\n\n this.create();\n}\n\n// defaults\nInfiniteScroll.defaults = {\n // path: null,\n // hideNav: null,\n // debug: false,\n};\n\n// create & destroy methods\nInfiniteScroll.create = {};\nInfiniteScroll.destroy = {};\n\nvar proto = InfiniteScroll.prototype;\n// inherit EvEmitter\nutils.extend( proto, EvEmitter.prototype );\n\n// -------------------------- -------------------------- //\n\n// globally unique identifiers\nvar GUID = 0;\n\nproto.create = function() {\n // create core\n // add id for InfiniteScroll.data\n var id = this.guid = ++GUID;\n this.element.infiniteScrollGUID = id; // expando\n instances[ id ] = this; // associate via id\n // properties\n this.pageIndex = 1; // default to first page\n this.loadCount = 0;\n this.updateGetPath();\n // bail if getPath not set, or returns falsey #776\n var hasPath = this.getPath && this.getPath();\n if ( !hasPath ) {\n console.error('Disabling InfiniteScroll');\n return;\n }\n this.updateGetAbsolutePath();\n this.log( 'initialized', [ this.element.className ] );\n this.callOnInit();\n // create features\n for ( var method in InfiniteScroll.create ) {\n InfiniteScroll.create[ method ].call( this );\n }\n};\n\nproto.option = function( opts ) {\n utils.extend( this.options, opts );\n};\n\n// call onInit option, used for binding events on init\nproto.callOnInit = function() {\n var onInit = this.options.onInit;\n if ( onInit ) {\n onInit.call( this, this );\n }\n};\n\n// ----- events ----- //\n\nproto.dispatchEvent = function( type, event, args ) {\n this.log( type, args );\n var emitArgs = event ? [ event ].concat( args ) : args;\n this.emitEvent( type, emitArgs );\n // trigger jQuery event\n if ( !jQuery || !this.$element ) {\n return;\n }\n // namespace jQuery event\n type += '.infiniteScroll';\n var $event = type;\n if ( event ) {\n // create jQuery event\n var jQEvent = jQuery.Event( event );\n jQEvent.type = type;\n $event = jQEvent;\n }\n this.$element.trigger( $event, args );\n};\n\nvar loggers = {\n initialized: function( className ) {\n return 'on ' + className;\n },\n request: function( path ) {\n return 'URL: ' + path;\n },\n load: function( response, path ) {\n return ( response.title || '' ) + '. URL: ' + path;\n },\n error: function( error, path ) {\n return error + '. URL: ' + path;\n },\n append: function( response, path, items ) {\n return items.length + ' items. URL: ' + path;\n },\n last: function( response, path ) {\n return 'URL: ' + path;\n },\n history: function( title, path ) {\n return 'URL: ' + path;\n },\n pageIndex: function( index, origin ) {\n return 'current page determined to be: ' + index + ' from ' + origin;\n },\n};\n\n// log events\nproto.log = function( type, args ) {\n if ( !this.options.debug ) {\n return;\n }\n var message = '[InfiniteScroll] ' + type;\n var logger = loggers[ type ];\n if ( logger ) {\n message += '. ' + logger.apply( this, args );\n }\n console.log( message );\n};\n\n// -------------------------- methods used amoung features -------------------------- //\n\nproto.updateMeasurements = function() {\n this.windowHeight = window.innerHeight;\n var rect = this.element.getBoundingClientRect();\n this.top = rect.top + window.pageYOffset;\n};\n\nproto.updateScroller = function() {\n var elementScroll = this.options.elementScroll;\n if ( !elementScroll ) {\n // default, use window\n this.scroller = window;\n return;\n }\n // if true, set to element, otherwise use option\n this.scroller = elementScroll === true ? this.element :\n utils.getQueryElement( elementScroll );\n if ( !this.scroller ) {\n throw 'Unable to find elementScroll: ' + elementScroll;\n }\n};\n\n// -------------------------- page path -------------------------- //\n\nproto.updateGetPath = function() {\n var optPath = this.options.path;\n if ( !optPath ) {\n console.error( 'InfiniteScroll path option required. Set as: ' + optPath );\n return;\n }\n // function\n var type = typeof optPath;\n if ( type == 'function' ) {\n this.getPath = optPath;\n return;\n }\n // template string: '/pages/{{#}}.html'\n var templateMatch = type == 'string' && optPath.match('{{#}}');\n if ( templateMatch ) {\n this.updateGetPathTemplate( optPath );\n return;\n }\n // selector: '.next-page-selector'\n this.updateGetPathSelector( optPath );\n};\n\nproto.updateGetPathTemplate = function( optPath ) {\n // set getPath with template string\n this.getPath = function() {\n var nextIndex = this.pageIndex + 1;\n return optPath.replace( '{{#}}', nextIndex );\n }.bind( this );\n // get pageIndex from location\n // convert path option into regex to look for pattern in location\n var regexString = optPath.replace( '{{#}}', '(\\\\d\\\\d?\\\\d?)' );\n var templateRe = new RegExp( regexString );\n var match = location.href.match( templateRe );\n if ( match ) {\n this.pageIndex = parseInt( match[1], 10 );\n this.log( 'pageIndex', [ this.pageIndex, 'template string' ] );\n }\n};\n\nvar pathRegexes = [\n // WordPress & Tumblr - example.com/page/2\n // Jekyll - example.com/page2\n /^(.*?\\/?page\\/?)(\\d\\d?\\d?)(.*?$)/,\n // Drupal - example.com/?page=1\n /^(.*?\\/?\\?page=)(\\d\\d?\\d?)(.*?$)/,\n // catch all, last occurence of a number\n /(.*?)(\\d\\d?\\d?)(?!.*\\d)(.*?$)/,\n];\n\nproto.updateGetPathSelector = function( optPath ) {\n // parse href of link: '.next-page-link'\n var hrefElem = document.querySelector( optPath );\n if ( !hrefElem ) {\n console.error( 'Bad InfiniteScroll path option. Next link not found: ' +\n optPath );\n return;\n }\n var href = hrefElem.getAttribute('href');\n // try matching href to pathRegexes patterns\n var pathParts, regex;\n for ( var i=0; href && i < pathRegexes.length; i++ ) {\n regex = pathRegexes[i];\n var match = href.match( regex );\n if ( match ) {\n pathParts = match.slice(1); // remove first part\n break;\n }\n }\n if ( !pathParts ) {\n console.error( 'InfiniteScroll unable to parse next link href: ' + href );\n return;\n }\n this.isPathSelector = true; // flag for checkLastPage()\n this.getPath = function() {\n var nextIndex = this.pageIndex + 1;\n return pathParts[0] + nextIndex + pathParts[2];\n }.bind( this );\n // get pageIndex from href\n this.pageIndex = parseInt( pathParts[1], 10 ) - 1;\n this.log( 'pageIndex', [ this.pageIndex, 'next link' ] );\n};\n\nproto.updateGetAbsolutePath = function() {\n var path = this.getPath();\n // path doesn't start with http or /\n var isAbsolute = path.match( /^http/ ) || path.match( /^\\// );\n if ( isAbsolute ) {\n this.getAbsolutePath = this.getPath;\n return;\n }\n\n var pathname = location.pathname;\n // /foo/bar/index.html => /foo/bar\n var directory = pathname.substring( 0, pathname.lastIndexOf('/') );\n\n this.getAbsolutePath = function() {\n return directory + '/' + this.getPath();\n };\n};\n\n// -------------------------- nav -------------------------- //\n\n// hide navigation\nInfiniteScroll.create.hideNav = function() {\n var nav = utils.getQueryElement( this.options.hideNav );\n if ( !nav ) {\n return;\n }\n nav.style.display = 'none';\n this.nav = nav;\n};\n\nInfiniteScroll.destroy.hideNav = function() {\n if ( this.nav ) {\n this.nav.style.display = '';\n }\n};\n\n// -------------------------- destroy -------------------------- //\n\nproto.destroy = function() {\n this.allOff(); // remove all event listeners\n // call destroy methods\n for ( var method in InfiniteScroll.destroy ) {\n InfiniteScroll.destroy[ method ].call( this );\n }\n\n delete this.element.infiniteScrollGUID;\n delete instances[ this.guid ];\n};\n\n// -------------------------- utilities -------------------------- //\n\n// https://remysharp.com/2010/07/21/throttling-function-calls\nInfiniteScroll.throttle = function( fn, threshold ) {\n threshold = threshold || 200;\n var last, timeout;\n\n return function() {\n var now = +new Date();\n var args = arguments;\n var trigger = function() {\n last = now;\n fn.apply( this, args );\n }.bind( this );\n if ( last && now < last + threshold ) {\n // hold on to it\n clearTimeout( timeout );\n timeout = setTimeout( trigger, threshold );\n } else {\n trigger();\n }\n };\n};\n\nInfiniteScroll.data = function( elem ) {\n elem = utils.getQueryElement( elem );\n var id = elem && elem.infiniteScrollGUID;\n return id && instances[ id ];\n};\n\n// set internal jQuery, for Webpack + jQuery v3\nInfiniteScroll.setJQuery = function( $ ) {\n jQuery = $;\n};\n\n// -------------------------- setup -------------------------- //\n\nutils.htmlInit( InfiniteScroll, 'infinite-scroll' );\n\nif ( jQuery && jQuery.bridget ) {\n jQuery.bridget( 'infiniteScroll', InfiniteScroll );\n}\n\n// -------------------------- -------------------------- //\n\nreturn InfiniteScroll;\n\n}));\n", "// page-load\n( function( window, factory ) {\n // universal module definition\n /* globals define, module, require */\n if ( typeof define == 'function' && define.amd ) {\n // AMD\n define( [\n './core',\n ], function( InfiniteScroll ) {\n return factory( window, InfiniteScroll );\n });\n } else if ( typeof module == 'object' && module.exports ) {\n // CommonJS\n module.exports = factory(\n window,\n require('./core')\n );\n } else {\n // browser global\n factory(\n window,\n window.InfiniteScroll\n );\n }\n\n}( window, function factory( window, InfiniteScroll ) {\n\nvar proto = InfiniteScroll.prototype;\n\n// InfiniteScroll.defaults.append = false;\nInfiniteScroll.defaults.loadOnScroll = true;\nInfiniteScroll.defaults.checkLastPage = true;\nInfiniteScroll.defaults.responseType = 'document';\n// InfiniteScroll.defaults.prefill = false;\n// InfiniteScroll.defaults.outlayer = null;\n\nInfiniteScroll.create.pageLoad = function() {\n this.canLoad = true;\n this.on( 'scrollThreshold', this.onScrollThresholdLoad );\n this.on( 'load', this.checkLastPage );\n if ( this.options.outlayer ) {\n this.on( 'append', this.onAppendOutlayer );\n }\n};\n\nproto.onScrollThresholdLoad = function() {\n if ( this.options.loadOnScroll ) {\n this.loadNextPage();\n }\n};\n\nproto.loadNextPage = function() {\n if ( this.isLoading || !this.canLoad ) {\n return;\n }\n\n var path = this.getAbsolutePath();\n this.isLoading = true;\n\n var onLoad = function( response ) {\n this.onPageLoad( response, path );\n }.bind( this );\n\n var onError = function( error ) {\n this.onPageError( error, path );\n }.bind( this );\n\n request( path, this.options.responseType, onLoad, onError );\n this.dispatchEvent( 'request', null, [ path ] );\n};\n\nproto.onPageLoad = function( response, path ) {\n // done loading if not appending\n if ( !this.options.append ) {\n this.isLoading = false;\n }\n this.pageIndex++;\n this.loadCount++;\n this.dispatchEvent( 'load', null, [ response, path ] );\n this.appendNextPage( response, path );\n return response;\n};\n\nproto.appendNextPage = function( response, path ) {\n var optAppend = this.options.append;\n // do not append json\n var isDocument = this.options.responseType == 'document';\n if ( !isDocument || !optAppend ) {\n return;\n }\n\n var items = response.querySelectorAll( optAppend );\n var fragment = getItemsFragment( items );\n var appendReady = function () {\n this.appendItems( items, fragment );\n this.isLoading = false;\n this.dispatchEvent( 'append', null, [ response, path, items ] );\n }.bind( this );\n\n // TODO add hook for option to trigger appendReady\n if ( this.options.outlayer ) {\n this.appendOutlayerItems( fragment, appendReady );\n } else {\n appendReady();\n }\n};\n\nproto.appendItems = function( items, fragment ) {\n if ( !items || !items.length ) {\n return;\n }\n // get fragment if not provided\n fragment = fragment || getItemsFragment( items );\n refreshScripts( fragment );\n this.element.appendChild( fragment );\n};\n\nfunction getItemsFragment( items ) {\n // add items to fragment\n var fragment = document.createDocumentFragment();\n for ( var i=0; items && i < items.length; i++ ) {\n fragment.appendChild( items[i] );\n }\n return fragment;\n}\n\n// replace