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.
114 lines
3.9 KiB
JavaScript
114 lines
3.9 KiB
JavaScript
$(document).ready(function() {
|
|
resizeGallery();
|
|
|
|
$('.gallery-more').css('cursor', 'pointer').on('click', function() {
|
|
$('.next-item').slideDown('fast');
|
|
$(this).remove();
|
|
});
|
|
|
|
$('#writeForm').submit(function () {
|
|
if (!$("#name").checkEmpty('이름을 입력해 주세요.')) return false;
|
|
if (!$("#phone").checkEmpty('연락처를 입력해 주세요.')) return false;
|
|
if (!$("#email").checkEmpty('이메일을 입력해 주세요.')) return false;
|
|
if (!$("#content").checkEmpty('문의내용을 입력해 주세요.')) return false;
|
|
$.post($(this).attr('action'), $(this).serialize(), function(result) {
|
|
alert(result.message);
|
|
if (result.code == 'success') {
|
|
window.location.reload();
|
|
}
|
|
}).fail(function(result) {
|
|
console.log(result);
|
|
alert('문의 등록에 실패했습니다!!\n잠시 후 다시 시도해 주세요.');
|
|
});
|
|
|
|
return false;
|
|
});
|
|
|
|
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
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
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();
|
|
})
|
|
});
|
|
|
|
$(window).on('resize', function() {
|
|
resizeGallery();
|
|
});
|
|
|
|
function resizeGallery() {
|
|
$('.g-main').each(function() {
|
|
if($(this).find('.empty-txt').length > 0 || $(this).find('.grid').length == 0) return;
|
|
|
|
var gel = $(this).find('.grid').eq(0);
|
|
var gw = parseFloat(gel[0].getBoundingClientRect().width);
|
|
var gpl = parseFloat(gel.css('padding-left').replace(/[^0-9]/g,''));
|
|
var gpr = parseFloat(gel.css('padding-right').replace(/[^0-9]/g,''));
|
|
var g_img_height = (gw - (gpl+gpr)) * parseFloat(1);
|
|
|
|
$(this).find('.grid .g-img').css('height', g_img_height + 'px');
|
|
});
|
|
}
|