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