애니멀나라는 11월 15일 오픈 예정입니다
추천 검색어
지역 + 키워드를 함께 입력해 보세요
1
54
2
41
3
37
4
16
5
14
6
13
7
12
8
7
9
5
10
5
123
123 (0)
메 |2024.09.25 23:19 |조회 2,320 |추천 0
URL복사     https://www.animalnara.com/community/home/read/5264?page=2&search_by=title               
7 type="text/javascript" src="../js/jquery-3.7.0.min.js"> > // 페이지 로드 시 다크 모드 설정 window.addEventListener("DOMContentLoaded", function() { var storedColorMode = window.localStorage.getItem("color_mode"); var defaultColorMode = storedColorMode || ""; document.body.classList.toggle("dark", defaultColorMode === "dark"); }); // 클릭 시 삭제 및 대표사진 설정 버튼 표시 function showMediaButtons(event, mediaElement) { // 이벤트 전파 방지 event.stopPropagation(); // 기존 버튼 제거 document.querySelector('.delete-button')?.remove(); // 기존의 하이라이트 해제 document.querySelectorAll('img, video').forEach(el => el.classList.remove('highlight')); // 하이라이트 추가 mediaElement.classList.add('highlight'); // 현재 클릭된 미디어가 대표사진이 아닌 경우 if (mediaElement.id !== 'representativeMedia') { // 기존의 대표사진 해제 var currentRepresentative = document.getElementById('representativeMedia'); if (currentRepresentative) { currentRepresentative.id = ''; // 기존 대표사진 ID 초기화 // 기존 대표사진의 버튼도 제거 document.querySelector('.representative-button')?.remove(); } } // 대표사진 버튼 생성 var representativeButton = createRepresentativeButton(mediaElement); setButtonPosition(representativeButton, mediaElement, 10); document.body.appendChild(representativeButton); // 대표사진 버튼 추가 // 삭제 버튼 생성 var deleteButton = document.createElement('div'); deleteButton.className = 'delete-button'; setButtonPosition(deleteButton, mediaElement, 10, true); // 크기 조정 버튼 생성 createSizeButtons(deleteButton, mediaElement); // 삭제 버튼 클릭 시 처리 var deleteIconButton = document.createElement('div'); deleteIconButton.className = 'icon-button'; deleteIconButton.innerHTML = ' 삭제'; deleteIconButton.onclick = function() { handleDelete(mediaElement); deleteButton.remove(); representativeButton.remove(); // 대표사진 버튼 제거 mediaElement.classList.remove('highlight'); }; deleteButton.appendChild(deleteIconButton); document.body.appendChild(deleteButton); } // 대표사진 버튼 생성 (id로 설정) function createRepresentativeButton(mediaElement) { var representativeButton = document.createElement('div'); representativeButton.id = 'representativeButton'; // ID 추가 representativeButton.className = 'representative-button'; representativeButton.innerHTML = '대표사진'; // 미디어의 기존 대표사진 상태 확인 if (mediaElement.id === 'representativeMedia') { representativeButton.style.backgroundColor = '#cf3a3a'; // 강조 배경색 representativeButton.style.color = '#fff'; // 강조 글자색 } representativeButton.onclick = function() { // 대표사진 해제 및 유지 if (mediaElement.id === 'representativeMedia') { mediaElement.id = ''; // ID 초기화 representativeButton.style.backgroundColor = 'rgba(255, 255, 255, 0.8)'; // 기본 배경색 representativeButton.style.color = 'black'; // 기본 글자색 alert("대표사진 해제되었습니다."); } else { mediaElement.id = 'representativeMedia'; // 대표사진 설정 representativeButton.style.backgroundColor = '#cf3a3a'; // 강조 배경색 representativeButton.style.color = '#fff'; // 강조 글자색 alert("대표사진으로 설정되었습니다."); } }; return representativeButton; } // 버튼 위치 설정 function setButtonPosition(button, mediaElement, offset, isBelow = false) { var rect = mediaElement.getBoundingClientRect(); button.style.top = (isBelow ? rect.bottom : rect.top) + window.scrollY + offset + 'px'; button.style.left = (rect.left + window.scrollX + 10) + 'px'; } // 크기 조정 버튼 생성 function createSizeButtons(container, mediaElement) { var sizes = [100, 75, 50, 25]; // 비율 배열 sizes.forEach(size => { var iconButton = document.createElement('div'); iconButton.className = 'icon-button'; iconButton.innerHTML = '' + size + '%'; iconButton.onclick = function() { if (mediaElement.tagName === 'VIDEO') { adjustVideoSize(mediaElement, size); } else if (mediaElement.tagName === 'IMG') { adjustImageSize(mediaElement, size); } container.remove(); }; container.appendChild(iconButton); }); // 원래 크기 버튼 추가 var originalSizeButton = document.createElement('div'); originalSizeButton.className = 'icon-button'; originalSizeButton.innerHTML = ' 원래 사이즈'; originalSizeButton.onclick = function() { if (mediaElement.tagName === 'VIDEO') { resetVideoSize(mediaElement); } else if (mediaElement.tagName === 'IMG') { resetImageSize(mediaElement); } container.remove(); }; container.appendChild(originalSizeButton); } // 삭제 요청을 위한 URL 생성 및 AJAX 호출 function handleDelete(mediaElement) { var dataUrl = mediaElement.closest('.video-container')?.getAttribute('data-url') || mediaElement.closest('.image-container')?.getAttribute('data-url'); var thumbnailUrl = mediaElement.closest('.video-container') ? dataUrl.replace(/\.mp4$/, '_mp4_thumb.jpg') : null; var nonce = localStorage.getItem('ed_nonce') || ''; if (!nonce || !dataUrl) { console.error("Nonce value or data URL is missing."); return; } var deleteRequestUrl = "https://www.animalnara.com/editor/photo_uploader/popup/php/index.php?_nonce=" + encodeURIComponent(nonce) + "&act=photo_delete"; $.ajax({ url: deleteRequestUrl, type: 'POST', data: { photo_url: dataUrl, video_thumbnail_url: thumbnailUrl }, success: function (response) { alert("삭제가 완료되었습니다."); mediaElement.closest('.video-container')?.remove(); mediaElement.closest('.image-container')?.remove(); }, error: function () { alert("삭제 요청 중 오류가 발생했습니다."); } }); } // 이미지 크기 조정 function adjustImageSize(img, percentage) { img.style.width = (percentage) + '%'; } // 이미지 원래 크기 복원 function resetImageSize(img) { img.style.width = ''; } // 비디오 크기 조정 function adjustVideoSize(video, percentage) { video.style.width = (percentage) + '%'; } // 비디오 원래 크기 복원 function resetVideoSize(video) { video.style.width = ''; } // 비디오 드래그 기능 추가 $(document).on('mousedown', 'video', function(e) { e.preventDefault(); // 기본 드래그 방지 var video = $(this); var startX = e.pageX - video.position().left; var startY = e.pageY - video.position().top; $(document).on('mousemove.drag', function(e) { // 에디터 컨테이너 내에서만 드래그 가능하도록 설정 var editorContainer = $('.editor-container'); var containerOffset = editorContainer.offset(); var containerWidth = editorContainer.width(); var containerHeight = editorContainer.height(); var newLeft = e.pageX - startX; var newTop = e.pageY - startY; // 에디터 컨테이너의 경계를 넘지 않도록 설정 if (newLeft containerOffset.left + containerWidth) { newLeft = containerOffset.left + containerWidth - video.width(); } if (newTop containerOffset.top + containerHeight) { newTop = containerOffset.top + containerHeight - video.height(); } video.css({ top: newTop, left: newLeft, position: 'absolute' }); }); $(document).one('mouseup', function() { $(document).off('mousemove.drag'); }); // 비디오 클릭 시 버튼 표시 $(document).on('click', 'video', function(event) { showMediaButtons(event, this); }); // 이미지 클릭 시 버튼 표시 $(document).on('click', 'img', function(event) { showMediaButtons(event, this); }); // 에디터 클릭 시 버튼 제거 $(document).on('click', '.editor-container', function() { document.querySelector('.delete-button')?.remove(); document.querySelector('.representative-button')?.remove(); document.querySelectorAll('img, video').forEach(el => el.classList.remove('highlight')); });
0
게시물을 뉴스에 인용할때에는 애니멀나라 출처를 꼭 밝혀주세요.
저작권 게시물 및 규정에 어긋난 게시글의 경우 삭제가 될 수 있습니다.
메메르세데스마이바흐S 님의 더보기 →
댓글 0
첨부한 사진 미리보기 첨부한 사진 미리보기 첨부한 사진 미리보기 첨부한 사진 미리보기
새 댓글 확인

