function initGraffiti(event) { let canvas = null; const msgbox = new CMessageBox({ title: tr("draw_graffiti"), body: "
", close_on_buttons: false, warn_on_exit: true, buttons: [tr("save"), tr("cancel")], callbacks: [function() { canvas.getImage({includeWatermark: false}).toBlob(blob => { let fName = "Graffiti-" + Math.ceil(performance.now()).toString() + ".jpeg"; let image = new File([blob], fName, {type: "image/jpeg", lastModified: new Date().getTime()}); __uploadToTextarea(image, u(event.target).closest('#write')) }, "image/jpeg", 0.92); canvas.teardown(); msgbox.close() }, async function() { const res = await msgbox.__showCloseConfirmationDialog() if(res === true) { canvas.teardown() msgbox.close() } }] }) let watermarkImage = new Image(); watermarkImage.src = "/assets/packages/static/openvk/img/logo_watermark.gif"; msgbox.getNode().attr("style", "width: 750px;"); canvas = LC.init(document.querySelector("#ovkDraw"), { backgroundColor: "#fff", imageURLPrefix: "/assets/packages/static/openvk/js/node_modules/literallycanvas/lib/img", watermarkImage: watermarkImage, imageSize: { width: 640, height: 480 } }); } u(document).on('click', '.menu_toggler', (e) => { const post_buttons = $(e.target).closest('.post-buttons') const wall_attachment_menu = post_buttons.find('#wallAttachmentMenu') if(wall_attachment_menu.is('.hidden')) { wall_attachment_menu.css({ opacity: 0 }); wall_attachment_menu.toggleClass('hidden').fadeTo(250, 1); } else { wall_attachment_menu.fadeTo(250, 0, function () { $(this).toggleClass('hidden'); }); } }) $(document).on("click", ".post-like-button", function(e) { e.preventDefault(); var thisBtn = u(this).first(); var link = u(this).attr("href"); var heart = u(".heart", thisBtn); var counter = u(".likeCnt", thisBtn); var likes = counter.text() === "" ? 0 : counter.text(); var isLiked = heart.attr("id") === 'liked'; ky.post(link) heart.attr("id", isLiked ? '' : 'liked'); counter.text(parseInt(likes) + (isLiked ? -1 : 1)); if (counter.text() === "0") { counter.text(""); } return false; }); u(document).on("input", "textarea", function(e) { var boost = 5; var textArea = e.target; textArea.style.height = "5px"; var newHeight = textArea.scrollHeight; textArea.style.height = newHeight + boost + "px"; return; // revert to original size if it is larger (possibly changed by user) // textArea.style.height = (newHeight > originalHeight ? (newHeight + boost) : originalHeight) + "px"; }); function OpenMiniature(e, photo, post, photo_id, type = "post") { /* костыли но смешные однако */ e.preventDefault(); if(u(".ovk-photo-view").length > 0) u(".ovk-photo-view-dimmer").remove(); // Значения для переключения фоток let json; let imagesCount = 0; let imagesIndex = 0; let tempDetailsSection = []; let dialog = u( ``); u("body").addClass("dimmed").append(dialog); document.querySelector("html").style.overflowY = "hidden" let button = u("#ovk-photo-close"); button.on("click", function(e) { let __closeDialog = () => { u("body").removeClass("dimmed"); u(".ovk-photo-view-dimmer").remove(); document.querySelector("html").style.overflowY = "scroll" }; __closeDialog(); }); function __reloadTitleBar() { u("#photo_com_title_photos").last().innerHTML = imagesCount > 1 ? tr("photo_x_from_y", imagesIndex, imagesCount) : tr("photo"); } function __loadDetails(photo_id, index) { if(tempDetailsSection[index] == null) { u(".ovk-photo-details").last().innerHTML = ''; ky("/photo" + photo_id, { hooks: { afterResponse: [ async (_request, _options, response) => { let parser = new DOMParser(); let body = parser.parseFromString(await response.text(), "text/html"); let element = u(body.getElementsByClassName("ovk-photo-details")).last(); tempDetailsSection[index] = element.innerHTML; if(index == imagesIndex) { u(".ovk-photo-details").last().innerHTML = element.innerHTML ?? ''; } document.querySelectorAll(".ovk-photo-details .bsdn").forEach(bsdnInitElement) document.querySelectorAll(".ovk-photo-details script").forEach(scr => { // stolen from #953 let newScr = document.createElement('script') if(scr.src) { newScr.src = scr.src } else { newScr.textContent = scr.textContent } document.querySelector(".ovk-photo-details").appendChild(newScr); }) } ] } }); } else { u(".ovk-photo-details").last().innerHTML = tempDetailsSection[index]; } } function __slidePhoto(direction) { /* direction = 1 - right direction = 0 - left */ if(json == undefined) { console.log("Да подожди ты. Куда торопишься?"); } else { if(imagesIndex >= imagesCount && direction == 1) { imagesIndex = 1; } else if(imagesIndex <= 1 && direction == 0) { imagesIndex = imagesCount; } else if(direction == 1) { imagesIndex++; } else if(direction == 0) { imagesIndex--; } let photoURL = json.body[imagesIndex - 1].url; u("#ovk-photo-img").last().src = photoURL; __reloadTitleBar(); __loadDetails(json.body[imagesIndex - 1].id, imagesIndex); } } let slideLeft = u(".ovk-photo-slide-left"); slideLeft.on("click", (e) => { __slidePhoto(0); }); let slideRight = u(".ovk-photo-slide-right"); slideRight.on("click", (e) => { __slidePhoto(1); }); let data = new FormData() data.append('parentType', type); if(type) { ky.post("/iapi/getPhotosFromPost/" + (type == "post" ? post : "1_"+post), { hooks: { afterResponse: [ async (_request, _options, response) => { json = await response.json(); imagesCount = json.body.length; imagesIndex = 0; // Это всё придётся правда на 1 прибавлять json.body.every(element => { imagesIndex++; if(element.id == photo_id) { return false; } else { return true; } }); __reloadTitleBar(); __loadDetails(json.body[imagesIndex - 1].id, imagesIndex); } ] }, body: data }); } else { imagesCount = 1 __reloadTitleBar() __loadDetails(photo_id, imagesIndex) } return u(".ovk-photo-view-dimmer"); } u("#write > form").on("keydown", function(event) { if(event.ctrlKey && event.keyCode === 13) this.submit(); }); var tooltipClientTemplate = Handlebars.compile(`
${tr("learn_more")} |
|
|
${ovk_proc_strtr(escapeHtml(video.title), 50)}
${ovk_proc_strtr(escapeHtml(video.description ?? ""), 140)} ${ovk_proc_strtr(escapeHtml(author_name ?? ""), 100)} |
${!is_attached ? tr("attach") : tr("detach")} |
${tr('info_name')}: | |
${tr('description')}: | |
${tr('video')}: |
${tr('info_name')}: | |
${tr('description')}: | |
${tr('video_link_to_yt')}: |
${isGroup == true ? tr('groups_avatar') : tr('friends_avatar')}
${tr('formats_avatar')}
${tr('troubles_avatar')}
${tr('webcam_avatar')}
${tr("selected_area_rotate")}