You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
4.1 KiB
JavaScript
122 lines
4.1 KiB
JavaScript
$(document).ready(function() {
|
|
|
|
$('.gallery-more').css('cursor', 'pointer').on('click', function() {
|
|
$('.next-item').slideDown('fast');
|
|
$(this).remove();
|
|
});
|
|
|
|
$('#writeForm').submit(function (e) {
|
|
if (!$("#name").checkEmpty('이름 또는 업체명을 입력해 주세요.')) return false;
|
|
if (!$("#email").checkEmpty('이메일 주소를 입력해 주세요.')) return false;
|
|
if (!$("#phone").checkEmpty('연락처를 입력해 주세요.')) return false;
|
|
if (!$("#zone").checkEmpty('지역을 입력해 주세요.')) return false;
|
|
if (!$("#subject").checkEmpty('제목을 입력해 주세요.')) return false;
|
|
if (!$("#content").checkEmpty('문의내용을 입력해 주세요.')) return false;
|
|
|
|
var formData = new FormData(this);
|
|
|
|
$.ajax({
|
|
url : $(this).attr('action'),
|
|
type : 'POST',
|
|
data : formData,
|
|
enctype : 'multipart/form-data',
|
|
processData : false,
|
|
contentType : false,
|
|
dataType : 'json',
|
|
cache : false,
|
|
async : false,
|
|
success: function(result) {
|
|
if (result.code == 'success') {
|
|
alert('등록되었습니다.');
|
|
window.location.reload();
|
|
} else {
|
|
alert(result.message);
|
|
}
|
|
},
|
|
error: function(result) {
|
|
console.log(result);
|
|
alert('문의 등록에 실패했습니다!!\n잠시 후 다시 시도해 주세요.');
|
|
}
|
|
});
|
|
|
|
return false;
|
|
});
|
|
|
|
$('#file-add').on('click', function() {
|
|
$(this).parent().append(
|
|
'<div class="custom-file mb-2">'+
|
|
'<input type="file" name="files[]" class="form-control rounded-0 hand">'+
|
|
'</div>'
|
|
);
|
|
});
|
|
|
|
var currentPage = 1;
|
|
|
|
function getGalleryData(uid) {
|
|
$.get('/main/gallery/view', { 'uid': uid }, function(result) {
|
|
var data = result.data;
|
|
if (result.code == 'success' && data.assets && data.assets.length > 0) {
|
|
var assets = data.assets;
|
|
console.log(result.code);
|
|
var gallery = [];
|
|
$.each(assets, function(idx, asset) {
|
|
var item = {
|
|
'src': "/image/"+ asset.uid,
|
|
'thumb': "/image/rate/h80/"+ asset.uid,
|
|
'caption': data.subject,
|
|
};
|
|
gallery.push(item);
|
|
});
|
|
Fancybox.show(gallery, {
|
|
// Your options go here
|
|
});
|
|
resizeGallery();
|
|
}
|
|
});
|
|
}
|
|
|
|
function getGalleryList() {
|
|
$.get('/main/gallery', { 'page': currentPage }, function(result) {
|
|
if (!result.data.lists.length) {
|
|
return false;
|
|
}
|
|
|
|
var lists = result.data.lists;
|
|
var pages = result.data.pages;
|
|
|
|
$.each(lists, function(i, list) {
|
|
var galleryBox = $('#galleryBox');
|
|
galleryBox.find('.portfolio').attr('data-uid', list.uid);
|
|
galleryBox.find('.portfolio-img').html('<img src="/image/600x600/'+ list.assets[0].uid +'" />');
|
|
galleryBox.find('.portfolio-title').html(list.subject);
|
|
galleryBox.find('.portfolio-desc').html(list.content.replaceAll('\r\n', '<br>'));
|
|
$('#portfolio-list').append(galleryBox.html());
|
|
});
|
|
|
|
$('.portfolio').on('click', function(e) {
|
|
e.preventDefault();
|
|
getGalleryData($(this).data('uid'));
|
|
});
|
|
|
|
if (pages.mores) {
|
|
$('.now-count').html(pages.items);
|
|
$('.max-count').html(pages.total);
|
|
} else {
|
|
$('#galleryMore').remove();
|
|
}
|
|
|
|
currentPage++;
|
|
|
|
}).fail(function(result) {
|
|
console.log(result.responseJSON);
|
|
});
|
|
}
|
|
|
|
getGalleryList();
|
|
|
|
$('#galleryMore').on('click', function(e) {
|
|
e.preventDefault();
|
|
getGalleryList();
|
|
})
|
|
});
|