• Y
  • List All
  • Feedback
    • This Project
    • All Projects
Profile Account Log out
  • Favorite
  • Project
  • Recent History
Loading...
  • Log in
  • Sign up
kadrians / Testing_for_YONA star
  • Project homeH
  • CodeC
  • IssueI 1
  • Pull requestP
  • Review R
  • MilestoneM
  • BoardB 2
  • Files
  • Commit
  • Branches
Testing_for_YONAsourcepublicjavascriptscommonyona.CommentAttachmentsUpdate.js
Download as .zip file
File name
Commit message
Commit date
bin
Yona 1.16.0 Upload
02-04
lib
Yona 1.16.0 Upload
02-04
share/doc/api
Yona 1.16.0 Upload
02-04
source
Source Code Upload
02-04
README.md
Yona 1.16.0 Upload
02-04
File name
Commit message
Commit date
app
Source Code Upload
02-04
conf
Source Code Upload
02-04
docs
Source Code Upload
02-04
lib
Source Code Upload
02-04
project
Source Code Upload
02-04
public
Source Code Upload
02-04
support-script
Source Code Upload
02-04
test
Source Code Upload
02-04
.gitignore
Source Code Upload
02-04
.mailmap
Source Code Upload
02-04
.travis.yml
Source Code Upload
02-04
AUTHORS
Source Code Upload
02-04
LICENSE
Source Code Upload
02-04
NOTICE
Source Code Upload
02-04
README.md
Source Code Upload
02-04
build.sbt
Source Code Upload
02-04
dev.sh
Source Code Upload
02-04
dist.sh
Source Code Upload
02-04
is-alive-bot.sh
Source Code Upload
02-04
minify-js.sh
Source Code Upload
02-04
restart.sh
Source Code Upload
02-04
File name
Commit message
Commit date
bootstrap
Source Code Upload
02-04
help
Source Code Upload
02-04
images
Source Code Upload
02-04
javascripts
Source Code Upload
02-04
stylesheets
Source Code Upload
02-04
compiler.jar
Source Code Upload
02-04
File name
Commit message
Commit date
common
Source Code Upload
02-04
lib
Source Code Upload
02-04
service
Source Code Upload
02-04
template
Source Code Upload
02-04
yona-common.js
Source Code Upload
02-04
yona-layout.js
Source Code Upload
02-04
yona-lib.js
Source Code Upload
02-04
File name
Commit message
Commit date
yobi.Attachments.js
Source Code Upload
02-04
yobi.CodeCommentBlock.js
Source Code Upload
02-04
yobi.CodeCommentBox.js
Source Code Upload
02-04
yobi.Comment.js
Source Code Upload
02-04
yobi.CommentForm.js
Source Code Upload
02-04
yobi.Common.js
Source Code Upload
02-04
yobi.Files.js
Source Code Upload
02-04
yobi.Interval.js
Source Code Upload
02-04
yobi.LoginDialog.js
Source Code Upload
02-04
yobi.Markdown.js
Source Code Upload
02-04
yobi.Mention.js
Source Code Upload
02-04
yobi.OriginalMessage.js
Source Code Upload
02-04
yobi.Pagination.js
Source Code Upload
02-04
yobi.ShortcutKey.js
Source Code Upload
02-04
yobi.WatcherList.js
Source Code Upload
02-04
yobi.ui.Calendar.js
Source Code Upload
02-04
yobi.ui.Dialog.js
Source Code Upload
02-04
yobi.ui.Dropdown.js
Source Code Upload
02-04
yobi.ui.Mergely.js
Source Code Upload
02-04
yobi.ui.Select2.js
Source Code Upload
02-04
yobi.ui.Tabs.js
Source Code Upload
02-04
yobi.ui.Toast.js
Source Code Upload
02-04
yobi.ui.Typeahead.js
Source Code Upload
02-04
yona.CommentAttachmentsUpdate.js
Source Code Upload
02-04
yona.KeyControl.js
Source Code Upload
02-04
yona.ReceiverList.js
Source Code Upload
02-04
yona.Sha1.js
Source Code Upload
02-04
yona.SubComment.js
Source Code Upload
02-04
yona.Subtask.js
Source Code Upload
02-04
yona.Tasklist.js
Source Code Upload
02-04
yona.TitleHeadAutoCompletion.js
Source Code Upload
02-04
yona.Usermenu.js
Source Code Upload
02-04
Nell 02-04 2600fe6 Source Code Upload UNIX
Raw Open in browser Change history
$(function () { function deleteAttachment() { var $this = $(this); var $parent = $this.parent(".attached-file-marker"); var id = $this.data("id"); var filename = $parent.data("name"); var url = $parent.data("href"); var mimeType = $parent.data("mime"); var linkStr = "[" + filename + "](" + url + ")"; if (mimeType.startsWith("image")) { linkStr = "!" + linkStr; } var $form = $this.parent().closest("form"); var $textarea = $form.find("textarea"); var $attachfiles = $form.find(".temporaryUploadFiles"); $attachfiles.val($attachfiles.val().split(",").filter(function (item) { return item != id; }).join(",")); $textarea.val($textarea.val().split(linkStr).join("")); $.post(url) .done(function (data) { $parent.remove(); }) .fail(function (data) { console.log(data); }); } $(".attached-file-marker").on("click", ".btn-delete", deleteAttachment); $(".file-upload__input").on("change", function (e) { NProgress.start(); var $attachmentInput = $(this); var files = $attachmentInput[0].files; var caretPos = getCaretPos($attachmentInput); var doneCount = 0; for (var i = 0; i < files.length; i++) { var formData = new FormData(); formData.append("filePath", files[i]); $.ajax({ url: '/files', type: 'POST', cache: false, contentType: false, processData: false, data: formData }).done(function (data) { var $parentForm = $attachmentInput.parent().closest("form"); buildTemporaryUploadedFileCards($parentForm, data); caretPos = insertLinkIntoTextarea($parentForm.find("textarea"), data, caretPos); doneCount++; if (doneCount === files.length) { NProgress.done(); } }).fail(function (data) { $yobi.notify(data); }); } }); var rememberBorder = ""; $(".textarea-box") .on("dragenter", "textarea", function (e) { e.stopPropagation(); e.preventDefault(); rememberBorder = $(this).css("border"); $(this).css("border", "1px dashed orange"); }) .on("dragover", "textarea", function (e) { e.stopPropagation(); e.preventDefault(); }) .on("drop", "textarea", function (e) { e.stopPropagation(); e.preventDefault(); var dt = e.originalEvent.dataTransfer; var files = dt.files; $(this).css("border", rememberBorder); var attachmentInput = $(this).parent().closest("form").find(".file-upload__input"); attachmentInput[0].files = files; attachmentInput.trigger("change"); }) .on("dragleave", "textarea", function (e) { $(this).css("border", rememberBorder); }) .on("paste", "textarea", function (event) { var items = (event.clipboardData || event.originalEvent.clipboardData).items; var $attachmentInput = $(this).parent().closest("form").find(".file-upload__input"); var caretPos = getCaretPos($attachmentInput); for (var index in items) { var item = items[index]; if (item.kind === 'file' && item.type.indexOf("image") === 0) { NProgress.start(); var formData = new FormData(); formData.append('filePath', item.getAsFile(), generateFileName()); $.ajax('/files', { type: 'POST', contentType: false, processData: false, data: formData }).done(function (data) { var $parentForm = $attachmentInput.parent().closest("form"); buildTemporaryUploadedFileCards($parentForm, data); caretPos = insertLinkIntoTextarea($parentForm.find("textarea"), data, caretPos); NProgress.done(); }).fail(function (data) { $yobi.notify(data); }); } } }); function getCaretPos($attachmentInput) { return $attachmentInput.parent().closest("form").find("textarea")[0].selectionStart; } function buildTemporaryUploadedFileCards($parentForm, data) { var attachmentFileListArea = $parentForm.find(".attachment-files"); setTemporaryUploadFileIds($parentForm.find(".temporaryUploadFiles"), data.id); attachmentFileListArea.append(getAttachmentCard(data)) .on("click", ".btn-delete", deleteAttachment); } function getAttachmentCard(data) { return '<div class="attached-file attached-file-marker" data-mime="' + data.mimeType.trim() + '" data-name="' + data.name + '" data-href="' + data.url + '">\n' + '<strong class="name">' + data.name + '</strong>\n' + '<span class="size">' + humanize.filesize(data.size) + '</span>\n' + '<button type="button" class="btn-transparent btn-delete" data-id="' + data.id + '">&times;</button>\n' + '</div>'; } function setTemporaryUploadFileIds($attachmentFiles, fileId) { if ($attachmentFiles.val() === "") { $attachmentFiles.val(fileId); } else { var splitIds = $attachmentFiles.val().split(","); if (!splitIds.includes(fileId)) { $attachmentFiles.val(splitIds.concat(fileId).join(",")); } } } function generateFileName() { var now = new Date(); return now.getSeconds() + "" + now.getMilliseconds() + '-' + now.getFullYear() + '-' + (now.getMonth() + 1) + '-' + now.getDate() + '-' + now.getHours() + '-' + now.getMinutes() + ".png"; } function insertLinkIntoTextarea($textarea, data, caretPos) { var textAreaTxt = $textarea.val(); var txtToAdd = "[" + data.name + "](" + data.url + ")"; if (data.mimeType.startsWith("image")) { txtToAdd = "!" + txtToAdd; } txtToAdd = " " + txtToAdd; if (textAreaTxt.length > 0 && caretPos === 0) { caretPos = textAreaTxt.length; } $textarea.val(textAreaTxt.substring(0, caretPos) + txtToAdd + textAreaTxt.substring(caretPos)); return caretPos + txtToAdd.length; } });

          
        
    
    
Copyright Yona authors & © NAVER Corp. & NAVER LABS Supported by NAVER CLOUD PLATFORM

or
login with Google Sign in with Google
Reset password | Sign up