$(document).ready(function() { $('.gallery-more').css('cursor', 'pointer').on('click', function() { $('.next-item').slideDown('fast'); $(this).remove(); }); $('#writeForm').submit(function () { if (!$("#name").checkEmpty('이름 또는 업체명을 입력해 주세요.')) return false; if (!$("#email").checkEmpty('이메일 주소를 입력해 주세요.')) return false; if (!$("#subject").checkEmpty('제목을을 입력해 주세요.')) return false; if (!$("#content").checkEmpty('문의내용을 입력해 주세요.')) return false; $.post($(this).attr('action'), $(this).serialize(), function(result) { if (result.code == 'success') { alert('등록되었습니다.'); window.location.reload(); } else { alert(result.message); } }).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 }); 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(''); galleryBox.find('.portfolio-title').html(list.subject); galleryBox.find('.portfolio-desc').html(list.content.replaceAll('\r\n', '
')); $('#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(); }) });