// theme/rd.laser/skin/board/gallery_general/script.js (function($) { // ========================================================================== // 게시판 목록 (list.skin.php) // ========================================================================== $(document).ready(function() { if ($('#bo_gall').length) { // 뷰 모드 전환 const viewModeButtons = document.querySelectorAll('.btn_view_mode'); const boardContainer = document.getElementById('bo_gall'); const boTable = (typeof gallery_general_config !== 'undefined') ? gallery_general_config.bo_table : ''; viewModeButtons.forEach(button => { button.addEventListener('click', function() { const mode = this.dataset.mode; viewModeButtons.forEach(btn => btn.classList.remove('active')); this.classList.add('active'); boardContainer.classList.remove('view-mode-card', 'view-mode-list'); boardContainer.classList.add('view-mode-' + mode); set_cookie('board_' + boTable + '_view_mode', mode, 365); }); }); // 💡 [추가] 노출 상태 토글 기능 $('.status-toggle-switch').on('click', function() { var $this = $(this); var wr_id = $this.data('wr-id'); var current_status = $this.data('status'); var new_status = (current_status == '1') ? '0' : '1'; var bo_table = gallery_general_config.bo_table; $.ajax({ url: './ajax.status_update.php', type: 'POST', data: { 'bo_table': bo_table, 'wr_id': wr_id, 'status': new_status }, dataType: 'json', success: function(data) { if (data.success) { $this.data('status', new_status); if (new_status == '1') { $this.removeClass('on').addClass('off'); } else { $this.removeClass('off').addClass('on'); } } else { alert(data.message || '상태 변경에 실패했습니다.'); } }, error: function() { alert('서버와의 통신 중 오류가 발생했습니다.'); } }); }); } }); // 전체 선택 window.all_checked = function(sw) { var f = document.fboardlist; for (var i=0; i -1) { $tx.attr("href", ex.replace("nogood", "good")); $tx.find("i").removeClass("far fa-thumbs-down").addClass("far fa-thumbs-up"); } else { $tx.attr("href", ex.replace("good", "nogood")); $tx.find("i").removeClass("far fa-thumbs-up").addClass("far fa-thumbs-down"); } } }, "json"); } return false; }); // 이미지 리사이즈 $("#bo_v_atc").viewimageresize(); } }); // ========================================================================== // 게시판 쓰기 (write.skin.php) // ========================================================================== $(function() { if ($('#bo_w').length) { // Datepicker if ($.fn.datepicker) { $(".datepicker").datepicker({ dateFormat: 'yy-mm-dd', prevText: '이전 달', nextText: '다음 달', monthNames: ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월'], monthNamesShort: ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월'], dayNames: ['일', '월', '화', '수', '목', '금', '토'], dayNamesShort: ['일', '월', '화', '수', '목', '금', '토'], dayNamesMin: ['일', '월', '화', '수', '목', '금', '토'], showMonthAfterYear: true, yearSuffix: '년' }); } // 예약 노출 토글 $('input[name="wr_9"]').change(function() { if ($(this).val() === 'RESERVED') { $('#reservation_fields').show(); } else { $('#reservation_fields').hide(); } }); // 에디터(textarea) 높이 자동 조절 var $wr_content = $("#wr_content"); $wr_content.css("overflow-y", "hidden").on("input keyup paste change", function() { this.style.height = "auto"; this.style.height = (this.scrollHeight) + "px"; }); // 초기 높이 설정 $wr_content.trigger("input"); // 글자수 제한 if (typeof gallery_general_config !== 'undefined' && (gallery_general_config.write_min || gallery_general_config.write_max)) { check_byte("wr_content", "char_count"); $("#wr_content").on("keyup", function() { check_byte("wr_content", "char_count"); }); } // 💡 [추가] 수동 임시저장 $("#btn_manual_autosave").click(function() { if (typeof(autosave) == "undefined") return; var subject = $.trim($("#wr_subject").val()); var content = $.trim(get_editor_content()); if (!subject || !content) { alert("제목과 내용을 모두 입력해야 임시저장할 수 있습니다."); return false; } autosave(); }); } }); window.html_auto_br = function(obj) { if (obj.checked) { result = confirm("자동 줄바꿈을 하시겠습니까?\n\n자동 줄바꿈은 게시물 내용중 줄바뀐 곳을
태그로 변환하는 기능입니다."); if (result) obj.value = "html2"; else obj.value = "html1"; } else obj.value = ""; } // 예약 노출 유효성 검사 (fwrite_submit 내부에서 호출) window.validate_reservation = function(f) { if (document.querySelector('input[name="wr_9"]:checked').value === 'RESERVED') { if (f.wr_2.value === '' || f.wr_3.value === '') { alert('예약 시작일과 종료일을 모두 선택해주세요.'); return false; } if (f.wr_2.value > f.wr_3.value) { alert('예약 종료일은 시작일보다 빠를 수 없습니다.'); return false; } } return true; } })(jQuery);