diff --git a/Web/Presenters/templates/components/attachment.xml b/Web/Presenters/templates/components/attachment.xml index f1bd0a88..d084ae63 100644 --- a/Web/Presenters/templates/components/attachment.xml +++ b/Web/Presenters/templates/components/attachment.xml @@ -30,19 +30,14 @@ {elseif $attachment instanceof \openvk\Web\Models\Entities\Poll} {presenter "openvk!Poll->view", $attachment->getId()} {elseif $attachment instanceof \openvk\Web\Models\Entities\Note} - {if !$attachment->isDeleted()} -
- +
+ + + - {else} -
- - {_note} - {_deleted} -
- {/if} +
{elseif $attachment instanceof \openvk\Web\Models\Entities\Post} {php $GLOBALS["_nesAttGloCou"] = (isset($GLOBALS["_nesAttGloCou"]) ? $GLOBALS["_nesAttGloCou"] : 0) + 1} {if $GLOBALS["_nesAttGloCou"] > 2} diff --git a/Web/Presenters/templates/components/textArea.xml b/Web/Presenters/templates/components/textArea.xml index b01758f9..9074e86a 100644 --- a/Web/Presenters/templates/components/textArea.xml +++ b/Web/Presenters/templates/components/textArea.xml @@ -83,6 +83,10 @@ {_audio} + + + {_note} + {_graffiti} diff --git a/Web/static/css/main.css b/Web/static/css/main.css index 04c56408..4e0ec10b 100644 --- a/Web/static/css/main.css +++ b/Web/static/css/main.css @@ -2502,7 +2502,7 @@ a.poll-retract-vote { } .post-vertical .vertical-attachment .audioEntry .playerButton { - padding: 0px 3px 0px 3px; + padding: 0px 3px 0px 0px; } .post-vertical .vertical-attachment .audioEntry .status { @@ -2999,17 +2999,33 @@ a.poll-retract-vote { width: 100%; } -.attachment_note_icon { +.attachment_note .attachment_note_icon { max-width: 9px; } -.attachment_note_text { +.attachment_note .attachment_note_text { color: #605F63; margin-left: 2px; } .attachment_note { user-select: none; + display: flex; + align-items: center; + gap: 1px; +} + +.attachment_note svg { + width: 8px; + height: 10px; + fill: #605f63; + margin-top: 2px; +} + +.attachment_note .attachment_note_content { + display: flex; + gap: 4px; + height: 12px; } #notesList diff --git a/Web/static/js/al_music.js b/Web/static/js/al_music.js index 6c37347c..51590511 100644 --- a/Web/static/js/al_music.js +++ b/Web/static/js/al_music.js @@ -1431,7 +1431,7 @@ $(document).on("click", "#__audioAttachment", (e) => { u(form).find(`.post-vertical .vertical-attachment[data-id='${id}']`).remove() u(ev.currentTarget).find("span").html(tr("attach_audio")) } else { - if(u(form).find(`.vertical-attachment`).length > window.openvk.max_attachments) { + if(u(form).find(`.upload-item`).length > window.openvk.max_attachments) { makeError(tr('too_many_attachments'), 'Red', 10000, 1) return } diff --git a/Web/static/js/al_wall.js b/Web/static/js/al_wall.js index 6ec92934..d3530caf 100644 --- a/Web/static/js/al_wall.js +++ b/Web/static/js/al_wall.js @@ -527,14 +527,14 @@ u('#write .small-textarea').on('paste', (e) => { } }) -u('#write').on('dragstart', '.post-horizontal .upload-item, .post-vertical .upload-item > *', (e) => { +u('#write').on('dragstart', '.post-horizontal .upload-item, .post-vertical .upload-item', (e) => { //e.preventDefault() //console.log(e) u(e.target).closest('.upload-item').addClass('currently_dragging') return }) -u('#write').on('dragover', '.post-horizontal .upload-item, .post-vertical .upload-item > *', (e) => { +u('#write').on('dragover', '.post-horizontal .upload-item, .post-vertical .upload-item', (e) => { e.preventDefault() const target = u(e.target).closest('.upload-item') @@ -547,7 +547,7 @@ u('#write').on('dragover', '.post-horizontal .upload-item, .post-vertical .uploa return }) -u('#write').on('dragleave dragend', '.post-horizontal .upload-item, .post-vertical .upload-item > *', (e) => { +u('#write').on('dragleave dragend', '.post-horizontal .upload-item, .post-vertical .upload-item', (e) => { //console.log(e) u(e.target).closest('.upload-item').removeClass('dragged') return @@ -892,6 +892,125 @@ u(document).on('click', '#__videoAttachment', async (e) => { __recieveVideos(0) }) +// __audioAttachment -> al_music.js, 1318 + +u(document).on('click', '#__notesAttachment', async (e) => { + const per_page = 10 + const form = u(e.target).closest('form') + const msg = new CMessageBox({ + title: tr('select_note'), + body: ` +
+
+
+
+
+ `, + buttons: [tr("create_note"), tr('close')], + callbacks: [() => { + window.location.assign('/notes/create') + }, Function.noop] + }) + + msg.getNode().attr('style', 'width: 340px;') + msg.getNode().find('.ovk-diag-body').attr('style', 'height:335px;padding:0px;') + + async function __recieveNotes(page) { + u('#gif_loader').remove() + u('#attachment_insert').append(`
`) + const insert_place = u('#attachment_insert .notesInsert') + let notes = null + + try { + notes = await window.OVKAPI.call('notes.get', {'user_id': window.openvk.current_id, 'count': per_page, 'offset': per_page * page}) + } catch(e) { + u("#gif_loader").remove() + insert_place.html("Err") + return + } + + u("#gif_loader").remove() + const pages_count = Math.ceil(Number(notes.count) / per_page) + notes.notes.forEach(note => { + is_attached = (form.find(`.upload-item[data-type='note'][data-id='${note.owner_id}_${note.id}']`)).length > 0 + insert_place.append(` +
+
+
+ ${escapeHtml(note.title)} + + + ${ovk_proc_strtr(escapeHtml(strip_tags(note.text)), 100)} + +
+
+
+ ${is_attached ? tr("detach") : tr("attach")} +
+
+ `) + }) + + if(page < pages_count - 1) { + insert_place.append(` +
+ ${tr('show_more')} +
`) + } + } + + // next page + u(".ovk-diag-body .attachment_selector").on("click", "#show_more", async (ev) => { + const target = u(ev.target).closest('#show_more') + target.addClass('lagged') + await __recieveNotes(Number(target.nodes[0].dataset.page)) + target.remove() + }) + + // add note + u(".ovk-diag-body .attachment_selector").on("click", "#__attach_note", async (ev) => { + if(u(form).find(`.upload-item`).length > window.openvk.max_attachments) { + makeError(tr('too_many_attachments'), 'Red', 10000, 1) + return + } + + const target = u(ev.target).closest('._content') + const button = target.find('#__attach_note') + const dataset = target.nodes[0].dataset + const is_attached = (form.find(`.upload-item[data-type='note'][data-id='${dataset.attachmentdata}']`)).length > 0 + if(is_attached) { + (form.find(`.upload-item[data-type='note'][data-id='${dataset.attachmentdata}']`)).remove() + button.html(tr('attach')) + } else { + if(form.find(`.upload-item`).length + 1 > window.openvk.max_attachments) { + makeError(tr('too_many_attachments'), 'Red', 10000, 1) + return + } + + button.html(tr('detach')) + form.find('.post-vertical').append(` +
+
+
+ + +
+ ${tr('note')} + ${ovk_proc_strtr(dataset.name, 66)} +
+
+
+
+
+
+
+ `) + } + }) + + __recieveNotes(0) +}) + u(document).on('click', `.post-horizontal .upload-item .upload-delete`, (e) => { e.preventDefault() u(e.target).closest('.upload-item').remove() diff --git a/Web/static/js/utils.js b/Web/static/js/utils.js index 10990c70..a8f7836a 100644 --- a/Web/static/js/utils.js +++ b/Web/static/js/utils.js @@ -135,3 +135,8 @@ function array_splice(array, key) return resultArray; } + +function strip_tags(text) +{ + return text.replace(/(<([^>]+)>)/gi, "") +}