Hormold

VK Change (#1391098506)

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