101}102103window.onpopstate = function () {104var body = document.body;105body.classList.remove('t-zoomer__show');106body.classList.remove('t-zoomer__show_fixed');107108if (window.history.state !== null) {109var obj = window.history.state.obj;110var post = window.history.state.post;111t_feed_workPostPopup(recid, obj, post, post.uid, opts);112} else if (body.classList.contains('t-body_popupshowed')) {
t_feed_closePopup(recid, opts, window.location.href); } };}/** * Show posts from the current part * @param {string} recid – recid of current block * @param {object} opts – object with feed settings * @param {number} slice – number of the current phase in pagination (before the "Show more" button) */function t_feed_loadPartPosts(recid, opts, slice) { var rec = document.querySelector('#rec' + recid); var switchers = rec.querySelectorAll('.js-feed-parts-switcher'); Array.prototype.forEach.call(switchers, function (switcher) { var hashArr = decodeURI(window.location.hash).split('/'); var isPartTitle = switcher.getAttribute('data-feedpart-title') == hashArr[hashArr.length - 1]; var isUid = switcher.closest('.js-feed').getAttribute('data-feed-uid') == hashArr[hashArr.length - 3]; if (isPartTitle && isUid) { var feedpartuid = switcher.getAttribute('data-feedpart-uid'); opts.feeduid = opts.feeduid.split('-')[0] + '-' + feedpartuid; rec.querySelector('.t-active').classList.remove('t-active'); switcher.classList.add('t-active'); } }); window.tFeedPosts[recid]['switcher'] = true; window.tFeedPosts[recid]['count'] = 0; t_feed_loadPosts(recid, opts, slice, false); if (window.location.href.indexOf('#!/tfeeds') != -1) { var hashArr = decodeURI(window.location.hash).split('/'); var uid = hashArr[hashArr.length - 3]; var feeds = document.querySelector('.js-feed[data-feed-uid="' + uid + '"]'); t_feed_scrollToFeed(feeds); }}/** * Scroll to the current feed on load or after closing the popup * @param {HTMLElement} feeds – current feed * @param {number} offsetTop – top coordinate of current feed */function t_feed_scrollToFeed(feeds) { if (!feeds) return; var offset = feeds.getBoundingClientRect(); var offsetTop = offset.top + window.pageYOffset; var top = offsetTop ? offsetTop - 100 : 0; if ('scrollBehavior' in document.documentElement.style) { window.scrollTo({ top: top, behavior: 'smooth', }); } else { window.scrollTo(0, top); }}/** * Create a separate object for each news feed */function t_feed_createObjWithPosts() { var feeds = document.querySelectorAll('.js-feed'); Array.prototype.forEach.call(feeds, function (feed) { var id = feed.getAttribute('data-feed-recid'); window.tFeedPosts[id] = {}; if (typeof window.tFeedPosts[id] != 'undefined') { window.tFeedPosts[id]['count'] = 0; window.tFeedPosts[id]['switcher'] = false; } });}/** * Load posts – all or from current part * @param {string} recid – recid of current feed * @param {object} opts – object with all settings * @param {number} slice – number of step in "pagination" after clickin on the "Show more" button * @param {boolean} showmore – boolean to understand that posts are loaded after clicking on the "Show more" button * @param {Function} callback – function for load posts from current part */function t_feed_loadPosts(recid, opts, slice, showmore, callback) { var rec = document.querySelector('#rec' + recid); var records = document.querySelector('.t-records');