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KR,YAAcA,EACnBQ,KAAKiB,2BACLjB,KAAK0B,yBACL1B,KAAKe,iBAC8B,WAA9Bf,KAAKhB,sBACTgB,KAAKkB,qBAKR4B,aA/SuB,SA+STM,GACbA,EAAM,QAAUA,EAAM,SACtB,IAAMC,EAAY,WACjB,IAAO7C,OAAO8C,UAAY,OAAO,EACjC,IAAMC,EAAS,IAAID,UACnB,IACCC,EAAOC,gBAAiB,IAAK,aAC5B,MAAQC,GACT,OAAO,EAER,OAAO,EARU,GAYlB,GAAKJ,EAGJ,OAFe,IAAIC,WACAE,gBAAiBJ,EAAK,aAC9BM,KAAKC,WAIjB,IAAMC,EAAM3D,SAAS4D,cAAe,OAEpC,OADAD,EAAIV,UAAYE,EACTQ,EAAID,YAGZ3C,YAzUuB,SAyUV8C,EAASC,GACrBA,EAAcd,WAAW7B,aACxB0C,EACAC,EAAcC,cAIhB5C,aAhVuB,SAgVT0C,EAASC,GACtBA,EAAcd,WAAW7B,aAAc0C,EAASC,IAGjDnC,aApVuB,SAoVTqC,GACb,IAAMC,EAAWD,EAAQE,wBACzB,OACCD,EAASE,KAAO,GAChBF,EAASG,MAAQ,GACjBH,EAASI,SACN9D,OAAO+D,aACRtE,SAASuE,gBAAgBC,eAC3BP,EAASQ,QACNlE,OAAOmE,YACR1E,SAASuE,gBAAgBI,eAK9B3E,SAASK,iBAAkB,oBAAoB,WAC9C7B,EAAgBqB,UAvWlB","sources":["webpack://wp-hummingbird/./_src/js/lazy-load.js"],"sourcesContent":["/* global wphbGlobal */\n/* global ajaxurl */\n\n( function () {\n\t'use strict';\n\n\tconst WPHBLazyComment = {\n\t\tcommentsFormLoading : false,\n\t\tcommentsLoading: false,\n\t\tcommentsLoadComplete: false,\n\t\tcommentsLoaded: 0,\n\t\tloadOnScroll: false,\n\t\tloadCommentFormOnScroll : false,\n\t\tcommentLoadingMethod: 'click', //or scroll\n\t\tpageCommentsOption: 0,\n\t\ttotalCommentsPages: 1,\n\t\tcommentsPageOrder: 'newest', //or oldest\n\t\tcpageNum: 1,\n\t\tpostId: 0,\n\t\tcommentNonce: '',\n\t\tcommentsContainer: null,\n\t\tcommentList: null,\n\t\tloadCommentsButton: null,\n\t\tloadCommentsButtonWrap: null,\n\t\tcommentsEndIndicator: null,\n\t\tcommentsLoadSpinnerWrap: null,\n\t\tajaxurl: null,\n\n\t\tinit() {\n\t\t\tif ( wphbGlobal ) {\n\t\t\t\tthis.ajaxurl = wphbGlobal.ajaxurl;\n\t\t\t} else {\n\t\t\t\tthis.ajaxurl = ajaxurl;\n\t\t\t}\n\n\t\t\t// Run comment lazy loader if we are in site fron-end and in a single page.\n\t\t\tif ( document.getElementById( 'wphb-comments-wrap' ) ) {\n\t\t\t\tthis.initCommentLazyLoader();\n\t\t\t}\n\t\t},\n\n\t\tinitCommentLazyLoader() {\n\t\t\tthis.commentLoadingMethod = document.getElementById(\n\t\t\t\t'wphb-load-comments-method'\n\t\t\t).value;\n\n\t\t\tthis.pageCommentsOption = parseInt(\n\t\t\t\tdocument.getElementById( 'wphb-page-comments-option' ).value\n\t\t\t);\n\n\t\t\tthis.totalCommentsPages = parseInt(\n\t\t\t\tdocument.getElementById( 'wphb-total-comments-pages' ).value\n\t\t\t);\n\n\t\t\tthis.commentsPageOrder = document.getElementById(\n\t\t\t\t'wphb-comments-page-order'\n\t\t\t).value;\n\n\t\t\tthis.cpageNum = parseInt(\n\t\t\t\tdocument.getElementById( 'wphb-cpage-num' ).value\n\t\t\t);\n\n\t\t\tthis.postId = parseInt(\n\t\t\t\tdocument.getElementById( 'wphb-post-id' ).value\n\t\t\t);\n\n\t\t\tthis.commentNonce = document.getElementById(\n\t\t\t\t'comment-template-nonce'\n\t\t\t).value;\n\n\t\t\tthis.commentsContainer = document.getElementById(\n\t\t\t\t'wphb-comments-container'\n\t\t\t);\n\n\t\t\tthis.commentsEndIndicator = document.getElementById(\n\t\t\t\t'wphb-comments-end-indicator'\n\t\t\t);\n\n\t\t\tthis.commentsLoadSpinnerWrap = document.getElementById(\n\t\t\t\t'wphb-load-comments-spinner-wrap'\n\t\t\t);\n\n\t\t\tif ( this.commentLoadingMethod === 'click' ) {\n\t\t\t\tthis.loadCommentsButton = document.getElementById(\n\t\t\t\t\t'wphb-load-comments'\n\t\t\t\t);\n\t\t\t\tthis.loadCommentsButtonWrap = document.getElementById(\n\t\t\t\t\t'wphb-load-comments-button-wrap'\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t//If we've the load on click enabled\n\t\t\tif ( this.commentLoadingMethod === 'click' ) {\n\t\t\t\tthis.loadCommentsButton.addEventListener( 'click', () =>\n\t\t\t\t\tWPHBLazyComment.loadComments()\n\t\t\t\t);\n\t\t\t\t//At the very beginning load the comment form and basic wrappers\n\t\t\t\tthis.loadCommentFormOnScroll = true;\n\t\t\t\twindow.addEventListener( 'scroll', WPHBLazyComment.handleScrollingForLoadForm );\n\t\t\t\t//For some small posts comment area might be in view port on page load. \n\t\t\t\t//So try to run loadComments on page load. \n\t\t\t\tWPHBLazyComment.handleScrollingForLoadForm();\n\t\t\t}\n\n\t\t\t//If we've the load on scroll enabled\n\t\t\tif ( this.commentLoadingMethod === 'scroll' ) {\n\t\t\t\tthis.loadOnScroll = true;\n\t\t\t\twindow.addEventListener( 'scroll', () =>\n\t\t\t\t\tWPHBLazyComment.handleScrolling()\n\t\t\t\t);\n\t\t\t\t//For some small posts comment area might be in view port on page load. \n\t\t\t\t//So try to run loadCommentsForm on page load. \n\t\t\t\tWPHBLazyComment.handleScrolling();\n\t\t\t}\n\t\t},\n\n\t\tenableCommentLoad() {\n\t\t\tif ( this.loadCommentsButton ) {\n\t\t\t\tthis.loadCommentsButton.removeAttribute( 'disabled' );\n\t\t\t}\n\n\t\t\tthis.loadOnScroll = true;\n\t\t},\n\n\t\tdisableCommentLoad() {\n\t\t\tif ( this.loadCommentsButton ) {\n\t\t\t\tthis.loadCommentsButton.setAttribute( 'disabled', 'disabled' );\n\t\t\t}\n\n\t\t\tthis.loadOnScroll = false;\n\t\t\tthis.loadCommentFormOnScroll = false;\n\t\t},\n\n\t\tmoveLoadButton() {\n\t\t\tif ( this.loadCommentsButton ) {\n\t\t\t\tthis.insertAfter(\n\t\t\t\t\tthis.loadCommentsButtonWrap,\n\t\t\t\t\tthis.commentList\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\n\t\tmoveCommentsEndIndicator() {\n\t\t\tthis.insertAfter( this.commentsEndIndicator, this.commentList );\n\t\t},\n\n\t\tmoveCommentForm() {\n\t\t\tconst form = document.getElementById( 'respond' );\n\t\t\tif ( form ) {\n\t\t\t\tthis.insertBefore( form, this.commentList );\n\t\t\t}\n\t\t},\n\n\t\thideLoadButton() {\n\t\t\tif ( this.loadCommentsButton ) {\n\t\t\t\tthis.loadCommentsButton.style.display = 'none';\n\t\t\t}\n\t\t},\n\n\t\tshowCommentLoadSpinner() {\n\t\t\tthis.commentsLoadSpinnerWrap.style.display = 'block';\n\t\t},\n\n\t\thideCommentLoadSpinner() {\n\t\t\tthis.commentsLoadSpinnerWrap.style.display = 'none';\n\t\t},\n\n\t\tmoveCommentLoadSpinner() {\n\t\t\tthis.insertAfter( this.commentsLoadSpinnerWrap, this.commentList );\n\t\t},\n\n\t\tfinishCommentLoad() {\n\t\t\tthis.commentsLoading = false;\n\t\t\tthis.disableCommentLoad();\n\t\t\tthis.hideLoadButton();\n\t\t},\n\n\t\thandleScrolling() {\n\t\t\t/** Check if in viewport and loadOnScroll is enabled **/\n\t\t\tif (\n\t\t\t\t! this.loadOnScroll ||\n\t\t\t\t! this.isInViewport( this.commentsEndIndicator )\n\t\t\t) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tthis.loadComments();\n\t\t},\n\n\t\thandleScrollingForLoadForm() {\n\t\t\t/** Check if in viewport and loadCommentFormOnScroll is enabled **/\n\t\t\tif (\n\t\t\t\t! WPHBLazyComment.loadCommentFormOnScroll ||\n\t\t\t\t! WPHBLazyComment.isInViewport( WPHBLazyComment.commentsEndIndicator )\n\t\t\t) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\twindow.removeEventListener( 'scroll', WPHBLazyComment.handleScrollingForLoadForm );\n\t\t\t\n\t\t\tWPHBLazyComment.loadCommentsForm();\n\t\t},\n\n\t\tloadCommentsForm() {\n\t\t\tthis.commentsFormLoading = true;\n\t\t\tthis.loadComments();\n\t\t},\n\n\t\tloadComments() {\n\t\t\tif ( this.commentsLoadComplete || this.commentsLoading ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tthis.getCommentsTemplate();\n\t\t},\n\n\t\tgetCommentsTemplate() {\n\t\t\tthis.disableCommentLoad();\n\t\t\tthis.showCommentLoadSpinner();\n\t\t\tconst cxhr = new XMLHttpRequest();\n\n\t\t\tthis.commentsLoading = true;\n\t\t\tcxhr.open(\n\t\t\t\t'GET',\n\t\t\t\tWPHBLazyComment.ajaxurl +\n\t\t\t\t\t'?action=get_comments_template&id=' +\n\t\t\t\t\tWPHBLazyComment.postId +\n\t\t\t\t\t'&cpage_num=' +\n\t\t\t\t\tWPHBLazyComment.cpageNum +\n\t\t\t\t\t'&_nonce=' +\n\t\t\t\t\tWPHBLazyComment.commentNonce\n\t\t\t);\n\n\t\t\tcxhr.onload = function () {\n\t\t\t\t/** Append the comment template **/\n\t\t\t\tif ( 200 === cxhr.status ) {\n\t\t\t\t\tconst response = JSON.parse( cxhr.responseText );\n\t\t\t\t\tif ( 'undefined' !== typeof response.data ) {\n\t\t\t\t\t\t/** Append the comment template/ Error message returned in Ajax response **/\n\t\t\t\t\t\tif( WPHBLazyComment.commentsFormLoading === true ) {\n\t\t\t\t\t\t\tWPHBLazyComment.enableCommentLoad();\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tWPHBLazyComment.commentsLoaded++;\n\t\t\t\t\t\t\tWPHBLazyComment.cpageNum =\n\t\t\t\t\t\t\tWPHBLazyComment.commentsPageOrder === 'newest'\n\t\t\t\t\t\t\t\t? WPHBLazyComment.cpageNum - 1\n\t\t\t\t\t\t\t\t: WPHBLazyComment.cpageNum + 1;\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tWPHBLazyComment.cpageNum < 1 ||\n\t\t\t\t\t\t\t\tWPHBLazyComment.cpageNum >\n\t\t\t\t\t\t\t\t\tWPHBLazyComment.totalCommentsPages\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tWPHBLazyComment.finishCommentLoad();\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tWPHBLazyComment.enableCommentLoad();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tWPHBLazyComment.putCommentContent(\n\t\t\t\t\t\t\tresponse.data.content\n\t\t\t\t\t\t);\n\t\t\t\t\t\t\n\t\t\t\t\t\tif( WPHBLazyComment.commentsFormLoading === true ) {\n\t\t\t\t\t\t\tWPHBLazyComment.commentsFormLoading = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t} else {\n\t\t\t\t\t\tWPHBLazyComment.enableCommentLoad();\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t/** Show the error, if failed; Enable the button, scroll loading **/\n\t\t\t\t\tWPHBLazyComment.enableCommentLoad();\n\t\t\t\t}\n\t\t\t\tWPHBLazyComment.commentsLoading = false;\n\t\t\t\tWPHBLazyComment.hideCommentLoadSpinner();\n\t\t\t};\n\n\t\t\tcxhr.send();\n\t\t},\n\n\t\tputCommentContent( content ) {\n\t\t\tconst html = this.stringToHTML( content );\n\t\t\tconst comment = html.querySelector( '.comment' );\n\n\t\t\tif ( ! comment ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst commentList = comment.parentNode;\n\n\t\t\tif( WPHBLazyComment.commentsFormLoading === true ) {\n\t\t\t\tcommentList.innerHTML = '';\n\t\t\t}\n\n\t\t\tif ( this.commentsLoaded > 1 || ( this.commentLoadingMethod === 'click' && WPHBLazyComment.commentsFormLoading === false ) ) {\n\t\t\t\tthis.commentList.innerHTML += commentList.innerHTML;\n\t\t\t} else {\n\t\t\t\tthis.commentsContainer.appendChild( html );\n\t\t\t\tthis.commentList = commentList;\n\t\t\t\tthis.moveCommentsEndIndicator();\n\t\t\t\tthis.moveCommentLoadSpinner();\n\t\t\t\tthis.moveLoadButton();\n\t\t\t\tif ( this.commentLoadingMethod === 'scroll' ) {\n\t\t\t\t\tthis.moveCommentForm();\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\tstringToHTML( str ) {\n\t\t\tstr = '