Hormold

VK Change (#1383730204)

Nov 6th, 2013
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 76.68 KB | None | 0 0
  1. Файл - friends.js (Старый размер - 62654 | Новый - 0):
  2. 0.  - var Friends = {
  3. 1.  -   init: function(obj, friendsTpl, commonTpl) {
  4. 2.  -     extend(cur, {
  5. 3.  -       fSearch: ge('s_search'),
  6. 4.  -       module: 'friends',
  7. 5.  -       fListEl: ge('friends_list'),
  8. 6.  -       showMore: ge('show_more'),
  9. 7.  -       pageEnd: ge('page_end'),
  10. 8.  -       fContent: ge('list_content'),
  11. 9.  -       friendsTpl: friendsTpl,
  12. 10.  -       commonTpl: commonTpl,
  13. 11.  -       savedMasks: {},
  14. 12.  -       bigphCache: {},
  15. 13.  -       bigphShown: {}
  16. 14.  -     });
  17. 15.  -     extend(cur, obj);
  18. 16.  -
  19. 17.  -     if (!cur.secData) {
  20. 18.  -       cur.secData = {};
  21. 19.  -     }
  22. 20.  -
  23. 21.  -     cur.curList = cur.section;
  24. 22.  -
  25. 23.  -     placeholderSetup(cur.fSearch, {back: true})
  26. 24.  -     elfocus(cur.fSearch);
  27. 25.  -
  28. 26.  -     Friends.scrollNode = browser.msie6 ? pageNode : window;
  29. 27.  -
  30. 28.  -     addEvent(Friends.scrollNode, 'scroll', Friends.scrollResize);
  31. 29.  -
  32. 30.  -     setTimeout(function() {
  33. 31.  -       cur.destroy.push(function() {
  34. 32.  -         clearTimeout(cur.resizeTimeout);
  35. 33.  -         removeEvent(Friends.scrollNode, 'scroll', Friends.scrollResize);
  36. 34.  -       });
  37. 35.  -     }, 0);
  38. 36.  -
  39. 37.  -     cur.friends = {};
  40. 38.  -
  41. 39.  -     if (!cur.silent) {
  42. 40.  -       this.indexAll(function() {
  43. 41.  -         if (cur.section.substr(0, 4) == 'list') {
  44. 42.  -           cur.friendsList[cur.section] = Friends.filter(cur.friendsList['all'], cur.section);
  45. 43.  -         }
  46. 44.  -         if (!cur.friendsList[cur.section] || !cur.friendsList[cur.section].length) {
  47. 45.  -           if (cur.section != 'requests' || !cur.suggCount) {
  48. 46.  -             show('not_found');
  49. 47.  -           }
  50. 48.  -         }
  51. 49.  -       });
  52. 50.  -     }
  53. 51.  -
  54. 52.  -     cur.timeouts = {};
  55. 53.  -
  56. 54.  -     cur.nav.push((function(changed, old, n) {
  57. 55.  -       if ('id' in changed || 'sort' in changed || isEmpty(changed)) {
  58. 56.  -         return true;
  59. 57.  -       }
  60. 58.  -       if (n[0] == 'friends' || n[0] == 'al_friends.php' && (changed.section)) {
  61. 59.  -         var s = changed.section;
  62. 60.  -
  63. 61.  -         if ((s == 'requests' || s == 'all_requests' || s == 'out_requests') && !cur.requestsCount && !cur.suggCount && !cur.allRequestsCount && !cur.outRequestsCount) {
  64. 62.  -           return nav.change({section: 'all'});
  65. 63.  -         } else if (s == 'requests' && !cur.requestsCount && !cur.suggCount) {
  66. 64.  -           return nav.change({section: cur.allRequestsCount ? 'all_requests' : 'out_requests'});
  67. 65.  -         } else if (s == 'all_requests' && !cur.allRequestsCount) {
  68. 66.  -           return nav.change({section: cur.requestsCount || cur.suggCount ? 'requests' : 'out_requests'});
  69. 67.  -         } else if (s == 'out_requests' && !cur.outRequestsCount) {
  70. 68.  -           return nav.change({section: 'all'});
  71. 69.  -         }
  72. 70.  -
  73. 71.  -         if (s == 'all' || s == 'online' || s == 'requests' || s == 'all_requests' || s == 'out_requests') {
  74. 72.  -           __adsUpdate('force');
  75. 73.  -         }
  76. 74.  -         if (s == 'all_requests' && !('sort' in changed) && !cur.sortByDate) {
  77. 75.  -           delete n.sort;
  78. 76.  -           setTimeout(Friends.changeSummary, 0);
  79. 77.  -         }
  80. 78.  -         this.section(n.section, (function() {
  81. 79.  -           this.changeSummary();
  82. 80.  -           nav.setLoc(n);
  83. 81.  -         }).bind(this));
  84. 82.  -         return false;
  85. 83.  -       } else if (n[0] == 'al_friends.php' || n[0] == 'friends') {
  86. 84.  -         return false;
  87. 85.  -       }
  88. 86.  -     }).bind(this));
  89. 87.  -
  90. 88.  -     if (cur.silent) {
  91. 89.  -       addClass(cur.showMore, 'load_more');
  92. 90.  -       ajax.post('al_friends.php', {act: 'load_friends_silent', id: cur.oid, gid: cur.gid, sort: nav.objLoc.sort}, {
  93. 91.  -         onDone: (function(data, universities, filters) {
  94. 92.  -           removeClass(cur.showMore, 'load_more');
  95. 93.  -           cur.silent = false;
  96. 94.  -           var obj = eval('('+data+')');
  97. 95.  -           // load friends json
  98. 96.  -           if (!obj) {
  99. 97.  -             return;
  100. 98.  -           }
  101. 99.  -           cur.universities = universities;
  102. 100.  -           for (var i in obj) {
  103. 101.  -             cur.friendsList[i] = obj[i];
  104. 102.  -           }
  105. 103.  -           this.indexAll(function() {
  106. 104.  -             //Friends.selectTabAndSection(cur.section);
  107. 105.  -             if (cur.section.substr(0, 4) == 'list') {
  108. 106.  -               cur.friendsList[cur.section] = Friends.filter(cur.friendsList['all'], cur.section);
  109. 107.  -             }
  110. 108.  -             (cur.onSilentLoad || Friends.showMore)();
  111. 109.  -           });
  112. 110.  -           if (filters.cities) {
  113. 111.  -             stManager.add(['ui_controls.js', 'ui_controls.css'], function() {
  114. 112.  -               cur.cityFilter.setData(filters.cities);
  115. 113.  -               if (cur.cityFilterOpened) {
  116. 114.  -                 hide('friends_fltr_progress');
  117. 115.  -                 cur.cityFilter.showDefaultList()
  118. 116.  -               }
  119. 117.  -             });
  120. 118.  -           }
  121. 119.  -         }).bind(this), local: 1
  122. 120.  -       });
  123. 121.  -     }
  124. 122.  -
  125. 123.  -   },
  126. 124.  -   indexAll: function(callback) {
  127. 125.  -     var all = cur.friendsList['all'];
  128. 126.  -
  129. 127.  -     cur.friendsIndex = new vkIndexer(all, function(obj) {
  130. 128.  -       var mid = parseInt(obj[0]);
  131. 129.  -       if (cur.friends && mid) {
  132. 130.  -         cur.friends[mid] = obj;
  133. 131.  -       }
  134. 132.  -       return obj[5] || '';
  135. 133.  -     }, function() {
  136. 134.  -       if (!cur.silent) {
  137. 135.  -         cur.friendsList['online'] = Friends.filter(all, 'online');
  138. 136.  -         if (cur.section == 'common') {
  139. 137.  -           cur.friendsList['common'] = Friends.filter(all, 'common');
  140. 138.  -         }
  141. 139.  -         if (callback) {
  142. 140.  -           callback();
  143. 141.  -         }
  144. 142.  -       }
  145. 143.  -       Friends.initBackFunc();
  146. 144.  -     });
  147. 145.  -
  148. 146.  -     if (cur.section == 'phonebook') {
  149. 147.  -       Friends.indexPhone();
  150. 148.  -     }
  151. 149.  -   },
  152. 150.  -   indexPhone: function() {
  153. 151.  -     cur.phoneIndex = new vkIndexer(cur.friendsList['phonebook'], function(obj) {
  154. 152.  -       var mobile = obj[10][0] || '';
  155. 153.  -       var home = obj[10][1] || '';
  156. 154.  -       return [obj[5], mobile, mobile.replace(/[^0-9\+]/g, ''), home, home.replace(/[^0-9\+]/g, '')].join(' ');
  157. 155.  -     });
  158. 156.  -   },
  159. 157.  -   initBackFunc: function() {
  160. 158.  -     cur._back = {show: [function() {
  161. 159.  -       addEvent(Friends.scrollNode, 'scroll', Friends.scrollResize);
  162. 160.  -     }], hide: [function() {
  163. 161.  -       if (Friends.searchTimout) {
  164. 162.  -         clearTimeout(Friends.searchTimout);
  165. 163.  -       }
  166. 164.  -       if (cur.timeouts) {
  167. 165.  -         for (var i in cur.timeouts) {
  168. 166.  -           clearTimeout(cur.timeouts);
  169. 167.  -         }
  170. 168.  -       }
  171. 169.  -       for (var i in cur.bigphShown) {
  172. 170.  -         animate(cur.bigphShown[i], {marginTop: 100}, 0);
  173. 171.  -       }
  174. 172.  -       cur.bigphShown = {};
  175. 173.  -       removeEvent(Friends.scrollNode, 'scroll', Friends.scrollResize);
  176. 174.  -     }], text: cur.backLang};
  177. 175.  -   },
  178. 176.  -   switchTab: function(section, ev) {
  179. 177.  -     var param = {'0':'friends', section: section};
  180. 178.  -     return checkEvent(ev) || nav.change(param);
  181. 179.  -   },
  182. 180.  -   filter: function(arr, type) {
  183. 181.  -     var len = (arr) ? arr.length : 0;
  184. 182.  -     var res = [];
  185. 183.  -     if (type.substr(0, 4) == 'list') {
  186. 184.  -       var listNum = parseInt(type.substr(4));
  187. 185.  -       type = 'list';
  188. 186.  -     }
  189. 187.  -     for (var i = 0; i < len; i++) {
  190. 188.  -       var obj = arr[i];
  191. 189.  -       if (cur.filterIds && !cur.filterIds[parseInt(obj[0])]) {
  192. 190.  -         continue;
  193. 191.  -       }
  194. 192.  -       switch (type) {
  195. 193.  -         case 'online':
  196. 194.  -           if (intval(obj[4])) {
  197. 195.  -             res.push(obj);
  198. 196.  -           }
  199. 197.  -           break;
  200. 198.  -         case 'common':
  201. 199.  -           if (cur.commonCount && obj[10]) {
  202. 200.  -             res.push(obj);
  203. 201.  -           }
  204. 202.  -           break;
  205. 203.  -         case 'list':
  206. 204.  -           if (parseInt(obj[6]) & (1 << listNum)) {
  207. 205.  -             res.push(obj);
  208. 206.  -           }
  209. 207.  -           break;
  210. 208.  -         default:
  211. 209.  -           res.push(obj);
  212. 210.  -           break;
  213. 211.  -       }
  214. 212.  -     }
  215. 213.  -     return res;
  216. 214.  -   },
  217. 215.  -   loadMore: function(start, end) {
  218. 216.  -     var section = cur.section;
  219. 217.  -     var list = cur.curList;
  220. 218.  -     var curData = cur.secData[section];
  221. 219.  -     if (curData.loading) {
  222. 220.  -       return;
  223. 221.  -     }
  224. 222.  -     curData.loading = true;
  225. 223.  -     addClass(cur.showMore, 'load_more');
  226. 224.  -     show(cur.showMore);
  227. 225.  -     ajax.post('/friends', extend({
  228. 226.  -       act: 'get_section_friends',
  229. 227.  -       section: section,
  230. 228.  -       offset: start,
  231. 229.  -       gid: cur.gid,
  232. 230.  -       sort: nav.objLoc.sort,
  233. 231.  -       sugg_rev: cur.suggRev
  234. 232.  -     }, cur.filter), {
  235. 233.  -       onDone: (function(data, preload) {
  236. 234.  -         removeClass(cur.showMore, 'load_more');
  237. 235.  -         var response = eval('('+data+')')
  238. 236.  -         if (!cur.friendsList) {
  239. 237.  -           return;
  240. 238.  -         }
  241. 239.  -         if (!cur.friendsList[list]) {
  242. 240.  -           cur.friendsList[list] = [];
  243. 241.  -         }
  244. 242.  -         Array.prototype.push.apply(cur.friendsList[list], response[section]);
  245. 243.  -         if (list == 'requests' && response['sugg_requests']) {
  246. 244.  -           Array.prototype.push.apply(cur.friendsList['sugg_requests'], response['sugg_requests']);
  247. 245.  -         }
  248. 246.  -         this.showMore(false, start, end);
  249. 247.  -         curData.loading = false;
  250. 248.  -         curData.preload = preload;
  251. 249.  -       }).bind(this)
  252. 250.  -     });
  253. 251.  -   },
  254. 252.  -   canSugSwitch: function(list) {
  255. 253.  -     if (!list) {
  256. 254.  -       return cur.suggCount ? true : true;
  257. 255.  -     }
  258. 256.  -     if (cur.suggRev) {
  259. 257.  -       return list.length >= cur.suggCount || !cur.secData.requests.preload;
  260. 258.  -     } else {
  261. 259.  -       return list.length >= cur.requestsCount || !cur.secData.requests.preload;
  262. 260.  -     }
  263. 261.  -   },
  264. 262.  -   showMore: function(clear, start, end, plain) {
  265. 263.  -     if (!cur.friendsList) {
  266. 264.  -       return false;
  267. 265.  -     }
  268. 266.  -     var clist = cur.curList;
  269. 267.  -     var list = cur.friendsList[clist];
  270. 268.  -     if (start == undefined) {
  271. 269.  -       start = cur.shownFriends;
  272. 270.  -     }
  273. 271.  -     if (end == undefined) {
  274. 272.  -       end = cur.shownFriends + cur.friendsPerPage;
  275. 273.  -     }
  276. 274.  -     if (cur.section == 'requests') {
  277. 275.  -       if (cur.suggRev) {
  278. 276.  -         list = (cur.friendsList['sugg_requests'] || []).slice();
  279. 277.  -         if (Friends.canSugSwitch(list)) {
  280. 278.  -           var suggSwitch = parseInt(cur.suggCount);
  281. 279.  -           list.push.apply(list, cur.friendsList[cur.curList] || []);
  282. 280.  -         }
  283. 281.  -       } else if (!cur.suggRev && cur.requestsCount < end && Friends.canSugSwitch(list)) {
  284. 282.  -         list = (list || []).slice();
  285. 283.  -         var suggSwitch = parseInt(cur.requestsCount);
  286. 284.  -         list.push.apply(list, cur.friendsList['sugg_requests']);
  287. 285.  -       }
  288. 286.  -     }
  289. 287.  -     if (!list || !list.length) {
  290. 288.  -       if (cur.shownFriends == 0 && !cur.searchCount) {
  291. 289.  -         if (cur.isLoading) {
  292. 290.  -           return false; // Dont show empty msg while search
  293. 291.  -         }
  294. 292.  -         if (cur.searchStr) {
  295. 293.  -           addClass(ge('not_found'), 'f_search');
  296. 294.  -           ge('search_ph').innerHTML = cur.searchStr.replace(/([<>&#]*)/g, '');
  297. 295.  -         } else {
  298. 296.  -           removeClass(ge('not_found'), 'f_search');
  299. 297.  -         }
  300. 298.  -         var text = '';
  301. 299.  -         if (cur.curList.substr(0, 4) == 'list') {
  302. 300.  -           if (cur.filterIds) {
  303. 301.  -             text = cur.summaryLang['list_not_found_filter'];
  304. 302.  -             text = text.replace('{link}', '<a onclick="Friends.clearFilter(true);">').replace('{/link}', '</a>');
  305. 303.  -           } else {
  306. 304.  -             text = cur.summaryLang['list_not_found'];
  307. 305.  -             text = text.replace('{link}', '<a onclick="Friends.editList(-1);">').replace('{/link}', '</a>');
  308. 306.  -           }
  309. 307.  -         } else if (cur.filter) {
  310. 308.  -           text = cur.summaryLang['not_found_filter'];
  311. 309.  -           text = text.replace('{link}', '<a onclick="Friends.clearFilter(true);">').replace('{/link}', '</a>');
  312. 310.  -         } else {
  313. 311.  -           text = cur.summaryLang['not_found'];
  314. 312.  -         }
  315. 313.  -         ge('not_found_text').innerHTML = text;
  316. 314.  -         show('not_found');
  317. 315.  -       }
  318. 316.  -       if (clear) {
  319. 317.  -         cur.fContent.innerHTML = '';
  320. 318.  -       }
  321. 319.  -       if (cur.searchCount) {
  322. 320.  -         Friends.serverSearchMore();
  323. 321.  -       }
  324. 322.  -       hide('show_more');
  325. 323.  -       return;
  326. 324.  -     } else if (isVisible('not_found')) {
  327. 325.  -       hide('not_found');
  328. 326.  -     }
  329. 327.  -
  330. 328.  -     var friends = list.slice(start, end);
  331. 329.  -     if (!friends.length) {
  332. 330.  -       // can upload
  333. 331.  -       var secData = cur.secData[cur.section];
  334. 332.  -       if (secData && secData.preload) {
  335. 333.  -         Friends.loadMore(start, end);
  336. 334.  -       }
  337. 335.  -       if (cur.searchCount) {
  338. 336.  -         Friends.serverSearchMore();
  339. 337.  -       }
  340. 338.  -       if (cur.shownFriends >= cur.sectionCount) {
  341. 339.  -         hide('show_more');
  342. 340.  -       }
  343. 341.  -       return;
  344. 342.  -     }
  345. 343.  -     var html = [];
  346. 344.  -     var first = (cur.shownFriends == 0) ? ' user_block_first' : '';
  347. 345.  -     if (clear) {
  348. 346.  -       cur.fContent.innerHTML = '';
  349. 347.  -     }
  350. 348.  -     for (i in friends) {
  351. 349.  -       var iSt = parseInt(i) + start;
  352. 350.  -       if (suggSwitch && suggSwitch == iSt) {
  353. 351.  -         if (cur.suggRev) {
  354. 352.  -           var summaryText = langNumeric(cur.requestsCount, cur.summaryLang['requests']);
  355. 353.  -           if (nav.objLoc.sort != 'date') {
  356. 354.  -             summaryText += '<span class="divide">|</span><span><a href="/friends?section=' + cur.section + '&sort=date">' + cur.summaryLang['friends_sort_by_date'] + '</a></span>';
  357. 355.  -           } else {
  358. 356.  -             summaryText += '<span class="divide">|</span><span><a href="/friends?section=' + cur.section + '">' + cur.summaryLang['friends_sort_by_common'] + '</a></span>';
  359. 357.  -           }
  360. 358.  -         } else {
  361. 359.  -           var summaryText = langNumeric(cur.suggCount, cur.summaryLang['friends_sugg_summary']);
  362. 360.  -         }
  363. 361.  -         html.push('<div id="friends_sub_summary" class="summary_wrap"><div class="summary">',summaryText,'</div></div>');
  364. 362.  -         first = ' user_block_first';
  365. 363.  -       }
  366. 364.  -       if (cur.selection) {
  367. 365.  -         var friend = friends[i].slice();
  368. 366.  -         friend[5] = friend[5].replace(cur.selection.re, cur.selection.val);
  369. 367.  -       } else {
  370. 368.  -         var friend = friends[i];
  371. 369.  -       }
  372. 370.  -       if (cur.importCount && cur.importCount == cur.shownFriends && cur.section == 'suggestions') {
  373. 371.  -         html.push('<div id="friends_sub_summary" class="summary_wrap"><div class="summary">',cur.summaryLang['suggestions'],'</div></div>');
  374. 372.  -         first = ' user_block_first';
  375. 373.  -       }
  376. 374.  -       /*if (friend[0] && ge('user_block' + friend[0])) { // bad with search
  377. 375.  -         debugLog('here');
  378. 376.  -         continue;
  379. 377.  -       }*/
  380. 378.  -       ++cur.shownFriends;
  381. 379.  -       if (!friend) {
  382. 380.  -         continue;
  383. 381.  -       }
  384. 382.  -       var tplType = '';
  385. 383.  -       if (cur.section == 'requests') {
  386. 384.  -         if (suggSwitch <= iSt) {
  387. 385.  -           tplType = (!cur.suggRev ? 'sugg_requests' : '');
  388. 386.  -         } else {
  389. 387.  -           tplType = (!cur.suggRev ? '' : 'sugg_requests');
  390. 388.  -         }
  391. 389.  -       }
  392. 390.  -       Array.prototype.push.apply(html, Friends.drawFriend(friend, first, tplType));
  393. 391.  -       first = '';
  394. 392.  -     }
  395. 393.  -     if (plain) {
  396. 394.  -       return '<div>'+html.join('')+'</div>';
  397. 395.  -     }
  398. 396.  -     cur.fContent.appendChild(ce('div', {innerHTML: html.join('')}));
  399. 397.  -     if (cur.shownFriends >= cur.sectionCount) {
  400. 398.  -       hide('show_more');
  401. 399.  -     } else {
  402. 400.  -       show('show_more');
  403. 401.  -     }
  404. 402.  -   },
  405. 403.  -
  406. 404.  -   updateList: function(e, obj, force) {
  407. 405.  -     if (!obj || e.keyCode == KEY.ESC) {
  408. 406.  -       obj = cur.fSearch;
  409. 407.  -       val(obj, '');
  410. 408.  -       cur.searchStr = '';
  411. 409.  -     }
  412. 410.  -     if (cur.silent) {
  413. 411.  -       cur.onSilentLoad = function() {
  414. 412.  -         Friends.updateList(e, obj, true);
  415. 413.  -       };
  416. 414.  -       if (trim(obj.value)) {
  417. 415.  -         hide(cur.showMore);
  418. 416.  -         cur.fContent.innerHTML = '<div class="wide_loading"></div>';
  419. 417.  -       }
  420. 418.  -       return;
  421. 419.  -     }
  422. 420.  -     clearTimeout(this.searchTimout);
  423. 421.  -     this.searchTimout = setTimeout((function() {
  424. 422.  -       var str = trim(obj.value);
  425. 423.  -       if (str && cur.searchStr == str) return;
  426. 424.  -       cur.searchStr = str;
  427. 425.  -       if (str) {
  428. 426.  -         if (cur.section != 'all' && cur.section != 'phonebook') {
  429. 427.  -           this.selectTab('all');
  430. 428.  -           this.selectSection('all');
  431. 429.  -           cur.curList = cur.section = 'all';
  432. 430.  -
  433. 431.  -           nav.setLoc(extend(nav.objLoc, {'section': 'all'}));
  434. 432.  -         }
  435. 433.  -         this.search(str, cur.section);
  436. 434.  -         this.changeSummary();
  437. 435.  -       } else if (cur.section != cur.curList || force) {
  438. 436.  -         this.showSection();
  439. 437.  -         this.changeSummary();
  440. 438.  -         this.showMore();
  441. 439.  -       } else {
  442. 440.  -         this.hideLoading();
  443. 441.  -         cur.searchCount = 0;
  444. 442.  -         this.showMore();
  445. 443.  -       }
  446. 444.  -     }).bind(this), 10);
  447. 445.  -   },
  448. 446.  -   showSection: function(section) {
  449. 447.  -     cur.shownFriends = 0;
  450. 448.  -     cur.curList = cur.section = section || cur.section;
  451. 449.  -     if (vk.id == cur.oid) {
  452. 450.  -       if (cur.section == 'requests' || cur.section == 'all_requests' || cur.section == 'out_requests') {
  453. 451.  -         hide('friends_search');
  454. 452.  -         var tabsCount = ((cur.requestsCount || cur.suggCount) ? 1 : 0) + (cur.allRequestsCount ? 1 : 0) + (cur.outRequestsCount ? 1 : 0);
  455. 453.  -         toggle('friends_req_tabs', tabsCount > 1);
  456. 454.  -         toggle('friends_hide_all', (cur.section == 'requests') && (cur.requestsCount > 1 || cur.suggCount));
  457. 455.  -         toggle(ge('sum_tab_requests').parentNode, cur.requestsCount > 0 || cur.suggCount > 0);
  458. 456.  -         toggle(ge('sum_tab_all_requests').parentNode, cur.allRequestsCount > 0);
  459. 457.  -         toggle(ge('sum_tab_out_requests').parentNode, cur.outRequestsCount > 0);
  460. 458.  -         show('tab_requests');
  461. 459.  -         addClass(ge('main_class'), 'wide');
  462. 460.  -       } else {
  463. 461.  -         show('friends_search');
  464. 462.  -         hide('friends_req_tabs');
  465. 463.  -         (cur.allFriendsCount && (cur.section != 'members') ? removeClass : addClass)(ge('main_class'), 'wide');
  466. 464.  -       }
  467. 465.  -       toggle('tab_requests', nav.objLoc.act != 'invite' && (cur.requestsCount || cur.allRequestsCount || cur.outRequestsCount || cur.suggCount));
  468. 466.  -     }
  469. 467.  -     if (cur.filterIds) {
  470. 468.  -       cur.curList += '_filter';
  471. 469.  -     }
  472. 470.  -     var list = cur.friendsList[cur.curList];
  473. 471.  -     if (!list) {
  474. 472.  -       if (section == 'recent' || section == 'phonebook' || section == 'requests') {
  475. 473.  -         var friendsList = section;
  476. 474.  -       } else {
  477. 475.  -         var friendsList = 'all';
  478. 476.  -       }
  479. 477.  -       list = cur.friendsList[cur.curList] = this.filter(cur.friendsList[friendsList], cur.section);
  480. 478.  -     }
  481. 479.  -     cur.sectionCount = (list) ? list.length : 0;
  482. 480.  -     cur.selection = false;
  483. 481.  -     if (cur.filter && !cur.filterIds && section != 'suggestions') {
  484. 482.  -       Friends.changeFilter();
  485. 483.  -       if (!cur.searchStr) {
  486. 484.  -         hide('friends_reset_search');
  487. 485.  -         this.clearServerSearch();
  488. 486.  -       }
  489. 487.  -       return false;
  490. 488.  -     }
  491. 489.  -     this.showMore(true);
  492. 490.  -     if (!cur.searchStr) {
  493. 491.  -       hide('friends_reset_search');
  494. 492.  -       this.clearServerSearch();
  495. 493.  -     }
  496. 494.  -   },
  497. 495.  -
  498. 496.  -   updateView: function() {
  499. 497.  -     cur.fContent.innerHTML = this.showMore(false, 0, cur.shownFriends, true);
  500. 498.  -   },
  501. 499.  -
  502. 500.  -   showLoading: function() {
  503. 501.  -     cur.isLoading = 1;
  504. 502.  -     show('friends_loading');
  505. 503.  -     hide('friends_reset_search');
  506. 504.  -   },
  507. 505.  -
  508. 506.  -   hideLoading: function() {
  509. 507.  -     cur.isLoading = 0;
  510. 508.  -     hide('friends_loading');
  511. 509.  -     if (cur.searchStr) {
  512. 510.  -       show('friends_reset_search');
  513. 511.  -     }
  514. 512.  -   },
  515. 513.  -
  516. 514.  -   serverSearchMore: function() {
  517. 515.  -     if (cur.serverLoadingMore) {
  518. 516.  -       return;
  519. 517.  -     }
  520. 518.  -     if (cur.searchFinished) {
  521. 519.  -       return;
  522. 520.  -     }
  523. 521.  -     cur.serverLoadingMore = true;
  524. 522.  -     ajax.post('friends', {
  525. 523.  -       act: 'server_search',
  526. 524.  -       q: cur.searchStr,
  527. 525.  -       offset: cur.searchOffset
  528. 526.  -     }, {
  529. 527.  -       onDone: function(html, found, summary, newOffset) {
  530. 528.  -         cur.searchFinished = !found;
  531. 529.  -         if (cur.searchFinished) {
  532. 530.  -           hide('friends_search_more');
  533. 531.  -         }
  534. 532.  -         cur.searchOffset = newOffset;
  535. 533.  -         cur.serverLoadingMore = false;
  536. 534.  -         ge('friends_search_cont').appendChild(ce('div', {innerHTML: html}));
  537. 535.  -       },
  538. 536.  -       showProgress: function() {
  539. 537.  -         addClass(ge('friends_search_more'), 'load_more');
  540. 538.  -       },
  541. 539.  -       hideProgress: function() {
  542. 540.  -         removeClass(ge('friends_search_more'), 'load_more');
  543. 541.  -       }
  544. 542.  -     });
  545. 543.  -   },
  546. 544.  -
  547. 545.  -   serverSearch: function(str, count, exclude) {
  548. 546.  -     cur.searchCount = 0;
  549. 547.  -     Friends.showLoading();
  550. 548.  -     cur.serverSearchStr = str;
  551. 549.  -     clearTimeout(cur.serverSearchTimeout);
  552. 550.  -     var excludeList = [];
  553. 551.  -     for (var i in exclude) {
  554. 552.  -       excludeList.push(exclude[i][0]);
  555. 553.  -     }
  556. 554.  -     cur.serverSearchTimeout = setTimeout((function() {
  557. 555.  -       ajax.post('friends', {
  558. 556.  -         act: 'server_search',
  559. 557.  -         q: str,
  560. 558.  -         exclude: excludeList.join(',')
  561. 559.  -       }, {
  562. 560.  -         onDone: function(html, found, summary, newOffset) {
  563. 561.  -           cur.searchOffset = newOffset;
  564. 562.  -           cur.searchFinished = !found;
  565. 563.  -           Friends.hideLoading();
  566. 564.  -           if (cur.searchStr != str) return;
  567. 565.  -           var cont = ge('friends_search_cont');
  568. 566.  -           cur.searchCount = found;
  569. 567.  -           if (cur.shownFriends == 0) {
  570. 568.  -             hide(cont);
  571. 569.  -             cur.fContent.innerHTML = '';
  572. 570.  -             Friends.showMore();
  573. 571.  -           }
  574. 572.  -           if (!found) {
  575. 573.  -             Friends.changeSummary();
  576. 574.  -             return;
  577. 575.  -           }
  578. 576.  -           if (cur.searchFinished) {
  579. 577.  -             hide('friends_search_more');
  580. 578.  -           } else {
  581. 579.  -             show('friends_search_more');
  582. 580.  -           }
  583. 581.  -           cur.searchSummary = summary;
  584. 582.  -           if (count) {
  585. 583.  -             html = '<div class="summary_wrap"><div class="summary">'+summary+'</div></div>'+html;
  586. 584.  -           }
  587. 585.  -           cont.innerHTML = html;
  588. 586.  -           show(cont);
  589. 587.  -           Friends.changeSummary();
  590. 588.  -           hide('not_found');
  591. 589.  -         },
  592. 590.  -         onFail: Friends.hideLoading
  593. 591.  -       });
  594. 592.  -     }).bind(this), 300);
  595. 593.  -   },
  596. 594.  -
  597. 595.  -   clearServerSearch: function() {
  598. 596.  -     hide('friends_search_cont');
  599. 597.  -     hide('friends_search_more');
  600. 598.  -     cur.searchCount = 0;
  601. 599.  -   },
  602. 600.  -
  603. 601.  -   goToSearch: function(obj) {
  604. 602.  -     nav.go('search?c%5Bname%5D=1&c%5Bq%5D='+encodeURIComponent(cur.searchStr)+'&c%5Bsection%5D=people');
  605. 603.  -   },
  606. 604.  -
  607. 605.  -   search: function(str, type, callback, filter) {
  608. 606.  -     cur.shownFriends = 0;
  609. 607.  -     cur.section = type;
  610. 608.  -     if (str) {
  611. 609.  -       var index = (type == 'phonebook') ? cur.phoneIndex : cur.friendsIndex;
  612. 610.  -       var checkTime = new Date().getTime();
  613. 611.  -       if (str == -1) {
  614. 612.  -         if (type == 'recent' || type == 'phonebook') {
  615. 613.  -           var friendsList = type;
  616. 614.  -         } else {
  617. 615.  -           var friendsList = 'all';
  618. 616.  -         }
  619. 617.  -         var res = this.filter(cur.friendsList[friendsList], type);
  620. 618.  -         str = '';
  621. 619.  -         if (str != cur.searchStr) {
  622. 620.  -           this.clearServerSearch();
  623. 621.  -         }
  624. 622.  -       } else {
  625. 623.  -         var res = index.search(str);
  626. 624.  -         if (cur.filterIds) {
  627. 625.  -           res = this.filter(res, type);
  628. 626.  -         }
  629. 627.  -         var count = res.length;
  630. 628.  -         if (count) {
  631. 629.  -           if (str != cur.serverSearchStr && !cur.sectionCount) {
  632. 630.  -             this.clearServerSearch();
  633. 631.  -           }
  634. 632.  -         }
  635. 633.  -         if (count < 5 && cur.oid == vk.id) { // try to find some on the server side
  636. 634.  -           this.serverSearch(str, count, res);
  637. 635.  -         }
  638. 636.  -       }
  639. 637.  -       var newList = cur.section;
  640. 638.  -       if (cur.filterIds) {
  641. 639.  -         newList += '_filter';
  642. 640.  -       }
  643. 641.  -       if (str) {
  644. 642.  -         newList += '_search_'+str;
  645. 643.  -       }
  646. 644.  -       if (cur.curList == newList && !filter) {
  647. 645.  -         return; // now at this section
  648. 646.  -       }
  649. 647.  -       cur.curList = newList;
  650. 648.  -       cur.friendsList[cur.curList] = res;
  651. 649.  -
  652. 650.  -       if (str) {
  653. 651.  -         str += ' '+(parseLatin(str) || '');
  654. 652.  -         str = trim(escapeRE(str.replace(/[,]/g, '')));
  655. 653.  -         cur.selection = {
  656. 654.  -           re: new RegExp('('+str.replace(index.delimiter, '|').replace(/(^\||\|$|\?)/g, '')+')', 'gi'),
  657. 655.  -           val: '<em>$1</em>'
  658. 656.  -         };
  659. 657.  -       }
  660. 658.  -       if (!cur.isLoading) {
  661. 659.  -         show('friends_reset_search');
  662. 660.  -       }
  663. 661.  -     } else {
  664. 662.  -       cur.curList = cur.section;
  665. 663.  -       cur.selection = false;
  666. 664.  -       hide('friends_reset_search');
  667. 665.  -       if (cur.searchStr) {
  668. 666.  -         this.clearServerSearch();
  669. 667.  -       }
  670. 668.  -     }
  671. 669.  -
  672. 670.  -     cur.sectionCount = cur.friendsList[cur.curList].length;
  673. 671.  -     this.searchTimout = setTimeout((function() {
  674. 672.  -       this.showMore(true);
  675. 673.  -       if (callback) {
  676. 674.  -         Friends.onSectionChange();
  677. 675.  -         callback();
  678. 676.  -       }
  679. 677.  -     }).bind(this), 10);
  680. 678.  -   },
  681. 679.  -
  682. 680.  -   changeSummary: function() {
  683. 681.  -     var sum = ge('friends_summary');
  684. 682.  -     var html = '';
  685. 683.  -     if (cur.curList.indexOf('_search_') != -1 || cur.filterIds) {
  686. 684.  -       if (!cur.sectionCount) {
  687. 685.  -         if (cur.searchCount) {
  688. 686.  -           html = cur.searchSummary;
  689. 687.  -         } else {
  690. 688.  -           if (cur.isLoading) {
  691. 689.  -             return; // no update while loading
  692. 690.  -           }
  693. 691.  -           html = cur.summaryLang['search_no'];
  694. 692.  -         }
  695. 693.  -       } else {
  696. 694.  -         html = langNumeric(cur.sectionCount, cur.summaryLang['search'], true);
  697. 695.  -       }
  698. 696.  -     } else if (cur.curList.slice(0, 4) == 'list') {
  699. 697.  -       var langKey = (parseInt(cur.curList.slice(4)) < 25) ? 'list' : 'pub_list';
  700. 698.  -       if (cur.sectionCount) {
  701. 699.  -         html = langNumeric(cur.sectionCount, cur.summaryLang[langKey], true);
  702. 700.  -       } else {
  703. 701.  -         html = cur.summaryLang[langKey+'_no'];
  704. 702.  -       }
  705. 703.  -     } else if (cur.section == 'suggestions') {
  706. 704.  -       if (!cur.importCount) {
  707. 705.  -         html = cur.summaryLang['suggestions'];
  708. 706.  -       } else {
  709. 707.  -         html = cur.summaryLang['import'];
  710. 708.  -       }
  711. 709.  -     } else if (cur.section == 'recent') {
  712. 710.  -       html = cur.summaryLang['recent'];
  713. 711.  -     } else if (cur.section == 'requests' && cur.requestsCount > 0) {
  714. 712.  -       if (cur.suggRev && cur.suggCount > 0) {
  715. 713.  -         html = langNumeric(cur.suggCount, cur.summaryLang['friends_sugg_summary'], true);
  716. 714.  -       } else {
  717. 715.  -         html = langNumeric(cur.requestsCount, cur.summaryLang[cur.section], true);
  718. 716.  -       }
  719. 717.  -     } else if (cur.section == 'requests' && cur.suggCount > 0) {
  720. 718.  -       html = langNumeric(cur.suggCount, cur.summaryLang['friends_sugg_summary'], true);
  721. 719.  -     } else if (cur.section == 'all_requests' && cur.sectionCount > 0) {
  722. 720.  -       html = langNumeric(cur.allRequestsCount, cur.summaryLang[cur.section], true);
  723. 721.  -     } else if (cur.section == 'out_requests' && cur.sectionCount > 0) {
  724. 722.  -       html = langNumeric(cur.outRequestsCount, cur.summaryLang[cur.section], true);
  725. 723.  -     } else if (cur.sectionCount > 0) {
  726. 724.  -       html = langNumeric(cur.sectionCount, cur.summaryLang[cur.section], true);
  727. 725.  -     } else {
  728. 726.  -       html = cur.summaryLang['all_no'];
  729. 727.  -     }
  730. 728.  -     if (cur.section.indexOf('list') == 0 && cur.oid == vk.id) {
  731. 729.  -       listNum = parseInt(cur.curList.substr(4));
  732. 730.  -       var list_edit_text = cur.summaryLang[(cur.sectionCount ? 'list_edit': 'list_start_edit')];
  733. 731.  -       html += '<span class="divider">|</span><span><a onclick="Friends.editList('+listNum+');">'+list_edit_text+'</a></span>';
  734. 732.  -       if (listNum < 25) {
  735. 733.  -         html += '<span class="divider">|</span><span><a onclick="Friends.deleteList('+listNum+');">'+cur.summaryLang['list_delete']+'</a></span>';
  736. 734.  -       }
  737. 735.  -     }
  738. 736.  -     if (vk.id != cur.oid) {
  739. 737.  -       html += '<span class="divider">|</span><span>' + cur.summaryLang['to_users_page'] + '</span>';
  740. 738.  -     }
  741. 739.  -     if ((cur.section == 'requests' && cur.requestsCount > 50) || cur.section == 'all_requests') {
  742. 740.  -       if (!cur.suggRev || !cur.suggCount) {
  743. 741.  -         if (nav.objLoc.sort != 'date') {
  744. 742.  -           html += '<span class="divide">|</span><span><a href="/friends?section=' + cur.section + '&sort=date">' + cur.summaryLang['friends_sort_by_date'] + '</a></span>';
  745. 743.  -         } else {
  746. 744.  -           html += '<span class="divide">|</span><span><a href="/friends?section=' + cur.section + '">' + cur.summaryLang['friends_sort_by_common'] + '</a></span>';
  747. 745.  -         }
  748. 746.  -       }
  749. 747.  -
  750. 748.  -     }
  751. 749.  -     sum.innerHTML = html;
  752. 750.  -
  753. 751.  -     document.title = replaceEntities(stripHTML(cur.htitles[cur.section] || cur.htitles.all));
  754. 752.  -   },
  755. 753.  -   selectTab: function(tab) {
  756. 754.  -     var section = geByClass1('active_link', ge('friends_tabs'));
  757. 755.  -     removeClass(section, 'active_link');
  758. 756.  -     addClass(ge('tab_' + tab), 'active_link');
  759. 757.  -     if (cur.oid != vk.id) {
  760. 758.  -       toggleClass(ge('main_class'), 'wide', tab != 'all' || !cur.allFriendsCount);
  761. 759.  -     }
  762. 760.  -   },
  763. 761.  -   selectSection: function(tab) {
  764. 762.  -     var section = geByClass1('cur_section', ge('sections_block'));
  765. 763.  -     removeClass(section, 'cur_section');
  766. 764.  -     addClass(ge('section_' + tab), 'cur_section');
  767. 765.  -   },
  768. 766.  -   selectSumTab: function(tab) {
  769. 767.  -     var section = geByClass1('summary_tab_sel', ge('friends_req_tabs'));
  770. 768.  -     removeClass(section, 'summary_tab_sel');
  771. 769.  -     addClass(section, 'summary_tab');
  772. 770.  -     var el = ge('sum_tab_' + tab).parentNode;
  773. 771.  -     removeClass(el, 'summary_tab');
  774. 772.  -     addClass(el, 'summary_tab_sel');
  775. 773.  -   },
  776. 774.  -   selectTabAndSection: function(type) {
  777. 775.  -     if (type == 'all' || type == 'online' || type == 'common' || type == 'members') {
  778. 776.  -       this.selectTab(type);
  779. 777.  -       this.selectSection('all');
  780. 778.  -     } else if (type == 'all_requests' || type == 'requests' || type == 'out_requests') {
  781. 779.  -       this.selectTab('requests');
  782. 780.  -       this.selectSumTab(type);
  783. 781.  -     } else {
  784. 782.  -       this.selectTab('all');
  785. 783.  -       this.selectSection(type);
  786. 784.  -     }
  787. 785.  -   },
  788. 786.  -   onSectionChange: function() {
  789. 787.  -     if (window.tooltips) {
  790. 788.  -       tooltips.hideAll();
  791. 789.  -     }
  792. 790.  -   },
  793. 791.  -   section: function(type, callback, updateData) {
  794. 792.  -     Friends.clearServerSearch();
  795. 793.  -     if (!type) {
  796. 794.  -       type = 'all';
  797. 795.  -     }
  798. 796.  -     //if (!updateData && (type != 'all' || cur.section != type) && type.substr(0, 4) != 'list') {
  799. 797.  -     if (!updateData && ((type == 'online' && cur.oid != vk.id) || type.indexOf('requests') != -1) && type.substr(0, 4) != 'list') {
  800. 798.  -       Friends.clearFilter();
  801. 799.  -     }
  802. 800.  -     if (!type) {
  803. 801.  -       if ((cur.requestsCount && cur.requestsCount > 0 && cur.requestsCount < 100) || cur.suggCount) {
  804. 802.  -         type = 'requests';
  805. 803.  -       } else {
  806. 804.  -         type = 'all';
  807. 805.  -       }
  808. 806.  -     }
  809. 807.  -     if (!cur.requestsCount && !cur.suggCount && !cur.allRequestsCount && !cur.outRequestsCount) {
  810. 808.  -       hide('tab_requests');
  811. 809.  -     }
  812. 810.  -     if (type != cur.section) {
  813. 811.  -       cur.fSearch.setValue('');
  814. 812.  -       cur.searchStr = '';
  815. 813.  -     }
  816. 814.  -     // Select section filter
  817. 815.  -     this.selectTabAndSection(type);
  818. 816.  -
  819. 817.  -     if (cur.silent && type != 'suggestions' && type != 'out_requests') {
  820. 818.  -       cur.onSilentLoad = function() {
  821. 819.  -         Friends.section(type, callback);
  822. 820.  -       };
  823. 821.  -       if (type != cur.section) {
  824. 822.  -         hide(cur.showMore);
  825. 823.  -         cur.fContent.innerHTML = '<div class="wide_loading"></div>';
  826. 824.  -       }
  827. 825.  -       return;
  828. 826.  -     }
  829. 827.  -
  830. 828.  -
  831. 829.  -     if (!cur.secData[type]) {
  832. 830.  -       cur.secData[type] = {};
  833. 831.  -     }
  834. 832.  -     // from cache
  835. 833.  -     if (!updateData && cur.friendsList[type] || type == 'all' || (type == 'requests' && cur.friendsList['sugg_requests'])) {
  836. 834.  -       if (!cur.filter || type != 'suggestions') {
  837. 835.  -         this.showSection(type);
  838. 836.  -         callback();
  839. 837.  -         Friends.onSectionChange();
  840. 838.  -         return;
  841. 839.  -       }
  842. 840.  -     }
  843. 841.  -     // generate
  844. 842.  -     switch (type) {
  845. 843.  -       case 'online':
  846. 844.  -       case 'common':
  847. 845.  -         this.search(-1, type, callback);
  848. 846.  -         break;
  849. 847.  -       case 'phonebook':
  850. 848.  -         this.loadingState('phonebook');
  851. 849.  -         ajax.post('/al_friends.php', {act: 'phonebook', id: nav.objLoc.id}, {onDone: (function(data) {
  852. 850.  -           if (!data) {
  853. 851.  -             return;
  854. 852.  -           }
  855. 853.  -           cur.shownFriends = 0;
  856. 854.  -           cur.curList = cur.section = type;
  857. 855.  -           var list = cur.friendsList['all'];
  858. 856.  -           var phoneList = [];
  859. 857.  -           if (list) {
  860. 858.  -             for (var i = 0, len = list.length; i < len; i++) {
  861. 859.  -               var friend = list[i];
  862. 860.  -               var phone = data[friend[0]];
  863. 861.  -               if (phone) {
  864. 862.  -                 friend.push(phone);
  865. 863.  -                 phoneList.push(friend);
  866. 864.  -               }
  867. 865.  -             }
  868. 866.  -           }
  869. 867.  -           cur.friendsList[cur.section] = phoneList;
  870. 868.  -           cur.sectionCount = phoneList.length;
  871. 869.  -           cur.fContent.innerHTML = '';
  872. 870.  -           this.loadingState('phonebook', true);
  873. 871.  -           Friends.onSectionChange();
  874. 872.  -           callback();
  875. 873.  -           Friends.indexPhone();
  876. 874.  -           if (cur.filterIds) {
  877. 875.  -             cur.curList += '_filter';
  878. 876.  -             Friends.search(cur.searchStr || -1, cur.section, false, true);
  879. 877.  -             Friends.changeSummary();
  880. 878.  -             return;
  881. 879.  -           }
  882. 880.  -           this.showMore();
  883. 881.  -         }).bind(this)});
  884. 882.  -         break;
  885. 883.  -       case 'recent':
  886. 884.  -         this.loadingState('recent');
  887. 885.  -         ajax.post('/al_friends.php', {act: 'recent'}, {onDone: (function(data) {
  888. 886.  -           if (!data) {
  889. 887.  -             return;
  890. 888.  -           }
  891. 889.  -           cur.shownFriends = 0;
  892. 890.  -           cur.curList = cur.section = type;
  893. 891.  -           var list = [];
  894. 892.  -           len = data.length;
  895. 893.  -           for (var i = 0; i < len; i++) {
  896. 894.  -             var f = cur.friends[data[i]];
  897. 895.  -             if (f) {
  898. 896.  -               list.push(f);
  899. 897.  -             }
  900. 898.  -           }
  901. 899.  -           cur.friendsList[cur.section] = list;
  902. 900.  -           cur.sectionCount = list.length;
  903. 901.  -           cur.fContent.innerHTML = '';
  904. 902.  -           this.loadingState('recent', true);
  905. 903.  -           Friends.onSectionChange();
  906. 904.  -           callback();
  907. 905.  -           if (cur.filterIds) {
  908. 906.  -             cur.curList += '_filter';
  909. 907.  -             Friends.search(cur.searchStr || -1, cur.section, false, true);
  910. 908.  -             Friends.changeSummary();
  911. 909.  -             return;
  912. 910.  -           }
  913. 911.  -           this.showMore();
  914. 912.  -         }).bind(this)});
  915. 913.  -         break;
  916. 914.  -       case 'suggestions':
  917. 915.  -         this.loadingState('suggestions');
  918. 916.  -         ajax.post('/friends', extend({
  919. 917.  -           act: 'get_section_friends',
  920. 918.  -           section: 'suggestions'
  921. 919.  -         }, cur.filter || {}), {
  922. 920.  -           onDone: (function(list, preload, data) {
  923. 921.  -             var list = eval('('+list+')');
  924. 922.  -             extend(cur, data || {});
  925. 923.  -             var keyType = type + (cur.filterIds ? '_filter' : '');
  926. 924.  -             cur.friendsList[keyType] = list[type];
  927. 925.  -             this.loadingState(type, true);
  928. 926.  -             this.showSection(type);
  929. 927.  -             cur.secData[type].preload = preload;
  930. 928.  -             Friends.onSectionChange();
  931. 929.  -             callback();
  932. 930.  -           }).bind(this)
  933. 931.  -         });
  934. 932.  -         break;
  935. 933.  -       case 'out_requests':
  936. 934.  -         hide(cur.showMore, 'friends_hide_all');
  937. 935.  -         cur.fContent.innerHTML = '<div class="wide_loading"></div>';
  938. 936.  -         ajax.post('/friends', {act: 'out_requests'}, {onDone: (function(data, universities) {
  939. 937.  -           var obj = eval('('+data+')');
  940. 938.  -
  941. 939.  -           // load friends json
  942. 940.  -           if (!obj) {
  943. 941.  -             return;
  944. 942.  -           }
  945. 943.  -           extend(cur.universities, universities);
  946. 944.  -           extend(cur.friendsList, obj);
  947. 945.  -
  948. 946.  -           this.indexAll(function() {
  949. 947.  -             Friends.section(type, callback);
  950. 948.  -           });
  951. 949.  -         }).bind(this)});
  952. 950.  -         break;
  953. 951.  -       default:
  954. 952.  -         if (type.substr(0, 4) == 'list') {
  955. 953.  -           this.search(-1, type, callback);
  956. 954.  -         }
  957. 955.  -
  958. 956.  -     }
  959. 957.  -   },
  960. 958.  -   loadingState: function(section, state) {
  961. 959.  -     if (state) {
  962. 960.  -       if (cur.oldSection) {
  963. 961.  -         removeClass(cur.oldSection, 'loading');
  964. 962.  -       }
  965. 963.  -     } else {
  966. 964.  -       cur.oldSection = ge('section_' + section);
  967. 965.  -       addClass(cur.oldSection, 'loading');
  968. 966.  -     }
  969. 967.  -   },
  970. 968.  -   scrollResize: function() {
  971. 969.  -     if (browser.mobile) return;
  972. 970.  -     var docEl = document.documentElement;
  973. 971.  -     var ch = window.innerHeight || docEl.clientHeight || bodyNode.clientHeight;
  974. 972.  -     var st = scrollGetY();
  975. 973.  -     if (!cur.pageEnd) {
  976. 974.  -       return;
  977. 975.  -     }
  978. 976.  -     if (st + ch * 3 > cur.pageEnd.offsetTop) {
  979. 977.  -       setTimeout(function() {
  980. 978.  -         Friends.showMore();
  981. 979.  -       }, 0);
  982. 980.  -     }
  983. 981.  -   },
  984. 982.  -   drawFriend: function(friend, first, type) {
  985. 983.  -     if (cur.section == 'requests' || cur.section == 'all_requests' || cur.section == 'out_requests' || cur.section == 'suggestions') {
  986. 984.  -       return cur.commonTpl(friend, type || cur.section, first);
  987. 985.  -     } else {
  988. 986.  -       return cur.friendsTpl(friend, cur.section, first);
  989. 987.  -     }
  990. 988.  -   },
  991. 989.  -
  992. 990.  -   inviteToGroup: function(ev, gid, mid, invited, hash) {
  993. 991.  -     var setInvited = function(invited) {
  994. 992.  -       for(var i in cur.friendsList[cur.curList]) {
  995. 993.  -         var row = cur.friendsList[cur.curList][i];
  996. 994.  -         if (row[0] == mid) {
  997. 995.  -           row[10] = invited;
  998. 996.  -           //Friends.updateView();
  999. 997.  -           var block = ge('user_block'+mid), link = '';
  1000. 998.  -           if (invited) {
  1001. 999.  -             link = '<a href="" onclick="return Friends.inviteToGroup(event, '+gid+', '+mid+', 1, \''+row[11]+'\')">'+getLang('friends_cancel_invite')+'</a>';
  1002. 1000.  -           } else {
  1003. 1001.  -             link = '<a href="" onclick="return Friends.inviteToGroup(event, '+gid+', '+mid+', 0, \''+row[11]+'\')">'+getLang('friends_send_invite')+'</a>';
  1004. 1002.  -           }
  1005. 1003.  -           geByClass('actions', block)[0].innerHTML = link;
  1006. 1004.  -           break;
  1007. 1005.  -         }
  1008. 1006.  -       }
  1009. 1007.  -     }
  1010. 1008.  -     if (invited) {
  1011. 1009.  -       ajax.post('/al_page.php', {act:'a_cancel_invite', mid:mid, gid:gid, hash:hash}, {onDone:function(res){ }});
  1012. 1010.  -       setInvited(0);
  1013. 1011.  -     } else {
  1014. 1012.  -       ajax.post('/al_page.php', {act:'a_invite', mid:mid, gid:gid, hash:hash}, {onDone:function(res, message) {
  1015. 1013.  -         if (!res) {
  1016. 1014.  -           setInvited(0);
  1017. 1015.  -           ge('res'+mid).innerHTML = '<div class="res">'+message+'</div>';
  1018. 1016.  -           hide('lists'+mid);
  1019. 1017.  -           var block = ge('user_block'+mid);
  1020. 1018.  -           hide(geByClass('actions', block)[0]);
  1021. 1019.  -         }
  1022. 1020.  -       }});
  1023. 1021.  -       setInvited(1);
  1024. 1022.  -     }
  1025. 1023.  -     return false;
  1026. 1024.  -   },
  1027. 1025.  -
  1028. 1026.  -   acceptRequest: function(mid, hash, el) {
  1029. 1027.  -     var controls = ge('request_controls_'+mid);
  1030. 1028.  -     var controlsCont = controls.parentNode;
  1031. 1029.  -     if (!el) {
  1032. 1030.  -       controls.innerHTML = '<div align="center"><img src="/images/upload.gif"></div>';
  1033. 1031.  -     }
  1034. 1032.  -     ajax.post('al_friends.php', {act: 'add', mid: mid, hash: hash, request: 1, 'select_list': 1}, {onDone: function(text) {
  1035. 1033.  -       controls.innerHTML = text;
  1036. 1034.  -       delete cur.friendsList['recent'];
  1037. 1035.  -     }, onFail: function(text) {
  1038. 1036.  -       if (!text) return;
  1039. 1037.  -
  1040. 1038.  -       showFastBox(getLang('global_error'), text);
  1041. 1039.  -       return true;
  1042. 1040.  -     }, showProgress: lockButton.pbind(el), hideProgress: unlockButton.pbind(el)});
  1043. 1041.  -     Friends.processRequest(mid, true);
  1044. 1042.  -     delete cur.friendsList['online'];
  1045. 1043.  -     Friends.indexAll();
  1046. 1044.  -   },
  1047. 1045.  -
  1048. 1046.  -   declineRequest: function(mid, hash, el) {
  1049. 1047.  -     var controls = ge('request_controls_'+mid);
  1050. 1048.  -     var controlsCont = controls.parentNode;
  1051. 1049.  -     if (!el) {
  1052. 1050.  -       controls.innerHTML = '<div align="center"><img src="/images/upload.gif"></div>';
  1053. 1051.  -     }
  1054. 1052.  -     ajax.post('al_friends.php', {act: 'remove', mid: mid, hash: hash, report_spam: 1, from_section: cur.section}, {onDone: function(text) {
  1055. 1053.  -       controls.innerHTML = text;
  1056. 1054.  -     }, onFail: function(text) {
  1057. 1055.  -       if (!text) return;
  1058. 1056.  -
  1059. 1057.  -       showFastBox(getLang('global_error'), text);
  1060. 1058.  -       return true;
  1061. 1059.  -     }, showProgress: lockButton.pbind(el), hideProgress: unlockButton.pbind(el)});
  1062. 1060.  -
  1063. 1061.  -     Friends.processRequest(mid, false);
  1064. 1062.  -   },
  1065. 1063.  -
  1066. 1064.  -   processRequest: function(mid, add, sugg) {
  1067. 1065.  -     var reqs = cur.friendsList[sugg ? 'sugg_requests' : 'requests'] || [];
  1068. 1066.  -     var len = reqs.length, found = false;
  1069. 1067.  -     while (len--) {
  1070. 1068.  -       if (reqs[len][0] == mid) {
  1071. 1069.  -         var friend = reqs.splice(len, 1)[0];
  1072. 1070.  -         if (sugg) {
  1073. 1071.  -           --cur.suggCount;
  1074. 1072.  -         } else {
  1075. 1073.  -           --cur.requestsCount;
  1076. 1074.  -         }
  1077. 1075.  -         val(geByClass1('tab_word', ge('tab_requests')), cur.summaryLang['requests_title'] + (cur.requestsCount ? ('<span class="count">+' + cur.requestsCount + '</span>') : ''));
  1078. 1076.  -         toggleClass(ge('tab_requests'), 'count', !!cur.requestsCount);
  1079. 1077.  -         if (add) {
  1080. 1078.  -           found = true;
  1081. 1079.  -           friend.pop();
  1082. 1080.  -           if (cur.friendsList['all']) {
  1083. 1081.  -             cur.friendsList['all'].push(friend);
  1084. 1082.  -           } else {
  1085. 1083.  -             cur.friendsList['all'] = [friend];
  1086. 1084.  -           }
  1087. 1085.  -           cur.friends[friend[0]] = friend;
  1088. 1086.  -         }
  1089. 1087.  -       }
  1090. 1088.  -     }
  1091. 1089.  -     if (add) {
  1092. 1090.  -       var reqs = cur.friendsList['all_requests'] || [];
  1093. 1091.  -       var len = reqs.length;
  1094. 1092.  -       while (len--) {
  1095. 1093.  -         if (reqs[len][0] == mid) {
  1096. 1094.  -           var friend = reqs.splice(len, 1)[0];
  1097. 1095.  -           --cur.allRequestsCount;
  1098. 1096.  -           if (!found) {
  1099. 1097.  -             friend.pop();
  1100. 1098.  -             if (cur.friendsList['all']) {
  1101. 1099.  -               cur.friendsList['all'].push(friend);
  1102. 1100.  -             } else {
  1103. 1101.  -               cur.friendsList['all'] = [friend];
  1104. 1102.  -             }
  1105. 1103.  -             cur.friends[friend[0]] = friend;
  1106. 1104.  -           }
  1107. 1105.  -         }
  1108. 1106.  -       }
  1109. 1107.  -     } else {
  1110. 1108.  -       var reqs = cur.friendsList['out_requests'] || [];
  1111. 1109.  -       var len = reqs.length;
  1112. 1110.  -       while (len--) {
  1113. 1111.  -         if (reqs[len][0] == mid) {
  1114. 1112.  -           var friend = reqs.splice(len, 1)[0];
  1115. 1113.  -           --cur.outRequestsCount;
  1116. 1114.  -         }
  1117. 1115.  -       }
  1118. 1116.  -     }
  1119. 1117.  -   },
  1120. 1118.  -
  1121. 1119.  -   reportSpam: function(mid, hash) {
  1122. 1120.  -     var controls = ge('request_controls_' + mid);
  1123. 1121.  -     if (!controls) {
  1124. 1122.  -       controls = ge('result_msg');
  1125. 1123.  -       removeClass(controls, 'msg');
  1126. 1124.  -     }
  1127. 1125.  -     controls.innerHTML = '<div align="center"><img src="/images/upload.gif"></div>';
  1128. 1126.  -     ajax.post('al_friends.php', {act: 'report_spam', mid: mid, hash: hash}, {onDone: function(text) {
  1129. 1127.  -       controls.innerHTML = text;
  1130. 1128.  -     }});
  1131. 1129.  -   },
  1132. 1130.  -
  1133. 1131.  -   restoreFriend: function(el, id) {
  1134. 1132.  -     var back = el.innerHTML;
  1135. 1133.  -     ajax.post('al_friends.php', {act: 'add', mid: id, hash: cur.userHash, cats: cur.savedMasks[id]}, {
  1136. 1134.  -       onDone: Friends.onRemoveFriend.pbind(id, true),
  1137. 1135.  -       showProgress: function() {
  1138. 1136.  -         el.innerHTML = '<center><img src="/images/upload.gif" /></center>';
  1139. 1137.  -       },
  1140. 1138.  -       hideProgress: function() {
  1141. 1139.  -         el.innerHTML = back;
  1142. 1140.  -       }
  1143. 1141.  -     });
  1144. 1142.  -   },
  1145. 1143.  -
  1146. 1144.  -   deleteFriend: function(e, id, el) {
  1147. 1145.  -     var back = el.innerHTML;
  1148. 1146.  -     ajax.post('al_friends.php', {act: 'remove', mid: id, hash: cur.userHash}, {
  1149. 1147.  -       onDone: Friends.onRemoveFriend.pbind(id, false),
  1150. 1148.  -       showProgress: function() {
  1151. 1149.  -         el.innerHTML = '<center><img src="/images/upload.gif" /></center>';
  1152. 1150.  -       },
  1153. 1151.  -       hideProgress: function() {
  1154. 1152.  -         el.innerHTML = back;
  1155. 1153.  -       }
  1156. 1154.  -     });
  1157. 1155.  -     return false;
  1158. 1156.  -   },
  1159. 1157.  -
  1160. 1158.  -   onRemoveFriend: function(mid, res) {
  1161. 1159.  -     var needUpdateView = (cur.friendsList[cur.curList] || []).length < 10;
  1162. 1160.  -
  1163. 1161.  -     for (var i in cur.friendsList) {
  1164. 1162.  -       if (i != 'all' && i != 'requests' && i != 'all_requests' && i != 'out_requests' && i != 'suggestions') {
  1165. 1163.  -         delete cur.friendsList[i];
  1166. 1164.  -       }
  1167. 1165.  -     }
  1168. 1166.  -     var list = cur.friendsList['all'];
  1169. 1167.  -     var len = list.length;
  1170. 1168.  -     mid = positive(mid);
  1171. 1169.  -
  1172. 1170.  -     var block = ge('user_block' + mid);
  1173. 1171.  -     var fr = cur.friends[mid];
  1174. 1172.  -     if (fr && block) {
  1175. 1173.  -       if (res) {
  1176. 1174.  -         fr[6] = cur.savedMasks[mid];
  1177. 1175.  -         delete(cur.savedMasks[mid]);
  1178. 1176.  -       } else {
  1179. 1177.  -         cur.savedMasks[mid] = fr[6];
  1180. 1178.  -         fr[6] = 0; // zero mask - removed friend
  1181. 1179.  -       }
  1182. 1180.  -       block.parentNode.replaceChild(ce('div', {innerHTML: cur.friendsTpl(fr, cur.section, hasClass(block, 'user_block_first') ? ' user_block_first' : '').join('')}).firstChild, block);
  1183. 1181.  -     } else {
  1184. 1182.  -       re(block);
  1185. 1183.  -     }
  1186. 1184.  -
  1187. 1185.  -     Friends.indexAll(function() {
  1188. 1186.  -     });
  1189. 1187.  -   },
  1190. 1188.  -   showCommonBox: function(e, id, hash) {
  1191. 1189.  -     if (checkEvent(e)) return true;
  1192. 1190.  -     showBox('al_friends.php', {act: 'common_friends', mid: id, hash: hash}, {params: {bodyStyle: "padding: 0px;"}});
  1193. 1191.  -     return false;
  1194. 1192.  -   },
  1195. 1193.  -   toList: function(num) {
  1196. 1194.  -     nav.change({'0':'al_friends.php', section:'list' + num});
  1197. 1195.  -     scrollToTop(0);
  1198. 1196.  -     return false;
  1199. 1197.  -   },
  1200. 1198.  -
  1201. 1199.  -   /*ddShowSearchActs: function(obj, ev, uid) {
  1202. 1200.  -     var elems = [];
  1203. 1201.  -     elems.push('<a class="friends_dd_item" onclick="Friends.ddHide(ge(\'friends_dd_menu_'+uid+'\'), '+uid+');return showWriteMessageBox(event, '+uid+')">'+cur.summaryLang['global_write_msg']+'</a>');
  1204. 1202.  -     Friends.ddShowCustom(obj, ev, elems, uid);
  1205. 1203.  -   },*/
  1206. 1204.  -
  1207. 1205.  -   ttActToggle: function(obj, uid, hash, add) {
  1208. 1206.  -     var back = obj.innerHTML;
  1209. 1207.  -     ajax.post('al_friends.php', {act: add ? 'add' : 'remove', mid: uid, hash: hash, from: 'friends'}, {
  1210. 1208.  -       onDone: function(text) {
  1211. 1209.  -         //re(obj);
  1212. 1210.  -         cur['friends_info'+uid] = add;
  1213. 1211.  -         showDoneBox('<div class="friends_done">'+text+'</div>')
  1214. 1212.  -         tooltips.destroyAll();
  1215. 1213.  -         //ge('friends_tt_cont_'+uid).tt.close();
  1216. 1214.  -       },
  1217. 1215.  -       showProgress: function() {
  1218. 1216.  -         obj.innerHTML = '<center><img src="/images/upload.gif" /></center>';
  1219. 1217.  -       },
  1220. 1218.  -       hideProgress: function() {
  1221. 1219.  -         obj.innerHTML = back;
  1222. 1220.  -       }
  1223. 1221.  -     })
  1224. 1222.  -   },
  1225. 1223.  -
  1226. 1224.  -   ttActGift: function(uid) {
  1227. 1225.  -     return !showBox('al_gifts.php', {act: 'get_gift_box', mid: uid, fr: (uid == vk.id ? 1 : 0)}, {stat: ['gifts.css', 'ui_controls.js', 'ui_controls.css'], cache: 1}, false);
  1228. 1226.  -   },
  1229. 1227.  -
  1230. 1228.  -   ttActsMenu: function(obj, ev, uid, hash) {
  1231. 1229.  -     if (obj.tt) {
  1232. 1230.  -       if (!obj.tt.show) return;
  1233. 1231.  -       return obj.tt.show();
  1234. 1232.  -     }
  1235. 1233.  -     if (window.tooltips) {
  1236. 1234.  -       tooltips.hideAll();
  1237. 1235.  -     }
  1238. 1236.  -     var info = cur['friends_info'+uid] || '';
  1239. 1237.  -     var html = ['<div class="friends_tt_menu">'];
  1240. 1238.  -     html.push('<a class="friends_tt_item" onclick="return showWriteMessageBox(event, '+uid+')"><div class="friends_tt_icon friends_tt_msg"></div>'+cur.summaryLang['global_write_msg']+'</a>');
  1241. 1239.  -     if (info) {
  1242. 1240.  -       html.push('<a class="friends_tt_item" onclick="return Friends.ttActToggle(this, '+uid+', \''+hash+'\', 0);"><div class="friends_tt_icon friends_tt_cancel"></div>'+cur.summaryLang['friends_add_cancel']+'</a>');
  1243. 1241.  -     } else if (!cur.friends[uid]) {
  1244. 1242.  -       html.push('<a class="friends_tt_item" onclick="return Friends.ttActToggle(this, '+uid+', \''+hash+'\', 1);"><div class="friends_tt_icon friends_tt_add"></div>'+cur.summaryLang['friends_add_act']+'</a>');
  1245. 1243.  -     }
  1246. 1244.  -     html.push('<a class="friends_tt_item" onclick="return Friends.ttActGift('+uid+');"><div class="friends_tt_icon friends_tt_gift"></div>'+cur.summaryLang['friends_gift_act']+'</a>');
  1247. 1245.  -     html.push('</div>');
  1248. 1246.  -     showTooltip(obj, {
  1249. 1247.  -       text: html.join(''),
  1250. 1248.  -       className: 'friends_tt wall_tt',
  1251. 1249.  -       shift: [0, 0, -2],
  1252. 1250.  -       forcetodown: 1,
  1253. 1251.  -       hasover: 1,
  1254. 1252.  -       center: 1
  1255. 1253.  -     });
  1256. 1254.  -   },
  1257. 1255.  -
  1258. 1256.  -   ddShow: function(uid, obj, ev) {
  1259. 1257.  -     if (cur.silent) {
  1260. 1258.  -       cur.onSilentLoad = function() {
  1261. 1259.  -         Friends.ddShow(uid, obj, ev);
  1262. 1260.  -       };
  1263. 1261.  -       return;
  1264. 1262.  -     }
  1265. 1263.  -
  1266. 1264.  -     var friend = cur.friends[parseInt(uid)];
  1267. 1265.  -     var cats = parseInt(friend[6]);
  1268. 1266.  -
  1269. 1267.  -     var elems = [];
  1270. 1268.  -
  1271. 1269.  -     var publicLists = [28, 29, 27, 25, 26];
  1272. 1270.  -     for (var j = 0, i; j < 5; ++j) {
  1273. 1271.  -       i = publicLists[j];
  1274. 1272.  -       if (cur.publicLists[i]) {
  1275. 1273.  -         elems.push('<a class="friends_dd_item'+((cats & (1 << parseInt(i))) ? ' checked' : '')+'" onclick="Friends.checkCat(this, '+uid+', '+i+');">'+cur.publicLists[i]+'</a>');
  1276. 1274.  -       }
  1277. 1275.  -     }
  1278. 1276.  -     for (var i in cur.userLists) {
  1279. 1277.  -       if (i < 25) {
  1280. 1278.  -         var lname = cur.userLists[i];
  1281. 1279.  -         if (lname.length > 20) {
  1282. 1280.  -           lname = trim(lname.substr(0, 18))+'...';
  1283. 1281.  -         }
  1284. 1282.  -         elems.push('<a class="friends_dd_item'+((cats & (1 << parseInt(i))) ? ' checked' : '')+'" onclick="Friends.checkCat(this, '+uid+', '+i+');">'+lname+'</a>');
  1285. 1283.  -       }
  1286. 1284.  -     }
  1287. 1285.  -     Friends.ddShowCustom(obj, ev, elems, uid);
  1288. 1286.  -   },
  1289. 1287.  -
  1290. 1288.  -   ddShowCustom: function(obj, event, elems, ddId) {
  1291. 1289.  -     var text = obj.innerHTML;
  1292. 1290.  -     var pos = getXY(obj);
  1293. 1291.  -     var height = window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.offsetHeight);
  1294. 1292.  -     var posY = pos[1] - scrollGetY();
  1295. 1293.  -     var ddHeight = elems.length * 22;
  1296. 1294.  -
  1297. 1295.  -     var params = {
  1298. 1296.  -       className: 'lists_menu'
  1299. 1297.  -     }
  1300. 1298.  -
  1301. 1299.  -     var styleAdd = '';
  1302. 1300.  -     var headerAdd = '';
  1303. 1301.  -
  1304. 1302.  -     if (posY > (height / 2) && (height - posY) < ddHeight) {
  1305. 1303.  -       headerAdd = ' friends_header_up';
  1306. 1304.  -       elems = elems.reverse();
  1307. 1305.  -       styleAdd = ' style="margin-top: -'+(ddHeight + 1)+'px;"';
  1308. 1306.  -     }
  1309. 1307.  -
  1310. 1308.  -     var htmlH = ['<div id="friends_dd_menu_',ddId,'" onmouseout="Friends.ddHide(this, ',ddId,');" onmouseover="Friends.ddActive(this, ',ddId,');"><div class="lists_header', headerAdd,'"><div>', text, '</div></div><div class="lists_body" ', styleAdd,'><table cellspacing="0" cellpadding="0"><tbody><tr><td class="lists_shad_l"><div></div></td><td><div class="lists_shad_t2"></div><div class="lists_shad_t"></div><div class="lists_rows"><div id="rows3">'];
  1311. 1309.  -
  1312. 1310.  -     var htmlF = '</div></div><div class="lists_shad_b"></div><div class="lists_shad_b2"></div></td><td class="lists_shad_r"><div> </div></td></tr></tbody></table></div></div>';
  1313. 1311.  -
  1314. 1312.  -     params.innerHTML = htmlH.join('') + elems.join('') + htmlF;
  1315. 1313.  -
  1316. 1314.  -     var dd = ce('div', params);
  1317. 1315.  -
  1318. 1316.  -     obj.parentNode.insertBefore(dd, obj);
  1319. 1317.  -     cur.onMouseClick = function(ev) {
  1320. 1318.  -       var menuId = 'friends_dd_menu_'+ddId;
  1321. 1319.  -       var obj = ev.target;
  1322. 1320.  -       while (obj) {
  1323. 1321.  -         if (hasClass(obj, 'lists_select') || obj.id == menuId) {
  1324. 1322.  -           return false;
  1325. 1323.  -         }
  1326. 1324.  -         obj = obj.parentNode;
  1327. 1325.  -       }
  1328. 1326.  -       if (ev.target)
  1329. 1327.  -       Friends.ddHide(ge(menuId), ddId, 1);
  1330. 1328.  -     }
  1331. 1329.  -   },
  1332. 1330.  -
  1333. 1331.  -   ddHide: function(obj, ddId, fast) {
  1334. 1332.  -     cur.timeouts['dd_fade'+ddId] = setTimeout(function() {
  1335. 1333.  -       fadeOut(obj, fast ? 0 : 100, function() {
  1336. 1334.  -         var parentEl = obj.parentNode.parentNode;
  1337. 1335.  -         if (parentEl) {
  1338. 1336.  -           parentEl.removeChild(obj.parentNode);
  1339. 1337.  -         }
  1340. 1338.  -       });
  1341. 1339.  -     }, fast ? 0 : 600);
  1342. 1340.  -   },
  1343. 1341.  -   ddActive: function(obj, ddId) {
  1344. 1342.  -     if (cur.timeouts['dd_fade'+ddId]) {
  1345. 1343.  -       clearTimeout(cur.timeouts['dd_fade'+ddId]);
  1346. 1344.  -     }
  1347. 1345.  -   },
  1348. 1346.  -   checkCat: function(obj, uid, listId, from) {
  1349. 1347.  -     if (from == 1) {
  1350. 1348.  -       var checked = isChecked(obj);
  1351. 1349.  -     } else {
  1352. 1350.  -       var checked = hasClass(obj, 'checked');
  1353. 1351.  -       var lists = ge('lists' + uid);
  1354. 1352.  -     }
  1355. 1353.  -     var friend = cur.friends[uid];
  1356. 1354.  -     if (!friend) {
  1357. 1355.  -       return false;
  1358. 1356.  -     }
  1359. 1357.  -     friend[6] = parseInt(friend[6]);
  1360. 1358.  -     if (checked) {
  1361. 1359.  -       if (friend[6] & (1 << listId)) {
  1362. 1360.  -         friend[6] -= (1 << listId);
  1363. 1361.  -       }
  1364. 1362.  -       if (lists) {
  1365. 1363.  -         lists.innerHTML = Friends.getLists(friend[6]);
  1366. 1364.  -       }
  1367. 1365.  -     } else {
  1368. 1366.  -       if (!(friend[6] & (1 << listId))) {
  1369. 1367.  -         friend[6] += (1 << listId);
  1370. 1368.  -       }
  1371. 1369.  -       if (lists) {
  1372. 1370.  -         lists.innerHTML = Friends.getLists(friend[6]);
  1373. 1371.  -       }
  1374. 1372.  -     }
  1375. 1373.  -
  1376. 1374.  -     if (from == 1) {
  1377. 1375.  -       checkbox(obj);
  1378. 1376.  -     } else {
  1379. 1377.  -       (checked ? removeClass : addClass)(obj, 'checked');
  1380. 1378.  -     }
  1381. 1379.  -     if (cur.timeouts['list'+uid]) {
  1382. 1380.  -       clearTimeout(cur.timeouts['list'+uid]);
  1383. 1381.  -     }
  1384. 1382.  -     delete cur.friendsList['list'+listId];
  1385. 1383.  -     delete cur.friendsList['list'+friend[6]]
  1386. 1384.  -     cur.timeouts['list'+uid] = setTimeout(function() {
  1387. 1385.  -       ajax.post('al_friends.php', {act: 'save_cats', uid: uid, cats: friend[6], hash: cur.userHash}, {
  1388. 1386.  -         onDone: function(text) {
  1389. 1387.  -           if (from) {
  1390. 1388.  -             var info = ge('friends_added_'+uid);
  1391. 1389.  -             if (!cur['fr_add_text_'+uid] && info) {
  1392. 1390.  -               cur['fr_add_text_'+uid] = info.innerHTML;
  1393. 1391.  -             }
  1394. 1392.  -             fadeTo(info, 100, 0, function() {
  1395. 1393.  -               info.innerHTML = text;
  1396. 1394.  -               fadeTo(info, 100, 1);
  1397. 1395.  -             });
  1398. 1396.  -             clearTimeout(cur['fr_add_timeout_'+uid]);
  1399. 1397.  -             cur['fr_add_timeout_'+uid] = setTimeout(function() {
  1400. 1398.  -               fadeTo(info, 100, 0, function() {
  1401. 1399.  -                 info.innerHTML = cur['fr_add_text_'+uid];
  1402. 1400.  -                 fadeTo(info, 100, 1);
  1403. 1401.  -               });
  1404. 1402.  -             }, 2000);
  1405. 1403.  -           }
  1406. 1404.  -         }
  1407. 1405.  -       });
  1408. 1406.  -     });
  1409. 1407.  -   },
  1410. 1408.  -   getLists: function(cats) {
  1411. 1409.  -     var info = [];
  1412. 1410.  -     for (var i = 29; i >= 25; i--) {
  1413. 1411.  -       if ((1 << i) & cats && cur.publicLists[i]) {
  1414. 1412.  -         info.push('<span class="group', (i - 1) % 8 + 1, ' fl_l" onmousedown="Friends.toList(', i, ');">', cur.publicLists[i], '</span>');
  1415. 1413.  -       }
  1416. 1414.  -     }
  1417. 1415.  -     if (vk.id == cur.oid) {
  1418. 1416.  -       for (var i in cur.userLists) {
  1419. 1417.  -         if ((1 << i) & cats && !cur.publicLists[i] && cur.userLists[i]) {
  1420. 1418.  -           info.push('<span class="group', (i - 1) % 8 + 1, ' fl_l" onmousedown="Friends.toList(', i, ');">', cur.userLists[i], '</span>');
  1421. 1419.  -         }
  1422. 1420.  -       }
  1423. 1421.  -     }
  1424. 1422.  -     return info.join('');
  1425. 1423.  -   },
  1426. 1424.  -   subscribeAllRequests: function(obj, hash) {
  1427. 1425.  -     ajax.post('al_friends.php', {act: 'subscribe_all_requests', hash: hash, once: 1}, {
  1428. 1426.  -       showProgress: lockButton.pbind(obj),
  1429. 1427.  -       hideProgress: unlockButton.pbind(obj)
  1430. 1428.  -     });
  1431. 1429.  -   },
  1432. 1430.  -   onAllRequestsRemove: function() {
  1433. 1431.  -     return nav.go('/friends?section=all_requests', false, {nocur: true});
  1434. 1432.  -   },
  1435. 1433.  -   editList: function(listId) {
  1436. 1434.  -     var checked = [];
  1437. 1435.  -     if (listId == -1) {
  1438. 1436.  -       listId = intval(cur.curList.substr(4));
  1439. 1437.  -     }
  1440. 1438.  -     if (listId) {
  1441. 1439.  -       var list = Friends.filter(cur.friendsList['all'], cur.curList);
  1442. 1440.  -       var len = list.length;
  1443. 1441.  -       while (len--) {
  1444. 1442.  -         checked.push(list[len][0]);
  1445. 1443.  -       }
  1446. 1444.  -     } else {
  1447. 1445.  -       listId = 0;
  1448. 1446.  -     }
  1449. 1447.  -     showTabbedBox('al_friends.php', {
  1450. 1448.  -       act: 'select_friends_box',
  1451. 1449.  -       Checked: checked.join(','),
  1452. 1450.  -       from: 'list',
  1453. 1451.  -       list_name: (listId ? cur.userLists[listId] : ''),
  1454. 1452.  -       list_id: listId
  1455. 1453.  -     }, {
  1456. 1454.  -       stat: ['privacy.js', 'ui_controls.js', 'ui_controls.css'],
  1457. 1455.  -       cache: 1,
  1458. 1456.  -       onFail: function(text) {
  1459. 1457.  -         setTimeout(showFastBox(getLang('global_error'), text).hide, 3000);
  1460. 1458.  -         return true;
  1461. 1459.  -       }
  1462. 1460.  -     });
  1463. 1461.  -     cur.onFlistSave = function (ids, list, hash, title) {
  1464. 1462.  -       var friendsList = [];
  1465. 1463.  -       for (var i in list) {
  1466. 1464.  -         friendsList.push(parseInt(i));
  1467. 1465.  -       }
  1468. 1466.  -
  1469. 1467.  -       ajax.post('al_friends.php', {act: 'save_list', title: title, cat_id: listId, Friends: friendsList.join(','), hash: hash}, {
  1470. 1468.  -         onDone: function(id, title) {
  1471. 1469.  -           Friends.editListClient(listId, id, title, friendsList);
  1472. 1470.  -         },
  1473. 1471.  -         onFail: function(text) {
  1474. 1472.  -           setTimeout(showFastBox({title: getLang('global_error')}, text, getLang('global_close')).hide, 4000);
  1475. 1473.  -           return true;
  1476. 1474.  -         }
  1477. 1475.  -       });
  1478. 1476.  -
  1479. 1477.  -       Friends.clearFilter();
  1480. 1478.  -
  1481. 1479.  -       return false;
  1482. 1480.  -     };
  1483. 1481.  -
  1484. 1482.  -   },
  1485. 1483.  -   editListClient: function(listId, id, title, friendsList) {
  1486. 1484.  -     var listName = 'list' + id;
  1487. 1485.  -     if (listId == 0) {
  1488. 1486.  -       var html = '<a onmousedown="return nav.change({\'0\':\'al_friends.php\', section:\'list'+id+'\'});" id="section_list'+id+'" class="side_filter">'+title+'</a>';
  1489. 1487.  -       ge('sections_block').insertBefore(ce('div', {
  1490. 1488.  -         innerHTML: html
  1491. 1489.  -       }), ge('friends_create_list'));
  1492. 1490.  -       var len = friendsList.length;
  1493. 1491.  -       var mask = 1 << parseInt(id);
  1494. 1492.  -       cur.friendsList[listName] = [];
  1495. 1493.  -       while (len--) {
  1496. 1494.  -         var friend = cur.friends[friendsList[len]];
  1497. 1495.  -         friend[6] = parseInt(friend[6]);
  1498. 1496.  -
  1499. 1497.  -         if (!(friend[6] & mask)) {
  1500. 1498.  -           friend[6] += mask;
  1501. 1499.  -           cur.friendsList[listName].push(friend)
  1502. 1500.  -         }
  1503. 1501.  -       }
  1504. 1502.  -       cur.userLists[id] = title;
  1505. 1503.  -       //Friends.indexAll();
  1506. 1504.  -       Friends.indexAll();
  1507. 1505.  -       removeClass(ge('main_class'), 'no_lists');
  1508. 1506.  -       return nav.change({'0':'friends', section: listName});
  1509. 1507.  -     } else {
  1510. 1508.  -       if (id < 25) {
  1511. 1509.  -         ge('section_list'+id).innerHTML = title;
  1512. 1510.  -         cur.userLists[id] = title;
  1513. 1511.  -       }
  1514. 1512.  -       var mask = (1 << id);
  1515. 1513.  -       cur.friendsList[listName] = [];
  1516. 1514.  -       for (var i in cur.friends) {
  1517. 1515.  -         var friend = cur.friends[i];
  1518. 1516.  -         var inList = (friendsList.indexOf(parseInt(friend[0])) != -1);
  1519. 1517.  -         if (inList) {
  1520. 1518.  -           cur.friendsList[listName].push(friend);
  1521. 1519.  -         }
  1522. 1520.  -         friend[6] = parseInt(friend[6]);
  1523. 1521.  -         if (friend[6] & mask) {
  1524. 1522.  -           if (!inList) {
  1525. 1523.  -             friend[6] -= mask;
  1526. 1524.  -           }
  1527. 1525.  -         } else {
  1528. 1526.  -           if (inList) {
  1529. 1527.  -             friend[6] += mask;
  1530. 1528.  -           }
  1531. 1529.  -         }
  1532. 1530.  -       }
  1533. 1531.  -       Friends.indexAll();
  1534. 1532.  -       return Friends.section(listName, function() {
  1535. 1533.  -         Friends.changeSummary();
  1536. 1534.  -         nav.setLoc({'0':'friends', section: listName});
  1537. 1535.  -       });
  1538. 1536.  -     }
  1539. 1537.  -   },
  1540. 1538.  -   createList: function(event) {
  1541. 1539.  -     Friends.editList(0);
  1542. 1540.  -   },
  1543. 1541.  -   deleteList: function(listId) {
  1544. 1542.  -     showBox('al_friends.php', {act: 'delete_list_box', list_id: listId});
  1545. 1543.  -   },
  1546. 1544.  -   deleteListClient: function(listId) {
  1547. 1545.  -     var listSection = ge('section_list'+listId);
  1548. 1546.  -     listSection.parentNode.removeChild(listSection);
  1549. 1547.  -     var mask = (1 << listId);
  1550. 1548.  -     for (var i in cur.friends) {
  1551. 1549.  -       if (cur.friends[i][6] & mask) {
  1552. 1550.  -         cur.friends[i][6] -= mask;
  1553. 1551.  -       }
  1554. 1552.  -     }
  1555. 1553.  -     delete cur.userLists[listId];
  1556. 1554.  -     var listsCount = 0;
  1557. 1555.  -     for (var i in cur.userLists) listsCount++;
  1558. 1556.  -     if (!listsCount) {
  1559. 1557.  -       addClass(ge('main_class'), 'no_lists');
  1560. 1558.  -     }
  1561. 1559.  -     //Friends.indexAll();
  1562. 1560.  -     return nav.change({'0':'friends', section:'all'});
  1563. 1561.  -   },
  1564. 1562.  -   searchForFriends: function() {
  1565. 1563.  -     showBox('al_friends.php', {act: 'search'}, {stat: ['friends_search.js', 'friends_search.css'], dark: 1});
  1566. 1564.  -   },
  1567. 1565.  -   selectList: function(obj, id, event) {
  1568. 1566.  -     Friends.ddShow(id, obj, event);
  1569. 1567.  -   },
  1570. 1568.  -   _animDelX: function(color, new_active, post) {
  1571. 1569.  -     if (post === undefined) {
  1572. 1570.  -       post = new_active;
  1573. 1571.  -       new_active = undefined;
  1574. 1572.  -     }
  1575. 1573.  -     var el = ge('delete_row' + post);
  1576. 1574.  -     if (!el) return;
  1577. 1575.  -     if (new_active !== undefined) {
  1578. 1576.  -       el.active = new_active;
  1579. 1577.  -     } else if (el.active) {
  1580. 1578.  -       return;
  1581. 1579.  -     }
  1582. 1580.  -     animate(el, {backgroundColor: color}, 200);
  1583. 1581.  -   },
  1584. 1582.  -   hideSuggestion: function(mid, hash, el) {
  1585. 1583.  -     var controls = ge('request_controls_'+mid);
  1586. 1584.  -     var controlsCont = controls.parentNode;
  1587. 1585.  -     (el || controls).innerHTML = '<div align="center"><img src="/images/upload.gif"></div>';
  1588. 1586.  -     ajax.post('al_friends.php', {act: 'hide_suggestion', mid: mid, hash: hash, report_spam: 1}, {onDone: function(text) {
  1589. 1587.  -       controls.innerHTML = text;
  1590. 1588.  -       cur.suggCount -= 1;
  1591. 1589.  -     }, onFail: function(text) {
  1592. 1590.  -       if (!text) return;
  1593. 1591.  -
  1594. 1592.  -       showFastBox(getLang('global_error'), text);
  1595. 1593.  -       return true;
  1596. 1594.  -     }});
  1597. 1595.  -     Friends.processRequest(mid, false, true);
  1598. 1596.  -
  1599. 1597.  -   },
  1600. 1598.  -   addRecommend: function(mid, uid, hash, obj) {
  1601. 1599.  -     obj = obj.parentNode;
  1602. 1600.  -     obj.innerHTML = '<img src="/images/upload.gif" />';
  1603. 1601.  -     ajax.post('al_friends.php', {
  1604. 1602.  -       act: 'a_suggest_friends',
  1605. 1603.  -       mid: mid,
  1606. 1604.  -       uids: uid,
  1607. 1605.  -       hash: hash,
  1608. 1606.  -       from: 'add'
  1609. 1607.  -     }, {
  1610. 1608.  -       onDone: function(text) {
  1611. 1609.  -         obj.innerHTML = text;
  1612. 1610.  -       },
  1613. 1611.  -       onFail: function(text) {
  1614. 1612.  -         obj.innerHTML = text;
  1615. 1613.  -       }
  1616. 1614.  -     })
  1617. 1615.  -
  1618. 1616.  -   },
  1619. 1617.  -   suggestBox: function(mid) {
  1620. 1618.  -     var box = showBox('al_friends.php', {
  1621. 1619.  -       act: 'select_friends_box',
  1622. 1620.  -       from: 'suggest_friends',
  1623. 1621.  -       friend_id: mid
  1624. 1622.  -     }, {stat: ['privacy.js', 'privacy.css', 'indexer.js', 'profile.css']});
  1625. 1623.  -     box.leaveOnSave = true;
  1626. 1624.  -     cur.onFlistSave = function(ids, list, hash) {
  1627. 1625.  -       //if (!ids || !ids.length) return;
  1628. 1626.  -       ajax.post('al_friends.php', {
  1629. 1627.  -         act: 'a_suggest_friends',
  1630. 1628.  -         mid: mid,
  1631. 1629.  -         ids: ids.join(','),
  1632. 1630.  -         hash: hash
  1633. 1631.  -       }, {
  1634. 1632.  -         onDone: function(text) {
  1635. 1633.  -           box.hide();
  1636. 1634.  -           showDoneBox(text);
  1637. 1635.  -         },
  1638. 1636.  -         showProgress: box.showProgress,
  1639. 1637.  -         hideProgress: box.hideProgress
  1640. 1638.  -       });
  1641. 1639.  -     }
  1642. 1640.  -   },
  1643. 1641.  -   getAgeFromData: function(max, opts) {
  1644. 1642.  -     max = parseInt(max);
  1645. 1643.  -     if (!max > 0) max = opts.ageTo;
  1646. 1644.  -     return Friends.getRangeData(opts.ageFrom, max, 1, opts.langAgeFrom+' ', opts.langAgeFromEmpty);
  1647. 1645.  -   },
  1648. 1646.  -   getAgeToData: function(min, opts) {
  1649. 1647.  -     min = parseInt(min);
  1650. 1648.  -     if (!min > 0) min = opts.ageFrom;
  1651. 1649.  -     return Friends.getRangeData(min, opts.ageTo, 1, opts.langAgeTo+' ', opts.langAgeToEmpty);
  1652. 1650.  -   },
  1653. 1651.  -   getRangeData: function(min, max, step, prefix, label) {
  1654. 1652.  -     if (min > max) return false;
  1655. 1653.  -     var ret = [[0, label]];
  1656. 1654.  -     if (step < 0) {
  1657. 1655.  -       for (var i = max; i >= min; i += step)
  1658. 1656.  -         ret.push([i, prefix + i]);
  1659. 1657.  -     } else if (step > 0) {
  1660. 1658.  -       for (var i = min; i <= max; i += step)
  1661. 1659.  -         ret.push([i, prefix + i]);
  1662. 1660.  -     }
  1663. 1661.  -     return ret;
  1664. 1662.  -   },
  1665. 1663.  -   radioFilter: function(el, value, fireEvent) {
  1666. 1664.  -     radiobtn(el, value, 'friends_radio_sex');
  1667. 1665.  -     if (fireEvent || fireEvent == undefined) {
  1668. 1666.  -       Friends.changeFilter();
  1669. 1667.  -     }
  1670. 1668.  -   },
  1671. 1669.  -   initFilters: function(opts) {
  1672. 1670.  -     stManager.add(['ui_controls.js', 'ui_controls.css'], function() {
  1673. 1671.  -       cur.cityFilter = new Dropdown(ge('friends_fltr_city'), opts.cities, {
  1674. 1672.  -         width: 150,
  1675. 1673.  -         zeroPlaceholder: true,
  1676. 1674.  -         placeholder: opts.citiesPl,
  1677. 1675.  -         placeholderColor: '#777',
  1678. 1676.  -         //selectedItems: '{$school_year}',
  1679. 1677.  -         onChange: Friends.changeFilter,
  1680. 1678.  -         onShow: function() {
  1681. 1679.  -           if (cur.silent) {
  1682. 1680.  -             cur.cityFilterOpened = true;
  1683. 1681.  -             show('friends_fltr_progress');
  1684. 1682.  -           }
  1685. 1683.  -         }
  1686. 1684.  -       });
  1687. 1685.  -
  1688. 1686.  -       cur.ageFromFilter = new Dropdown(ge('friends_age_from'), Friends.getAgeFromData(opts.ageTo, opts), {
  1689. 1687.  -         zeroPlaceholder: true,
  1690. 1688.  -         placeholderColor: '#777',
  1691. 1689.  -         width: 70,
  1692. 1690.  -         onChange: function(value){
  1693. 1691.  -          cur.ageToFilter.setData(Friends.getAgeToData(value, opts));
  1694. 1692.  -          Friends.changeFilter();
  1695. 1693.  -         }
  1696. 1694.  -       });
  1697. 1695.  -
  1698. 1696.  -       cur.ageToFilter = new Dropdown(ge('friends_age_to'), Friends.getAgeToData(opts.ageFrom, opts), {
  1699. 1697.  -         zeroPlaceholder: true,
  1700. 1698.  -         placeholderColor: '#777',
  1701. 1699.  -         width: 70,
  1702. 1700.  -         onChange: function(value){
  1703. 1701.  -           cur.ageFromFilter.setData(Friends.getAgeFromData(value, opts));
  1704. 1702.  -           Friends.changeFilter();
  1705. 1703.  -         }
  1706. 1704.  -       });
  1707. 1705.  -
  1708. 1706.  -       window.radioBtns['friends_radio_sex'] = {
  1709. 1707.  -         els: Array.prototype.slice.apply(geByClass('radiobtn', ge('friends_radio_sex'))),
  1710. 1708.  -         val: 0
  1711. 1709.  -       }
  1712. 1710.  -     });
  1713. 1711.  -   },
  1714. 1712.  -   clearFilter: function(fireEvent) {
  1715. 1713.  -     if (!cur.cityFilter) return;
  1716. 1714.  -     cur.cityFilter.selectItem(0, false);
  1717. 1715.  -     cur.ageFromFilter.selectItem(0, false);
  1718. 1716.  -     cur.ageToFilter.selectItem(0, false);
  1719. 1717.  -     Friends.radioFilter(ge('friends_radio_any'), 0, false);
  1720. 1718.  -     cur.filterIds = false;
  1721. 1719.  -     cur.filter = false;
  1722. 1720.  -     if (fireEvent) {
  1723. 1721.  -       Friends.changeFilter();
  1724. 1722.  -     }
  1725. 1723.  -   },
  1726. 1724.  -   filterParams: function() {
  1727. 1725.  -     var p = {
  1728. 1726.  -       city: parseInt(cur.cityFilter.val()),
  1729. 1727.  -       sex: parseInt(radioBtns['friends_radio_sex'].val),
  1730. 1728.  -       age_from: parseInt(cur.ageFromFilter.val()),
  1731. 1729.  -       age_to: parseInt(cur.ageToFilter.val())
  1732. 1730.  -     }
  1733. 1731.  -     if (p.city || p.sex || p.age_from || p.age_to) {
  1734. 1732.  -       return p;
  1735. 1733.  -     } else {
  1736. 1734.  -       return false;
  1737. 1735.  -     }
  1738. 1736.  -   },
  1739. 1737.  -   changeFilter: function() {
  1740. 1738.  -     if (cur.silent) {
  1741. 1739.  -       cur.onSilentLoad = function() {
  1742. 1740.  -         Friends.changeFilter();
  1743. 1741.  -       };
  1744. 1742.  -       hide(cur.showMore);
  1745. 1743.  -       cur.fContent.innerHTML = '<div class="wide_loading"></div>';
  1746. 1744.  -       return;
  1747. 1745.  -     }
  1748. 1746.  -     cur.filter = Friends.filterParams();
  1749. 1747.  -     if (cur.section == 'suggestions') {
  1750. 1748.  -       return Friends.section(cur.section, function() {}, cur.filter || true);
  1751. 1749.  -     }
  1752. 1750.  -     if (cur.filter) {
  1753. 1751.  -       ajax.post('friends', extend({act: 'filter_friends', uid: cur.oid}, cur.filter), {
  1754. 1752.  -         onDone: function(ids) {
  1755. 1753.  -           cur.filterIds = {};
  1756. 1754.  -           for (var i in ids) {
  1757. 1755.  -             cur.filterIds[ids[i]] = 1;
  1758. 1756.  -           }
  1759. 1757.  -           for (var i in cur.friendsList) {
  1760. 1758.  -             if (i.split('_').pop() == 'filter') {
  1761. 1759.  -               delete cur.friendsList[i];
  1762. 1760.  -             }
  1763. 1761.  -           }
  1764. 1762.  -           Friends.search(cur.searchStr || -1, cur.section, false, true);
  1765. 1763.  -           Friends.changeSummary();
  1766. 1764.  -         },
  1767. 1765.  -         progress: 'friends_fltr_progress',
  1768. 1766.  -         cache: 1
  1769. 1767.  -       })
  1770. 1768.  -     } else {
  1771. 1769.  -       if (cur.filterIds) {
  1772. 1770.  -         cur.filterIds = false;
  1773. 1771.  -       }
  1774. 1772.  -       Friends.updateList();
  1775. 1773.  -     }
  1776. 1774.  -   },
  1777. 1775.  -
  1778. 1776.  -   bigphOver: function(obj, uid) {
  1779. 1777.  -     if (!window.lang || !lang.global_photo_full_size || browser.mobile) return;
  1780. 1778.  -     var o = obj.firstChild, ch = cur.bigphCache[uid];
  1781. 1779.  -     if (o.tagName != 'A' || o.className != 'friends_bigph') {
  1782. 1780.  -       (o = obj.insertBefore(ce('a', {className: 'friends_bigph', href: ch && ch._id ? ('/photo' + ch._id + '?all=1') : ('/albums' + uid), innerHTML: '<span class="friends_bigph_label">' + getLang('global_photo_full_size') + '</span>'}), obj.firstChild)).onclick = Friends.bigphClick.pbind(uid);
  1783. 1781.  -       o._uid = uid;
  1784. 1782.  -     }
  1785. 1783.  -
  1786. 1784.  -     clearTimeout(o.hideTO);
  1787. 1785.  -     animate(o, {marginTop: 75}, {duration: 200, transition: Fx.Transitions.easeOutCirc});
  1788. 1786.  -     cur.bigphShown[uid] = o;
  1789. 1787.  -
  1790. 1788.  -     if (ch === undefined) {
  1791. 1789.  -       cur.bigphCache[uid] = 'load';
  1792. 1790.  -       ajax.post('al_photos.php', {act: 'fast_get_photo', oid: uid}, {onDone: function(res) {
  1793. 1791.  -         if (!res) {
  1794. 1792.  -           obj.onmouseover = function() {};
  1795. 1793.  -           re(obj.firstChild);
  1796. 1794.  -           return;
  1797. 1795.  -         }
  1798. 1796.  -         var sh = (cur.bigphCache[uid] == 'show');
  1799. 1797.  -         cur.bigphCache[uid] = res;
  1800. 1798.  -         o.href = '/photo' + res._id + '?all=1';
  1801. 1799.  -         if (sh) Friends.bigphClick(uid);
  1802. 1800.  -       }, onFail: function() {
  1803. 1801.  -         obj.onmouseover = function() {};
  1804. 1802.  -         re(obj.firstChild);
  1805. 1803.  -         return true;
  1806. 1804.  -       }});
  1807. 1805.  -     }
  1808. 1806.  -
  1809. 1807.  -     if (!obj.onmouseout) obj.onmouseout = Friends.bigphOut.pbind(obj);
  1810. 1808.  -   },
  1811. 1809.  -   bigphOut: function(obj) {
  1812. 1810.  -     var o = obj.firstChild;
  1813. 1811.  -     if (!o || o.tagName != 'A' || o.className != 'friends_bigph') return;
  1814. 1812.  -
  1815. 1813.  -     clearTimeout(o.hideTO);
  1816. 1814.  -     o.hideTO = setTimeout(function() {
  1817. 1815.  -       animate(o, {marginTop: 100}, 200);
  1818. 1816.  -       delete(cur.bigphShown[o._uid]);
  1819. 1817.  -     }, 150);
  1820. 1818.  -   },
  1821. 1819.  -   bigphClick: function(uid, ev) {
  1822. 1820.  -     if (checkEvent(ev) !== false) return;
  1823. 1821.  -
  1824. 1822.  -     var ch = cur.bigphCache[uid];
  1825. 1823.  -     if (ch == 'load' || ch == 'show') {
  1826. 1824.  -       cur.bigphCache[uid] = 'show';
  1827. 1825.  -       return cancelEvent(ev);
  1828. 1826.  -     }
  1829. 1827.  -     if (!ch) return;
  1830. 1828.  -     return showPhoto(ch._id, 'album' + uid + '_0/rev', extend({jumpTo: {z: 'albums' + uid}}, ch), ev);
  1831. 1829.  -   }
  1832. 1830.  -
  1833. 1831.  - }
  1834. 1832.  -
  1835. 1833.  - extend(Friends, {
  1836. 1834.  -   rowOver: Friends._animDelX.pbind('#C4D2E1'),
  1837. 1835.  -   rowOut: Friends._animDelX.pbind('#FFF'),
  1838. 1836.  -   activeDeleteRow: function(post, tt) {
  1839. 1837.  -     Friends._animDelX('#6B8DB1', 1, post);
  1840. 1838.  -     if (tt) showTooltip(ge('delete_row' + post), {text: tt, showdt: 500, black: 1});
  1841. 1839.  -   },
  1842. 1840.  -   deactiveDeleteRow: Friends._animDelX.pbind('#C4D2E1', 0),
  1843. 1841.  -   deleteRow: function(row, hash) {
  1844. 1842.  -     rowInfo = row.split('_');
  1845. 1843.  -     var obj = ge('suggestion'+row);
  1846. 1844.  -     if (hasClass(obj, 'user_block_first')) {
  1847. 1845.  -       nobj = obj.nextSibling;
  1848. 1846.  -       while (nobj && !isVisible(nobj)) {
  1849. 1847.  -         nobj = nobj.nextSibling;
  1850. 1848.  -       }
  1851. 1849.  -       if (nobj) {
  1852. 1850.  -         if (nobj.id == 'friends_sub_summary') {
  1853. 1851.  -           var summ = nobj.childNodes[0].innerHTML;
  1854. 1852.  -           ge('friends_summary').innerHTML = summ;
  1855. 1853.  -           re(nobj);
  1856. 1854.  -         } else if (nobj.className) {
  1857. 1855.  -           addClass(nobj, 'user_block_first')
  1858. 1856.  -         }
  1859. 1857.  -       }
  1860. 1858.  -     }
  1861. 1859.  -     slideUp('suggestion' + row, 100);
  1862. 1860.  -     if (tooltips) {
  1863. 1861.  -       tooltips.hide(ge('delete_row' + row))
  1864. 1862.  -     }
  1865. 1863.  -     ajax.post('al_friends.php', {act: 'hide_possible', mid: rowInfo[1], hash: hash}, {onDone: function() {
  1866. 1864.  -     }});
  1867. 1865.  -     var list = cur.friendsList['suggestions'];
  1868. 1866.  -     row = row.split('_');
  1869. 1867.  -     for (var i in list) {
  1870. 1868.  -       if (parseInt(list[i][0]) == parseInt(row[1])) {
  1871. 1869.  -         cur.friendsList['suggestions'].splice(i, 1);
  1872. 1870.  -       }
  1873. 1871.  -     }
  1874. 1872.  -     cur.importCount -= 1;
  1875. 1873.  -   }
  1876. 1874.  - });
  1877. 1875.  -
  1878. 1876.  - try{stManager.done('friends.js');}catch(e){}
  1879. ------
Advertisement
Add Comment
Please, Sign In to add comment