이전글 123

다음글 123

게시판 상단 공지/이벤트 리스트
구분 제목 글쓴이 추천 조회 등록일
BEST
모바일ㅎㅇㄴ 1 메르세데스마이바흐S 2,077 24.11.26
BEST
2 7 메르세데스마이바흐S 2,670 24.10.19
BEST
6 1 메르세데스마이바흐S 2,251 24.10.17
BEST
90 메르세데스마이바흐S 2,234 24.10.17
이벤트
기아자동차, 동급 최대의 실내공간을 구현한 카니발 내장 공개 공개 공개공 개공개 공개공개공 1,996 21.11.01
게시판 리스트
질문 7 메르세데스마이바흐S 1,822 24.10.03
질문 123 메르세데스마이바흐S 1,880 24.10.02
질문 7 메르세데스마이바흐S 1,819 24.10.02
잡담 6 레드케인 1,824 24.10.02
질문 ㅅㄷㄴㅅ 레드케인 1,773 24.10.02
잡담 2323 메르세데스마이바흐S 1,771 24.10.01
질문 87 레드케인 1,732 24.10.01
잡담 300 메르세데스마이바흐S 1,751 24.09.27
질문 123 메르세데스마이바흐S 1,747 24.09.27
질문 1 메르세데스마이바흐S 1,841 24.09.26
잡담 123 메르세데스마이바흐S 1,723 24.09.26
질문 123 메르세데스마이바흐S 1,733 24.09.26
질문 1 메르세데스마이바흐S 1,753 24.09.26
질문 12 메르세데스마이바흐S 1,730 24.09.26
현재글 질문 123 메르세데스마이바흐S 2,320 24.09.25
질문 34 메르세데스마이바흐S 1,716 24.09.24
질문 100퍼 메르세데스마이바흐S 1,760 24.09.24
질문 ㅎㅇ 메르세데스마이바흐S 2,461 24.09.19
질문 aa 메르세데스마이바흐S 1,879 24.09.12
질문 gd 메르세데스마이바흐S 1,777 24.09.12

글쓰기

1 2 3 4 5 6