Hormold

VK Change (#1384447505)

Nov 14th, 2013
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 137.19 KB | None | 0 0
  1. Файл - photoview.js (Старый размер - 113028 | Новый - 0):
  2. 0.  - var Photoview = {
  3. 1.  -   blank: '/images/blank.gif',
  4. 2.  -   blankf: function() {},
  5. 3.  -   cacheSize: 3,
  6. 4.  -   allSizes: ['x', 'y', 'z'/*, 'w'*/],
  7. 5.  -   genUrl: function(base, add) {
  8. 6.  -     if (!add.match(/\.[a-z]{3}$/i)) add += '.jpg';
  9. 7.  -     if (add.match(/https?:\/\//i)) return add;
  10. 8.  -     return (base || '').replace(/\/[a-z0-9_:\.]*$/i, '') + '/' + add;
  11. 9.  -   },
  12. 10.  -   genData: function(ph, size) {
  13. 11.  -     var f = (size == 'x') ? 3 : ((size == 'y') ? 2 : ((size == 'z') ? 1 : 0)), c = ['w', 'z', 'y', 'x'].slice(f), d, s, i, l;
  14. 12.  -     for (i = 0; i < 4 - f; ++i) {
  15. 13.  -       l = c[i];
  16. 14.  -       if (d = ph[l + '_']) break;
  17. 15.  -       if (s = ph[l + '_src']) break;
  18. 16.  -     }
  19. 17.  -     if (!d) d = [s];
  20. 18.  -     return {src: Photoview.genUrl(ph.base, d[0]), width: d[2] && d[1], height: d[1] && d[2]};
  21. 19.  -   },
  22. 20.  -
  23. 21.  -   updateArrows: function() {
  24. 22.  -     var sbw = sbWidth() + 2;
  25. 23.  -     if (cur.pvLeft) {
  26. 24.  -       cur.pvLeft.style.left = '20px';//(Math.floor((lastWindowWidth - sbw - cur.pvActualWidth - 52) / 2) - 39) + 'px';
  27. 25.  -     }
  28. 26.  -     cur.pvLeftNav.style.width = Math.floor((lastWindowWidth - sbw - cur.pvActualWidth - 52) / 2) + 'px';
  29. 27.  -     cur.pvRightNav.style.left = Math.floor((lastWindowWidth - sbw + cur.pvActualWidth + 52) / 2) + 'px';
  30. 28.  -     cur.pvRightNav.style.width = Math.floor((lastWindowWidth - sbw - cur.pvActualWidth - 52) / 2) + 'px';
  31. 29.  -     if (cur.pvClose) {
  32. 30.  -       cur.pvClose.style.left = (lastWindowWidth - sbw - 2 - 37) + 'px';//(Math.floor((lastWindowWidth - sbw + cur.pvActualWidth + 52) / 2) + 22) + 'px';
  33. 31.  -     }
  34. 32.  -   },
  35. 33.  -   updateHeight: function() {
  36. 34.  -     var h = cur.pvBox.offsetHeight + 110, sbw = Math.floor(sbWidth() / 2);
  37. 35.  -     cur.pvLeftNav.style.height = cur.pvRightNav.style.height = (h - 110) + 'px';
  38. 36.  -     window.updateWndVScroll && updateWndVScroll();
  39. 37.  -     if (!browser.mobile) return;
  40. 38.  -     var skipTop = 10 + cur.pvYOffset;
  41. 39.  -     cur.pvLeft.style.top = cur.pvClose.style.top = (cur.pvYOffset + 25) + 'px';
  42. 40.  -     if (lastWindowHeight < cur.pvYOffset + h) {
  43. 41.  -       setTimeout(function() {
  44. 42.  -         var f = ge('footer');
  45. 43.  -         f.style.height = (intval(getStyle(f, 'height')) + (cur.pvYOffset + h - lastWindowHeight)) + 'px';
  46. 44.  -         onBodyResize();
  47. 45.  -         Photoview.onResize();
  48. 46.  -       }, 1);
  49. 47.  -     }
  50. 48.  -   },
  51. 49.  -   actionInfo: function() {
  52. 50.  -     return ge('pv_action_info') || cur.pvWide.insertBefore(ce('div', {id: 'pv_action_info'}), cur.pvTags);
  53. 51.  -   },
  54. 52.  -
  55. 53.  -   locNav: function(ch, old, nw, opts) {
  56. 54.  -     if ((cur.pvListId == 'newtag' + vk.id + (nw.rev ? '/rev' : '')) && (nw[0] == 'albums' + vk.id) && (nw.act == 'added')) {
  57. 55.  -       Photoview.hide(opts.hist);
  58. 56.  -       return false;
  59. 57.  -     }
  60. 58.  -     nw = nav.toStr(nw);
  61. 59.  -     if (nw.replace('?rev=1', '/rev') == cur.pvListId && cur.pvShown) {
  62. 60.  -       Photoview.hide(opts.hist);
  63. 61.  -       return false;
  64. 62.  -     }
  65. 63.  -     var m = nw.match(/^photo(-?\d+_\d+)\??((all=1|newtag=\d+)(&rev=1)?|(rev=1&)?tag=\d+|rev=1)?$/);
  66. 64.  -     if (!m) return;
  67. 65.  -
  68. 66.  -     var listId = cur.pvListId;
  69. 67.  -     if (!listId || !cur.pvShown) {
  70. 68.  -       if (nav.objLoc.act == 'added') {
  71. 69.  -         listId = 'newtag' + vk.id + (nav.objLoc.rev ? '/rev' : '');
  72. 70.  -       } else {
  73. 71.  -         listId = nav.strLoc.replace('?rev=1', '/rev');
  74. 72.  -       }
  75. 73.  -     }
  76. 74.  -     var data = cur.pvData[listId];
  77. 75.  -     if (!data) return;
  78. 76.  -
  79. 77.  -     for (var i = 0, l = data.length; i < l; ++i) {
  80. 78.  -       if (data[i] && data[i].id == m[1]) {
  81. 79.  -         Photoview.show(listId, i, false, cur.pvRoot);
  82. 80.  -         return false;
  83. 81.  -       }
  84. 82.  -     }
  85. 83.  -   },
  86. 84.  -   updateLocNav: function() {
  87. 85.  -     if (cur.pvRoot) {
  88. 86.  -       for (var i = 0, l = cur.nav.length; i < l; ++i) {
  89. 87.  -         if (cur.nav[i] == Photoview.locNav) return;
  90. 88.  -       }
  91. 89.  -       cur.nav.push(Photoview.locNav);
  92. 90.  -     } else {
  93. 91.  -       for (var i = 0, l = cur.nav.length; i < l; ++i) {
  94. 92.  -         if (cur.nav[i] == Photoview.locNav) {
  95. 93.  -           cur.nav.splice(i, 1);
  96. 94.  -           --i; --l;
  97. 95.  -         }
  98. 96.  -       }
  99. 97.  -     }
  100. 98.  -   },
  101. 99.  -
  102. 100.  -   checkLayerVisibility: function() {
  103. 101.  -     if (cur.pvShown) return true;
  104. 102.  -
  105. 103.  -     debugLog('layerqueue.hide from photoview');
  106. 104.  -     layerQueue.hide();
  107. 105.  -
  108. 106.  -     addEvent(window, 'resize', Photoview.onResize);
  109. 107.  -     addEvent(document, 'keydown', Photoview.onKeyDown);
  110. 108.  -     addEvent(layerWrap, 'click', Photoview.onClick);
  111. 109.  -     boxQueue.hideAll();
  112. 110.  -     setStyle(layerBG, {opacity: ''});
  113. 111.  -     layers.show();
  114. 112.  -     layers.fullhide = Photoview.hide;
  115. 113.  -   },
  116. 114.  -   createLayer: function() {
  117. 115.  -     var colorClass = vk.pvdark ? 'pv_dark' : 'pv_light';
  118. 116.  -
  119. 117.  -     cur.pvFixed = bodyNode.appendChild(ce('div', {className: 'pv_fixed fixed ' + colorClass, innerHTML: '\
  120. 118.  - <div class="pv_left no_select" onmousedown="Photoview.show(false, cur.pvIndex - 1, event);" onmouseover="Photoview.activate(this)" onmouseout="Photoview.deactivate(this)"><div></div></div>\
  121. 119.  - <div class="pv_close no_select" onmouseover="Photoview.activate(this)" onmouseout="Photoview.deactivate(this)" onmousedown="cur.pvClicked = true; Photoview.onClick(event, true);"><div></div></div>\
  122. 120.  -     '}));
  123. 121.  -
  124. 122.  -     cur.pvLeft = cur.pvFixed.firstChild;
  125. 123.  -     cur.pvClose = cur.pvLeft.nextSibling;
  126. 124.  -
  127. 125.  -     addClass(layerWrap, colorClass);
  128. 126.  -     addClass(layerBG, colorClass);
  129. 127.  -     vkImage().src = '/images/upload.gif';
  130. 128.  -
  131. 129.  -     var hhHide = Photoview.hhCheck() ? '' : ' style="display: none;"',
  132. 130.  -         albumsHtml = cur.pvAlbumsShown ? cur.pvAlbumsData[cur.pvAlbumsShown].html : '',
  133. 131.  -         albumHtml = cur.pvAlbumShown ? cur.pvAlbumData[cur.pvAlbumShown].html : '',
  134. 132.  -         pvVTagsHtml = cur.pvVideoTagsShown ? cur.pvVideoTagsData.html : '',
  135. 133.  -         pwStyle = cur.pvVideoTagsShown || cur.pvAlbumsShown || cur.pvAlbumShown || cur.pvPhotoTagShown ? 'display: none' : '',
  136. 134.  -         awStyle = cur.pvAlbumsShown ? '' : 'display: none',
  137. 135.  -         sawStyle = cur.pvAlbumShown ? '' : 'display: none',
  138. 136.  -         vtStyle = cur.pvVideoTagsShown ? '' : 'display: none';
  139. 137.  -     if (cur.pvPhotoTagShown) {
  140. 138.  -       albumHtml = cur.pvPhotoTagData[cur.pvPhotoTagShown].html;
  141. 139.  -       sawStyle = '';
  142. 140.  -     }
  143. 141.  -
  144. 142.  -     layer.innerHTML = '\
  145. 143.  - <div class="pv_cont">\
  146. 144.  - \
  147. 145.  - <table cellspacing="0" cellpadding="0">\
  148. 146.  - <tr><td class="sidesh s1"><div></div></td><td>\
  149. 147.  - <table cellspacing="0" cellpadding="0">\
  150. 148.  - <tr><td class="sidesh s2"><div></div></td><td>\
  151. 149.  - <table cellspacing="0" cellpadding="0">\
  152. 150.  - <tr><td colspan="3" class="bottomsh s3"><div></div></td></tr>\
  153. 151.  - <tr><td class="sidesh s3"><div></div></td><td>\
  154. 152.  - \
  155. 153.  - <div id="pv_box" onclick="cur.pvClicked = true;">\
  156. 154.  -   <a class="fl_r pv_close_link" onclick="Photoview.hide(0)">' + getLang('global_close') + '</a>\
  157. 155.  -   <div id="pv_summary"><span class="summary"></span></div>\
  158. 156.  -   <div id="pv_photo_wrap" style="' + pwStyle + '">\
  159. 157.  -     <div id="pv_tag_info" class="clear_fix"></div>\
  160. 158.  -     <div class="no_select pv_data">\
  161. 159.  -       <div id="pv_tag_frame"></div>\
  162. 160.  -       <div id="pv_tag_faded"></div>\
  163. 161.  -       <div id="pv_tag_person" onmouseout="Photoview.hideTag()"></div>\
  164. 162.  -       <div id="pv_loader"></div>\
  165. 163.  -       <div class="pvs_hh"' + hhHide + ' id="pv_hh"><div class="pvs_hh_cover"><div class="pvs_hh_bg"></div><div class="pvs_hh_fg" id="pv_hh_fg" onmouseover="Photoview.hhOver(this)" onmouseout="Photoview.hhOut(this)" onmousedown="return Photoview.hhClick(this, event, 1)"></div></div></div>\
  166. 164.  -       <a onmouseout="Photoview.hideTag()" onmousedown="if (!cur.pvTagger && checkEvent(event) === false) return Photoview.show(false, cur.pvIndex + 1, event);" onselectstart="return cancelEvent(event);" onclick="return checkEvent(event)" href="" id="pv_photo"></a>\
  167. 165.  -     </div>\
  168. 166.  -     <div class="clear_fix select_fix" id="pv_comments_data">\
  169. 167.  -       <div class="fl_l wide_column">\
  170. 168.  -         <div id="pv_wide"></div>\
  171. 169.  -         <div id="pv_your_comment" class="clear clear_fix" onclick="return cancelEvent(event);">\
  172. 170.  -           <div id="pv_comment_header">' + getLang('photos_yourcomment') + '</div>\
  173. 171.  -           <textarea id="pv_comment" onkeyup="Photoview.commentChanged()" onkeypress="onCtrlEnter(event, Photoview.sendComment);"></textarea>\
  174. 172.  -           <div id="pv_comment_warn"></div>\
  175. 173.  -           <div id="pv_media_preview" class="clear_fix"></div>\
  176. 174.  -           <div id="pv_comment_submit">\
  177. 175.  -             <div class="button_blue fl_l"><button id="pv_comment_send">' + getLang('box_send') + '</button></div>\
  178. 176.  -             <div id="pv_reply_as_group" class="checkbox fl_l" onclick="checkbox(this)">\
  179. 177.  -               <div></div>' + getLang('wall_reply_as_group') + '\
  180. 178.  -             </div>\
  181. 179.  -             <div id="pv_reply_to_title" class="fl_l"></div>\
  182. 180.  -             <div id="pv_del_reply_to" class="fl_l" onclick="Photoview.commentTo()"></div>\
  183. 181.  -             <div id="pv_add_media" class="fl_r">\
  184. 182.  -               <span class="add_media_lnk">' + getLang('global_add_media') + '</span>\
  185. 183.  -             </div>\
  186. 184.  -           </div>\
  187. 185.  -         </div>\
  188. 186.  -       </div>\
  189. 187.  -       <div class="fl_r narrow_column" id="pv_narrow"></div>\
  190. 188.  -     </div>\
  191. 189.  -   </div>\
  192. 190.  -   <div id="pv_albums_wrap" style="' + awStyle + '">' + albumsHtml + '</div>\
  193. 191.  -   <div id="pv_album_wrap" '+ (cur.pvsaMini ? 'class="pv_album_wrap_mini"' : '') +' style="' + sawStyle + '">' + albumHtml + '</div>\
  194. 192.  -   <div id="pv_vtagged_wrap" style="' + vtStyle + '">' + pvVTagsHtml + '</div>\
  195. 193.  - </div>\
  196. 194.  - \
  197. 195.  - </td><td class="sidesh s3"><div></div></td></tr>\
  198. 196.  - <tr><td colspan="3" class="bottomsh s3"><div></div></td></tr></table>\
  199. 197.  - </td><td class="sidesh s2"><div></div></td></tr>\
  200. 198.  - <tr><td colspan="3" class="bottomsh s2"><div></div></td></tr></table>\
  201. 199.  - </td><td class="sidesh s1"><div></div></td></tr>\
  202. 200.  - <tr><td colspan="3" class="bottomsh s1"><div></div></td></tr></table>\
  203. 201.  - </div>\
  204. 202.  - <div class="no_select" id="pv_left_nav" '+'onmouseover="Photoview.activate(cur.pvLeft)" onmouseout="Photoview.deactivate(cur.pvLeft)" onmousedown="cur.pvClicked = true; Photoview.show(false, cur.pvIndex - 1, event);" onselectstart="return cancelEvent(event);"></div>\
  205. 203.  - <div class="no_select" id="pv_right_nav" '+'onmouseover="Photoview.activate(cur.pvClose)" onmouseout="Photoview.deactivate(cur.pvClose)" onmousedown="cur.pvClicked = true; Photoview.onClick(event, true);"></div>\
  206. 204.  - <div class="pv_switch no_select" id="pv_switch" onmouseover="if (!browser.msie6) Photoview.activate(this)" onmouseout="if (!browser.msie6) Photoview.deactivate(this)" onmousedown="Photoview.switchColor(this); cur.pvClicked = true;"><div class="pv_switch_wrap"><img class="pv_switch_img" width="10" height="22" src="/images/photoswitch'+(window.devicePixelRatio >= 2 ? '_2x' : '')+'.png" /></div></div>\
  207. 205.  -     ';
  208. 206.  -
  209. 207.  -     if (cur.pvYourComment) {
  210. 208.  -       domPN(ge('pv_your_comment')).replaceChild(cur.pvYourComment, ge('pv_your_comment'));
  211. 209.  -     }
  212. 210.  -     extend(cur, {
  213. 211.  -       pvCont: domFC(layer),
  214. 212.  -       pvBox: ge('pv_box'),
  215. 213.  -
  216. 214.  -       pvLeftNav: ge('pv_left_nav'),
  217. 215.  -       pvRightNav: ge('pv_right_nav'),
  218. 216.  -
  219. 217.  -       pvPhotoWrap: ge('pv_photo_wrap'),
  220. 218.  -       pvAlbumWrap: ge('pv_album_wrap'),
  221. 219.  -       pvAlbumsWrap: ge('pv_albums_wrap'),
  222. 220.  -       pvVTagsWrap: ge('pv_vtagged_wrap'),
  223. 221.  -
  224. 222.  -       pvSummary: domFC(ge('pv_summary')),
  225. 223.  -       pvTagInfo: ge('pv_tag_info'),
  226. 224.  -       pvLoader: ge('pv_loader'),
  227. 225.  -       pvTagFrame: ge('pv_tag_frame'),
  228. 226.  -       pvTagFaded: ge('pv_tag_faded'),
  229. 227.  -       pvTagPerson: ge('pv_tag_person'),
  230. 228.  -       pvPhoto: ge('pv_photo'),
  231. 229.  -       pvCommentsData: ge('pv_comments_data'),
  232. 230.  -
  233. 231.  -       pvNarrow: ge('pv_narrow'),
  234. 232.  -       pvWide: ge('pv_wide'),
  235. 233.  -
  236. 234.  -       pvHH: ge('pv_hh'),
  237. 235.  -       pvHHFg: ge('pv_hh_fg'),
  238. 236.  -
  239. 237.  -       pvYourComment: ge('pv_your_comment'),
  240. 238.  -       pvAddMedia: domFC(ge('pv_add_media')),
  241. 239.  -       pvMediaPreview: ge('pv_media_preview'),
  242. 240.  -       pvCommentSend: ge('pv_comment_send'),
  243. 241.  -       pvComment: ge('pv_comment'),
  244. 242.  -       pvAsGroup: ge('pv_reply_as_group'),
  245. 243.  -
  246. 244.  -       pvSwitch: ge('pv_switch')
  247. 245.  -     });
  248. 246.  -     addEvent(cur.pvPhoto, 'mousemove', Photoview.onMouseMove);
  249. 247.  -     if (browser.mobile) {
  250. 248.  -       cur.pvYOffset = intval(window.pageYOffset);
  251. 249.  -
  252. 250.  -       cur.pvCont.style.paddingTop = cur.pvLeftNav.style.top =
  253. 251.  -       cur.pvRightNav.style.top = (cur.pvYOffset + 10) + 'px';
  254. 252.  -
  255. 253.  -       cur.pvSwitch.style.top = cur.pvYOffset + 'px';
  256. 254.  -     }
  257. 255.  -     addEvent(layerWrap, 'scroll', Photoview.scrollResize);
  258. 256.  -
  259. 257.  -     Photoview.updateSize();
  260. 258.  -   },
  261. 259.  -   doShowAlbums: function(ownerId, ev) {
  262. 260.  -     ownerId = intval(ownerId);
  263. 261.  -     if (ev && (ev.button == 2 || ev.which == 3)) return;
  264. 262.  -
  265. 263.  -     clearTimeout(window.__pvhideTimer);
  266. 264.  -     if (__afterFocus) {
  267. 265.  -       return ev ? cancelEvent(ev) : false;
  268. 266.  -     }
  269. 267.  -     if (cur.pvTagger) {
  270. 268.  -       Phototag.stopTag();
  271. 269.  -       if (ev !== false) {
  272. 270.  -         return ev ? cancelEvent(ev) : false;
  273. 271.  -       }
  274. 272.  -     }
  275. 273.  -
  276. 274.  -     var data = (cur.pvAlbumsData || {})[ownerId];
  277. 275.  -     if (!data) return;
  278. 276.  -
  279. 277.  - //    if (window.wkLayerWrap && isVisible(window.wkLayerWrap)) {
  280. 278.  - //      wkcur.scrollTop = window.wkLayerWrap.scrollTop;
  281. 279.  - //      hide(wkLayerWrap);
  282. 280.  - //    }
  283. 281.  -
  284. 282.  -     Photoview.checkLayerVisibility();
  285. 283.  -     cur.pvRoot = false;
  286. 284.  -     Photoview.updateLocNav();
  287. 285.  -
  288. 286.  -     if (ev && ev.pageX && ev.pageY) {
  289. 287.  -       extend(cur, {pvOldX: ev.pageX, pvOldY: ev.pageY, pvOldT: vkNow()});
  290. 288.  -     }
  291. 289.  -
  292. 290.  -     cur.pvShown = true;
  293. 291.  -     cur.pvAlbumsShown = ownerId;
  294. 292.  -     if (!cur.pvFixed || val('pva_owner') != ownerId) {
  295. 293.  -       extend(cur, {
  296. 294.  -         pvaOffset: data.opts.offset,
  297. 295.  -         pvaCount: data.opts.count,
  298. 296.  -         pvaPhotosOffset: data.opts.photos_offset,
  299. 297.  -         pvaPhotosCount: data.opts.photos_count,
  300. 298.  -         pvShowAllAlbums: false
  301. 299.  -       });
  302. 300.  -     }
  303. 301.  -     if (!cur.pvFixed) {
  304. 302.  -       Photoview.createLayer();
  305. 303.  -     } else {
  306. 304.  -       if (val('pva_owner') != ownerId) {
  307. 305.  -         val(cur.pvAlbumsWrap, data.html);
  308. 306.  -       }
  309. 307.  -       if (!isVisible(cur.pvAlbumsWrap)) {
  310. 308.  -         hide(cur.pvPhotoWrap, cur.pvAlbumWrap, cur.pvVTagsWrap);
  311. 309.  -         show(cur.pvAlbumsWrap);
  312. 310.  -         Photoview.updateSize();
  313. 311.  -         layerWrap.scrollTop = val('pva_scroll');
  314. 312.  -       }
  315. 313.  -     }
  316. 314.  -
  317. 315.  -     cur.pvSummary.innerHTML = data.opts.summary;
  318. 316.  -
  319. 317.  -     if (cur.pvListId && cur.pvListId != 'temp') {
  320. 318.  -       extend(cur, {
  321. 319.  -         pvOldListId: cur.pvListId,
  322. 320.  -         pvOldIndex: cur.pvIndex
  323. 321.  -       });
  324. 322.  -       var old = (cur.pvListId || '').split('/');
  325. 323.  -       if (old[0]) {
  326. 324.  -         Photoview.showRepeat(ge(old[0]));
  327. 325.  -       }
  328. 326.  -
  329. 327.  -       show(cur.pvLeft, cur.pvLeftNav, cur.pvRightNav, cur.pvClose);
  330. 328.  -     } else {
  331. 329.  -       hide(cur.pvLeft, cur.pvLeftNav, cur.pvRightNav, cur.pvClose);
  332. 330.  -       if (!browser.msie || browser.version > 8) cur.pvClicked = false;
  333. 331.  -     }
  334. 332.  -     cur.pvListId = false;
  335. 333.  -
  336. 334.  -     var nl = extend(nav.objLoc, {z: 'albums' + cur.pvAlbumsShown});
  337. 335.  -     if (nav.strLoc != nav.toStr(nl)) {
  338. 336.  -       if (!cur.pvNoHistory) {
  339. 337.  -         ++cur.pvHistoryLength;
  340. 338.  -       }
  341. 339.  -       nav.setLoc(nl);
  342. 340.  -     }
  343. 341.  -
  344. 342.  -     return ev ? cancelEvent(ev) : false;
  345. 343.  -   },
  346. 344.  -   jumpToAlbums: function(returning) {
  347. 345.  -     if (cur.pvListId == 'temp') {
  348. 346.  -       cur.pvCancelLoad();
  349. 347.  -       if (cur.pvJumpTo.z == 'albums' + val('pva_owner') && cur.pvJumpTo.z == nav.objLoc.z) {
  350. 348.  -         showAlbums(val('pva_owner'), {noHistory: true});
  351. 349.  -         return;
  352. 350.  -       }
  353. 351.  -     }
  354. 352.  -     if (returning) {
  355. 353.  -       cur.pvListId = false;
  356. 354.  -     }
  357. 355.  -     extend(cur, {
  358. 356.  -       pvJumpFrom: false,
  359. 357.  -       pvJumpSteps: 0
  360. 358.  -     });
  361. 359.  -     nav.change(cur.pvJumpTo);
  362. 360.  -   },
  363. 361.  -   jumpToAlbum: function(returning) {
  364. 362.  -     if (cur.pvListId == 'temp') {
  365. 363.  -       cur.pvCancelLoad();
  366. 364.  -       if (cur.pvJumpTo.z == 'album' + val('pvsa_album') && cur.pvJumpTo.z == nav.objLoc.z) {
  367. 365.  -         showAlbum(val('pvsa_album'), {noHistory: true});
  368. 366.  -         return;
  369. 367.  -       }
  370. 368.  -     }
  371. 369.  -     if (returning) {
  372. 370.  -       cur.pvListId = false;
  373. 371.  -     }
  374. 372.  -     extend(cur, {
  375. 373.  -       pvJumpFrom: false,
  376. 374.  -       pvJumpSteps: 0
  377. 375.  -     });
  378. 376.  -     nav.change(cur.pvJumpTo);
  379. 377.  -   },
  380. 378.  -   jumpToTagged: function(returning) {
  381. 379.  -     if (cur.pvListId == 'temp') {
  382. 380.  -       cur.pvCancelLoad();
  383. 381.  -       if (cur.pvJumpTo.z == 'tag' + val('pvsa_tag') && cur.pvJumpTo.z == nav.objLoc.z) {
  384. 382.  -         showTagged(val('pvsa_tag'), {noHistory: true});
  385. 383.  -         return;
  386. 384.  -       }
  387. 385.  -     }
  388. 386.  -     if (cur.pvJumpTo.z == 'tag' + val('pvsa_tag')) {
  389. 387.  -       cur.pvJumpTo.z = 'photo_' + cur.pvJumpTo.z;
  390. 388.  -     }
  391. 389.  -     if (returning) {
  392. 390.  -       cur.pvListId = false;
  393. 391.  -     }
  394. 392.  -     extend(cur, {
  395. 393.  -       pvJumpFrom: false,
  396. 394.  -       pvJumpSteps: 0
  397. 395.  -     });
  398. 396.  -     nav.change(cur.pvJumpTo);
  399. 397.  -   },
  400. 398.  -   doShowAlbum: function(albumRaw, ev) {
  401. 399.  -     if (ev && (ev.button == 2 || ev.which == 3)) return;
  402. 400.  -
  403. 401.  -     clearTimeout(window.__pvhideTimer);
  404. 402.  -     if (__afterFocus) {
  405. 403.  -       return ev ? cancelEvent(ev) : false;
  406. 404.  -     }
  407. 405.  -     if (cur.pvTagger) {
  408. 406.  -       Phototag.stopTag();
  409. 407.  -       if (ev !== false) {
  410. 408.  -         return ev ? cancelEvent(ev) : false;
  411. 409.  -       }
  412. 410.  -     }
  413. 411.  -
  414. 412.  -     var data = (cur.pvAlbumData || {})[albumRaw];
  415. 413.  -     if (!data) return;
  416. 414.  -
  417. 415.  - //    if (window.wkLayerWrap && isVisible(window.wkLayerWrap)) {
  418. 416.  - //      wkcur.scrollTop = window.wkLayerWrap.scrollTop;
  419. 417.  - //      hide(wkLayerWrap);
  420. 418.  - //    }
  421. 419.  -
  422. 420.  -     Photoview.checkLayerVisibility();
  423. 421.  -     cur.pvRoot = false;
  424. 422.  -     Photoview.updateLocNav();
  425. 423.  -
  426. 424.  -     if (ev && ev.pageX && ev.pageY) {
  427. 425.  -       extend(cur, {pvOldX: ev.pageX, pvOldY: ev.pageY, pvOldT: vkNow()});
  428. 426.  -     }
  429. 427.  -
  430. 428.  -     cur.pvShown = true;
  431. 429.  -     cur.pvAlbumShown = albumRaw;
  432. 430.  -     if (!cur.pvFixed || val('pvsa_album') != albumRaw) {
  433. 431.  -       extend(cur, {
  434. 432.  -         pvsaOffset: data.opts.offset,
  435. 433.  -         pvsaCount: data.opts.count,
  436. 434.  -         pvsaMini: data.opts.count <= 40
  437. 435.  -       });
  438. 436.  -     }
  439. 437.  -     if (!cur.pvFixed) {
  440. 438.  -       Photoview.createLayer();
  441. 439.  -     } else {
  442. 440.  -       toggleClass(cur.pvAlbumWrap, 'pv_album_wrap_mini', cur.pvsaMini);
  443. 441.  -       if (val('pvsa_album') != albumRaw) {
  444. 442.  -         val(cur.pvAlbumWrap, data.html);
  445. 443.  -       }
  446. 444.  -       if (!isVisible(cur.pvAlbumWrap)) {
  447. 445.  -         hide(cur.pvPhotoWrap, cur.pvAlbumsWrap, cur.pvVTagsWrap);
  448. 446.  -         show(cur.pvAlbumWrap);
  449. 447.  -         Photoview.updateSize();
  450. 448.  -         layerWrap.scrollTop = val('pvsa_scroll');
  451. 449.  -       }
  452. 450.  -     }
  453. 451.  -
  454. 452.  -     val(cur.pvSummary, data.opts.summary);
  455. 453.  -
  456. 454.  -     if (cur.pvListId && cur.pvListId != 'temp') {
  457. 455.  -       extend(cur, {
  458. 456.  -         pvOldListId: cur.pvListId,
  459. 457.  -         pvOldIndex: cur.pvIndex
  460. 458.  -       });
  461. 459.  -       var old = (cur.pvListId || '').split('/');
  462. 460.  -       if (old[0]) {
  463. 461.  -         Photoview.showRepeat(ge(old[0]));
  464. 462.  -       }
  465. 463.  -
  466. 464.  -       show(cur.pvLeft, cur.pvLeftNav, cur.pvRightNav, cur.pvClose);
  467. 465.  -     } else {
  468. 466.  -       hide(cur.pvLeft, cur.pvLeftNav, cur.pvRightNav, cur.pvClose);
  469. 467.  -       if (!browser.msie || browser.version > 8) cur.pvClicked = false;
  470. 468.  -     }
  471. 469.  -     cur.pvListId = false;
  472. 470.  -
  473. 471.  -     var nl = extend(nav.objLoc, {z: 'album' + cur.pvAlbumShown});
  474. 472.  -     if (nav.strLoc != nav.toStr(nl)) {
  475. 473.  -       if (!cur.pvNoHistory) {
  476. 474.  -         ++cur.pvHistoryLength;
  477. 475.  -       }
  478. 476.  -       nav.setLoc(nl);
  479. 477.  -     }
  480. 478.  -
  481. 479.  -     return ev ? cancelEvent(ev) : false;
  482. 480.  -   },
  483. 481.  -   doShowTagged: function(ownerId, ev) {
  484. 482.  -     ownerId = intval(ownerId);
  485. 483.  -     if (ev && (ev.button == 2 || ev.which == 3)) return;
  486. 484.  -
  487. 485.  -     clearTimeout(window.__pvhideTimer);
  488. 486.  -     if (__afterFocus) {
  489. 487.  -       return ev ? cancelEvent(ev) : false;
  490. 488.  -     }
  491. 489.  -     if (cur.pvTagger) {
  492. 490.  -       Phototag.stopTag();
  493. 491.  -       if (ev !== false) {
  494. 492.  -         return ev ? cancelEvent(ev) : false;
  495. 493.  -       }
  496. 494.  -     }
  497. 495.  -
  498. 496.  -     var data = (cur.pvPhotoTagData || {})[ownerId];
  499. 497.  -     if (!data) return;
  500. 498.  -
  501. 499.  - //    if (window.wkLayerWrap && isVisible(window.wkLayerWrap)) {
  502. 500.  - //      wkcur.scrollTop = window.wkLayerWrap.scrollTop;
  503. 501.  - //      hide(wkLayerWrap);
  504. 502.  - //    }
  505. 503.  -
  506. 504.  -     Photoview.checkLayerVisibility();
  507. 505.  -     cur.pvRoot = false;
  508. 506.  -     Photoview.updateLocNav();
  509. 507.  -
  510. 508.  -     if (ev && ev.pageX && ev.pageY) {
  511. 509.  -       extend(cur, {pvOldX: ev.pageX, pvOldY: ev.pageY, pvOldT: vkNow()});
  512. 510.  -     }
  513. 511.  -
  514. 512.  -     cur.pvShown = true;
  515. 513.  -     cur.pvPhotoTagShown = ownerId;
  516. 514.  -     if (!cur.pvFixed || val('pvsa_tag') != ownerId) {
  517. 515.  -       extend(cur, {
  518. 516.  -         pvsaOffset: data.opts.offset,
  519. 517.  -         pvsaCount: data.opts.count,
  520. 518.  -         pvsaMini: data.opts.count <= 40
  521. 519.  -       });
  522. 520.  -     }
  523. 521.  -     if (!cur.pvFixed) {
  524. 522.  -       Photoview.createLayer();
  525. 523.  -     } else {
  526. 524.  -       toggleClass(cur.pvAlbumWrap, 'pv_album_wrap_mini', cur.pvsaMini);
  527. 525.  -       if (val('pvsa_tag') != ownerId) {
  528. 526.  -         val(cur.pvAlbumWrap, data.html);
  529. 527.  -       }
  530. 528.  -       if (!isVisible(cur.pvAlbumWrap)) {
  531. 529.  -         hide(cur.pvPhotoWrap, cur.pvAlbumsWrap, cur.pvVTagsWrap);
  532. 530.  -         show(cur.pvAlbumWrap);
  533. 531.  -         Photoview.updateSize();
  534. 532.  -         layerWrap.scrollTop = val('pvsa_scroll');
  535. 533.  -       }
  536. 534.  -     }
  537. 535.  -
  538. 536.  -     val(cur.pvSummary, data.opts.summary);
  539. 537.  -
  540. 538.  -     if (cur.pvListId && cur.pvListId != 'temp') {
  541. 539.  -       extend(cur, {
  542. 540.  -         pvOldListId: cur.pvListId,
  543. 541.  -         pvOldIndex: cur.pvIndex
  544. 542.  -       });
  545. 543.  -       var old = (cur.pvListId || '').split('/');
  546. 544.  -       if (old[0]) {
  547. 545.  -         Photoview.showRepeat(ge(old[0]));
  548. 546.  -       }
  549. 547.  -
  550. 548.  -       show(cur.pvLeft, cur.pvLeftNav, cur.pvRightNav, cur.pvClose);
  551. 549.  -     } else {
  552. 550.  -       hide(cur.pvLeft, cur.pvLeftNav, cur.pvRightNav, cur.pvClose);
  553. 551.  -       if (!browser.msie || browser.version > 8) cur.pvClicked = false;
  554. 552.  -     }
  555. 553.  -     cur.pvListId = false;
  556. 554.  -
  557. 555.  -     var nl = extend(nav.objLoc, {z: 'photo_tag' + cur.pvPhotoTagShown});
  558. 556.  -     if (nav.strLoc != nav.toStr(nl)) {
  559. 557.  -       if (!cur.pvNoHistory) {
  560. 558.  -         ++cur.pvHistoryLength;
  561. 559.  -       }
  562. 560.  -       nav.setLoc(nl);
  563. 561.  -     }
  564. 562.  -
  565. 563.  -     return ev ? cancelEvent(ev) : false;
  566. 564.  -   },
  567. 565.  -   doShowVideoTags: function(ownerId, ev) {
  568. 566.  -     if (ev && (ev.button == 2 || ev.which == 3)) return;
  569. 567.  -
  570. 568.  -     clearTimeout(window.__pvhideTimer);
  571. 569.  -     if (__afterFocus) {
  572. 570.  -       return ev ? cancelEvent(ev) : false;
  573. 571.  -     }
  574. 572.  -     if (cur.pvTagger) {
  575. 573.  -       Phototag.stopTag();
  576. 574.  -       if (ev !== false) {
  577. 575.  -         return ev ? cancelEvent(ev) : false;
  578. 576.  -       }
  579. 577.  -     }
  580. 578.  -
  581. 579.  -     var data = cur.pvVideoTagsData;
  582. 580.  -     if (!data) return;
  583. 581.  -
  584. 582.  - //    if (window.wkLayerWrap && isVisible(window.wkLayerWrap)) {
  585. 583.  - //      wkcur.scrollTop = window.wkLayerWrap.scrollTop;
  586. 584.  - //      hide(wkLayerWrap);
  587. 585.  - //    }
  588. 586.  -
  589. 587.  -     Photoview.checkLayerVisibility();
  590. 588.  -     cur.pvRoot = false;
  591. 589.  -     Photoview.updateLocNav();
  592. 590.  -
  593. 591.  -     if (ev && ev.pageX && ev.pageY) {
  594. 592.  -       extend(cur, {pvOldX: ev.pageX, pvOldY: ev.pageY, pvOldT: vkNow()});
  595. 593.  -     }
  596. 594.  -
  597. 595.  -     cur.pvShown = true;
  598. 596.  -     cur.pvVideoTagsShown = ownerId;
  599. 597.  -     if (!cur.pvFixed || val('pvsa_vtag') != ownerId) {
  600. 598.  -       extend(cur, {
  601. 599.  -         pvsaOffset: data.opts.offset,
  602. 600.  -         pvsaCount: data.opts.count
  603. 601.  -       });
  604. 602.  -     }
  605. 603.  -     if (data.opts.lang) {
  606. 604.  -       cur.lang = extend(cur.lang || {}, data.opts.lang);
  607. 605.  -     }
  608. 606.  -     if (!cur.pvFixed) {
  609. 607.  -       Photoview.createLayer();
  610. 608.  -     } else {
  611. 609.  -       if (val('pvsa_vtag') != ownerId) {
  612. 610.  -         val(cur.pvVTagsWrap, data.html);
  613. 611.  -       }
  614. 612.  -       if (!isVisible(cur.pvVTagsWrap)) {
  615. 613.  -         hide(cur.pvPhotoWrap, cur.pvAlbumsWrap, cur.pvAlbumWrap);
  616. 614.  -         show(cur.pvVTagsWrap);
  617. 615.  -         Photoview.updateSize();
  618. 616.  -         layerWrap.scrollTop = val('pvsa_scroll');
  619. 617.  -       }
  620. 618.  -     }
  621. 619.  -
  622. 620.  -     val(cur.pvSummary, data.opts.summary);
  623. 621.  -
  624. 622.  -     hide(cur.pvLeft, cur.pvLeftNav, cur.pvRightNav, cur.pvClose);
  625. 623.  -     cur.pvListId = false;
  626. 624.  -     domPN(cur.pvSummary).style.width = '606px';
  627. 625.  -
  628. 626.  -     var nl = extend(nav.objLoc, {z: 'video_tag' + cur.pvVideoTagsShown});
  629. 627.  -     if (nav.strLoc != nav.toStr(nl)) {
  630. 628.  -       if (!cur.pvNoHistory) {
  631. 629.  -         ++cur.pvHistoryLength;
  632. 630.  -       }
  633. 631.  -       nav.setLoc(nl);
  634. 632.  -     }
  635. 633.  -
  636. 634.  -     return ev ? cancelEvent(ev) : false;
  637. 635.  -   },
  638. 636.  -   show: function(listId, index, ev, root) {
  639. 637.  -     if (ev && (ev.button == 2 || ev.which == 3)) return;
  640. 638.  -
  641. 639.  -     clearTimeout(window.__pvhideTimer);
  642. 640.  -
  643. 641.  -     if (listId == 'temp' && cur.pvShown) {
  644. 642.  -       if (cur.pvListId && cur.pvListId != 'temp') return;
  645. 643.  -       cur.pvWasShown = true;
  646. 644.  -     } else {
  647. 645.  -       cur.pvWasShown = false;
  648. 646.  -     }
  649. 647.  -     if (__afterFocus) {
  650. 648.  -       return ev ? cancelEvent(ev) : false;
  651. 649.  -     }
  652. 650.  -     if (cur.pvTagger) {
  653. 651.  -       Phototag.stopTag();
  654. 652.  -       if (ev !== false) {
  655. 653.  -         return ev ? cancelEvent(ev) : false;
  656. 654.  -       }
  657. 655.  -     }
  658. 656.  -     if (listId === false) {
  659. 657.  -       if (cur.pvAlbumsShown || cur.pvAlbumShown || cur.pvPhotoTagShown) {
  660. 658.  -         if (cur.pvOldListId) {
  661. 659.  -           extend(cur, {
  662. 660.  -             pvJumpTo: cur.pvOldJumpTo,
  663. 661.  -             pvJumpFrom: cur.pvOldJumpFrom,
  664. 662.  -             pvJumpSteps: cur.pvOldJumpSteps
  665. 663.  -           });
  666. 664.  -           if (index == cur.pvOldIndex + 1) ++cur.pvOldIndex;
  667. 665.  -           return Photoview.show(cur.pvOldListId, cur.pvOldIndex, ev, root);
  668. 666.  -         } else {
  669. 667.  -           hide(cur.pvLeft, cur.pvLeftNav, cur.pvRightNav, cur.pvClose);
  670. 668.  -         }
  671. 669.  -       }
  672. 670.  -       listId = cur.pvListId;
  673. 671.  -     }
  674. 672.  -     var count = ((cur.pvData || {})[listId] || {}).length, otherList = (listId != cur.pvListId);
  675. 673.  -     if (!count) return;
  676. 674.  -
  677. 675.  -     if (ev && ev.pageX && ev.pageY) {
  678. 676.  -       extend(cur, {pvOldX: ev.pageX, pvOldY: ev.pageY, pvOldT: vkNow()});
  679. 677.  -     }
  680. 678.  -
  681. 679.  -     if ((cur.pvOptions || {}).queue) {
  682. 680.  -       debugLog('pushing in photoview.show');
  683. 681.  -       layerQueue.push();
  684. 682.  -       cur.pvOptions.queue = false;
  685. 683.  -       cur.pvHistoryLength = 0;
  686. 684.  -     }
  687. 685.  -
  688. 686.  - //    if (window.wkLayerWrap && isVisible(window.wkLayerWrap)) {
  689. 687.  - //      wkcur.scrollTop = window.wkLayerWrap.scrollTop;
  690. 688.  - //      hide(wkLayerWrap);
  691. 689.  - //    }
  692. 690.  -
  693. 691.  -     if (!Photoview.checkLayerVisibility()) {
  694. 692.  -       otherList = true;
  695. 693.  -     }
  696. 694.  -
  697. 695.  -     var newIndex = index + (index < 0 ? count : (index >= count ? (-count) : 0));
  698. 696.  -     var direction = otherList ? 1 : (cur.pvIndex > index ? -1 : 1);
  699. 697.  -
  700. 698.  -     if (!otherList && !cur.pvCanvas) {
  701. 699.  -       if (cur.pvJumpTo) {
  702. 700.  -         cur.pvJumpSteps += (index - cur.pvIndex);
  703. 701.  -         var needJump = (newIndex === cur.pvJumpFrom && cur.pvJumpSteps >= count);
  704. 702.  -         if (needJump) {
  705. 703.  -           extend(cur, {
  706. 704.  -             pvOldJumpFrom: cur.pvJumpFrom,
  707. 705.  -             pvOldJumpSteps: cur.pvJumpSteps - (index - cur.pvIndex),
  708. 706.  -             pvOldJumpTo: cur.pvJumpTo
  709. 707.  -           });
  710. 708.  -           return Photoview.jumpToAlbums(cur.pvJumpSteps < 0);
  711. 709.  -         }
  712. 710.  -         if (direction > 0) {
  713. 711.  -           if (newIndex < cur.pvJumpFrom && newIndex + 4 > cur.pvJumpFrom || newIndex < cur.pvJumpFrom + count && newIndex + 4 > cur.pvJumpFrom + count) {
  714. 712.  -             vkImage().src = stManager._srcPrefix('.css')+'/images/icons/post_hh'+(window.devicePixelRatio >= 2 ? '_2x' : '')+'.png?2';
  715. 713.  -             var m = cur.pvJumpTo.z.match(/^albums(-?\d+)$/);
  716. 714.  -             if (m) {
  717. 715.  -               if (!cur.pvAlbumsData) cur.pvAlbumsData = {};
  718. 716.  -               if (!cur.pvAlbumsData[m[1]]) {
  719. 717.  -                 cur.pvAlbumsData[m[1]] = 'loading';
  720. 718.  -                 ajax.post('al_photos.php', {act: 'show_albums', owner: m[1], other: 1}, {onDone: Photoview.loadedAlbums});
  721. 719.  -               }
  722. 720.  -             }
  723. 721.  -           }
  724. 722.  -         }
  725. 723.  -         if (cur.pvJumpSteps <= -count) {
  726. 724.  -           cur.pvJumpSteps += count;
  727. 725.  -         }
  728. 726.  -       }
  729. 727.  -       if (count == 1 && index != cur.pvIndex && listId != 'temp') {
  730. 728.  -         Photoview.hide();
  731. 729.  -         return ev ? cancelEvent(ev) : false;
  732. 730.  -       }
  733. 731.  -     }
  734. 732.  -
  735. 733.  -     if (otherList && listId != 'temp') {
  736. 734.  -       if (cur.pvJumpFrom === false) {
  737. 735.  -         cur.pvJumpFrom = newIndex;
  738. 736.  -       }
  739. 737.  -       cur.pvRoot = root;
  740. 738.  -       Photoview.updateLocNav();
  741. 739.  -     }
  742. 740.  -
  743. 741.  -     index = newIndex;
  744. 742.  -
  745. 743.  -     var ph = cur.pvData[listId][index];
  746. 744.  -
  747. 745.  -     if (!ph || !ph.x_ && !ph.x_src) return;
  748. 746.  -
  749. 747.  -     cur.pvIndex = index;
  750. 748.  -     cur.pvShown = true;
  751. 749.  -     cur.pvAlbumsShowing = cur.pvAlbumsShown = false;
  752. 750.  -     cur.pvAlbumShowing = cur.pvAlbumShown = false;
  753. 751.  -     cur.pvPhotoTagShowing = cur.pvPhotoTagShown = false;
  754. 752.  -     cur.pvVideoTagShowing = cur.pvVideoTagsShown = false;
  755. 753.  -     cur.pvListId = listId;
  756. 754.  -     if (!cur.pvFixed) {
  757. 755.  -       Photoview.createLayer();
  758. 756.  -     }
  759. 757.  -     cur.pvCurData = Photoview.genData(ph, vk.pvbig ? (cur.pvVeryBig ? (cur.pvVeryBig > 1 ? 'z' : 'z') : 'y') : 'x');
  760. 758.  -     if (cur.pvCurrent) {
  761. 759.  -       cur.pvCurrent.onload = Photoview.blankf;
  762. 760.  -       cur.pvCurrent.src = Photoview.blank;
  763. 761.  -     }
  764. 762.  -     delete cur.pvCurrent;
  765. 763.  -     cur.pvCurrent = vkImage();
  766. 764.  -     cur.pvCurrent.onload = Photoview.preload.pbind(index, direction);
  767. 765.  -     cur.pvCurrent.src = cur.pvCurData.src;
  768. 766.  -
  769. 767.  -     if (otherList) {
  770. 768.  -       var needControls = (count > 1) || ((cur.pvJumpTo || {}).z == 'albums' + val('pva_owner')) || ((cur.pvJumpTo || {}).z == 'album' + val('pvsa_album'));
  771. 769.  -       (needControls ? show : hide)(cur.pvLeft, cur.pvLeftNav, cur.pvRightNav, cur.pvClose);
  772. 770.  -     }
  773. 771.  -     cur.pvSummary.innerHTML = (listId == 'temp') ? '<img src="/images/upload.gif" />' : ((count > 1) ? getLang('photos_photo_num_of_N').replace('%s', cur.pvIndex + 1).replace('%s', count) : getLang('photos_view_one_photo'));
  774. 772.  -
  775. 773.  -     cur.pvCurPhoto = ph;
  776. 774.  -     if (!cur.pvCurData.width || !cur.pvCurData.height) {
  777. 775.  -       cur.pvCurData = cur.pvCurrent;
  778. 776.  -       cur.pvTimerPassed = 0;
  779. 777.  -       clearTimeout(cur.pvTimer);
  780. 778.  -       cur.pvTimer = setTimeout(Photoview.doShow, 0);
  781. 779.  -     } else {
  782. 780.  -       Photoview.doShow();
  783. 781.  -     }
  784. 782.  -
  785. 783.  -     return ev ? cancelEvent(ev) : false;
  786. 784.  -   },
  787. 785.  -   doShow: function() {
  788. 786.  -     var img = cur.pvCurData;
  789. 787.  -     if ((!img.width || !img.height) && cur.pvTimerPassed < 5000) {
  790. 788.  -       clearTimeout(cur.pvTimer);
  791. 789.  -       cur.pvTimerPassed += 100;
  792. 790.  -       cur.pvTimer = setTimeout(Photoview.doShow, 100);
  793. 791.  -       return;
  794. 792.  -     }
  795. 793.  -     if (!cur.pvShown) return;
  796. 794.  -
  797. 795.  -     if (cur.pvCanvas) {
  798. 796.  -       cur.pvScrWidth = cur.pvCanvas.offsetWidth;
  799. 797.  -       cur.pvScrHeight = cur.pvCanvas.offsetHeight;
  800. 798.  -
  801. 799.  -       var c = 1, t = 0, l = 0, w = img.width || 604, h = img.height || 453, i = vkImage();
  802. 800.  - //      if (w > cur.pvScrWidth) {
  803. 801.  -         c = cur.pvScrWidth / w;
  804. 802.  - //      }
  805. 803.  -       if (h * c > cur.pvScrHeight) {
  806. 804.  -         c = cur.pvScrHeight / h;
  807. 805.  -       }
  808. 806.  -       if (c > 1.25) c = 1.25;
  809. 807.  -       cur.pvFSWidth = w = Math.floor(w * c);
  810. 808.  -       cur.pvFSHeight = h = Math.floor(h * c);
  811. 809.  -       cur.pvFSTop = t = Math.floor((cur.pvScrHeight - h) / 2);
  812. 810.  -
  813. 811.  -       val(domFC(cur.pvCanvas), '<img style="margin-top: ' + t + 'px; width: ' + w + 'px; height: ' + h + 'px;" src="' + img.src + '" />');
  814. 812.  -       i.onload = Photoview.fullscreenOnLoad;
  815. 813.  -       i.src = img.src;
  816. 814.  -
  817. 815.  -       if (window.FullscreenPV) FullscreenPV.updateInfo();
  818. 816.  -       return;
  819. 817.  -     }
  820. 818.  -
  821. 819.  -     if (isVisible(cur.pvAlbumsWrap)) {
  822. 820.  -       val('pva_scroll', layerWrap.scrollTop);
  823. 821.  -       hide(cur.pvAlbumsWrap);
  824. 822.  -       show(cur.pvPhotoWrap);
  825. 823.  -       Photoview.updateSize();
  826. 824.  -     }
  827. 825.  -     if (isVisible(cur.pvAlbumWrap)) {
  828. 826.  -       val('pvsa_scroll', layerWrap.scrollTop);
  829. 827.  -       hide(cur.pvAlbumWrap);
  830. 828.  -       show(cur.pvPhotoWrap);
  831. 829.  -       Photoview.updateSize();
  832. 830.  -     }
  833. 831.  -
  834. 832.  -     var lnk = cur.pvPhoto, c = 1, marginTop = 0, w = img.width || 604, h = img.height || 453;
  835. 833.  -     if (vk.pvbig) {
  836. 834.  -       if (w > cur.pvWidth) {
  837. 835.  -         c = cur.pvWidth / w;
  838. 836.  -       }
  839. 837.  -       if (h * c > cur.pvHeight) {
  840. 838.  -         c = cur.pvHeight / h;
  841. 839.  -       }
  842. 840.  -     }
  843. 841.  -     marginTop = positive(Math.floor((403 - h * c) / 2));
  844. 842.  -     cur.pvPhWidth = Math.floor(w * c);
  845. 843.  -     cur.pvPhHeight = Math.floor(h * c);
  846. 844.  -     cur.pvActualWidth = Math.max(cur.pvPhWidth, 604);
  847. 845.  -     if (h * c >= 453) {
  848. 846.  -       lnk.style.height = Math.floor(h * c) + 'px';
  849. 847.  -     } else {
  850. 848.  -       lnk.style.height = Math.max(400, cur.pvPhHeight)+'px';
  851. 849.  -     }
  852. 850.  -
  853. 851.  -     if (vk.pvbig) {
  854. 852.  -       cur.pvCont.style.width = (cur.pvActualWidth + 154) + 'px';
  855. 853.  -       domPN(cur.pvSummary).style.width = (cur.pvActualWidth - 4) + 'px';
  856. 854.  -     }
  857. 855.  -
  858. 856.  -     if (cur.pvTagger) Phototag.stopTag();
  859. 857.  -     Photoview.hideTag(true);
  860. 858.  -
  861. 859.  -     if (cur.pvLoader) {
  862. 860.  -       hide(cur.pvLoader);
  863. 861.  -       delete(cur.pvLoader);
  864. 862.  -     }
  865. 863.  -
  866. 864.  -     imgOpts = '';
  867. 865.  -
  868. 866.  -     var ph = cur.pvCurPhoto, notAvail = (ph.commshown >= 0) ? false : (-ph.commshown);
  869. 867.  -
  870. 868.  -     if (!cur.pvHHMove && Photoview.hhCheck() && !notAvail) {
  871. 869.  -       addEvent(layer, 'mousemove', Photoview.photoAct);
  872. 870.  -       cur.pvHHMove = true;
  873. 871.  -     }
  874. 872.  -
  875. 873.  -     cur.pvHH.style[vk.rtl ? 'marginRight' : 'marginLeft'] = Math.ceil((cur.pvActualWidth + 50 - 72) / 2) + 'px';
  876. 874.  -
  877. 875.  -     lnk.innerHTML = '<img '+imgOpts+' style="width: ' + cur.pvPhWidth + 'px; height: ' + cur.pvPhHeight + 'px; margin-top: ' + marginTop + 'px;" src="' + img.src + '" />';
  878. 876.  -
  879. 877.  -     layerWrap.scrollTop = 0;
  880. 878.  -     if (cur.pvListId == 'temp') {
  881. 879.  -       hide(cur.pvCommentsData);
  882. 880.  -       Photoview.updateArrows();
  883. 881.  -       return;
  884. 882.  -     }
  885. 883.  -
  886. 884.  -     (ph.liked ? addClass : removeClass)(cur.pvHH, 'pvs_hh_liked');
  887. 885.  -     Photoview.hhOut(cur.pvHHFg);
  888. 886.  -
  889. 887.  -     if (window.tooltips) {
  890. 888.  -       tooltips.destroyAll(cur.pvBox);
  891. 889.  -     }
  892. 890.  -
  893. 891.  -     var taglnkst = (!ph.taginfo && ph.actions.tag && ph.tags[0] < cur.pvMaxTags) ? '' : ' style="display: none"';
  894. 892.  -     var shareacts = [], fs = false;
  895. 893.  -     if (vk.id) shareacts.push(['pvs_send', getLang('photos_send_to_fr'), 'onclick="Photoview.sendPhoto()"']);
  896. 894.  -     if (ph.actions.save) shareacts.push(['pvs_save', getLang('photos_save_to_alb'), 'onclick="Photoview.savePhoto()"']);
  897. 895.  -     shareacts.push(['pvs_down', getLang('photos_download_hq'), 'target="_blank" href="' + Photoview.genData(ph, 'w').src + /* '?dl=1' + */'"']);
  898. 896.  -
  899. 897.  -     var share = '', l = shareacts.length, sprg = '<div id="pv_share_prg" class="progress fl_r"></div>';
  900. 898.  -     if (l < 1) {
  901. 899.  -       share = '';
  902. 900.  -     } else if (l == 1) {
  903. 901.  -       share = '<a ' + shareacts[0][2] + '>' + sprg + shareacts[0][1] + '</a>';
  904. 902.  -     } else {
  905. 903.  -       for (var i = 0; i < l; ++i) {
  906. 904.  -         share += '<a class="pvs_act" ' + shareacts[i][2] + '><span class="fl_l ' + shareacts[i][0] + '"></span><span class="pvs_act_text">' + shareacts[i][1] + '</span></a>';
  907. 905.  -       }
  908. 906.  -       share = '<a id="pv_share" onclick="Photoview.showShare()">' + sprg + '<span id="pv_share_text">' + getLang('photos_share_from_view') + '</span></a>\
  909. 907.  - <div onmouseover="Photoview.showShare()" onmouseout="Photoview.hideShare(500)" onclick="Photoview.hideShare(-1)" id="pvs_dd" class="fixed"><table cellspacing="0" cellpadding="0"><tr>\
  910. 908.  -   <td class="pvs_side_sh"><div class="pvs_side_sh_el"></div></td>\
  911. 909.  -   <td>\
  912. 910.  -     <div class="pvs_header_wrap"><div class="pvs_header"><span class="pvs_header_text">' + getLang('photos_share_from_view') + '</span></div></div>\
  913. 911.  -     <div class="pvs_acts">' + share + '</div>\
  914. 912.  -     <div class="pvs_sh1"></div><div class="pvs_sh2"></div>\
  915. 913.  -   </td>\
  916. 914.  -   <td class="pvs_side_sh"><div class="pvs_side_sh_el"></div></td>\
  917. 915.  - </tr></table></div>';
  918. 916.  -     }
  919. 917.  -
  920. 918.  - if (ph.actions.edit/* & 2*/) {
  921. 919.  -   photoEditAct = '<a id="pv_edit_link" onclick="return showBox(\'al_photos.php\', {act: \'edit_photo\', photo: cur.pvData[cur.pvListId][cur.pvIndex].id}, {stat: [\'ui_controls.css\', \'ui_controls.js\']})">' + getLang('photos_edit') + '</a>';
  922. 920.  - } else {
  923. 921.  -   photoEditAct = '';
  924. 922.  - }
  925. 923.  -
  926. 924.  -     if (img.width < 200 || img.height < 200) {
  927. 925.  -       ph.actions.prof = false;
  928. 926.  -       ph.actions.dialog = false;
  929. 927.  -     }
  930. 928.  -     cur.pvNarrow.innerHTML = '\
  931. 929.  - ' + ((ph.album != 'NA' && notAvail != 2 || ph.graffiti) ? '<div class="pv_info">' + getLang('photos_album_name') + '</div><div class="pv_info" id="pv_album">' + ph.album + '</div>' : '') + '\
  932. 930.  - ' + (ph.author != 'NA' ? '<div class="pv_info">' + getLang('photos_author') + '</div><div id="pv_author">' + ph.author + '</div>' : '') + '\
  933. 931.  - <div id="pv_actions">\
  934. 932.  - ' + (fs ? '<a onclick="Photoview.fullscreen()">' + getLang('photos_fullscreen') + '</a>' : '') + '\
  935. 933.  -   <a id="pv_tag_link" onclick="stManager.add([\'phototag.js\', \'phototag.css\', \'tagger.css\', \'tagger.js\'], function() { Phototag.startTag(); })"' + taglnkst + '>' + getLang('photos_tagperson') + '</a>\
  936. 934.  - ' + (ph.actions.prof ? ('<a id="pv_to_profile" onmouseover="Photoview.toProfileTag()" onmouseout="Photoview.hideTag()" onclick="showBox(\'al_page.php\', {act: \'owner_photo_edit\', photo: \'' + ph.id + '\'}, {stat: [\'owner_photo.css\', \'owner_photo.js\', \'tagger.css\', \'tagger.js\']});">' + getLang('photos_load_to_profile') + '</a>') : '') + '\
  937. 935.  - ' + (ph.actions.dialog ? ('<a id="pv_to_dialog" onclick="showBox(\'al_page.php\', {act: \'owner_photo_edit\', photo: \'' + ph.id + '\', oid: ' + ph.actions.dialog + ', list: \'' + cur.pvListId + '\'}, {stat: [\'owner_photo.css\', \'owner_photo.js\', \'tagger.css\', \'tagger.js\']});">' + getLang('photos_load_to_dialog') + '</a>') : '') + '\
  938. 936.  - ' + photoEditAct + '\
  939. 937.  - ' + ((ph.y_src || ph.y_) ? ('<a id="pv_large_link" onclick="Photoview.switchSize()">' + getLang(vk.pvbig ? 'photos_smaller' : 'photos_larger') + '</a>') : '') + '\
  940. 938.  - ' + share + '\
  941. 939.  - ' + (ph.actions.del ? ('<a id="pv_delete_link" onclick="Photoview.deletePhoto()"><div class="progress fl_r" id="pv_delete_progress"></div>' + getLang('global_delete') + '</a>') : '') + '\
  942. 940.  - ' + (ph.actions.spam ? ('<a id="pv_spam_link" onclick="Photoview.spamPhoto(this.firstChild)"><div class="progress fl_r"></div>' + getLang('its_spam') + '</a>') : '') + '\
  943. 941.  - ' + (ph.actions.rot ? ('<div id="pv_rotate"><div id="pv_rotate_progress" class="progress fl_r"></div>' + getLang('photos_rotate') + '\
  944. 942.  -     <span onclick="Photoview.rotatePhoto(1)" class="right"></span>\
  945. 943.  -     <span onclick="Photoview.rotatePhoto(-1)" class="left"></span>\
  946. 944.  -     <form method="POST" target="pv_rotate_frame" name="pv_rotate_form" id="pv_rotate_form"></form>\
  947. 945.  -   </div>') : '') + '\
  948. 946.  - </div>';
  949. 947.  -
  950. 948.  -     var likeop = (ph.liked ? 1 : 0.4), likest = browser.msie ? ('filter: alpha(opacity=' + Math.floor(likeop * 100) + ')') : ('opacity: ' + likeop);
  951. 949.  -
  952. 950.  -     var commstyle = '', commshown = '', commlink = '', commclass = '',
  953. 951.  -         commslikes = cur.pvCommsLikes[ph.id], comms = commslikes[0], likes = commslikes[1];;
  954. 952.  -     if (ph.commcount > ph.commshown) {
  955. 953.  -       commshown = getLang('photos_show_prev_comments', ph.commcount - ph.commshown);
  956. 954.  -     } else {
  957. 955.  -       commstyle = ' style="display: none"';
  958. 956.  -     }
  959. 957.  -
  960. 958.  -     Wall.cancelEdit(true);
  961. 959.  -
  962. 960.  -     var additional = notAvail ? '<div class="clear">' + getLang('photos_in_closed_album') + '</div>' : '\
  963. 961.  - <div id="pv_comments_header" class="clear ' + commclass + '"' + commstyle + ' onclick="Photoview.comments()">\
  964. 962.  -   <div>' + commshown + '</div><div id="pv_comments_progress" class="progress"></div>\
  965. 963.  - </div>\
  966. 964.  - <div id="pv_comments" class="clear wall_module">' + (comms.tagName ? '' : comms) + '</div>', commsNode;
  967. 965.  -
  968. 966.  -     var tagsst = ph.tagshtml ? '' : ' style="display: none"',
  969. 967.  -         descText = '<div' + (ph.actions.edit & 1 ? (' class="pv_can_edit" onclick="Photoview.editInline(event)"' + (ph.desc ? (' onmouseover="Photoview.descTT(this)"') : '')) : ' class="pv_cant_edit"') + '>' + (ph.desc || ('<span class="pv_desc_edit">' + getLang('photos_edit_desc') + '</span>')) + '</div>',
  970. 968.  -         placeText = ph.place ? ('<span class="pv_place_label">' + getLang('photos_place_label') + '</span> <a class="pv_place_a" id="pv_place_a" onclick="Photoview.showPlace()">' + ph.place + '</a>') : '',
  971. 969.  -         addPlace = ph.actions.place ? ('<span' + (placeText ? ' style="display: none;"' : '') + ' id="pv_add_place"><span class="divider fl_l">|</span><a class="fl_l" id="pv_app_place_link" onclick="Photoview.editPlace();">' + getLang('photos_edit_add_place') + '</a></span>') : '';
  972. 970.  -     cur.pvWide.innerHTML = '\
  973. 971.  - <div id="pv_desc" style="' + ((ph.actions.edit & 1 || ph.desc) ? '' : 'display: none') + '">' + descText + '</div>\
  974. 972.  - <div id="pv_place">' + placeText + '</div>\
  975. 973.  - <div id="pv_tags"' + tagsst + '>' + getLang('photos_onthisphoto') + ': ' + ph.tagshtml + '</div>\
  976. 974.  - <div id="pv_inlineedit_prg" class="fl_r progress"></div>\
  977. 975.  - <div id="pv_date_wrap" class="fl_l">' + getLang('photos_added') + ' <span id="pv_date">' + ph.date + '</span></div>\
  978. 976.  - ' + addPlace + (cur.pvNoLikes ? '' : '<span class="divider fl_l">|</span>\
  979. 977.  - <div id="pv_like_wrap" class="fl_l" onmouseover="Photoview.likeOver()" onmouseout="Photoview.likeOut()" onclick="Photoview.like()">\
  980. 978.  -   <span class="fl_l" id="pv_like_link">' + getLang('photos_i_like') + '</span>\
  981. 979.  -   <i class="fl_l' + (likes ? '' : ' nolikes') + '" id="pv_like_icon" style="' + likest + '"></i>\
  982. 980.  -   <span id="pv_like_count" class="fl_l">' + (likes || '') + '</span>\
  983. 981.  - </div>') + (notAvail == 2 ? '' : additional);
  984. 982.  -     if (comms.tagName) {
  985. 983.  -       each(geByClass('page_gif_loading', comms), function() { Page.hideGif(this, false); });
  986. 984.  -       commsNode = ge('pv_comments');
  987. 985.  -       domPN(commsNode).replaceChild(comms, commsNode);
  988. 986.  -     }
  989. 987.  -
  990. 988.  -     extend(cur, {
  991. 989.  -       pvTagLink: ge('pv_tag_link'),
  992. 990.  -       pvLikeIcon: ge('pv_like_icon'),
  993. 991.  -       pvLikeLink: ge('pv_like_link'),
  994. 992.  -       pvDesc: ge('pv_desc'),
  995. 993.  -       pvTags: ge('pv_tags'),
  996. 994.  -       pvEditing: false
  997. 995.  -     });
  998. 996.  -
  999. 997.  -     if (ph.deleted || !ph.author) {
  1000. 998.  -       cleanElems('pv_confirm_tag', 'pv_delete_tag', 'pv_prof_cancel', 'pv_prof_done');
  1001. 999.  -       if (ph.deleted) {
  1002. 1000.  -         cur.pvTagInfo.innerHTML = ph.deleted;
  1003. 1001.  -         show(cur.pvTagInfo);
  1004. 1002.  -       }
  1005. 1003.  -       hide(cur.pvCommentsData, cur.pvHH);
  1006. 1004.  -     } else if (ph.taginfo) {
  1007. 1005.  -       cleanElems('pv_confirm_tag', 'pv_delete_tag', 'pv_prof_cancel', 'pv_prof_done');
  1008. 1006.  -       cur.pvTagInfo.innerHTML = '\
  1009. 1007.  - <table cellspacing="0" cellpadding="0"><tr>\
  1010. 1008.  - <td class="info">' + ph.taginfo + '</td>\
  1011. 1009.  - <td><nobr><div class="button_blue"><button id="pv_confirm_tag">' + getLang('photos_confirm_tag') + '</button></div></td>\
  1012. 1010.  - <td><nobr><div class="button_gray"><button id="pv_delete_tag">' + getLang('photos_delete_tag') + '</button></div></td>\
  1013. 1011.  - <td><div id="pv_tag_handling" class="progress"></div></td>\
  1014. 1012.  - </tr></table>';
  1015. 1013.  -       show(cur.pvTagInfo, cur.pvCommentsData);
  1016. 1014.  -       if (Photoview.hhCheck()) show(cur.pvHH);
  1017. 1015.  -       ge('pv_confirm_tag').onclick = Photoview.confirmTag.pbind(ph.tagid);
  1018. 1016.  -       ge('pv_delete_tag').onclick = Photoview.deleteTag.pbind(ph.tagid);
  1019. 1017.  -     } else {
  1020. 1018.  -       hide(cur.pvTagInfo);
  1021. 1019.  -       show(cur.pvCommentsData);
  1022. 1020.  -       if (Photoview.hhCheck()) show(cur.pvHH);
  1023. 1021.  -     }
  1024. 1022.  -
  1025. 1023.  -     if (notAvail || !ph.actions.comm) {
  1026. 1024.  -       hide(cur.pvYourComment);
  1027. 1025.  -     } else {
  1028. 1026.  -       show(cur.pvYourComment);
  1029. 1027.  -       Wall.initComposer(cur.pvComment, {
  1030. 1028.  -         lang: {
  1031. 1029.  -           introText: getLang('profile_mention_start_typing'),
  1032. 1030.  -           noResult: getLang('profile_mention_not_found')
  1033. 1031.  -         },
  1034. 1032.  -         wddClass: 'pv_composer_dd',
  1035. 1033.  -         width: getSize(domPN(cur.pvYourComment))[0],
  1036. 1034.  -         media: {
  1037. 1035.  -           lnk: cur.pvAddMedia,
  1038. 1036.  -           preview: cur.pvMediaPreview,
  1039. 1037.  -           types: cur.pvMediaTypes,
  1040. 1038.  -           options: {limit: 2, disabledTypes: ['album'], toggleLnk: true, onChange: function() {
  1041. 1039.  -             setTimeout(Photoview.updateHeight, 2);
  1042. 1040.  -           }}
  1043. 1041.  -         }
  1044. 1042.  -       });
  1045. 1043.  -       cur.pvCommentSend.onclick = Photoview.sendComment;
  1046. 1044.  -       if (!cur.pvComment.phevents) {
  1047. 1045.  -         cur.pvComment.placeholder = getLang('reply_to_post');
  1048. 1046.  -         placeholderSetup(cur.pvComment);
  1049. 1047.  -       }
  1050. 1048.  -       if (!cur.pvComment.autosize) {
  1051. 1049.  -         autosizeSetup(cur.pvComment, {minHeight: 65, onResize: Photoview.updateHeight});
  1052. 1050.  -       }
  1053. 1051.  -       if (cur.pvCommenting && cur.pvCommenting != ph.id) {
  1054. 1052.  -         var replyToName = (cur.pvReplyNames[(cur.pvReplyTo || {})[0]] || [])[1];
  1055. 1053.  -         if (replyToName && !replyToName.indexOf(trim(val(cur.pvComment)))) {
  1056. 1054.  -           val(cur.pvComment, '');
  1057. 1055.  -         }
  1058. 1056.  -         cur.pvReplyTo = false;
  1059. 1057.  -         hide('pv_reply_to_title', 'pv_del_reply_to');
  1060. 1058.  -
  1061. 1059.  -         cur.pvCommenting = false;
  1062. 1060.  -       }
  1063. 1061.  -       toggle(cur.pvAsGroup, !!ph.actions.asgr);
  1064. 1062.  -     }
  1065. 1063.  -
  1066. 1064.  -     Photoview.updateArrows();
  1067. 1065.  -     if ((cur.pvOptions || {}).scroll) {
  1068. 1066.  -       layerWrap.scrollTop = cur.pvOptions.scroll;
  1069. 1067.  -     }
  1070. 1068.  -
  1071. 1069.  -     setTimeout(Photoview.afterShow, 2);
  1072. 1070.  -   },
  1073. 1071.  -   afterShow: function() {
  1074. 1072.  -     Photoview.updateHeight();
  1075. 1073.  -     setStyle(layer, {marginTop: 0});
  1076. 1074.  -
  1077. 1075.  -     cur.pvPhoto.href = '/photo' + cur.pvCurPhoto.id;
  1078. 1076.  -     cur.pvPhoto.focus();
  1079. 1077.  -
  1080. 1078.  -     if ((cur.pvCurPhoto.actions.edit & 4) && !cur.pvCurPhoto.desc) {
  1081. 1079.  -       Photoview.editInline();
  1082. 1080.  -     }
  1083. 1081.  -
  1084. 1082.  -     var x = cur.pvPhoto.firstChild.offsetLeft, y = cur.pvPhoto.firstChild.offsetTop;
  1085. 1083.  -     cur.pvTagFrame.innerHTML = '<img style="width: ' + cur.pvPhWidth + 'px; height: ' + cur.pvPhHeight + 'px;" src="' + cur.pvCurData.src + '" />';
  1086. 1084.  -     setStyle(cur.pvTagFaded, {
  1087. 1085.  -       width: cur.pvPhWidth + 'px',
  1088. 1086.  -       height: cur.pvPhHeight + 'px',
  1089. 1087.  -       left: x + 'px',
  1090. 1088.  -       top: y + 'px'
  1091. 1089.  -     });
  1092. 1090.  -     var deltaX = browser.mozilla && ((lastWindowWidth - cur.pvActualWidth) % 2) && ((cur.pvActualWidth - cur.pvPhWidth) % 2) ? 4 : 3;
  1093. 1091.  -     setStyle(cur.pvTagFrame, {
  1094. 1092.  -       left: (x - deltaX) + 'px', // 3 - tag frame border, mozilla buggy
  1095. 1093.  -       top: (y - 3) + 'px'
  1096. 1094.  -     });
  1097. 1095.  -     setStyle(cur.pvTagPerson, {
  1098. 1096.  -       left: x + 'px',
  1099. 1097.  -       top: y + 'px'
  1100. 1098.  -     });
  1101. 1099.  -
  1102. 1100.  -     if ((cur.pvOptions || {}).scroll) {
  1103. 1101.  -       layerWrap.scrollTop = cur.pvOptions.scroll;
  1104. 1102.  -       cur.pvOptions.scroll = 0;
  1105. 1103.  -     }
  1106. 1104.  -
  1107. 1105.  -     Photoview.updateLoc();
  1108. 1106.  -   },
  1109. 1107.  -   updateLoc: function() {
  1110. 1108.  -     var nl, listId = cur.pvListId;
  1111. 1109.  -     if (cur.pvRoot) {
  1112. 1110.  -       nl = {0: 'photo' + cur.pvCurPhoto.id};
  1113. 1111.  -       if (listId.substr(0, 6) == 'photos') {
  1114. 1112.  -         nl.all = 1;
  1115. 1113.  -       } else if (listId.substr(0, 3) == 'tag') {
  1116. 1114.  -         nl.tag = intval(listId.substr(3));
  1117. 1115.  -       } else if (listId.substr(0, 6) == 'newtag') {
  1118. 1116.  -         nl.newtag = intval(listId.substr(6));
  1119. 1117.  -       }
  1120. 1118.  -       if (listId.indexOf('/rev') != -1) {
  1121. 1119.  -         nl.rev = 1;
  1122. 1120.  -       }
  1123. 1121.  -     } else {
  1124. 1122.  -       nl = extend(nav.objLoc, {z: 'photo' + cur.pvCurPhoto.id + '/' + (cur.pvCurPhoto.list_override || listId)});
  1125. 1123.  -     }
  1126. 1124.  -
  1127. 1125.  -     if (nav.strLoc != nav.toStr(nl)) {
  1128. 1126.  -       if (!cur.pvNoHistory) {
  1129. 1127.  -         ++cur.pvHistoryLength;
  1130. 1128.  -       }
  1131. 1129.  -       nav.setLoc(nl);
  1132. 1130.  -       if ((cur.pvOptions || {}).fromQueue) {
  1133. 1131.  -         cur.pvNoHistory = true;
  1134. 1132.  -         cur.pvHistoryLength = 0;
  1135. 1133.  -       }
  1136. 1134.  -     }
  1137. 1135.  -     if (cur.pvOptions) cur.pvOptions.fromQueue = false;
  1138. 1136.  -   },
  1139. 1137.  -
  1140. 1138.  -   canFullscreen: function() {
  1141. 1139.  -     var b = browser, v = floatval(browser.version);
  1142. 1140.  -     return (b.chrome && v > 15) ||
  1143. 1141.  -       (b.mozilla && v > 9) ||
  1144. 1142.  -       (b.safari && v > 5 && !b.mobile);
  1145. 1143.  -   },
  1146. 1144.  -   fullscreenOnLoad: function() {
  1147. 1145.  -     if (window.FullscreenPV) {
  1148. 1146.  -       FullscreenPV.slide();
  1149. 1147.  -     }
  1150. 1148.  -   },
  1151. 1149.  -   fullscreenEnd: function(finishing) {
  1152. 1150.  -     var el = cur.pvCanvas;
  1153. 1151.  -     if (!el) return;
  1154. 1152.  -     cleanElems(el);
  1155. 1153.  -     re(el);
  1156. 1154.  -     clearTimeout(cur.pvFSTimer);
  1157. 1155.  -     clearTimeout(cur.pvFSControlsTimer);
  1158. 1156.  -     cur.pvCanvas = cur.pvFSControls = cur.pvFSTimer = cur.pvFSControlsTimer = false;
  1159. 1157.  -     removeEvent(document, 'webkitfullscreenchange mozfullscreenchange fullscreenchange webkitfullscreenerror mozfullscreenerror fullscreenerror');
  1160. 1158.  -     show(pageNode);
  1161. 1159.  -     if (cur.pvScrWasY !== undefined) {
  1162. 1160.  -       scrollToY(cur.pvScrWasY, 0);
  1163. 1161.  -       delete cur.pvScrWasY;
  1164. 1162.  -     }
  1165. 1163.  -     if (finishing !== true) {
  1166. 1164.  -       Photoview.updateSize();
  1167. 1165.  -       Photoview.show(cur.pvListId, cur.pvIndex);
  1168. 1166.  -     }
  1169. 1167.  -   },
  1170. 1168.  -   fullscreen: function() {
  1171. 1169.  -     if (cur.pvCanvas) return;
  1172. 1170.  -     var el = cur.pvCanvas = bodyNode.appendChild(ce('div', {className: 'fixed', id: 'pv_fullscreen', innerHTML: '<div></div>'})), method = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullScreen;
  1173. 1171.  -
  1174. 1172.  -     cur.pvFinishing = false;
  1175. 1173.  -     stManager.add(['fullscreen_pv.css', 'fullscreen_pv.js'], function() {
  1176. 1174.  -       FullscreenPV.init();
  1177. 1175.  -     });
  1178. 1176.  -
  1179. 1177.  -     addEvent(document, 'webkitfullscreenchange mozfullscreenchange fullscreenchange', Photoview.onFullscreen);
  1180. 1178.  -     addEvent(document, 'webkitfullscreenerror mozfullscreenerror fullscreenerror', Photoview.fullscreenEnd.pbind(true));
  1181. 1179.  -
  1182. 1180.  -     try {
  1183. 1181.  -       method.call(el);
  1184. 1182.  -     } catch(e) {
  1185. 1183.  -       cur.pvPartScreen = true;
  1186. 1184.  -       Photoview.onFullscreen();
  1187. 1185.  -     }
  1188. 1186.  -   },
  1189. 1187.  -   fullscreenStop: function(finishing) {
  1190. 1188.  -     cur.pvFinishing = (finishing === true);
  1191. 1189.  -     cur.pvPartScreen = false;
  1192. 1190.  -     var method = document.exitFullscreen || document.mozCancelFullScreen || document.webkitCancelFullScreen;
  1193. 1191.  -     try {
  1194. 1192.  -       method();
  1195. 1193.  -     } catch(e) {
  1196. 1194.  -       Photoview.onFullscreen();
  1197. 1195.  -     }
  1198. 1196.  -     Photoview.fullscreenEnd();
  1199. 1197.  -   },
  1200. 1198.  -   onFullscreen: function() {
  1201. 1199.  -     if (document.fullScreenElement || document.mozFullScreen || document.webkitIsFullScreen || cur.pvPartScreen) {
  1202. 1200.  -       if (cur.pvTagger) {
  1203. 1201.  -         Phototag.stopTag();
  1204. 1202.  -       }
  1205. 1203.  -       vk.oldpvbig = vk.pvbig;
  1206. 1204.  -       vk.pvbig = true;
  1207. 1205.  -       cur.pvScrWidth = cur.pvCanvas.offsetWidth;
  1208. 1206.  -       cur.pvScrHeight = cur.pvCanvas.offsetHeight;
  1209. 1207.  -       cur.pvScrWasY = scrollGetY();
  1210. 1208.  -       hide(pageNode);
  1211. 1209.  -       if (!cur.pvFinishing) {
  1212. 1210.  -         Photoview.updateSize();
  1213. 1211.  -         Photoview.show(cur.pvListId, cur.pvIndex);
  1214. 1212.  -       }
  1215. 1213.  -     } else {
  1216. 1214.  -       vk.pvbig = vk.oldpvbig;
  1217. 1215.  -       Photoview.fullscreenEnd(cur.pvFinishing);
  1218. 1216.  -     }
  1219. 1217.  -   },
  1220. 1218.  -
  1221. 1219.  -   showShare: function() {
  1222. 1220.  -     clearTimeout(cur.hideShareTimer);
  1223. 1221.  -     var dd = ge('pvs_dd');
  1224. 1222.  -     ge('pv_share').blur();
  1225. 1223.  -     if (isVisible(dd)) {
  1226. 1224.  -       return fadeIn(dd, 0);
  1227. 1225.  -     }
  1228. 1226.  -     setTimeout(addEvent.pbind(document, 'click', Photoview.hideShare), 1);
  1229. 1227.  -     show(dd);
  1230. 1228.  -   },
  1231. 1229.  -   hideShare: function(timeout) {
  1232. 1230.  -     if (timeout > 0) {
  1233. 1231.  -       cur.hideShareTimer = setTimeout(Photoview.hideShare.pbind(0), timeout);
  1234. 1232.  -       return;
  1235. 1233.  -     }
  1236. 1234.  -     var dd = ge('pvs_dd');
  1237. 1235.  -     if (!dd) return;
  1238. 1236.  -     if (timeout == -1) {
  1239. 1237.  -       hide(dd);
  1240. 1238.  -     } else {
  1241. 1239.  -       fadeOut(dd, 200);
  1242. 1240.  -     }
  1243. 1241.  -     removeEvent(document, 'click', Photoview.hideShare);
  1244. 1242.  -   },
  1245. 1243.  -   savePhoto: function() {
  1246. 1244.  -     var listId = cur.pvListId, index = cur.pvIndex, ph = cur.pvData[listId][index];
  1247. 1245.  -     ajax.post('al_photos.php', {act: 'save_me', photo: ph.id, list: listId, hash: ph.hash}, {progress: 'pv_share_prg', onDone: showDoneBox});
  1248. 1246.  -   },
  1249. 1247.  -   sendPhoto: function() {
  1250. 1248.  -     var listId = cur.pvListId, index = cur.pvIndex, ph = cur.pvData[listId][index];
  1251. 1249.  -     showBox('like.php', {act: 'publish_box', object: 'photo' + ph.id, list: listId, to: 'mail'}, {stat: ['page.js', 'page.css', 'wide_dd.js', 'wide_dd.css', 'sharebox.js']});
  1252. 1250.  -   },
  1253. 1251.  -
  1254. 1252.  -   setTags: function(tags) {
  1255. 1253.  -     Photoview.hideTag();
  1256. 1254.  -     if (!tags) {
  1257. 1255.  -       hide(cur.pvTags);
  1258. 1256.  -       return;
  1259. 1257.  -     }
  1260. 1258.  -     show(cur.pvTags);
  1261. 1259.  -     if (window.tooltips) {
  1262. 1260.  -       each(geByClass('delete', cur.pvTags), function() {
  1263. 1261.  -         tooltips.destroy(this);
  1264. 1262.  -       });
  1265. 1263.  -     }
  1266. 1264.  -     cur.pvTags.innerHTML = getLang('photos_onthisphoto') + ': ' + tags;
  1267. 1265.  -   },
  1268. 1266.  -   preload: function(from, direction) {
  1269. 1267.  -     window.updateWndVScroll && updateWndVScroll(); // Because called on photo load
  1270. 1268.  -     var listId = cur.pvListId, count = ((cur.pvData || {})[listId] || {}).length;
  1271. 1269.  -     if (!count) return;
  1272. 1270.  -
  1273. 1271.  -     var s1 = vk.pvbig ? (cur.pvVeryBig > 1 ? 'z' : (cur.pvVeryBig ? 'z' : 'y')) : 'x';
  1274. 1272.  -     var s2 = vk.pvbig ? (cur.pvVeryBig > 1 ? 'z' : (cur.pvVeryBig ? 'y' : 'x')) : 0;
  1275. 1273.  -     var s3 = vk.pvbig ? (cur.pvVeryBig > 1 ? 'y' : (cur.pvVeryBig ? 'x' : 0)) : 0;
  1276. 1274.  -
  1277. 1275.  -     cur.pvLastFrom = from;
  1278. 1276.  -     cur.pvLastDirection = direction;
  1279. 1277.  -
  1280. 1278.  -     // remove preloaded ones without touching preloading ones
  1281. 1279.  -     for (var i = 0; i < Math.min(Photoview.cacheSize, count - Photoview.cacheSize); ++i) {
  1282. 1280.  -       var ind = from + (i + 1) * (-direction);
  1283. 1281.  -       while (ind >= count) ind -= count;
  1284. 1282.  -       while (ind < 0) ind += count;
  1285. 1283.  -
  1286. 1284.  -       var p = cur.pvData[listId][ind];
  1287. 1285.  -       if (!p) continue;
  1288. 1286.  -       for (var j = 0, l = Photoview.allSizes.length; j < l; ++j) {
  1289. 1287.  -         var s = Photoview.allSizes[j];
  1290. 1288.  -         if (p[s] && p[s].src) {
  1291. 1289.  -           p[s].src = Photoview.blank;
  1292. 1290.  -           delete(p[s]);
  1293. 1291.  -         }
  1294. 1292.  -       }
  1295. 1293.  -     }
  1296. 1294.  -     for (var i = 0; i < Photoview.cacheSize; ++i) {
  1297. 1295.  -       var ind = from + (i + 1) * direction;
  1298. 1296.  -       while (ind >= count) ind -= count;
  1299. 1297.  -       while (ind < 0) ind += count;
  1300. 1298.  -
  1301. 1299.  -       var p = cur.pvData[listId][ind];
  1302. 1300.  -       if (!p || !p.id) {
  1303. 1301.  -         if (!p || (vkNow() - p > 3000)) {
  1304. 1302.  -           cur.pvData[listId][ind] = vkNow();
  1305. 1303.  -           setTimeout(function() {
  1306. 1304.  -             ajax.post('al_photos.php', {act: 'show', list: listId, offset: Photoview.realOffset(listId, ind, -1), direction: direction}, {onDone: Photoview.loaded});
  1307. 1305.  -           }, 10);
  1308. 1306.  -         }
  1309. 1307.  -         break;
  1310. 1308.  -       }
  1311. 1309.  -
  1312. 1310.  -       if (p[s1]) continue;
  1313. 1311.  -       if (p[s1 + '_src']) {
  1314. 1312.  -         p[s1] = vkImage();
  1315. 1313.  -         p[s1].src = p[s1 + '_src'];
  1316. 1314.  -         continue;
  1317. 1315.  -       } else {
  1318. 1316.  -         p[s1] = 1;
  1319. 1317.  -       }
  1320. 1318.  -
  1321. 1319.  -       if (p[s2]) continue;
  1322. 1320.  -       if (p[s2 + '_src']) {
  1323. 1321.  -         p[s2] = vkImage();
  1324. 1322.  -         p[s2].src = p[s2 + '_src'];
  1325. 1323.  -         continue;
  1326. 1324.  -       } else {
  1327. 1325.  -         p[s2] = 1;
  1328. 1326.  -       }
  1329. 1327.  -
  1330. 1328.  -       if (p[s3]) continue;
  1331. 1329.  -       if (p[s3 + '_src']) {
  1332. 1330.  -         p[s3] = vkImage();
  1333. 1331.  -         p[s3].src = p[s3 + '_src'];
  1334. 1332.  -         continue;
  1335. 1333.  -       } else {
  1336. 1334.  -         p[s3] = 1;
  1337. 1335.  -       }
  1338. 1336.  -
  1339. 1337.  -       if (p.x) continue;
  1340. 1338.  -       p.x = vkImage();
  1341. 1339.  -       p.x.src = p.x_src;
  1342. 1340.  -     }
  1343. 1341.  -   },
  1344. 1342.  -   hide: function(noLoc, fromQueue) {
  1345. 1343.  -     if (!cur.pvShown || __afterFocus && fromQueue !== true) return;
  1346. 1344.  -     if (cur.pvCanvas) Photoview.fullscreenStop(true);
  1347. 1345.  -
  1348. 1346.  -     if ((cur.pvJumpTo || {}).z == 'albums' + val('pva_owner') && !cur.pvAlbumsShown && noLoc === 0) {
  1349. 1347.  -       return Photoview.jumpToAlbums(true);
  1350. 1348.  -     }
  1351. 1349.  -     if ((cur.pvJumpTo || {}).z == 'album' + val('pvsa_album') && !cur.pvAlbumShown && noLoc === 0) {
  1352. 1350.  -       return Photoview.jumpToAlbum(true);
  1353. 1351.  -     }
  1354. 1352.  -     if ((cur.pvJumpTo || {}).z == 'tag' + val('pvsa_tag') && !cur.pvPhotoTagShown && noLoc === 0) {
  1355. 1353.  -       return Photoview.jumpToTagged(true);
  1356. 1354.  -     }
  1357. 1355.  -     if (cur.pvListId == 'temp') {
  1358. 1356.  -       cur.pvCancelLoad();
  1359. 1357.  -     } else if (!cur.pvNoHistory && !noLoc && cur.pvHistoryLength > 0 && cur.pvHistoryLength < 10) {
  1360. 1358.  -       cur.pvNoHistory = true;
  1361. 1359.  -       __adsUpdate('very_lazy');
  1362. 1360.  -       return history.go(-cur.pvHistoryLength);
  1363. 1361.  -     }
  1364. 1362.  -
  1365. 1363.  -     if (noLoc !== true && !layerQueue.count()) {
  1366. 1364.  -       var newLoc;
  1367. 1365.  -       if (cur.pvRoot) {
  1368. 1366.  -         if (cur.pvListId.substr(0, 6) == 'newtag') {
  1369. 1367.  -           newLoc = 'albums' + vk.id + '?act=added';
  1370. 1368.  -           if (cur.pvListId.indexOf('/rev') != -1) {
  1371. 1369.  -             newLoc += '&rev=1';
  1372. 1370.  -           }
  1373. 1371.  -         } else {
  1374. 1372.  -           newLoc = cur.pvListId.replace('/rev', '?rev=1');
  1375. 1373.  -         }
  1376. 1374.  -         nav.setLoc(newLoc);
  1377. 1375.  -       } else {
  1378. 1376.  -         newLoc = clone(nav.objLoc);
  1379. 1377.  -         delete(newLoc.z);
  1380. 1378.  -       }
  1381. 1379.  -       if (nav.strLoc != nav.toStr(newLoc)) {
  1382. 1380.  -         nav.setLoc(newLoc);
  1383. 1381.  -       }
  1384. 1382.  -       __adsUpdate('very_lazy');
  1385. 1383.  -     }
  1386. 1384.  -
  1387. 1385.  -     window.__pvhideTimer = setTimeout(Photoview.doHide.pbind(cur), 0);
  1388. 1386.  -     __adsUpdate();
  1389. 1387.  -
  1390. 1388.  - //    if (window.wkcur && wkcur.scrollTop) {
  1391. 1389.  - //      setTimeout(function() {
  1392. 1390.  - //        window.wkLayerWrap.scrollTop = wkcur.scrollTop;
  1393. 1391.  - //        wkcur.scrollTop = false;
  1394. 1392.  - //      }, 0);
  1395. 1393.  - //    }
  1396. 1394.  -     if (cur.pvHHMove) {
  1397. 1395.  -       removeEvent(layer, 'mousemove', Photoview.photoAct);
  1398. 1396.  -       cur.pvHHMove = false;
  1399. 1397.  -     }
  1400. 1398.  -     cur.pvAlbumsShowing = cur.pvAlbumsShown = false;
  1401. 1399.  -     cur.pvAlbumShowing = cur.pvAlbumShown = false;
  1402. 1400.  -     cur.pvPhotoTagShowing = cur.pvPhotoTagShown = false;
  1403. 1401.  -     cur.pvVideoTagShowing = cur.pvVideoTagsShown = false;
  1404. 1402.  -   },
  1405. 1403.  -   doHide: function(c) {
  1406. 1404.  -     c.pvHistoryLength = 0;
  1407. 1405.  -     if (cur.pvTagger) Phototag.stopTag();
  1408. 1406.  -     cleanElems('pv_confirm_tag', 'pv_delete_tag', 'pv_prof_cancel', 'pv_prof_done');
  1409. 1407.  -     if (c.pvFriends) {
  1410. 1408.  -       cleanElems('pv_add_tag', 'pv_cancel_tag', c.pvFriends.firstChild.firstChild, c.pvFriends);
  1411. 1409.  -       re(c.pvFriends);
  1412. 1410.  -       c.pvFriends = c.pvFriendName = false;
  1413. 1411.  -     }
  1414. 1412.  -
  1415. 1413.  -     Wall.cancelEdit(true);
  1416. 1414.  -
  1417. 1415.  -     removeEvent(c.pvPhoto, 'mousemove', Photoview.onMouseMove);
  1418. 1416.  -
  1419. 1417.  -     // remove preloaded
  1420. 1418.  -     var listId = c.pvListId, count = ((c.pvData || {})[listId] || {}).length;
  1421. 1419.  -     if (c.pvLastDirection && count) {
  1422. 1420.  -       for (var i = 0; i < Photoview.cacheSize; ++i) {
  1423. 1421.  -         var ind = c.pvLastFrom + (i + 1) * c.pvLastDirection;
  1424. 1422.  -         while (ind >= count) ind -= count;
  1425. 1423.  -         while (ind < 0) ind += count;
  1426. 1424.  -
  1427. 1425.  -         var p = c.pvData[listId][ind];
  1428. 1426.  -         if (!p) continue;
  1429. 1427.  -         for (var j = 0, l = Photoview.allSizes.length; j < l; ++j) {
  1430. 1428.  -           var s = Photoview.allSizes[j];
  1431. 1429.  -           if (p[s] && p[s].src) {
  1432. 1430.  -             p[s].src = Photoview.blank;
  1433. 1431.  -             delete(p[s]);
  1434. 1432.  -           }
  1435. 1433.  -         }
  1436. 1434.  -       }
  1437. 1435.  -       c.pvLastDirection = c.pvLastFrom = false;
  1438. 1436.  -     }
  1439. 1437.  -     debugLog('hiding layers');
  1440. 1438.  -
  1441. 1439.  -     cur.pvYourComment = re(cur.pvYourComment);
  1442. 1440.  -
  1443. 1441.  -     layers.hide();
  1444. 1442.  -     layers.fullhide = false;
  1445. 1443.  -
  1446. 1444.  -     Photoview.hideTag(true);
  1447. 1445.  -     each(['pvLeft', 'pvClose', 'pvSwitch', 'pvFixed'], function() {
  1448. 1446.  -       var n = this + '';
  1449. 1447.  -       re(c[n]);
  1450. 1448.  -       c[n] = false;
  1451. 1449.  -     });
  1452. 1450.  -     if (window.tooltips) {
  1453. 1451.  -       tooltips.destroyAll(cur.pvBox);
  1454. 1452.  -     }
  1455. 1453.  -
  1456. 1454.  -     if (browser.mobile) {
  1457. 1455.  -       ge('footer').style.height = '';
  1458. 1456.  -     }
  1459. 1457.  -
  1460. 1458.  -     var colorClass = vk.pvdark ? 'pv_dark' : 'pv_light';
  1461. 1459.  -     removeClass(layerWrap, colorClass);
  1462. 1460.  -     removeClass(layerBG, colorClass);
  1463. 1461.  -     layerBG.style.opacity = '';
  1464. 1462.  -
  1465. 1463.  -     c.pvShown = c.pvListId = c.pvClicked = false;
  1466. 1464.  -     removeEvent(window, 'resize', Photoview.onResize);
  1467. 1465.  -     removeEvent(document, 'keydown', Photoview.onKeyDown);
  1468. 1466.  -     removeEvent(layerWrap, 'click', Photoview.onClick);
  1469. 1467.  -     removeEvent(layerWrap, 'scroll', Photoview.scrollResize);
  1470. 1468.  -
  1471. 1469.  - //    if (window.wkcur && wkcur.shown) {
  1472. 1470.  - //      WkView.showLayer();
  1473. 1471.  - //    }
  1474. 1472.  -     var onh = cur.pvOptions && cur.pvOptions.onHide;
  1475. 1473.  -     if (cur.pvOptions) {
  1476. 1474.  -       var onh = cur.pvOptions.onHide;
  1477. 1475.  -       cur.pvOptions.onHide = false;
  1478. 1476.  -       if (onh) onh();
  1479. 1477.  -     }
  1480. 1478.  -     layerQueue.pop();
  1481. 1479.  -
  1482. 1480.  -     if (c.pvPreloaded && c === cur) {
  1483. 1481.  -       var cont = ge('photos_container'), d = ce('div', {innerHTML: c.pvPreloaded});
  1484. 1482.  -       while (d.firstChild) {
  1485. 1483.  -         cont.appendChild(d.firstChild);
  1486. 1484.  -       }
  1487. 1485.  -       if (cont.qsorter) {
  1488. 1486.  -         setTimeout(qsorter.added.pbind(cont), 0);
  1489. 1487.  -       }
  1490. 1488.  -       c.pvPreloaded = false;
  1491. 1489.  -     }
  1492. 1490.  -   },
  1493. 1491.  -   editPhoto: function() {
  1494. 1492.  -   },
  1495. 1493.  -   descTT: function(el) {
  1496. 1494.  -     return showTooltip(el, {
  1497. 1495.  -       text: getLang('photos_edit_desc'),
  1498. 1496.  -       black: 1,
  1499. 1497.  -       shift: [2, 4, 0],
  1500. 1498.  -       showdt: 0
  1501. 1499.  -     });
  1502. 1500.  -   },
  1503. 1501.  -   editInline: function(ev, noreq) {
  1504. 1502.  -     if (((ev || window.event || {}).target || {}).tagName == 'A' || cur.pvEditing) return;
  1505. 1503.  -
  1506. 1504.  -     var listId = cur.pvListId, index = cur.pvIndex, ph = cur.pvData[listId][index], noreq = !ph.desc;
  1507. 1505.  -     var onDone = function(text) {
  1508. 1506.  -       if (!cur.pvShown || cur.pvListId != listId || cur.pvIndex != index || cur.pvEditing) return;
  1509. 1507.  -
  1510. 1508.  -       cur.pvEditing = [listId, index];
  1511. 1509.  -       var mrg = '0px 0px 0px', taStyle = '';
  1512. 1510.  -       if (browser.chrome) {
  1513. 1511.  -         mrg = '0px 0px -5px';
  1514. 1512.  -         taStyle = ' style="padding-bottom: 0px"';
  1515. 1513.  -       } else if (browser.mozilla) {
  1516. 1514.  -         mrg = '0px -1px 0px';
  1517. 1515.  -       } else if (browser.msie) {
  1518. 1516.  -         mrg = '0px 0px -6px';
  1519. 1517.  -       }
  1520. 1518.  -       var el = cur.pvDesc.appendChild(ce('div', {innerHTML: '\
  1521. 1519.  - <div style="margin: ' + mrg + '">\
  1522. 1520.  -   <textarea id="pv_edit_text"' + taStyle + ' onkeydown="onCtrlEnter(event, Photoview.saveInline)" placeholder="' + getLang('photos_edit_desc_intro') + '">' + text + '</textarea>\
  1523. 1521.  - </div>'}, {display: 'none'})), txt = ge('pv_edit_text');
  1524. 1522.  -       placeholderSetup(txt, {back: 1});
  1525. 1523.  -       autosizeSetup(txt, {minHeight: 13});
  1526. 1524.  -       setTimeout(function() {
  1527. 1525.  -         show(el);
  1528. 1526.  -         elfocus(txt);
  1529. 1527.  -         addEvent(txt, 'blur', Photoview.saveInline);
  1530. 1528.  -         hide(cur.pvDesc.firstChild);
  1531. 1529.  -       }, 1);
  1532. 1530.  -     };
  1533. 1531.  -     if (!noreq) {
  1534. 1532.  -       ajax.post('al_photos.php', {act: 'edit_desc', photo: ph.id}, {onDone: onDone, progress: 'pv_inlineedit_prg'});
  1535. 1533.  -     } else {
  1536. 1534.  -       onDone('');
  1537. 1535.  -     }
  1538. 1536.  -   },
  1539. 1537.  -   cancelInline: function() {
  1540. 1538.  -     cur.pvEditing = false;
  1541. 1539.  -     removeEvent(ge('pv_edit_text'), 'blur');
  1542. 1540.  -     show(cur.pvDesc.firstChild);
  1543. 1541.  -     re(cur.pvDesc.firstChild.nextSibling);
  1544. 1542.  -   },
  1545. 1543.  -   saveInline: function() {
  1546. 1544.  -     if (!cur.pvEditing) return;
  1547. 1545.  -     removeEvent(ge('pv_edit_text'), 'blur');
  1548. 1546.  -
  1549. 1547.  -     var listId = cur.pvEditing[0], index = cur.pvEditing[1], ph = cur.pvData[listId][index];
  1550. 1548.  -     ajax.post('al_photos.php', {act: 'save_desc', photo: ph.id, hash: ph.hash, text: val('pv_edit_text')}, {onDone: function(text) {
  1551. 1549.  -       ph.desc = text;
  1552. 1550.  -
  1553. 1551.  -       var shown = cur.pvShown && listId == cur.pvListId && index == cur.pvIndex;
  1554. 1552.  -       if (!shown) return;
  1555. 1553.  -
  1556. 1554.  -       cur.pvEditing = false;
  1557. 1555.  -       var d = domFC(cur.pvDesc);
  1558. 1556.  -       val(d, text || ('<span class="pv_desc_edit">' + getLang('photos_edit_desc') + '</span>'));
  1559. 1557.  -       d.onmouseover = text ? Photoview.descTT.pbind(d) : function() {};
  1560. 1558.  -       show(d);
  1561. 1559.  -       re(domNS(d));
  1562. 1560.  -     }, progress: 'pv_inlineedit_prg'});
  1563. 1561.  -   },
  1564. 1562.  -
  1565. 1563.  -   cmp: function(id1, id2) {
  1566. 1564.  -     var l1 = id1.length, l2 = id2.length;
  1567. 1565.  -     if (l1 < l2) {
  1568. 1566.  -       return -1;
  1569. 1567.  -     } else if (l1 > l2) {
  1570. 1568.  -       return 1;
  1571. 1569.  -     } else if (id1 < id2) {
  1572. 1570.  -       return -1;
  1573. 1571.  -     } else if (id1 > id2) {
  1574. 1572.  -       return 1;
  1575. 1573.  -     }
  1576. 1574.  -     return 0;
  1577. 1575.  -   },
  1578. 1576.  -   receiveComms: function(listId, index, text, names, noOld, toUp) {
  1579. 1577.  -     if (listId != cur.pvListId || index != cur.pvIndex) return;
  1580. 1578.  -
  1581. 1579.  -     var n = ce('div', {innerHTML: text}), comms = ge('pv_comments'), last = current = domLC(comms), frm = getXY(current, true)[1], ph = cur.pvData[listId][index];
  1582. 1580.  -     for (var el = domLC(n); el; el = domLC(n)) {
  1583. 1581.  -       if (ph.actions.comm) addClass(el, 'reply_replieable');
  1584. 1582.  -       while (current && Photoview.cmp(current.id, el.id) > 0) {
  1585. 1583.  -         current = domPS(current);
  1586. 1584.  -       }
  1587. 1585.  -       if (current && !Photoview.cmp(current.id, el.id)) {
  1588. 1586.  -         comms.replaceChild(el, current);
  1589. 1587.  -         current = el;
  1590. 1588.  -       } else {
  1591. 1589.  -         if (current && domNS(current)) {
  1592. 1590.  -           comms.insertBefore(el, domNS(current));
  1593. 1591.  -         } else if (!current && domFC(comms)) {
  1594. 1592.  -           if (noOld === true) {
  1595. 1593.  -             --ph.commshown;
  1596. 1594.  -             n.removeChild(el);
  1597. 1595.  -           } else {
  1598. 1596.  -             comms.insertBefore(el, domFC(comms));
  1599. 1597.  -           }
  1600. 1598.  -         } else {
  1601. 1599.  -           comms.appendChild(el);
  1602. 1600.  -         }
  1603. 1601.  -         ++ph.commshown;
  1604. 1602.  -       }
  1605. 1603.  -     }
  1606. 1604.  -     if (toUp && last) {
  1607. 1605.  -       layerWrap.scrollTop += getXY(last, true)[1] - frm;
  1608. 1606.  -     }
  1609. 1607.  -     cur.pvCommsLikes[ph.id][0] = comms;
  1610. 1608.  -     extend(cur.pvReplyNames, names);
  1611. 1609.  -     Photoview.updateComms();
  1612. 1610.  -   },
  1613. 1611.  -   commSaved: function(post) {
  1614. 1612.  -     if (!cur.pvShown) return;
  1615. 1613.  -     var comms = ge('pv_comments'), ph = comms ? cur.pvData[cur.pvListId][cur.pvIndex] : false, comm = post.match(/^(-?\d+)photo(_\d+)/);
  1616. 1614.  -     if (!ph || !comm || !ge('pv_comment' + comm[1] + comm[2])) return;
  1617. 1615.  -     cur.pvCommsLikes[ph.id][0] = comms;
  1618. 1616.  -   },
  1619. 1617.  -   comments: function(showcomm) {
  1620. 1618.  -     if (showcomm) {
  1621. 1619.  -       var frst = domFC(ge('pv_comments')).id || '';
  1622. 1620.  -       if (
  1623. 1621.  -         !isVisible('pv_comments_header') ||
  1624. 1622.  -         isVisible('pv_comments_progress') ||
  1625. 1623.  -         Photoview.cmp(frst, 'pv_comment' + showcomm) < 0
  1626. 1624.  -       ) {
  1627. 1625.  -         return;
  1628. 1626.  -       }
  1629. 1627.  -     }
  1630. 1628.  -     var listId = cur.pvListId, index = cur.pvIndex, ph = cur.pvData[listId][index];
  1631. 1629.  -     var prg = ge('pv_comments_progress');
  1632. 1630.  -     ajax.post('al_photos.php', {act: 'photo_comments', offset: ph.commshown, photo: ph.id}, {
  1633. 1631.  -       onDone: function(text, names) {
  1634. 1632.  -         Photoview.receiveComms(listId, index, text, names, false, showcomm);
  1635. 1633.  -         if (showcomm && ge('pv_comment' + showcomm)) {
  1636. 1634.  -           Photoview.showComment(showcomm);
  1637. 1635.  -         }
  1638. 1636.  -       },
  1639. 1637.  -       showProgress: function() {
  1640. 1638.  -         hide(prg.previousSibling);
  1641. 1639.  -         show(prg);
  1642. 1640.  -       }, hideProgress: function() {
  1643. 1641.  -         hide(prg);
  1644. 1642.  -         show(prg.previousSibling);
  1645. 1643.  -       }
  1646. 1644.  -     });
  1647. 1645.  -   },
  1648. 1646.  -   updateComms: function() {
  1649. 1647.  -     setTimeout(Photoview.updateHeight, 2);
  1650. 1648.  -
  1651. 1649.  -     var ph = cur.pvData[cur.pvListId][cur.pvIndex];
  1652. 1650.  -     var commshown = '', commprg = ge('pv_comments_progress'), commheader = ge('pv_comments_header');
  1653. 1651.  -     if (ph.commcount > ph.commshown) {
  1654. 1652.  -       commshown = getLang('photos_show_prev_comments', ph.commcount - ph.commshown);
  1655. 1653.  -     }
  1656. 1654.  -     (commshown ? show : hide)(commheader);
  1657. 1655.  -     domPS(commprg).innerHTML = commshown;
  1658. 1656.  -   },
  1659. 1657.  -   commentClick: function(el, event, from) {
  1660. 1658.  -     var comm = el.id.replace('pv_comment', ''), cmnt = comm.split('_');
  1661. 1659.  -     if (Wall.checkReplyClick(el, event)) return;
  1662. 1660.  -
  1663. 1661.  -     var moreLink = geByClass1('wall_reply_more', el, 'a');
  1664. 1662.  -     if (moreLink && isVisible(moreLink)) {
  1665. 1663.  -       removeClass(el, 'reply_moreable');
  1666. 1664.  -       moreLink.onclick();
  1667. 1665.  -       return;
  1668. 1666.  -     }
  1669. 1667.  -     if (from && cmnt[1] && isVisible(cur.pvYourComment)) {
  1670. 1668.  -       Photoview.commentTo(comm, from, event);
  1671. 1669.  -     }
  1672. 1670.  -   },
  1673. 1671.  -   commentChanged: function() {
  1674. 1672.  -     checkTextLength(cur.pvCommLimit, cur.pvComment, ge('pv_comment_warn'));
  1675. 1673.  -     cur.pvCommenting = cur.pvData[cur.pvListId][cur.pvIndex].id;
  1676. 1674.  -   },
  1677. 1675.  -   commentTo: function(comm, toId, event) {
  1678. 1676.  -     var cmnt = (comm || '').split('_'), commId = cmnt[1], ph = cur.pvData[cur.pvListId][cur.pvIndex], replyNameOld = cur.pvReplyTo && cur.pvReplyNames[cur.pvReplyTo[0]] || '', replyName = cur.pvReplyNames[toId] || '', rf = cur.pvComment, tl = ge('pv_reply_to_title');
  1679. 1677.  -
  1680. 1678.  -     cur.pvCommenting = ph.id;
  1681. 1679.  -
  1682. 1680.  -     if (comm) {
  1683. 1681.  -       cur.pvReplyTo = [toId, commId];
  1684. 1682.  -       val(tl, replyName[0]);
  1685. 1683.  -       show(tl, 'pv_del_reply_to');
  1686. 1684.  -       setStyle(tl, {maxWidth: ge('pv_comment_submit').offsetWidth - domPN(ge('pv_comment_send')).offsetWidth - (isVisible(cur.pvAsGroup) ? cur.pvAsGroup.offsetWidth : 0) - domPN(cur.pvAddMedia).offsetWidth - 31});
  1687. 1685.  -     } else {
  1688. 1686.  -       cur.pvReplyTo = false;
  1689. 1687.  -       hide(tl, 'pv_del_reply_to');
  1690. 1688.  -     }
  1691. 1689.  -
  1692. 1690.  -     var v = trim(val(rf)), cEl = comm && geByClass1('pv_reply_to', ge('pv_comment' + comm));
  1693. 1691.  -     if (!v || replyNameOld && !winToUtf(replyNameOld[1]).indexOf(v)) {
  1694. 1692.  -       val(rf, (comm && !checkEvent(event)) ? replaceEntities(replyName[1]) : '');
  1695. 1693.  -     }
  1696. 1694.  -     toggleClass(cur.pvAsGroup, 'on', !!(ph.actions.asgr && cEl && cEl.getAttribute('rid') === cmnt[0]));
  1697. 1695.  -     elfocus(rf);
  1698. 1696.  -   },
  1699. 1697.  -   sendComment: function() {
  1700. 1698.  -     var listId = cur.pvListId, index = cur.pvIndex, ph = cur.pvData[listId][index],
  1701. 1699.  -         fld = cur.pvComment, comp = fld && data(fld, 'composer'),
  1702. 1700.  -         params = comp ? Composer.getSendParams(comp, Photoview.sendComment) : {message: trim(val(fld))},
  1703. 1701.  -         replyToName = (cur.pvReplyNames[(cur.pvReplyTo || {})[0]] || [])[1], btn = 'pv_comment_send';
  1704. 1702.  -
  1705. 1703.  -     if (params.delayed) return;
  1706. 1704.  -
  1707. 1705.  -     if (!params.attach1_type && (!params.message || replyToName && !replyToName.indexOf(params.message))) {
  1708. 1706.  -       elfocus(fld);
  1709. 1707.  -       return;
  1710. 1708.  -     }
  1711. 1709.  -
  1712. 1710.  -     hide('pv_comment_warn');
  1713. 1711.  -     ajax.post('al_photos.php',  Wall.fixPostParams(extend(params, {
  1714. 1712.  -       act: 'post_comment',
  1715. 1713.  -       photo: ph.id,
  1716. 1714.  -       hash: ph.hash,
  1717. 1715.  -       fromview: 1,
  1718. 1716.  -       from_group: isVisible(cur.pvAsGroup) ? isChecked(cur.pvAsGroup) : '',
  1719. 1717.  -       reply_to: (cur.pvReplyTo || {})[1]
  1720. 1718.  -     })), {onDone: function(text, names) {
  1721. 1719.  -       ++ph.commcount;
  1722. 1720.  -       Photoview.receiveComms(listId, index, text, names, true);
  1723. 1721.  -       if (data(cur.pvComment, 'composer')) {
  1724. 1722.  -         Composer.reset(data(cur.pvComment, 'composer'));
  1725. 1723.  -       } else {
  1726. 1724.  -         val(cur.pvComment, '');
  1727. 1725.  -       }
  1728. 1726.  -       cur.pvComment.blur();
  1729. 1727.  -       cur.pvReplyTo = false;
  1730. 1728.  -       hide('pv_reply_to_title', 'pv_del_reply_to');
  1731. 1729.  -     }, showProgress: lockButton.pbind(btn), hideProgress: unlockButton.pbind(btn)});
  1732. 1730.  -   },
  1733. 1731.  -   highlightComment: function(el) {
  1734. 1732.  -     el = ge(el);
  1735. 1733.  -     if (!el) return;
  1736. 1734.  -
  1737. 1735.  -     var hlfunc = animate.pbind(el, {backgroundColor: '#ECEFF3'}, 200, function() {
  1738. 1736.  -       setTimeout(function() {
  1739. 1737.  -         animate(el, {backgroundColor: '#FFF'}, 200, function() {
  1740. 1738.  -           setStyle(el, {backgroundColor: ''});
  1741. 1739.  -         });
  1742. 1740.  -       }, 1000);
  1743. 1741.  -     }), top = getXY(el, true)[1];
  1744. 1742.  -
  1745. 1743.  -     if (top < 0 || top > lastWindowHeight - 200) {
  1746. 1744.  -       animate(layerWrap, {scrollTop: layerWrap.scrollTop + top - 50}, 300, hlfunc);
  1747. 1745.  -     } else {
  1748. 1746.  -       hlfunc();
  1749. 1747.  -     }
  1750. 1748.  -   },
  1751. 1749.  -   showComment: function(comm) {
  1752. 1750.  -     var p = ge('pv_comment' + comm);
  1753. 1751.  -     if (p) {
  1754. 1752.  -       Photoview.highlightComment(p);
  1755. 1753.  -     } else {
  1756. 1754.  -       Photoview.comments(comm);
  1757. 1755.  -     }
  1758. 1756.  -     return false;
  1759. 1757.  -   },
  1760. 1758.  -   commDone: function(comm, context, text, del) {
  1761. 1759.  -     var node = ge('pv_comment' + comm + context);
  1762. 1760.  -     if (!node) return;
  1763. 1761.  -
  1764. 1762.  -     var msg = node.firstChild.nextSibling, ph = context ? false : cur.pvData[cur.pvListId][cur.pvIndex];
  1765. 1763.  -     if (!text) {
  1766. 1764.  -       show(node.firstChild);
  1767. 1765.  -       hide(msg);
  1768. 1766.  -       if (ph) {
  1769. 1767.  -         ++ph.commcount;
  1770. 1768.  -         ++ph.commshown;
  1771. 1769.  -         Photoview.updateComms();
  1772. 1770.  -       } else if (window.photos && cur.offset) {
  1773. 1771.  -         photos.recache(cur.offset, 1);
  1774. 1772.  -       }
  1775. 1773.  -       return;
  1776. 1774.  -     }
  1777. 1775.  -     if (msg) {
  1778. 1776.  -       msg.innerHTML = text;
  1779. 1777.  -       show(msg);
  1780. 1778.  -     } else {
  1781. 1779.  -       node.appendChild(ce('div', {innerHTML: text}));
  1782. 1780.  -     }
  1783. 1781.  -     hide(node.firstChild);
  1784. 1782.  -     if (del) {
  1785. 1783.  -       if (ph) {
  1786. 1784.  -         --ph.commshown;
  1787. 1785.  -         --ph.commcount;
  1788. 1786.  -         Photoview.updateComms();
  1789. 1787.  -       } else if (window.photos && cur.offset) {
  1790. 1788.  -         photos.recache(cur.offset, -1);
  1791. 1789.  -       }
  1792. 1790.  -     } else {
  1793. 1791.  -       Photoview.updateHeight();
  1794. 1792.  -     }
  1795. 1793.  -     if (ph) {
  1796. 1794.  -       cur.pvCommsLikes[ph.id][0] = ge('pv_comments');
  1797. 1795.  -     }
  1798. 1796.  -   },
  1799. 1797.  -   commProgress: function(comm, sh) {
  1800. 1798.  -     var acts = ge('pv_actions' + comm);
  1801. 1799.  -     if (!acts) return;
  1802. 1800.  -
  1803. 1801.  -     var prg = acts.firstChild.nextSibling;
  1804. 1802.  -     if (sh !== true) {
  1805. 1803.  -       hide(prg);
  1806. 1804.  -       show(acts.firstChild);
  1807. 1805.  -       return;
  1808. 1806.  -     }
  1809. 1807.  -     hide(acts.firstChild);
  1810. 1808.  -     if (!prg) {
  1811. 1809.  -       prg = acts.appendChild(ce('div', {className: 'progress'}));
  1812. 1810.  -     }
  1813. 1811.  -     show(prg);
  1814. 1812.  -   },
  1815. 1813.  -   commParams: function(comm, context) {
  1816. 1814.  -     return {
  1817. 1815.  -       onDone: Photoview.commDone.pbind(comm, context),
  1818. 1816.  -       progress: 'pv_progress' + comm + context
  1819. 1817.  -     }
  1820. 1818.  -   },
  1821. 1819.  -   commAction: function(act, comm, context, hash) {
  1822. 1820.  -     if (isVisible('pv_progress' + comm + context)) return;
  1823. 1821.  -     ajax.post('al_photos.php', {act: act + '_comment', comment: comm, context: context, hash: hash}, Photoview.commParams(comm, context));
  1824. 1822.  -   },
  1825. 1823.  -
  1826. 1824.  -   onClick: function(e, skipClicked) {
  1827. 1825.  -     if (cur.pvClicked && !skipClicked || __afterFocus) {
  1828. 1826.  -       cur.pvClicked = false;
  1829. 1827.  -       return;
  1830. 1828.  -     }
  1831. 1829.  -     if (e && (e.button == 2 || e.which == 3 || e.pvHandle)) return;
  1832. 1830.  -     if (e) e.pvHandle = true;
  1833. 1831.  -     var px = e.pageX, py = e.pageY;
  1834. 1832.  -     if (px == null && e.clientX != null) {
  1835. 1833.  -       var doc = document.documentElement, body = bodyNode;
  1836. 1834.  -       px = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0);
  1837. 1835.  -       py = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0);
  1838. 1836.  -     }
  1839. 1837.  -     var dx = Math.abs(px - intval(cur.pvOldX));
  1840. 1838.  -     var dy = Math.abs(py - intval(cur.pvOldY));
  1841. 1839.  -     if (dx > 3 || dy > 3) {
  1842. 1840.  -       if (vkNow() - intval(cur.pvOldT) > 300) {
  1843. 1841.  -         if (cur.pvTagger) {
  1844. 1842.  -           Phototag.stopTag();
  1845. 1843.  -         } else {
  1846. 1844.  -           Photoview.hide(0);
  1847. 1845.  -         }
  1848. 1846.  -       }
  1849. 1847.  -     }
  1850. 1848.  -   },
  1851. 1849.  -   onMouseMove: function(ev) {
  1852. 1850.  -     var el = cur.pvPhoto.firstChild;
  1853. 1851.  -     if (cur.pvTagger || !el) return;
  1854. 1852.  -
  1855. 1853.  -     var elemXY = getXY(el), ph = cur.pvData[cur.pvListId][cur.pvIndex];
  1856. 1854.  -     var x = (ev.pageX - elemXY[0]) * 100 / cur.pvPhWidth, y = (ev.pageY - elemXY[1]) * 100 / cur.pvPhHeight;
  1857. 1855.  -     for (var i in ph.tags) {
  1858. 1856.  -       var coords = ph.tags[i];
  1859. 1857.  -       if (x > coords[0] && x < coords[2] && y > coords[1] && y < coords[3]) {
  1860. 1858.  -         Photoview.showDynTag(i);
  1861. 1859.  -         return;
  1862. 1860.  -       }
  1863. 1861.  -     }
  1864. 1862.  -     Photoview.hideTag();
  1865. 1863.  -   },
  1866. 1864.  -   onKeyDown: function(e) {
  1867. 1865.  -     if (e.returnValue === false) return false;
  1868. 1866.  -     if (e.keyCode == KEY.ESC && cur.pvEditing) {
  1869. 1867.  -       Photoview.cancelInline();
  1870. 1868.  -       return cancelEvent(e);
  1871. 1869.  -     }
  1872. 1870.  -     if (e.altKey && e.keyCode == KEY.RETURN && Photoview.canFullscreen()) {
  1873. 1871.  -       (cur.pvCanvas ? Photoview.fullscreenStop() : Photoview.fullscreen());
  1874. 1872.  -     }
  1875. 1873.  -     if (e.target && (e.target.tagName == 'INPUT' || e.target.tagName == 'TEXTAREA' || e.target.tagName == 'DIV' && e.target.contentEditable)) {
  1876. 1874.  -       return true;
  1877. 1875.  -     }
  1878. 1876.  -     if (e.keyCode == KEY.ESC) {
  1879. 1877.  -       if (cur.pvCanvas) {
  1880. 1878.  -         Photoview.fullscreenStop();
  1881. 1879.  -       } else if (cur.pvTagger) {
  1882. 1880.  -         Phototag.stopTag();
  1883. 1881.  -       } else if (!e.vkCanceled && !curBox()) {
  1884. 1882.  -         Photoview.hide(0);
  1885. 1883.  -       }
  1886. 1884.  -       return cancelEvent(e);
  1887. 1885.  -     } else if (!cur.pvTagger && !boxQueue.count() && (!cur.pvComment || !cur.pvComment.focused)) {
  1888. 1886.  -       if (e.keyCode == KEY.RIGHT) {
  1889. 1887.  -         Photoview.show(cur.pvListId, cur.pvIndex + 1);
  1890. 1888.  -       } else if (e.keyCode == KEY.LEFT) {
  1891. 1889.  -         Photoview.show(cur.pvListId, cur.pvIndex - 1);
  1892. 1890.  -       }
  1893. 1891.  -     }
  1894. 1892.  -   },
  1895. 1893.  -   onResize: function() {
  1896. 1894.  -     var dwidth = lastWindowWidth, dheight = lastWindowHeight, sbw = sbWidth();
  1897. 1895.  -     if (cur.pvCanvas) {
  1898. 1896.  -       var sizeChanged = false, oldverybig = cur.pvVeryBig, w = cur.pvCanvas.offsetWidth, h = cur.pvCanvas.offsetHeight;
  1899. 1897.  -       cur.pvVeryBig = (w > 1280 || h > 1280) ? 2 : ((w > 807 || h > 807) ? 1 : false);
  1900. 1898.  -       if (sizeChanged = (oldverybig != cur.pvVeryBig)) {
  1901. 1899.  -         setTimeout(Photoview.preload.pbind(cur.pvIndex, cur.pvLastDirection || 1), 10);
  1902. 1900.  -       }
  1903. 1901.  -       return;
  1904. 1902.  -     }
  1905. 1903.  -     if (cur.pvAlbumsShown || cur.pvAlbumShown || cur.pvPhotoTagShown) {
  1906. 1904.  -       cur.pvActualWidth = (cur.pvsaMini && !cur.pvAlbumsShown) ? 536 : 804;
  1907. 1905.  -       cur.pvCont.style.width = (cur.pvActualWidth + 154) + 'px';
  1908. 1906.  -       domPN(cur.pvSummary).style.width = (cur.pvActualWidth - 4) + 'px';
  1909. 1907.  -     } else if (vk.pvbig) {
  1910. 1908.  -       var w = dwidth - sbw - 2 - 120 - 34 - 50, h = dheight - 31 - 28 - 72;
  1911. 1909.  -       if (w > 1280) { // less than full hd - not size > 2
  1912. 1910.  -         w = 1280;
  1913. 1911.  -       } else if (w > 807 && w < 907) { // 1024x768 - not size > 1
  1914. 1912.  -         w = 807;
  1915. 1913.  -       } else if (w < 604) {
  1916. 1914.  -         w = 604;
  1917. 1915.  -       }
  1918. 1916.  -       if (h < 453) {
  1919. 1917.  -         h = 453;
  1920. 1918.  -       }
  1921. 1919.  -       cur.pvWidth = w;
  1922. 1920.  -       cur.pvHeight = h;
  1923. 1921.  -
  1924. 1922.  -       var sizeChanged = false, oldverybig = cur.pvVeryBig;
  1925. 1923.  -       cur.pvVeryBig = (w > 1280) ? 2 : (w > 807 ? 1 : false);
  1926. 1924.  -       sizeChanged = (oldverybig != cur.pvVeryBig);
  1927. 1925.  -
  1928. 1926.  -       var lnk = cur.pvPhoto;
  1929. 1927.  -       if (lnk && lnk.firstChild && cur.pvCurData.src == lnk.firstChild.src && cur.pvCurData.width) {
  1930. 1928.  -         var c = (cur.pvCurData.width > cur.pvWidth) ? (cur.pvWidth / cur.pvCurData.width) : 1;
  1931. 1929.  -         if (cur.pvCurData.height * c > cur.pvHeight) {
  1932. 1930.  -           c = cur.pvHeight / cur.pvCurData.height;
  1933. 1931.  -         }
  1934. 1932.  -         var w = cur.pvPhWidth = Math.floor(cur.pvCurData.width * c);
  1935. 1933.  -         var h = cur.pvPhHeight = Math.floor(cur.pvCurData.height * c);
  1936. 1934.  -         cur.pvActualWidth = Math.max(604, w);
  1937. 1935.  -
  1938. 1936.  -         if (vk.pvbig) {
  1939. 1937.  -           cur.pvCont.style.width = (cur.pvActualWidth + 154) + 'px';
  1940. 1938.  -           domPN(cur.pvSummary).style.width = (cur.pvActualWidth - 4) + 'px';
  1941. 1939.  -         }
  1942. 1940.  -
  1943. 1941.  -         lnk.style.height = Math.max(453, h) + 'px';
  1944. 1942.  -         lnk.firstChild.style.width = w + 'px';
  1945. 1943.  -         lnk.firstChild.style.height = h + 'px';
  1946. 1944.  -         if (cur.pvTagger && cur.pvTagger != 'loading') {
  1947. 1945.  -           cur.pvTagger.resize(w, h);
  1948. 1946.  -         }
  1949. 1947.  -
  1950. 1948.  -         var x = lnk.firstChild.offsetLeft, y = lnk.firstChild.offsetTop;
  1951. 1949.  -         if (browser.msie7 || browser.msie6) {
  1952. 1950.  -           x += lnk.offsetLeft;
  1953. 1951.  -           y += lnk.offsetTop;
  1954. 1952.  -         }
  1955. 1953.  -         setStyle(cur.pvTagFrame.firstChild, {
  1956. 1954.  -           width: w + 'px',
  1957. 1955.  -           height: h + 'px'
  1958. 1956.  -         });
  1959. 1957.  -         setStyle(cur.pvTagFaded, {
  1960. 1958.  -           width: w + 'px',
  1961. 1959.  -           height: h + 'px',
  1962. 1960.  -           left: x + 'px',
  1963. 1961.  -           top: y + 'px'
  1964. 1962.  -         });
  1965. 1963.  -         setStyle(cur.pvTagFrame, {
  1966. 1964.  -           left: (x - 3) + 'px', // 3 - tag frame border
  1967. 1965.  -           top: (y - 3) + 'px'
  1968. 1966.  -         });
  1969. 1967.  -         setStyle(cur.pvTagPerson, {
  1970. 1968.  -           left: x + 'px',
  1971. 1969.  -           top: y + 'px'
  1972. 1970.  -         });
  1973. 1971.  -
  1974. 1972.  -         if (sizeChanged) {
  1975. 1973.  -           setTimeout(Photoview.preload.pbind(cur.pvIndex, cur.pvLastDirection || 1), 10);
  1976. 1974.  -         }
  1977. 1975.  -       } else {
  1978. 1976.  -         cur.pvActualWidth = intval(getStyle(cur.pvBox, 'width'));
  1979. 1977.  -       }
  1980. 1978.  -     }
  1981. 1979.  -     if (!cur.pvPhoto) return;
  1982. 1980.  -     if (browser.mozilla && cur.pvPhoto.firstChild) {
  1983. 1981.  -       var x = cur.pvPhoto.firstChild.offsetLeft, deltaX = ((lastWindowWidth - cur.pvActualWidth) % 2) && ((cur.pvActualWidth - cur.pvPhWidth) % 2) ? 4 : 3;
  1984. 1982.  -       setStyle(cur.pvTagFrame, {
  1985. 1983.  -         left: (x - deltaX) + 'px' // 3 - tag w border, mozilla buggy
  1986. 1984.  -       });
  1987. 1985.  -     }
  1988. 1986.  -     Photoview.updateArrows();
  1989. 1987.  -     Photoview.updateHeight();
  1990. 1988.  -     cur.pvHH.style.marginLeft = Math.ceil((cur.pvActualWidth + 50 - 72) / 2) + 'px';
  1991. 1989.  -
  1992. 1990.  -     Photoview.scrollResize();
  1993. 1991.  - //    if (ge('pv_date')) { // debug
  1994. 1992.  - //      ge('pv_date').innerHTML = lastWindowWidth + ' ' + cur.pvActualWidth + ' ' + cur.pvPhWidth;
  1995. 1993.  - //    }
  1996. 1994.  -   },
  1997. 1995.  -   updateSize: function() {
  1998. 1996.  -     if (!vk.pvbig) {
  1999. 1997.  -       cur.pvActualWidth = 604;
  2000. 1998.  -       domPN(cur.pvSummary).style.width = '600px';
  2001. 1999.  -       cur.pvCont.style.width = '758px';
  2002. 2000.  -       cur.pvPhoto.innerHTML = '';
  2003. 2001.  -     }
  2004. 2002.  -     onBodyResize();
  2005. 2003.  -     Photoview.onResize();
  2006. 2004.  -   },
  2007. 2005.  -
  2008. 2006.  -   switchSize: function() {
  2009. 2007.  -     vk.pvbig = !vk.pvbig;
  2010. 2008.  -
  2011. 2009.  -     ge('pv_large_link').innerHTML = getLang(vk.pvbig ? 'photos_smaller' : 'photos_larger');
  2012. 2010.  -     if (cur.pvTagger) Phototag.stopTag();
  2013. 2011.  -     Photoview.updateSize();
  2014. 2012.  -     Photoview.show(cur.pvListId, cur.pvIndex);
  2015. 2013.  -     if (vk.id) {
  2016. 2014.  -       clearTimeout(cur.pvSaveBig);
  2017. 2015.  -       cur.pvSaveBig = setTimeout(ajax.post.pbind('al_photos.php', {act: 'viewer_big', big: (vk.pvbig ? 1 : ''), hash: cur.pvHash}), 1000);
  2018. 2016.  -     }
  2019. 2017.  -   },
  2020. 2018.  -   switchColor: function(el) {
  2021. 2019.  -     var old = vk.pvdark ? 'pv_dark' : 'pv_light';
  2022. 2020.  -     vk.pvdark = !vk.pvdark;
  2023. 2021.  -     var cl = vk.pvdark ? 'pv_dark' : 'pv_light';
  2024. 2022.  -
  2025. 2023.  -     setStyle(el, 'opacity', vk.pvdark ? 1 : 0.7);
  2026. 2024.  -
  2027. 2025.  -     layerBG.className = layerBG.className.replace(old, cl);
  2028. 2026.  -     layerWrap.className = layerWrap.className.replace(old, cl);
  2029. 2027.  -     cur.pvFixed.className = cur.pvFixed.className.replace(old, cl);
  2030. 2028.  -     if (vk.id) {
  2031. 2029.  -       clearTimeout(cur.pvSaveColor);
  2032. 2030.  -       cur.pvSaveColor = setTimeout(ajax.post.pbind('al_photos.php', {act: 'viewer_color', dark: (vk.pvdark ? 1 : ''), hash: cur.pvHash}), 1000);
  2033. 2031.  -     }
  2034. 2032.  -   },
  2035. 2033.  -
  2036. 2034.  -   activate: function(arrow) {
  2037. 2035.  -     if (arrow && arrow.timeout) {
  2038. 2036.  -       clearTimeout(arrow.timeout);
  2039. 2037.  -       removeAttr(arrow, 'timeout');
  2040. 2038.  -     } else if (isVisible(arrow)) {
  2041. 2039.  -       fadeTo(arrow, 200, vk.pvdark ? 1 : 0.7);
  2042. 2040.  -     }
  2043. 2041.  -   },
  2044. 2042.  -   deactivate: function(arrow) {
  2045. 2043.  -     if (!arrow || !isVisible(arrow) || arrow.timeout) {
  2046. 2044.  -       return;
  2047. 2045.  -     }
  2048. 2046.  -     arrow.timeout = setTimeout(function() {
  2049. 2047.  -       removeAttr(arrow, 'timeout');
  2050. 2048.  -       fadeTo(arrow, 200, 0.4);
  2051. 2049.  -     }, 1);
  2052. 2050.  -   },
  2053. 2051.  -
  2054. 2052.  -   deletePhoto: function(sure) {
  2055. 2053.  -     var listId = cur.pvListId, index = cur.pvIndex, ph = cur.pvData[listId][index], box = curBox();
  2056. 2054.  -     var prg = box ? box.progress : 'pv_delete_progress';
  2057. 2055.  -     if (isVisible(prg)) return;
  2058. 2056.  -
  2059. 2057.  -     if (cur.pvTagger && ev !== false) {
  2060. 2058.  -       Phototag.stopTag();
  2061. 2059.  -       return;
  2062. 2060.  -     }
  2063. 2061.  -
  2064. 2062.  -     ajax.post('al_photos.php', {act: 'delete_photo', photo: ph.id, hash: ph.hash, set_prev: isChecked('pvb_prev_check'), sure: intval(sure)}, {onDone: function(text, html) {
  2065. 2063.  -       if (box) {
  2066. 2064.  -         box.hide();
  2067. 2065.  -         return nav.go('/id0', false, {nocur: true});
  2068. 2066.  -       }
  2069. 2067.  -       if (html) {
  2070. 2068.  -         return showFastBox(text, html, getLang('global_delete'), Photoview.deletePhoto.pbind(1), getLang('global_cancel'));
  2071. 2069.  -       }
  2072. 2070.  -       ph.deleted = text;
  2073. 2071.  -       if (listId == cur.pvListId && index == cur.pvIndex) {
  2074. 2072.  -         cleanElems('pv_confirm_tag', 'pv_delete_tag', 'pv_prof_cancel', 'pv_prof_done');
  2075. 2073.  -         cur.pvTagInfo.innerHTML = ph.deleted;
  2076. 2074.  -         show(cur.pvTagInfo);
  2077. 2075.  -         hide(cur.pvCommentsData);
  2078. 2076.  -         Photoview.updateHeight();
  2079. 2077.  -       }
  2080. 2078.  -     }, progress: prg});
  2081. 2079.  -   },
  2082. 2080.  -   restorePhoto: function() {
  2083. 2081.  -     var listId = cur.pvListId, index = cur.pvIndex, ph = cur.pvData[listId][index];
  2084. 2082.  -     if (isVisible('pv_restore_progress')) return;
  2085. 2083.  -
  2086. 2084.  -     ajax.post('al_photos.php', {act: 'restore_photo', photo: ph.id, hash: ph.hash}, {onDone: function(text) {
  2087. 2085.  -       ph.deleted = false;
  2088. 2086.  -       if (listId == cur.pvListId && index == cur.pvIndex) {
  2089. 2087.  -         cleanElems('pv_confirm_tag', 'pv_delete_tag', 'pv_prof_cancel', 'pv_prof_done');
  2090. 2088.  -         if (ph.taginfo) {
  2091. 2089.  -           cur.pvTagInfo.innerHTML = '\
  2092. 2090.  - <table cellspacing="0" cellpadding="0"><tr>\
  2093. 2091.  -   <td class="info">' + ph.taginfo + '</td>\
  2094. 2092.  -   <td><nobr><div class="button_blue"><button id="pv_confirm_tag">' + getLang('photos_confirm_tag') + '</button></div></td>\
  2095. 2093.  -   <td><nobr><div class="button_gray"><button id="pv_delete_tag">' + getLang('photos_delete_tag') + '</button></div></td>\
  2096. 2094.  -   <td><div id="pv_tag_handling" class="progress"></div></td>\
  2097. 2095.  - </tr></table>';
  2098. 2096.  -           show(cur.pvTagInfo);
  2099. 2097.  -           ge('pv_confirm_tag').onclick = Photoview.confirmTag.pbind(ph.tagid);
  2100. 2098.  -           ge('pv_delete_tag').onclick = Photoview.deleteTag.pbind(ph.tagid);
  2101. 2099.  -         } else {
  2102. 2100.  -           cur.pvTagInfo.innerHTML = '';
  2103. 2101.  -           hide(cur.pvTagInfo);
  2104. 2102.  -         }
  2105. 2103.  -         show(cur.pvCommentsData);
  2106. 2104.  -         Photoview.updateHeight();
  2107. 2105.  -       }
  2108. 2106.  -     }, progress: 'pv_restore_progress'});
  2109. 2107.  -   },
  2110. 2108.  -   spamPhoto: function(prg, spamHash) {
  2111. 2109.  -     var listId = cur.pvListId, index = cur.pvIndex, ph = cur.pvData[listId][index];
  2112. 2110.  -     if (isVisible(prg)) return;
  2113. 2111.  -
  2114. 2112.  -     if (cur.pvTagger && ev !== false) {
  2115. 2113.  -       Phototag.stopTag();
  2116. 2114.  -       return;
  2117. 2115.  -     }
  2118. 2116.  -
  2119. 2117.  -     ajax.post('al_photos.php', {act: 'spam_photo', photo: ph.id, hash: ph.hash, spam_hash: spamHash}, {onDone: function(text, del) {
  2120. 2118.  -       if (del) ph.deleted = text;
  2121. 2119.  -       if (listId == cur.pvListId && index == cur.pvIndex) {
  2122. 2120.  -         cleanElems('pv_confirm_tag', 'pv_delete_tag', 'pv_prof_cancel', 'pv_prof_done');
  2123. 2121.  -         cur.pvTagInfo.innerHTML = text;
  2124. 2122.  -         show(cur.pvTagInfo);
  2125. 2123.  -         if (del) hide(cur.pvCommentsData);
  2126. 2124.  -         Photoview.updateHeight();
  2127. 2125.  -       }
  2128. 2126.  -     }, progress: prg});
  2129. 2127.  -   },
  2130. 2128.  -   rotatePhoto: function(to) {
  2131. 2129.  -     var prg = ge('pv_rotate_progress');
  2132. 2130.  -     if (isVisible(prg)) return;
  2133. 2131.  -
  2134. 2132.  -     show(prg);
  2135. 2133.  -     ge('pv_rotate').appendChild(ce('div', {id: 'pv_rotate_frame', className: 'upload_frame', innerHTML: '<iframe name="pv_rotate_frame"></iframe>'}));
  2136. 2134.  -     var listId = cur.pvListId, index = cur.pvIndex, ph = cur.pvData[listId][index], form = ge('pv_rotate_form');
  2137. 2135.  -     form.innerHTML = '';
  2138. 2136.  -     form.action = ph.rotate[0];
  2139. 2137.  -     var data = extend({act: 'do_rotate', to: to, list_id: listId, index: index, fid: ph.id}, ph.rotate);
  2140. 2138.  -     to = (to + 4) % 4;
  2141. 2139.  -     if (data.act == 'rotate_photo') {
  2142. 2140.  -       data.angle = (data.angle + to) % 4;
  2143. 2141.  -     }
  2144. 2142.  -     if (data['rot'+to]) {
  2145. 2143.  -       data.act = 'done_rotate';
  2146. 2144.  -       data.complete = 1;
  2147. 2145.  -       ajax.post('/al_photos.php', data, {
  2148. 2146.  -         onDone: Photoview.rotateDone,
  2149. 2147.  -         onFail: function() {
  2150. 2148.  -           Photoview.rotateDone();
  2151. 2149.  -         }
  2152. 2150.  -       });
  2153. 2151.  -       return;
  2154. 2152.  -     }
  2155. 2153.  -     for (var i in data) {
  2156. 2154.  -       if (i != 0) {
  2157. 2155.  -         form.appendChild(ce('input', {type: 'hidden', name: i, value: data[i]}));
  2158. 2156.  -       }
  2159. 2157.  -     }
  2160. 2158.  -     form.submit();
  2161. 2159.  -   },
  2162. 2160.  -   rotateDone: function(data) {
  2163. 2161.  -     hide('pv_rotate_progress');
  2164. 2162.  -     var el = ge('pv_rotate_frame');
  2165. 2163.  -
  2166. 2164.  -     if (!el) return;
  2167. 2165.  -     re(el);
  2168. 2166.  -
  2169. 2167.  -     if (!data) return;
  2170. 2168.  -     var listId = data.list_id, index = data.index, ph = cur.pvData[listId][index];
  2171. 2169.  -     extend(ph, {x_src: data.x_src, y_src: data.y_src, z_src: data.z_src, w_src: data.w_src, base: data.base, x_: data.x_, y_: data.y_, z_: data.z_, w_: data.w_, x: 0, y: 0, z: 0, w: 0, tags: data.tags, tagged: data.tagged, tagshtml: data.html})
  2172. 2170.  -     extend(ph.rotate, {photo: data.photo, hash: data.hash, rhash: data.rhash, angle: data.angle, rot1: data.rot1, rot3: data.rot3});
  2173. 2171.  -     if (listId == cur.pvListId && index == cur.pvIndex) {
  2174. 2172.  -       Photoview.show(listId, index);
  2175. 2173.  -     }
  2176. 2174.  -   },
  2177. 2175.  -
  2178. 2176.  -   likeUpdate: function(my, count, title) {
  2179. 2177.  -     count = intval(count);
  2180. 2178.  -
  2181. 2179.  -     var listId = cur.pvListId, index = cur.pvIndex, ph = cur.pvData[listId][index];
  2182. 2180.  -     var countInput = ge('like_real_count_photo' + ph.id) || {}, rows = ge('like_table_photo' + ph.id);
  2183. 2181.  -     var titleNode = ge('like_title_photo' + ph.id), countNode = ge('pv_like_count');
  2184. 2182.  -     var icon = cur.pvLikeIcon;
  2185. 2183.  -     var tt = icon.parentNode.tt || {}, opts = clone(tt.opts || {}), newleft = (my ? 0 : -36);
  2186. 2184.  -
  2187. 2185.  -     if (title && titleNode) {
  2188. 2186.  -       val(titleNode, title);
  2189. 2187.  -     }
  2190. 2188.  -     cur.pvCommsLikes[ph.id][1] = countInput.value = count;
  2191. 2189.  -     animateCount(countNode, count);
  2192. 2190.  -
  2193. 2191.  -     ph.liked = my;
  2194. 2192.  -     (my ? addClass : removeClass)(cur.pvHH, 'pvs_hh_liked');
  2195. 2193.  -     if (!my) {
  2196. 2194.  -       var cb = ge('like_share_photo' + ph.id);
  2197. 2195.  -       if (cb) checkbox(cb, false);
  2198. 2196.  -     } else {
  2199. 2197.  -       setStyle(icon, {opacity: 1});
  2200. 2198.  -     }
  2201. 2199.  -     if (count) {
  2202. 2200.  -       var styleName = vk.rtl ? 'right' : 'left';
  2203. 2201.  -       if (tt.el && !isVisible(tt.container) && !title) {
  2204. 2202.  -         rows.style[styleName] = newleft + 'px';
  2205. 2203.  -         tooltips.show(tt.el, extend(opts, {showdt: 0}));
  2206. 2204.  -       } else if (rows) {
  2207. 2205.  -         var params = {};
  2208. 2206.  -         params[styleName] = newleft;
  2209. 2207.  -         animate(rows, params, 200);
  2210. 2208.  -       }
  2211. 2209.  -       removeClass(icon, 'no_likes');
  2212. 2210.  -     } else {
  2213. 2211.  -       if (tt.el) tt.hide();
  2214. 2212.  -       addClass(icon, 'no_likes');
  2215. 2213.  -     }
  2216. 2214.  -   },
  2217. 2215.  -   like: function() {
  2218. 2216.  -     if (!vk.id) return;
  2219. 2217.  -     var listId = cur.pvListId, index = cur.pvIndex, ph = cur.pvData[listId][index], my = !ph.liked;
  2220. 2218.  -     ajax.post('like.php', {act: 'a_do_' + (my ? '' : 'un') + 'like', object: 'photo' + ph.id, hash: ph.hash, from: 'photo_viewer'}, {
  2221. 2219.  -       onDone: function(count, title) {
  2222. 2220.  -         if (cur.pvListId == listId && cur.pvIndex == index) {
  2223. 2221.  -           return Photoview.likeUpdate(my, count, title);
  2224. 2222.  -         }
  2225. 2223.  -         cur.pvCommsLikes[ph.id][1] = count;
  2226. 2224.  -         ph.liked = my;
  2227. 2225.  -       }
  2228. 2226.  -     });
  2229. 2227.  -     Photoview.likeUpdate(my, cur.pvCommsLikes[ph.id][1] + (my ? 1 : -1));
  2230. 2228.  -   },
  2231. 2229.  -   likeShare: function(hash) {
  2232. 2230.  -     if (!vk.id) return;
  2233. 2231.  -     var listId = cur.pvListId, index = cur.pvIndex, ph = cur.pvData[listId][index];
  2234. 2232.  -     var el = ge('like_share_photo' + ph.id), was = isChecked(el);
  2235. 2233.  -     checkbox(el);
  2236. 2234.  -     ajax.post('like.php', {act: 'a_do_' + (was ? 'un' : '') + 'publish', object: 'photo' + ph.id, list: listId, hash: hash, from: 'photo_viewer'}, {
  2237. 2235.  -       onDone: function(count, title) {
  2238. 2236.  -         if (cur.pvListId == listId && cur.pvIndex == index) {
  2239. 2237.  -           return Photoview.likeUpdate(true, count, title);
  2240. 2238.  -         }
  2241. 2239.  -         cur.pvCommsLikes[ph.id][1] = count;
  2242. 2240.  -         ph.liked = true;
  2243. 2241.  -       }
  2244. 2242.  -     });
  2245. 2243.  -     Photoview.likeUpdate(true, cur.pvCommsLikes[ph.id][1] + (ph.liked ? 0 : 1));
  2246. 2244.  -   },
  2247. 2245.  -   likeOver: function() {
  2248. 2246.  -     var listId = cur.pvListId, index = cur.pvIndex, ph = cur.pvData[listId][index];
  2249. 2247.  -     var icon = cur.pvLikeIcon;
  2250. 2248.  -     if (!ph.liked) {
  2251. 2249.  -       setTimeout(animate.pbind(icon, {opacity: 1}, 200, false), 1);
  2252. 2250.  -     } else {
  2253. 2251.  -       setStyle(icon, {opacity: 1});
  2254. 2252.  -     }
  2255. 2253.  -     var linkW = cur.pvLikeLink.offsetWidth;
  2256. 2254.  -
  2257. 2255.  -     showTooltip(icon.parentNode, {
  2258. 2256.  -       url: 'like.php',
  2259. 2257.  -       params: {act: 'a_get_stats', object: 'photo' + ph.id, list: listId},
  2260. 2258.  -       slide: 15,
  2261. 2259.  -       shift: [0, 5, 9],
  2262. 2260.  -       ajaxdt: 100,
  2263. 2261.  -       showdt: 400,
  2264. 2262.  -       hidedt: 200,
  2265. 2263.  -       className: 'rich like_tt',
  2266. 2264.  -       init: function (tt) {
  2267. 2265.  -         if (!tt.container) return;
  2268. 2266.  -         var bp = geByClass1('bottom_pointer', tt.container, 'div');
  2269. 2267.  -         var tp = geByClass1('top_pointer', tt.container, 'div');
  2270. 2268.  -         setStyle(bp, {marginLeft: linkW + 2});
  2271. 2269.  -         setStyle(tp, {marginLeft: linkW + 2});
  2272. 2270.  -       }
  2273. 2271.  -     });
  2274. 2272.  -   },
  2275. 2273.  -   likeOut: function() {
  2276. 2274.  -     var listId = cur.pvListId, index = cur.pvIndex, ph = cur.pvData[listId][index];
  2277. 2275.  -     if (!ph.liked) {
  2278. 2276.  -       setTimeout(animate.pbind(cur.pvLikeIcon, {opacity: 0.4}, 200, false), 1);
  2279. 2277.  -     }
  2280. 2278.  -   },
  2281. 2279.  -
  2282. 2280.  -   tagOver: function(el) {
  2283. 2281.  -     animate(el, {backgroundColor: '#6B8DB1'}, 200);
  2284. 2282.  -     showTooltip(el, {text: getLang('photos_delete_tag'), shift: [0, -2, 0]});
  2285. 2283.  -   },
  2286. 2284.  -   tagOut: function(el) {
  2287. 2285.  -     if (!el.parentNode || !el.parentNode.parentNode) return;
  2288. 2286.  -     animate(el, {backgroundColor: '#C4D2E1'}, 200);
  2289. 2287.  -   },
  2290. 2288.  -   deleteTag: function(tagId) {
  2291. 2289.  -     var listId = cur.pvListId, index = cur.pvIndex, ph = cur.pvData[listId][index];
  2292. 2290.  -     if (ph.tagid) {
  2293. 2291.  -       if (isVisible('pv_tag_handling')) return;
  2294. 2292.  -     } else {
  2295. 2293.  -       if (ge('pv_action_progress')) return;
  2296. 2294.  -     }
  2297. 2295.  -
  2298. 2296.  -     ajax.post('al_photos.php', {act: 'delete_tag', photo: ph.id, tag: tagId, hash: ph.hash}, {onDone: function(text, tags, tagged, html, padres) {
  2299. 2297.  -       if (_pads.shown == 'ph') {
  2300. 2298.  -         Pads.phDone(ph.id, false, padres);
  2301. 2299.  -       }
  2302. 2300.  -       Pads.invalidate('ph');
  2303. 2301.  -       if (ph.tagid) {
  2304. 2302.  -         ph.taginfo = ph.tagid = false;
  2305. 2303.  -         cleanElems('pv_confirm_tag', 'pv_delete_tag', 'pv_prof_cancel', 'pv_prof_done');
  2306. 2304.  -         cur.pvTagInfo.innerHTML = '<div class="progress fl_r" id="pv_spam_progress"></div><div class="pv_info">' + text + '</div>';
  2307. 2305.  -       } else {
  2308. 2306.  -         Photoview.actionInfo().innerHTML = text;
  2309. 2307.  -       }
  2310. 2308.  -       Photoview.updateHeight();
  2311. 2309.  -       if (tags !== undefined) {
  2312. 2310.  -         ph.tags = tags;
  2313. 2311.  -         ph.tagged = tagged;
  2314. 2312.  -         ph.tagshtml = html;
  2315. 2313.  -         if (cur.pvListId == listId && cur.pvIndex == index) {
  2316. 2314.  -           Photoview.setTags(html);
  2317. 2315.  -
  2318. 2316.  -           ((!ph.taginfo && ph.actions.tag && tags[0] < cur.pvMaxTags) ? show : hide)(cur.pvTagLink);
  2319. 2317.  -         }
  2320. 2318.  -       }
  2321. 2319.  -     }, onFail: function(text) {
  2322. 2320.  -       if (!text) return;
  2323. 2321.  -       Photoview.actionInfo().innerHTML = text;
  2324. 2322.  -       return true;
  2325. 2323.  -     }, showProgress: function() {
  2326. 2324.  -       if (ph.tagid) {
  2327. 2325.  -         hide(ge('pv_confirm_tag').parentNode, ge('pv_delete_tag').parentNode);
  2328. 2326.  -         show('pv_tag_handling');
  2329. 2327.  -       } else {
  2330. 2328.  -         Photoview.actionInfo().innerHTML = '<div id="pv_action_progress" class="progress" style="display: block"></div>';
  2331. 2329.  -       }
  2332. 2330.  -     }, hideProgress: function() {
  2333. 2331.  -       if (ph.tagid) {
  2334. 2332.  -         hide('pv_tag_handling');
  2335. 2333.  -         show(ge('pv_confirm_tag').parentNode, ge('pv_delete_tag').parentNode);
  2336. 2334.  -       } else {
  2337. 2335.  -         re(Photoview.actionInfo());
  2338. 2336.  -       }
  2339. 2337.  -     }});
  2340. 2338.  -   },
  2341. 2339.  -   restoreTag: function(tagId) {
  2342. 2340.  -     if (ge('pv_action_progress')) return;
  2343. 2341.  -
  2344. 2342.  -     var listId = cur.pvListId, index = cur.pvIndex, ph = cur.pvData[listId][index];
  2345. 2343.  -     ajax.post('al_photos.php', {act: 'restore_tag', photo: ph.id, tag: tagId, hash: ph.hash}, {onDone: function(text, tags, tagged, html) {
  2346. 2344.  -       if (tags !== undefined) {
  2347. 2345.  -         ph.tags = tags;
  2348. 2346.  -         ph.tagged = tagged;
  2349. 2347.  -         ph.tagshtml = html;
  2350. 2348.  -         if (cur.pvListId == listId && cur.pvIndex == index) {
  2351. 2349.  -           Photoview.setTags(html);
  2352. 2350.  -           ((!ph.taginfo && ph.actions.tag && tags[0] < cur.pvMaxTags) ? show : hide)(cur.pvTagLink);
  2353. 2351.  -         }
  2354. 2352.  -       }
  2355. 2353.  -       Photoview.actionInfo().innerHTML = text;
  2356. 2354.  -     }, onFail: function(text) {
  2357. 2355.  -       if (!text) return;
  2358. 2356.  -       Photoview.actionInfo().innerHTML = text;
  2359. 2357.  -       return true;
  2360. 2358.  -     }, showProgress: function() {
  2361. 2359.  -       Photoview.actionInfo().innerHTML = '<div id="pv_action_progress" class="progress" style="display: block"></div>';
  2362. 2360.  -     }, hideProgress: function() {
  2363. 2361.  -       re(Photoview.actionInfo());
  2364. 2362.  -     }});
  2365. 2363.  -   },
  2366. 2364.  -
  2367. 2365.  -   confirmTag: function(tagId) {
  2368. 2366.  -     var listId = cur.pvListId, index = cur.pvIndex, ph = cur.pvData[listId][index];
  2369. 2367.  -     if (isVisible('pv_tag_handling')) return;
  2370. 2368.  -
  2371. 2369.  -     ajax.post('al_photos.php', {act: 'confirm_tag', tag: tagId, photo: ph.id, hash: ph.hash}, {onDone: function(tags, tagged, html, padres) {
  2372. 2370.  -       if (_pads.shown == 'ph') {
  2373. 2371.  -         Pads.phDone(ph.id, false, padres);
  2374. 2372.  -       }
  2375. 2373.  -       Pads.invalidate('ph');
  2376. 2374.  -       ph.tags = tags;
  2377. 2375.  -       ph.tagged = tagged;
  2378. 2376.  -       ph.tagshtml = html;
  2379. 2377.  -       ph.taginfo = ph.tagid = false;
  2380. 2378.  -       if (listId == cur.pvListId && index == cur.pvIndex) {
  2381. 2379.  -         Photoview.setTags(html);
  2382. 2380.  -         ((!ph.taginfo && ph.actions.tag && tags[0] < cur.pvMaxTags) ? show : hide)(cur.pvTagLink);
  2383. 2381.  -         cleanElems('pv_confirm_tag', 'pv_delete_tag', 'pv_prof_cancel', 'pv_prof_done');
  2384. 2382.  -         cur.pvTagInfo.innerHTML = '';
  2385. 2383.  -         hide(cur.pvTagInfo);
  2386. 2384.  -       }
  2387. 2385.  -       Photoview.updateHeight();
  2388. 2386.  -     }, showProgress: function() {
  2389. 2387.  -       hide(ge('pv_confirm_tag').parentNode, ge('pv_delete_tag').parentNode);
  2390. 2388.  -       show('pv_tag_handling');
  2391. 2389.  -     }, hideProgress: function() {
  2392. 2390.  -       hide('pv_tag_handling');
  2393. 2391.  -       show(ge('pv_confirm_tag').parentNode, ge('pv_delete_tag').parentNode);
  2394. 2392.  -     }});
  2395. 2393.  -   },
  2396. 2394.  -
  2397. 2395.  -   toProfileTag: function() {
  2398. 2396.  -     var tag = cur.pvData[cur.pvListId][cur.pvIndex].tagged[vk.id];
  2399. 2397.  -     if (tag && !cur.pvTagger) {
  2400. 2398.  -       Photoview.showTag(tag);
  2401. 2399.  -     }
  2402. 2400.  -   },
  2403. 2401.  -   showTag: function(tagId) {
  2404. 2402.  -     clearTimeout(cur.pvHidingTag);
  2405. 2403.  -     if (cur.pvShowingTag == tagId) return;
  2406. 2404.  -
  2407. 2405.  -     var coords = clone(cur.pvData[cur.pvListId][cur.pvIndex].tags[tagId]);
  2408. 2406.  -     each(coords, function(i, v) {
  2409. 2407.  -       var wh = cur[(i % 2) ? 'pvPhHeight' : 'pvPhWidth'];
  2410. 2408.  -       coords[i] = Math.max(3, Math.min(wh - 3, positive(v * wh / 100)));
  2411. 2409.  -     });
  2412. 2410.  -     setStyle(cur.pvTagFrame, {
  2413. 2411.  -       marginLeft: coords[0] + 'px',
  2414. 2412.  -       marginTop: coords[1] + 'px',
  2415. 2413.  -       width: (coords[2] - coords[0]) + 'px',
  2416. 2414.  -       height: (coords[3] - coords[1]) + 'px'
  2417. 2415.  -     });
  2418. 2416.  -     setStyle(cur.pvTagFrame.firstChild, {
  2419. 2417.  -       marginLeft: -coords[0] + 'px',
  2420. 2418.  -       marginTop: -coords[1] + 'px'
  2421. 2419.  -     });
  2422. 2420.  -     cur.pvShowingTag = tagId;
  2423. 2421.  -     if (browser.msie) {
  2424. 2422.  -       show(cur.pvTagFrame, cur.pvTagFaded);
  2425. 2423.  -     } else {
  2426. 2424.  -       fadeIn(cur.pvTagFrame, 200);
  2427. 2425.  -       fadeIn(cur.pvTagFaded, 200);
  2428. 2426.  -     }
  2429. 2427.  -   },
  2430. 2428.  -   showDynTag: function(tagId) {
  2431. 2429.  -     clearTimeout(cur.pvHidingTag);
  2432. 2430.  -     if (cur.pvShowingTag == tagId) return;
  2433. 2431.  -
  2434. 2432.  -     var coords = clone(cur.pvData[cur.pvListId][cur.pvIndex].tags[tagId]), el = ge('pv_tag' + tagId);
  2435. 2433.  -     if (!el) return;
  2436. 2434.  -
  2437. 2435.  -     each(coords, function(i, v) {
  2438. 2436.  -       coords[i] = positive(v * cur[(i % 2) ? 'pvPhHeight' : 'pvPhWidth'] / 100);
  2439. 2437.  -     });
  2440. 2438.  -     setStyle(cur.pvTagPerson, {
  2441. 2439.  -       marginLeft: coords[0] + 'px',
  2442. 2440.  -       marginTop: coords[3] + 'px',
  2443. 2441.  -       minWidth: (coords[2] - coords[0]) + 'px'
  2444. 2442.  -     });
  2445. 2443.  -     cur.pvTagPerson.innerHTML = el.firstChild.innerHTML;
  2446. 2444.  -     var s = getSize(cur.pvTagPerson);
  2447. 2445.  -     if (coords[3] + s[1] > cur.pvPhHeight) {
  2448. 2446.  -       setStyle(cur.pvTagPerson, {marginTop: (cur.pvPhHeight - s[1]) + 'px'});
  2449. 2447.  -     }
  2450. 2448.  -     cur.pvTagPerson.onmouseover = Photoview.showDynTag.pbind(tagId);
  2451. 2449.  -     cur.pvShowingTag = tagId;
  2452. 2450.  -     if (browser.msie){
  2453. 2451.  -       show(cur.pvTagPerson);
  2454. 2452.  -     } else {
  2455. 2453.  -       fadeIn(cur.pvTagPerson, 200);
  2456. 2454.  -     }
  2457. 2455.  -   },
  2458. 2456.  -   hideTag: function(quick) {
  2459. 2457.  -     if (quick === true) {
  2460. 2458.  -       clearTimeout(cur.pvHidingTag);
  2461. 2459.  -       hide(cur.pvTagFaded, cur.pvTagFrame, cur.pvTagPerson);
  2462. 2460.  -       cur.pvShowingTag = false;
  2463. 2461.  -     }
  2464. 2462.  -     if (!cur.pvShowingTag) return;
  2465. 2463.  -
  2466. 2464.  -     clearTimeout(cur.pvHidingTag);
  2467. 2465.  -     cur.pvHidingTag = setTimeout(function() {
  2468. 2466.  -       if (browser.msie) {
  2469. 2467.  -         hide(cur.pvTagFaded, cur.pvTagFrame, cur.pvTagPerson);
  2470. 2468.  -       } else if (cur.pvShowingTag) {
  2471. 2469.  -         fadeOut(cur.pvTagFaded, 200);
  2472. 2470.  -         fadeOut(cur.pvTagFrame, 200);
  2473. 2471.  -         fadeOut(cur.pvTagPerson, 200);
  2474. 2472.  -       }
  2475. 2473.  -       cur.pvShowingTag = false;
  2476. 2474.  -     }, 0);
  2477. 2475.  -   },
  2478. 2476.  -   realOffset: function(listId, offset, inc) {
  2479. 2477.  -     var res = offset;
  2480. 2478.  -     if (!cur.pvData || !cur.pvData[listId]) {
  2481. 2479.  -       return res;
  2482. 2480.  -     }
  2483. 2481.  -     for (var i = 0; i < offset; i++) {
  2484. 2482.  -       if (cur.pvData[listId][i] && (cur.pvData[listId][i].deleted || cur.pvData[listId][i].moved)) {
  2485. 2483.  -         res += inc;
  2486. 2484.  -       }
  2487. 2485.  -     }
  2488. 2486.  -     return res;
  2489. 2487.  -   },
  2490. 2488.  -   realCount: function(listId, count) {
  2491. 2489.  -     var res = count;
  2492. 2490.  -     if (!cur.pvData || !cur.pvData[listId]) {
  2493. 2491.  -       return res;
  2494. 2492.  -     }
  2495. 2493.  -     for (var i = 0; i < cur.pvData[listId].length; i++) {
  2496. 2494.  -       if (cur.pvData[listId][i] && (cur.pvData[listId][i].deleted || cur.pvData[listId][i].moved)) {
  2497. 2495.  -         res++;
  2498. 2496.  -       }
  2499. 2497.  -     }
  2500. 2498.  -     return res;
  2501. 2499.  -   },
  2502. 2500.  -
  2503. 2501.  -   list: function(photoId, listId, realList) {
  2504. 2502.  -     if (realList == 'deleted') return;
  2505. 2503.  -     if (!cur.pvList) cur.pvList = {};
  2506. 2504.  -     cur.pvList[photoId + '_' + listId] = realList;
  2507. 2505.  -   },
  2508. 2506.  -   loaded: function(listId, count, offset, data, opts) {
  2509. 2507.  -     if (listId == 'deleted') return;
  2510. 2508.  -     if (opts) {
  2511. 2509.  -       extend(cur, {
  2512. 2510.  -         lang: extend(cur.lang || {}, opts.lang),
  2513. 2511.  -         pvHash: opts.hash,
  2514. 2512.  -         pvCommLimit: opts.commlimit,
  2515. 2513.  -         pvMaxTags: opts.maxtags,
  2516. 2514.  -         pvReplyNames: extend(cur.pvReplyNames || {}, opts.names || {}),
  2517. 2515.  -         pvMediaTypes: opts.media
  2518. 2516.  -       });
  2519. 2517.  -       if (!cur.options) cur.options = {};
  2520. 2518.  -       if (!cur.options.share) cur.options.share = opts.share;
  2521. 2519.  -       val(cur.pvAsGroup, '<div></div>' + getLang('wall_reply_as_group'));
  2522. 2520.  -       val('pv_comment_header', getLang('photos_yourcomment'));
  2523. 2521.  -       val(domFC(ge('pv_add_media')), getLang('global_add_media'));
  2524. 2522.  -     }
  2525. 2523.  -     count = Photoview.realCount(listId, count);
  2526. 2524.  -     offset = Photoview.realOffset(listId, offset, 1);
  2527. 2525.  -     if (!cur.pvData) cur.pvData = {};
  2528. 2526.  -     if (!cur.pvCommsLikes) cur.pvCommsLikes = {};
  2529. 2527.  -     if (!cur.pvData[listId]) {
  2530. 2528.  -       cur.pvData[listId] = new Array(count);
  2531. 2529.  -     } else if (cur.pvData[listId].length < count) {
  2532. 2530.  -       for (var i = cur.pvData[listId].length; i < count; ++i) {
  2533. 2531.  -         cur.pvData[listId].push(undefined);
  2534. 2532.  -       }
  2535. 2533.  -     } else if (cur.pvData[listId].length > count) {
  2536. 2534.  -       cur.pvData[listId] = cur.pvData[listId].slice(0, count);
  2537. 2535.  -     }
  2538. 2536.  -     var nw = vkNow();
  2539. 2537.  -     for (var i = 0, len = data.length; i < len; ++i) {
  2540. 2538.  -       var index = (offset + i), ph = clone(data[i]);
  2541. 2539.  -       while (index >= count) index -= count;
  2542. 2540.  -       cur.pvCommsLikes[ph.id] = [ph.comments, ph.likes, vkNow(), false];
  2543. 2541.  -       delete(ph.comments);
  2544. 2542.  -       delete(ph.likes);
  2545. 2543.  -       cur.pvData[listId][index] = ph;
  2546. 2544.  -     }
  2547. 2545.  -   },
  2548. 2546.  -   showDeleted: function(lst, msg, spm) {
  2549. 2547.  -     if (cur.pvShown && cur.pvListId == 'temp') {
  2550. 2548.  -       msg += '<br><br>' + spm;
  2551. 2549.  -     }
  2552. 2550.  -
  2553. 2551.  -     showFastBox({title: getLang('global_error'), onHide: function() {
  2554. 2552.  -       if (cur.pvShown && cur.pvListId == 'temp') {
  2555. 2553.  -         Photoview.hide(true);
  2556. 2554.  -       }
  2557. 2555.  -     }}, msg);
  2558. 2556.  -   },
  2559. 2557.  -   spamDeleted: function(el, ph, hash) {
  2560. 2558.  -     if (isVisible(curBox().progress)) return;
  2561. 2559.  -     ajax.post('al_photos.php', {act: 'spam_photo', photo: ph, hash: hash, from: 'deleted'}, {onDone: function(text) {
  2562. 2560.  -       domPN(el).replaceChild(ce('span', {innerHTML: text}), el);
  2563. 2561.  -     }, showProgress: curBox().showProgress, hideProgress: curBox().hideProgress});
  2564. 2562.  -   },
  2565. 2563.  -   showPhoto: function(photoId, listId, options, just) {
  2566. 2564.  -     if (!cur.pvShown || cur.pvListId == 'temp' && !cur.pvWasShown || options.noHistory !== undefined) {
  2567. 2565.  -       debugLog('in showPhoto noHistory: ' + options.noHistory);
  2568. 2566.  -       cur.pvNoHistory = options.noHistory;
  2569. 2567.  -       cur.pvHistoryLength = options.noHistory ? 0 : (options.histLen || 0);
  2570. 2568.  -     }
  2571. 2569.  -     extend(cur, {
  2572. 2570.  -       pvJumpTo: options.jumpTo || false,
  2573. 2571.  -       pvJumpFrom: false,
  2574. 2572.  -       pvJumpSteps: 0
  2575. 2573.  -     });
  2576. 2574.  -     listId = cur.pvList && cur.pvList[photoId + '_' + listId] || listId;
  2577. 2575.  -     if (!cur.pvData || !cur.pvData[listId]) {
  2578. 2576.  -       return;
  2579. 2577.  -     }
  2580. 2578.  -     var data = cur.pvData[listId], whole = true, onh = cur.pvOptions && cur.pvOptions.onHide;
  2581. 2579.  -     cur.pvOptions = options;
  2582. 2580.  -     if (!cur.pvOptions.onHide) cur.pvOptions.onHide = onh;
  2583. 2581.  -     for (var i = 0, len = data.length; i < len; ++i) {
  2584. 2582.  -       if (data[i]) {
  2585. 2583.  -         if (data[i].id === photoId) {
  2586. 2584.  -           Photoview.show(listId, i, false, options.root);
  2587. 2585.  -           if (options.onShow) {
  2588. 2586.  -             options.onShow();
  2589. 2587.  -           }
  2590. 2588.  -           return false;
  2591. 2589.  -         }
  2592. 2590.  -       } else {
  2593. 2591.  -         whole = false;
  2594. 2592.  -       }
  2595. 2593.  -     }
  2596. 2594.  -     if (whole && just) {
  2597. 2595.  -       if (options.onEmpty) {
  2598. 2596.  -         options.onEmpty();
  2599. 2597.  -       }
  2600. 2598.  -       return false;
  2601. 2599.  -     }
  2602. 2600.  -   },
  2603. 2601.  -
  2604. 2602.  -   loadedAlbums: function(ownerId, html, preload, preloadPhotos, opts) {
  2605. 2603.  -     if (!cur.pvAlbumsData) return;
  2606. 2604.  -
  2607. 2605.  -     ajax.preload('al_photos.php', extend({offset: opts.offset, part: 1, owner: ownerId}, {act: 'show_albums'}), preload);
  2608. 2606.  -     ajax.preload('al_photos.php', extend({offset: opts.photos_offset, part: 1, owner: ownerId}, {act: 'show_albums', only_photos: 1}), preloadPhotos);
  2609. 2607.  -
  2610. 2608.  -     cur.pvAlbumsData[ownerId] = {
  2611. 2609.  -       html: html,
  2612. 2610.  -       opts: opts
  2613. 2611.  -     };
  2614. 2612.  -     if (cur.pvAlbumsShowing == ownerId) {
  2615. 2613.  -       Photoview.doShowAlbums(ownerId, false);
  2616. 2614.  -       boxRefreshCoords(layer);
  2617. 2615.  -     }
  2618. 2616.  -   },
  2619. 2617.  -   showAlbums: function(ownerId, options) {
  2620. 2618.  -     ownerId = intval(ownerId);
  2621. 2619.  -     if (!cur.pvAlbumsData) cur.pvAlbumsData = {};
  2622. 2620.  -     if (cur.pvListId == 'temp') {
  2623. 2621.  -       cur.pvCancelLoad();
  2624. 2622.  -     }
  2625. 2623.  -
  2626. 2624.  -     cur.pvNoHistory = options.noHistory;
  2627. 2625.  -     cur.pvHistoryLength = 0;
  2628. 2626.  -     cur.pvAlbumsShowing = ownerId;
  2629. 2627.  -     var of = options.onFail;
  2630. 2628.  -     if (!cur.pvAlbumsData[ownerId]) {
  2631. 2629.  -       cur.pvAlbumsData[ownerId] = 'loading';
  2632. 2630.  -       ajax.post('al_photos.php', {act: 'show_albums', owner: ownerId}, extend(options, {onDone: Photoview.loadedAlbums, onFail: function(t) {
  2633. 2631.  -           if (of) of(t);
  2634. 2632.  -           delete(cur.pvAlbumsData[ownerId]);
  2635. 2633.  -           cur.pvAlbumsData[ownerId];
  2636. 2634.  -           layers.fullhide(true);
  2637. 2635.  -           return true;
  2638. 2636.  -         }
  2639. 2637.  -       }));
  2640. 2638.  -     } else if (cur.pvAlbumsData[ownerId] != 'loading') {
  2641. 2639.  -       Photoview.doShowAlbums(ownerId, false);
  2642. 2640.  -       boxRefreshCoords(layer);
  2643. 2641.  -     }
  2644. 2642.  -   },
  2645. 2643.  -   loadedAlbum: function(albumRaw, html, preload, opts) {
  2646. 2644.  -     if (!cur.pvAlbumData) return;
  2647. 2645.  -
  2648. 2646.  -     if (preload) {
  2649. 2647.  -       ajax.preload('al_photos.php', extend({offset: opts.offset, part: 1, album: albumRaw}, {act: 'show_album'}), preload);
  2650. 2648.  -     }
  2651. 2649.  -
  2652. 2650.  -     cur.pvAlbumData[albumRaw] = {
  2653. 2651.  -       html: html,
  2654. 2652.  -       opts: opts
  2655. 2653.  -     };
  2656. 2654.  -     if (cur.pvAlbumShowing == albumRaw) {
  2657. 2655.  -       Photoview.doShowAlbum(albumRaw, false);
  2658. 2656.  -       boxRefreshCoords(layer);
  2659. 2657.  -     }
  2660. 2658.  -   },
  2661. 2659.  -   showAlbum: function(albumRaw, options) {
  2662. 2660.  -     if (!cur.pvAlbumData) cur.pvAlbumData = {};
  2663. 2661.  -     if (cur.pvListId == 'temp') {
  2664. 2662.  -       cur.pvCancelLoad();
  2665. 2663.  -     }
  2666. 2664.  -
  2667. 2665.  -     cur.pvNoHistory = options.noHistory;
  2668. 2666.  -     cur.pvHistoryLength = 0;
  2669. 2667.  -     cur.pvAlbumShowing = albumRaw;
  2670. 2668.  -     var of = options.onFail;
  2671. 2669.  -     if (!cur.pvAlbumData[albumRaw]) {
  2672. 2670.  -       cur.pvAlbumData[albumRaw] = 'loading';
  2673. 2671.  -       ajax.post('al_photos.php', {act: 'show_album', album: albumRaw}, extend(options, {onDone: Photoview.loadedAlbum, onFail: function(t) {
  2674. 2672.  -           if (of) of(t);
  2675. 2673.  -           delete(cur.pvAlbumData[albumRaw]);
  2676. 2674.  -           cur.pvAlbumData[albumRaw];
  2677. 2675.  -           layers.fullhide(true);
  2678. 2676.  -           return true;
  2679. 2677.  -         }
  2680. 2678.  -       }));
  2681. 2679.  -     } else if (cur.pvAlbumData[albumRaw] != 'loading') {
  2682. 2680.  -       Photoview.doShowAlbum(albumRaw, false);
  2683. 2681.  -       boxRefreshCoords(layer);
  2684. 2682.  -     }
  2685. 2683.  -   },
  2686. 2684.  -   loadedTagged: function(ownerId, html, preload, preloadPhotos, opts) {
  2687. 2685.  -     if (!cur.pvPhotoTagData) return;
  2688. 2686.  -
  2689. 2687.  -     ajax.preload('al_photos.php', extend({offset: opts.offset, part: 1, owner: ownerId}, {act: 'show_tag'}), preload);
  2690. 2688.  -     ajax.preload('al_photos.php', extend({offset: opts.photos_offset, part: 1, owner: ownerId}, {act: 'show_tag', only_photos: 1}), preloadPhotos);
  2691. 2689.  -
  2692. 2690.  -     cur.pvPhotoTagData[ownerId] = {
  2693. 2691.  -       html: html,
  2694. 2692.  -       opts: opts
  2695. 2693.  -     };
  2696. 2694.  -     if (cur.pvPhotoTagShowing == ownerId) {
  2697. 2695.  -       Photoview.doShowTagged(ownerId, false);
  2698. 2696.  -       boxRefreshCoords(layer);
  2699. 2697.  -     }
  2700. 2698.  -   },
  2701. 2699.  -   showTagged: function(ownerId, options) {
  2702. 2700.  -     ownerId = intval(ownerId);
  2703. 2701.  -     if (!cur.pvPhotoTagData) cur.pvPhotoTagData = {};
  2704. 2702.  -     if (cur.pvListId == 'temp') {
  2705. 2703.  -       cur.pvCancelLoad();
  2706. 2704.  -     }
  2707. 2705.  -
  2708. 2706.  -     cur.pvNoHistory = options.noHistory;
  2709. 2707.  -     cur.pvHistoryLength = 0;
  2710. 2708.  -     cur.pvPhotoTagShowing = ownerId;
  2711. 2709.  -     var of = options.onFail;
  2712. 2710.  -     if (!cur.pvPhotoTagData[ownerId]) {
  2713. 2711.  -       cur.pvPhotoTagData[ownerId] = 'loading';
  2714. 2712.  -       ajax.post('al_photos.php', {act: 'show_tag', mid: ownerId}, extend(options, {onDone: Photoview.loadedTagged, onFail: function(t) {
  2715. 2713.  -           if (of) of(t);
  2716. 2714.  -           delete(cur.pvPhotoTagData[ownerId]);
  2717. 2715.  -           cur.pvPhotoTagData[ownerId];
  2718. 2716.  -           layers.fullhide(true);
  2719. 2717.  -           return true;
  2720. 2718.  -         }
  2721. 2719.  -       }));
  2722. 2720.  -     } else if (cur.pvPhotoTagData[ownerId] != 'loading') {
  2723. 2721.  -       Photoview.doShowTagged(ownerId, false);
  2724. 2722.  -       boxRefreshCoords(layer);
  2725. 2723.  -     }
  2726. 2724.  -   },
  2727. 2725.  -   loadedVideoTags: function(ownerId, html, preload, opts) {
  2728. 2726.  -     ajax.preload('/al_video.php', {act: 'show_video_tags', offset: opts.offset, part: 1, mid: ownerId}, preload);
  2729. 2727.  -
  2730. 2728.  -     cur.pvVideoTagsData = {
  2731. 2729.  -       html: html,
  2732. 2730.  -       opts: opts
  2733. 2731.  -     };
  2734. 2732.  -     if (cur.pvVideoTagShowing == ownerId) {
  2735. 2733.  -       Photoview.doShowVideoTags(ownerId, false);
  2736. 2734.  -       boxRefreshCoords(layer);
  2737. 2735.  -     }
  2738. 2736.  -   },
  2739. 2737.  -   showVideoTags: function(ownerId, options) {
  2740. 2738.  -     cur.pvNoHistory = options.noHistory;
  2741. 2739.  -     cur.pvHistoryLength = 0;
  2742. 2740.  -     cur.pvVideoTagShowing = ownerId;
  2743. 2741.  -     var of = options.onFail;
  2744. 2742.  -     if (!cur.pvVideoTagsData) {
  2745. 2743.  -       cur.pvVideoTagsData = 'loading';
  2746. 2744.  -       ajax.post('/al_video.php', {act: 'show_video_tags', mid: ownerId}, extend(options, {onDone: Photoview.loadedVideoTags, onFail: function(t) {
  2747. 2745.  -           if (of) of(t);
  2748. 2746.  -           delete(cur.pvVideoTagsData);
  2749. 2747.  -           layers.fullhide && layers.fullhide(true);
  2750. 2748.  -           return true;
  2751. 2749.  -         }
  2752. 2750.  -       }));
  2753. 2751.  -     } else if (cur.pvVideoTagsData != 'loading') {
  2754. 2752.  -       Photoview.doShowVideoTags(ownerId, false);
  2755. 2753.  -       boxRefreshCoords(layer);
  2756. 2754.  -     }
  2757. 2755.  -   },
  2758. 2756.  -   scrollResize: function() {
  2759. 2757.  -     if (browser.mobile || !cur.pvShown || (!cur.pvAlbumsShown && !cur.pvAlbumShown && !cur.pvPhotoTagShown && !cur.pvVideoTagsShown)) return;
  2760. 2758.  -
  2761. 2759.  -     var bt = lastWindowHeight,
  2762. 2760.  -         lnk = cur.pvVideoTagsShown ? ge('pva_more_videos') : (cur.pvAlbumsShown ? ge('pva_more_photos') : ge('pvsa_more_photos')),
  2763. 2761.  -         albumsLnk = ge('pva_more');
  2764. 2762.  -
  2765. 2763.  -     if (isVisible(lnk) && bt > getXY(lnk)[1] - (browser.msie6 ? 0 : scrollGetY())) {
  2766. 2764.  -       if (cur.pvVideoTagsShown) {
  2767. 2765.  -         Photoview.loadVideoTags();
  2768. 2766.  -       } else if (cur.pvPhotoTagShown) {
  2769. 2767.  -         Photoview.loadTaggedPhotos();
  2770. 2768.  -       } else if (cur.pvAlbumsShown) {
  2771. 2769.  -         Photoview.loadAlbumsPhotos();
  2772. 2770.  -       } else {
  2773. 2771.  -         Photoview.loadAlbumPhotos();
  2774. 2772.  -       }
  2775. 2773.  -     }
  2776. 2774.  -     if (cur.pvAlbumsShown && cur.pvShowAllAlbums && isVisible(albumsLnk) && bt > getXY(albumsLnk)[1] - (browser.msie6 ? 0 : scrollGetY())) {
  2777. 2775.  -       Photoview.loadAlbums();
  2778. 2776.  -     }
  2779. 2777.  -   },
  2780. 2778.  -   loadAlbums: function() {
  2781. 2779.  -     cur.pvShowAllAlbums = true;
  2782. 2780.  -     Photoview.loadAlbumsPhotos(true);
  2783. 2781.  -   },
  2784. 2782.  -   loadedAlbumsPhotos: function(off, rows, albums) {
  2785. 2783.  -     cur.pvaLoading = 0;
  2786. 2784.  -
  2787. 2785.  -     if (!cur.pvAlbumsShown) return;
  2788. 2786.  -
  2789. 2787.  -     if (albums) {
  2790. 2788.  -       cur.pvaOffset = off;
  2791. 2789.  -     } else {
  2792. 2790.  -       cur.pvaPhotosOffset = off;
  2793. 2791.  -     }
  2794. 2792.  -
  2795. 2793.  -     var cont = albums ? ge('pva_content') : ge('pva_content_photos'),
  2796. 2794.  -         more = albums ? ge('pva_more') : ge('pva_more_photos'),
  2797. 2795.  -         opts = albums ? {act: 'show_albums'} : {act: 'show_albums', only_photos: 1},
  2798. 2796.  -         offset = albums ? cur.pvaOffset : cur.pvaPhotosOffset,
  2799. 2797.  -         count = albums ? cur.pvaCount : cur.pvaPhotosCount,
  2800. 2798.  -         d = ce('div', {innerHTML: rows});
  2801. 2799.  -     if (!cont) return;
  2802. 2800.  -
  2803. 2801.  -     while (d.firstChild) {
  2804. 2802.  -       cont.appendChild(d.firstChild);
  2805. 2803.  -     }
  2806. 2804.  -
  2807. 2805.  -     Photoview.onResize();
  2808. 2806.  -
  2809. 2807.  -     if (off >= count || !rows) {
  2810. 2808.  -       hide(more);
  2811. 2809.  -       return;
  2812. 2810.  -     }
  2813. 2811.  -     cur.pvaLoading = 1;
  2814. 2812.  -
  2815. 2813.  -     ajax.post('al_photos.php', extend({offset: offset, part: 1, owner: cur.pvAlbumsShown}, opts || {}), {cache: 1, onDone: function() {
  2816. 2814.  -       debugLog('preload done: ' + cur.pvaLoading);
  2817. 2815.  -       if (cur.pvaLoading == 2) {
  2818. 2816.  -         Photoview.loadedAlbumsPhotos.apply(window, arguments);
  2819. 2817.  -       } else {
  2820. 2818.  -         cur.pvaLoading = false;
  2821. 2819.  -       }
  2822. 2820.  -     }, onFail: function() {
  2823. 2821.  -       cur.pvaLoading = 0;
  2824. 2822.  -       return true;
  2825. 2823.  -     }});
  2826. 2824.  -   },
  2827. 2825.  -   loadAlbumsPhotos: function(albums) {
  2828. 2826.  -     var more = albums ? ge('pva_more') : ge('pva_more_photos'),
  2829. 2827.  -         progress = albums ? ge('pva_more_prg') : ge('pva_more_photos_prg'),
  2830. 2828.  -         opts = albums ? {act: 'show_albums'} : {act: 'show_albums', only_photos: 1},
  2831. 2829.  -         offset = albums ? cur.pvaOffset : cur.pvaPhotosOffset;
  2832. 2830.  -     if (!cur.pvAlbumsShown || !more || !isVisible(more) || isVisible(progress)) return;
  2833. 2831.  -
  2834. 2832.  -     if (cur.pvaLoading) {
  2835. 2833.  -       cur.pvaLoading = 2;
  2836. 2834.  -       return;
  2837. 2835.  -     }
  2838. 2836.  -
  2839. 2837.  -     ajax.post('al_photos.php', extend({offset: offset, part: 1, owner: cur.pvAlbumsShown}, opts || {}), {onDone: Photoview.loadedAlbumsPhotos, onFail: function() {
  2840. 2838.  -       cur.pvaLoading = 0;
  2841. 2839.  -       return true;
  2842. 2840.  -     }, showProgress: function() {
  2843. 2841.  -       show(progress);
  2844. 2842.  -       hide(more.firstChild);
  2845. 2843.  -     }, hideProgress: function() {
  2846. 2844.  -       show(more.firstChild);
  2847. 2845.  -       hide(progress);
  2848. 2846.  -     }, cache: 1});
  2849. 2847.  -   },
  2850. 2848.  -   loadedAlbumPhotos: function(off, rows) {
  2851. 2849.  -     cur.pvaLoading = 0;
  2852. 2850.  -
  2853. 2851.  -     if (!cur.pvAlbumShown) return;
  2854. 2852.  -
  2855. 2853.  -     cur.pvsaOffset = off;
  2856. 2854.  -
  2857. 2855.  -     var cont = ge('pvsa_content_photos'),
  2858. 2856.  -         more = ge('pvsa_more_photos');
  2859. 2857.  -     if (!cont) return;
  2860. 2858.  -
  2861. 2859.  -     cont.appendChild(cf(rows));
  2862. 2860.  -
  2863. 2861.  -     if (off >= cur.pvsaCount) {
  2864. 2862.  -       hide(more);
  2865. 2863.  -       Photoview.onResize();
  2866. 2864.  -       return;
  2867. 2865.  -     }
  2868. 2866.  -
  2869. 2867.  -     Photoview.onResize();
  2870. 2868.  -     cur.pvsaLoading = 1;
  2871. 2869.  -
  2872. 2870.  -     ajax.post('al_photos.php', extend({offset: cur.pvsaOffset, part: 1, album: cur.pvAlbumShown}, {act: 'show_album'}), {cache: 1, onDone: function() {
  2873. 2871.  -       debugLog('preload done: ', cur.pvsaLoading);
  2874. 2872.  -       if (cur.pvsaLoading == 2) {
  2875. 2873.  -         Photoview.loadedAlbumPhotos.apply(window, arguments);
  2876. 2874.  -       } else {
  2877. 2875.  -         cur.pvsaLoading = false;
  2878. 2876.  -       }
  2879. 2877.  -     }, onFail: function() {
  2880. 2878.  -       cur.pvsaLoading = 0;
  2881. 2879.  -       return true;
  2882. 2880.  -     }});
  2883. 2881.  -   },
  2884. 2882.  -   loadAlbumPhotos: function() {
  2885. 2883.  -     var more = ge('pvsa_more_photos'),
  2886. 2884.  -         progress = ge('pvsa_more_photos_prg'),
  2887. 2885.  -         offset = cur.pvsaOffset;
  2888. 2886.  -     if (!cur.pvAlbumShown || !more || !isVisible(more) || isVisible(progress)) return;
  2889. 2887.  -
  2890. 2888.  -     if (cur.pvsaLoading) {
  2891. 2889.  -       cur.pvsaLoading = 2;
  2892. 2890.  -       return;
  2893. 2891.  -     }
  2894. 2892.  -
  2895. 2893.  -     ajax.post('al_photos.php', {act: 'show_album', album: cur.pvAlbumShown, offset: offset, part: 1}, {onDone: Photoview.loadedAlbumPhotos, onFail: function() {
  2896. 2894.  -       cur.pvsaLoading = 0;
  2897. 2895.  -       return true;
  2898. 2896.  -     }, showProgress: function() {
  2899. 2897.  -       show(progress);
  2900. 2898.  -       hide(more.firstChild);
  2901. 2899.  -     }, hideProgress: function() {
  2902. 2900.  -       show(more.firstChild);
  2903. 2901.  -       hide(progress);
  2904. 2902.  -     }, cache: 1});
  2905. 2903.  -   },
  2906. 2904.  -   loadedTaggedPhotos: function(off, rows) {
  2907. 2905.  -     cur.pvaLoading = 0;
  2908. 2906.  -
  2909. 2907.  -     if (!cur.pvPhotoTagShown) return;
  2910. 2908.  -
  2911. 2909.  -     cur.pvsaOffset = off;
  2912. 2910.  -
  2913. 2911.  -     var cont = ge('pvsa_content_photos'),
  2914. 2912.  -         more = ge('pvsa_more_photos');
  2915. 2913.  -     if (!cont) return;
  2916. 2914.  -
  2917. 2915.  -     cont.appendChild(cf(rows));
  2918. 2916.  -
  2919. 2917.  -     Photoview.onResize();
  2920. 2918.  -
  2921. 2919.  -     if (off >= cur.pvsaCount || !rows) {
  2922. 2920.  -       hide(more);
  2923. 2921.  -       return;
  2924. 2922.  -     }
  2925. 2923.  -     cur.pvsaLoading = 1;
  2926. 2924.  -
  2927. 2925.  -     ajax.post('al_photos.php', extend({offset: cur.pvsaOffset, part: 1, mid: cur.pvPhotoTagShown}, {act: 'show_tag'}), {cache: 1, onDone: function() {
  2928. 2926.  -       debugLog('preload done: ', cur.pvsaLoading);
  2929. 2927.  -       if (cur.pvsaLoading == 2) {
  2930. 2928.  -         Photoview.loadedTaggedPhotos.apply(window, arguments);
  2931. 2929.  -       } else {
  2932. 2930.  -         cur.pvsaLoading = false;
  2933. 2931.  -       }
  2934. 2932.  -     }, onFail: function() {
  2935. 2933.  -       cur.pvsaLoading = 0;
  2936. 2934.  -       return true;
  2937. 2935.  -     }});
  2938. 2936.  -   },
  2939. 2937.  -   loadTaggedPhotos: function(albums) {
  2940. 2938.  -     var more = ge('pvsa_more_photos'),
  2941. 2939.  -         progress = ge('pvsa_more_photos_prg'),
  2942. 2940.  -         offset = cur.pvsaOffset;
  2943. 2941.  -     if (!cur.pvPhotoTagShown || !more || !isVisible(more) || isVisible(progress)) return;
  2944. 2942.  -
  2945. 2943.  -     if (cur.pvsaLoading) {
  2946. 2944.  -       cur.pvsaLoading = 2;
  2947. 2945.  -       return;
  2948. 2946.  -     }
  2949. 2947.  -
  2950. 2948.  -     ajax.post('al_photos.php', {act: 'show_tag', mid: cur.pvPhotoTagShown, offset: offset, part: 1}, {onDone: Photoview.loadedTaggedPhotos, onFail: function() {
  2951. 2949.  -       cur.pvsaLoading = 0;
  2952. 2950.  -       return true;
  2953. 2951.  -     }, showProgress: function() {
  2954. 2952.  -       show(progress);
  2955. 2953.  -       hide(more.firstChild);
  2956. 2954.  -     }, hideProgress: function() {
  2957. 2955.  -       show(more.firstChild);
  2958. 2956.  -       hide(progress);
  2959. 2957.  -     }, cache: 1});
  2960. 2958.  -   },
  2961. 2959.  -   loadedMoreVideoTags: function(off, rows) {
  2962. 2960.  -     cur.pvaLoading = 0;
  2963. 2961.  -
  2964. 2962.  -     if (!cur.pvVideoTagsShown) return;
  2965. 2963.  -
  2966. 2964.  -     cur.pvsaOffset = off;
  2967. 2965.  -
  2968. 2966.  -     var cont = ge('pva_video_tags'),
  2969. 2967.  -         more = ge('pva_more_videos');
  2970. 2968.  -     if (!cont) return;
  2971. 2969.  -
  2972. 2970.  -     cont.appendChild(cf(rows));
  2973. 2971.  -
  2974. 2972.  -     Photoview.onResize();
  2975. 2973.  -
  2976. 2974.  -     if (off >= cur.pvsaCount || !rows) {
  2977. 2975.  -       hide(more);
  2978. 2976.  -       return;
  2979. 2977.  -     }
  2980. 2978.  -     cur.pvsaLoading = 1;
  2981. 2979.  -
  2982. 2980.  -     ajax.post('/al_video.php', extend({act: 'show_video_tags', offset: cur.pvsaOffset, part: 1, mid: cur.pvVideoTagsShown}), {cache: 1, onDone: function() {
  2983. 2981.  -       debugLog('preload done: ', cur.pvsaLoading);
  2984. 2982.  -       if (cur.pvsaLoading == 2) {
  2985. 2983.  -         Photoview.loadedMoreVideoTags.apply(window, arguments);
  2986. 2984.  -       } else {
  2987. 2985.  -         cur.pvsaLoading = false;
  2988. 2986.  -       }
  2989. 2987.  -     }, onFail: function() {
  2990. 2988.  -       cur.pvsaLoading = 0;
  2991. 2989.  -       return true;
  2992. 2990.  -     }});
  2993. 2991.  -   },
  2994. 2992.  -   loadVideoTags: function(albums) {
  2995. 2993.  -     var more = ge('pva_more_videos'),
  2996. 2994.  -         progress = ge('pva_more_videos_prg'),
  2997. 2995.  -         offset = cur.pvsaOffset;
  2998. 2996.  -     if (!cur.pvVideoTagsShown || !more || !isVisible(more) || isVisible(progress)) return;
  2999. 2997.  -
  3000. 2998.  -     if (cur.pvsaLoading) {
  3001. 2999.  -       cur.pvsaLoading = 2;
  3002. 3000.  -       return;
  3003. 3001.  -     }
  3004. 3002.  -
  3005. 3003.  -     ajax.post('/al_video.php', {act: 'show_video_tags', mid: cur.pvVideoTagsShown, offset: offset, part: 1}, {onDone: Photoview.loadedMoreVideoTags, onFail: function() {
  3006. 3004.  -       cur.pvsaLoading = 0;
  3007. 3005.  -       return true;
  3008. 3006.  -     }, showProgress: function() {
  3009. 3007.  -       show(progress);
  3010. 3008.  -       hide(more.firstChild);
  3011. 3009.  -     }, hideProgress: function() {
  3012. 3010.  -       show(more.firstChild);
  3013. 3011.  -       hide(progress);
  3014. 3012.  -     }, cache: 1});
  3015. 3013.  -   },
  3016. 3014.  -   thumbOver: function(obj, id) {
  3017. 3015.  -     clearTimeout((cur.pvHideTO || {})[id]);
  3018. 3016.  -     var title = geByClass1('pva_title', obj), r = title.previousSibling, descY = getSize(geByClass1('pva_desc', obj))[1];
  3019. 3017.  -     if (descY < 5) return;
  3020. 3018.  -
  3021. 3019.  -     animate(title, {marginTop: 238 - (descY + 7)}, {duration: 200, transition: Fx.Transitions.easeOutCirc});
  3022. 3020.  -     if (r.className == 'pva_repeat') {
  3023. 3021.  -       animate(r, {marginTop: 86 - Math.floor((descY + 7) / 2)}, {duration: 200, transition: Fx.Transitions.easeOutCirc});
  3024. 3022.  -     }
  3025. 3023.  -   },
  3026. 3024.  -   thumbOut: function(obj, id) {
  3027. 3025.  -     if (!cur.pvHideTO) cur.pvHideTO = {};
  3028. 3026.  -     cur.pvHideTO[id] = setTimeout(function() {
  3029. 3027.  -       var title = geByClass1('pva_title', obj), r = title.previousSibling;
  3030. 3028.  -       animate(title, {marginTop: 238}, 200);
  3031. 3029.  -       if (r.className == 'pva_repeat') {
  3032. 3030.  -         animate(r, {marginTop: 86}, 200);
  3033. 3031.  -       }
  3034. 3032.  -     }, 150);
  3035. 3033.  -   },
  3036. 3034.  -
  3037. 3035.  -   photoAct: function(ev) {
  3038. 3036.  -     if (cur.pvAlbumsShown || cur.pvAlbumShown || cur.pvPhotoTagShown || !cur.pvCurPhoto.author) return;
  3039. 3037.  -
  3040. 3038.  -     var pos = getXY(cur.pvHH, true);
  3041. 3039.  -     if (pos[0]) {
  3042. 3040.  -       cur.hhPos = pos;
  3043. 3041.  -     } else {
  3044. 3042.  -       pos = cur.hhPos;
  3045. 3043.  -     }
  3046. 3044.  -
  3047. 3045.  -     var next = cur.pvHH;
  3048. 3046.  -
  3049. 3047.  -     var dx = Math.abs(ev.clientX - pos[0] - 36);
  3050. 3048.  -     var dy = ev.clientY - pos[1];
  3051. 3049.  -
  3052. 3050.  -     if (dx < 120 && dy < 130 && dy > -30) {
  3053. 3051.  -       if (cur.pvHHShowing) return;
  3054. 3052.  -       cur.pvHHShowing = true;
  3055. 3053.  -       show(next);
  3056. 3054.  -       animate(next.firstChild, {opacity: 1}, 400);
  3057. 3055.  -
  3058. 3056.  -       if (!cur.rvPreloadBig) {
  3059. 3057.  -         vkImage().src = '/images/icons/post_big_hh.png';
  3060. 3058.  -         cur.rvPreloadBig = true;
  3061. 3059.  -       }
  3062. 3060.  -     } else {
  3063. 3061.  -       if (!cur.pvHHShowing) return;
  3064. 3062.  -       cur.pvHHShowing = false;
  3065. 3063.  -       animate(next.firstChild, {opacity: 0}, 400);
  3066. 3064.  -     }
  3067. 3065.  -
  3068. 3066.  -   },
  3069. 3067.  -
  3070. 3068.  -   hhLiked: function(obj, act) {
  3071. 3069.  -     return (act || hasClass)(obj.parentNode.parentNode, 'pvs_hh_liked');
  3072. 3070.  -   },
  3073. 3071.  -   hhOver: function(obj) {
  3074. 3072.  -     clearTimeout(obj.parentNode.parentNode.getAttribute('timer'));
  3075. 3073.  -     var params = Photoview.hhLiked(obj) ? [0.25, 1] : [0.28, 0.65];
  3076. 3074.  -     animate(obj.previousSibling, {opacity: params[0]}, 200);
  3077. 3075.  -     animate(obj, {opacity: params[1]}, 200);
  3078. 3076.  -   },
  3079. 3077.  -   hhOut: function(obj) {
  3080. 3078.  -     var params = Photoview.hhLiked(obj) ? [0.25, 1] : [0.2, 0.5];
  3081. 3079.  -     animate(obj.previousSibling, {opacity: params[0]}, 200);
  3082. 3080.  -     animate(obj, {opacity: params[1]}, 200);
  3083. 3081.  -   },
  3084. 3082.  -   hhClick: function(obj, ev, pv) {
  3085. 3083.  -     if (ev.button == 2) return;
  3086. 3084.  -     var liked = Photoview.hhLiked(obj);
  3087. 3085.  -
  3088. 3086.  -     Photoview.like();
  3089. 3087.  -     liked && Photoview.likeOut();
  3090. 3088.  -
  3091. 3089.  -     Photoview.hhOver(obj);
  3092. 3090.  -
  3093. 3091.  -     if (!liked && !(browser.msie && intval(browser.version) < 9 || browser.mozilla && intval(browser.version) < 9)) {
  3094. 3092.  -       obj.innerHTML = '<img class="pvs_hh_ah" width="38" height="34" src="/images/icons/post_big_hh.png" />';
  3095. 3093.  -       var img = obj.firstChild;
  3096. 3094.  -       animate(img, {marginLeft: -3, marginTop: 3, width: 78, height: 71, opacity: 0}, {duration: 600, transition: Fx.Transitions.easeOutCubic});
  3097. 3095.  -     }
  3098. 3096.  -
  3099. 3097.  -     return cancelEvent(ev);
  3100. 3098.  -   },
  3101. 3099.  -   hhCheck: function() {
  3102. 3100.  -     return (!browser.msie || intval(browser.version) > 8) && !cur.pvNoLikes;
  3103. 3101.  -   },
  3104. 3102.  -
  3105. 3103.  -   showRepeat: function(row) {
  3106. 3104.  -     if (!row || geByClass1('pva_repeat', row)) return;
  3107. 3105.  -
  3108. 3106.  -     geByClass1('pva_link', row).insertBefore(ce('div', {className: 'pva_repeat', innerHTML: '\
  3109. 3107.  - <div class="pva_repeat_blob">\
  3110. 3108.  -   <div class="pva_repeat_cont"><img class="pva_repeat_img png" src="'+stManager._srcPrefix('.css')+'/images/icons/post_hh'+(window.devicePixelRatio >= 2 ? '_2x' : '')+'.png?2" /><span class="pva_repeat_text">' + getLang('photos_repeat_album') + '</span></div>\
  3111. 3109.  - </div>'}), geByClass1('pva_title', row));
  3112. 3110.  -   },
  3113. 3111.  -
  3114. 3112.  -   showPlace: function() {
  3115. 3113.  -     var geohash = cur.pvCurPhoto.geohash;
  3116. 3114.  -     showBox('al_places.php', {act: 'show_photo_place', geohash: geohash, photo: cur.pvCurPhoto.id}, {width: 708, hideButtons: true, title: false, cache: 1});
  3117. 3115.  -   },
  3118. 3116.  -
  3119. 3117.  -   editPlace: function() {
  3120. 3118.  -     var geohash = cur.pvCurPhoto.geohash;
  3121. 3119.  -     showBox('al_places.php', {act: 'show_photo_place', edit: 1, geohash: geohash || '', photo: cur.pvCurPhoto.id});
  3122. 3120.  -   },
  3123. 3121.  -
  3124. 3122.  -   updatePlace: function(photo, place) {
  3125. 3123.  -     var placeCont = ge('pv_edit_place');
  3126. 3124.  -     if (place) {
  3127. 3125.  -       placeCont && (placeCont.innerHTML = place ? place + '.' : '');
  3128. 3126.  -       ge('pv_place').innerHTML = place ? '<span class="pv_place_label">' + getLang('photos_place_label') + '</span> <a class="pv_place_a" id="pv_place_a" onclick="Photoview.showPlace()">' + place + '</a>' : '';
  3129. 3127.  -       hide('pv_add_place');
  3130. 3128.  -     } else {
  3131. 3129.  -       setTimeout(function() {
  3132. 3130.  -         ajax.post('al_photos.php', {act: 'get_photo_place', photo: photo}, {
  3133. 3131.  -           onDone: function(place, placeGeoHash) {
  3134. 3132.  -             Photoview.updatePlace(photo, place);
  3135. 3133.  -           }
  3136. 3134.  -         })
  3137. 3135.  -       }, 1000);
  3138. 3136.  -     }
  3139. 3137.  -   },
  3140. 3138.  -
  3141. 3139.  -   nearProgress: function(obj) {
  3142. 3140.  -     obj.insertBefore(ce('div', {className: 'pv_load_near'}), obj.firstChild);
  3143. 3141.  -   }/*,
  3144. 3142.  -
  3145. 3143.  -   showPvLayer: function() {
  3146. 3144.  -     if (cur.pvFixedHide) {
  3147. 3145.  -       show(cur.pvFixed);
  3148. 3146.  -     }
  3149. 3147.  -     cur.pvNoHistory = true;
  3150. 3148.  -     layers.fullhide && layers.fullhide(true);
  3151. 3149.  -
  3152. 3150.  -     layers.wrapshow(layerWrap, 0.7);
  3153. 3151.  -     layers.fullhide = Photoview.hide;
  3154. 3152.  -     onBodyResize();
  3155. 3153.  -     if (cur.pvVideoTagsShown) {
  3156. 3154.  -       var nl = extend(nav.objLoc, {z: 'video_tag' + cur.pvVideoTagsShown});
  3157. 3155.  -       if (nav.strLoc != nav.toStr(nl)) {
  3158. 3156.  -         setTimeout(nav.setLoc.pbind(nl), 0);
  3159. 3157.  -       }
  3160. 3158.  -     }
  3161. 3159.  -   }
  3162. 3160.  - */
  3163. 3161.  - }, photoview = Photoview;
  3164. 3162.  -
  3165. 3163.  - try{stManager.done('photoview.js');}catch(e){}
  3166. ------
Advertisement
Add Comment
Please, Sign In to add comment