Некодим логотипНекодим
МодификацииПубликацииНекодИИмЦены
Некодим логотипНекодим

© 2020-2026 Некодим

Готовые модификации для вашего сайта. Улучшайте функциональность и дизайн без программирования.

Компания

  • Контакты
  • Публичная оферта
  • Политика конфиденциальности
  • Согласие на обработку данных
  • Лицензионное соглашение
  • Реферальная программа

Полезное

  • Модификации
  • Публикации
  • Каталог блоков Tilda
  • MCP для агентов
  • Журнал изменений
  • Доска почёта

Личный кабинет

  • Вход
  • Регистрация
  • Цены
Журнал измененийИстория GitФайлыTilda MCP
Каталог файлов

tilda-feed-1.0.js

Код файла
Версия от 24.08.2026, 07:03:11 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
101	}102 103	window.onpopstate = function () {104		var body = document.body;105		body.classList.remove('t-zoomer__show');106		body.classList.remove('t-zoomer__show_fixed');107 108		if (window.history.state !== null) {109			var obj = window.history.state.obj;110			var post = window.history.state.post;111			t_feed_workPostPopup(recid, obj, post, post.uid, opts);112		} else if (body.classList.contains('t-body_popupshowed')) {
История файла и сравнение версий
  • 24.08.2026, 07:03:11 · 56c3b845
113 t_feed_closePopup(recid, opts, window.location.href);
114 }
115 };
116}
117
118/**
119 * Show posts from the current part
120 * @param {string} recid – recid of current block
121 * @param {object} opts – object with feed settings
122 * @param {number} slice – number of the current phase in pagination (before the "Show more" button)
123 */
124function t_feed_loadPartPosts(recid, opts, slice) {
125 var rec = document.querySelector('#rec' + recid);
126 var switchers = rec.querySelectorAll('.js-feed-parts-switcher');
127 Array.prototype.forEach.call(switchers, function (switcher) {
128 var hashArr = decodeURI(window.location.hash).split('/');
129 var isPartTitle = switcher.getAttribute('data-feedpart-title') == hashArr[hashArr.length - 1];
130 var isUid = switcher.closest('.js-feed').getAttribute('data-feed-uid') == hashArr[hashArr.length - 3];
131 if (isPartTitle && isUid) {
132 var feedpartuid = switcher.getAttribute('data-feedpart-uid');
133 opts.feeduid = opts.feeduid.split('-')[0] + '-' + feedpartuid;
134 rec.querySelector('.t-active').classList.remove('t-active');
135 switcher.classList.add('t-active');
136 }
137 });
138
139 window.tFeedPosts[recid]['switcher'] = true;
140 window.tFeedPosts[recid]['count'] = 0;
141
142 t_feed_loadPosts(recid, opts, slice, false);
143
144 if (window.location.href.indexOf('#!/tfeeds') != -1) {
145 var hashArr = decodeURI(window.location.hash).split('/');
146 var uid = hashArr[hashArr.length - 3];
147 var feeds = document.querySelector('.js-feed[data-feed-uid="' + uid + '"]');
148 t_feed_scrollToFeed(feeds);
149 }
150}
151
152/**
153 * Scroll to the current feed on load or after closing the popup
154 * @param {HTMLElement} feeds – current feed
155 * @param {number} offsetTop – top coordinate of current feed
156 */
157function t_feed_scrollToFeed(feeds) {
158 if (!feeds) return;
159 var offset = feeds.getBoundingClientRect();
160 var offsetTop = offset.top + window.pageYOffset;
161
162 var top = offsetTop ? offsetTop - 100 : 0;
163
164 if ('scrollBehavior' in document.documentElement.style) {
165 window.scrollTo({
166 top: top,
167
168 behavior: 'smooth',
169 });
170 } else {
171 window.scrollTo(0, top);
172 }
173}
174
175/**
176 * Create a separate object for each news feed
177 */
178function t_feed_createObjWithPosts() {
179 var feeds = document.querySelectorAll('.js-feed');
180 Array.prototype.forEach.call(feeds, function (feed) {
181 var id = feed.getAttribute('data-feed-recid');
182 window.tFeedPosts[id] = {};
183 if (typeof window.tFeedPosts[id] != 'undefined') {
184 window.tFeedPosts[id]['count'] = 0;
185 window.tFeedPosts[id]['switcher'] = false;
186 }
187 });
188}
189
190/**
191 * Load posts – all or from current part
192 * @param {string} recid – recid of current feed
193 * @param {object} opts – object with all settings
194 * @param {number} slice – number of step in "pagination" after clickin on the "Show more" button
195 * @param {boolean} showmore – boolean to understand that posts are loaded after clicking on the "Show more" button
196 * @param {Function} callback – function for load posts from current part
197 */
198function t_feed_loadPosts(recid, opts, slice, showmore, callback) {
199 var rec = document.querySelector('#rec' + recid);
200 var records = document.querySelector('.t-records');
Предыдущие 100 строкСледующие 100 строк