Hormold

VK Change (#1380643206)

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