Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Файл - feed.js (Старый размер - 97050 | Новый - 0):
- 0. - var Feed = {
- 1. - update: function (afterPost) {
- 2. - if (cur.feedUpdateLoading) return;
- 3. - if (cur.add_queue && window.Notifier &&
- 4. - Notifier.addKey(cur.add_queue, feed.updated) &&
- 5. - cur.section != 'news') {
- 6. - return;
- 7. - }
- 8. - if (cur.subsection == 'top' || inArray(cur.section, ['search', 'photos_search', 'mentions', 'articles', 'articles_search', 'likes'])) {
- 9. - return;
- 10. - }
- 11. - var rnd = Math.random();
- 12. - if (cur.section != 'news' && cur.section != 'comments' && rnd > 0.3 ||
- 13. - cur.section == 'news' && (afterPost || rnd > 0.05)) {
- 14. - return;
- 15. - }
- 16. - cur.feedUpdateLoading = true;
- 17. - ajax.post('al_feed.php?au_' + cur.section, extend(feed.getSectionParams(cur.section), {timestamp: cur.timestamp, posted: afterPost ? 1 : '', queue: cur.add_queue ? 1 : 0}), {
- 18. - onDone: function (options, rows, updates_timestamp) {
- 19. - cur.feedUpdateLoading = false;
- 20. - if (afterPost == 1 &&
- 21. - (!rows || rows.indexOf(vk.id + '') == -1)) {
- 22. - setTimeout(feed.update.pbind(2), 2000);
- 23. - return;
- 24. - }
- 25. - if (options.section != cur.section ||
- 26. - options.timestamp < cur.timestamp ||
- 27. - updates_timestamp < cur.timestamp) {
- 28. - return;
- 29. - }
- 30. - options.count += cur.count;
- 31. - var feed_rows = cur.rowsCont, au = ce('div'), el, postEl, post_raw, startST, updH = 0;
- 32. - if (cur.section == 'news') {
- 33. - startST = scrollGetY()
- 34. - if (rows) {
- 35. - au.innerHTML = rows;
- 36. - while (au.lastChild) {
- 37. - feed_rows.insertBefore(au.lastChild, feed_rows.firstChild);
- 38. - }
- 39. - each(geByClass('ts' + updates_timestamp, feed_rows), function() {
- 40. - var self = this;
- 41. - updH += this.offsetHeight;
- 42. - self.style.backgroundColor = '#FEFAE4';
- 43. - animate(self, {backgroundColor: '#FFF'}, 6000);
- 44. - cur.feedUnreadCount++;
- 45. - });
- 46. - }
- 47. - if (updH && startST > 100) {
- 48. - scrollToY(startST + updH, 0);
- 49. - }
- 50. - } else {
- 51. - if (rows) {
- 52. - au.innerHTML = rows;
- 53. - while (el = au.lastChild) {
- 54. - if (el.tagName != 'DIV') {
- 55. - au.removeChild(el);
- 56. - continue;
- 57. - }
- 58. - post_raw = el.firstChild.id.substr(4);
- 59. - if (post_raw && cur.wallLayer == post_raw) {
- 60. - continue;
- 61. - }
- 62. - if (!(postEl = ge('post' + post_raw))) {
- 63. - startST = scrollGetY();
- 64. - feed_rows.insertBefore(el, feed_rows.firstChild);
- 65. - el.style.backgroundColor = '#FEFAE4';
- 66. - animate(el, {backgroundColor: '#FFF'}, 6000);
- 67. - updH = el.offsetHeight;
- 68. - if (startST > 100) {
- 69. - scrollToY(startST + updH, 0);
- 70. - }
- 71. - } else {
- 72. - if (!hasClass(postEl.parentNode, 'feed_row')) {
- 73. - debugLog('insert fail', postEl.parentNode);
- 74. - return;
- 75. - }
- 76. - var repliesCont = ge('replies' + post_raw), openEl = repliesCont.nextSibling, cnt = 0;
- 77. - each ([].slice.call(geByClass('reply', el, 'div')), function () {
- 78. - if (ge(this.id)) return;
- 79. - addClass(this, 'new_reply');
- 80. - repliesCont.appendChild(this);
- 81. - cnt++;
- 82. - });
- 83. - if (cnt) {
- 84. - var stDelta = postEl.parentNode.offsetHeight, newCnt = geByClass('new_reply', repliesCont, 'div').length;
- 85. - if (!openEl || openEl.className != 'replies_open') {
- 86. - openEl = ce('div', {className: 'replies_open', onclick: wall.openNewComments.pbind(post_raw)});
- 87. - repliesCont.parentNode.insertBefore(openEl, repliesCont.nextSibling);
- 88. - }
- 89. - openEl.innerHTML = getLang('wall_x_new_replies_more', Math.min(100, newCnt));
- 90. - openEl.newCnt = newCnt;
- 91. -
- 92. - var st = scrollGetY(),
- 93. - ch = window.innerHeight || document.documentElement.clientHeight || bodyNode.clientHeight,
- 94. - btnY = getXY(openEl)[1],
- 95. - h = postEl.parentNode.offsetHeight;
- 96. -
- 97. - stDelta = h - stDelta;
- 98. -
- 99. - if (!inArray(post_raw, cur.feedUnread)) {
- 100. - cur.feedUnread.unshift(post_raw);
- 101. - }
- 102. - if (!cur.idleManager.isIdle && btnY > st + 100 && btnY < st + ch + 100) {
- 103. - debugLog('delaySorting');
- 104. - feed_rows.insertBefore(ge('post_ph' + post_raw) || ce('div', {id: 'post_ph' + post_raw}), feed_rows.firstChild);
- 105. - if (!inArray(post_raw, cur.feedToSort)) {
- 106. - cur.feedToSort.push(post_raw);
- 107. - }
- 108. - } else {
- 109. - debugLog('sort now', btnY, st + 100, st + ch + 100, stDelta);
- 110. - // debugLog(postEl.parentNode, feed_rows);
- 111. - re(postEl.parentNode);
- 112. - // debugLog(postEl.parentNode, feed_rows);
- 113. - feed_rows.insertBefore(postEl.parentNode, feed_rows.firstChild);
- 114. - if (btnY > st + ch + 100) {
- 115. - stDelta = h;
- 116. - }
- 117. - if (stDelta) {
- 118. - debugLog('moving st', stDelta);
- 119. - scrollToY(scrollGetY() + stDelta, 0);
- 120. - }
- 121. - }
- 122. - cur.feedUnreadCount += cnt;
- 123. - }
- 124. - au.removeChild(el);
- 125. - }
- 126. - }
- 127. - }
- 128. - }
- 129. - feed.applyOptions(options);
- 130. - feed.updateTitle();
- 131. - },
- 132. - onFail: function () {
- 133. - cur.feedUpdateLoading = false;
- 134. - return false;
- 135. - },
- 136. - showProgress: function () {
- 137. - cur.feedUpdateLoading = true;
- 138. - },
- 139. - hideProgress: function () {
- 140. - cur.feedUpdateLoading = false;
- 141. - }
- 142. - });
- 143. - },
- 144. - getNewQKey: function (to) {
- 145. - var params = {
- 146. - act: 'a_get_key',
- 147. - only_update: cur.add_queue ? 1 : 0,
- 148. - need_ignore: !isArray(cur.ignore_owners) ? 1 : 0
- 149. - };
- 150. - var options = {onDone: onDone, local: 1};
- 151. - ajax.post('al_feed.php?queue', extend(feed.getSectionParams(cur.section), params), options);
- 152. - function onDone(key, ignore_owners) {
- 153. - if (key) {
- 154. - cur.add_queue = key;
- 155. - setTimeout(feed.update.pbind(0), 0);
- 156. - } else if (!params.only_update) {
- 157. - var ts = ignore_owners;
- 158. - cur.timestamp = (ts || (vkNow() / 1000)) - to;
- 159. - return;
- 160. - }
- 161. - if (isArray(ignore_owners)) {
- 162. - cur.ignore_owners = ignore_owners;
- 163. - }
- 164. - }
- 165. - },
- 166. - updated: function (key, data) {
- 167. - if ((cur.section != 'search' && cur.section != 'news' && cur.section) || !cur.add_queue || cur.add_queue.key != key) {
- 168. - return;
- 169. - }
- 170. - if (data.failed) {
- 171. - cur.add_queue = false;
- 172. - var timeout = curNotifier.error_timeout || 1;
- 173. - clearTimeout(cur.lp_error_to);
- 174. - cur.lp_error_to = setTimeout(feed.getNewQKey.bind(feed).pbind(timeout), timeout * 1000);
- 175. - return;
- 176. - }
- 177. - if (!isArray(data.events) || !data.events.length) {
- 178. - return;
- 179. - }
- 180. - // debugLog('feed updated', data);
- 181. - cur.add_queue.ts = data.ts;
- 182. - if (data.key) {
- 183. - cur.add_queue.key = data.key;
- 184. - }
- 185. - var startST = scrollGetY(),
- 186. - updH = 0;
- 187. -
- 188. - each(data.events, function () {
- 189. - updH += feed.pushEvent(this.split('<!>'), startST);
- 190. - });
- 191. - var endST = scrollGetY();
- 192. - if (updH && startST > 100 && Math.abs(startST - endST) < 100) {
- 193. - scrollToY(endST + updH, 0);
- 194. - }
- 195. - feed.updateTitle();
- 196. - },
- 197. - pushEvent: function (ev, st) {
- 198. - var ev_ver = ev[0],
- 199. - ev_type = ev[1],
- 200. - post_id = ev[2],
- 201. - el = ge('post' + post_id),
- 202. - s = cur.section,
- 203. - flags = s != 'search' ? intval(ev.pop()) : 0,
- 204. - deltaH = 0;
- 205. -
- 206. - if (!cur.options || ev_ver != cur.options.qversion) {
- 207. - // location.reload();
- 208. - return;
- 209. - }
- 210. - // debugLog(ev_type, post_id, el, ev[ev.length - 1]);
- 211. - switch (ev_type) {
- 212. - case 'new_post':
- 213. - if (el) break;
- 214. - var adminLevel = 0;
- 215. - if (intval(ev[11]) && intval(ev[11]) != vk.id) { // own reply owner
- 216. - ajax.post('al_feed.php', {act: 'a_need_own_reply', oid: intval(ev[11])}, {
- 217. - onDone: function(need) {
- 218. - if (need) {
- 219. - ev[11] = 0;
- 220. - feed.pushEvent(ev);
- 221. - }
- 222. - }
- 223. - });
- 224. - return;
- 225. - }
- 226. - if (s != 'search') {
- 227. - var oid = post_id.split('_')[0];
- 228. - ev[8] = (intval(ev[8]) > 0 && (flags & 4) == 4) ? 1 : 0;
- 229. - if (oid < 0) {
- 230. - adminLevel = (flags & 8) ? 2 : ((flags & 2) ? 1 : 0);
- 231. - }
- 232. - // debugLog(oid, flags, adminLevel, ev[8]);
- 233. - }
- 234. - var cont = cur.rowsCont,
- 235. - cnodes = cont.childNodes,
- 236. - postHTML = wall.getNewPostHTML(ev, adminLevel, feed.feedPostRepl),
- 237. - place = ev[12],
- 238. - newEl, grouped, first, others, moreLink, singleOthers;
- 239. -
- 240. - if (place) { // Client-side grouping posts
- 241. - if (cur.ignore_owners.length && inArray(intval(place), cur.ignore_owners)) {
- 242. - break;
- 243. - }
- 244. - if (grouped = geByClass1('feed_reposts_wrap' + place, cont, 'div')) {
- 245. - first = geByClass1('feed_reposts_first', grouped, 'div').firstChild;
- 246. - others = geByClass1('feed_reposts_group', grouped, 'div');
- 247. - moreLink = geByClass1('feed_reposts_more_link', grouped, 'a');
- 248. - if (st > getXY(first)[1]) {
- 249. - deltaH -= first.offsetHeight;
- 250. - }
- 251. - first.parentNode.replaceChild(newEl = se(postHTML), first);
- 252. - others.insertBefore(first, others.firstChild);
- 253. - if (!isVisible(others)) {
- 254. - val(moreLink, getLang('news_show_X_reposts', others.childNodes.length));
- 255. - }
- 256. - grouped = grouped.parentNode;
- 257. - if (cont.firstChild != grouped) {
- 258. - cont.insertBefore(grouped, cont.firstChild);
- 259. - }
- 260. - if (st > getXY(grouped)[1]) {
- 261. - deltaH += grouped.offsetHeight;
- 262. - }
- 263. - grouped.bits = 0;
- 264. - } else if ((singleOthers = geByClass('feed_repost' + place, cont, 'div')) && singleOthers.length) {
- 265. - postHTML = rs(cur.wallTpl.grouped_posts, {
- 266. - place: place,
- 267. - random: irand(100000000, 200000000),
- 268. - first: postHTML,
- 269. - other: '',
- 270. - label: getLang('news_show_X_reposts', singleOthers.length)
- 271. - });
- 272. - var frow = se('<div class="feed_row">' + postHTML + '</div>');
- 273. - cont.insertBefore(frow, cont.firstChild);
- 274. - if (st > getXY(frow)[1]) {
- 275. - deltaH += frow.offsetHeight;
- 276. - }
- 277. - grouped = frow.firstChild;
- 278. - newEl = geByClass1('feed_reposts_first', grouped, 'div');
- 279. - others = geByClass1('feed_reposts_group', grouped, 'div');
- 280. - each(clone(singleOthers), function () {
- 281. - if (st > getXY(this)[1]) {
- 282. - deltaH -= this.offsetHeight;
- 283. - }
- 284. - re(this.parentNode);
- 285. - others.appendChild(this.firstChild);
- 286. - });
- 287. - } else {
- 288. - newEl = se('<div class="feed_row"><div class="feed_repost' + place + '">' + postHTML + '</div></div>');
- 289. - cont.insertBefore(newEl, cont.firstChild);
- 290. - if (st > getXY(newEl)[1]) {
- 291. - deltaH += newEl.offsetHeight;
- 292. - }
- 293. - }
- 294. - } else {
- 295. - newEl = se('<div class="feed_row">' + postHTML + '</div>');
- 296. - cont.insertBefore(newEl, cont.firstChild);
- 297. - if (st > getXY(newEl)[1]) {
- 298. - deltaH += newEl.offsetHeight;
- 299. - }
- 300. - }
- 301. - if (ge('post_poll_id' + post_id)) {
- 302. - wall.updatePoll(post_id);
- 303. - }
- 304. - cur.feedUnreadCount++;
- 305. - if (s != 'search') {
- 306. - setStyle(newEl, {backgroundColor: '#FEFAE4'});
- 307. - animate(newEl, {backgroundColor: '#FFF'}, 6000);
- 308. - }
- 309. - if (cnodes.length > 300) {
- 310. - cont.removeChild(cnodes[300]);
- 311. - } else if (cnodes.length <= 1) {
- 312. - hide('feed_empty');
- 313. - }
- 314. - Wall.updateMentionsIndex();
- 315. - break;
- 316. -
- 317. - case 'new_post_reply':
- 318. - if (el) break;
- 319. - var cont = cur.rowsCont,
- 320. - cnodes = cont.childNodes,
- 321. - postHTML = wall.getNewPostHTML(ev, false, feed.feedPostRepl),
- 322. - newEl = se('<div class="feed_row">' + postHTML + '</div>');
- 323. -
- 324. - cont.insertBefore(newEl, cont.firstChild);
- 325. - if (st > getXY(newEl)[1]) {
- 326. - deltaH += newEl.offsetHeight;
- 327. - }
- 328. - cur.feedUnreadCount++;
- 329. - if (cnodes.length > 300) {
- 330. - cont.removeChild(cnodes[300]);
- 331. - } else if (cnodes.length <= 1) {
- 332. - hide('feed_empty');
- 333. - }
- 334. - break;
- 335. -
- 336. - case 'edit_post':
- 337. - var editEl = ge('wpt' + post_id),
- 338. - stUnder;
- 339. - if (!isVisible(el) || !editEl) break;
- 340. -
- 341. - var wasExpanded = geByClass1('wall_post_more', editEl);
- 342. - if (wasExpanded) wasExpanded = isVisible(domNS(wasExpanded));
- 343. -
- 344. - if (stUnder = (st > getXY(editEl)[1])) {
- 345. - deltaH -= editEl.offsetHeight;
- 346. - }
- 347. - var text = psr(rs(ev[3], {
- 348. - poll_hash: cur.wallTpl.poll_hash
- 349. - }));
- 350. - val(editEl, text);
- 351. - if (wasExpanded) {
- 352. - wasExpanded = geByClass1('wall_post_more', editEl);
- 353. - if (wasExpanded) wasExpanded.onclick();
- 354. - }
- 355. - if (ge('post_poll_id' + post_id)) {
- 356. - wall.updatePoll(post_id);
- 357. - }
- 358. - if (stUnder) {
- 359. - deltaH += editEl.offsetHeight;
- 360. - }
- 361. -
- 362. - setStyle(editEl, {backgroundColor: '#FEFAE4'});
- 363. - animate(editEl, {backgroundColor: '#FFF'}, 6000);
- 364. - break;
- 365. -
- 366. - case 'edit_reply':
- 367. - var reply_id = ev[3],
- 368. - editEl = ge('wpt' + reply_id);
- 369. - if (!isVisible('post' + reply_id) || !editEl) break;
- 370. -
- 371. - var wasExpanded = geByClass1('wall_reply_more', editEl);
- 372. - if (wasExpanded) wasExpanded = isVisible(domNS(wasExpanded));
- 373. -
- 374. - updH = -editEl.offsetHeight;
- 375. - updY = getXY(editEl)[1];
- 376. - val(editEl, psr(ev[4]));
- 377. - if (wasExpanded) {
- 378. - wasExpanded = geByClass1('wall_reply_more', editEl);
- 379. - if (wasExpanded) wasExpanded.onclick();
- 380. - }
- 381. - updH += editEl.offsetHeight;
- 382. - setStyle(editEl, {backgroundColor: '#FEFAE4'});
- 383. - animate(editEl, {backgroundColor: '#FFF'}, 6000);
- 384. - break;
- 385. -
- 386. - case 'post_parsed_link':
- 387. - if (!el) break;
- 388. - var btnWrap = geByClass1('wall_postlink_preview_btn_disabled', el);
- 389. - if (!btnWrap) break;
- 390. - if (intval(ev[3])) {
- 391. - removeClass(btnWrap, 'wall_postlink_preview_btn_disabled');
- 392. - } else {
- 393. - re(btnWrap);
- 394. - }
- 395. - break;
- 396. -
- 397. - case 'del_post':
- 398. - if (el) {
- 399. - if (!cur.wallMyDeleted[post_id]) {
- 400. - if (st > getXY(el)[1]) {
- 401. - deltaH -= el.offsetHeight;
- 402. - }
- 403. - revertLastInlineVideo(el);
- 404. - hide(el);
- 405. - }
- 406. - cur.options.offset--;
- 407. - }
- 408. - break;
- 409. -
- 410. - case 'res_post':
- 411. - el && cur.options.offset++;
- 412. - break;
- 413. -
- 414. - case 'new_reply':
- 415. - if (!el || cur.wallMyReplied[post_id] || ge('post' + ev[3])) break;
- 416. -
- 417. - var repliesEl = ge('replies' + post_id),
- 418. - repliesWrap = ge('replies_wrap' + post_id),
- 419. - startH = el.offsetHeight,
- 420. - oid = post_id.split('_')[0],
- 421. - adminLevel = (oid < 0) ? ((flags & 8) ? 2 : ((flags & 2) ? 1 : 0)) : 0,
- 422. - newEl = se(wall.getNewReplyHTML(ev, adminLevel)),
- 423. - highlight = false;
- 424. -
- 425. - if (!isVisible(repliesEl) || !isVisible(repliesWrap) || isVisible('reply_link' + post_id)) {
- 426. - re('reply_link' + post_id);
- 427. - show(repliesWrap, repliesEl);
- 428. - highlight = true;
- 429. - } else {
- 430. - var openEl = repliesEl.nextSibling,
- 431. - newCnt = geByClass('new_reply', repliesEl, 'div').length + 1;
- 432. -
- 433. - if (!cur.wallMyOpened[post_id]) {
- 434. - addClass(newEl, 'new_reply');
- 435. - if (!openEl || openEl.className != 'replies_open') {
- 436. - openEl = ce('div', {className: 'replies_open', onclick: wall.openNewComments.pbind(post_id)});
- 437. - repliesEl.parentNode.insertBefore(openEl, repliesEl.nextSibling);
- 438. - }
- 439. - openEl.innerHTML = getLang('wall_x_new_replies_more', Math.min(100, newCnt));
- 440. - openEl.newCnt = newCnt;
- 441. - } else {
- 442. - if (openEl && openEl.className == 'replies_open') re(openEl);
- 443. - highlight = true;
- 444. - var headerEl = geByClass1('wr_header', repliesEl, 'a'),
- 445. - shown = geByClass('reply', repliesEl, 'div').length + 1,
- 446. - total = shown;
- 447. - if (headerEl) {
- 448. - total = intval(headerEl.getAttribute('offs').split('/')[1]) + 1;
- 449. - }
- 450. - if (total > 5 || shown < total) {
- 451. - if (!headerEl) {
- 452. - repliesEl.insertBefore(headerEl = ce('a', {className: 'wr_header'}), repliesEl.firstChild);
- 453. - }
- 454. - wall.updateRepliesHeader(post_id, headerEl, shown, total);
- 455. - }
- 456. - }
- 457. - }
- 458. - if (post_id.split('_')[0] == vk.id) {
- 459. - cur.feedUnreadCount++;
- 460. - }
- 461. - repliesEl.appendChild(newEl);
- 462. - if (st > getXY(highlight ? newEl : openEl)[1]) {
- 463. - deltaH += el.offsetHeight - startH;
- 464. - }
- 465. - if (highlight) {
- 466. - setStyle(newEl, {backgroundColor: '#FEFAE4'});
- 467. - animate(newEl, {backgroundColor: '#FFF'}, 6000);
- 468. - }
- 469. - Wall.repliesSideSetup(post_id);
- 470. - Wall.updateMentionsIndex();
- 471. - break;
- 472. -
- 473. - case 'del_reply':
- 474. - if (!cur.wallMyDeleted[post_id] && el) {
- 475. - if (st > getXY(el)[1]) {
- 476. - deltaH -= el.offsetHeight;
- 477. - }
- 478. -
- 479. - var post = el.parentNode.id.match(/replies(-?\d+_\d+)/);
- 480. - revertLastInlineVideo(el);
- 481. - re(el);
- 482. - if (post) {
- 483. - Wall.repliesSideSetup(post[1]);
- 484. - }
- 485. - }
- 486. - break;
- 487. -
- 488. - case 'like_post':
- 489. - case 'like_reply':
- 490. - if (!el) break;
- 491. - var likePost = ev_type == 'like_reply' ? post_id.replace('_', '_wall_reply') : post_id,
- 492. - cntEl = ge('like_count' + likePost),
- 493. - iconEl = ge('like_icon' + likePost),
- 494. - ttEl = iconEl && iconEl.parentNode,
- 495. - cnum = intval(val(cntEl)),
- 496. - num = intval(ev[3]);
- 497. -
- 498. - animateCount(cntEl, num);
- 499. - val('like_real_count_wall' + post_id, num);
- 500. - toggleClass(iconEl, 'no_likes', num <= 0);
- 501. - if (ttEl && ttEl.tt && !isVisible(ttEl.tt.container)) {
- 502. - ttEl && ttEl.tt && ttEl.tt.destroy();
- 503. - }
- 504. - setStyle(iconEl, {opacity: '', visibility: ''});
- 505. - break;
- 506. -
- 507. - case 'vote_poll':
- 508. - if (!el) break;
- 509. - wall.updatePollResults(post_id, ev[3]);
- 510. - break;
- 511. -
- 512. - case 'new_photos_private':
- 513. - break;
- 514. - ajax.post('al_feed.php', {act: 'a_get_private', oid: ev[2], key: ev[3], hash: ev[4], num: ev[5]}, {
- 515. - onDone: function (ev) {
- 516. - if (isArray(ev) && ev.length) {
- 517. - feed.pushEvent(ev);
- 518. - }
- 519. - }
- 520. - });
- 521. - break;
- 522. -
- 523. -
- 524. - case 'new_photos':
- 525. - case 'new_tagged':
- 526. - break;
- 527. - var cont = cur.rowsCont,
- 528. - cnodes = cont.childNodes,
- 529. - thumbs = ev.splice(7, ev.length - 7),
- 530. - place = ev[2].split('_')[1] + '_' + (ev_type == 'new_photos' ? 1 : 3),
- 531. - grouped, newEl;
- 532. -
- 533. - if (grouped = geByClass1('post_photos' + place, cont, 'div')) {
- 534. - if (st > getXY(grouped)[1]) {
- 535. - deltaH -= grouped.offsetHeight;
- 536. - }
- 537. - var numEl = geByClass1('feed_photos_num', grouped, 'small'),
- 538. - thumbsEl = geByClass1('post_media', grouped, 'div'),
- 539. - num = intval(numEl.getAttribute('num')) + thumbs.length / 3,
- 540. - thumbs_html = [], i;
- 541. - val(numEl, getLang('news_x_photos', num) + ', ' + wall.getNowRelTime());
- 542. - numEl.setAttribute('num', num);
- 543. - for (i = 0; i < thumbs.length; i += 3) {
- 544. - thumbs_html.push(cur.wallTpl.photo_thumb.replace(/%photo_id%/g, thumbs[i]).replace(/%thumb%/g, thumbs[i+1]).replace(/%temp%/g, thumbs[i+2].replace(/"/g, '"')).replace('%full_id%', ev[2]));
- 545. - }
- 546. - if (thumbs_html.length >= 8) {
- 547. - thumbs_html.splice(8, thumbs_html.length - 8);
- 548. - val(thumbsEl, thumbs_html.join(' '));
- 549. - } else {
- 550. - var t = ce('div', {innerHTML: thumbs_html});
- 551. - while (t.lastChild) {
- 552. - thumbsEl.insertBefore(t.lastChild, thumbsEl.firstChild);
- 553. - if (thumbsEl.childNodes.length > 8) {
- 554. - re(thumbsEl.lastChild);
- 555. - }
- 556. - }
- 557. - }
- 558. - newEl = grouped.parentNode;
- 559. - if (cont.firstChild != newEl) {
- 560. - cont.insertBefore(newEl, cont.firstChild);
- 561. - }
- 562. - if (st > getXY(newEl)[1]) {
- 563. - deltaH += newEl.offsetHeight;
- 564. - }
- 565. - } else {
- 566. - newEl = se('<div class="feed_row">' + wall.getNewPostHTML(ev, false, feed.feedPhotoRepl.pbind(thumbs)) + '</div>');
- 567. - addClass(newEl.firstChild, 'post_photos post_photos' + place);
- 568. - cont.insertBefore(newEl, cont.firstChild);
- 569. - if (st > getXY(newEl)[1]) {
- 570. - deltaH += newEl.offsetHeight;
- 571. - }
- 572. - }
- 573. - if (s != 'search') {
- 574. - setStyle(newEl, {backgroundColor: '#FEFAE4'});
- 575. - animate(newEl, {backgroundColor: '#FFF'}, 6000);
- 576. - }
- 577. - if (cnodes.length > 300) {
- 578. - cont.removeChild(cnodes[300]);
- 579. - } else if (cnodes.length == 1) {
- 580. - hide('feed_empty');
- 581. - }
- 582. - break;
- 583. - }
- 584. - return deltaH;
- 585. - },
- 586. - feedPostRepl: function (repl, ev) {
- 587. - repl.replies = cur.wallTpl.post_replies;
- 588. - var ext = {
- 589. - full_id: ev[2],
- 590. - item_id: 'wall_' + ev[2],
- 591. - sec_name: stripHTML(ev[3]),
- 592. - date: wall.getNowRelTime(),
- 593. - del: /*ev[9] == vk.id ? cur.wallTpl.del : */cur.wallTpl.spam // always hiding from feed
- 594. - };
- 595. - if (cur.section == 'search' && cur.q) {
- 596. - var text = repl.text || '',
- 597. - q = cur.q, q_words = q.toLowerCase().split(/[\s.,:;!?()]/),
- 598. - links = [];
- 599. - text = text.replace(/<.+?>/g, function (tag) {
- 600. - links.push(tag);
- 601. - return "\x01";
- 602. - });
- 603. - var text_l = text.toLowerCase(), i, pos, word;
- 604. - for (i = q_words.length - 1; i >= 0; i--) {
- 605. - word = q_words[i];
- 606. - if (!trim(word)) continue;
- 607. - pos = 0;
- 608. - while ((pos = text_l.indexOf(word, pos)) != -1) {
- 609. - if (text.charAt(pos - 1) == String.fromCharCode(2)) {
- 610. - pos += 2;
- 611. - continue;
- 612. - }
- 613. - text = text.substr(0, pos) + "\x02" + i + "\x02" + text.substr(pos + word.length);
- 614. - text_l = text_l.substr(0, pos) + "\x02" + i + "\x02" + text_l.substr(pos + word.length);
- 615. - }
- 616. - }
- 617. - text = text.replace(/\x02(\d+)\x02/g, function (a, i) {
- 618. - return '<span class="match">' + q_words[i] + '</span>';
- 619. - });
- 620. - text = text.replace(/\x01/g, function () {
- 621. - return links.shift() || '';
- 622. - });
- 623. - ext.text = text;
- 624. - if (ev[1] == 'new_post_reply') {
- 625. - ext.date_postfix = ev[7];
- 626. - }
- 627. - }
- 628. - return ext;
- 629. - },
- 630. - feedPhotoRepl: function (thumbs, repl, ev) {
- 631. - var thumbs_html = [], i, ext, explain = '', cnt = 1;
- 632. -
- 633. - for (i = 0; i < thumbs.length; i += 3) {
- 634. - thumbs_html.push(cur.wallTpl.photo_thumb.replace(/%photo_id%/g, thumbs[i]).replace(/%thumb%/g, thumbs[i+1]).replace(/%temp%/g, thumbs[i+2].replace(/"/g, '"')));
- 635. - }
- 636. - if (ev[1] == 'new_tagged') {
- 637. - explain = cur.wallTpl.tagged_explain.replace('%explain_text%', langSex(ev[6], cur.lang.wall_user_was_tagged_on_photos));
- 638. - } else {
- 639. - cnt = ev[6];
- 640. - }
- 641. - ext = {
- 642. - text: cur.wallTpl.photos,
- 643. - reply_link: '',
- 644. - reply_box: '',
- 645. - oid: ev[2].split('_')[1],
- 646. - explain: explain,
- 647. - photos: thumbs_html.join(' '),
- 648. - replies: cur.wallTpl.photo_replies.replace('%date%', getLang('news_x_photos', cnt) + ', ' + wall.getNowRelTime()),
- 649. - count: cnt,
- 650. - full_id: ev[2],
- 651. - item_id: ev[2].replace(/^1_/, 'photos_').replace(/^3_/, 'tagged_'),
- 652. - sec_name: stripHTML(ev[3])
- 653. - };
- 654. - return ext;
- 655. - },
- 656. - reSortItems: function () {
- 657. - debugLog('resort', cur.feedToSort);
- 658. - if (!cur.feedToSort || !cur.feedToSort.length) return;
- 659. - each (cur.feedToSort, function (k, v) {
- 660. - var ph = ge('post_ph' + v), el = ge('post' + v).parentNode;
- 661. - if (ph && el) {
- 662. - ph.parentNode.insertBefore(el, ph);
- 663. - re(ph);
- 664. - }
- 665. - });
- 666. - cur.feedToSort = [];
- 667. - scrollToY(0, 0);
- 668. - },
- 669. - updateTitle: function () {
- 670. - if (!cur.idleManager) return;
- 671. - if (!cur.idleManager.isIdle) {
- 672. - cur.feedUnreadCount = 0;
- 673. - }
- 674. - document.title = (cur.feedUnreadCount ? '('+ cur.feedUnreadCount + ') ' : '') + cur.feedInitialTitle;
- 675. - },
- 676. - toggleTabsMenu: function (on) {
- 677. - var feedMenu = ge('feed_tab_add_menu');
- 678. - if (on === undefined) {
- 679. - on = !isVisible(feedMenu);
- 680. - }
- 681. - if (browser.mozilla) {
- 682. - setStyle('page_body', {overflow: on ? 'visible' : ''});
- 683. - }
- 684. - toggle(feedMenu, on);
- 685. - if (on) {
- 686. - addEvent(document, 'mousedown', function (e) {
- 687. - Feed.toggleTabsMenu(0);
- 688. - removeEvent(document, 'mousedown', arguments.callee);
- 689. - });
- 690. - }
- 691. - },
- 692. - toggleMenu: function (on) {
- 693. - var feedMenu = ge('feed_menu');
- 694. - if (on === undefined) {
- 695. - on = !isVisible(feedMenu);
- 696. - }
- 697. - val('feed_menu_toggler', on ? getLang('news_hide_menu') : getLang('news_show_menu'));
- 698. - toggle(feedMenu, on);
- 699. - if (on) {
- 700. - addEvent(document, 'mousedown', function (e) {
- 701. - var target = e.target;
- 702. - while (target) {
- 703. - if (hasClass(target, 'dd_menu_header')) {
- 704. - return true;
- 705. - }
- 706. - target = target.parentNode;
- 707. - }
- 708. - Feed.toggleMenu(0);
- 709. - removeEvent(document, 'mousedown', arguments.callee);
- 710. - });
- 711. - }
- 712. - },
- 713. - getSectionParams: function(section) {
- 714. - var params = {section: section};
- 715. - switch (section) {
- 716. - case 'news':
- 717. - case 'recommended':
- 718. - if ((params.subsection = cur.subsections[section]) === undefined) {
- 719. - delete params.subsection;
- 720. - }
- 721. - break;
- 722. -
- 723. - case 'owner':
- 724. - if (!(params.owner = cur.owner)) {
- 725. - delete params.section;
- 726. - }
- 727. - break;
- 728. -
- 729. - case 'source':
- 730. - if (!(params.source = cur.source)) {
- 731. - delete params.source;
- 732. - }
- 733. - break;
- 734. -
- 735. - case 'list':
- 736. - if (!(params.list = cur.list)) {
- 737. - delete params.list;
- 738. - }
- 739. - break;
- 740. -
- 741. - case 'notifications':
- 742. - if (!(params.source = cur.source)) {
- 743. - delete params.source;
- 744. - }
- 745. - break;
- 746. -
- 747. - case 'articles':
- 748. - params.percent = cur.periodPercent;
- 749. - if ((params.subsection = cur.subsections[section]) === undefined) {
- 750. - delete params.subsection;
- 751. - }
- 752. - break;
- 753. -
- 754. - case 'search':
- 755. - case 'photos_search':
- 756. - if (!(params.q = trim(val('feed_search')))) {
- 757. - delete params.section;
- 758. - }
- 759. - if (!(params.sort = intval(cur.searchSortMenu && cur.searchSortMenu.val()))) {
- 760. - delete params.sort;
- 761. - }
- 762. - break;
- 763. -
- 764. - case 'articles_search':
- 765. - if (!(params.q = trim(val('feed_search')))) {
- 766. - params.section = 'articles';
- 767. - }
- 768. - break;
- 769. -
- 770. - case 'comments':
- 771. - if (cur.reposts) {
- 772. - params.reposts = cur.reposts;
- 773. - }
- 774. - break;
- 775. -
- 776. - case 'mentions':
- 777. - if (cur.mentionObj && cur.mentionObj != vk.id) {
- 778. - params.obj = cur.mentionObj;
- 779. - }
- 780. - break;
- 781. - }
- 782. - debugLog(params, section);
- 783. - return params;
- 784. - },
- 785. - switchSection: function(newSection, e) {
- 786. - if (e && checkEvent(e)) {
- 787. - return true;
- 788. - }
- 789. - if (newSection == 'search' && !trim(val('feed_search'))) {
- 790. - if (cur.section != 'search') return false;
- 791. - newSection = 'news';
- 792. - }
- 793. - if (newSection == 'photos_search' && !trim(val('feed_search'))) {
- 794. - if (cur.section != 'photos_search') return false;
- 795. - newSection = 'photos';
- 796. - }
- 797. - if (newSection == 'comments') {
- 798. - cur.reposts = cur.options.reposts = '';
- 799. - }
- 800. - feed.setSection(newSection, 1);
- 801. - var params = feed.getSectionParams(newSection || 'news');
- 802. - delete cur.feedUpdateLoading;
- 803. - delete cur.isFeedLoading;
- 804. - nav.go(extend(params || {}, {'0': 'feed'}));
- 805. - return false;
- 806. - },
- 807. - setSection: function (newSection, from) {
- 808. - from = from || 0;
- 809. - cur.prevSection = cur.section;
- 810. - if (newSection == cur.section && from < 2 || !newSection) return;
- 811. -
- 812. - var splitt = !!ge('feedtab_updates') || !ge('feedtab_news');
- 813. -
- 814. - hide('feed_progress');
- 815. -
- 816. - var feedBar = ge('feed_bar'),
- 817. - curSection = cur.section,
- 818. - curTopTab = 'news',
- 819. - newTopTab = 'news',
- 820. - curTab, newTab;
- 821. -
- 822. - if (from >= 2 && newSection == cur.section) {
- 823. - curSection = cur.prevSection || cur.section;
- 824. - }
- 825. - if (curSection == 'articles_search') {
- 826. - curTab = 'articles';
- 827. - } else if (curSection == 'photos_search') {
- 828. - curTab = 'photos';
- 829. - } else if (curSection == 'list') {
- 830. - curTab = 'list' + (newSection == 'list' ? cur.prevList : cur.list);
- 831. - } else {
- 832. - curTab = curSection || '';
- 833. - }
- 834. -
- 835. - if (newSection == 'articles_search') {
- 836. - newTab = 'articles';
- 837. - } else if (newSection == 'photos_search') {
- 838. - newTab = 'photos';
- 839. - } else if (newSection == 'list') {
- 840. - newTab = 'list' + cur.list;
- 841. - } else {
- 842. - newTab = newSection || '';
- 843. - }
- 844. -
- 845. - switch (cur.section) {
- 846. - // case 'groups':
- 847. - // case 'mentions':
- 848. - // case 'articles':
- 849. - // case 'articles_search':
- 850. - // curTopTab = 'custom';
- 851. - // break
- 852. - case 'notifications':
- 853. - curTopTab = 'notifications';
- 854. - break;
- 855. -
- 856. - case 'updates':
- 857. - if (splitt) {
- 858. - curTopTab = 'updates';
- 859. - break;
- 860. - }
- 861. - case 'comments':
- 862. - curTopTab = 'comments';
- 863. - break;
- 864. -
- 865. - case 'owner': curTopTab = 'owner'; break;
- 866. - case 'source': curTopTab = 'source'; break;
- 867. - }
- 868. - switch (newSection) {
- 869. - // case 'groups':
- 870. - // case 'mentions':
- 871. - // case 'articles':
- 872. - // case 'articles_search':
- 873. - // newTopTab = 'custom';
- 874. - // break
- 875. -
- 876. - case 'notifications':
- 877. - newTopTab = 'notifications';
- 878. - break;
- 879. -
- 880. - case 'updates':
- 881. - if (splitt) {
- 882. - newTopTab = 'updates';
- 883. - break;
- 884. - }
- 885. - case 'comments':
- 886. - newTopTab = 'comments';
- 887. - break;
- 888. -
- 889. - case 'owner':
- 890. - newTopTab = 'owner';
- 891. - break;
- 892. -
- 893. - case 'source':
- 894. - newTopTab = 'source';
- 895. - break;
- 896. - }
- 897. -
- 898. - var curTabEl = curTab && curTab != newTab && geByClass1('feed_tab_' + curTab, feedBar, 'div');
- 899. - newTabEl = newTab && geByClass1('feed_tab_' + newTab, feedBar, 'div');
- 900. -
- 901. - // debugLog('replace old', curTab, curTabEl, debugEl(curTabEl));
- 902. - curTabEl && replaceClass(curTabEl, 'summary_tab_sel', 'summary_tab');
- 903. -
- 904. - // debugLog('replace new', newTab, newTabEl, debugEl(newTabEl));
- 905. - if (newTabEl) {
- 906. - var tabLink = geByTag1('a', newTabEl),
- 907. - tween = data(tabLink, 'tween');
- 908. -
- 909. - if (tween && tween.isTweening) {
- 910. - tween.stop(false);
- 911. - }
- 912. - tabLink.style.backgroundColor = '';
- 913. - replaceClass(newTabEl, 'summary_tab', 'summary_tab_sel');
- 914. - }
- 915. -
- 916. - // debugLog(curTopTab, newTopTab, from);
- 917. - if (curTopTab != newTopTab || from > 1) {
- 918. - removeClass(ge('feedtab_' + curTopTab), 'active_link');
- 919. - addClass(ge('feedtab_' + newTopTab), 'active_link');
- 920. - if (from < 2) {
- 921. - if (cur.section != 'owner') {
- 922. - hide(feed.getTypesSection() + '_filters');
- 923. - } else {
- 924. - hide('person_filters', 'group_filters');
- 925. - }
- 926. - if (curTopTab == 'news' || cur.section == 'articles') {
- 927. - hide('feed_rate_slider_wrap');
- 928. - }
- 929. - cur.section = newSection;
- 930. - return;
- 931. - }
- 932. -
- 933. - toggle('feed_news_bar', newTopTab == 'news');
- 934. - toggle('feed_comments_bar', newTopTab == 'comments');
- 935. - toggle('feed_search_bar', inArray(newSection, ['articles_search', 'articles', 'notifications', 'search', 'photos_search', 'photos']));
- 936. - if (splitt) {
- 937. - toggle('feed_bar', newTopTab != 'updates' && newTopTab != 'notifications' && newTopTab != 'comments' && newTopTab != 'source');
- 938. - } else {
- 939. - toggle('feed_bar', newTopTab != 'source');
- 940. - }
- 941. -
- 942. - toggleClass('feed_bar', 'feed_bar_extended_search', newSection == 'search');
- 943. - }
- 944. -
- 945. - if (from > 1 && newSection.indexOf('search') == -1 && val('feed_search')) {
- 946. - Feed.searchReset();
- 947. - }
- 948. -
- 949. - var oldFilters = ge(feed.getTypesSection() + '_filters');
- 950. - cur.section = newSection;
- 951. - if (from == 4) {
- 952. - Feed.searchUpdate();
- 953. - return;
- 954. - }
- 955. -
- 956. - if (cur.section != 'owner') {
- 957. - hide(oldFilters);
- 958. - } else {
- 959. - hide('person_filters', 'group_filters');
- 960. - }
- 961. -
- 962. - var newFilters = ge(feed.getTypesSection() + '_filters');
- 963. - if (newFilters) {
- 964. - show(newFilters, 'feed_menu_toggle');
- 965. - } else {
- 966. - hide('feed_menu_toggle');
- 967. - }
- 968. - toggle('feed_edit_hidden', newSection == 'news' || newSection == 'photos');
- 969. - toggle('feed_search_sort', inArray(newSection, ['search'/*, 'photos_search'*/]));
- 970. - toggle('feed_period_select', newSection == 'articles' && cur.subsection == 'top');
- 971. - toggle('feed_rate_slider_wrap', newSection == 'articles' && cur.subsection == 'top');
- 972. -
- 973. - cur.editingHide = newSection == 'notifications' ? feed.notifyCheckHideReply : false;
- 974. -
- 975. - if (inArray(newSection, ['search', 'photos_search']) && !cur.searchSortMenu) {
- 976. - stManager.add(['ui_controls.js', 'ui_controls.css'], feed.initUi);
- 977. - }
- 978. - },
- 979. - applyOptions: function(options, from) {
- 980. - from = from || 0;
- 981. - if (options.owner) {
- 982. - cur.owner = options.owner;
- 983. - }
- 984. - cur.subsection = options.subsection || '';
- 985. - feed.setSection(options.section, from);
- 986. - if (!cur.options) cur.options = {reply_names: {}};
- 987. - extend(cur.options.reply_names, options.reply_names);
- 988. - delete options.reply_names;
- 989. - extend(cur, options);
- 990. -
- 991. - cur.subsections[cur.section] = cur.subsection;
- 992. -
- 993. - if (options.loc && from == 2) {
- 994. - nav.setLoc(options.loc);
- 995. - }
- 996. - if (options.summary) {
- 997. - val('feed_summary', options.summary);
- 998. - }
- 999. - if (options.owner_name) {
- 1000. - val(geByTag1('nobr', ge('feedtab_owner')), options.owner_name);
- 1001. - }
- 1002. - if (options.source_name) {
- 1003. - val(geByTag1('nobr', ge('feedtab_source')), options.source_name);
- 1004. - }
- 1005. - if (options.htitle) {
- 1006. - cur.feedInitialTitle = document.title = replaceEntities(stripHTML(options.htitle));
- 1007. - }
- 1008. - if (options.add_queue !== undefined && options.add_queue !== null) {
- 1009. - if (from) {
- 1010. - if (options.add_queue === true) {
- 1011. - cur.add_queue = options.add_queue = false;
- 1012. - }
- 1013. - feed.getNewQKey(0);
- 1014. - }
- 1015. - if (cur.add_queue = options.add_queue) {
- 1016. - setTimeout(feed.update.pbind(0), 0);
- 1017. - }
- 1018. - } else if (from && cur.section != 'search' && cur.section != 'news' && cur.section) {
- 1019. - cur.add_queue = false;
- 1020. - }
- 1021. - if (options.q) {
- 1022. - val('feed_search', replaceEntities(options.q));
- 1023. - var query = options.q;
- 1024. - if (query.length > 30) {
- 1025. - query = trim(query.substr(0, 30)) + '...';
- 1026. - }
- 1027. - }
- 1028. - Feed.searchUpdate();
- 1029. - if (cur.section == 'comments' && !cur.reposts) {
- 1030. - toggle('comments_filters', !cur.reposts);
- 1031. - }
- 1032. - if (cur.all_shown_text) {
- 1033. - val('all_shown', cur.all_shown_text);
- 1034. - }
- 1035. - if (cur.empty_text) {
- 1036. - val('feed_empty', cur.empty_text);
- 1037. - }
- 1038. - if (cur.percent !== undefined && cur.percent !== null) {
- 1039. - feed.sliderUpdate(cur.percent, true);
- 1040. - delete cur.percent;
- 1041. - }
- 1042. - if (cur.count >= 0) {
- 1043. - re('feed_error_wrap');
- 1044. - }
- 1045. - var hasNews = geByClass1('feed_row', cur.rowsCont, 'div') || false,
- 1046. - isEmpty = !hasNews,
- 1047. - nextRows = ge('feed_rows_next');
- 1048. -
- 1049. - if (isEmpty) {
- 1050. - toggle('feed_empty', !isVisible('feed_error_wrap'));
- 1051. - hide('all_shown');
- 1052. - toggle('show_more_link', cur.count > 0 && !cur.all_shown);
- 1053. - } else if (cur.all_shown && (!nextRows || !nextRows.firstChild)) {
- 1054. - hide('feed_empty', 'show_more_link');
- 1055. - show('all_shown');
- 1056. - re(nextRows);
- 1057. - } else {
- 1058. - hide('feed_empty', 'all_shown');
- 1059. - show('show_more_link');
- 1060. - }
- 1061. -
- 1062. - if (cur.section == 'notifications' && cur.notify) {
- 1063. - var el = ge('feedback_row_' + cur.notify);
- 1064. - if (el) {
- 1065. - setTimeout(function () {el.onclick()}, browser.msie ? 100 : 0);
- 1066. - delete cur.notify;
- 1067. - }
- 1068. - }
- 1069. - Feed.applyUi();
- 1070. - },
- 1071. - showMore: function() {
- 1072. - if (cur.isFeedLoading) return;
- 1073. - cur.disableAutoMore = false;
- 1074. - var nextRows = ge('feed_rows_next');
- 1075. - if (nextRows) {
- 1076. - if (nextRows.firstChild) {
- 1077. - while (nextRows.firstChild) {
- 1078. - cur.rowsCont.insertBefore(nextRows.firstChild, nextRows);
- 1079. - }
- 1080. - }
- 1081. - re(nextRows);
- 1082. - }
- 1083. - if (cur.all_shown) {
- 1084. - hide('show_more_link');
- 1085. - show('all_shown');
- 1086. - }
- 1087. - hide('show_more');
- 1088. - show('show_more_progress');
- 1089. - var escPressed = false;
- 1090. - var tmp = function (e) { if (e.keyCode == KEY.ESC) { escPressed = true; } };
- 1091. - addEvent(document, 'keyup', tmp);
- 1092. - var params = feed.getSectionParams(cur.section || 'news');
- 1093. - extend(params, {offset: cur.offset, from: cur.from, part: 1, more: 1});
- 1094. - ajax.post('al_feed.php?sm_' + cur.section, params, {
- 1095. - onDone: function (options, rows) {
- 1096. - removeEvent(document, 'keyup', tmp);
- 1097. - if (escPressed) {
- 1098. - show('show_more');
- 1099. - hide('show_more_progress');
- 1100. - cur.disableAutoMore = true;
- 1101. - return;
- 1102. - }
- 1103. - if (rows) {
- 1104. - var au = ce('div'), row;
- 1105. - au.innerHTML = rows;
- 1106. - while (row = au.firstChild) {
- 1107. - if (!row.firstChild || !row.firstChild.id || ge(row.firstChild.id)) {
- 1108. - au.removeChild(row);
- 1109. - continue;
- 1110. - }
- 1111. - cur.rowsCont.appendChild(row);
- 1112. - }
- 1113. - }
- 1114. - show('show_more');
- 1115. - hide('show_more_progress');
- 1116. - feed.applyOptions(options);
- 1117. - setTimeout(feed.scrollCheck, 200);
- 1118. - },
- 1119. - showProgress: function () {
- 1120. - cur.isFeedLoading = true;
- 1121. - },
- 1122. - hideProgress: function () {
- 1123. - cur.isFeedLoading = false;
- 1124. - },
- 1125. - cache: 1
- 1126. - });
- 1127. - },
- 1128. - getTypesSection: function () {
- 1129. - switch (cur.section) {
- 1130. - case 'owner':
- 1131. - return (cur.owner > 0 ? 'person' : 'group');
- 1132. -
- 1133. - default:
- 1134. - return cur.section;
- 1135. - }
- 1136. - },
- 1137. - checkTabsFilter: function (option, option_id) {
- 1138. - switch (option) {
- 1139. - case 'news': return false;
- 1140. - case 'newlist': return Feed.addList();
- 1141. - default:
- 1142. - if (listMatches = option.match(/list(\d+)/)) {
- 1143. - return Feed.editList(listMatches[1]);
- 1144. - }
- 1145. - }
- 1146. -
- 1147. - var cont = ge('tabs_type_filter'),
- 1148. - filter_row = ge('filter_' + option_id),
- 1149. - my_types = cur.my_feed_types.tabs,
- 1150. - types = cur.feed_types.tabs,
- 1151. - found, pos, listMatches;
- 1152. -
- 1153. - found = (pos = indexOf(my_types, option)) != -1;
- 1154. - toggleClass(filter_row, 'checked', !found);
- 1155. - if (found) {
- 1156. - my_types.splice(pos, 1);
- 1157. - if (cur.section == option) {
- 1158. - feed.switchSection('news');
- 1159. - }
- 1160. - } else {
- 1161. - my_types.push(option);
- 1162. - }
- 1163. -
- 1164. - // Feed.toggleTabsMenu(0);
- 1165. - cur.my_feed_types.tabs = my_types;
- 1166. - var tabEl = geByClass1('feed_tab_' + option, ge('feed_news_bar'))
- 1167. - tabLink = geByTag1('a', tabEl),
- 1168. - vis = isVisible(tabEl);
- 1169. - toggleClass(tabEl, 'feed_tab_hidden', found);
- 1170. - var onComplete = function () {
- 1171. - debugLog('oncomplete ', tabEl);
- 1172. - tabLink.style.backgroundColor = '';
- 1173. - };
- 1174. - if (!vis && !found) {
- 1175. - setStyle(tabLink, {backgroundColor: '#E1E7ED'});
- 1176. - debugLog('animate ', tabEl);
- 1177. - animate(tabLink, {backgroundColor: '#F7F7F7'}, 1000, onComplete);
- 1178. - tabLink.oncompleteTO = setTimeout(onComplete, 1000);
- 1179. - } else {
- 1180. - onComplete();
- 1181. - }
- 1182. - clearTimeout(cur.saveTabsTO);
- 1183. - cur.saveTabsTO = setTimeout(Feed.saveTabs, 500);
- 1184. - },
- 1185. - checkFilter: function(option, option_id) {
- 1186. - var typesSection = feed.getTypesSection(),
- 1187. - cont = ge(typesSection + '_type_filter'),
- 1188. - filter_row = ge('filter_' + option_id),
- 1189. - my_types = cur.my_feed_types[typesSection],
- 1190. - types = cur.feed_types[typesSection],
- 1191. - found, pos;
- 1192. -
- 1193. - if (my_types === true) {
- 1194. - my_types = clone(cur.feed_types[typesSection]);
- 1195. - }
- 1196. - // debugLog(typesSection, cont, filter_row, my_types, types);
- 1197. - found = (pos = indexOf(my_types, option)) != -1;
- 1198. - if (found) {
- 1199. - my_types.splice(pos, 1);
- 1200. - removeClass(filter_row, 'checked');
- 1201. - } else {
- 1202. - my_types.push(option);
- 1203. - if (my_types.length == types.length) {
- 1204. - my_types = true;
- 1205. - }
- 1206. - addClass(filter_row, 'checked');
- 1207. - }
- 1208. -
- 1209. - cur.my_feed_types[typesSection] = my_types;
- 1210. - feed.updateTypesCookie();
- 1211. - feed.switchSection(cur.section);
- 1212. - },
- 1213. - setFilter: function (option, option_id) {
- 1214. - var typesSection = feed.getTypesSection(),
- 1215. - cont = ge(typesSection + '_type_filter'),
- 1216. - filter_row = ge('filter_' + option_id),
- 1217. - my_types = cur.my_feed_types[typesSection],
- 1218. - types = cur.feed_types[typesSection],
- 1219. - pos,
- 1220. - all_unchecked = true;
- 1221. -
- 1222. - each (geByClass('checked', cont, 'div'), function () {
- 1223. - if (this != filter_row) return (all_unchecked = false);
- 1224. - });
- 1225. - if (all_unchecked) {
- 1226. - cur.my_feed_types[typesSection] = true;
- 1227. - each(geByClass('feed_filter_row', cont, 'div'), function () {
- 1228. - addClass(this, 'checked');
- 1229. - });
- 1230. - } else {
- 1231. - each([].slice.apply(geByClass('checked', cont, 'div')), function () {
- 1232. - removeClass(this, 'checked');
- 1233. - });
- 1234. - cur.my_feed_types[typesSection] = [option];
- 1235. - addClass(filter_row, 'checked');
- 1236. - }
- 1237. -
- 1238. - feed.updateTypesCookie();
- 1239. - feed.switchSection(cur.section);
- 1240. - },
- 1241. - updateTypesCookie: function () {
- 1242. - var new_cookie = [];
- 1243. - each(cur.my_feed_types, function (section, types) {
- 1244. - if (section == 'tabs') return;
- 1245. - new_cookie.push(
- 1246. - types === true ? '*' : types.join(',')
- 1247. - );
- 1248. - });
- 1249. - setCookie('remixfeed', new_cookie.join('.'), 365);
- 1250. - },
- 1251. - flistToggleReposts: function (value, hash) {
- 1252. - ajax.post('al_feed.php', {act: 'a_toggle_reposts', value: value, hash: hash}, {
- 1253. - onDone: function () {
- 1254. - feed.getNewQKey(0);
- 1255. - }
- 1256. - });
- 1257. - },
- 1258. - switchPhotos: function (loc, el, event) {
- 1259. - if (wall.checkPostClick(el, event)) {
- 1260. - return nav.go(loc, event);
- 1261. - }
- 1262. - },
- 1263. - switchOwner: function (owner_id, owner_name, el, event) {
- 1264. - if (el && event && !wall.checkPostClick(el, event)) return;
- 1265. - var ownerLabel = geByTag1('nobr', ge('feedtab_owner')),
- 1266. - loadCb = inArray(cur.section, ['comments', 'photos']) ? false : feed.onLocalTabLoad;
- 1267. - val(ownerLabel, owner_name);
- 1268. - cur.owner = owner_id;
- 1269. - feed.setSection('owner', 1);
- 1270. - feed.go(feed.getSectionParams(cur.section), loadCb);
- 1271. - },
- 1272. - switchSearch: function () {
- 1273. - Feed.setSection('search', 4);
- 1274. - Feed.searchToggleExtended(true);
- 1275. - setTimeout(elfocus.pbind('feed_search'), 10);
- 1276. - },
- 1277. - switchList: function (list_id) {
- 1278. - cur.prevList = cur.list;
- 1279. - cur.list = list_id;
- 1280. - feed.setSection('list', 1);
- 1281. - feed.go(feed.getSectionParams(cur.section));
- 1282. - },
- 1283. - submitSearch: function (query, section) {
- 1284. - if (query === undefined) {
- 1285. - query = trim(val('feed_search'));
- 1286. - } else {
- 1287. - val('feed_search', query);
- 1288. - Feed.searchUpdate();
- 1289. - }
- 1290. - var section = (section === undefined ? cur.section : section) || '',
- 1291. - switchTo = 'search',
- 1292. - switchToBad = 'news';
- 1293. - if (!section.indexOf('articles')) {
- 1294. - switchTo = 'articles_search';
- 1295. - switchToBad = 'articles';
- 1296. - } else if (!section.indexOf('photos')) {
- 1297. - switchTo = 'photos_search';
- 1298. - switchToBad = 'photos';
- 1299. - }
- 1300. - if (!query) {
- 1301. - feed.switchSection(switchToBad);
- 1302. - return;
- 1303. - }
- 1304. - var loadCb = false; // inArray(cur.section, ['comments', 'photos', 'search', 'articles_search']) ? false : feed.onLocalTabLoad;
- 1305. - feed.setSection(switchTo, 1);
- 1306. - feed.go(feed.getSectionParams(cur.section), loadCb);
- 1307. - },
- 1308. - onLocalTabLoad: function (content) {
- 1309. - // debugLog('local tab load', content);
- 1310. - if (window.wall) wall.cancelEdit();
- 1311. - var _back = cur._back, wNode = cur.rowsCont, cur_loc = hab.getLoc();
- 1312. - var newW = ce('div', {id: 'feed_rows', innerHTML: content}), st = scrollGetY();
- 1313. - cur._back_local = {
- 1314. - content: wNode.parentNode.replaceChild(newW, wNode),
- 1315. - section: cur.prevSection || cur.section || 'news',
- 1316. - subsection: cur.subsection,
- 1317. - percent: cur.percent,
- 1318. - owner: cur.owner,
- 1319. - source: cur.source,
- 1320. - q: cur.q,
- 1321. - reposts: cur.reposts,
- 1322. - add_queue: cur.add_queue,
- 1323. - loc: cur_loc,
- 1324. - scrollTop: st,
- 1325. - back: (window._tbLink && _tbLink.loc) ? [_tbLink.loc, val(_tbLink), _tbLink.fast] : false,
- 1326. - count: cur.count,
- 1327. - offset: cur.offset,
- 1328. - from: cur.from,
- 1329. - timestamp: cur.timestamp,
- 1330. - summary: cur.summary,
- 1331. - // options: cur.options,
- 1332. - all_shown: cur.all_shown,
- 1333. - all_shown_text: cur.all_shown_text,
- 1334. - empty_text: cur.empty_text,
- 1335. - htitle: cur.feedInitialTitle
- 1336. - };
- 1337. - cur.rowsCont = newW;
- 1338. - // cur.options = {};
- 1339. - scrollToY(0, 0);
- 1340. - showBackLink(cur._back_local.loc, getLang('news_return_to_news'), true);
- 1341. - },
- 1342. - returnToFeed: function (params, back) {
- 1343. - if (!cur._back_local) {
- 1344. - return true;
- 1345. - }
- 1346. -
- 1347. - var hist = cur._back_local;
- 1348. - if (params !== false) {
- 1349. - var next_section = params.section || 'news';
- 1350. - if (hist.section != next_section) {
- 1351. - return true;
- 1352. - }
- 1353. - } else {
- 1354. - params = {section: hist.section};
- 1355. - }
- 1356. - setTimeout(function() {
- 1357. - cur._back_local = false;
- 1358. - var _back = cur._back, wNode = cur.rowsCont;
- 1359. - cur.rowsCont = wNode.parentNode.replaceChild(hist.content, wNode);
- 1360. - feed.applyOptions({
- 1361. - section: hist.section,
- 1362. - subsection: hist.subsection,
- 1363. - percent: hist.percent,
- 1364. - owner: hist.owner,
- 1365. - source: hist.source,
- 1366. - q: hist.q,
- 1367. - reposts: hist.reposts,
- 1368. - add_queue: hist.add_queue,
- 1369. - count: hist.count,
- 1370. - offset: hist.offset,
- 1371. - from: hist.from,
- 1372. - timestamp: hist.timestamp,
- 1373. - options: hist.options,
- 1374. - all_shown: hist.all_shown,
- 1375. - all_shown_text: hist.all_shown_text,
- 1376. - empty_text: hist.empty_text,
- 1377. - htitle: hist.htitle,
- 1378. - summary: hist.summary
- 1379. - }, 3);
- 1380. - if (hist.back) {
- 1381. - showBackLink(hist.back[0], hist.back[1], hist.back[2]);
- 1382. - } else {
- 1383. - showBackLink(false);
- 1384. - }
- 1385. - nav.setLoc(hist.loc);
- 1386. - if (back) {
- 1387. - scrollToY(hist.scrollTop, 0);
- 1388. - } else {
- 1389. - scrollToY(0, 0);
- 1390. - feed.go(params);
- 1391. - }
- 1392. - }, 10);
- 1393. - return false;
- 1394. - },
- 1395. - notifyShowEditReply: function (item, opts) {
- 1396. - if (cur.editing && cur.notifyReplyData && cur.notifyReplyData[cur.editing].disabled) {
- 1397. - feed.notifyCheckHideReply(cur.editing, (window.event || {}).target);
- 1398. - }
- 1399. - var replyWrap = ge(item + '_reply_wrap');
- 1400. - if (replyWrap) {
- 1401. - if (isVisible(replyWrap)) {
- 1402. - feed.notifyCheckHideReply(item, false);
- 1403. - } else {
- 1404. - show(replyWrap);
- 1405. - removeClass(ge('feedback_row_' + item).parentNode, 'feedback_row_clickable');
- 1406. - if (opts.disabled) {
- 1407. - setTimeout(function() { cur.editing = item; }, 0);
- 1408. - } else {
- 1409. - val(item + '_field', opts.greet);
- 1410. - var ta = ge(item + '_field');
- 1411. - ta && ta.autosize && ta.autosize.update();
- 1412. - setTimeout(elfocus.pbind(item + '_field'), 0);
- 1413. - }
- 1414. - feed.notifyRowOver(item, 0);
- 1415. - }
- 1416. - return;
- 1417. - }
- 1418. -
- 1419. - var itemEl = ge('feedback_row_' + item),
- 1420. - acts = '',
- 1421. - repl = {
- 1422. - hint: opts.hint || '',
- 1423. - bighint: opts.bighint || '',
- 1424. - placeholder: opts.ph,
- 1425. - submit: opts.btn,
- 1426. - greeting: opts.greet,
- 1427. - item: item
- 1428. - };
- 1429. -
- 1430. - removeClass(itemEl.parentNode, 'feedback_row_clickable');
- 1431. -
- 1432. - if (cur.notifyReplyData === undefined) {
- 1433. - cur.notifyReplyData = {};
- 1434. - }
- 1435. - cur.notifyReplyData[item] = opts;
- 1436. - if (opts.disabled) {
- 1437. - itemEl.parentNode.appendChild(se(rs(cur.options.feedback_dis, {item: item, text: opts.disabled})));
- 1438. - setTimeout(function() { cur.editing = item; }, 0);
- 1439. - } else {
- 1440. - itemEl.parentNode.appendChild(se(rs(cur.options.feedback_form, repl)));
- 1441. - var ta = ge(item + '_field');
- 1442. - ta.onfocus = function () {cur.editing = item};
- 1443. - autosizeSetup(ta, {minHeight: 31});
- 1444. - setTimeout(elfocus.pbind(ta), 0);
- 1445. - Wall.initComposer(ta, {
- 1446. - lang: {
- 1447. - introText: getLang('profile_mention_start_typing'),
- 1448. - noResult: getLang('profile_mention_not_found')
- 1449. - }
- 1450. - });
- 1451. - }
- 1452. - feed.notifyRowOver(item, 0);
- 1453. - },
- 1454. - onNotifyReplySubmit: function (item, e) {
- 1455. - var rf = ge(item + '_field');
- 1456. - if (e.keyCode == KEY.RETURN || e.keyCode == 10) {
- 1457. - var composer = data(rf, 'composer'),
- 1458. - isListVisible = composer && composer.wdd && composer.wdd.listWrap && isVisible(composer.wdd.listWrap);
- 1459. -
- 1460. - if (cur.wallTpl.reply_multiline && (e.ctrlKey || browser.mac && e.metaKey) ||
- 1461. - !cur.wallTpl.reply_multiline && !e.shiftKey && !(e.ctrlKey || browser.mac && e.metaKey) && !isListVisible) {
- 1462. - feed.notifySendReply(item);
- 1463. - return cancelEvent(e);
- 1464. - }
- 1465. - }
- 1466. - if (e.ctrlKey && e.keyCode == KEY.RETURN) {
- 1467. - var v = val(rf),
- 1468. - pos = Composer.getCursorPosition(rf);
- 1469. -
- 1470. - val(rf, v.substr(0, pos) + "\n" + v.substr(pos));
- 1471. - elfocus(rf, pos + 1, pos + 1);
- 1472. -
- 1473. - rf.autosize.update();
- 1474. - setTimeout(function () {
- 1475. - rf.autosize.update();
- 1476. - }, 0);
- 1477. - return cancelEvent(e);
- 1478. - }
- 1479. - },
- 1480. - notifySendReply: function (item) {
- 1481. - var opts = cur.notifyReplyData[item];
- 1482. - if (!opts || opts.sending) return;
- 1483. -
- 1484. - var ta = ge(item + '_field'),
- 1485. - btn = ge(item + '_btn'),
- 1486. - params = {
- 1487. - act: 'post',
- 1488. - message: trim(val(ta)),
- 1489. - from: 'feedback',
- 1490. - item: item
- 1491. - };
- 1492. - extend(params, opts.params || {});
- 1493. - if (!params.message || opts.greet && !opts.greet.indexOf(params.message)) {
- 1494. - notaBene(ta);
- 1495. - return;
- 1496. - }
- 1497. - opts.sending = 1;
- 1498. - ajax.post('al_wall.php', params, {
- 1499. - onDone: function (text, answer) {
- 1500. - delete opts.sending;
- 1501. - feed.notifyHideReply(item);
- 1502. - if (answer) {
- 1503. - var answerWrap = ge(item + '_answer_wrap');
- 1504. - val(answerWrap, answer);
- 1505. - show(answerWrap);
- 1506. - } else if (text) {
- 1507. - showDoneBox(text);
- 1508. - }
- 1509. - },
- 1510. - onFail: function () {
- 1511. - delete opts.sending;
- 1512. - },
- 1513. - showProgress: lockButton.pbind(btn),
- 1514. - hideProgress: unlockButton.pbind(btn)
- 1515. - });
- 1516. - },
- 1517. - notifyCheckHideReply: function (item, target) {
- 1518. - var opts = cur.notifyReplyData[item],
- 1519. - toggled = target === false;
- 1520. - if (!opts || opts.sending || !isVisible(item + '_reply_wrap')) return;
- 1521. -
- 1522. - var i = 8, foundGood = false;
- 1523. - do {
- 1524. - if (!target || (foundGood = (target.id == (item + '_reply_wrap') || target.id == ('feedback_row_' + item)))) {
- 1525. - break;
- 1526. - }
- 1527. - } while (i-- && (target = target.parentNode));
- 1528. - if (foundGood) {
- 1529. - return;
- 1530. - }
- 1531. - cur.editing = false;
- 1532. - if (!opts.disabled) {
- 1533. - var ta = ge(item + '_field'), msg = trim(val(ta));
- 1534. - if (msg && !opts.greet || opts.greet.indexOf(msg)) {
- 1535. - return;
- 1536. - }
- 1537. - }
- 1538. - feed.notifyHideReply(item, toggled);
- 1539. - },
- 1540. - notifyHideReply: function (item, toggled) {
- 1541. - if (cur.editing == item) {
- 1542. - cur.editing = false;
- 1543. - }
- 1544. - addClass(ge('feedback_row_' + item).parentNode, 'feedback_row_clickable');
- 1545. - hide(item + '_reply_wrap');
- 1546. - if (toggled) {
- 1547. - feed.notifyRowOver(item, 1);
- 1548. - }
- 1549. - },
- 1550. -
- 1551. - notifyRowOver: function (item, state) {
- 1552. - var el = ge('feedback_row_' + item).parentNode,
- 1553. - prevRow = el.parentNode.previousSibling,
- 1554. - over = 2,
- 1555. - likeEl;
- 1556. -
- 1557. - while (prevRow && prevRow.nodeType == 3) { // skipping text nodes
- 1558. - prevRow = prevRow.previousSibling;
- 1559. - }
- 1560. -
- 1561. - if (state && hasClass(el, 'feedback_row_clickable')) {
- 1562. - if (prevRow && prevRow.className == 'feed_row' && isVisible(geByClass1('feedback_reply_row_wrap', prevRow, 'div'))) {
- 1563. - over = 2;
- 1564. - } else if (!prevRow) {
- 1565. - over = 3;
- 1566. - }
- 1567. - addClass(el, 'feedback_row_clickable_over' + over);
- 1568. - addClass(el, 'feedback_row_clickable_over');
- 1569. - } else {
- 1570. - removeClass(el, 'feedback_row_clickable_over1');
- 1571. - removeClass(el, 'feedback_row_clickable_over2');
- 1572. - removeClass(el, 'feedback_row_clickable_over3');
- 1573. - removeClass(el, 'feedback_row_clickable_over');
- 1574. - if (likeEl = geByTag1('div', geByClass1('like_wrap', ge(el), 'div'))) {
- 1575. - var to = data(likeEl, 'likeoutTO'), tween = data(likeEl, 'tween');
- 1576. - to && clearTimeout(to);
- 1577. - tween && tween.stop(true);
- 1578. - setStyle(likeEl, {display: '', opacity: ''});
- 1579. - }
- 1580. - }
- 1581. - },
- 1582. -
- 1583. - notifyPostTooltip: function(el, post, opts) {
- 1584. - var reply = (opts || {}).reply, url = 'al_wall.php';
- 1585. -
- 1586. - if (!post.indexOf('topic_comment')) {
- 1587. - url = 'al_board.php';
- 1588. - post = post.replace('topic_comment', '');
- 1589. - } else {
- 1590. - post = post.replace('wall_reply', '').replace('wall', '');
- 1591. - }
- 1592. -
- 1593. - showTooltip(el, {
- 1594. - url: url,
- 1595. - params: extend({act: 'post_tt', post: post, self: 1, from: 'feedback'}, opts || {}),
- 1596. - slide: 15,
- 1597. - shift: [35, -3, 0],
- 1598. - ajaxdt: 100,
- 1599. - showdt: 400,
- 1600. - hidedt: 200,
- 1601. - className: 'rich wall_tt'
- 1602. - });
- 1603. - },
- 1604. - notifyDeleteOver: function(item, el, label) {
- 1605. - if (label) showTooltip(el, {text: label});
- 1606. - wall && wall._animDelX(1, item);
- 1607. - },
- 1608. - notifyDeleteOut: function (item) {
- 1609. - wall && wall._animDelX(0.6, item);
- 1610. - },
- 1611. - notifyDelete: function (item, types, hash, el, canDel) {
- 1612. - el.tt && el.tt.el && el.tt.hide();
- 1613. - ajax.post('al_feed.php', {act: 'a_feedback_delete', item: item, hash: hash, types: types, candel: canDel}, {
- 1614. - onDone: function (html) {
- 1615. - feed.notifyHideReply(item);
- 1616. - var row = ge('feedback_row_' + item).parentNode;
- 1617. - row.parentNode.replaceChild(se(html), row);
- 1618. - cur.feedEntriesHTML['fb_' + item] = row;
- 1619. - }
- 1620. - })
- 1621. - },
- 1622. - notifyUndelete: function (item, types, hash) {
- 1623. - ajax.post('al_feed.php', {act: 'a_feedback_undelete', item: item, hash: hash, types: types}, {
- 1624. - onDone: function (text) {
- 1625. - var row = ge('feedback_row_' + item);
- 1626. - row.parentNode.replaceChild(cur.feedEntriesHTML['fb_' + item], row);
- 1627. - delete cur.feedEntriesHTML['fb_' + item];
- 1628. - }
- 1629. - })
- 1630. - },
- 1631. - notifyDeleteAll: function (uid, hash, btn, item) {
- 1632. - ajax.post('al_feed.php', {act: 'a_feedback_delete_all', uid: uid, item: item, hash: hash}, {
- 1633. - onDone: function (text) {
- 1634. - showDoneBox(text);
- 1635. - // feed.go(feed.getSectionParams(cur.section), false, true);
- 1636. - var rows = cur.rowsCont, row;
- 1637. - if (rows && (row = rows.firstChild)) {
- 1638. - var startY = false,
- 1639. - st = scrollGetY(),
- 1640. - h, y;
- 1641. - do {
- 1642. - if (row.className &&
- 1643. - hasClass(row, 'feed_row') &&
- 1644. - row.firstChild &&
- 1645. - uid == row.firstChild.getAttribute('author')) {
- 1646. - h = row.offsetHeight;
- 1647. - y = row.offsetTop;
- 1648. - if (startY === false) {
- 1649. - startY = getXY(row.offsetParent)[1]
- 1650. - }
- 1651. - hide(row);
- 1652. - if (y + startY < st) {
- 1653. - st -= h;
- 1654. - scrollToY(st, 0);
- 1655. - }
- 1656. - }
- 1657. - } while (row = row.nextSibling);
- 1658. -
- 1659. - if (cur.wasScroll === 0 || cur.wasScroll > 0) {
- 1660. - cur.wasScroll = st;
- 1661. - }
- 1662. - feed.scrollCheck();
- 1663. - }
- 1664. - },
- 1665. - showProgress: lockButton.pbind(btn),
- 1666. - hideProgress: unlockButton.pbind(btn)
- 1667. - })
- 1668. - },
- 1669. -
- 1670. -
- 1671. - ignoreItem: function (post_raw, feed_raw, hash) {
- 1672. - triggerEvent(ge('post_delete' + post_raw), 'mouseout');
- 1673. - revertLastInlineVideo('post' + post_raw);
- 1674. - cur.feedEntriesHTML[post_raw] = val('post' + post_raw);
- 1675. - ajax.post('/al_feed.php?misc', {act: 'a_ignore_item', post_raw: post_raw, feed_raw: feed_raw, hash: hash}, {
- 1676. - onDone: function (html) {
- 1677. - val('post' + post_raw, html);
- 1678. - }
- 1679. - });
- 1680. - },
- 1681. - unignoreItem: function (post_raw, feed_raw, hash) {
- 1682. - ajax.post('/al_feed.php?misc', {act: 'a_unignore_item', post_raw: post_raw, feed_raw: feed_raw, hash: hash}, {
- 1683. - onDone: function () {
- 1684. - feed.restorePost(post_raw);
- 1685. - }
- 1686. - });
- 1687. - },
- 1688. - reportIgnoredItem: function (post, hash) {
- 1689. - ajax.post('al_wall.php', {act: 'spam', post: post, hash: hash}, {
- 1690. - onDone: function(msg) {
- 1691. - var r = ge('post' + post), label = r && geByClass1('feed_post_report', r, 'div');
- 1692. - val(label, msg);
- 1693. - }
- 1694. - });
- 1695. - },
- 1696. - ignoreOwner: function (post_raw, owner_id, hash, btn) {
- 1697. - if (post_raw) {
- 1698. - cur.feedEntriesHTML[post_raw + '_ignored'] = val('post' + post_raw);
- 1699. - }
- 1700. - ajax.post('/al_feed.php?misc', {act: 'a_ignore_owner', post_raw: post_raw, owner_id: owner_id, hash: hash, list: cur.section == 'list' && cur.list || 0}, {
- 1701. - onDone:function(html) {
- 1702. - val('post' + post_raw, html);
- 1703. - each(geByClass('post', cur.rowsCont), function(i,v) {
- 1704. - var ids = this.id.match(/post((-?\d+)_(-?\d+)(_\d+)?)/);
- 1705. - if (ids[1] != post_raw && (!ids[4] && ids[2] == owner_id || ids[4] && ids[3] == owner_id)) {
- 1706. - revertLastInlineVideo(this);
- 1707. - hide(this.parentNode);
- 1708. - }
- 1709. - });
- 1710. - },
- 1711. - showProgress: btn && lockButton.pbind(btn),
- 1712. - hideProgress: btn && unlockButton.pbind(btn)
- 1713. - });
- 1714. - },
- 1715. - unignoreOwner: function (post_raw, owner_id, hash) {
- 1716. - ajax.post('/al_feed.php?misc', {act: 'a_unignore_owner', post_raw: post_raw || '', owner_id: owner_id, hash: hash, list: cur.section == 'list' && cur.list || 0}, {
- 1717. - onDone:function(html) {
- 1718. - if (post_raw) {
- 1719. - val('post' + post_raw, cur.feedEntriesHTML[post_raw + '_ignored']);
- 1720. - } else {
- 1721. - val('ignore_row' + owner_id, html);
- 1722. - }
- 1723. - each(geByClass('post', cur.rowsCont), function(i,v) {
- 1724. - var ids = this.id.match(/post((-?\d+)_(-?\d+)(_\d+)?)/);
- 1725. - if (!ids[4] && ids[2] == owner_id || ids[4] && ids[3] == owner_id) {
- 1726. - show(this.parentNode);
- 1727. - }
- 1728. - });
- 1729. - }
- 1730. - });
- 1731. - },
- 1732. - unsubscribe: function (post_raw, hash) {
- 1733. - triggerEvent(ge('post_delete' + post_raw), 'mouseout');
- 1734. - cur.feedEntriesHTML[post_raw] = ge('post' + post_raw).innerHTML;
- 1735. - var matches = post_raw.match(/(\-?\d+)_(photo|video|topic|note|)(\d+)/);
- 1736. - if (!matches) return;
- 1737. - ajax.post('al_feed.php', {act: 'unsubscribe', type: {'': 24, photo: 21, video: 22, topic: 20, note: 23}[matches[2]], owner_id: matches[1], place_id: matches[3], hash: hash, feed: 1}, {
- 1738. - onDone: function(html) { ge('post' + post_raw).innerHTML = html.replace('%post_raw%', post_raw); }
- 1739. - });
- 1740. - },
- 1741. - subscribe: function (post_raw, hash) {
- 1742. - var matches = post_raw.match(/(\-?\d+)_(photo|video|topic|note|)(\d+)/);
- 1743. - if (!matches) return;
- 1744. - ajax.post('al_feed.php', {act: 'subscribe', type: {'': 24, photo: 21, video: 22, topic: 20, note: 23}[matches[2]], owner_id: matches[1], place_id: matches[3], hash: hash, feed: 1}, {
- 1745. - onDone: feed.restorePost.pbind(post_raw)
- 1746. - });
- 1747. - },
- 1748. - restorePost: function (post_raw) {
- 1749. - ge('post' + post_raw).innerHTML = cur.feedEntriesHTML[post_raw];
- 1750. - var ph_back = geByClass1('input_back', ge('post' + post_raw), 'div');
- 1751. - var ta = geByTag1('textarea', ge('post' + post_raw));
- 1752. - if (!ta) return;
- 1753. - ta.placeholder = ph_back.innerHTML;
- 1754. - ph_back.parentNode.removeChild(ph_back);
- 1755. - placeholderSetup(ta);
- 1756. - },
- 1757. - toggleReposts: function (place, rand, e) {
- 1758. - if (checkEvent(e)) return true;
- 1759. -
- 1760. - var lnk = ge('feed_reposts_more' + place + '_' + rand),
- 1761. - cont = ge('feed_reposts' + place + '_' + rand),
- 1762. - h = 0,
- 1763. - st = scrollGetY(),
- 1764. - vis = isVisible(cont);
- 1765. - if (!cont) {
- 1766. - lnk && re(lnk.parentNode.parentNode);
- 1767. - return;
- 1768. - }
- 1769. -
- 1770. - if (vis) {
- 1771. - h -= cont.offsetHeight;
- 1772. - } else {
- 1773. - (domPN(domPN(cont)) || {}).bits = 0;
- 1774. - }
- 1775. - toggle(cont, !vis);
- 1776. - val(lnk, !vis ? getLang('news_hide_reposts') : getLang('news_show_X_reposts', cont.childNodes.length));
- 1777. - if (h) {
- 1778. - scrollToY(st + h, 0);
- 1779. - }
- 1780. - return false;
- 1781. - },
- 1782. -
- 1783. - sliderScaleClick: function (e) {
- 1784. - if (checkEvent(e)) return;
- 1785. - var slider = ge('feed_rate_slider'),
- 1786. - scale = slider.parentNode,
- 1787. - maxX = (scale.clientWidth || 100) - slider.offsetWidth,
- 1788. - margin = Math.max(0, Math.min(maxX, (e.offsetX || e.layerX) - slider.offsetWidth / 2)),
- 1789. - percent = margin / maxX * 100;
- 1790. -
- 1791. - setStyle('feed_rate_slider', 'marginLeft', margin);
- 1792. - feed.sliderUpdate(percent);
- 1793. - feed.sliderClick(e);
- 1794. - },
- 1795. - sliderClick: function (e) {
- 1796. - if (checkEvent(e)) return;
- 1797. - e.cancelBubble = true;
- 1798. -
- 1799. - var startX = e.clientX || e.pageX,
- 1800. - slider = ge('feed_rate_slider'),
- 1801. - scale = slider.parentNode,
- 1802. - startMargin = slider.offsetLeft || 0,
- 1803. - maxX = (scale.clientWidth || 100) - slider.offsetWidth,
- 1804. - selectEvent = 'mousedown selectstart',
- 1805. - defPercent = intval(cur.default_percent),
- 1806. - margin, percent;
- 1807. -
- 1808. - var _temp = function (e) {
- 1809. - margin = Math.max(0, Math.min(maxX, startMargin + (e.clientX || e.pageX)- startX));
- 1810. - percent = margin / maxX * 100;
- 1811. -
- 1812. - if (Math.abs(percent - 100) < 8) {
- 1813. - percent = 100;
- 1814. - }
- 1815. - if (defPercent > 0 && Math.abs(percent - defPercent) < 3) {
- 1816. - percent = defPercent;
- 1817. - }
- 1818. - percent = intval(percent);
- 1819. - margin = maxX * percent / 100;
- 1820. - slider.style.marginLeft = margin + 'px';
- 1821. - feed.sliderUpdate(percent);
- 1822. - return cancelEvent(e);
- 1823. - }, _temp2 = function () {
- 1824. - removeEvent(document, 'mousemove', _temp);
- 1825. - removeEvent(document, 'mouseup', _temp2);
- 1826. - removeEvent(document, selectEvent, cancelEvent);
- 1827. - setStyle(bodyNode, 'cursor', '');
- 1828. - setStyle(scale, 'cursor', '');
- 1829. - feed.sliderApply();
- 1830. - };
- 1831. -
- 1832. - addEvent(document, 'mousemove', _temp);
- 1833. - addEvent(document, 'mouseup', _temp2);
- 1834. - addEvent(document, selectEvent, cancelEvent);
- 1835. - setStyle(bodyNode, 'cursor', 'pointer');
- 1836. - setStyle(scale, 'cursor', 'pointer');
- 1837. - return false;
- 1838. - },
- 1839. - sliderSelectChanged: function (e) {
- 1840. - var percent = ge(cur.section == 'articles' ? 'feed_period_select' : 'feed_rate_select').value;
- 1841. - feed.sliderUpdate(percent);
- 1842. - feed.sliderApply();
- 1843. - },
- 1844. - sliderUpdate: function (percent, upd) {
- 1845. - percent = intval(percent);
- 1846. - switch (cur.section) {
- 1847. - case 'articles':
- 1848. - case 'articles_search':
- 1849. - cur.periodPercent = percent;
- 1850. - var label = getLang('news_top_no_articles');
- 1851. - each (cur.top_periods, function (p, key) {
- 1852. - if (percent < p) {
- 1853. - return false;
- 1854. - }
- 1855. - label = key;
- 1856. - });
- 1857. - val('feed_rate_slider_label', label);
- 1858. - break;
- 1859. - }
- 1860. - if (upd) {
- 1861. - if (isVisible('feed_rate_slider_wrap')) {
- 1862. - var slider = ge('feed_rate_slider'),
- 1863. - maxX = (slider.parentNode.clientWidth || 100) - slider.offsetWidth;
- 1864. - setStyle('feed_rate_slider', 'marginLeft', maxX * percent / 100);
- 1865. - }
- 1866. - var wasSelected = false, select = ge('feed_period_select');
- 1867. - each(select && select.childNodes || [], function () {
- 1868. - if (this.tagName != 'OPTION') return;
- 1869. - if (wasSelected === false && this.value >= percent) {
- 1870. - this.setAttribute('selected', 'selected');
- 1871. - select.value = this.value;
- 1872. - wasSelected = true;
- 1873. - } else {
- 1874. - removeAttr(this, 'selected');
- 1875. - }
- 1876. - });
- 1877. - }
- 1878. - },
- 1879. - sliderApply: function () {
- 1880. - if (!cur.section.indexOf('articles')) {
- 1881. - feed.switchSection(cur.section);
- 1882. - return;
- 1883. - }
- 1884. - },
- 1885. - sliderShowProgress: function () {
- 1886. - addClass('feed_rate_slider_wrap', 'feed_rate_wait');
- 1887. - },
- 1888. - sliderHideProgress: function () {
- 1889. - removeClass('feed_rate_slider_wrap', 'feed_rate_wait');
- 1890. - },
- 1891. -
- 1892. - editHidden: function () {
- 1893. - showTabbedBox('al_settings.php', {act: 'a_edit_owners_list', list: 'feed', height: lastWindowHeight}, {stat: ['privacy.js', 'privacy.css', 'ui_controls.js', 'ui_controls.css', 'indexer.js']});
- 1894. - cur.onOListSave = feed.onHiddenSave;
- 1895. - return false;
- 1896. - },
- 1897. - onHiddenSave: function (white, black, list, options) {
- 1898. - var box = curBox(), params = {act: 'a_ignore_olist', hash: options.hash};
- 1899. - if (white.length < black.length) {
- 1900. - params.White = white.join(',');
- 1901. - } else {
- 1902. - params.Black = black.join(',');
- 1903. - }
- 1904. - ajax.post('al_feed.php', params, {
- 1905. - onDone: function(control, rules) {
- 1906. - box.hide();
- 1907. - feed.switchSection(cur.section == 'photos' ? 'photos' : 'news');
- 1908. - },
- 1909. - showProgress: box.showProgress,
- 1910. - hiderogress: box.hideProgress
- 1911. - });
- 1912. - return false;
- 1913. - },
- 1914. -
- 1915. - addList: function () {
- 1916. - Feed.toggleTabsMenu(0);
- 1917. - showTabbedBox('al_settings.php', {act: 'a_edit_owners_list', list: 'feed', list_id: -1, height: lastWindowHeight}, {
- 1918. - stat: ['privacy.js', 'privacy.css', 'ui_controls.js', 'ui_controls.css', 'indexer.js'],
- 1919. - onFail: function (text) {
- 1920. - setTimeout(showFastBox({title: getLang('global_error')}, text, getLang('global_close')).hide, 4500);
- 1921. - return true;
- 1922. - }
- 1923. - });
- 1924. - cur.onOListSave = feed.onListSave.pbind(-1);
- 1925. - return false;
- 1926. - },
- 1927. - editList: function (list_id) {
- 1928. - Feed.toggleTabsMenu(0);
- 1929. - showTabbedBox('al_settings.php', {act: 'a_edit_owners_list', list: 'feed', list_id: list_id, height: lastWindowHeight}, {stat: ['privacy.js', 'privacy.css', 'ui_controls.js', 'ui_controls.css', 'indexer.js']});
- 1930. - cur.onOListSave = feed.onListSave.pbind(list_id);
- 1931. - return false;
- 1932. - },
- 1933. - onListSave: function (list_id, white, black, list, options) {
- 1934. - var listName = val('feed_list_name');
- 1935. - if (!trim(listName)) {
- 1936. - notaBene('feed_list_name');
- 1937. - return false;
- 1938. - }
- 1939. - if (!white.length) {
- 1940. - return false;
- 1941. - }
- 1942. - var box = curBox();
- 1943. - ajax.post('al_feed.php', {
- 1944. - act: 'a_save_list',
- 1945. - hash: cur.tabs_hash,
- 1946. - White: white.join(','),
- 1947. - title: listName,
- 1948. - list_id: list_id,
- 1949. - no_reposts: ge('feed_list_reposts') && !isChecked('feed_list_reposts') ? 1 : 0
- 1950. - }, {
- 1951. - onDone: function(new_list_id) {
- 1952. - var topTab = geByClass1('feed_tab_list' + list_id, ge('feed_news_bar')),
- 1953. - filterTab = ge('filter_t_list' + list_id);
- 1954. - val(geByTag1('nobr', topTab), clean(listName));
- 1955. - val(geByClass1('feed_filter_tabs_title', filterTab), clean(listName));
- 1956. - box.hide();
- 1957. - if (list_id > 0) {
- 1958. - Feed.switchList(list_id);
- 1959. - } else {
- 1960. - nav.go({'0': 'feed', section: 'list', list: new_list_id}, null, {nocur: true});
- 1961. - }
- 1962. - },
- 1963. - showProgress: box.showProgress,
- 1964. - hiderogress: box.hideProgress
- 1965. - });
- 1966. - return false;
- 1967. - },
- 1968. - deleteList: function (list_id, force) {
- 1969. - if (list_id <= 0) {
- 1970. - return false;
- 1971. - }
- 1972. -
- 1973. - if (!force) {
- 1974. - var box = showFastBox(getLang('news_delete_list_confirm_title'), getLang('news_delete_list_confirm'), getLang('box_yes'), function () {
- 1975. - Feed.deleteList(list_id, true);
- 1976. - }, getLang('box_no'), function () {
- 1977. - box.hide();
- 1978. - });
- 1979. - return;
- 1980. - }
- 1981. - var box = curBox();
- 1982. - ajax.post('al_feed.php', extend({act: 'a_delete_list', list_id: list_id, hash: cur.tabs_hash}), {
- 1983. - onDone: function () {
- 1984. - re(geByClass1('feed_tab_list' + list_id, ge('feed_news_bar')));
- 1985. - re('filter_t_list' + list_id);
- 1986. - boxQueue.hideAll();
- 1987. - if (cur.section == 'list' && cur.list == list_id) {
- 1988. - feed.switchSection('news');
- 1989. - }
- 1990. - },
- 1991. - showProgress: box.showProgress,
- 1992. - hideProgress: box.hideProgress
- 1993. - });
- 1994. - },
- 1995. -
- 1996. - saveTabs: function () {
- 1997. - ajax.post('al_feed.php', {act: 'a_save_tabs', hash: cur.tabs_hash, tabs: cur.my_feed_types.tabs.join(',')});
- 1998. - },
- 1999. -
- 2000. - statsShow: function (e, opts) {
- 2001. - return showWiki({w: 'stats' + (cur.source || '')}, false, e);
- 2002. - },
- 2003. -
- 2004. - // scrollTop check
- 2005. - scrollCheck: function() {
- 2006. - if (!cur.idleManager || cur.isFeedLoading || cur.idleManager.isIdle || cur.disableAutoMore) return;
- 2007. - var el = ge('show_more_link');
- 2008. - if (!isVisible(el)) return;
- 2009. -
- 2010. - var ch = window.innerHeight || document.documentElement.clientHeight || bodyNode.clientHeight,
- 2011. - st = scrollGetY(), top, ntop = 0, el, nel, bits, posts = [];
- 2012. -
- 2013. - if (st + ch + 1000 > el.offsetTop) {
- 2014. - feed.showMore();
- 2015. - }
- 2016. -
- 2017. - if (
- 2018. - domPN(cur.topRow) != cur.rowsCont ||
- 2019. - (cur.topRow || {}).id == 'feed_rows_next'
- 2020. - ) {
- 2021. - cur.topRow = domFC(cur.rowsCont);
- 2022. - }
- 2023. - if (
- 2024. - !vk.id ||
- 2025. - !cur.topRow ||
- 2026. - cur.topRow.id == 'feed_rows_next' ||
- 2027. - cur.section != 'news' && cur.section != 'recommended' ||
- 2028. - ((window.curNotifier || {}).idle_manager || {}).is_idle
- 2029. - ) {
- 2030. - return;
- 2031. - }
- 2032. - for (el = domPS(cur.topRow); el && cur.topRow.offsetTop > st; el = domPS(el)) cur.topRow = el;
- 2033. - for (el = cur.topRow; el; el = nel) {
- 2034. - top = ntop ? ntop : el.offsetTop;
- 2035. - if (top >= st + ch) break;
- 2036. -
- 2037. - nel = domNS(el);
- 2038. - if ((nel || {}).id == 'feed_rows_next') nel = null;
- 2039. -
- 2040. - ntop = nel ? nel.offsetTop : top + el.offsetHeight;
- 2041. - if (ntop < st && nel) cur.topRow = nel;
- 2042. -
- 2043. - bits = el.bits || 0;
- 2044. - if (bits >= 3) continue;
- 2045. -
- 2046. - bits |= ((top >= st && top < st + ch) ? 1 : 0) | ((ntop >= st && ntop < st + ch) ? 2 : 0);
- 2047. - if (bits) {
- 2048. - el.bits = bits;
- 2049. - if (bits == 3) {
- 2050. - posts.push(Feed.postsGetRaws(el));
- 2051. - }
- 2052. - }
- 2053. - }
- 2054. - Page.postsSeen(posts);
- 2055. - },
- 2056. -
- 2057. - postsGetRaws: function(el) {
- 2058. - var f = domFC(el), c, m, p, r = /^post(-?\d+_\d+)$/, res = {};
- 2059. - if (m = f.id.match(r)) {
- 2060. - res[m[1]] = 1;
- 2061. - } else {
- 2062. - c = f.className;
- 2063. - if (m = c.match(/feed_reposts_wrap(-?\d+_\d+)/)) {
- 2064. - p = domFC(f);
- 2065. - if (hasClass(domFC(p), 'post_copy')) {
- 2066. - res[m[1]] = -1;
- 2067. - }
- 2068. - if (m = domFC(p).id.match(r)) {
- 2069. - res[m[1]] = 1;
- 2070. - }
- 2071. - if (isVisible(p = domNS(p))) {
- 2072. - for (p = domFC(p); p; p = domNS(p)) {
- 2073. - if (m = p.id.match(r)) {
- 2074. - res[m[1]] = 1;
- 2075. - }
- 2076. - }
- 2077. - }
- 2078. - } else if (m = c.match(/feed_repost(-?\d+_\d+)/)) {
- 2079. - p = domFC(f);
- 2080. - if (hasClass(p, 'post_copy')) {
- 2081. - res[m[1]] = -1;
- 2082. - }
- 2083. - if (m = p.id.match(r)) {
- 2084. - res[m[1]] = 1;
- 2085. - }
- 2086. - }
- 2087. - }
- 2088. - return res;
- 2089. - },
- 2090. - searchPreloadExtended: function () {
- 2091. - if (cur.feedSearchExtendedLoaded || cur.feedSearchExtendedPreloaded) {
- 2092. - return false;
- 2093. - }
- 2094. - cur.feedSearchExtendedPreloaded = true;
- 2095. - ajax.post('al_feed.php', {act: 'a_get_search_extended'}, {cache: 1});
- 2096. - },
- 2097. - searchToggleExtended: function (enabled) {
- 2098. - if (cur.feedSearchExtendedLoaded || !enabled) {
- 2099. - toggle('feed_search_extform', enabled);
- 2100. - return;
- 2101. - }
- 2102. - var visibleBefore = [isVisible('feed_menu_toggle'), isVisible('feed_edit_hidden'), isVisible('feed_search_sort')];
- 2103. - ajax.post('al_feed.php', {act: 'a_get_search_extended'}, {
- 2104. - stat: ['ui_controls.css', 'ui_controls.js'],
- 2105. - showProgress: function () {
- 2106. - show('feed_progress');
- 2107. - hide('feed_menu_toggle', 'feed_edit_hidden', 'feed_search_sort');
- 2108. - },
- 2109. - hideProgress: function () {
- 2110. - hide('feed_progress');
- 2111. - toggle('feed_menu_toggle', visibleBefore[0]);
- 2112. - toggle('feed_edit_hidden', visibleBefore[1]);
- 2113. - toggle('feed_search_sort', visibleBefore[2]);
- 2114. - },
- 2115. - cache: 1,
- 2116. - onDone: function (html, js) {
- 2117. - cur.feedSearchExtendedLoaded = true;
- 2118. - val('feed_search_extform', html);
- 2119. - show('feed_search_extform');
- 2120. - eval(js);
- 2121. - }
- 2122. - });
- 2123. - },
- 2124. - searchAppendTag: function (tag, pattern, nosubmit) {
- 2125. - if (!trim(tag) && !pattern) {
- 2126. - return;
- 2127. - }
- 2128. - var text = val('feed_search');
- 2129. - try {
- 2130. - text = text.replace(pattern || new RegExp('(^|\\s)' + tag + '(\\s|$)', 'i'), ' ');
- 2131. - } catch (e) {};
- 2132. - text += ' ' + tag + ' ';
- 2133. - text = text.replace(/\s{2,}/g, ' ').replace(/^\s+/, '');
- 2134. - val('feed_search', text);
- 2135. - if (trim(text).length && !nosubmit) {
- 2136. - Feed.submitSearch();
- 2137. - }
- 2138. - Feed.searchUpdate();
- 2139. - },
- 2140. - searchUnchooseGeoPoint: function () {
- 2141. - var map = ge('feed_searchext_map'),
- 2142. - x = ge('feed_searchext_map_delete_wrap');
- 2143. -
- 2144. - removeClass(map, 'feed_searchext_map_selected');
- 2145. - setStyle(map, {background: ''});
- 2146. - x && x.tt && x.tt.hide && x.tt.hide();
- 2147. - Feed.searchAppendTag('', /near:[0-9\.,\-\+]+/);
- 2148. - },
- 2149. - searchChooseGeoPoint: function () {
- 2150. - var params = {act: 'a_choose_place_box', search: 1},
- 2151. - text = val('feed_search'),
- 2152. - currentPointMatches = text.match(/near\:(\-?\d{1,3}(?:\.\d+)?)\,(\-?\d{1,3}(?:\.\d+)?)(\+{0,4})/);
- 2153. -
- 2154. - if (currentPointMatches) {
- 2155. - params.lat = floatval(currentPointMatches[1]);
- 2156. - params.lon = floatval(currentPointMatches[2]);
- 2157. - params.zoom = [8, 11, 14, 17, 20][(currentPointMatches[3] || '').length]
- 2158. - }
- 2159. - showBox('al_places.php', params, {dark: 1});
- 2160. - cur.chooseGeoPoint = function (lat, lon, zoom) {
- 2161. - var num = 0;
- 2162. - each([8, 11, 14, 17, 20], function (k, zoomLevel) {
- 2163. - if (zoom <= zoomLevel) {
- 2164. - return false;
- 2165. - }
- 2166. - num = k;
- 2167. - });
- 2168. - boxQueue.hideLast();
- 2169. - var postfix = (new Array(num + 1)).join('+');
- 2170. - var mult = Math.pow(10, 10);
- 2171. - lat = Math.round(lat * mult) / mult;
- 2172. - lon = Math.round(lon * mult) / mult;
- 2173. -
- 2174. - var map = ge('feed_searchext_map');
- 2175. - addClass(map, 'feed_searchext_map_selected');
- 2176. - setStyle(map, {
- 2177. - background: 'url(/maps?lat='+lat+'&lng='+lon+'&z='+zoom+'&'+(window.devicePixelRatio >= 2 ? 'w=260&h=160' : 'w=130&h=80')+')'
- 2178. - });
- 2179. - Feed.searchAppendTag('near:' + lat + ',' + lon + postfix, /near:[0-9\.,\-\+]+/);
- 2180. - };
- 2181. - },
- 2182. - searchChooseFilter: function (filter, item) {
- 2183. - var uiDropdown;
- 2184. - switch (filter) {
- 2185. - case 'type':
- 2186. - uiDropdown = cur.uiSearchPostType; break;
- 2187. - case 'has':
- 2188. - uiDropdown = cur.uiSearchPostAttach; break;
- 2189. - case 'likes':
- 2190. - uiDropdown = cur.uiSearchPostLikes; break;
- 2191. -
- 2192. - default: return false;
- 2193. - }
- 2194. - var sel = (uiDropdown.selectedItems() || [])[0];
- 2195. -
- 2196. - Feed.searchAppendTag(sel && intval(sel[0]) ? (filter + ':' + (sel[3] || sel[0])) : '', new RegExp(filter + ':' + '[\\S]+', 'g'));
- 2197. - },
- 2198. - searchExcludeOnChange: function (input, nosubmit) {
- 2199. - var exclude = trim(val(input));
- 2200. - if (!exclude) {
- 2201. - return false;
- 2202. - }
- 2203. - var words = trim(exclude).split(/[\s\,\.\/\!\@\#\$\%\^\&\*\(\)\-\=\:\~\;\'\"\|\}\{\+]+/),
- 2204. - len = words.length,
- 2205. - newTag = len > 0 && ('-' + words.join(' -')) || '';
- 2206. -
- 2207. - Feed.searchAppendTag(newTag, /(?:\s|^)\-\S+/g, nosubmit);
- 2208. - },
- 2209. - searchUrlOnChange: function (fromTooltip) {
- 2210. - var urlMatches = (val('feed_searchext_link') || '').match(urlInactiveExp),
- 2211. - newTag = '';
- 2212. -
- 2213. - if (urlMatches) {
- 2214. - var url = urlMatches[4] + (urlMatches[5] || ''),
- 2215. - domain = urlMatches[4],
- 2216. - newTag = radioBtns.feed_searchext_domain.val ? ('domain:' + domain) : ('url:' + url);
- 2217. - }
- 2218. - Feed.searchAppendTag(newTag, cur.feedSearchPrevLinkTag);
- 2219. - cur.feedSearchPrevLinkTag = newTag;
- 2220. -
- 2221. - if (fromTooltip) {
- 2222. - elfocus('feed_searchext_link');
- 2223. - }
- 2224. - },
- 2225. - searchContentOnChange: function () {
- 2226. - var urlMatches = (val('feed_searchext_content') || '').match(urlInactiveExp),
- 2227. - domainMatches = urlMatches && urlMatches[4].match(/(^|\.|\/\/)vkontakte\.ru|vk\.com/),
- 2228. - mediaMatches = domainMatches && urlMatches[5].match(/(?:#(photo)|^\/(photo|video|album|page|audio|wall)|z=(album|photo|video)|w=(page|wall))(-?\d+_)?(\d+)(?:\?reply=(\d+))?$/),
- 2229. - newTag = '';
- 2230. -
- 2231. - if (mediaMatches) {
- 2232. - var mediaType = mediaMatches[1] || mediaMatches[2] || mediaMatches[3] || mediaMatches[4],
- 2233. - mediaID = mediaMatches[5] + (mediaMatches[7] || mediaMatches[6]),
- 2234. - newTag = 'copy:' + mediaType + mediaID;
- 2235. - }
- 2236. - Feed.searchAppendTag(newTag, /copy\:\S+/);
- 2237. - },
- 2238. - searchUpdate: function () {
- 2239. - val(cur.searchPh, !cur.section.indexOf('photos') ? getLang('news_photo_search') : getLang('news_search'));
- 2240. -
- 2241. - toggle('feed_query_reset', trim(val('feed_search')));
- 2242. - },
- 2243. - searchClickOutside: function (event) {
- 2244. - if (val('feed_search') || !hasClass('feed_bar', 'feed_bar_extended_search') || isChecked('feed_search_extended_checkbox')) {
- 2245. - return;
- 2246. - }
- 2247. - removeClass('feed_bar', 'feed_bar_extended_search');
- 2248. - },
- 2249. - searchReset: function (fire) {
- 2250. - console.trace();
- 2251. - val('feed_search', '');
- 2252. - // removeClass('feed_bar', 'feed_bar_extended_search');
- 2253. - each ([cur.uiSearchPostType, cur.uiSearchPostAttach, cur.uiSearchPostLikes], function () {
- 2254. - this.val(0);
- 2255. - });
- 2256. - each(['feed_searchext_exclude', 'feed_searchext_link', 'feed_searchext_content'], function (k, input) {
- 2257. - val(input, '');
- 2258. - });
- 2259. - Feed.searchUnchooseGeoPoint();
- 2260. - Feed.searchUpdate();
- 2261. - if (!fire) {
- 2262. - return;
- 2263. - }
- 2264. -
- 2265. - var switchTo = 'news';
- 2266. - switch (cur.section) {
- 2267. - case 'articles':
- 2268. - case 'articles_search':
- 2269. - switchTo = 'articles';
- 2270. - break;
- 2271. -
- 2272. - case 'photos_search':
- 2273. - case 'photos':
- 2274. - switchTo = 'photos';
- 2275. - break;
- 2276. - }
- 2277. - Feed.switchSection(switchTo);
- 2278. - },
- 2279. -
- 2280. - sinceOwnerOver: function (obj, oid, name) {
- 2281. - if (!obj.nophoto) {
- 2282. - Feed.sinceOwnerBigphOver(obj, oid);
- 2283. - }
- 2284. - showTooltip(obj, {
- 2285. - text: name,
- 2286. - showdt: 0,
- 2287. - hidedt: 0,
- 2288. - black: 1,
- 2289. - shift: [12, 3, 3],
- 2290. - forcetoup: true,
- 2291. - // onCreate: function () {removeEvent(obj, 'mouseout');},
- 2292. - className: 'feed_since_owner_tt'
- 2293. - });
- 2294. - },
- 2295. - sinceOwnerBigphOver: function(obj, oid) {
- 2296. - if (!cur.lang || !cur.lang.global_photo_full_size || browser.mobile) return;
- 2297. - var o = obj.firstChild,
- 2298. - ch = cur.phCache[oid];
- 2299. - if (o.tagName != 'A' || o.className != 'feed_since_ownerph') {
- 2300. - o = obj.insertBefore(ce('a', {className: 'feed_since_ownerph', href: ch && ch._id ? ('/photo' + ch._id + '?all=1') : ('/albums' + oid), innerHTML: '<span class="feed_since_ownerph_label">' + cur.lang.global_photo_full_size + '</span>'}), obj.firstChild);
- 2301. - o.onclick = Feed.sinceOwnerBigphClick.pbind(oid, obj);
- 2302. - o._oid = oid;
- 2303. - }
- 2304. -
- 2305. - clearTimeout(o.hideTO);
- 2306. - animate(o, {marginTop: 65}, {duration: 200, transition: Fx.Transitions.easeOutCirc});
- 2307. - cur.phShown[oid] = o;
- 2308. -
- 2309. - if (!obj.onmouseout) obj.onmouseout = Feed.sinceOwnerBigphOut.pbind(obj);
- 2310. - },
- 2311. - sinceOwnerBigphOut: function(obj) {
- 2312. - var o = obj.firstChild;
- 2313. - if (!o || o.tagName != 'A' || o.className != 'feed_since_ownerph') return;
- 2314. -
- 2315. - clearTimeout(o.hideTO);
- 2316. - o.hideTO = setTimeout(function() {
- 2317. - animate(o, {marginTop: 90}, 200);
- 2318. - delete cur.phShown[o._oid];
- 2319. - }, 150);
- 2320. - },
- 2321. - sinceOwnerBigphClick: function(oid, obj, ev) {
- 2322. - if (checkEvent(ev) !== false) return;
- 2323. -
- 2324. - obj && obj.tt && obj.tt.destroy();
- 2325. - var ch = cur.phCache[oid]
- 2326. - o = cur.phShown[oid],
- 2327. - obj = domPN(o);
- 2328. -
- 2329. - if (!o || !obj) return;
- 2330. - if (ch === undefined) {
- 2331. - ch = cur.phCache[oid] = 'show';
- 2332. - ajax.post('al_photos.php', {act: 'fast_get_photo', oid: oid}, {onDone: function(res) {
- 2333. - if (!res) {
- 2334. - obj.onmouseover = function() {};
- 2335. - re(o);
- 2336. - return;
- 2337. - }
- 2338. - var sh = (cur.phCache[oid] == 'show');
- 2339. - cur.phCache[oid] = res;
- 2340. - o.href = '/photo' + res._id + '?all=1';
- 2341. - if (sh) Feed.sinceOwnerBigphClick(oid, obj);
- 2342. - }, onFail: function() {
- 2343. - obj.nophoto = true;
- 2344. - re(o);
- 2345. - return true;
- 2346. - }});
- 2347. - }
- 2348. - if (ch == 'show') {
- 2349. - return cancelEvent(ev);
- 2350. - }
- 2351. - if (!ch) return;
- 2352. - extend(ch, {
- 2353. - jumpTo: {z: 'albums' + oid}
- 2354. - });
- 2355. - return showPhoto(ch._id, 'album' + oid + '_0/rev', ch, ev);
- 2356. - },
- 2357. -
- 2358. - go: function(params, onBeforeReplace, noscroll) {
- 2359. - if (cur._back_local) {
- 2360. - var hist = cur._back_local;
- 2361. - if (hist.back) {
- 2362. - showBackLink(hist.back[0], hist.back[1], hist.back[2]);
- 2363. - } else {
- 2364. - showBackLink(false);
- 2365. - }
- 2366. - cur._back_local = false;
- 2367. - }
- 2368. - if (cur.feedReq) {
- 2369. - try {
- 2370. - cur.feedReq.abort();
- 2371. - } catch (e) {debugLog(e);}
- 2372. - }
- 2373. - var frame = 1, hideProgress = function () {
- 2374. - cur.isFeedLoading = false;
- 2375. - };
- 2376. - if (browser.msie || noscroll) {
- 2377. - frame = false;
- 2378. - hideProgress = cur.onFrameBlocksDone;
- 2379. - }
- 2380. - cur.wasScroll = noscroll ? scrollGetY() : false;
- 2381. - cur.feedReq = ajax.post('al_feed.php', extend(params, {part: 1}), {
- 2382. - onDone: function (options, rows, js) {
- 2383. - // debugLog(onBeforeReplace, options, rows.length, js);
- 2384. - revertLastInlineVideo();
- 2385. - if (window.tooltips) tooltips.destroyAll(ge('feed_rows'));
- 2386. - boxQueue.hideAll();
- 2387. - if (layers.fullhide) layers.fullhide(true);
- 2388. -
- 2389. - if (frame) {
- 2390. - ajax._framenext();
- 2391. - }
- 2392. - if (window.wall) wall.cancelEdit();
- 2393. - boxQueue.hideAll();
- 2394. - if (onBeforeReplace) {
- 2395. - onBeforeReplace(rows || '');
- 2396. - } else {
- 2397. - val(cur.rowsCont, rows || '');
- 2398. - }
- 2399. - feed.applyOptions(options, 2);
- 2400. - js && eval(js);
- 2401. -
- 2402. - if (!params.norecom) {
- 2403. - val('feed_recommends', options.recommends || '');
- 2404. - var str = '/al_feed.php#' + ajx2q({act: 'recom'});
- 2405. - if (ajaxCache[str]) delete(ajaxCache[str]);
- 2406. - cur.recomPreload = false;
- 2407. - }
- 2408. - toggle('feed_recommends', cur.section == 'news' || cur.section == 'recommended');
- 2409. -
- 2410. - // debugLog('init js:', js);
- 2411. - var _a = window.audioPlayer, aid = currentAudioId();
- 2412. - if (_a && aid && _a.showCurrentTrack) _a.showCurrentTrack();
- 2413. - setTimeout(function () {
- 2414. - var aid = currentAudioId();
- 2415. - if (_a && aid && _a.showCurrentTrack) _a.showCurrentTrack();
- 2416. - }, 100);
- 2417. - setTimeout(feed.scrollCheck, 200);
- 2418. - },
- 2419. - onFail: function () {return false;},
- 2420. - showProgress: function () {
- 2421. - hide('feed_menu_toggle', 'feed_edit_hidden', 'feed_search_sort');
- 2422. - if (cur.section == 'articles') {
- 2423. - feed.sliderShowProgress();
- 2424. - }
- 2425. - show('feed_progress');
- 2426. - cur.isFeedLoading = true;
- 2427. - },
- 2428. - frame: frame,
- 2429. - ads: 1,
- 2430. - hideProgress: hideProgress
- 2431. - });
- 2432. - },
- 2433. -
- 2434. - init: function (options) {
- 2435. - var searchEl = ge('feed_search');
- 2436. - placeholderSetup(searchEl, {back: 1});
- 2437. - cur.searchPh = geByClass1('input_back_content', ge('feed_isearch'));
- 2438. -
- 2439. - FeedSearch.init(searchEl);
- 2440. -
- 2441. - if (!window.Select) {
- 2442. - addEvent(searchEl, 'focus', function (e) {
- 2443. - stManager.add(['ui_controls.js', 'ui_controls.css'], feed.initUi);
- 2444. - removeEvent(searchEl, 'focus', arguments.callee);
- 2445. - });
- 2446. - }
- 2447. -
- 2448. - addEvent(searchEl, 'keydown focus', function (e) {
- 2449. - if (e.type == 'focus') {
- 2450. - if (cur.section.indexOf('articles') && cur.section.indexOf('photos')) {
- 2451. - addClass('feed_bar', 'feed_bar_extended_search');
- 2452. - }
- 2453. - return;
- 2454. - }
- 2455. - if (e.keyCode == KEY.RETURN && (!FeedSearch.select || FeedSearch.select.active < 0)) {
- 2456. - if (val(searchEl)) {
- 2457. - feed.submitSearch();
- 2458. - } else if (cur.section == 'search' || cur.section == 'articles_search') {
- 2459. - if (feed.returnToFeed(false, false)) {
- 2460. - feed.go(feed.getSectionParams(cur.section == 'search' ? 'news' : 'articles'));
- 2461. - }
- 2462. - }
- 2463. - searchEl.blur();
- 2464. - clearTimeout(cur.requestTimeout);
- 2465. - return cancelEvent(e);
- 2466. - }
- 2467. - setTimeout(Feed.searchUpdate, 0);
- 2468. - });
- 2469. - setTimeout(function () {
- 2470. - each(geByTag('textarea', cur.rowsCont), function() { placeholderSetup(this); });
- 2471. - }, 200);
- 2472. -
- 2473. - extend(cur, {
- 2474. - oid: options.user_id,
- 2475. - postTo: options.user_id,
- 2476. - phCache: {},
- 2477. - phShown: {},
- 2478. - subsections: {},
- 2479. - module: 'feed',
- 2480. - isFeedLoading: false,
- 2481. - wallPostCb: function () {
- 2482. - if (cur.section == 'news') {
- 2483. - setTimeout(feed.update.pbind(1), 1000);
- 2484. - } else {
- 2485. - setTimeout(feed.switchSection.pbind('news'), 1000);
- 2486. - }
- 2487. - },
- 2488. - // Decomment
- 2489. - // disableAutoMore: true,
- 2490. -
- 2491. -
- 2492. - idleManager: (function () {
- 2493. - var setIdleTo, checkIdleCb, checkIdleCbTo, onActive, onInActive, onFocusBlur, params = {
- 2494. - isIdle: false,
- 2495. - onIdle: null,
- 2496. - onUnIdle: null,
- 2497. - stop: function () {
- 2498. - removeEvent(document, 'mousemove keydown', onActive);
- 2499. - removeEvent(window, 'focus blur', onFocusBlur);
- 2500. - // clearTimeout(setIdleTo);
- 2501. - // clearTimeout(checkIdleCbTo);
- 2502. - },
- 2503. - start: function () {
- 2504. - if (browser.mobile) return;
- 2505. - // checkIdleCb = function () {
- 2506. - // if (!cur.idleManager) return;
- 2507. - // addEvent(document, 'mousemove keydown', onActive);
- 2508. - // clearTimeout(setIdleTo);
- 2509. - // setIdleTo = setTimeout(onBlur, 60000); // tab becomes idle in 30 secs without moving mouse or typing
- 2510. - // };
- 2511. - onActive = function () {
- 2512. - if (!cur.idleManager) return;
- 2513. - // clearTimeout(setIdleTo);
- 2514. - if (params.isIdle) {
- 2515. - params.isIdle = false;
- 2516. - if (params.onUnIdle) params.onUnIdle();
- 2517. - debugLog('unidle');
- 2518. - }
- 2519. - // removeEvent(document, 'mousemove keydown', onAction);
- 2520. - // clearTimeout(checkIdleCbTo);
- 2521. - // checkIdleCbTo = setTimeout(checkIdleCb, 30000);
- 2522. - };
- 2523. - onInActive = function () {
- 2524. - if (!cur.idleManager) return;
- 2525. - params.isIdle = true;
- 2526. - debugLog('idle');
- 2527. - if (params.onIdle) params.onIdle();
- 2528. - };
- 2529. - onFocusBlur = function (e) {
- 2530. - if (e.type == 'focus') {
- 2531. - onActive();
- 2532. - } else {
- 2533. - onInActive();
- 2534. - }
- 2535. - };
- 2536. - addEvent(window, 'focus blur', onFocusBlur);
- 2537. - // clearTimeout(checkIdleCbTo);
- 2538. - // checkIdleCbTo = setTimeout(checkIdleCb, 30000);
- 2539. - }
- 2540. - };
- 2541. - return params;
- 2542. - }()),
- 2543. -
- 2544. - onFrameBlocksDone: /*vkLocal(*/function () {
- 2545. - hide('feed_progress');
- 2546. - feed.sliderHideProgress();
- 2547. - toggle('feed_edit_hidden', cur.section == 'news' || cur.section == 'photos');
- 2548. - toggle('feed_search_sort', cur.section == 'search'/* || cur.section == 'photos_search'*/);
- 2549. - toggle('feed_menu_toggle', ge(feed.getTypesSection() + '_filters'));
- 2550. - toggle('feed_rate_slider_wrap', cur.section == 'articles' && cur.subsection == 'top');
- 2551. - cur.isFeedLoading = false;
- 2552. - if (cur.wasScroll === 0 || cur.wasScroll > 0) {
- 2553. - scrollToY(st, 0);
- 2554. - cur.wasScroll = false;
- 2555. - }
- 2556. - }/*)*/,
- 2557. -
- 2558. - // Cached entries' HTML
- 2559. - feedEntriesHTML: {},
- 2560. - feedUnreadCount: 0,
- 2561. - feedInitialTitle: '',
- 2562. - feedUnread: [],
- 2563. - feedToSort: []
- 2564. - });
- 2565. -
- 2566. - cur.nav.push(function(changed, old, n, opts) {
- 2567. - if (changed[0] !== undefined) return;
- 2568. - var params = clone(n);
- 2569. - delete(params[0]);
- 2570. - var splitt = !!ge('feedtab_updates') || !ge('feedtab_news');
- 2571. - if (splitt && changed.section !== undefined && ((cur.section == 'notifications' || cur.section == 'comments') &&changed.section != 'notifications' && changed.section != 'comments' || cur.section != 'notifications' && cur.section != 'comments' && (changed.section == 'notifications' || changed.section == 'comments'))) {
- 2572. - return;
- 2573. - }
- 2574. - if ((cur.section == 'owner' || cur.section == 'search') && !feed.returnToFeed(params, opts.back || opts.hist)) {
- 2575. - return false;
- 2576. - }
- 2577. - if (changed.q) {
- 2578. - feed.submitSearch(changed.q, params.section || '');
- 2579. - return false;
- 2580. - }
- 2581. - if (changed.list) {
- 2582. - Feed.switchList(changed.list);
- 2583. - return false;
- 2584. - }
- 2585. - feed.go(extend(params, opts.params || {}));
- 2586. - return false;
- 2587. - });
- 2588. - cur.idleManager.onUnIdle = feed.updateTitle;
- 2589. - cur.idleManager.onIdle = feed.reSortItems;
- 2590. -
- 2591. - cur.options = cur.options || {};
- 2592. - extend(cur.options, options);
- 2593. - feed.applyOptions(options, 3);
- 2594. -
- 2595. - // Extrnal static requred
- 2596. - // page.js
- 2597. - cur.rowsCont = options.wallCont = ge('feed_rows');
- 2598. - wall.init(options);
- 2599. -
- 2600. - // Scroll check routine
- 2601. - feed.scrollNode = browser.msie6 ? pageNode : window;
- 2602. -
- 2603. - cur._back = {
- 2604. - text: getLang('news_return_to_news'),
- 2605. - show: [feed.startEvents],
- 2606. - hide: [function () {
- 2607. - clearInterval(cur.updateInt);
- 2608. - removeEvent(feed.scrollNode, 'scroll', feed.scrollCheck);
- 2609. - removeEvent(window, 'resize', feed.scrollCheck);
- 2610. - cur.idleManager.stop();
- 2611. - clearTimeout(cur.lp_error_to);
- 2612. - // removeEvent(document, 'click', Feed.searchClickOutside);
- 2613. - }],
- 2614. - loc: false
- 2615. - };
- 2616. - feed.startEvents();
- 2617. - var _a = window.audioPlayer,
- 2618. - aid = currentAudioId();
- 2619. - if (_a && aid && _a.showCurrentTrack) _a.showCurrentTrack();
- 2620. -
- 2621. - if (browser.mobile) {
- 2622. - setStyle('feed_rate_slider_wrap', {width: 150});
- 2623. - hide('feed_rate_full');
- 2624. - show('feed_rate_mobile');
- 2625. - }
- 2626. -
- 2627. - setTimeout(feed.scrollCheck, 200);
- 2628. - },
- 2629. - startEvents: function () {
- 2630. - // IDLE manager
- 2631. - cur.idleManager.start();
- 2632. -
- 2633. - // Feed update interval
- 2634. - cur.updateInt = setInterval(function () {feed.update(0);}, 20000);
- 2635. -
- 2636. - // Scroll check routine for auto preload next news
- 2637. - addEvent(feed.scrollNode, 'scroll', feed.scrollCheck);
- 2638. - addEvent(window, 'resize', feed.scrollCheck);
- 2639. - // addEvent(document, 'click', Feed.searchClickOutside);
- 2640. - },
- 2641. - initUi: function () {
- 2642. - cur.searchSortMenu = new DropdownMenu(cur.options.search_sorts, {
- 2643. - target: ge('feed_search_sort_dd'),
- 2644. - onSelect: function (e) {
- 2645. - feed.submitSearch()
- 2646. - },
- 2647. - fadeSpeed: 0
- 2648. - });
- 2649. -
- 2650. - FeedSearch.initSelect();
- 2651. - cur.destroy.push(function () {
- 2652. - FeedSearch.destroy();
- 2653. - });
- 2654. - },
- 2655. - applyUi: function () {
- 2656. - // debugLog('apply ui');
- 2657. - if (!cur.searchSortMenu) return;
- 2658. - cur.searchSortMenu.setOptions({title: cur.search_sort[1]});
- 2659. - cur.searchSortMenu.value = cur.search_sort[0];
- 2660. - val('feed_search_sort_dd', cur.search_sort[1].replace(/\s+/g, ' '));
- 2661. - },
- 2662. - mentionClick: function(el, ev) {
- 2663. - var post = ((el.getAttribute('mention') || '').match(/^bp(-?\d+_\d+)$/) || {})[1];
- 2664. - if (!post) return nav.go(el, ev);
- 2665. -
- 2666. - post = post.split('_');
- 2667. - for (; el; el = el.parentNode) {
- 2668. - var m = (el.id || '').match(/^replies(-?\d+_topic\d+)$/);
- 2669. - if (m) {
- 2670. - var topic = m[1].split('_');
- 2671. - if (topic[0] == post[0]) {
- 2672. - return wall.showReply(m[1], post[0] + 'topic_' + post[1]);
- 2673. - } else {
- 2674. - break;
- 2675. - }
- 2676. - }
- 2677. - }
- 2678. - return nav.go(el, ev);
- 2679. - },
- 2680. -
- 2681. - recomPreload: function() {
- 2682. - if (cur.recomPreload) return;
- 2683. - cur.recomPreload = true;
- 2684. - ajax.post('/al_feed.php', {act: 'recom'}, {cache: 1});
- 2685. - },
- 2686. - recomMore: function(ev) {
- 2687. - if (checkEvent(ev) !== false) return;
- 2688. - var cont = ge('feed_recom_rows'), lnk = ge('feed_recom_more');
- 2689. - if (cont.childNodes.length > 2) {
- 2690. - var old = getSize(cont)[1];
- 2691. - while (cont.childNodes.length > 2) {
- 2692. - cont.removeChild(cont.lastChild);
- 2693. - }
- 2694. - scrollToY(0, 0);
- 2695. - hide(lnk.firstChild.nextSibling);
- 2696. - show(lnk.firstChild);
- 2697. - return cancelEvent(ev);
- 2698. - }
- 2699. -
- 2700. - ajax.post('/al_feed.php', {act: 'recom'}, {cache: 1, onDone: function(rows) {
- 2701. - hide(lnk.firstChild);
- 2702. - show(lnk.firstChild.nextSibling);
- 2703. - var e = ce('div', {innerHTML: rows}), c = ge('feed_recom_rows'), el;
- 2704. - while (el = e.firstChild) {
- 2705. - if (ge(el.id)) {
- 2706. - re(el);
- 2707. - } else {
- 2708. - c.appendChild(el);
- 2709. - }
- 2710. - }
- 2711. - if (c.childNodes.length % 2) re(c.lastChild);
- 2712. - }, showProgress: function() {
- 2713. - hide(lnk.firstChild);
- 2714. - show(lnk.lastChild);
- 2715. - }, hideProgress: function() {
- 2716. - show(lnk.firstChild);
- 2717. - hide(lnk.lastChild);
- 2718. - }});
- 2719. - return cancelEvent(ev);
- 2720. - },
- 2721. - recomSubscribe: function(oid, btn) {
- 2722. - ajax.post('/al_feed.php', {act: 'subscr', oid: oid, from: nav.objLoc.section, hash: val('feed_recom_hash')}, {
- 2723. - onDone: function(text) {
- 2724. - btn.parentNode.parentNode.replaceChild(ce('div', {className: 'feed_recom_done fl_l', innerHTML: text}), btn.parentNode);
- 2725. - if (nav.objLoc.section != 'recommended') {
- 2726. - nav.go(nav.objLoc, false, {params: {norecom: 1}});
- 2727. - }
- 2728. - },
- 2729. - showProgress: lockButton.pbind(btn),
- 2730. - hideProgress: unlockButton.pbind(btn)
- 2731. - });
- 2732. - }
- 2733. -
- 2734. - };
- 2735. - window.feed = Feed;
- 2736. -
- 2737. - FeedSearch = {
- 2738. - init: function (input, options) {
- 2739. - return false;
- 2740. - var self = this;
- 2741. - this.input = input;
- 2742. - this.cont = input.parentNode.parentNode;
- 2743. - var resultContainer = ce('div', {className: 'results_container', innerHTML: '<div class="result_list"></div><div class="result_list_shadow"><div class="shadow1"></div><div class="shadow2"></div></div>'});
- 2744. - this.cont.appendChild(resultContainer);
- 2745. - this.resultList = geByClass('result_list', resultContainer)[0];
- 2746. - this.resultListShadow = geByClass('result_list_shadow', resultContainer)[0];
- 2747. - hide(this.resultList, this.resultListShadow);
- 2748. -
- 2749. - if (browser.chrome) this.resultList.style.opacity = 1;
- 2750. - else if (!browser.safari) setStyle(this.resultListShadow, 'top', browser.mozilla ? 0 : (browser.msie && browser.version < 8) ? 0 : -1);
- 2751. - this.resultList.style.width = this.resultListShadow.style.width = resultContainer.style.width = '273px';
- 2752. -
- 2753. - this.initSelect();
- 2754. -
- 2755. - addEvent(input, 'keyup click mouseup', function (e) {
- 2756. - if (!self.select) return;
- 2757. - if (self.select.isVisible() && self.select.active > -1) {
- 2758. - if (inArray(e.keyCode, [KEY.UP, KEY.DOWN, KEY.PAGEUP, KEY.PAGEDOWN, KEY.RETURN])) return cancelEvent(e);
- 2759. - }
- 2760. - clearTimeout(cur.requestTimeout);
- 2761. - var term = val(input);
- 2762. - self.currentTerm = term;
- 2763. - var section = cur.section;
- 2764. - if (!term) {
- 2765. - self.select.hide();
- 2766. - return;
- 2767. - }
- 2768. - cur.requestTimeout = setTimeout(function() {
- 2769. - ajax.post('/hints.php?act=a_feed_hints', {q: term, section: section}, {
- 2770. - onDone: function (data) {
- 2771. - if (self.currentTerm === term) self.showSelectList(term, data);
- 2772. - }, cache: 1
- 2773. - });
- 2774. - }, 300);
- 2775. - });
- 2776. - addEvent(input, 'blur', function () {
- 2777. - clearTimeout(cur.requestTimeout);
- 2778. - delete self.currentTerm;
- 2779. - if (!self.select) return;
- 2780. - self.select.hide();
- 2781. - });
- 2782. - addEvent(input, 'keypress keydown', function (e) {
- 2783. - if (!self.select) return;
- 2784. - if (!self.select || self.select.active < 0) return true;
- 2785. -
- 2786. - if (e.keyCode == KEY.RETURN || e.keyCode == 10) {
- 2787. - if (self.select && self.select.isVisible()) {
- 2788. - triggerEvent(document, e.type, e);
- 2789. - return cancelEvent(e);
- 2790. - }
- 2791. - } else if (e.keyCode == KEY.SPACE) {
- 2792. - var el = self.select.list.childNodes[self.select.active], id = el ? el.getAttribute('val') : '', item;
- 2793. - each(self.lastItems, function () {
- 2794. - if (this[0] == id) {
- 2795. - item = this;
- 2796. - }
- 2797. - });
- 2798. - if (!item) return;
- 2799. - val(input, item[3] + ' ');
- 2800. - focusAtEnd(input);
- 2801. - return cancelEvent(e);
- 2802. - }
- 2803. - return true;
- 2804. - });
- 2805. - },
- 2806. - initSelect: function () {
- 2807. - return false;
- 2808. - if (this.select || !window.Select || !window._ui) return;
- 2809. - if (!this.resultList || !this.resultListShadow) {
- 2810. - debugLog('no containers', this.resultList, this.resultListShadow);
- 2811. - return;
- 2812. - }
- 2813. - this.guid = _ui.reg(this);
- 2814. - this.select = new Select(this.resultList, this.resultListShadow, {
- 2815. - selectFirst: false,
- 2816. - onItemSelect: this.onItemSelect.bind(this),
- 2817. - onShow: _ui.sel.pbind(this.guid),
- 2818. - onHide: _ui.sel.pbind(false),
- 2819. - cycle: true
- 2820. - });
- 2821. - this.select.hide();
- 2822. - },
- 2823. - showSelectList: function (term, items) {
- 2824. - var self = this;
- 2825. - if (!this.select) return;
- 2826. - items = isArray(items) && items.length ? items : [];
- 2827. - if (!items.length) {
- 2828. - self.select.hide();
- 2829. - return;
- 2830. - }
- 2831. - this.select.clear();
- 2832. - this.lastItems = items;
- 2833. - this.select.content(items);
- 2834. - this.select.show();
- 2835. - },
- 2836. - onItemSelect: function(id) {
- 2837. - if (!this.select) return;
- 2838. - this.select.hide();
- 2839. - var item;
- 2840. - each(this.lastItems, function () {
- 2841. - if (this[0] == id) {
- 2842. - item = this;
- 2843. - }
- 2844. - });
- 2845. - if (!item) return;
- 2846. - val(this.input, '');
- 2847. - feed.switchOwner(item[4], item[3]);
- 2848. - this.input.blur();
- 2849. - },
- 2850. - onEvent: function(e) {
- 2851. - if (e.type == (browser.opera || browser.mozilla ? 'keypress' : 'keydown')) {
- 2852. - this.select.handleKeyEvent(e);
- 2853. - }
- 2854. - },
- 2855. - destroy: function (prevCur) {
- 2856. - cleanElems(this.resultList, this.resultListShadow, this.input);
- 2857. - clearTimeout(prevCur ? prevCur.requestTimeout : cur.requestTimeout);
- 2858. - if (this.select) {
- 2859. - this.select.destroy();
- 2860. - delete this.select;
- 2861. - }
- 2862. - if (this.resultList) {
- 2863. - re(this.resultList.parentNode);
- 2864. - }
- 2865. - delete this.lastItems;
- 2866. - this.inited = false;
- 2867. - }
- 2868. - }
- 2869. -
- 2870. - try{stManager.done('feed.js');}catch(e){}
- ------
Advertisement
Add Comment
Please, Sign In to add comment