diff --git a/Web/Presenters/templates/Photos/Photo.xml b/Web/Presenters/templates/Photos/Photo.xml index a5e17caa..06bec386 100644 --- a/Web/Presenters/templates/Photos/Photo.xml +++ b/Web/Presenters/templates/Photos/Photo.xml @@ -28,7 +28,7 @@
- {include "../components/comments.xml", comments => $comments, count => $cCount, page => $cPage, model => "photos", parent => $photo} + {include "../components/comments.xml", comments => $comments, count => $cCount, page => $cPage, model => "photos", parent => $photo, custom_id => 999}
diff --git a/Web/Presenters/templates/components/comments.xml b/Web/Presenters/templates/components/comments.xml index d84a0732..f33c6176 100644 --- a/Web/Presenters/templates/components/comments.xml +++ b/Web/Presenters/templates/components/comments.xml @@ -4,7 +4,7 @@ {var $commentsURL = "/al_comments/create/$model/" . $parent->getId()} {var $club = $parent instanceof \openvk\Web\Models\Entities\Post && $parent->getTargetWall() < 0 ? (new openvk\Web\Models\Repositories\Clubs)->get(abs($parent->getTargetWall())) : $club} {if !$readOnly} - {include "textArea.xml", route => $commentsURL, postOpts => false, graffiti => (bool) ovkGetQuirk("comments.allow-graffiti"), club => $club} + {include "textArea.xml", route => $commentsURL, postOpts => false, graffiti => (bool) ovkGetQuirk("comments.allow-graffiti"), club => $club, custom_id => $custom_id} {/if}
diff --git a/Web/Presenters/templates/components/textArea.xml b/Web/Presenters/templates/components/textArea.xml index 9d6a81e9..310a3724 100644 --- a/Web/Presenters/templates/components/textArea.xml +++ b/Web/Presenters/templates/components/textArea.xml @@ -1,5 +1,6 @@ {php if(!isset($GLOBALS["textAreaCtr"])) $GLOBALS["textAreaCtr"] = 10;} {var $textAreaId = ($post ?? NULL) === NULL ? (++$GLOBALS["textAreaCtr"]) : $post->getId()} +{var $textAreaId = ($custom_id ?? NULL) === NULL ? $textAreaId : $custom_id}
diff --git a/Web/static/js/al_wall.js b/Web/static/js/al_wall.js index 20b436aa..148a3c1a 100644 --- a/Web/static/js/al_wall.js +++ b/Web/static/js/al_wall.js @@ -173,6 +173,8 @@ function OpenMiniature(e, photo, post, photo_id) { let imagesCount = 0; let imagesIndex = 0; + + let tempDetailsSection = []; let dialog = u( `
@@ -208,6 +210,36 @@ function OpenMiniature(e, photo, post, photo_id) { __closeDialog(); }); + function __reloadTitleBar() { + u("#photo_com_title_photos").last().innerHTML = "Фотография " + imagesIndex + " из " + imagesCount; + } + + 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; + } + } + ] + } + }); + } else { + u(".ovk-photo-details").last().innerHTML = tempDetailsSection[index]; + } + } + function __slidePhoto(direction) { /* direction = 1 - right direction = 0 - left */ @@ -227,7 +259,8 @@ function OpenMiniature(e, photo, post, photo_id) { let photoURL = json.body[imagesIndex - 1].url; u("#ovk-photo-img").last().src = photoURL; - u("#photo_com_title_photos").last().innerHTML = "Фотография " + imagesIndex + " из " + imagesCount; + __reloadTitleBar(); + __loadDetails(json.body[imagesIndex - 1].id, imagesIndex); } } @@ -262,25 +295,8 @@ function OpenMiniature(e, photo, post, photo_id) { } }); - u("#photo_com_title_photos").last().innerHTML = "Фотография " + imagesIndex + " из " + imagesCount; - } - ] - } - }); - - 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(); - - u(".ovk-photo-details").last().innerHTML = element.innerHTML; - - u("#photo_com_title_photos").last().innerHTML = "Фотография " + imagesIndex + " из " + imagesCount; - } + __reloadTitleBar(); + __loadDetails(json.body[imagesIndex - 1].id, imagesIndex); } ] } });