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