Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Файл - privacy.js (Старый размер - 40270 | Новый - 0):
- 0. - var Privacy = {
- 1. - flistBox: function (box, friendsData, selectedFriends, rowTemplate, saveLang, hash) {
- 2. - cur.flistTpl = rowTemplate;
- 3. - if (selectedFriends.length === 0) selectedFriends = {};
- 4. -
- 5. - cur.flistList = cur.flistFriends = friendsData;
- 6. - cur.flistSelected = selectedFriends;
- 7. -
- 8. - cur.flistIndex = new vkIndexer(friendsData, function(obj) {
- 9. - return obj[1]+' '+obj[4];
- 10. - });
- 11. -
- 12. - box.removeButtons();
- 13. -
- 14. - if (cur.flistTooltip) {
- 15. - if (cur.flistTooltipRight) {
- 16. - var hintLeft = '<td class="priv_h_arrow_td" style="vertical-align: top;"><div class="priv_h_arrow" style="margin-top: 50px;"><img src="/images/ddtooltip'+(window.devicePixelRatio >= 2 ? '_2x' : '')+'.png" width="16" height="11" class="priv_h_arrow_img png" /></div></td>';
- 17. - var hintRight = '';
- 18. - } else {
- 19. - var hintRight = '<td class="priv_h_arrow_td" style="vertical-align: top;"><div class="priv_h_arrow_l" style="margin-top: 50px;"><img src="/images/ddtooltip'+(window.devicePixelRatio >= 2 ? '_2x' : '')+'.png" width="16" height="11" class="priv_h_arrow_img png" /></div></td>';
- 20. - var hintLeft = '';
- 21. - }
- 22. -
- 23. -
- 24. - var ttHelper = ge('flist_helper');
- 25. - ttHelper.appendChild(ce('div', {
- 26. - innerHTML: '<table cellspacing="0" cellpadding="0">\
- 27. - <tr class="priv_h_top_sh">\
- 28. - <td></td>\
- 29. - <td colspan="5"><div class="priv_h_bottom2"></div></td>\
- 30. - </tr>\
- 31. - <tr class="priv_h_top_sh">\
- 32. - <td></td>\
- 33. - <td class="priv_h_side_td2"><div class="priv_h_side"></div></td>\
- 34. - <td colspan="3"><div class="priv_h_bottom"></div></td>\
- 35. - <td class="priv_h_side_td2"><div class="priv_h_side"></div></td>\
- 36. - </tr>\
- 37. - <tr>\
- 38. - '+hintLeft+'\
- 39. - <td class="priv_h_side_td2"><div class="priv_h_side"></div></td>\
- 40. - <td class="priv_h_side_td"><div class="priv_h_side"></div></td>\
- 41. - <td><div class="priv_h_rows flist_info_text" style="width: 179px;">'+cur.flistTooltip+'</div></td>\
- 42. - <td class="priv_h_side_td"><div class="priv_h_side"></div></td>\
- 43. - <td class="priv_h_side_td2"><div class="priv_h_side"></div></td>\
- 44. - '+hintRight+'\
- 45. - </tr>\
- 46. - <tr class="priv_h_bottom_sh">\
- 47. - <td></td>\
- 48. - <td class="priv_h_side_td2"><div class="priv_h_side"></div></td>\
- 49. - <td colspan="3"><div class="priv_h_bottom"></div></td>\
- 50. - <td class="priv_h_side_td2"><div class="priv_h_side"></div></td>\
- 51. - </tr>\
- 52. - <tr class="priv_h_bottom_sh">\
- 53. - <td></td>\
- 54. - <td colspan="5"><div class="priv_h_bottom2"></div></td>\
- 55. - </tr>\
- 56. - </table>'
- 57. - }));
- 58. - if (cur.flistTooltipRight) {
- 59. - ttHelper.style.marginLeft = '510px';
- 60. - animate(ttHelper, {opacity: 1, marginLeft: 538}, 200);
- 61. - } else {
- 62. - animate(ttHelper, {opacity: 1, marginLeft: -228}, 200);
- 63. - }
- 64. - } else {
- 65. - box.addButton(getLang('global_cancel'), function () {
- 66. - box.hide();
- 67. - }, 'no');
- 68. - }
- 69. - box.addButton(saveLang || getLang('global_save'), function () {
- 70. - var listName = ge('flist_list_name');
- 71. - var listStr = false;
- 72. - if (isVisible(listName)) {
- 73. - listStr = listName.value;
- 74. - if (!listStr) {
- 75. - return notaBene(listName);
- 76. - }
- 77. - placeholderSetup(listName, {back: true});
- 78. - elfocus(listName, 0, listName.value.length);
- 79. - }
- 80. - var list = {}, ids = [];
- 81. - each (friendsData, function () {
- 82. - if (cur.flistSelected[this[0]]) {
- 83. - list[this[0]] = this;
- 84. - ids.push(this[0]);
- 85. - }
- 86. - });
- 87. - if (cur.flistFriendsPrivacy) {
- 88. - ajax.post('al_settings.php', {act: 'hide_friends', hash: hash, ids: ids.join(',')}, {
- 89. - onDone: function(control, rules) {
- 90. - showDoneBox(cur.flistFriendsPrivacyText);
- 91. - box.hide();
- 92. - },
- 93. - showProgress: box.showProgress,
- 94. - hiderogress: box.hideProgress
- 95. - });
- 96. - showDoneBox(cur.flistFriendsPrivacyText, {out: 4000});
- 97. - if (cur.flistNavReload) setTimeout(function() {nav.reload();}, 2000);
- 98. - return;
- 99. - }
- 100. -
- 101. - if (cur.onFlistSave) {
- 102. - cur.onFlistSave(ids, list, hash, listStr);
- 103. - }
- 104. -
- 105. - if (!box.leaveOnSave) {
- 106. - box.hide();
- 107. - }
- 108. - });
- 109. -
- 110. - var rInner = ge('flist_right_inner');
- 111. - var rCol = ge('flist_right_col');
- 112. - var rHeight = getSize(rInner)[1];
- 113. - var rColHeight = getSize(rCol)[1];
- 114. - cur.flistScrollbar = new Scrollbar('flist_scroll_wrap', {
- 115. - nomargin: true,
- 116. - right: vk.rtl ? 'auto' : 0,
- 117. - left: !vk.rtl ? 'auto' : 0,
- 118. - more: Privacy.flistMore,
- 119. - onScroll: function(delta) {
- 120. - rCol.scrollTop -= delta;
- 121. - },
- 122. - wheelObj: ge('flist_cont')
- 123. - });
- 124. - addEvent(rCol, 'mousewheel', cur.flistScrollbar.wheel.bind(cur.flistScrollbar));
- 125. -
- 126. - cur.flistAllCont = ge('flist_all_list');
- 127. - cur.flistSelCont = ge('flist_sel_list');
- 128. - cur.flistSearchEl = ge('flist_search');
- 129. -
- 130. - if (cur.flistLimit && cur.flistSelectedCnt >= (cur.flistLimit - 1)) {
- 131. - Privacy.flistFull();
- 132. - }
- 133. -
- 134. - if (cur.flistCountStr && cur.flistSelectedCnt > 0) {
- 135. - ge('flist_sel_summary').innerHTML = langNumeric(cur.flistSelectedCnt, cur.flistCountStr);
- 136. - }
- 137. -
- 138. -
- 139. - return false;
- 140. - },
- 141. - flistMore: function() {
- 142. - var lim = cur.flistShown + 60;
- 143. - while(cur.flistShown < lim && Privacy.flistShowOne(cur.flistList[cur.flistShown + 1])) {
- 144. - ++cur.flistShown;
- 145. - }
- 146. - setTimeout(function() {
- 147. - cur.flistScrollbar.update();
- 148. - }, 10);
- 149. - },
- 150. - flistShowOne: function(u, ins) {
- 151. - if (!u) return false;
- 152. - if (ge('flist_sel_cell' + u[0])) {
- 153. - return true;
- 154. - }
- 155. - if (ge('flist_cell' + u[0])) {
- 156. - show(ge('flist_cell' + u[0]));
- 157. - return true;
- 158. - }
- 159. - var uname = u[1];
- 160. - if (cur.flistSelection) {
- 161. - uname = uname.replace(cur.flistSelection.re, cur.flistSelection.val);
- 162. - }
- 163. - var row = ce('div', {id: 'flist_cell' + u[0], innerHTML: cur.flistTpl.replace('%id%', u[0]).replace('%name%', uname).replace('%photo%', u[2])});
- 164. - if (ins) {
- 165. - cur.flistAllCont.insertBefore(row, cur.flistAllCont.firstChild);
- 166. - } else {
- 167. - cur.flistAllCont.appendChild(row);
- 168. - }
- 169. - return true;
- 170. - },
- 171. - flistSelect: function(id, obj, event) {
- 172. - var el = ge('flist_cell'+id);
- 173. - var cont = obj.parentNode;
- 174. - if (cont.id.slice(0, 9) == 'flist_sel') {
- 175. - re(cont);
- 176. - if (el) {
- 177. - show(el);
- 178. - } else {
- 179. - for (var i in cur.flistList) {
- 180. - if (cur.flistList[i][0] == id) {
- 181. - Privacy.flistShowOne(cur.flistList[i], true);
- 182. - break;
- 183. - }
- 184. - }
- 185. - }
- 186. - cur.flistSelectedCnt--;
- 187. - if (cur.flistSelectedCnt == 0) {
- 188. - show('flist_info');
- 189. - }
- 190. - if (cur.flistLimit && cur.flistSelectedCnt == (cur.flistLimit - 1)) {
- 191. - removeClass(cur.flistAllCont, 'flist_full');
- 192. - }
- 193. - curBox().changed = true;
- 194. - delete cur.flistSelected[id];
- 195. - } else {
- 196. - if (cur.flistLimit && cur.flistSelectedCnt >= cur.flistLimit) {
- 197. - Privacy.flistFull(event || window.event);
- 198. - return false;
- 199. - }
- 200. - var html = val(el);
- 201. - hide(el);
- 202. - cur.flistSelCont.insertBefore(ce('div', {
- 203. - id: 'flist_sel_cell'+id,
- 204. - innerHTML: html
- 205. - }), cur.flistSelCont.firstChild);
- 206. - if (Privacy.flistShowOne(cur.flistList[cur.flistShown + 1])) {
- 207. - ++cur.flistShown;
- 208. - }
- 209. - if (cur.flistSelectedCnt == 0) {
- 210. - hide('flist_info');
- 211. - }
- 212. - cur.flistSelectedCnt++;
- 213. - if (cur.flistLimit && cur.flistSelectedCnt >= cur.flistLimit) {
- 214. - Privacy.flistFull(event || window.event);
- 215. - }
- 216. - cur.flistSelected[id] = true;
- 217. - if (cur.flistSearchStr) {
- 218. - Privacy.flistSearch(false);
- 219. - }
- 220. - }
- 221. - if (cur.flistCountStr) {
- 222. - val('flist_sel_summary', cur.flistSelectedCnt > 0 ? langNumeric(cur.flistSelectedCnt, cur.flistCountStr) : cur.flistNoSelStr);
- 223. - }
- 224. - cur.flistScrollbar.update();
- 225. - return false;
- 226. - },
- 227. - flistFull: function(tooltipEvent) {
- 228. - if (tooltipEvent) {
- 229. - var tt = showTooltip(bodyNode, {
- 230. - text: cur.limitTooltip,
- 231. - className: 'flist_max_size_tt',
- 232. - slideX: -15,
- 233. - shift: [-tooltipEvent.pageX - 5, -tooltipEvent.pageY - 5, 300],
- 234. - nohide: 1,
- 235. - hasover: 1,
- 236. - toup: 1
- 237. - });
- 238. - setTimeout(function() {
- 239. - tooltips.hide(bodyNode);
- 240. - }, 2000);
- 241. - }
- 242. - addClass(cur.flistAllCont, 'flist_full');
- 243. - },
- 244. - flistSearch: function(obj, event) {
- 245. - if (event && event.keyCode < 41 && event.keyCode > 15) {
- 246. - if (event.keyCode == 27) {
- 247. - if (obj.value) {
- 248. - cancelEvent(event);
- 249. - }
- 250. - obj = false;
- 251. - } else {
- 252. - return;
- 253. - }
- 254. - }
- 255. - setTimeout(function() {
- 256. - var str = obj ? obj.value : '';
- 257. - cur.flistSearchStr = str;
- 258. - if (str) {
- 259. - cur.flistList = cur.flistIndex.search(str);
- 260. - cur.flistSelection = {
- 261. - re: new RegExp('('+str.replace(cur.flistIndex.delimiter, '|').replace(/[\/\\\(\)\[\]\{\}\*,]/g, '').replace(/^\||\|$/g, '')+')', 'gi'),
- 262. - val: '<em>$1</em>'
- 263. - };
- 264. - show('flist_search_reset');
- 265. - cur.flistScrollbar.scrollTop(0);
- 266. - } else {
- 267. - cur.flistList = cur.flistFriends;
- 268. - cur.flistSelection = false;
- 269. - hide('flist_search_reset');
- 270. - val(cur.flistSearchEl, '');
- 271. - }
- 272. -
- 273. - if (cur.flistList.length) {
- 274. - cur.flistAllCont.innerHTML = '';
- 275. - cur.flistShown = -1;
- 276. - Privacy.flistMore();
- 277. - } else {
- 278. -
- 279. - }
- 280. - }, 0);
- 281. - },
- 282. - hideFriends: function(key, obj) {
- 283. - var checked = cur.privacy[key][2];
- 284. - showBox('al_friends.php', {act: 'select_friends_box', from: 'friends_privacy', Checked: checked.join(',')}, {stat: ['privacy.js', 'privacy.css', 'indexer.js']});
- 285. - cur.onFlistSave = function(ids, list, hash) {
- 286. - ajax.post('al_settings.php', {act: 'hide_friends', hash: hash, ids: ids.join(',')}, {
- 287. - onDone: function(control, rules) {
- 288. - ge('privacy_'+key+'_hide').innerHTML = control;
- 289. - cur.privacy[key] = rules;
- 290. - if (cur.onPrivacyChanged) cur.onPrivacyChanged(key);
- 291. - }
- 292. - });
- 293. - }
- 294. - },
- 295. -
- 296. - customType: 4,
- 297. - someType: 5,
- 298. - listsType: 6,
- 299. - update: function(key) {
- 300. - var el = ge('privacy_edit_' + key), p = cur.privacy[key], v = p[0];
- 301. - var types = cur.privacy[key + '_types'] || cur.privacy._types;
- 302. - var lists = cur.privacy[key + '_lists'] || cur.privacy._lists || {};
- 303. -
- 304. - if (el) {
- 305. - ge('privacy_header').innerHTML = el.innerHTML = types[v];
- 306. - if (el.nextSibling) {
- 307. - if (v == Privacy.listsType) {
- 308. - var str = [];
- 309. - for (var i in p[2]) {
- 310. - var cat_id = -p[2][i], color = (cat_id - 1) % 8 + 1;
- 311. - str.push('<span class="group' + color + '">' + lists[cat_id] + '</span>');
- 312. - }
- 313. - el.nextSibling.innerHTML = (str.length ? ': ' : '') + str.join(', ');
- 314. - } else {
- 315. - el.nextSibling.innerHTML = '';
- 316. - }
- 317. - }
- 318. - }
- 319. -
- 320. - if (cur.onPrivacyChanged) cur.onPrivacyChanged(key);
- 321. - },
- 322. - someSaved: function(key, ids, list, plain) {
- 323. - cur.privacy[key] = [Privacy.someType, 0, ids, []];
- 324. -
- 325. - var count = ids.length, str = [];
- 326. - for (var i = 0; i < count && i < 5; ++i) {
- 327. - var id = ids[i], mem = plain ? list[i] : list[id], shortname = mem[4].replace(/'/g, '');
- 328. - str.push('<a href="/' + (shortname ? shortname : ('id' + id)) + '" onclick="return nav.go(this, event)">' + mem[1] + '</a>');
- 329. - }
- 330. - str = str.join(', ');
- 331. - if (count > 5) {
- 332. - str += ' ' + getLang('privacy_N_friends_some', count - 5);
- 333. - }
- 334. -
- 335. - var el = ge('privacy_edit_' + key);
- 336. - var types = cur.privacy[key + '_types'] || cur.privacy._types;
- 337. - el.innerHTML = types[Privacy.someType];
- 338. - el.nextSibling.innerHTML = ': ' + str;
- 339. -
- 340. - if (cur.onPrivacyChanged) cur.onPrivacyChanged(key);
- 341. - },
- 342. - customSaved: function(key, np, plus, minus) {
- 343. - cur.privacy[key] = np;
- 344. - if (np[1] == 1 && !np[3].length || np[0] == Privacy.listsType) {
- 345. - Privacy.update(key);
- 346. - } else if (np[0] == Privacy.someType) {
- 347. - Privacy.someSaved(key, np[2], plus, true);
- 348. - } else { // save here
- 349. - var el = ge('privacy_edit_' + key);
- 350. - var types = cur.privacy[key + '_types'] || cur.privacy._types;
- 351. - var lists = cur.privacy[key + '_lists'] || cur.privacy._lists || {};
- 352. -
- 353. - if (key == 'hidden_friends') { // hack for hidden friends
- 354. - types = cur.privacy._types;
- 355. - }
- 356. -
- 357. - var label = types[Privacy.listsType], str = '';
- 358. - if (np[1] == 1) {
- 359. - label = types[np[2][0]];
- 360. - } else {
- 361. - str = [];
- 362. - var count = plus.length, hasUser = false;
- 363. - for (var i = 0; i < count && i < 5; ++i) {
- 364. - var mem = plus[i], id = mem[0];
- 365. - if (id > 0) {
- 366. - var shortname = mem[4].replace(/'/g, '');
- 367. - hasUser = true;
- 368. - str.push('<a href="/' + (shortname ? shortname : ('id' + id)) + '" onclick="return nav.go(this, event)">' + mem[5] + '</a>');
- 369. - } else {
- 370. - var cat_id = -id, color = (cat_id - 1) % 8 + 1;
- 371. - str.push('<span class="group' + color + '">' + lists[cat_id] + '</span>');
- 372. - }
- 373. - }
- 374. - if (hasUser) {
- 375. - label = types[Privacy.someType];
- 376. - }
- 377. - str = ': ' + str.join(', ');
- 378. - if (count > 5) {
- 379. - str += ' ' + getLang('privacy_N_friends_some', count - 5);
- 380. - }
- 381. - }
- 382. - if (minus.length) {
- 383. - var count = minus.length, mstr = [];
- 384. - for (var i = 0; i < count && i < 5; ++i) {
- 385. - var mem = minus[i], id = mem[0];
- 386. - if (id > 0) {
- 387. - var shortname = mem[4].replace(/'/g, '');
- 388. - mstr.push('<a href="/' + (shortname ? shortname : ('id' + id)) + '" onclick="return nav.go(this, event)">' + mem[6] + '</a>');
- 389. - } else {
- 390. - var cat_id = -id, color = (cat_id - 1) % 8 + 1;
- 391. - mstr.push('<span class="group' + color + '">' + lists[cat_id] + '</span>');
- 392. - }
- 393. - }
- 394. - str += ', ' + getLang('global_privacy_except') + ' ' + mstr.join(', ');
- 395. - if (count > 5) {
- 396. - str += ' ' + getLang('privacy_N_friends_more', count - 5);
- 397. - }
- 398. - }
- 399. - el.innerHTML = label;
- 400. - el.nextSibling.innerHTML = str;
- 401. -
- 402. - if (cur.onPrivacyChanged) cur.onPrivacyChanged(key);
- 403. - }
- 404. - },
- 405. - choose: function(ev, val, list) {
- 406. - var key = cur.privSel, p = cur.privacy[key], noselect = (cur.privacy._noselect || key == 'chat_actions');
- 407. - if (noselect) {
- 408. - if (cur.onPrivacyChanged) cur.onPrivacyChanged(key, val, list);
- 409. - Privacy.qhide();
- 410. - return cancelEvent(ev);
- 411. - }
- 412. - if (val == Privacy.customType) {
- 413. - var type, plus, minus = [];
- 414. - if (p[0] == Privacy.customType) {
- 415. - type = p[1];
- 416. - plus = p[2];
- 417. - minus = p[3];
- 418. - } else if (p[0] == Privacy.someType || p[0] == Privacy.listsType) {
- 419. - type = 0;
- 420. - plus = p[2];
- 421. - } else {
- 422. - type = 1;
- 423. - plus = p[2];
- 424. - }
- 425. - cur.onCprivSave = Privacy.customSaved.pbind(key);
- 426. - return showBox('al_friends.php', {act: 'custom_privacy_box', type: type, plus: plus.join(','), minus: minus.join(','), opt: cur.privacy.custom_box_type ? cur.privacy.custom_box_type : (key == 'apps_invite' || key == 'videocalls' ? 'fronly' : '')}, {stat: ['ui_controls.js', 'ui_controls.css']});
- 427. - } else if (val == Privacy.someType) {
- 428. - var checked = (p[0] == Privacy.someType || p[0] == Privacy.complexType && p[1] == 0) ? p[2].join(',') : '';
- 429. - cur.onFlistSave = function (ids, list) {
- 430. - Privacy.someSaved(key, ids, list);
- 431. - }
- 432. - return showTabbedBox('al_friends.php', {act: 'select_friends_box', Checked: checked}, {stat: ['ui_controls.js']});
- 433. - } else if (val == Privacy.listsType) {
- 434. - var el = ge('privacy_l_item' + list);
- 435. - if (el.className == 'l_item_sel') {
- 436. - el.className = 'l_item';
- 437. - var ind = indexOf(p[2], -list);
- 438. - if (ind != -1) {
- 439. - p[2].splice(ind, 1);
- 440. - }
- 441. - if (!p[2].length && key != 'updates') { // sorry, dirty hack
- 442. - cur.privacy[key] = [0, 1, [0], []];
- 443. - }
- 444. - } else {
- 445. - el.className = 'l_item_sel';
- 446. - if (p[0] != val) {
- 447. - p = cur.privacy[key] = [val, 0, [], []];
- 448. - }
- 449. - p[2].push(-list);
- 450. - }
- 451. - Privacy.update(key);
- 452. - return cancelEvent(ev);
- 453. - }
- 454. - cur.privacy[key] = [val, 1, [val], []];
- 455. - Privacy.update(key);
- 456. - Privacy.qhide();
- 457. - },
- 458. - select: function(val, force) {
- 459. - if (!force && val === cur.privSelIndex) return;
- 460. - if (cur.privSelIndex !== false) {
- 461. - var el = ge('privacy_item' + cur.privSelIndex);
- 462. - if (el) el.className = 'item';
- 463. - if (cur.privSelIndex == Privacy.listsType && cur.privacy[cur.privSel][0] != Privacy.listsType) {
- 464. - if (Privacy.toup) {
- 465. - hide(el.previousSibling);
- 466. - setStyle(cur.privEl, {top: cur.privFromY - getSize(cur.privEl)[1]});
- 467. - } else {
- 468. - hide(el.nextSibling);
- 469. - }
- 470. - }
- 471. - }
- 472. - cur.privSelIndex = val;
- 473. - var el = ge('privacy_item' + cur.privSelIndex), add = (cur.privSelIndex == Privacy.someType) ? '_plus' : '';
- 474. - if (el.nextSibling && el.nextSibling.id == 'privacy_item' + Privacy.listsType && isVisible(el.nextSibling.nextSibling)) {
- 475. - el.className = 'last item_sel' + add;
- 476. - } else {
- 477. - if (val == Privacy.listsType) {
- 478. - if (Privacy.toup) {
- 479. - show(el.previousSibling);
- 480. - setStyle(cur.privEl, {top: cur.privFromY - getSize(cur.privEl)[1]});
- 481. - } else {
- 482. - show(el.nextSibling);
- 483. - }
- 484. - } else {
- 485. - el.className = 'item_sel' + add;
- 486. - }
- 487. - }
- 488. - },
- 489. - unselect: function(val) {
- 490. - if (val != cur.privSelIndex) return;
- 491. - ge('privacy_item' + val).className = 'item';
- 492. - cur.privSelIndex = false;
- 493. - },
- 494. - hide: function(timeout) {
- 495. - if (timeout > 0) {
- 496. - cur.hidePrivacyTimer = setTimeout(Privacy.hide.pbind(0), timeout);
- 497. - return;
- 498. - }
- 499. - clearTimeout(cur.hidePrivacyTimer);
- 500. - if (timeout == -1) {
- 501. - hide(cur.privEl, cur.privHelper);
- 502. - } else if (isVisible) {
- 503. - fadeOut(cur.privEl, 200);
- 504. - if (cur.privHelper) {
- 505. - fadeOut(cur.privHelper, 200);
- 506. - }
- 507. - }
- 508. - cur.privSel = cur.privSelIndex = false;
- 509. - removeEvent(document, 'click', Privacy.qhide);
- 510. - },
- 511. - show: function(el, ev, key, delta) {
- 512. - var p = cur.privacy[key], noselect = (key.indexOf('actions') != -1);
- 513. - if (!p) return;
- 514. -
- 515. - if (!cur.privEl) {
- 516. - if (cur.privEl = ge('privacy_dropdown')) {
- 517. - cur.privRows = cur.privEl.firstChild.rows[1].cells[1].firstChild;
- 518. - }
- 519. - }
- 520. - if (!cur.privEl) {
- 521. - cur.privEl = bodyNode.appendChild(ce('div', {id: 'privacy_dropdown', innerHTML: '\
- 522. - <table cellspacing="0" cellpadding="0">\
- 523. - <tr class="top_sh">\
- 524. - <td colspan="3">\
- 525. - <div class="bottom2"></div><div class="bottom"></div>\
- 526. - </td>\
- 527. - <tr>\
- 528. - <td class="side"><div></div></td>\
- 529. - <td><div class="rows"></div></td>\
- 530. - <td class="side"><div></div></td>\
- 531. - </tr>\
- 532. - <tr class="bottom_sh">\
- 533. - <td colspan="3">\
- 534. - <div class="bottom"></div><div class="bottom2"></div>\
- 535. - </td>\
- 536. - </tr>\
- 537. - </table>'}));
- 538. - cur.privRows = cur.privEl.firstChild.rows[1].cells[1].firstChild;
- 539. - addEvent(cur.privEl, 'mouseout', Privacy.hide.pbind(500));
- 540. - addEvent(cur.privEl, 'mouseover', function() { clearTimeout(cur.hidePrivacyTimer); });
- 541. - }
- 542. - setTimeout(addEvent.pbind(document, 'click', Privacy.qhide), 1);
- 543. -
- 544. - var types = cur.privacy[key + '_types'] || cur.privacy._types;
- 545. - var lists = cur.privacy[key + '_lists'] || cur.privacy._lists || {};
- 546. - var hidden = cur.privacy[key + '_hidden'] || cur.privacy._hidden || {};
- 547. - var fontSize = getStyle(el, 'fontSize') || vk.fs;
- 548. - setStyle(cur.privRows, {fontSize: fontSize});
- 549. -
- 550. - cur.privSelIndex = p[0];
- 551. - if (hidden[cur.privSelIndex]) { cur.privSelIndex = 0; }
- 552. -
- 553. - var html = [], sel, handlers, hasLists = false;
- 554. - for (var i in lists) {
- 555. - hasLists = true; break;
- 556. - }
- 557. - html.push('<div class="header" onclick="Privacy.hide(-1)"><div id="privacy_header">' + el.innerHTML + '</div></div>');
- 558. - html.push('<div class="body">');
- 559. - for (var i in types) {
- 560. - if (hidden[i]) { continue; }
- 561. - sel = (i == cur.privSelIndex && i != Privacy.listsType) ? '_sel' : '';
- 562. - handlers = 'onmouseover="Privacy.select(\'' + i + '\')" onclick="Privacy.choose(event, \'' + i + '\')"';
- 563. - if (i == Privacy.listsType) {
- 564. - if (!hasLists) {
- 565. - continue;
- 566. - }
- 567. - } else {
- 568. - handlers += ' onmouseout="Privacy.unselect(\'' + i + '\')"';
- 569. - }
- 570. - if (sel && i == Privacy.someType) {
- 571. - sel += '_plus';
- 572. - }
- 573. - html.push('<div class="item' + sel + '" id="privacy_item' + i + '" ' + handlers + '>' + types[i] + '</div>');
- 574. - }
- 575. - if (types[Privacy.listsType] && hasLists) {
- 576. - var hideLists = (cur.privSelIndex != Privacy.listsType);
- 577. - html.push('<div id="privacy_lists">');
- 578. - html.push('<div class="l_header" onclick="return cancelEvent(event)"><div>' + types[Privacy.listsType] + '</div></div>');
- 579. - for (var i in lists) {
- 580. - var sel = hideLists ? '' : (inArray(-i, p[2]) ? '_sel' : '');
- 581. - html.push('<div class="l_item' + sel + '" id="privacy_l_item' + i + '" onclick="Privacy.choose(event, ' + Privacy.listsType + ', ' + i + ')"><div class="privacy_item_icon"></div>' + lists[i] + '</div>');
- 582. - }
- 583. - html.push('</div>');
- 584. - }
- 585. - html.push('</div>');
- 586. - cur.privRows.innerHTML = html.join('');
- 587. - cur.privSel = key;
- 588. -
- 589. - var helpText = cur.privacy[key + '_help'], hsz = [0, 0], hw = cur.privacy[key + '_help_w'];
- 590. - if (helpText) {
- 591. - if (!cur.privHelper) {
- 592. - if (cur.privHelper = ge('privacy_helper')) {
- 593. - cur.privHelp = cur.privHelper.firstChild.rows[2].cells[3].firstChild;
- 594. - }
- 595. - }
- 596. - if (!cur.privHelper) {
- 597. - cur.privHelper = bodyNode.appendChild(ce('div', {id: 'privacy_helper', innerHTML: '\
- 598. - <table cellspacing="0" cellpadding="0">\
- 599. - <tr class="priv_h_top_sh">\
- 600. - <td></td>\
- 601. - <td colspan="5"><div class="priv_h_bottom2"></div></td>\
- 602. - </tr>\
- 603. - <tr class="priv_h_top_sh">\
- 604. - <td></td>\
- 605. - <td class="priv_h_side_td2"><div class="priv_h_side"></div></td>\
- 606. - <td colspan="3"><div class="priv_h_bottom"></div></td>\
- 607. - <td class="priv_h_side_td2"><div class="priv_h_side"></div></td>\
- 608. - </tr>\
- 609. - <tr>\
- 610. - <td class="priv_h_arrow_td"><div class="priv_h_arrow"><img src="/images/ddtooltip'+(window.devicePixelRatio >= 2 ? '_2x' : '')+'.png" width="16" height="11" class="priv_h_arrow_img png" /></div></td>\
- 611. - <td class="priv_h_side_td2"><div class="priv_h_side"></div></td>\
- 612. - <td class="priv_h_side_td"><div class="priv_h_side"></div></td>\
- 613. - <td><div class="priv_h_rows"' + (hw ? ' style="width: ' + hw + 'px"' : '') + '></div></td>\
- 614. - <td class="priv_h_side_td"><div class="priv_h_side"></div></td>\
- 615. - <td class="priv_h_side_td2"><div class="priv_h_side"></div></td>\
- 616. - </tr>\
- 617. - <tr class="priv_h_bottom_sh">\
- 618. - <td></td>\
- 619. - <td class="priv_h_side_td2"><div class="priv_h_side"></div></td>\
- 620. - <td colspan="3"><div class="priv_h_bottom"></div></td>\
- 621. - <td class="priv_h_side_td2"><div class="priv_h_side"></div></td>\
- 622. - </tr>\
- 623. - <tr class="priv_h_bottom_sh">\
- 624. - <td></td>\
- 625. - <td colspan="5"><div class="priv_h_bottom2"></div></td>\
- 626. - </tr>\
- 627. - </table>'}));
- 628. - cur.privHelp = cur.privHelper.firstChild.rows[2].cells[3].firstChild;
- 629. - addEvent(cur.privHelper, 'mouseout', Privacy.hide.pbind(500));
- 630. - addEvent(cur.privHelper, 'mouseover', function() { clearTimeout(cur.hidePrivacyTimer); });
- 631. - }
- 632. - cur.privHelp.innerHTML = helpText;
- 633. -
- 634. - var tw = data(cur.privHelper, 'tween');
- 635. - if (tw) tw.stop(true);
- 636. - //show(cur.privHelper);
- 637. -
- 638. - var hsz = getSize(cur.privHelper);
- 639. - }
- 640. - var tw = data(cur.privEl, 'tween');
- 641. - if (tw) tw.stop(true);
- 642. - show(cur.privEl);
- 643. -
- 644. - var isFixed = false, pel = el;
- 645. - while (pel) {
- 646. - if (getStyle(pel, 'position') == 'fixed') {
- 647. - isFixed = true;
- 648. - break;
- 649. - }
- 650. - pel = pel.offsetParent;
- 651. - }
- 652. - cur.privEl.className = 'privacy_dropdown_' + key;
- 653. - if (isFixed) {
- 654. - addClass(cur.privEl, 'fixed');
- 655. - setStyle(cur.privEl, {position: ''});
- 656. - addClass(cur.privHelper, 'fixed');
- 657. - setStyle(cur.privHelper, {position: ''});
- 658. - } else {
- 659. - removeClass(cur.privEl, 'fixed');
- 660. - setStyle(cur.privEl, {position: 'absolute'});
- 661. - removeClass(cur.privHelper, 'fixed');
- 662. - setStyle(cur.privHelper, {position: 'absolute'});
- 663. - }
- 664. -
- 665. - var sz = getSize(cur.privEl), h = Math.max(sz[1], hsz[1])
- 666. - if (types[Privacy.listsType] && hideLists) {
- 667. - hide('privacy_lists');
- 668. - }
- 669. -
- 670. - if (delta === undefined) {
- 671. - delta = isFixed ? [0, 0] : [-1, -1];
- 672. - }
- 673. - var xy = getXY(el, isFixed), dx = 7 + delta[0], dy = 3 + delta[1];
- 674. - if ((browser.msie || browser.opera) && !isFixed) {
- 675. - dx += 1;
- 676. - dy += 1;
- 677. - }
- 678. -
- 679. - var y = xy[1] - dy - ((browser.msie6 || isFixed) ? 0 : scrollNode.scrollTop);
- 680. - Privacy.toup = false;
- 681. - if (y - h > 0) {
- 682. - if (y + h > lastWindowHeight) {
- 683. - Privacy.toup = true;
- 684. -
- 685. - var r = cur.privRows;
- 686. - r.appendChild(r.firstChild);
- 687. -
- 688. - var b = r.firstChild;
- 689. - for (var e = b.firstChild, t = false; e.nextSibling && e.nextSibling != t; e = b.firstChild) {
- 690. - if (t) {
- 691. - t = b.insertBefore(e, t);
- 692. - } else {
- 693. - t = b.appendChild(e);
- 694. - }
- 695. - }
- 696. -
- 697. - var l = b.firstChild;
- 698. - if (l.id == 'privacy_lists') {
- 699. - for (var e = l.firstChild, t = false; e.nextSibling && e.nextSibling != t; e = l.firstChild) {
- 700. - if (t) {
- 701. - t = l.insertBefore(e, t);
- 702. - } else {
- 703. - t = l.appendChild(e);
- 704. - }
- 705. - }
- 706. - }
- 707. - sz = getSize(cur.privEl);
- 708. - }
- 709. - }
- 710. -
- 711. - if (vk.rtl) {
- 712. - var sz1 = getSize(el);
- 713. - xy[0] -= sz[0] - sz1[0];
- 714. - dx = -8;
- 715. - }
- 716. -
- 717. - bodyNode.appendChild(cur.privEl);
- 718. - if (Privacy.toup) {
- 719. - cur.privEl.firstChild.className = 'to_up';
- 720. - dy -= 1;
- 721. - cur.privFromY = xy[1] + getSize(cur.privRows.lastChild)[1] - dy;
- 722. - setStyle(cur.privEl, {left: xy[0] - dx, top: cur.privFromY - sz[1]});
- 723. - } else {
- 724. - cur.privEl.firstChild.className = '';
- 725. - setStyle(cur.privEl, {left: xy[0] - dx, top: xy[1] - dy});
- 726. - }
- 727. -
- 728. - if (helpText) {
- 729. - var hx = (xy[0] - dx) + (vk.rtl ? (-hsz[0]) : sz[0]), hy = 0;
- 730. - if (Privacy.toup) {
- 731. - cur.privHelper.firstChild.className = 'to_up';
- 732. - hy = cur.privFromY - hsz[1];
- 733. - } else {
- 734. - cur.privHelper.firstChild.className = '';
- 735. - hy = xy[1] - dy;
- 736. - }
- 737. - setStyle(cur.privHelper, {left: hx + 15, top: hy});
- 738. - animate(cur.privHelper, {opacity: 1, left: hx}, 200);
- 739. - } else {
- 740. - hide(cur.privHelper);
- 741. - }
- 742. -
- 743. - return cancelEvent(ev);
- 744. - },
- 745. - getValue: function(key) {
- 746. - var p = cur.privacy[key], res = [];
- 747. - if (p[0] < Privacy.customType) {
- 748. - res = [p[0]];
- 749. - } else if (p[0] == Privacy.someType) {
- 750. - res = [4, p[2].join(',')];
- 751. - } else if (p[0] == Privacy.listsType) {
- 752. - var l = [];
- 753. - for (var i in p[2]) {
- 754. - l.push(-p[2][i]);
- 755. - }
- 756. - res = [5, l.join(',')];
- 757. - } else {
- 758. - res = [-1, p[1], p[2].join(','), p[3].join(',')];
- 759. - }
- 760. - return res.join('_');
- 761. - }
- 762. - }
- 763. -
- 764. - Privacy.qhide = Privacy.hide.pbind(-1);
- 765. -
- 766. - function OList (box, owners, selected, options) {
- 767. - if (selected.length === 0) selected = {};
- 768. - options = options || {};
- 769. - // this.indexer = new Indexer(owners); // Requires ui_controls for indexer
- 770. - this.indexer = new vkIndexer(owners, options.getName ? options.getName : function(owner) {
- 771. - return owner[1];
- 772. - });
- 773. - this.owners = owners;
- 774. - this.tpl = options.tpl;
- 775. - this.rsTpl = options.rsTpl;
- 776. - this.idIndex = options.idIndex || 0;
- 777. - this.selected = selected;
- 778. - this.getUnsorted = options.getUnsorted;
- 779. - this.unsortedIndex = options.unsortedIndex || 0;
- 780. - this.box = box;
- 781. - this.nofocus = options.nofocus;
- 782. - if (options.onTabUpdate) {
- 783. - this.onTabUpdate = options.onTabUpdate;
- 784. - }
- 785. -
- 786. - box.removeButtons();
- 787. - box.addButton(getLang('global_cancel'), function () {
- 788. - if (cur.onOListCancel && cur.onOListCancel(options.ret || {}) === false) {
- 789. - return;
- 790. - }
- 791. - box.hide(200);
- 792. - }, 'no');
- 793. - box.addButton(options['save_lang'] || getLang('global_save'), function () {
- 794. - var list = {}, ids = [], inv = [];
- 795. - each (owners, function () {
- 796. - if (!self.invertedSelection && self.selected[this[self.idIndex]] || self.invertedSelection && !self.selected[this[self.idIndex]]) {
- 797. - list[this[self.idIndex]] = this;
- 798. - ids.push(this[self.idIndex]);
- 799. - } else {
- 800. - inv.push(this[self.idIndex])
- 801. - }
- 802. - });
- 803. - if (cur.onOListSave(ids, inv, list, options.ret || {}) !== false) {
- 804. - box.hide(200);
- 805. - }
- 806. - });
- 807. - if (options['box_options']) {
- 808. - box.setOptions(options['box_options']);
- 809. - }
- 810. -
- 811. - var self = this;
- 812. - var tabsEl = geByClass1('summary_tabs', box.bodyNode);
- 813. - var actionsWrap = geByClass1('olist_actions', box.bodyNode, 'div');
- 814. - var selButton = geByTag1('button', box.bodyNode);
- 815. - this.scrolNode = geByClass1('privacy_olist', box.bodyNode);
- 816. - this.moreEl = geByClass1('olist_more', box.bodyNode, 'a');
- 817. - this.olistEl = geByClass1('olist', box.bodyNode, 'div');
- 818. - this.selCnt = intval(val('olist_selected'));
- 819. - this.sel = options.sel || 0;
- 820. - this.noSelMsg = options.noSelMsg || getLang('friends_no_user_selected');
- 821. - this.invertedSelection = false;
- 822. -
- 823. - var filter = this.filter = geByClass1('olist_filter', box.bodyNode, 'input');
- 824. - var filterWrap = filter.parentNode;
- 825. - placeholderSetup(filter, {back: 1});
- 826. - if (!options.nofocus) {
- 827. - setTimeout(elfocus.pbind(filter), 100);
- 828. - }
- 829. -
- 830. - if (this.moreEl) {
- 831. - if (!isVisible(this.moreEl)) {
- 832. - re(this.moreEl);
- 833. - show(this.moreEl);
- 834. - } else {
- 835. - this.moreEl.onclick = function (event) {
- 836. - self.renderList('', 60);
- 837. - return cancelEvent(event);
- 838. - }
- 839. - }
- 840. - }
- 841. -
- 842. - var actMenuOptions = [], selMenuOptions = [], selTitle = '';
- 843. - each (options.actions_menu, function () {
- 844. - var menuItem = {i: this[0], l: this[1]};
- 845. - if (!this[0]) {
- 846. - menuItem.onMouseOver = function () {
- 847. - self.olistSelectMenu.options.target = this;
- 848. - self.olistSelectMenu.moveToTarget();
- 849. - setStyle(self.olistSelectMenu.header, {width: getSize(this)[0]});
- 850. - setStyle(self.olistSelectMenu.rows, {minWidth: getSize(this)[0]});
- 851. - if (browser.msie) {
- 852. - setStyle(self.olistSelectMenu.rows, {width: getSize(this)[0] + 20});
- 853. - }
- 854. - self.olistSelectMenu.show();
- 855. - }
- 856. - menuItem.onClick = function () {return false;}
- 857. - selTitle = this[1];
- 858. - }
- 859. - actMenuOptions.push(menuItem);
- 860. - });
- 861. - each (options.selection_menu, function () {
- 862. - var menuItem = {i: this[0], l: this[1]};
- 863. - selMenuOptions.push(menuItem);
- 864. - });
- 865. - this.olistActionsMenu = new DropdownMenu(actMenuOptions, {
- 866. - target: selButton,
- 867. - containerClass: 'dd_menu_olist_act',
- 868. - title: '<span class="olist_dd_over"></span>',
- 869. - updateTarget: false,
- 870. - offsetLeft: 0,
- 871. - offsetTop: 0,
- 872. - showHover: false,
- 873. - fadeSpeed: 0,
- 874. - onSelect: this.selMenuOnSelect.bind(this)
- 875. - });
- 876. -
- 877. - this.olistSelectMenu = new DropdownMenu(selMenuOptions, {
- 878. - parentMenu: this.olistActionsMenu,
- 879. - showHover: false,
- 880. - updateTarget: false,
- 881. - title: selTitle,
- 882. - offsetLeft: 0,
- 883. - offsetTop: 1,
- 884. - fadeSpeed: 0,
- 885. - containerClass: 'dd_menu_nested dd_menu_olist_sel',
- 886. - onSelect: this.selMenuOnSelect.bind(this)
- 887. - });
- 888. -
- 889. - addEvent(filter, 'keyup', function (e) {
- 890. - self.renderList(clean(val(this)));
- 891. - });
- 892. - addEvent(this.olistEl, 'click mouseover mouseout', this.onMouseEvent.bind(this));
- 893. - addEvent(this.scrolNode, 'scroll', this.onScroll.bind(this));
- 894. -
- 895. - if (options.ignored) {
- 896. - // this.ignoredIndexer = new Indexer(options.ignored);
- 897. - this.ignoredIndexer = new vkIndexer(options.ignored, options.getName ? options.getName : function(owner) {
- 898. - return owner[1];
- 899. - });
- 900. - this.ignoredOwners = options.ignored;
- 901. - this.ignoredTpl = options.ignored_tpl;
- 902. - this.ignoredSelected = {};
- 903. - this.ignoredCnt = options.ignored.length;
- 904. - }
- 905. -
- 906. - (cur.onOListTabChange = function (tab) {
- 907. - self.sel = tab;
- 908. - toggle(tabsEl, tab != 2);
- 909. - if (tab == 2) {
- 910. - if (filterWrap.nextSibling != tabsEl) {
- 911. - tabsEl.parentNode.insertBefore(filterWrap, tabsEl);
- 912. - }
- 913. - } else {
- 914. - if (filterWrap.parentNode != actionsWrap) {
- 915. - actionsWrap.appendChild(filterWrap);
- 916. - }
- 917. - }
- 918. - toggleClass(filterWrap, 'fl_l', tab != 2);
- 919. - toggleClass(actionsWrap, 'olist_ignored_actions', tab == 2);
- 920. - toggleClass(self.olistEl, 'olist_ignored', tab == 2);
- 921. - if (options.ignored) {
- 922. - box.setControlsText(tab == 2 ? options.ignored_return_link : options.ignored_link.replace('%s', self.ignoredCnt));
- 923. - }
- 924. - self.renderList(val(filter), 0, tab);
- 925. - if (!options.nofocus) {
- 926. - setTimeout(elfocus.pbind(filter), 100);
- 927. - }
- 928. - })(self.sel);
- 929. -
- 930. - }
- 931. - extend(OList.prototype, {
- 932. - onScroll: function () {
- 933. - if (!this.moreEl || !this.moreEl.offsetTop || !this.moreEl.onclick) {
- 934. - return;
- 935. - }
- 936. - var y = this.moreEl.offsetTop,
- 937. - sh = this.scrolNode.scrollHeight,
- 938. - st = this.scrolNode.scrollTop,
- 939. - h = this.scrolNode.offsetHeight || this.scrolNode.clientHeight;
- 940. -
- 941. - if (st + h + 100 >= y) {
- 942. - this.moreEl.onclick();
- 943. - }
- 944. - },
- 945. - onMouseEvent: function (event) {
- 946. - var target = event.originalTarget || event.target;
- 947. - while (target && target != bodyNode && (!target.className || target.className.indexOf('olist_item_wrap') == -1)) {
- 948. - target = target.parentNode;
- 949. - }
- 950. - if (!target || target == bodyNode) return;
- 951. - if (hasClass(target, 'olist_item_loading')) {
- 952. - return cancelEvent(event);
- 953. - }
- 954. - if (event.type == 'mouseover' || event.type == 'mouseout') {
- 955. - if (!hasClass(target, 'olist_item_wrap_on'))
- 956. - target.className = 'olist_item_wrap' + (event.type == 'mouseover' ? '_over' : '');
- 957. - } else {
- 958. - if (checkEvent(event)) return true;
- 959. - this.box.changed = true;
- 960. - var id = target.id.match(/-?\d+/)[0];
- 961. - if (this.sel == 2) {
- 962. - this.ignoreOnClick(target, id);
- 963. - } else {
- 964. - var checked = !this.invertedSelection && this.selected[id] || this.invertedSelection && !this.selected[id];
- 965. - target.className = !checked ? 'olist_item_wrap_on' : 'olist_item_wrap_over';
- 966. - this.selected[id] = !checked || this.invertedSelection;
- 967. - this.selCnt += !checked || this.invertedSelection ? 1 : -1;
- 968. - this.selTabUpdate();
- 969. - }
- 970. - if (!this.nofocus && this.scrolNode.scrollTop < 50) {
- 971. - var filter = this.filter;
- 972. - setTimeout(function () {
- 973. - elfocus(filter);
- 974. - if (val(filter).length) {
- 975. - filter.select();
- 976. - }
- 977. - }, 100);
- 978. - }
- 979. -
- 980. - return cancelEvent(event);
- 981. - }
- 982. - },
- 983. - selMenuOnSelect: function (event) {
- 984. - this.olistActionsMenu.hide(false);
- 985. - this.olistSelectMenu.hide(false);
- 986. - var k = event.target.index,
- 987. - selCnt = this.selCnt,
- 988. - selected = this.selected;
- 989. -
- 990. - if (!event.ctrlKey && !event.metaKey && !event.shiftKey) {
- 991. - selected = {};
- 992. - selCnt = 0;
- 993. - }
- 994. -
- 995. - switch (k) {
- 996. - case -1:
- 997. - selected = {};
- 998. - selCnt = 0;
- 999. - each (this.owners, function () {
- 1000. - selected[this[0]] = 1;
- 1001. - selCnt++;
- 1002. - });
- 1003. - break;
- 1004. -
- 1005. - case -2: // None
- 1006. - selected = {};
- 1007. - selCnt = 0;
- 1008. - break;
- 1009. -
- 1010. - case -3:
- 1011. - each (this.owners, function () {
- 1012. - if (this[0] > 0 && !selected[this[0]]) {
- 1013. - selected[this[0]] = 1;
- 1014. - selCnt++;
- 1015. - }
- 1016. - });
- 1017. - break;
- 1018. -
- 1019. - case -4:
- 1020. - each (this.owners, function () {
- 1021. - if (this[0] < 0 && !selected[this[0]]) {
- 1022. - selected[this[0]] = 1;
- 1023. - selCnt++;
- 1024. - }
- 1025. - });
- 1026. - break;
- 1027. -
- 1028. - default:
- 1029. - var mask = (1 << k);
- 1030. - each (this.owners, function () {
- 1031. - if ((this[4] & mask) && !selected[this[0]]) {
- 1032. - selected[this[0]] = 1;
- 1033. - selCnt++;
- 1034. - }
- 1035. - });
- 1036. - }
- 1037. -
- 1038. - this.selCnt = selCnt;
- 1039. - this.selected = selected;
- 1040. - this.selTabUpdate();
- 1041. - this.renderList();
- 1042. - return false;
- 1043. - },
- 1044. - selTabUpdate: function () {
- 1045. - var cnt1 = this.selCnt, cnt2 = this.owners.length - cnt1;
- 1046. - val('olist_selected', cnt1);
- 1047. - val('olist_unselected', cnt2);
- 1048. - toggle('olist_selected', cnt1 > 0);
- 1049. - toggle('olist_unselected', cnt2 > 0);
- 1050. - if (this.onTabUpdate) {
- 1051. - this.onTabUpdate();
- 1052. - }
- 1053. - },
- 1054. - ignoreOnClick: function (target, id) {
- 1055. - var self = this,
- 1056. - hash = false;
- 1057. -
- 1058. - var checked = !this.invertedSelection && this.ignoredSelected[id] || this.invertedSelection && !this.ignoredSelected[id];
- 1059. - each (this.ignoredOwners, function () {
- 1060. - if (this[0] == id) {
- 1061. - hash = this[4];
- 1062. - return false;
- 1063. - }
- 1064. - });
- 1065. - ajax.post('/al_feed.php?misc', {act: checked ? 'a_ignore_owner' : 'a_unignore_owner', owner_id: id, hash: hash}, {
- 1066. - onDone: function () {
- 1067. - target.className = !checked ? 'olist_item_wrap_on' : 'olist_item_wrap_over';
- 1068. - self.ignoredSelected[id] = !checked || self.invertedSelection;
- 1069. - self.ignoredCnt += !checked || self.invertedSelection ? -1 : 1;
- 1070. - val('olist_blacklisted', self.ignoredCnt);
- 1071. - toggle('olist_blacklisted', self.ignoredCnt);
- 1072. - },
- 1073. - showProgress: function () {
- 1074. - addClass(target, 'olist_item_loading');
- 1075. - },
- 1076. - hideProgress: function () {
- 1077. - removeClass(target, 'olist_item_loading');
- 1078. - }
- 1079. - });
- 1080. - },
- 1081. - renderList: function (pattern, offset, sel) {
- 1082. - offset = offset || 0;
- 1083. - sel = sel || this.sel;
- 1084. - var slice, selected, tpl,
- 1085. - limit = offset ? 60 : 120,
- 1086. - self = this;
- 1087. -
- 1088. - if (pattern) {
- 1089. - pattern = pattern.replace(/\u2013|\u2014/g, '-');
- 1090. - }
- 1091. - if (sel == 2) {
- 1092. - slice = pattern ? this.ignoredIndexer.search(pattern) : this.ignoredOwners;
- 1093. - selected = this.ignoredSelected;
- 1094. - tpl = self.ignoredTpl;
- 1095. - } else {
- 1096. - slice = pattern ? this.indexer.search(pattern) : this.owners;
- 1097. - if (self.unsortedIndex == sel && self.getUnsorted) {
- 1098. - slice = self.getUnsorted(slice);
- 1099. - }
- 1100. - selected = this.selected;
- 1101. - var inverted = self.invertedSelection ? !(this.sel < 0) : (this.sel < 0);
- 1102. - tpl = self.tpl;
- 1103. - if (sel && self.unsortedIndex != sel) {
- 1104. - var sel_slice = [];
- 1105. - each (slice, function () {
- 1106. - var id = this[self.idIndex];
- 1107. - if (!inverted && selected[id] || inverted && !selected[id]) {
- 1108. - sel_slice.push(this);
- 1109. - if (sel_slice.length > offset + limit) {
- 1110. - return false;
- 1111. - }
- 1112. - }
- 1113. - });
- 1114. - slice = sel_slice;
- 1115. - }
- 1116. - }
- 1117. - var total = slice.length;
- 1118. - slice = slice.slice(offset, offset + limit);
- 1119. - var html = [];
- 1120. - if (pattern) {
- 1121. - var term = escapeRE(pattern), termRus = parseLatin(pattern);
- 1122. - if (termRus != null) {
- 1123. - term = term + '|' + escapeRE(termRus);
- 1124. - }
- 1125. - var regexp = new RegExp('(?![^&;]+;)(?!<[^<>]*)((\\(*)(' + term + '))(?![^<>]*>)(?![^&;]+;)', 'gi');
- 1126. - }
- 1127. - var rsTpl = self.rsTpl ? self.rsTpl : function(obj, pattern, invertedSelection, selected, regexp) {
- 1128. - var checked = !invertedSelection && selected[obj[0]] || invertedSelection && !selected[obj[0]];
- 1129. - var label = obj[1];
- 1130. - if (pattern) {
- 1131. - label = pattern.indexOf(' ') == -1 ? label.split(' ') : [label];
- 1132. - var tmp = '';
- 1133. - for (var i in label) {
- 1134. - tmp += (i > 0 ? ' ' : '') + label[i].replace(regexp, '$2<em>$3</em>');
- 1135. - }
- 1136. - label = tmp;
- 1137. - }
- 1138. - return {
- 1139. - id: obj[0],
- 1140. - name: label,
- 1141. - photo: obj[2],
- 1142. - classname: checked ? ' olist_item_wrap_on' : '',
- 1143. - link: obj[3] || (obj[0] > 0 ? ('id' + obj[0]) : ('club' + (-obj[0])))
- 1144. - };
- 1145. - }
- 1146. - each (slice, function () {
- 1147. - html.push(rs(tpl, rsTpl(this, pattern, self.invertedSelection, selected, regexp)));
- 1148. - });
- 1149. - if (!offset && !html.length) {
- 1150. - html.push('<div class="olist_empty">' + (pattern ? getLang('global_search_not_found').replace('{search}', clean(pattern)) : self.noSelMsg) + '</div>');
- 1151. - }
- 1152. - re(this.moreEl);
- 1153. - html = html.join(' ');
- 1154. -
- 1155. - if (!offset) {
- 1156. - val(this.olistEl, html);
- 1157. - } else {
- 1158. - this.olistEl.appendChild(cf(html));
- 1159. - }
- 1160. - if (total > offset + limit) {
- 1161. - this.olistEl.appendChild(this.moreEl);
- 1162. - this.moreEl.onclick = function (event) {
- 1163. - self.renderList(pattern, offset + limit);
- 1164. - return cancelEvent(event);
- 1165. - }
- 1166. - }
- 1167. - if (self.box && self.box.scroll) {
- 1168. - self.box.scroll.update(false, true);
- 1169. - }
- 1170. - }
- 1171. - });
- 1172. -
- 1173. - try{jsDispatcher.triggerOnload('privacy.js');}catch(e){}
- 1174. - try{stManager.done('privacy.js');}catch(e){}
- ------
Advertisement
Add Comment
Please, Sign In to add comment