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