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