애니멀나라는 10월 19일 오픈 예정입니다
추천 검색어
지역 + 키워드를 함께 입력해 보세요
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 |조회 1,821 |추천 0
URL복사     http://www.animalnara.com/community/board_view.php?board_code=home&idx=5264&search_order=comment_count               
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 0
게시물을 뉴스에 인용할때에는 애니멀나라 출처를 꼭 밝혀주세요.
저작권 게시물 및 규정에 어긋난 게시글의 경우 삭제가 될 수 있습니다.
메메르세데스마이바흐S 님의 더보기 →
  • 0 식물 567(9) 01-27
  • 0 식물 5656 01-27
  • 0 식물 890- 01-27
  • 0 식물 df 01-27
  • 0 식물 dfdf 01-27
  • 0 식물 123 01-27
댓글 0
첨부한 사진 미리보기 첨부한 사진 미리보기 첨부한 사진 미리보기 첨부한 사진 미리보기
새 댓글 확인

이전글 123

다음글 123

게시판 상단 공지/이벤트 리스트
구분 제목 글쓴이 추천 조회 등록일
BEST
모바일ㅎㅇㄴ 1 메르세데스마이바흐S 1,691 24.11.26
BEST
2 7 메르세데스마이바흐S 2,056 24.10.19
BEST
6 1 메르세데스마이바흐S 1,736 24.10.17
BEST
90 메르세데스마이바흐S 1,700 24.10.17
이벤트
기아자동차, 동급 최대의 실내공간을 구현한 카니발 내장 공개 공개 공개공 개공개 공개공개공 1,875 21.11.01
게시판 리스트
잡담 1 74 메르세데스마이바흐S 2,340 24.08.18
질문 123 49 메르세데스마이바흐S 54 3,130 24.06.27
질문 2 44 메르세데스마이바흐S 3,620 24.08.22
질문 지금 이영현 체념 부르는데 정말 잘부르네요 강추 드립니다 온몸에 소름이 돋을정도로 42 메르세데스마이바흐S 3,232 24.06.08
질문 1 41 메르세데스마이바흐S 1 2,118 24.08.05
잡담 1 38 메르세데스마이바흐S 3,269 24.08.22
잡담 123 38 레드케인 2,327 24.06.26
잡담 7 37 메르세데스마이바흐S 1,977 24.08.18
질문 789 35 메르세데스마이바흐S 1,863 24.08.21
질문 789 35 메르세데스마이바흐S 1,796 24.08.21
잡담 1 35 레드케인 2,078 24.08.06
잡담 룰루 33 렌트사냥 3,218 24.08.23
질문 123 32 메르세데스마이바흐S 1,971 24.08.21
잡담 12 32 메르세데스마이바흐S 1,927 24.06.23
질문 678 30 메르세데스마이바흐S 2,939 24.08.23
질문 13 30 메르세데스마이바흐S 1,925 24.08.20
질문 123 28 메르세데스마이바흐S 1,817 24.08.14
잡담 678 28 메르세데스마이바흐S 1,920 24.06.23
질문 123 28 메르세데스마이바흐S 3,116 24.06.02
잡담 1 27 레드케인 37 2,458 24.07.23

글쓰기

1 2 3 4 5 6