292 lines
12 KiB
JavaScript
292 lines
12 KiB
JavaScript
// 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<f.length; i++) {
|
|
if (f.elements[i].name == "chk_wr_id[]")
|
|
f.elements[i].checked = sw;
|
|
}
|
|
}
|
|
|
|
// 목록 폼 제출
|
|
window.fboardlist_submit = function(f) {
|
|
var chk_count = 0;
|
|
for (var i=0; i<f.length; i++) {
|
|
if (f.elements[i].name == "chk_wr_id[]" && f.elements[i].checked)
|
|
chk_count++;
|
|
}
|
|
|
|
if (!chk_count) {
|
|
alert(document.pressed + "할 게시물을 하나 이상 선택하세요.");
|
|
return false;
|
|
}
|
|
|
|
if(document.pressed == "선택복사") {
|
|
select_copy("copy");
|
|
return false;
|
|
}
|
|
|
|
if(document.pressed == "선택이동") {
|
|
select_copy("move");
|
|
return false;
|
|
}
|
|
|
|
if(document.pressed == "선택삭제") {
|
|
if (!confirm("선택한 게시물을 정말 삭제하시겠습니까?\n\n한번 삭제한 자료는 복구할 수 없습니다\n\n답변글이 있는 게시글을 선택하신 경우\n답변글도 선택하셔야 게시글이 삭제됩니다."))
|
|
return false;
|
|
f.removeAttribute("target");
|
|
f.action = g5_bbs_url+"/board_list_update.php";
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
// 선택 복사/이동
|
|
window.select_copy = function(sw) {
|
|
var f = document.fboardlist;
|
|
if (sw == "copy") str = "복사";
|
|
else str = "이동";
|
|
var sub_win = window.open("", "move", "left=50, top=50, width=500, height=550, scrollbars=1");
|
|
f.sw.value = sw;
|
|
f.target = "move";
|
|
f.action = g5_bbs_url+"/move.php";
|
|
f.submit();
|
|
}
|
|
|
|
|
|
// ==========================================================================
|
|
// 게시판 읽기 (view.skin.php)
|
|
// ==========================================================================
|
|
|
|
// 게시물 이동/복사 창
|
|
window.board_move = function(href) {
|
|
window.open(href, "boardmove", "left=50, top=50, width=500, height=550, scrollbars=1");
|
|
}
|
|
|
|
// 뷰 페이지 초기화
|
|
$(function() {
|
|
if ($('#bo_v').length) {
|
|
|
|
// 더보기 메뉴 토글
|
|
$('.btn_more_opt.is_view_btn').on('click', function(e) {
|
|
e.stopPropagation(); // 이벤트 버블링 중단
|
|
$(this).next('.more_opt.is_view_btn').toggle();
|
|
});
|
|
|
|
// 외부 클릭 시 더보기 메뉴 닫기
|
|
$(document).on('click', function(e) {
|
|
if (!$(e.target).closest('.more_opt_wrapper').length) {
|
|
$('.more_opt.is_view_btn').hide();
|
|
}
|
|
});
|
|
|
|
// 파일 다운로드 클릭
|
|
$("a.view_file_download").click(function() {
|
|
if (typeof gallery_general_config !== 'undefined' && gallery_general_config.bo_download_point < 0) {
|
|
if(!g5_is_member) {
|
|
alert("다운로드 권한이 없습니다.\n회원이시라면 로그인 후 이용해 보십시오.");
|
|
return false;
|
|
}
|
|
var msg = "파일을 다운로드 하시면 포인트가 차감(" + number_format(String(Math.abs(gallery_general_config.bo_download_point))) + "점)됩니다.\n\n포인트는 게시물당 한번만 차감됩니다.\n\n그래도 다운로드 하시겠습니까?";
|
|
if(confirm(msg)) {
|
|
var href = $(this).attr("href");
|
|
$('#bo_v_file_down').attr('src', href);
|
|
}
|
|
return false;
|
|
}
|
|
});
|
|
|
|
// 이미지 크게 보기
|
|
$("a.view_image").click(function() {
|
|
window.open(this.href, "large_image", "location=yes,links=yes,toolbar=yes,top=10,left=10,width=10,height=10,resizable=yes,scrollbars=yes,status=yes");
|
|
return false;
|
|
});
|
|
|
|
// 추천, 비추천
|
|
$("#good_button, #nogood_button").click(function() {
|
|
var $tx = $(this);
|
|
var ex = $tx.attr('href');
|
|
|
|
if(ex) {
|
|
$.post(ex, { js: "on" }, function(data) {
|
|
if (data.error) {
|
|
alert(data.error);
|
|
return false;
|
|
}
|
|
|
|
if (data.count) {
|
|
$tx.find("strong").text(number_format(String(data.count)));
|
|
if($tx.attr("id").search("nogood") > -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자동 줄바꿈은 게시물 내용중 줄바뀐 곳을<br>태그로 변환하는 기능입니다.");
|
|
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);
|