Hormold

VK Change (#1383129007)

Oct 30th, 2013
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 69.80 KB | None | 0 0
  1. Файл - wkview.js (Старый размер - 55568 | Новый - 0):
  2. 0.  - var WkView = {
  3. 1.  -
  4. 2.  - init: function() {
  5. 3.  -   if (window.wkLayer) {
  6. 4.  -     return;
  7. 5.  -   }
  8. 6.  -   window.wkLayer = ce('div', {
  9. 7.  -     id: 'wk_layer'
  10. 8.  -   });
  11. 9.  -
  12. 10.  -   window.wkLayerWrap = ce('div', {
  13. 11.  -     id: 'wk_layer_wrap',
  14. 12.  -     className: 'scroll_fix_wrap fixed'
  15. 13.  -   });
  16. 14.  -
  17. 15.  -
  18. 16.  -   wkLayerWrap.appendChild(window.wkLayer);
  19. 17.  -
  20. 18.  -   bodyNode.appendChild(wkLayerWrap);
  21. 19.  -
  22. 20.  -   window.wkLayer.style.width = (lastWindowWidth - sbWidth() - 2) + 'px';
  23. 21.  - },
  24. 22.  -
  25. 23.  - showLayer: function() {
  26. 24.  - //  if (!wkcur.previousLayer) {
  27. 25.  - //    wkcur.previousLayer = isVisible(layerWrap) || (isVisible(ge('mv_layer_wrap')) && !mvcur.minimized);
  28. 26.  - //  }
  29. 27.  - //  layers.fullhide && layers.fullhide(true);
  30. 28.  -
  31. 29.  -   debugLog('layerqueue.hide from wkview');
  32. 30.  -   layerQueue.hide();
  33. 31.  -
  34. 32.  -   layers.wrapshow(wkLayerWrap, 0.7);
  35. 33.  -   layers.fullhide = WkView.hide;
  36. 34.  -   wkcur.showT = setTimeout(function() {
  37. 35.  -     layers.wrapshow(wkLayerWrap, 0.7);
  38. 36.  -     layers.fullhide = WkView.hide;
  39. 37.  -   }, 0);
  40. 38.  -   onBodyResize();
  41. 39.  - },
  42. 40.  - restoreLayer: function(opts) {
  43. 41.  -   WkView.showLayer();
  44. 42.  -   if (wkcur.root) {
  45. 43.  -     if (opts.myLoc) nav.setLoc(opts.myLoc);
  46. 44.  -   } else {
  47. 45.  -     WkView.setLocation();
  48. 46.  -   }
  49. 47.  -   if (opts.prevLoc) wkcur.prevLoc = opts.prevLoc;
  50. 48.  -   WkView.updateSize();
  51. 49.  - },
  52. 50.  -
  53. 51.  - wikiClick: function(obj, ev) {
  54. 52.  -   if (checkEvent(ev)) {
  55. 53.  -     return true
  56. 54.  -   }
  57. 55.  -   var el = ev.target;
  58. 56.  -   while(el && el.tagName != 'A') {
  59. 57.  -     el = el.parentNode;
  60. 58.  -   }
  61. 59.  -   if (el && el.tagName == 'A') {
  62. 60.  -     var href = el.href;
  63. 61.  -     var m = href.match(/^\/(page[^?]*)(\?.*)?$/);
  64. 62.  -     if (m) {
  65. 63.  -       var path = m[1];
  66. 64.  -       var query = (m[4]) ? q2ajx(m[4].substr(1)) : {};
  67. 65.  -     } else {
  68. 66.  -       var m = href.match(/https?:\/\/([a-zA-Z0-9\-_\.]+\.)?(vk\.com|vkontakte\.ru)\/([^?]*)(\?.*)?$/i);
  69. 67.  -       if (!m || !m[3]) {
  70. 68.  -         return true;
  71. 69.  -       }
  72. 70.  -
  73. 71.  -       var path = m[3].split('/');
  74. 72.  -       var query = (m[4]) ? q2ajx(m[4].substr(1)) : {};
  75. 73.  -     }
  76. 74.  -
  77. 75.  -     var params = {};
  78. 76.  -     switch(path[0]) {
  79. 77.  -       case 'pages':
  80. 78.  -         params['oid'] = query.oid || query.o;
  81. 79.  -         params['id'] = query['id'];
  82. 80.  -         params['p'] = query['p'];
  83. 81.  -         break;
  84. 82.  -       case 'ru':
  85. 83.  -       case 'en':
  86. 84.  -         params['p'] = path[1];
  87. 85.  -         params['global'] = path[0];
  88. 86.  -         break;
  89. 87.  -       default:
  90. 88.  -         if (path[0].match(/^page-?\d+_\d+$/)) {
  91. 89.  -           var query = path[0].substr(4).split('_');
  92. 90.  -           params['oid'] = query[0];
  93. 91.  -           params['id'] = query[1];
  94. 92.  -         } else if (path[0].match(/^note\d+_\d+$/)) {
  95. 93.  -           var query = path[0].substr(4).split('_');
  96. 94.  -           params['w'] = path[0];
  97. 95.  -         }
  98. 96.  -         break;
  99. 97.  -     }
  100. 98.  -     if (params.w || (params.oid && (params.id || params.p))) {
  101. 99.  -       showWiki(params);
  102. 100.  -       return cancelEvent(ev);
  103. 101.  -     }
  104. 102.  -   }
  105. 103.  - },
  106. 104.  -
  107. 105.  - edit: function() {
  108. 106.  -   if (!wkcur.canEdit) {
  109. 107.  -     return true;
  110. 108.  -   }
  111. 109.  -   var link = ge('wk_edit_link');
  112. 110.  -   if (!wkcur.editLang) {
  113. 111.  -     wkcur.editLang = val(link);
  114. 112.  -   }
  115. 113.  -
  116. 114.  -   val(link, '<img src="images/upload.gif" />');
  117. 115.  -
  118. 116.  -   if (wkcur.type == 'wall') {
  119. 117.  -     if (wkcur.edit) {
  120. 118.  -       Wall.cancelEdit();
  121. 119.  -     } else {
  122. 120.  -       Wall.editPost(wkcur.post, {from: 'wkview'}, function () {
  123. 121.  -         val(link, wkcur.editLang);
  124. 122.  -       });
  125. 123.  -     }
  126. 124.  -     return true;
  127. 125.  -   }
  128. 126.  -
  129. 127.  -   if (wkcur.edit) {
  130. 128.  -     if (wkcur.note) {
  131. 129.  -       showWiki({
  132. 130.  -         w: 'note' + wkcur.oid + '_' + wkcur.nid
  133. 131.  -       });
  134. 132.  -     } else {
  135. 133.  -       showWiki({
  136. 134.  -         oid: wkcur.oid,
  137. 135.  -         id: wkcur.pid,
  138. 136.  -         p: wkcur.p
  139. 137.  -       });
  140. 138.  -     }
  141. 139.  -     return true;
  142. 140.  -   }
  143. 141.  -   wkcur.edit = true;
  144. 142.  -   var params = {
  145. 143.  -     act: 'edit',
  146. 144.  -     oid: wkcur.oid,
  147. 145.  -     load: 1,
  148. 146.  -     section: 'edit'
  149. 147.  -   };
  150. 148.  -   if (wkcur.note) {
  151. 149.  -     params['nid'] = wkcur.nid;
  152. 150.  -     params['note'] = 1;
  153. 151.  -   } else {
  154. 152.  -     params['id'] = wkcur.pid;
  155. 153.  -   }
  156. 154.  -   ajax.post('wkview.php', params, {
  157. 155.  -     stat: ['pages.js','wysiwyg.js', 'wysiwyg.css'],
  158. 156.  -     onDone: function(content, js, info, options) {
  159. 157.  -       wkcur.wkContent.innerHTML = content;
  160. 158.  -       eval(js);
  161. 159.  -       addEvent(wkLayerWrap, 'scroll', WkView.onScroll);
  162. 160.  -       addEvent(window, 'resize', WkView.onResize);
  163. 161.  -       val(link, options.lang['pages_view']);
  164. 162.  -       WkView.onScroll();
  165. 163.  -       WkView.updateSize();
  166. 164.  -     },
  167. 165.  -     onFail: function() {
  168. 166.  -       val(link, wkcur.editLang);
  169. 167.  -     }
  170. 168.  -   });
  171. 169.  - },
  172. 170.  -
  173. 171.  - onScroll: function(ev, resize) {
  174. 172.  -   switch (wkcur.type) {
  175. 173.  -     case 'wall':
  176. 174.  -       return WkView.wallUpdateRepliesOnScroll(resize);
  177. 175.  -
  178. 176.  -     case 'likes':
  179. 177.  -       return WkView.likesOnScroll(resize);
  180. 178.  -
  181. 179.  -     case 'history':
  182. 180.  -       return WkView.historyOnScroll(resize);
  183. 181.  -   }
  184. 182.  -
  185. 183.  -   var y = wkLayerWrap.scrollTop;
  186. 184.  -   var panel = ge('wk_buttons_panel');
  187. 185.  -   if (!panel) return;
  188. 186.  -   var py = getXY(ge('wk_buttons_cont'), true)[1];
  189. 187.  -   if (!wkcur.bottomSize) {
  190. 188.  -     wkcur.bottomSize = getSize(panel);
  191. 189.  -   }
  192. 190.  -
  193. 191.  -   var ph = wkcur.bottomSize[1];
  194. 192.  -
  195. 193.  -   var wndHeight = window.innerHeight || document.documentElement.clientHeight;
  196. 194.  -
  197. 195.  -   if (resize && !wkcur.fixedBottom && wndHeight - ph < py + 20) {
  198. 196.  -     wkLayerWrap.scrollTop += py + 20 - (wndHeight - ph);
  199. 197.  -   } else if (wndHeight - ph < py) {
  200. 198.  -     if (!wkcur.fixedBottom || resize) {
  201. 199.  -       wkcur.fixedBottom = true;
  202. 200.  -       setStyle(panel, {
  203. 201.  -         position: 'fixed',
  204. 202.  -         top: (wndHeight - ph) + 'px'
  205. 203.  -       });
  206. 204.  -       addClass(panel, 'wk_panel_fixed');
  207. 205.  -     }
  208. 206.  -   } else {
  209. 207.  -     if (wkcur.fixedBottom || resize) {
  210. 208.  -       wkcur.fixedBottom = false;
  211. 209.  -       setStyle(panel, {
  212. 210.  -         position: 'static',
  213. 211.  -         top: '0px'
  214. 212.  -       });
  215. 213.  -       removeClass(panel, 'wk_panel_fixed');
  216. 214.  -     }
  217. 215.  -   }
  218. 216.  -
  219. 217.  -   if (resize && wkcur.fixedBottom) {
  220. 218.  -     setStyle(panel, {left: getXY(wkcur.wkContent)[0]+'px'})
  221. 219.  -   }
  222. 220.  -
  223. 221.  -   if (!wkcur.editorLayer) {
  224. 222.  -     wkCont = wkcur.wkContent;//ge('wk_content');
  225. 223.  -     wkcur.editorLayer = ge('wke_buttons_cont') || geByClass('editor_layer', wkCont)[0];
  226. 224.  -   } else {
  227. 225.  -     var pos = getXY(wkcur.editorLayer, true);
  228. 226.  -     if (pos[1] < 0) {
  229. 227.  -       if (!wkcur.fixedTop) {
  230. 228.  -         wkcur.fixedTop = true;
  231. 229.  -         addClass(wkcur.wkContent, 'wk_top_fixed');
  232. 230.  -         WkView.updateShadow();
  233. 231.  -         wkcur.editor.floatPanel = true;
  234. 232.  -       }
  235. 233.  -     } else {
  236. 234.  -       if (wkcur.fixedTop) {
  237. 235.  -         wkcur.fixedTop = false;
  238. 236.  -         removeClass(wkcur.wkContent, 'wk_top_fixed');
  239. 237.  -         wkcur.editorLayer.style.paddingTop = '0px';
  240. 238.  -         wkcur.editor.floatPanel = false;
  241. 239.  -       }
  242. 240.  -     }
  243. 241.  -   }
  244. 242.  - },
  245. 243.  -
  246. 244.  - updateShadow: function() {
  247. 245.  -   if (!wkcur.editorLayer) {
  248. 246.  -     wkCont = wkcur.wkContent;//ge('wk_content');
  249. 247.  -     wkcur.editorLayer = geByClass('editor_layer', wkCont)[0];
  250. 248.  -   }
  251. 249.  -   var toolbox = ge('wke_buttons') || geByClass('editor_toolbar', wkCont)[0];
  252. 250.  -   if (toolbox) {
  253. 251.  -     if (wkcur.fixedTop) {
  254. 252.  -       var size = getSize(toolbox);
  255. 253.  -       wkcur.editorLayer.style.paddingTop = size[1]+'px';
  256. 254.  -       ge('wk_top_toolbox_shadow').style.top = (size[1] - 1)+'px';
  257. 255.  -     }
  258. 256.  -   }
  259. 257.  - },
  260. 258.  -
  261. 259.  - saveInfo: function(autosave) {
  262. 260.  -   var params = {
  263. 261.  -     page: wkcur.p,
  264. 262.  -     hash: wkcur.hash
  265. 263.  -   }
  266. 264.  -   if (wkcur.newEditor) {
  267. 265.  -     params['Body'] = wkcur.editor.val();
  268. 266.  -     if (params['Body'] === false) {
  269. 267.  -       return false;
  270. 268.  -     }
  271. 269.  -   } else {
  272. 270.  -     params['Body'] = wkcur.editor.convertToWiki(true);
  273. 271.  -   }
  274. 272.  -   if (wkcur.note) {
  275. 273.  -     params = extend(params, {
  276. 274.  -       act: 'save',
  277. 275.  -       oid: wkcur.oid,
  278. 276.  -       nid: wkcur.nid,
  279. 277.  -       wysiwyg: 1,
  280. 278.  -       note: wkcur.note
  281. 279.  -     });
  282. 280.  -   } else {
  283. 281.  -     params = extend(params, {
  284. 282.  -       act: 'save',
  285. 283.  -       oid: wkcur.oid,
  286. 284.  -       id: wkcur.pid
  287. 285.  -     });
  288. 286.  -   }
  289. 287.  -   if (wkcur.pageTitle) {
  290. 288.  -     params['title'] = val(wkcur.pageTitle);
  291. 289.  -     /*if (!params['title']) {
  292. 290.  -       notaBene(wkcur.pageTitle);
  293. 291.  -       return false;
  294. 292.  -     }*/
  295. 293.  -   }
  296. 294.  -   if (autosave && wkcur.lockAutoSave) {
  297. 295.  -     return false;
  298. 296.  -   }
  299. 297.  -   wkcur.lockAutoSave = true;
  300. 298.  -   ajax.post(wkcur.note ? 'wkview.php' : 'al_pages.php', params, {
  301. 299.  -     onDone: function(text, data) {
  302. 300.  -       wkcur.lockAutoSave = false;
  303. 301.  -       wkcur.editor.changed = false;
  304. 302.  -       if (!autosave) {
  305. 303.  -         var saveEl = ge('pages_save_info_wysiwyg');
  306. 304.  -         saveEl.innerHTML = text;
  307. 305.  -         show(saveEl);
  308. 306.  -       }
  309. 307.  -       if (data.nid) {
  310. 308.  -         wkcur.nid = data.nid;
  311. 309.  -       }
  312. 310.  -       if (data.raw) {
  313. 311.  -         wkcur.wkRaw = data.raw;
  314. 312.  -       }
  315. 313.  -       if (data) {
  316. 314.  -         if (data.created && cur.chooseMedia) {
  317. 315.  -           nav.setLoc(extend(nav.objLoc, {w:'note'+data.raw}));
  318. 316.  -           if (!autosave) {
  319. 317.  -             WkView.hide(false, true);
  320. 318.  -           }
  321. 319.  -           cur.pbNoteAdded = data;
  322. 320.  -           cur.chooseMedia('note', data.raw, data);
  323. 321.  -           return true;
  324. 322.  -         } else {
  325. 323.  -           var title = ge('share_note_title'+data['raw']);
  326. 324.  -           if (title && !autosave) {
  327. 325.  -             title.innerHTML = data['title'];
  328. 326.  -           }
  329. 327.  -           if (data['title']) {
  330. 328.  -             val('wk_layer_title', data['title']);
  331. 329.  -           }
  332. 330.  -           if (wkcur.note && wkcur.toStatus && !autosave) {
  333. 331.  -             WkView.hide(false, true);
  334. 332.  -             if (wkcur.reloadOnSave) {
  335. 333.  -               boxRefreshCoords(boxLoader);
  336. 334.  -               show(boxLoader);
  337. 335.  -               show(boxLayerWrap);
  338. 336.  -               nav.reload({
  339. 337.  -                 onDone: function() {
  340. 338.  -                   hide(boxLoader);
  341. 339.  -                   hide(boxLayerWrap);
  342. 340.  -                 }
  343. 341.  -               });
  344. 342.  -             }
  345. 343.  -             return true;
  346. 344.  -           }
  347. 345.  -         }
  348. 346.  -       }
  349. 347.  -       if (autosave) return true;
  350. 348.  -       setTimeout(function() {
  351. 349.  -         fadeOut(saveEl, 200);
  352. 350.  -       }, 1500);
  353. 351.  -     },
  354. 352.  -     showProgress: function() {
  355. 353.  -       !autosave && lockButton(ge('wk_layer_save'));
  356. 354.  -     },
  357. 355.  -     hideProgress: function() {
  358. 356.  -       !autosave && unlockButton(ge('wk_layer_save'));
  359. 357.  -     },
  360. 358.  -     onFail: WkView.showError
  361. 359.  -   })
  362. 360.  - },
  363. 361.  -
  364. 362.  - show: function(title, html, options, script, ev) {
  365. 363.  -   // var previous = false;
  366. 364.  -   var arrowOver = window.wkcur && wkcur.arrowOver;
  367. 365.  -   if (!window.wkcur) {
  368. 366.  -     this.init();
  369. 367.  -   } else {
  370. 368.  -     if (wkcur.shown && !isVisible(wkLayerWrap)) {
  371. 369.  -       debugLog('hiding old wkview');
  372. 370.  -       WkView.hide(true, true);
  373. 371.  -     }
  374. 372.  -     each (wkcur._hide || [], function (k, hideCallback) {
  375. 373.  -       if (isFunction(hideCallback)) hideCallback();
  376. 374.  -     });
  377. 375.  -     // previous = {
  378. 376.  -     //   scrollTop: wkLayer.scrollTop,
  379. 377.  -     //   cont: wkcur.wkCont,
  380. 378.  -     //   cur: wkcur
  381. 379.  -     // };
  382. 380.  -   }
  383. 381.  -   var hlen = (window.wkcur && wkcur.historyLen) ? wkcur.historyLen : 0;
  384. 382.  -   if (!window.wkcur || !wkcur.doBack && !options.fromlist) {
  385. 383.  -     hlen += 1;
  386. 384.  -   }
  387. 385.  -
  388. 386.  -   var toQueue = options.queue;
  389. 387.  -   if (toQueue) {
  390. 388.  -     layerQueue.push();
  391. 389.  -     options.queue = false;
  392. 390.  -   }
  393. 391.  -   if ((window.wkcur || {}).shown && wkcur.root) {
  394. 392.  -     nav.setLoc(wkcur.prevLoc);
  395. 393.  -   }
  396. 394.  -
  397. 395.  -   window.wkcur = {
  398. 396.  -     historyLen: hlen,
  399. 397.  -     _hide: [],
  400. 398.  -     _show: []
  401. 399.  -   };
  402. 400.  -
  403. 401.  -   if (browser.iphone || browser.ipad) {
  404. 402.  -     cur.wkStartScroll = scrollGetY();
  405. 403.  -   }
  406. 404.  -
  407. 405.  -   if (options.edit) {
  408. 406.  -     cur._editMode = function() {
  409. 407.  -       return true;
  410. 408.  -     }
  411. 409.  -     if (!window.WkEditor) {
  412. 410.  -       stManager.add(['wk_editor.js', 'wk_editor.css'], WkView.show.pbind(title, html, options, script, ev));
  413. 411.  -       return false;
  414. 412.  -     }
  415. 413.  -   }
  416. 414.  -
  417. 415.  -   cur.cancelTooltip = true;
  418. 416.  -   if (window.tooltips) {
  419. 417.  -     tooltips.hideAll();
  420. 418.  -   }
  421. 419.  -
  422. 420.  -   if (!isVisible(wkLayerWrap)) {
  423. 421.  -     otherList = true;
  424. 422.  -     addEvent(window, 'resize', WkView.onResize);
  425. 423.  -     addEvent(wkLayerWrap, 'click', WkView.onClick);
  426. 424.  -     boxQueue.hideAll();
  427. 425.  -     WkView.showLayer();
  428. 426.  -   }
  429. 427.  -
  430. 428.  -   wkcur.noLocChange = 0; // do return location
  431. 429.  -   wkcur.noHistory = options.noLocChange;
  432. 430.  -
  433. 431.  -   wkcur.shown = true;
  434. 432.  -
  435. 433.  -   if (wkcur.edit) {
  436. 434.  -     wkcur.edit = false;
  437. 435.  -     ge('wk_edit_link').innerHTML = wkcur.editLang;
  438. 436.  -   }
  439. 437.  -   extend(wkcur, options);
  440. 438.  -
  441. 439.  -   if (wkcur.root) {
  442. 440.  -     cur.nav.push(function(ch, old, nw, opts) {
  443. 441.  -       nw = nav.toStr(nw);
  444. 442.  -       if (nw == wkcur.prevLoc) {
  445. 443.  -         WkView.hide(true);
  446. 444.  -         return false;
  447. 445.  -       }
  448. 446.  -     });
  449. 447.  -     if (!options.noLocChange && options.myLoc) nav.setLoc(options.myLoc);
  450. 448.  -   } else {
  451. 449.  -     WkView.setLocation(options.noLocChange, toQueue);
  452. 450.  -     if (options.prevLoc) wkcur.prevLoc = options.prevLoc;
  453. 451.  -   }
  454. 452.  -
  455. 453.  -   if (ev && ev.pageX && ev.pageY) {
  456. 454.  -     extend(wkcur, {oldX: ev.pageX, oldY: ev.pageY, oldT: vkNow()});
  457. 455.  -   }
  458. 456.  -
  459. 457.  -   var colorClass = wkcur.layerLight ? 'wk_light' : 'wk_dark';
  460. 458.  -
  461. 459.  -   addClass(wkLayerWrap, colorClass);
  462. 460.  -   addClass(layerBG, colorClass);
  463. 461.  -
  464. 462.  -   var content = html,
  465. 463.  -       editLink = getLang('global_edit'),
  466. 464.  -       hideLeft = wkcur.historyLen > 1 ? '' : 'display: none;';
  467. 465.  -   if (options.type == 'wall') {
  468. 466.  -     addEvent(wkLayerWrap, 'scroll', WkView.onScroll);
  469. 467.  -     addEvent(window, 'resize', WkView.onResize);
  470. 468.  -     WkView.wallBeforeInitPost(options);
  471. 469.  -   } else if (options.edit) {
  472. 470.  -     addEvent(wkLayerWrap, 'scroll', WkView.onScroll);
  473. 471.  -     addEvent(window, 'resize', WkView.onResize);
  474. 472.  -     editLink = options.lang['pages_view'];
  475. 473.  -     wkcur.editLang = getLang('global_edit');
  476. 474.  -   } else {
  477. 475.  -     if (options) {
  478. 476.  -       content = '<div class="wk_text wk_wiki_content' + (options.className ? ' '+options.className : '') + '" onclick="return WkView.wikiClick(this, event);">' + content + '</div>';
  479. 477.  -     }
  480. 478.  -   }
  481. 479.  -
  482. 480.  -   if (wkcur.wkCont) {
  483. 481.  -     wkcur.wkContent.innerHTML = content;
  484. 482.  -     ge('wk_layer_title').innerHTML = title;
  485. 483.  -   } else {
  486. 484.  -     wkLayer.innerHTML = '<div class="wk_cont">\
  487. 485.  -   <table cellspacing="0" cellpadding="0" class="wk_cont_t wk_cont_top_t">\
  488. 486.  -   <tr><td class="sidesh s1"><div class="sidesh_filler"></div></td><td>\
  489. 487.  -   <table cellspacing="0" cellpadding="0" class="wk_cont_t">\
  490. 488.  -   <tr><td>\
  491. 489.  -   <table cellspacing="0" cellpadding="0" class="wk_cont_t">\
  492. 490.  -   <tr><td colspan="3" class="bottomsh s3"><div></div></td></tr>\
  493. 491.  -   <tr><td class="sidesh s3"><div class="sidesh_filler"></div></td><td>\
  494. 492.  -   \
  495. 493.  -   <div id="wk_box" onclick="wkcur.wkClicked = true;">\
  496. 494.  -     <div id="wk_loader"></div>\
  497. 495.  -     <a id="wk_close_link" href="javascript: return false;" class="fl_r wk_close_link" onclick="return WkView.hide(false, true, event);">\
  498. 496.  -       '+getLang('global_close')+'\
  499. 497.  -     </a>\
  500. 498.  -     <div class="fl_r divide wk_edit_divide">|</div>\
  501. 499.  -     <a class="fl_r wk_edit_link" id="wk_edit_link" onclick="return WkView.edit();">\
  502. 500.  -       '+editLink+'\
  503. 501.  -     </a>\
  504. 502.  -     <div id="wk_summary" class="fl_l"><span class="summary" id="wk_layer_title">'+title+'</span></div>\
  505. 503.  -     <div id="wk_content">'+content+'</div>\
  506. 504.  -     <div class="clear"></div>\
  507. 505.  -   </div>\
  508. 506.  -   \
  509. 507.  -   </td><td class="sidesh s3"><div class="sidesh_filler"></div></td></tr>\
  510. 508.  -   <tr><td colspan="3" class="bottomsh s3"><div></div></td></tr></table>\
  511. 509.  -   </td></tr>\
  512. 510.  -   <tr><td colspan="3" class="bottomsh s2"><div></div></td></tr></table>\
  513. 511.  -   </td><td class="sidesh s1"><div class="sidesh_filler"></div></td></tr>\
  514. 512.  -   <tr><td colspan="3" class="bottomsh s1"><div></div></td></tr></table>\
  515. 513.  -   </div>\
  516. 514.  - <div id="wk_left" style="'+hideLeft+'" class="wk_left no_select"></div>\
  517. 515.  - <div id="wk_right" class="wk_close no_select"></div>\
  518. 516.  - <div id="wk_left_arrow" class="no_select"></div>\
  519. 517.  - <div id="wk_right_arrow" class="no_select"></div>\
  520. 518.  - <div class="no_select" id="wk_left_nav" style="'+hideLeft+'" '+'onmouseover="WkView.activate(wkcur.wkLeft)" onmouseout="WkView.deactivate(wkcur.wkLeft)" onmousedown="wkcur.wkClicked = true; WkView.back();" onselectstart="return cancelEvent(event);"></div>\
  521. 519.  - <div class="no_select" id="wk_right_nav" '+'onmouseover="WkView.activate(wkcur.wkRight)" onmouseout="WkView.deactivate(wkcur.wkRight)" onmousedown="if (!wkcur.noClickHide) { wkcur.wkClicked = true; WkView.hide(); }"></div>\
  522. 520.  - <div id="wk_left_arrow_bg" class="no_select" onclick="return WkView.navigate(this, event, -1);" onmouseover="WkView.activateArrow(false, event)" onmouseout="WkView.deactivateArrow(false, event)"><div class="wk_arrow_bg_inner"></div></div>\
  523. 521.  - <div id="wk_right_arrow_bg" class="no_select" onclick="return WkView.navigate(this, event, 1);" onmouseover="WkView.activateArrow(true, event)" onmouseout="WkView.deactivateArrow(true, event)"><div class="wk_arrow_bg_inner"></div></div>';
  524. 522.  -
  525. 523.  -     extend(wkcur, {
  526. 524.  -       wkCont: wkLayer.firstChild,
  527. 525.  -       wkBox: ge('wk_box'),
  528. 526.  -
  529. 527.  -       mvLoader: ge('wk_loader'),
  530. 528.  -       wkContent: ge('wk_content'),
  531. 529.  -
  532. 530.  -       wkLeftNav: ge('wk_left_nav'),
  533. 531.  -       wkRightNav: ge('wk_right_nav'),
  534. 532.  -       wkLeft: ge('wk_left'),
  535. 533.  -       wkRight: ge('wk_right'),
  536. 534.  -       wkLeftArrow: ge('wk_left_arrow'),
  537. 535.  -       wkRightArrow: ge('wk_right_arrow'),
  538. 536.  -       wkLeftArrowBg: ge('wk_left_arrow_bg'),
  539. 537.  -       wkRightArrowBg: ge('wk_right_arrow_bg')
  540. 538.  -     });
  541. 539.  -   }
  542. 540.  -   toggle('wk_summary', title);
  543. 541.  -
  544. 542.  -   if (wkcur.commonClass) {
  545. 543.  -     addClass(wkcur.wkBox, wkcur.commonClass);
  546. 544.  -   } else {
  547. 545.  -     wkcur.wkBox.className = '';
  548. 546.  -   }
  549. 547.  -
  550. 548.  -   if (wkcur.canEdit && !wkcur.toStatus && wkcur.type != 'wall') {
  551. 549.  -     addClass(wkcur.wkBox, 'wk_view_edit_link');
  552. 550.  -   } else {
  553. 551.  -     removeClass(wkcur.wkBox, 'wk_view_edit_link');
  554. 552.  -   }
  555. 553.  -
  556. 554.  -   if (browser.mobile) {
  557. 555.  -     wkcur.wkYOffset = intval(window.pageYOffset);
  558. 556.  -     wkcur.wkCont.style.paddingTop = (wkcur.wkYOffset + 10) + 'px';
  559. 557.  -     wkcur.wkRightNav.style.top = (wkcur.wkYOffset + 10) + 'px';
  560. 558.  -   }
  561. 559.  -
  562. 560.  -   if (script) {
  563. 561.  -     eval(script);
  564. 562.  -   }
  565. 563.  -   WkView.updateSize();
  566. 564.  -
  567. 565.  -   removeEvent(document, 'keydown', WkView.onKeyDown);
  568. 566.  -   addEvent(document, 'keydown', WkView.onKeyDown);
  569. 567.  -
  570. 568.  -   options.onLoaded && options.onLoaded();
  571. 569.  -
  572. 570.  -   var closeLink = ge('wk_close_link');
  573. 571.  -   if (closeLink) {
  574. 572.  -     closeLink.focus();
  575. 573.  -   }
  576. 574.  -
  577. 575.  -   WkView.updateArrows();
  578. 576.  -
  579. 577.  -   if (options.type == 'wall') {
  580. 578.  -     WkView.wallAfterInitPost();
  581. 579.  -   } else if (options.toScroll) {
  582. 580.  -     wkLayerWrap.scrollTop = options.toScroll;
  583. 581.  -     wkcur.toScroll = 0;
  584. 582.  -   }
  585. 583.  -
  586. 584.  -   if (arrowOver !== undefined) {
  587. 585.  -     WkView.activateArrow(arrowOver);
  588. 586.  -   }
  589. 587.  -   if (options.fromlist) {
  590. 588.  -     WkView.preloadArrow(options.fromlist == 1);
  591. 589.  -   }
  592. 590.  -   var _a = window.audioPlayer, aid = currentAudioId();
  593. 591.  -   if (_a && aid && _a.showCurrentTrack) _a.showCurrentTrack();
  594. 592.  -
  595. 593.  -   return false;
  596. 594.  - },
  597. 595.  -
  598. 596.  - hide: function(noLoc, force, ev) {
  599. 597.  -   if (!window.wkcur || !force && !wkcur.shown) return;
  600. 598.  -   var doUpdAds = !wkcur.wkRaw.match(/^recom_apps\d+$/) && !wkcur.wkRaw.match(/^app\d+$/);
  601. 599.  -
  602. 600.  -   clearTimeout(wkcur.autosaveTimeout);
  603. 601.  -   clearTimeout(wkcur.showT);
  604. 602.  -
  605. 603.  -   /*if (!wkcur.noHistory && !noLoc) {
  606. 604.  -     wkcur.noHistory = 1;
  607. 605.  -     wkcur.forceHistoryHide = force;
  608. 606.  -     __adsUpdate('lazy');
  609. 607.  -     return history.go(-1);
  610. 608.  -   }
  611. 609.  -   if (wkcur.forceHistoryHide) {
  612. 610.  -     force = wkcur.forceHistoryHide;
  613. 611.  -     wkcur.forceHistoryHide = false;
  614. 612.  -   }*/
  615. 613.  -
  616. 614.  -   if (!force && wkcur.edit && wkcur.editor) {
  617. 615.  -     if (wkcur.editor.changed) {
  618. 616.  -       if (wkcur.note && wkcur.toStatus) {
  619. 617.  -         WkView.saveInfo();
  620. 618.  -         return;
  621. 619.  -       } else {
  622. 620.  -         var box = showFastBox(wkcur.lang['pages_close_title'], wkcur.lang['pages_close_text'], getLang('box_yes'), function() {
  623. 621.  -           box.hide();
  624. 622.  -           WkView.hide(noLoc, true);
  625. 623.  -         }, getLang('box_no'))
  626. 624.  -         return;
  627. 625.  -       }
  628. 626.  -     }
  629. 627.  -   }
  630. 628.  -
  631. 629.  -   each (wkcur._hide || [], function (k, hideCallback) {
  632. 630.  -     if (isFunction(hideCallback)) hideCallback();
  633. 631.  -   });
  634. 632.  -
  635. 633.  -   var donthide = false;
  636. 634.  -   if (isVisible(wkLayerWrap)) {
  637. 635.  -     setTimeout(layerQueue.pop, 0);
  638. 636.  -     donthide = layerQueue.count() && layerQueue._layers[layerQueue._layers.length - 1][0] == 'wiki' && !layerQueue._bl;
  639. 637.  -     if (!donthide) {
  640. 638.  -       layers.wraphide(wkLayerWrap);
  641. 639.  -       layers.fullhide = false;
  642. 640.  -     }
  643. 641.  -   }
  644. 642.  -
  645. 643.  -   if (window.tooltips) {
  646. 644.  -     tooltips.destroy(this);
  647. 645.  -   }
  648. 646.  -
  649. 647.  -   removeEvent(document, 'keydown', WkView.onKeyDown);
  650. 648.  -
  651. 649.  -   wkcur.editorLayer = false;
  652. 650.  -   removeClass(wkcur.wkContent, 'wk_top_fixed');
  653. 651.  -   wkcur.fixedTop = wkcur.fixedBottom = false;
  654. 652.  -
  655. 653.  -   if (!donthide) {
  656. 654.  -     var colorClass = wkcur.layerLight ? 'wk_light' : 'wk_dark';
  657. 655.  -     removeClass(wkLayerWrap, colorClass);
  658. 656.  -     removeClass(layerBG, colorClass);
  659. 657.  -
  660. 658.  -     wkcur.shown = false;
  661. 659.  -     removeEvent(wkLayerWrap, 'click', WkView.onClick);
  662. 660.  -     removeEvent(wkLayerWrap, 'scroll', WkView.onScroll);
  663. 661.  -     wkcur.wkContent.innerHTML = '';
  664. 662.  -   }
  665. 663.  -   wkcur.wkClicked = false;
  666. 664.  -
  667. 665.  -   wkcur.changeCanvasSize = false;
  668. 666.  -
  669. 667.  -   if (wkcur.onHide && isFunction(wkcur.onHide)) {
  670. 668.  -     wkcur.onHide();
  671. 669.  -   }
  672. 670.  -
  673. 671.  -   cur._editMode = false;
  674. 672.  -
  675. 673.  -   if (wkcur.root && noLoc !== true) {
  676. 674.  -     WkView.backLocation();
  677. 675.  -   } else if (!wkcur.noLocChange && noLoc !== true) {
  678. 676.  -     if (noLoc === 2) {
  679. 677.  -       nav.setLoc(hab.getLoc());
  680. 678.  -     } else {
  681. 679.  -       WkView.backLocation();
  682. 680.  -     }
  683. 681.  -     if (doUpdAds) {
  684. 682.  -       __adsUpdate('lazy');
  685. 683.  -     }
  686. 684.  -   } else if (doUpdAds) {
  687. 685.  -     __adsUpdate();
  688. 686.  -   }
  689. 687.  -
  690. 688.  -   if (browser.iphone || browser.ipad) {
  691. 689.  -     var scroll = scrollGetY();
  692. 690.  -     if (Math.abs(scroll - cur.wkStartScroll) > 500) {
  693. 691.  -       scrollToY(cur.wkStartScroll, 0);
  694. 692.  -     }
  695. 693.  -   }
  696. 694.  -   delete wkcur.historyLen;
  697. 695.  -   var _a = window.audioPlayer, aid = currentAudioId();
  698. 696.  -   if (_a && aid && _a.showCurrentTrack) _a.showCurrentTrack();
  699. 697.  -   return false;
  700. 698.  - },
  701. 699.  -
  702. 700.  - cmp: function(id1, id2) {
  703. 701.  -   var l1 = id1.length, l2 = id2.length;
  704. 702.  -   if (l1 < l2) {
  705. 703.  -     return -1;
  706. 704.  -   } else if (l1 > l2) {
  707. 705.  -     return 1;
  708. 706.  -   } else if (id1 < id2) {
  709. 707.  -     return -1;
  710. 708.  -   } else if (id1 > id2) {
  711. 709.  -     return 1;
  712. 710.  -   }
  713. 711.  -   return 0;
  714. 712.  - },
  715. 713.  -
  716. 714.  -
  717. 715.  - onClick: function(e) {
  718. 716.  -   if (wkcur.wkClicked || wkcur.noClickHide) {
  719. 717.  -     wkcur.wkClicked = false;
  720. 718.  -     return;
  721. 719.  -   }
  722. 720.  -   var dx = Math.abs(e.pageX - intval(wkcur.oldX));
  723. 721.  -   var dy = Math.abs(e.pageY - intval(wkcur.oldY));
  724. 722.  -   if (dx > 3 || dy > 3) {
  725. 723.  -     if (vkNow() - intval(wkcur.oldT) > 300) {
  726. 724.  -       WkView.hide();
  727. 725.  -     }
  728. 726.  -   }
  729. 727.  - },
  730. 728.  -
  731. 729.  - onKeyDown: function(e) {
  732. 730.  -   e = e || window.event;
  733. 731.  -   // debugLog(e.type, e.returnValue, e.keyCode, e, WkView.edit);
  734. 732.  -   if (e.returnValue === false) return false;
  735. 733.  -   if (!cur.pvShown && e.keyCode == KEY.ESC) {
  736. 734.  -     WkView.hide();
  737. 735.  -     return cancelEvent(e);
  738. 736.  -   }
  739. 737.  -   if (!cur.pvShown && (!wkcur.edit && (e.keyCode == KEY.LEFT || e.keyCode == KEY.RIGHT))) {
  740. 738.  -     var target = e && e.target || e.srcElement;
  741. 739.  -     if (target && (target.tagName == 'TEXTAREA' || target.tagName == 'INPUT' || target.tagName == 'DIV' && target.contentEditable)) {
  742. 740.  -       return true;
  743. 741.  -     }
  744. 742.  -     WkView.navigate(null, e, e.keyCode == KEY.RIGHT ? 1 : -1);
  745. 743.  -     return cancelEvent(e);
  746. 744.  -   }
  747. 745.  -   if (WkView.edit) {
  748. 746.  -     if (e.keyCode == 10 || e.keyCode == 13 && (e.ctrlKey || e.metaKey && browser.mac)) {
  749. 747.  -       WkView.saveInfo();
  750. 748.  -     }
  751. 749.  -     if (cur.updTimeout) return;
  752. 750.  -     cur.updTimeout = setTimeout(function() {
  753. 751.  -       WkView.onResize()
  754. 752.  -       cur.updTimeout = false;
  755. 753.  -     }, 200);
  756. 754.  -   }
  757. 755.  - },
  758. 756.  -
  759. 757.  - onResize: function() {
  760. 758.  -   var dwidth = lastWindowWidth, dheight = lastWindowHeight, sbw = sbWidth();
  761. 759.  -
  762. 760.  -   var w = dwidth - sbw - 2 - 120 - 34 - 50, h = dheight - 31 - 28 - 72;
  763. 761.  -   if (w > 1280) { // less than full hd - not size > 2
  764. 762.  -     w = 1280;
  765. 763.  -   } else if (w > 807 && w < 907) { // 1024x768 - not size > 1
  766. 764.  -     w = 807;
  767. 765.  -   } else if (w < 604) {
  768. 766.  -     w = 604;
  769. 767.  -   }
  770. 768.  -   if (h < 453) {
  771. 769.  -     h = 453;
  772. 770.  -   }
  773. 771.  -   wkcur.mvWidth = w;
  774. 772.  -   wkcur.mvHeight = h;
  775. 773.  -
  776. 774.  -   var sizeChanged = false, oldverybig = wkcur.mvVeryBig;
  777. 775.  -   wkcur.mvVeryBig = (w > 1280) ? 2 : (w > 807 ? 1 : false);
  778. 776.  -   sizeChanged = (oldverybig != wkcur.mvVeryBig);
  779. 777.  -   WkView.onScroll(false, true);
  780. 778.  -
  781. 779.  -   WkView.updateHeight();
  782. 780.  -   WkView.updateArrows();
  783. 781.  - },
  784. 782.  -
  785. 783.  -
  786. 784.  - updateArrows: function() {
  787. 785.  -   var sbw = sbWidth() + 2;
  788. 786.  -   if (wkcur.wkLeft) {
  789. 787.  -     wkcur.wkLeft.style.left = '20px';
  790. 788.  -   }
  791. 789.  -   var size = getSize(wkcur.wkBox),
  792. 790.  -       width = size[0],
  793. 791.  -       height = size[1];
  794. 792.  -   wkcur.wkLeftNav.style.width = Math.floor((lastWindowWidth - sbw - width - 2) / 2) + 'px';
  795. 793.  -   wkcur.wkRightNav.style.left = Math.floor((lastWindowWidth - sbw + width + 2) / 2) + 'px';
  796. 794.  -   wkcur.wkRightNav.style.width = Math.floor((lastWindowWidth - sbw - width - 2) / 2) + 'px';
  797. 795.  -   if (wkcur.wkClose) {
  798. 796.  -     wkcur.wkClose.style.left = (lastWindowWidth - sbw - 2 - 37) + 'px';
  799. 797.  -   }
  800. 798.  -
  801. 799.  -   var arrowActions = WkView.getNextWkRaws();
  802. 800.  -   if (arrowActions[0] || arrowActions[1]) {
  803. 801.  -     var arrowTop = (wkcur.wkCont.offsetHeight < lastWindowHeight ? wkcur.wkCont.offsetTop + 10 + (height / 2) : lastWindowHeight / 2) - 8;
  804. 802.  -     if (arrowActions[0]) {
  805. 803.  -       show(wkcur.wkLeftArrow);
  806. 804.  -       show(wkcur.wkLeftArrowBg);
  807. 805.  -
  808. 806.  -       setStyle(wkcur.wkLeftArrowBg, {left: (lastWindowWidth - sbw - width) / 2 - 90});
  809. 807.  -       setStyle(wkcur.wkLeftArrow, {left: (lastWindowWidth - sbw - width) / 2 - 52, top: arrowTop});
  810. 808.  -     } else {
  811. 809.  -       hide(wkcur.wkLeftArrow, wkcur.wkLeftArrowBg);
  812. 810.  -     }
  813. 811.  -
  814. 812.  -     if (arrowActions[1]) {
  815. 813.  -       show(wkcur.wkRightArrow);
  816. 814.  -       show(wkcur.wkRightArrowBg);
  817. 815.  -       setStyle(wkcur.wkRightArrowBg, {left: (lastWindowWidth - sbw - width) / 2 + width});
  818. 816.  -       setStyle(wkcur.wkRightArrow, {left: (lastWindowWidth - sbw - width) / 2 + width + 36, top: arrowTop});
  819. 817.  -     } else {
  820. 818.  -       hide(wkcur.wkRightArrow, wkcur.wkRightArrowBg);
  821. 819.  -     }
  822. 820.  -   } else {
  823. 821.  -     hide(wkcur.wkLeftArrow, wkcur.wkLeftArrowBg, wkcur.wkRightArrow, wkcur.wkRightArrowBg);
  824. 822.  -   }
  825. 823.  - },
  826. 824.  - getNextWkRaws: function () {
  827. 825.  -   var wkRawPrevious = wkRawNext = false;
  828. 826.  -   if (isArray(wkcur.wkRawList) && wkcur.historyLen <= 1 && !wkcur.wkRawLoading) {
  829. 827.  -     var len = wkcur.wkRawList.length,
  830. 828.  -         pos = indexOf(wkcur.wkRawList, wkcur.wkRaw);
  831. 829.  -     if (pos > 0) {
  832. 830.  -       wkRawPrevious = wkcur.wkRawList[pos - 1];
  833. 831.  -     }
  834. 832.  -     if (pos >= 0 && pos < len - 1) {
  835. 833.  -       wkRawNext = wkcur.wkRawList[pos + 1];
  836. 834.  -     }
  837. 835.  -   }
  838. 836.  -   return [wkRawPrevious, wkRawNext];
  839. 837.  - },
  840. 838.  - navigate: function (el, event, delta) {
  841. 839.  -   if (event && event.type == 'click') {
  842. 840.  -     wkcur.arrowOver = (delta == 1);
  843. 841.  -     wkcur.arrowClicked = vkNow();
  844. 842.  -   }
  845. 843.  -   var actions = WkView.getNextWkRaws();
  846. 844.  -   if (delta > 0 && actions[1]) {
  847. 845.  -     wkcur.wkRawLoading = true;
  848. 846.  -     addClass(wkcur.wkRightArrow, 'wk_arrow_progress');
  849. 847.  -     // debugLog(wkcur.wkRightArrow, wkcur.wkRightArrow.className);
  850. 848.  -     showWiki({w: actions[1]}, false, false, {fromlist: 1, noloader: true, preload: {cache: 1}});
  851. 849.  -     cancelEvent(event);
  852. 850.  -   }
  853. 851.  -   if (delta < 0 && actions[0]) {
  854. 852.  -     wkcur.wkRawLoading = true;
  855. 853.  -     addClass(wkcur.wkLeftArrow, 'wk_arrow_progress');
  856. 854.  -     showWiki({w: actions[0]}, false, false, {fromlist: -1, noloader: true, preload: {cache: 1}});
  857. 855.  -     cancelEvent(event);
  858. 856.  -   }
  859. 857.  - },
  860. 858.  -
  861. 859.  - updateHeight: function() {
  862. 860.  -   window.updateWndVScroll && updateWndVScroll();
  863. 861.  -
  864. 862.  -   var h = Math.max(wkcur.wkCont.offsetHeight, lastWindowHeight);
  865. 863.  -   wkcur.wkLeftNav.style.height = wkcur.wkRightNav.style.height = h + 'px';
  866. 864.  -
  867. 865.  -   var boxH = wkcur.wkBox.offsetHeight + 2;
  868. 866.  -   setStyle(wkcur.wkLeftArrowBg.firstChild, {height: boxH});
  869. 867.  -   setStyle(wkcur.wkRightArrowBg.firstChild, {height: boxH});
  870. 868.  - },
  871. 869.  -
  872. 870.  - updateSize: function() {
  873. 871.  -   var size = getSize(wkcur.wkCont);
  874. 872.  -
  875. 873.  -   var docEl = document.documentElement,
  876. 874.  -       ch = window.innerHeight || docEl.clientHeight || bodyNode.clientHeight,
  877. 875.  -       top = Math.max(positive((ch - size[1] - 5) / 2), 14),
  878. 876.  -       paddingTop = top + 10,
  879. 877.  -       paddingBottom = wkLayer.offsetHeight - size[1] + top + 90;
  880. 878.  -
  881. 879.  -   wkcur.wkCont.style.top = top + 'px';
  882. 880.  -   wkcur.wkLeftArrowBg.style.paddingTop = wkcur.wkRightArrowBg.style.paddingTop = paddingTop + 'px';
  883. 881.  -   wkcur.wkLeftArrowBg.style.paddingBottom = wkcur.wkRightArrowBg.style.paddingBottom = paddingBottom + 'px';
  884. 882.  -
  885. 883.  -   onBodyResize();
  886. 884.  -   WkView.onResize();
  887. 885.  - },
  888. 886.  -
  889. 887.  -
  890. 888.  - setLocation: function(noLocChange, toQueue) {
  891. 889.  -   wkcur.prevLoc = {};
  892. 890.  -   for (var i in nav.objLoc) {
  893. 891.  -     if (i != 'w' || nav.objLoc[i] != wkcur.wkRaw && toQueue) {
  894. 892.  -       wkcur.prevLoc[i] = nav.objLoc[i];
  895. 893.  -     }
  896. 894.  -   }
  897. 895.  -   if (noLocChange) {
  898. 896.  -     return;
  899. 897.  -   }
  900. 898.  -
  901. 899.  -   var nl = extend(nav.objLoc, {'w': wkcur.wkRaw});
  902. 900.  -   delete(nl.z);
  903. 901.  -   if (nav.strLoc != nav.toStr(nl)) {
  904. 902.  -     nav.setLoc(nl);
  905. 903.  -   }
  906. 904.  -
  907. 905.  -   //wkcur.noHistory = 0;
  908. 906.  - },
  909. 907.  -
  910. 908.  - backLocation: function() {
  911. 909.  -   var loc = hab.getLoc();
  912. 910.  -   if (wkcur.prevLoc && wkcur.prevLoc != loc) {
  913. 911.  - //    if (wkcur.previousLayer) {
  914. 912.  - //      nav.go(wkcur.prevLoc);
  915. 913.  - //    } else {
  916. 914.  -       nav.setLoc(wkcur.prevLoc);
  917. 915.  - //    }
  918. 916.  - //    if (wkcur.previousLayer && wkcur.prevLoc.z) {
  919. 917.  - //      zNav({z: wkcur.prevLoc.z});
  920. 918.  - //    }
  921. 919.  -   } else {
  922. 920.  -     var locParts = loc.split('/');
  923. 921.  -     if (locParts.length > 1) {
  924. 922.  -       nav.setLoc(locParts[0]);
  925. 923.  -     }
  926. 924.  -   }
  927. 925.  -   layerQueue.noHistory();
  928. 926.  - },
  929. 927.  -
  930. 928.  - showError: function(txt) {
  931. 929.  -   if (window.wkcur) {
  932. 930.  -     delete wkcur.wkRawLoading;
  933. 931.  -     addClass(wkcur.wkRightArrow, 'wk_arrow_progress');
  934. 932.  -     addClass(wkcur.wkLeftArrow, 'wk_arrow_progress');
  935. 933.  -   }
  936. 934.  -   var box = showFastBox({title: getLang('global_error')}, txt, getLang('global_close'));
  937. 935.  -   setTimeout(box.hide, 2000);
  938. 936.  -   return true;
  939. 937.  - },
  940. 938.  -
  941. 939.  - wysiwygInit: function() {
  942. 940.  -   if (browser.ipod || browser.ipad || browser.iphone) return;
  943. 941.  -   var simpleToolBar = 'bold,italic,gray,underline,strike,left,center,right,marker_list,numeric_list,h1,h2,h3,image,video,audio,link,unlink';
  944. 942.  -   var extendedToolBar = 'bold,italic,gray,underline,strike,left,center,right,marker_list,numeric_list,h1,h2,h3,image,video,audio,doc,link,unlink,break,';
  945. 943.  -   extendedToolBar += 'table,table_delete,insert_row_before,insert_row_after,insert_col_before,insert_col_after,delete_row,delete_col,col_width,sub,sup,citate,outdent,indent,pre,character,hider';
  946. 944.  -   window.editorName = 'pageWysiwyg';
  947. 945.  -   var editorParams = {
  948. 946.  -     editorName: editorName,
  949. 947.  -     replaceElemID: 'pages_html',
  950. 948.  -     contentCSS: '/css/al/wysiwyg.css',
  951. 949.  -     html: ge('pages_html').value,
  952. 950.  -     wiki: ge('pages_body') ? ge('pages_body').value : '',
  953. 951.  -     height: 326,
  954. 952.  -     simpleToolBar: simpleToolBar,
  955. 953.  -     extendedToolBar: extendedToolBar,
  956. 954.  -     defaultMode: 'simple',
  957. 955.  -     skinFile: 'pages',
  958. 956.  -     photoMinSize: { w: 50, h: 50 },
  959. 957.  -     photoMaxSize: { w: 607, h: 500 },
  960. 958.  -     userID: 0,
  961. 959.  -     userName: '',
  962. 960.  -     groupID: 0,
  963. 961.  -     oid: wkcur.oid,
  964. 962.  -     debug: false,
  965. 963.  -     layer: 1,
  966. 964.  -     toolWidth: 654,
  967. 965.  -     width: 608,
  968. 966.  -     note: wkcur.note ? wkcur.wkRaw : 0,
  969. 967.  -     onHeightChange: function() {
  970. 968.  -       WkView.onScroll();
  971. 969.  -     },
  972. 970.  -     onChange: WkView.onChange
  973. 971.  -   };
  974. 972.  -   window[editorName] = wkcur.editor = new Wysiwyg(editorParams);
  975. 973.  - },
  976. 974.  -
  977. 975.  - onChange: function() {
  978. 976.  -   if (!wkcur.shown) return false;
  979. 977.  -   clearTimeout(wkcur.autosaveTimeout);
  980. 978.  -   wkcur.autosaveTimeout = setTimeout(function() {
  981. 979.  -     if (wkcur.note && wkcur.toStatus) {
  982. 980.  -       WkView.saveInfo(true);
  983. 981.  -     }
  984. 982.  -   }, 4000);
  985. 983.  - },
  986. 984.  -
  987. 985.  - likeOver: function() {
  988. 986.  -   var icon = ge('wk_like_icon');
  989. 987.  -   if (!wkcur.liked) {
  990. 988.  -     setTimeout(animate.pbind(icon, {opacity: 1}, 200, false), 1);
  991. 989.  -   } else {
  992. 990.  -     setStyle(icon, {opacity: 1});
  993. 991.  -   }
  994. 992.  -   var linkSize = getSize(ge('wk_like_link'));
  995. 993.  -   var linkW = linkSize ? linkSize[0] : 20;
  996. 994.  -
  997. 995.  -   showTooltip(icon.parentNode, {
  998. 996.  -     url: 'like.php',
  999. 997.  -     params: {act: 'a_get_stats', object: wkcur.like_obj || wkcur.wkRaw, from: 'wkview'},
  1000. 998.  -     slide: 15,
  1001. 999.  -     shift: [0, 8, 9],
  1002. 1000.  -     ajaxdt: 100,
  1003. 1001.  -     showdt: 400,
  1004. 1002.  -     hidedt: 200,
  1005. 1003.  -     className: 'rich like_tt',
  1006. 1004.  -     init: function (tt) {
  1007. 1005.  -       if (!tt.container) return;
  1008. 1006.  -       var bp = geByClass1('bottom_pointer', tt.container, 'div');
  1009. 1007.  -       var tp = geByClass1('top_pointer', tt.container, 'div');
  1010. 1008.  -       setStyle(bp, {marginLeft: linkW + 2});
  1011. 1009.  -       setStyle(tp, {marginLeft: linkW + 2});
  1012. 1010.  -     }
  1013. 1011.  -   });
  1014. 1012.  - },
  1015. 1013.  -
  1016. 1014.  - likeOut: function() {
  1017. 1015.  -   if (!wkcur.liked) {
  1018. 1016.  -     setTimeout(animate.pbind(ge('wk_like_icon'), {opacity: 0.4}, 200, false), 1);
  1019. 1017.  -   }
  1020. 1018.  - },
  1021. 1019.  -
  1022. 1020.  - like: function() {
  1023. 1021.  -   if (!vk.id) return;
  1024. 1022.  -   var my = !wkcur.liked;
  1025. 1023.  -
  1026. 1024.  -   ajax.post('like.php', {act: 'a_do_' + (my ? '' : 'un') + 'like', object: wkcur.like_obj || wkcur.wkRaw, hash: wkcur.likehash, from: 'wkview'}, {
  1027. 1025.  -     onDone: function(count, title) {
  1028. 1026.  -       return WkView.likeUpdate(my, count, title);
  1029. 1027.  -       wkcur.likes = count;
  1030. 1028.  -       wkcur.liked = my;
  1031. 1029.  -     }
  1032. 1030.  -   });
  1033. 1031.  -   WkView.likeUpdate(my, wkcur.likes + (my ? 1 : -1));
  1034. 1032.  - },
  1035. 1033.  - likeShare: function(hash) {
  1036. 1034.  -   var like_obj = wkcur.like_obj || wkcur.wkRaw,
  1037. 1035.  -       el = ge('like_share_' + like_obj),
  1038. 1036.  -       was = isChecked(el);
  1039. 1037.  -   checkbox(el);
  1040. 1038.  -   ajax.post('like.php', {act: 'a_do_' + (was ? 'un' : '') + 'publish', object: like_obj, hash: hash}, {
  1041. 1039.  -     onDone: WkView.likeUpdate.pbind(true)
  1042. 1040.  -   });
  1043. 1041.  -   var countInput = ge('like_real_count_' + like_obj),
  1044. 1042.  -       count = countInput ? countInput.value : val('like_count' + like_obj),
  1045. 1043.  -       my = hasClass(ge('like_icon' + like_obj), 'my_like');
  1046. 1044.  -
  1047. 1045.  -   WkView.likeUpdate(true, intval(count) + (my ? 0 : 1));
  1048. 1046.  - },
  1049. 1047.  - likeShareCustom: function () {
  1050. 1048.  -   if (vk.id) {
  1051. 1049.  -     showBox('like.php', {act: 'publish_box', object: wkcur.like_obj || wkcur.wkRaw, list: '', from: 'wkview'});
  1052. 1050.  -   }
  1053. 1051.  - },
  1054. 1052.  -
  1055. 1053.  - likeUpdate: function(my, count, title) {
  1056. 1054.  -   count = intval(count);
  1057. 1055.  -
  1058. 1056.  -   var rows = ge('like_table_' + (wkcur.like_obj || wkcur.wkRaw));
  1059. 1057.  -   var titleNode = ge('like_title_' + (wkcur.like_obj || wkcur.wkRaw)),
  1060. 1058.  -       countNode = ge('wk_like_count');
  1061. 1059.  -   var icon = ge('wk_like_icon');
  1062. 1060.  -   var tt = icon.parentNode.tt || {}, opts = clone(tt.opts || {}), newleft = (my ? 0 : -36);
  1063. 1061.  -
  1064. 1062.  -   if (title && titleNode) {
  1065. 1063.  -     val(titleNode, title);
  1066. 1064.  -   }
  1067. 1065.  -   wkcur.likes = count;
  1068. 1066.  -   animateCount(countNode, count);
  1069. 1067.  -
  1070. 1068.  -   wkcur.liked = my;
  1071. 1069.  -   toggleClass(icon, 'my_like', my);
  1072. 1070.  -   if (my) {
  1073. 1071.  -     setStyle(icon, {opacity: 1});
  1074. 1072.  -   }
  1075. 1073.  -   if (count) {
  1076. 1074.  -     var styleName = wkcur.rtl ? 'right' : 'left';
  1077. 1075.  -     if (tt.el && !isVisible(tt.container) && !title) {
  1078. 1076.  -       rows.style[styleName] = newleft + 'px';
  1079. 1077.  -       tooltips.show(tt.el, extend(opts, {showdt: 0}));
  1080. 1078.  -     } else if (rows) {
  1081. 1079.  -       var params = {};
  1082. 1080.  -       params[styleName] = newleft;
  1083. 1081.  -       animate(rows, params, 200);
  1084. 1082.  -     }
  1085. 1083.  -     removeClass(icon, 'no_likes');
  1086. 1084.  -   } else {
  1087. 1085.  -     if (tt.el) tt.hide();
  1088. 1086.  -     addClass(icon, 'no_likes');
  1089. 1087.  -   }
  1090. 1088.  - },
  1091. 1089.  -
  1092. 1090.  - showLikesPage: function(like_obj, published, offset) {
  1093. 1091.  -   cur.likesBox.loadTabContent('like.php', {act: 'a_get_members', object: like_obj, published: published, offset: offset, wall: 1}, published);
  1094. 1092.  - },
  1095. 1093.  -
  1096. 1094.  - extPageSubscribe: function(btn, oid, hash, msg) {
  1097. 1095.  -   var reqOptions = {
  1098. 1096.  -     showProgress: lockButton.pbind(btn),
  1099. 1097.  -     hideProgress: unlockButton.pbind(btn),
  1100. 1098.  -     onDone: function () {
  1101. 1099.  -       showDoneBox(msg, {w: 500, out: 5000});
  1102. 1100.  -       removeClass(btn.parentNode.parentNode.parentNode.parentNode, 'wk_extpage_head_unsubscribed');
  1103. 1101.  -     }
  1104. 1102.  -   };
  1105. 1103.  -   if (oid > 0) {
  1106. 1104.  -     ajax.post('al_friends.php', {act: 'add', mid: oid, hash: hash, from: 'wkview_extpage'}, reqOptions);
  1107. 1105.  -   } else {
  1108. 1106.  -     ajax.post('al_groups.php', {act: 'a_enter', gid: -oid, hash: hash, from: 'wkview_extpage'}, reqOptions);
  1109. 1107.  -   }
  1110. 1108.  - },
  1111. 1109.  -
  1112. 1110.  - wallBeforeInitPost: function (opts) {
  1113. 1111.  -   if (window.tooltips) tooltips.destroyAll();
  1114. 1112.  -
  1115. 1113.  -   if (wkcur.postInited) {
  1116. 1114.  -     return false;
  1117. 1115.  -   }
  1118. 1116.  -   wkcur.pageReplaced = [];
  1119. 1117.  -   var post = wkcur.post,
  1120. 1118.  -       postEl, size, postPlaceholder;
  1121. 1119.  -   while (true) {
  1122. 1120.  -     postEl = ge('post' + post);
  1123. 1121.  -     if (!postEl && cur.onepost && post == (cur.oid + '_' + cur.pid)) {
  1124. 1122.  -       postEl = ge('fw_post');
  1125. 1123.  -     }
  1126. 1124.  -     postEl = postEl || ge('reply_fakebox' + post) || ge('reply_box' + post) || ge('replies' + post) || ge('feedback_row_wall' + post) || (wkcur.hl_reply && (ge('post' + wkcur.hl_reply) || ge('feedback_row_wall_reply' + wkcur.hl_reply))) || ge('feed_rows');
  1127. 1125.  -     if (!postEl) {
  1128. 1126.  -       break;
  1129. 1127.  -     }
  1130. 1128.  -     size = getSize(postEl);
  1131. 1129.  -     postPlaceholder = ce('div', {className: 'wk_wall_post_placeholder', id: 'wk_wall_post_placeholder_' + postEl.id}, {width: size[0], height: size[1]});
  1132. 1130.  -     postEl.parentNode.replaceChild(postPlaceholder, postEl);
  1133. 1131.  -     wkcur.pageReplaced.push([postEl, postPlaceholder]);
  1134. 1132.  -   }
  1135. 1133.  -
  1136. 1134.  -   cur.wallLayer = post;
  1137. 1135.  -
  1138. 1136.  -   if (opts.options.wall_tpl) {
  1139. 1137.  -     extend(window.lang, opts.lang, opts.options.wall_tpl.lang);
  1140. 1138.  -     extend(wkcur, {
  1141. 1139.  -       wallType: opts.options.wall_type,
  1142. 1140.  -       wallTpl: opts.options.wall_tpl,
  1143. 1141.  -       wallMyDeleted: {},
  1144. 1142.  -       tsDiff: opts.options.wall_tpl && opts.options.wall_tpl.abs_timestamp ? Math.round((vkNow() / 1000 - opts.options.wall_tpl.abs_timestamp) / 900.0) * 900 : 0,
  1145. 1143.  -       wallMyOpened: {},
  1146. 1144.  -       wallMyReplied: {},
  1147. 1145.  -       wallMyRepliesCnt: 0
  1148. 1146.  -     });
  1149. 1147.  -     WkView.wallInitUpdates();
  1150. 1148.  -     wkcur.timeUpdateInt = setInterval(function () {Wall.updateTimes(wkcur.wkContent);}, 10000);
  1151. 1149.  -   }
  1152. 1150.  -
  1153. 1151.  -   wkcur._hide.push(WkView.wallDeinitPost);
  1154. 1152.  -
  1155. 1153.  -   wkcur.postInited = true;
  1156. 1154.  - },
  1157. 1155.  - wallAfterInitPost: function () {
  1158. 1156.  -   // debugLog('wall init', clone(wkcur));
  1159. 1157.  -   var post = wkcur.post,
  1160. 1158.  -       rf = ge('reply_field' + post);
  1161. 1159.  -
  1162. 1160.  -   if (rf) {
  1163. 1161.  -     placeholderSetup(rf, {pad: {margin: 0, padding: 0}})
  1164. 1162.  -   }
  1165. 1163.  -   WkView.wallUpdateReplies();
  1166. 1164.  -   if (wkcur.hl_reply) {
  1167. 1165.  -     setTimeout(Wall.highlightReply.pbind('post' + wkcur.hl_reply), 0);
  1168. 1166.  -   } else {
  1169. 1167.  -     setTimeout(function () {
  1170. 1168.  -       wkLayerWrap.scrollTop = wkcur.toScroll || 0;
  1171. 1169.  -       wkcur.toScroll = 0;
  1172. 1170.  -     }, 0);
  1173. 1171.  -   }
  1174. 1172.  - },
  1175. 1173.  - wallDeinitPost: function () {
  1176. 1174.  -   // debugLog('wall deinit', clone(wkcur));
  1177. 1175.  -   if (!wkcur.postInited) {
  1178. 1176.  -     return false;
  1179. 1177.  -   }
  1180. 1178.  -   cur.wallLayer = false;
  1181. 1179.  -   if (wkcur.edit) {
  1182. 1180.  -     Wall.cancelEdit();
  1183. 1181.  -   }
  1184. 1182.  -   each (wkcur.pageReplaced, function () {
  1185. 1183.  -     var postEl = this[0],
  1186. 1184.  -         postPlaceholder = this[1];
  1187. 1185.  -     if (postEl && postPlaceholder) {
  1188. 1186.  -       postPlaceholder.parentNode.replaceChild(postEl, postPlaceholder);
  1189. 1187.  -     }
  1190. 1188.  -   })
  1191. 1189.  -
  1192. 1190.  -   clearInterval(wkcur.updatesCheckInt);
  1193. 1191.  -   clearInterval(wkcur.timeUpdateInt);
  1194. 1192.  -
  1195. 1193.  -   if (window.tooltips) tooltips.destroyAll();
  1196. 1194.  -
  1197. 1195.  -   delete cur.editing;
  1198. 1196.  -   delete wkcur.postInited;
  1199. 1197.  - },
  1200. 1198.  - wallOnEdit: function (post, options) {
  1201. 1199.  -   wkcur.edit = true;
  1202. 1200.  -   val('wk_edit_link', options.lang.pages_view);
  1203. 1201.  -   wkcur.editor = {changed: true};
  1204. 1202.  - },
  1205. 1203.  - wallOnEdited: function (post) {
  1206. 1204.  -   wkcur.edit = false;
  1207. 1205.  -   val('wk_edit_link', wkcur.editLang);
  1208. 1206.  - },
  1209. 1207.  - wallFixPost: function (link, hash, value) {
  1210. 1208.  -   var post = wkcur.post;
  1211. 1209.  -   ajax.post('al_wall.php', {act: 'a_fix_post', post: post, hash: hash, value: value}, {
  1212. 1210.  -     progress: ge('wpe_prg' + post),
  1213. 1211.  -     onDone: function () {
  1214. 1212.  -       val(link, wkcur.lang[value ? 'wall_unfix_post' : 'wall_fix_post']);
  1215. 1213.  -       link.onclick = function () {
  1216. 1214.  -         return WkView.wallFixPost(link, hash, value ? 0 : 1);
  1217. 1215.  -       }
  1218. 1216.  -     }
  1219. 1217.  -   });
  1220. 1218.  -   return false;
  1221. 1219.  - },
  1222. 1220.  - wallPostDelete: function(act, hash) {
  1223. 1221.  -   var post = wkcur.post;
  1224. 1222.  -   if (cur.wallMyDeleted) {
  1225. 1223.  -     cur.wallMyDeleted[post] = 1;
  1226. 1224.  -   }
  1227. 1225.  -   ajax.post('al_wall.php', {act: act, post: post, hash: hash, from: 'wkview'}, {onDone: function(msg, deleted) {
  1228. 1226.  -     var p = ge('wl_post_body');
  1229. 1227.  -     if (!p) return;
  1230. 1228.  -     cur.pgPaused = true;
  1231. 1229.  -     hide('wl_replies_wrap', 'wl_post_actions_wrap', 'wl_reply_form_wrap');
  1232. 1230.  -     var del = p.nextSibling;
  1233. 1231.  -     if (del && hasClass(del, 'wl_post_deleted')) {
  1234. 1232.  -       val(del, msg);
  1235. 1233.  -     } else {
  1236. 1234.  -       p.parentNode.insertBefore(ce('div', {id: 'post_del' + post, innerHTML: msg, className: 'wl_post_deleted'}), p.nextSibling);
  1237. 1235.  -       hide(p);
  1238. 1236.  -     }
  1239. 1237.  -     wkLayerWrap.scrollTop = 0;
  1240. 1238.  -   }, progress: ge('wpe_prg' + post)});
  1241. 1239.  - },
  1242. 1240.  - wallPostRestore: function(hash) {
  1243. 1241.  -   var post = wkcur.post;
  1244. 1242.  -   if (cur.wallMyDeleted) {
  1245. 1243.  -     cur.wallMyDeleted[post] = 0;
  1246. 1244.  -   }
  1247. 1245.  -   ajax.post('al_wall.php', {act: 'restore', post: post, hash: hash, from: 'wkview'}, {onDone: function() {
  1248. 1246.  -     var p = ge('wl_post_body');
  1249. 1247.  -     if (!p || isVisible(p)) return;
  1250. 1248.  -     cur.pgPaused = false;
  1251. 1249.  -     show('wl_replies_wrap', 'wl_post_actions_wrap', 'wl_reply_form_wrap');
  1252. 1250.  -     var del = p.nextSibling;
  1253. 1251.  -     show(p);
  1254. 1252.  -     if (del && hasClass(del, 'wl_post_deleted')) {
  1255. 1253.  -       re(del);
  1256. 1254.  -     }
  1257. 1255.  -   }});
  1258. 1256.  - },
  1259. 1257.  - wallUpdateRepliesOnScroll: function (resize) {
  1260. 1258.  -   if (!wkcur.postInited) return;
  1261. 1259.  -   var wndHeight = window.innerHeight || document.documentElement.clientHeight;
  1262. 1260.  -
  1263. 1261.  -   var moreLink = ge('wl_replies_more_link');
  1264. 1262.  -   if (moreLink && isVisible(moreLink)) {
  1265. 1263.  -     var moreLinkY = getXY(moreLink, true)[1];
  1266. 1264.  -     if (wndHeight + 500 > moreLinkY) {
  1267. 1265.  -       moreLink.onclick();
  1268. 1266.  -     }
  1269. 1267.  -   }
  1270. 1268.  -
  1271. 1269.  -   var replyForm = ge('wl_reply_form');
  1272. 1270.  -   if (!replyForm || hasClass(replyForm, 'wl_post_reply_form_forbidden')) {
  1273. 1271.  -     return;
  1274. 1272.  -   }
  1275. 1273.  -   var formWrap = ge('wl_reply_form_wrap'),
  1276. 1274.  -       formY = getXY(formWrap, true)[1],
  1277. 1275.  -       formSize = getSize(replyForm);
  1278. 1276.  -       formH = formSize[1];
  1279. 1277.  -
  1280. 1278.  -   if (resize && wkcur.fixedBottom === false && wndHeight - formH < formY + 20) {
  1281. 1279.  -     wkLayerWrap.scrollTop += formY + 20 - (wndHeight - formH);
  1282. 1280.  -   } else if (isVisible(formWrap) && wndHeight - formH < formY) {
  1283. 1281.  -     if (!wkcur.fixedBottom || resize) {
  1284. 1282.  -       wkcur.fixedBottom = true;
  1285. 1283.  -       addClass(replyForm, 'wl_reply_form_fixed');
  1286. 1284.  -     }
  1287. 1285.  -     setStyle('wl_reply_form_wrap', {width: formSize[0], height: formSize[1], bottom: bottom});
  1288. 1286.  -     var bottom = Math.min(0, wndHeight - getXY('wl_replies_wrap', true)[1] - formH);
  1289. 1287.  -     setStyle(replyForm, {bottom: bottom});
  1290. 1288.  -   } else {
  1291. 1289.  -     if (wkcur.fixedBottom || resize) {
  1292. 1290.  -       wkcur.fixedBottom = false;
  1293. 1291.  -       removeClass(replyForm, 'wl_reply_form_fixed');
  1294. 1292.  -       setStyle('wl_reply_form_wrap', {width: '', height: ''});
  1295. 1293.  -     }
  1296. 1294.  -   }
  1297. 1295.  -   if (resize && wkcur.fixedBottom) {
  1298. 1296.  -     setStyle(replyForm, {left: getXY(wkcur.wkContent)[0] + 'px'})
  1299. 1297.  -   }
  1300. 1298.  - },
  1301. 1299.  - wallShowMoreReplies: function () {
  1302. 1300.  -   if (wkcur.loadingReplies) {
  1303. 1301.  -     return false;
  1304. 1302.  -   }
  1305. 1303.  -   var newOffset = wkcur.offset + wkcur.loaded,
  1306. 1304.  -       limit = wkcur.limit,
  1307. 1305.  -       repliesWrap = ge('replies' + wkcur.post);
  1308. 1306.  -
  1309. 1307.  -   if (wkcur.count <= newOffset || !repliesWrap) {
  1310. 1308.  -     return false;
  1311. 1309.  -   }
  1312. 1310.  -   wkcur.loadingReplies = true;
  1313. 1311.  -   Wall.moreReplies(wkcur.post, (wkcur.reverse ? -1 : 1) * newOffset, limit, {
  1314. 1312.  -     from: 'wkview',
  1315. 1313.  -     append: true,
  1316. 1314.  -     rev: wkcur.reverse ? 1 : 0,
  1317. 1315.  -     onDone: function (replies, names, data) {
  1318. 1316.  -       // debugLog((wkcur.reverse ? -1 : 1) * newOffset, limit, data);
  1319. 1317.  -       extend(wkcur, {
  1320. 1318.  -         count: data.count,
  1321. 1319.  -         loaded: wkcur.loaded + data.num
  1322. 1320.  -       });
  1323. 1321.  -       WkView.wallUpdateReplies();
  1324. 1322.  -       wkcur.loadingReplies = false;
  1325. 1323.  -     },
  1326. 1324.  -     onFail: function () {
  1327. 1325.  -       wkcur.loadingReplies = false;
  1328. 1326.  -     },
  1329. 1327.  -     showProgress: function () {
  1330. 1328.  -       hide('wl_replies_more_link');
  1331. 1329.  -       show('wl_replies_more_progress');
  1332. 1330.  -     },
  1333. 1331.  -     hideProgress: function () {
  1334. 1332.  -       show('wl_replies_more_link');
  1335. 1333.  -       hide('wl_replies_more_progress');
  1336. 1334.  -     }
  1337. 1335.  -   });
  1338. 1336.  -   return false;
  1339. 1337.  - },
  1340. 1338.  - wallShowPreviousReplies: function (hlReply) {
  1341. 1339.  -   if (wkcur.loadingReplies || wkcur.reverse) {
  1342. 1340.  -     return false;
  1343. 1341.  -   }
  1344. 1342.  -   var maxLimit = 100,
  1345. 1343.  -       newOffset = Math.max(0, wkcur.offset - maxLimit),
  1346. 1344.  -       limit = Math.min(maxLimit, wkcur.offset - newOffset),
  1347. 1345.  -       repliesWrap = ge('replies' + wkcur.post);
  1348. 1346.  -
  1349. 1347.  -   if (limit <= 0 || !repliesWrap) {
  1350. 1348.  -     return false;
  1351. 1349.  -   }
  1352. 1350.  -   wkcur.loadingReplies = true;
  1353. 1351.  -   var prevH = repliesWrap.offsetHeight;
  1354. 1352.  -   Wall.moreReplies(wkcur.post, newOffset, limit, {
  1355. 1353.  -     from: 'wkview',
  1356. 1354.  -     onDone: function (replies, names, data) {
  1357. 1355.  -       extend(wkcur, {
  1358. 1356.  -         count: data.count,
  1359. 1357.  -         offset: data.offset,
  1360. 1358.  -         loaded: wkcur.loaded + data.num
  1361. 1359.  -       });
  1362. 1360.  -       if (hlReply) {
  1363. 1361.  -         wkLayerWrap.scrollTop += repliesWrap.offsetHeight - prevH;
  1364. 1362.  -         setTimeout(Wall.highlightReply.pbind('post' + hlReply), 0);
  1365. 1363.  -       }
  1366. 1364.  -       WkView.wallUpdateReplies();
  1367. 1365.  -       wkcur.loadingReplies = false;
  1368. 1366.  -     },
  1369. 1367.  -     onFail: function () {
  1370. 1368.  -       wkcur.loadingReplies = false;
  1371. 1369.  -     },
  1372. 1370.  -     showProgress: function () {
  1373. 1371.  -       hide('wl_replies_header', 'wl_replies_header_toggler');
  1374. 1372.  -       show('wl_replies_previous_progress');
  1375. 1373.  -     },
  1376. 1374.  -     hideProgress: function () {
  1377. 1375.  -       show('wl_replies_header', 'wl_replies_header_toggler');
  1378. 1376.  -       hide('wl_replies_previous_progress');
  1379. 1377.  -     }
  1380. 1378.  -   });
  1381. 1379.  - },
  1382. 1380.  - wallUpdateReplies: function () {
  1383. 1381.  -   toggle('wl_replies_more_link', wkcur.offset + wkcur.loaded < wkcur.count);
  1384. 1382.  -
  1385. 1383.  -   var header = ge('wl_replies_header'),
  1386. 1384.  -       label = langNumeric(wkcur.count, wkcur.lang.wall_N_replies),
  1387. 1385.  -       hasPrevious = false;
  1388. 1386.  -
  1389. 1387.  -   if (!wkcur.reverse && wkcur.offset > 0) {
  1390. 1388.  -     if (wkcur.offset > 100) {
  1391. 1389.  -       label = langNumeric(100, wkcur.lang.wall_show_n_of_m_last).replace('{count}', wkcur.count);
  1392. 1390.  -     } else {
  1393. 1391.  -       label = langNumeric(wkcur.count, wkcur.lang.wall_show_all_n_replies);
  1394. 1392.  -     }
  1395. 1393.  -     hasPrevious = true;
  1396. 1394.  -   }
  1397. 1395.  -   val('wl_replies_header_label', label);
  1398. 1396.  -   toggleClass(header, 'wl_replies_header_clickable', hasPrevious);
  1399. 1397.  -
  1400. 1398.  -   var repliesWrap = ge('wl_replies_wrap'),
  1401. 1399.  -       form = ge('wl_reply_form');
  1402. 1400.  -   if (wkcur.count && repliesWrap && !isVisible(repliesWrap.firstChild)) {
  1403. 1401.  -     show(repliesWrap.firstChild);
  1404. 1402.  -   }
  1405. 1403.  -   if (form) {
  1406. 1404.  -     var formPlace1 = ge('wl_reply_form_reverse_wrap'),
  1407. 1405.  -         formPlace2 = ge('wl_reply_form_wrap'),
  1408. 1406.  -         formPlace = wkcur.reverse && repliesWrap && isVisible(repliesWrap.firstChild) && formPlace1 || formPlace2;
  1409. 1407.  -
  1410. 1408.  -     toggle(formPlace1, formPlace == formPlace1);
  1411. 1409.  -     toggle(formPlace2, formPlace == formPlace2);
  1412. 1410.  -     toggleClass(form, 'wl_reply_form_reversed', formPlace == formPlace1);
  1413. 1411.  -     if (form.parentNode != formPlace) {
  1414. 1412.  -       formPlace.appendChild(form);
  1415. 1413.  -     }
  1416. 1414.  -   }
  1417. 1415.  -
  1418. 1416.  -   WkView.wallUpdateRepliesOnScroll();
  1419. 1417.  -   WkView.updateSize();
  1420. 1418.  - },
  1421. 1419.  - wallInitUpdates: function () {
  1422. 1420.  -   var key = wkcur.options.add_queue_key;
  1423. 1421.  -   if (!key || !window.Notifier) {
  1424. 1422.  -     return;
  1425. 1423.  -   }
  1426. 1424.  -   var wasKey = wkcur.wallAddQueue,
  1427. 1425.  -       checkCb = function () {
  1428. 1426.  -         if (wkcur.wallAddQueue) Notifier.addKey(wkcur.wallAddQueue, Wall.updated.pbind(true));
  1429. 1427.  -       };
  1430. 1428.  -
  1431. 1429.  -   wkcur.wallAddQueue = key;
  1432. 1430.  -   checkCb();
  1433. 1431.  -   wkcur.updatesCheckInt = setInterval(checkCb, 10000);
  1434. 1432.  - },
  1435. 1433.  - wallCancelEditReply: function () {
  1436. 1434.  -   var post = wkcur.post,
  1437. 1435.  -       rf = ge('reply_field' + post),
  1438. 1436.  -       composer = rf && data(rf, 'composer');
  1439. 1437.  -   if (composer) {
  1440. 1438.  -     Composer.reset(composer);
  1441. 1439.  -   } else {
  1442. 1440.  -     val(rf, '');
  1443. 1441.  -   }
  1444. 1442.  -   Wall.hideEditReply(post);
  1445. 1443.  -   WkView.wallUpdateReplies();
  1446. 1444.  - },
  1447. 1445.  - wallInverseReplies: function () {
  1448. 1446.  -   if (wkcur.loadingReplies) {
  1449. 1447.  -     return false;
  1450. 1448.  -   }
  1451. 1449.  -   wkcur.loadingReplies = true;
  1452. 1450.  -   wkcur.reverse = !wkcur.reverse;
  1453. 1451.  -   wkcur.offset = 0;
  1454. 1452.  -
  1455. 1453.  -   Wall.moreReplies(wkcur.post, wkcur.offset, wkcur.limit, {
  1456. 1454.  -     from: 'wkview',
  1457. 1455.  -     clear: true,
  1458. 1456.  -     rev: wkcur.reverse ? 1 : 0,
  1459. 1457.  -     onDone: function (replies, names, data) {
  1460. 1458.  -       toggleClass('wl_replies_header_toggler', 'wl_replies_header_toggler_inversed', wkcur.reverse);
  1461. 1459.  -       extend(wkcur, {
  1462. 1460.  -         count: data.count,
  1463. 1461.  -         loaded: data.num
  1464. 1462.  -       });
  1465. 1463.  -       WkView.wallUpdateReplies();
  1466. 1464.  -       wkcur.loadingReplies = false;
  1467. 1465.  -     },
  1468. 1466.  -     onFail: function () {
  1469. 1467.  -       wkcur.reverse = !wkcur.reverse;
  1470. 1468.  -       wkcur.loadingReplies = false;
  1471. 1469.  -     },
  1472. 1470.  -     showProgress: function () {
  1473. 1471.  -       hide('wl_replies_header', 'wl_replies_header_toggler');
  1474. 1472.  -       show('wl_replies_previous_progress');
  1475. 1473.  -     },
  1476. 1474.  -     hideProgress: function () {
  1477. 1475.  -       show('wl_replies_header', 'wl_replies_header_toggler');
  1478. 1476.  -       hide('wl_replies_previous_progress');
  1479. 1477.  -     }
  1480. 1478.  -   });
  1481. 1479.  - },
  1482. 1480.  -
  1483. 1481.  - likesInit: function () {
  1484. 1482.  -   re(cur.lSTL);
  1485. 1483.  -   extend(wkcur, {
  1486. 1484.  -     phCache: {},
  1487. 1485.  -     phShown: {},
  1488. 1486.  -     historyLen: 0,
  1489. 1487.  -
  1490. 1488.  -     lSTL: wkLayerWrap.appendChild(ce('div', {id: 'layer_stl', innerHTML: '<div id="layer_stl_bg" class="fixed"></div><div id="layer_stl_cl"></div><nobr id="layer_stl_text" class="fixed">' + getLang('global_to_top') + '</nobr>', el: ge('wk_box'), onclick: cancelEvent, onmousedown: WkView.likesSTLDown, sc: WkView.likesOnScroll})),
  1491. 1489.  -     lSTLShown: 0,
  1492. 1490.  -     lSTLWas: 0,
  1493. 1491.  -     lSTLWasSet: 0
  1494. 1492.  -   });
  1495. 1493.  -   cur.lSTL = wkcur.lSTL;
  1496. 1494.  -
  1497. 1495.  -   WkView.likesTabInit();
  1498. 1496.  -
  1499. 1497.  -   addEvent(wkLayerWrap, 'scroll', WkView.onScroll);
  1500. 1498.  -   addEvent(window, 'resize', WkView.onResize);
  1501. 1499.  -   onBodyResize();
  1502. 1500.  -
  1503. 1501.  -   if (!cur.wallInited) {
  1504. 1502.  -     Wall.initWallOptions(wkcur.wall_opts);
  1505. 1503.  -   } else {
  1506. 1504.  -     wkcur._oldReplyForm = cur.wallTpl.reply_form;
  1507. 1505.  -     cur.wallTpl.reply_form = wkcur.wall_opts.wall_tpl.reply_form;
  1508. 1506.  -   }
  1509. 1507.  -
  1510. 1508.  -   if (cur.options === undefined) {
  1511. 1509.  -     cur.options = {reply_names: {}};
  1512. 1510.  -   } else if (cur.options.reply_names === undefined) {
  1513. 1511.  -     cur.options.reply_names = {};
  1514. 1512.  -   }
  1515. 1513.  -   extend(cur.options.reply_names, wkcur.reply_names);
  1516. 1514.  -
  1517. 1515.  -   wkcur._hide.push(function () {
  1518. 1516.  -     removeEvent(wkLayerWrap, 'scroll', WkView.onScroll);
  1519. 1517.  -     removeEvent(window, 'resize', WkView.onResize);
  1520. 1518.  -     re(wkcur.lSTL, cur.lSTL);
  1521. 1519.  -     if (wkcur._oldReplyForm) {
  1522. 1520.  -       cur.wallTpl.reply_form = wkcur._oldReplyForm;
  1523. 1521.  -       wkcur._oldReplyForm = false;
  1524. 1522.  -     }
  1525. 1523.  -   });
  1526. 1524.  - },
  1527. 1525.  - likesTabInit: function () {
  1528. 1526.  -   if (wkcur.preload) {
  1529. 1527.  -     ajax.preload('wkview.php', {
  1530. 1528.  -       act: 'show',
  1531. 1529.  -       w: wkcur.wkRaw,
  1532. 1530.  -       offset: wkcur.offset
  1533. 1531.  -     }, wkcur.preload);
  1534. 1532.  -   }
  1535. 1533.  - },
  1536. 1534.  - likesTab: function (tab) {
  1537. 1535.  -   ajax.post('wkview.php', {act: 'show', w: tab + '/' + wkcur.like_obj, part: 1}, {
  1538. 1536.  -     cache: 1,
  1539. 1537.  -     showProgress: setStyle.pbind('wk_likes_tabs_prg', {visibility: 'visible'}),
  1540. 1538.  -     hideProgress: setStyle.pbind('wk_likes_tabs_prg', {visibility: 'hidden'}),
  1541. 1539.  -     onDone: function (title, content, options) {
  1542. 1540.  -       val('wk_likes_title', title);
  1543. 1541.  -       val('wk_likes_content', content);
  1544. 1542.  -       extend(wkcur, options);
  1545. 1543.  -       WkView.likesTabInit();
  1546. 1544.  -
  1547. 1545.  -       var oldTab = geByClass1('summary_tab_sel', ge('wk_likes_tabs')),
  1548. 1546.  -           newTab = ge('wk_likes_tab' + tab);
  1549. 1547.  -       replaceClass(oldTab, 'summary_tab_sel', 'summary_tab');
  1550. 1548.  -       replaceClass(newTab.parentNode, 'summary_tab', 'summary_tab_sel');
  1551. 1549.  -
  1552. 1550.  -       WkView.setLocation();
  1553. 1551.  -       WkView.updateHeight();
  1554. 1552.  -       WkView.likesOnScroll();
  1555. 1553.  -     }
  1556. 1554.  -   });
  1557. 1555.  - },
  1558. 1556.  - likesPreload: function () {
  1559. 1557.  -   ajax.post('wkview.php', {act: 'show', w: wkcur.wkRaw, offset: wkcur.offset}, {cache: 1});
  1560. 1558.  - },
  1561. 1559.  - likesMore: function() {
  1562. 1560.  -   if (isVisible('wk_likes_more_prg')) return;
  1563. 1561.  -   ajax.post('wkview.php', {act: 'show', w: wkcur.wkRaw, offset: wkcur.offset}, {
  1564. 1562.  -     onDone: function(rows, newOffset, needMore, names, noReplies) {
  1565. 1563.  -       var cnt = ge('wk_likes_rows');
  1566. 1564.  -       if (!cnt) return;
  1567. 1565.  -
  1568. 1566.  -       if (noReplies) { // show all posts with hidden replies
  1569. 1567.  -         var hidden = geByClass('wk_likes_hidden', cnt);
  1570. 1568.  -         for (var i = 0, l = hidden.length; i < l; ++i) {
  1571. 1569.  -           cnt.appendChild(hidden[i]);
  1572. 1570.  -           removeClass(hidden[i], 'wk_likes_hidden');
  1573. 1571.  -         }
  1574. 1572.  -       }
  1575. 1573.  -
  1576. 1574.  -       cnt.appendChild(cf(rows));
  1577. 1575.  -       wkcur.offset = newOffset;
  1578. 1576.  -       if (needMore) {
  1579. 1577.  -         WkView.likesPreload();
  1580. 1578.  -       } else {
  1581. 1579.  -         hide('wk_likes_more_link');
  1582. 1580.  -       }
  1583. 1581.  -       WkView.updateHeight();
  1584. 1582.  -       if (names) {
  1585. 1583.  -         extend(cur.options.reply_names, names);
  1586. 1584.  -       }
  1587. 1585.  -     }, showProgress: function() {
  1588. 1586.  -       hide('wk_likes_more_link');
  1589. 1587.  -       show('wk_likes_more_prg');
  1590. 1588.  -     }, hideProgress: function() {
  1591. 1589.  -       show('wk_likes_more_link');
  1592. 1590.  -       hide('wk_likes_more_prg');
  1593. 1591.  -     }, cache: 1
  1594. 1592.  -   });
  1595. 1593.  - },
  1596. 1594.  - likesBigphOver: function(obj, uid) {
  1597. 1595.  -   if (!wkcur.lang || !wkcur.lang.global_photo_full_size || browser.mobile) return;
  1598. 1596.  -   var o = obj.firstChild,
  1599. 1597.  -       ch = wkcur.phCache[uid];
  1600. 1598.  -   if (o.tagName != 'A' || o.className != 'wk_likes_likerph') {
  1601. 1599.  -     o = obj.insertBefore(ce('a', {className: 'wk_likes_likerph', href: ch && ch._id ? ('/photo' + ch._id + '?all=1') : ('/albums' + uid), innerHTML: '<span class="wk_likes_likerph_label">' + wkcur.lang.global_photo_full_size + '</span>'}), obj.firstChild);
  1602. 1600.  -     o.onclick = WkView.likesBigphClick.pbind(uid);
  1603. 1601.  -     o._uid = uid;
  1604. 1602.  -   }
  1605. 1603.  -
  1606. 1604.  -   clearTimeout(o.hideTO);
  1607. 1605.  -   animate(o, {marginTop: 75}, {duration: 200, transition: Fx.Transitions.easeOutCirc});
  1608. 1606.  -   wkcur.phShown[uid] = o;
  1609. 1607.  -
  1610. 1608.  -   if (!obj.onmouseout) obj.onmouseout = WkView.likesBigphOut.pbind(obj);
  1611. 1609.  - },
  1612. 1610.  - likesBigphOut: function(obj) {
  1613. 1611.  -   var o = obj.firstChild;
  1614. 1612.  -   if (!o || o.tagName != 'A' || o.className != 'wk_likes_likerph') return;
  1615. 1613.  -
  1616. 1614.  -   clearTimeout(o.hideTO);
  1617. 1615.  -   o.hideTO = setTimeout(function() {
  1618. 1616.  -     animate(o, {marginTop: 100}, 200);
  1619. 1617.  -     delete(wkcur.phShown[o._uid]);
  1620. 1618.  -   }, 150);
  1621. 1619.  - },
  1622. 1620.  - likesBigphClick: function(uid, ev) {
  1623. 1621.  -   if (checkEvent(ev) !== false) return;
  1624. 1622.  -
  1625. 1623.  -   var ch = wkcur.phCache[uid]
  1626. 1624.  -       o = wkcur.phShown[uid],
  1627. 1625.  -       obj = domPN(o);
  1628. 1626.  -
  1629. 1627.  -   if (!o || !obj) return;
  1630. 1628.  -   if (ch === undefined) {
  1631. 1629.  -     ch = wkcur.phCache[uid] = 'show';
  1632. 1630.  -     ajax.post('al_photos.php', {act: 'fast_get_photo', oid: uid}, {onDone: function(res) {
  1633. 1631.  -       if (!res) {
  1634. 1632.  -         obj.onmouseover = function() {};
  1635. 1633.  -         re(o);
  1636. 1634.  -         return;
  1637. 1635.  -       }
  1638. 1636.  -       var sh = (wkcur.phCache[uid] == 'show');
  1639. 1637.  -       wkcur.phCache[uid] = res;
  1640. 1638.  -       o.href = '/photo' + res._id + '?all=1';
  1641. 1639.  -       if (sh) WkView.likesBigphClick(uid);
  1642. 1640.  -     }, onFail: function() {
  1643. 1641.  -       obj.onmouseover = function() {};
  1644. 1642.  -       re(o);
  1645. 1643.  -       return true;
  1646. 1644.  -     }});
  1647. 1645.  -   }
  1648. 1646.  -   if (ch == 'show') {
  1649. 1647.  -     return cancelEvent(ev);
  1650. 1648.  -   }
  1651. 1649.  -   if (!ch) return;
  1652. 1650.  -   extend(ch, {
  1653. 1651.  -     jumpTo: {z: 'albums' + uid},
  1654. 1652.  -     queue: 1
  1655. 1653.  -   });
  1656. 1654.  -   return showPhoto(ch._id, 'album' + uid + '_0/rev', ch, ev);
  1657. 1655.  - },
  1658. 1656.  - likesSTLDown: function(e) {
  1659. 1657.  -   e = e || window.event;
  1660. 1658.  -   if (checkEvent(e)) return;
  1661. 1659.  -
  1662. 1660.  -   if (!__afterFocus) {
  1663. 1661.  -     if (wkcur.lSTLWasSet && wkcur.lSTLWas) {
  1664. 1662.  -       var to = wkcur.lSTLWas;
  1665. 1663.  -       wkcur.lSTLWas = 0;
  1666. 1664.  -       wkLayerWrap.scrollTop = to;
  1667. 1665.  -     } else {
  1668. 1666.  -       wkcur.lSTLWas = wkLayerWrap.scrollTop;
  1669. 1667.  -       wkLayerWrap.scrollTop = 0;
  1670. 1668.  -     }
  1671. 1669.  -   }
  1672. 1670.  -   return cancelEvent(e);
  1673. 1671.  - },
  1674. 1672.  - likesOnScroll: function (resize) {
  1675. 1673.  -
  1676. 1674.  -   var st = wkLayerWrap.scrollTop,
  1677. 1675.  -       mx = 200,
  1678. 1676.  -       vis = wkcur.lSTLWas || (st > mx),
  1679. 1677.  -       o = 0;
  1680. 1678.  -
  1681. 1679.  -   wkcur.lSTL.style.marginTop = st + 'px';
  1682. 1680.  -   if (!vis) {
  1683. 1681.  -     if (wkcur.lSTLShown !== 0) {
  1684. 1682.  -       hide(wkcur.lSTL);
  1685. 1683.  -       wkcur.lSTLShown = 0;
  1686. 1684.  -     }
  1687. 1685.  -   } else {
  1688. 1686.  -     if (wkcur.lSTLShown !== 1) {
  1689. 1687.  -       show(wkcur.lSTL);
  1690. 1688.  -       wkcur.lSTLShown = 1;
  1691. 1689.  -     }
  1692. 1690.  -     if (wkcur.lSTLWas && st > 500) {
  1693. 1691.  -       wkcur.lSTLWas = 0;
  1694. 1692.  -     }
  1695. 1693.  -     if (st > mx) {
  1696. 1694.  -       o = (st - mx) / mx;
  1697. 1695.  -       if (wkcur.lSTLWasSet) {
  1698. 1696.  -         wkcur.lSTLWasSet = 0;
  1699. 1697.  -         val(domLC(wkcur.lSTL), getLang('global_to_top'));
  1700. 1698.  -         removeClass(domLC(wkcur.lSTL), 'down');
  1701. 1699.  -       }
  1702. 1700.  -     } else {
  1703. 1701.  -       o = (mx - st) / mx;
  1704. 1702.  -       if (wkcur.lSTLWas) {
  1705. 1703.  -         if (!wkcur.lSTLWasSet) {
  1706. 1704.  -           wkcur.lSTLWasSet = 1;
  1707. 1705.  -           val(domLC(wkcur.lSTL), '');
  1708. 1706.  -           addClass(domLC(wkcur.lSTL), 'down');
  1709. 1707.  -         }
  1710. 1708.  -       }
  1711. 1709.  -     }
  1712. 1710.  -   }
  1713. 1711.  -   setStyle(wkcur.lSTL, {opacity: Math.min(Math.max(o, 0), 1)});
  1714. 1712.  -
  1715. 1713.  -   var bt = lastWindowHeight,
  1716. 1714.  -       objMore = ge('wk_likes_more_link');
  1717. 1715.  -   if (isVisible(objMore) && (bt > getXY(objMore, true)[1])) {
  1718. 1716.  -     objMore.click();
  1719. 1717.  -   }
  1720. 1718.  - },
  1721. 1719.  - likesBlacklistTip: function (el) {
  1722. 1720.  -   showTooltip(el, {
  1723. 1721.  -     text: wkcur.lang.like_block_liker,
  1724. 1722.  -     shift: [13, 1, 1],
  1725. 1723.  -     black: 1
  1726. 1724.  -   });
  1727. 1725.  - },
  1728. 1726.  - likesBlacklist: function (el, oid, event) {
  1729. 1727.  -   if (el.tt && el.tt.destroy) el.tt.destroy();
  1730. 1728.  -   showBox('like.php', {act: 'spam', mid: oid, object: wkcur.like_obj});
  1731. 1729.  -   return cancelEvent(event);
  1732. 1730.  - },
  1733. 1731.  - likesRecache: function(d) {
  1734. 1732.  -   wkcur.offset += d;
  1735. 1733.  -   for (var i in ajaxCache) {
  1736. 1734.  -     if (i.match(new RegExp('^\\/wkview\.php\\#act=show', ''))) {
  1737. 1735.  -       delete(ajaxCache[i]);
  1738. 1736.  -     }
  1739. 1737.  -   }
  1740. 1738.  - },
  1741. 1739.  - likesRemove: function(oid) {
  1742. 1740.  -   re('wk_likes_liker_row' + oid);
  1743. 1741.  -   WkView.likesRecache(-1);
  1744. 1742.  -   WkView.onScroll();
  1745. 1743.  -   if (!domFC(ge('wk_likes_rows'))) {
  1746. 1744.  -     location.reload();
  1747. 1745.  -   }
  1748. 1746.  - },
  1749. 1747.  -
  1750. 1748.  - historyInit: function () {
  1751. 1749.  -   addEvent(wkLayerWrap, 'scroll', WkView.onScroll);
  1752. 1750.  -   addEvent(window, 'resize', WkView.onResize);
  1753. 1751.  -   onBodyResize();
  1754. 1752.  -
  1755. 1753.  -   wkcur._hide.push(function () {
  1756. 1754.  -     removeEvent(wkLayerWrap, 'scroll', WkView.onScroll);
  1757. 1755.  -     removeEvent(window, 'resize', WkView.onResize);
  1758. 1756.  -   });
  1759. 1757.  - },
  1760. 1758.  - historyOnScroll: function () {
  1761. 1759.  -   if (wkcur.loadingHistory) {
  1762. 1760.  -     return false;
  1763. 1761.  -   }
  1764. 1762.  -   var wndHeight = window.innerHeight || document.documentElement.clientHeight;
  1765. 1763.  -
  1766. 1764.  -   var moreLink = ge('wk_history_more_link');
  1767. 1765.  -   if (moreLink && isVisible(moreLink)) {
  1768. 1766.  -     var moreLinkY = getXY(moreLink, true)[1];
  1769. 1767.  -     if (wndHeight + 500 > moreLinkY) {
  1770. 1768.  -       moreLink.onclick();
  1771. 1769.  -     }
  1772. 1770.  -   }
  1773. 1771.  - },
  1774. 1772.  - historyShowMore: function () {
  1775. 1773.  -   if (wkcur.loadingHistory) {
  1776. 1774.  -     return false;
  1777. 1775.  -   }
  1778. 1776.  -   var newOffset = wkcur.offset;
  1779. 1777.  -   wkcur.loadingHistory = true;
  1780. 1778.  -   ajax.post('wkview.php', {act: 'show', w: wkcur.wkRaw, offset: newOffset, part: 1}, {
  1781. 1779.  -     onDone: function (options, rows) {
  1782. 1780.  -       extend(wkcur, options);
  1783. 1781.  -       ge('wk_history_rows').appendChild(cf(rows));
  1784. 1782.  -       setTimeout(WkView.historyOnScroll, 500);
  1785. 1783.  -
  1786. 1784.  -       toggle('wk_history_more_link', wkcur.offset < wkcur.count);
  1787. 1785.  -       toggle('wk_history_empty', wkcur.offset >= wkcur.count && !domFC(ge('wk_history_rows')));
  1788. 1786.  -       toggleClass('wk_history_more', 'wk_history_more_loading', wkcur.offset < wkcur.count && !domFC(ge('wk_history_rows')));
  1789. 1787.  -       wkcur.loadingHistory = false;
  1790. 1788.  -     },
  1791. 1789.  -     onFail: function () {
  1792. 1790.  -       wkcur.loadingHistory = false;
  1793. 1791.  -     },
  1794. 1792.  -     showProgress: function () {
  1795. 1793.  -       hide('wk_history_more_link');
  1796. 1794.  -       show('wk_history_more_progress');
  1797. 1795.  -     },
  1798. 1796.  -     hideProgress: function () {
  1799. 1797.  -       show('wk_history_more_link');
  1800. 1798.  -       hide('wk_history_more_progress');
  1801. 1799.  -     }
  1802. 1800.  -   });
  1803. 1801.  -
  1804. 1802.  -   return false;
  1805. 1803.  - },
  1806. 1804.  -
  1807. 1805.  - activate: function(arrow) {
  1808. 1806.  -   if (arrow && arrow.timeout) {
  1809. 1807.  -     clearTimeout(arrow.timeout);
  1810. 1808.  -     removeAttr(arrow, 'timeout');
  1811. 1809.  -   } else if (isVisible(arrow)) {
  1812. 1810.  -     fadeTo(arrow, 200, vk.pvdark ? 1 : 0.7);
  1813. 1811.  -   }
  1814. 1812.  - },
  1815. 1813.  -
  1816. 1814.  - deactivate: function(arrow) {
  1817. 1815.  -   if (!arrow || !isVisible(arrow) || arrow.timeout) {
  1818. 1816.  -     return;
  1819. 1817.  -   }
  1820. 1818.  -   arrow.timeout = setTimeout(function() {
  1821. 1819.  -     removeAttr(arrow, 'timeout');
  1822. 1820.  -     fadeTo(arrow, 200, 0.4);
  1823. 1821.  -   }, 1);
  1824. 1822.  - },
  1825. 1823.  -
  1826. 1824.  - activateArrow: function (next, event) {
  1827. 1825.  -   var arrow = wkcur[next ? 'wkRightArrow' : 'wkLeftArrow'],
  1828. 1826.  -       bg = wkcur[next ? 'wkRightArrowBg' : 'wkLeftArrowBg'].firstChild;
  1829. 1827.  -
  1830. 1828.  -   if (arrow && arrow.timeout) {
  1831. 1829.  -     clearTimeout(arrow.timeout);
  1832. 1830.  -     removeAttr(arrow, 'timeout');
  1833. 1831.  -   } else if (isVisible(arrow)) {
  1834. 1832.  -     wkcur.arrowOver = next;
  1835. 1833.  -     fadeTo(arrow, 200, vk.pvdark ? 1 : 0.7);
  1836. 1834.  -     fadeTo(bg, 200, 0.15);
  1837. 1835.  -   }
  1838. 1836.  -   WkView.preloadArrow(next);
  1839. 1837.  -   cancelEvent(event);
  1840. 1838.  - },
  1841. 1839.  - preloadArrow: function (next) {
  1842. 1840.  -   var arrow = wkcur[next ? 'wkRightArrow' : 'wkLeftArrow'];
  1843. 1841.  -
  1844. 1842.  -   if (!arrow.cached) {
  1845. 1843.  -     arrow.cached = true;
  1846. 1844.  -     var actions = WkView.getNextWkRaws(),
  1847. 1845.  -         preloadWkRaw = actions[next ? 1 : 0];
  1848. 1846.  -
  1849. 1847.  -     if (preloadWkRaw) {
  1850. 1848.  -       ajax.post('wkview.php', extend({act: 'show', loc: nav.objLoc[0]}, {w: preloadWkRaw}), {cache: 1});
  1851. 1849.  -     }
  1852. 1850.  -   }
  1853. 1851.  - },
  1854. 1852.  - deactivateArrow: function (next, event) {
  1855. 1853.  -   var arrow = wkcur[next ? 'wkRightArrow' : 'wkLeftArrow'],
  1856. 1854.  -       bg = wkcur[next ? 'wkRightArrowBg' : 'wkLeftArrowBg'].firstChild;
  1857. 1855.  -
  1858. 1856.  -   if (!arrow || !isVisible(arrow) || arrow.timeout || (wkcur.arrowClicked && (vkNow() - wkcur.arrowClicked < 100))) {
  1859. 1857.  -     return;
  1860. 1858.  -   }
  1861. 1859.  -
  1862. 1860.  -   delete wkcur.arrowOver;
  1863. 1861.  -   arrow.timeout = setTimeout(function() {
  1864. 1862.  -     removeAttr(arrow, 'timeout');
  1865. 1863.  -     fadeTo(arrow, 200, 0.4);
  1866. 1864.  -     fadeTo(bg, 200, 0);
  1867. 1865.  -   }, 1);
  1868. 1866.  -   cancelEvent(event);
  1869. 1867.  - },
  1870. 1868.  -
  1871. 1869.  - back: function() {
  1872. 1870.  -   if (wkcur.historyLen > 1) {
  1873. 1871.  -     wkcur.doBack = 1;
  1874. 1872.  -     wkcur.historyLen -= 1;
  1875. 1873.  -     history.go(-1);
  1876. 1874.  -     return true;
  1877. 1875.  -   } else {
  1878. 1876.  -     WkView.hide();
  1879. 1877.  -   }
  1880. 1878.  - },
  1881. 1879.  -
  1882. 1880.  -
  1883. 1881.  - _eof: 1};try{stManager.done('wkview.js');}catch(e){}
  1884. ------
Advertisement
Add Comment
Please, Sign In to add comment