This commit is contained in:
shim
2023-04-17 11:06:08 +09:00
parent d0b393aa97
commit 76264e09ad
4686 changed files with 552713 additions and 0 deletions

View File

@@ -0,0 +1,820 @@
/**
* --------------------------------------------------------------------------
* kimsQ Rb v2.5 모바일 기본형 게시판 테마 스크립트 (rc-default): component.js
* Homepage: http://www.kimsq.com
* Licensed under RBL
* Copyright 2018 redblock inc
* --------------------------------------------------------------------------
*/
var kakao_link_btn = $('#kakao-link-btn') //카카오톡 링크공유 버튼
var page_bbs_write_main = $('#page-bbs-write-main');
var page_bbs_write_category = $('#page-bbs-write-category');
var page_bbs_write_tag = $('#page-bbs-write-tag');
var page_bbs_list = $('#page-bbs-list');
var page_bbs_category = $('#page-bbs-category');
var page_bbs_result = $('#page-bbs-result');
var page_bbs_view = $('#page-bbs-view');
var modal_bbs_search = $('#modal-bbs-search');
var modal_bbs_write = $('#modal-bbs-write');
var modal_bbs_view = $('#modal-bbs-view');
var sheet_comment_write = $('#sheet-comment-write');
var popup_bbs_cancelCheck = $('#popup-bbs-cancelCheck');
var popup_comment_mypost = $('#popup-comment-mypost');
var popup_linkshare = $('#popup-link-share'); //링크공유 팝업
var popover_bbs_listMarkup = $('#popover-bbs-listMarkup');
var popover_bbs_view = $('#popover-bbs-view');
var editor_bbs;
var attach_file_saveDir = './files/bbs/';// 파일 업로드 폴더
var attach_module_theme = '_mobile/rc-post-file';// attach 모듈 테마
function overScrollEffect_bbs(page){
var page_startY = 0;
var page_endY = 0;
page.find('.content').on('touchstart',function(event){
page_startY = event.originalEvent.changedTouches[0].pageY;
});
page.find('.content').on('touchmove',function(event){
var page_moveY = event.originalEvent.changedTouches[0].pageY;
var page_contentY = $(this).scrollTop();
if (page_contentY === 0 && page_moveY > page_startY && !document.body.classList.contains('refreshing')) {
if (page_moveY-page_startY>50) {
edgeEffect(page,'top','show'); // 스크롤 상단 끝
}
}
if( (page_moveY < page_startY) && ($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight)) {
if (page_startY-page_moveY>50) {
edgeEffect(page,'bottom','show'); // 스크롤 하단 끝
}
}
});
}
function pullToRefresh_bbs(page){
var bid = page.attr('data-bid');
page.find('.content').on('touchstart',function(event){
page_startY = event.originalEvent.changedTouches[0].pageY;
});
page.find('.content').on('touchend',function(event){
var page_endY=event.originalEvent.changedTouches[0].pageY;
var page_contentY = $(this).scrollTop();
if (page_contentY === 0 && page_endY > page_startY ) {
if (page_endY-page_startY>150) {
resetBbsContent(page);
getBbsList(bid,'','','#page-bbs-list');
}
}
})
}
function resetBbsContent(page){
page.find('.content').empty();
var content_html = page.find('.content').clone();
page.find('.content').infinitescroll('destroy');
page.append(content_html);
page.find('[data-role="post"]').loader({ position: 'inside' });
activeBbsTab('list');
}
function activeBbsTab(item){
$('#page-bbs-list').find('.bar-tab .tab-item').removeClass('active');
$('#page-bbs-list').find('.bar-tab [data-role="'+item+'"]').addClass('active');
}
var p = page_bbs_list.find('[data-role="list-wrapper"]').attr('data-page');
page_bbs_list.on('show.rc.page', function (e) {
var button = $(e.relatedTarget);
var bid = button.attr('data-bid');
var page = $(this)
page.find('[data-toggle="popover"]').attr('data-bid',bid);
getBbsList(bid,'','','#page-bbs-list');
})
page_bbs_list.on('hidden.rc.page', function (e) {
var page = $(this);
page.find('[data-toggle="popover"]').removeAttr('data-bid');
resetBbsContent(page_bbs_list);
})
page_bbs_result.on('hidden.rc.page', function (e) {
var page = $(this);
page.find('[data-role="bname"]').text('');
page.find('[data-role="bbs-list"]').html('');
})
popover_bbs_listMarkup.find('[data-toggle="listMarkup"]').tap(function() {
var button = $(this)
var markup = button.attr('data-markup');
var bid = button.attr('data-bid');
history.back() // popover 닫기
localStorage.setItem('bbs-'+bid+'-listMarkup', markup);
resetBbsContent(page_bbs_list);
getBbsList(bid,'','','#page-bbs-list');
});
page_bbs_category.on('show.rc.page', function (e) {
var button = $(e.relatedTarget);
var bid = button.attr('data-bid');
var page = $(this)
page.attr('data-bid',bid);
setTimeout(function(){
page.find('.content').loader({ position: 'inside' });
$.post(rooturl+'/?r='+raccount+'&m=bbs&a=get_categoryList',{
bid : bid,
},function(response){
var result = $.parseJSON(response);
var list=result.list;
page.find('.content').html(list)
})
}, 200);
})
page_bbs_category.on('hidden.rc.page', function (e) {
var page = $(this);
page.find('.content').html('');
})
page_bbs_category.on('click','[data-act="category"]',function(){
var bid = page_bbs_category.attr('data-bid');
var category = $(this).attr("data-cat");
var bname = $(this).attr("data-bname");
setTimeout(function(){
page_bbs_result.find('[data-role="bname"]').text(bname);
page_bbs_result.page({ start: '#page-bbs-category',title: category });
page_bbs_result.find('[data-role="bbs-list"]').loader({ position: 'inside' });
setTimeout(function(){
getBbsList(bid,category,'','#page-bbs-result');
}, 200);
}, 10);
});
page_bbs_view.on('click','[data-act="category"]',function(){
var category = $(this).attr("data-cat");
var bname = $(this).attr("data-bname");
var bid = page_bbs_view.find('[name="bid"]').val();
var start = page_bbs_view.attr('data-start');
getBbsList(bid,category,'','#page-bbs-result');
history.back(); //이전 페이지 이동
setTimeout(function(){
page_bbs_result.find('[data-role="bname"]').text(bname);
page_bbs_result.page({ start: start,title: category });
}, 300);
});
page_bbs_view.on('click','[data-act="tag"]',function(){
var tag = $(this).attr("data-tag");
var bname = $(this).attr("data-bname");
var bid = page_bbs_view.find('[name="bid"]').val();
var start = page_bbs_view.attr('data-start');
getBbsList(bid,'',tag+';tag','#page-bbs-result');
history.back(); //이전 페이지 이동
setTimeout(function(){
page_bbs_result.find('[data-role="bname"]').text(bname);
page_bbs_result.page({ start: start,title: '# '+tag });
}, 300);
});
modal_bbs_search.find('[data-role="search"]').submit(function(e){
e.preventDefault();
var form = $(this);
var bid = form.attr('data-bid');
var bname = form.attr('data-bname');
var keyword = form.find('[name="keyword"]').val();
var where = form.find('[name="where"]').val();
var search = keyword+';'+where;
history.back(); // 모달 닫기
form.find('[name="keyword"]').blur().val(''); //가상 키보드 내리기
setTimeout(function(){
page_bbs_result.find('[data-role="bname"]').text(bname);
page_bbs_result.page({ start: '#page-bbs-list',title: keyword+' 검색결과' });
page_bbs_result.find('[data-role="bbs-list"]').loader({ position: 'inside' });
setTimeout(function(){
getBbsList(bid,'',search,'#page-bbs-result');
}, 200);
}, 10);
});
$(document).on('tap','[data-act="reset"]',function() {
var bid = page_bbs_list.attr('data-bid');
resetBbsContent(page_bbs_list);
getBbsList(bid,'','','#page-bbs-list');
});
page_bbs_list.find('.content').on( 'scroll', function(){
var page = $(this);
var pos =$(this).scrollTop();
});
$('[data-act="opinion"]').click(function() {
getIframeForAction('');
frames.__iframe_for_action__.location.href = $(this).attr("data-url");
});
// Popover : 리스트 마크업 목록
popover_bbs_listMarkup.on('show.rc.popover', function (e) {
var button = $(e.relatedTarget)
var bid = button.attr('data-bid')
$(this).find('.table-view-cell').attr('data-bid',bid)
var popover = $(this)
var _local_listMarkup = localStorage.getItem('bbs-'+bid+'-listMarkup');
var local_listMarkup = _local_listMarkup?_local_listMarkup:'media';
popover.find('[data-toggle="listMarkup"]').removeClass('table-view-info');
popover.find('[data-toggle="listMarkup"][data-markup="'+local_listMarkup+'"]').addClass('table-view-info');
})
// Popover : 게시물 관리
popover_bbs_view.on('show.rc.popover', function (e) {
var button = $(e.relatedTarget)
var bid = button.attr('data-bid');
var uid = button.attr('data-uid');
$(this).find('.table-view-cell').attr('data-bid',bid).attr('data-uid',uid)
var subject = button.attr('data-subject')
var popover = $(this)
var origin = $(location).attr('origin');
var path = button.attr('data-url')?button.attr('data-url'):'';
popover.find('[data-toggle="linkCopy"]').attr('data-clipboard-text',origin+path)
popover.find('[data-toggle="linkShare"]').attr('data-subject',subject).attr('data-url',origin+path)
})
modal_bbs_search.on('shown.rc.modal', function (e) {
var button = $(e.relatedTarget)
var bid = button.attr('data-bid');
var bname = button.attr('data-title');
var modal = $(this);
modal.find('form').attr('data-bid',bid).attr('data-bname',bname);;
setTimeout(function(){ modal.find('[name="keyword"]').focus(); }, 100);
});
modal_bbs_search.on('hidden.rc.modal', function (e) {
var modal = $(this);
modal.find('form').attr('data-bid','').attr('data-name','');
modal.find('[name="keyword"]').blur().val('');
});
//글쓰기 모달이 열릴때
modal_bbs_write.on('shown.rc.modal', function (e) {
var button = $(e.relatedTarget)
var modal = $(this);
var uid = modal.find('[name="uid"]').val();
var subject = page_bbs_view.find('[data-role="subject"]').text();
if (uid) var bid = modal.find('[name="bid"]').val();
else var bid = button.attr('data-bid');
modal.find('[data-act="submit"]').attr('disabled', false);
modal.find('[data-role="loader"]').removeClass('d-none') //로더 제거
modal.find('form').addClass('d-none')
modal.find('[data-act="submit"]').addClass('d-none');
if (bid) modal.find('[name="bid"]').val(bid);
setTimeout(function(){
// 글쓰기 권한 체크
$.post(rooturl+'/?r='+raccount+'&m=bbs&a=check_permWrite',{
bid : bid
},function(response){
var result = $.parseJSON(response);
var main=result.main;
var pcode=result.pcode;
var isperm =result.isperm;
if (!isperm) {
history.back();
setTimeout(function(){
$.notify({message: '작성권한이 없습니다.'},{type: 'default'});
}, 300);
//modal.find('.page .content').html(main);
return false
} else {
modal.find('[name="pcode"]').val(pcode);
modal.find('[data-toggle="collapse"]').addClass('collapsed');
modal.find('.collapse').removeClass('in');
// 미디어셋 초기화
modal.find('[data-role="attach-files"]').RbUploadFile(bbs_upload_settings); // 아작스 폼+input=file 엘리먼트 세팅
modal.find('[data-role="attach-files"]').RbAttachTheme(bbs_attach_settings);
modal.find('[data-sortable="mediaset"]').sortable({
axis: 'y',
cancel: 'button',
delay: 250,
update: function( event, ui ) {
var attachfiles=modal.find('input[name="attachfiles[]"]').map(function(){return $(this).val()}).get();
var new_upfiles='';
if(attachfiles){
for(var i=0;i<attachfiles.length;i++) {
new_upfiles+=attachfiles[i];
}
}
$.post(rooturl+'/?r='+raccount+'&m=mediaset&a=modifygid',{
attachfiles : new_upfiles
})
}
});
// 에디터 초기화
DecoupledEditor
.create( document.querySelector( '#modal-bbs-write [data-role="editor-body"]' ),{
placeholder: '본문 입력...',
toolbar: [ 'alignment:left','alignment:center','bulletedList','blockQuote','imageUpload','insertTable','undo'],
removePlugins: [ 'ImageToolbar', 'ImageCaption', 'ImageStyle',,'WordCount' ],
image: {},
language: 'ko',
extraPlugins: [rbUploadAdapterPlugin],
table: {
contentToolbar: [ 'tableColumn', 'tableRow', 'mergeTableCells' ]
},
mediaEmbed: {
extraProviders: [
{
name: 'other',
url: /^([a-zA-Z0-9_\-]+)\.([a-zA-Z0-9_\-]+)\.([a-zA-Z0-9_\-]+)/
},
{
name: 'another',
url: /^([a-zA-Z0-9_\-]+)\.([a-zA-Z0-9_\-]+)/
}
]
},
typing: {
transformations: {
include: [
'quotes',
'typography',
],
extra: [
// Add some custom transformations e.g. for emojis.
{ from: ':)', to: '🙂' },
{ from: ':+1:', to: '👍' },
{ from: ':tada:', to: '🎉' }
],
}
}
} )
.then( newEditor => {
console.log('editor_bbs init');
modal.find('[data-role="loader"]').addClass('d-none'); //로더 제거
modal.find('[data-act="submit"]').removeClass('d-none');
modal.find('form').removeClass('d-none');
editor_bbs = newEditor;
modal.find('.toolbar-container').html(editor_bbs.ui.view.toolbar.element)
editor_bbs.editing.view.document.on( 'change:isFocused', ( evt, name, value ) => {
if (value) {
console.log('editor_bbs focus');
modal.addClass('editor-focused');
} else {
console.log('editor_bbs blur');
modal.removeClass('editor-focused');
}
} );
if (uid) {
modal.find('[data-act="submit"] .not-loading').text('수정');
modal.find('[name="subject"]').val(subject);
$.post(rooturl+'/?r='+raccount+'&m=bbs&a=get_postData',{
bid : bid,
uid : uid,
mod : 'edit'
},function(response){
var result = $.parseJSON(response);
var content=result.content;
var category=result.category;
var notice=result.notice;
var hidden=result.hidden;
var tag=result.tag;
var adddata=result.adddata;
var featured_img=result.featured_img;
var attachNum=result.attachNum;
var attachFileTheme = result.theme_attachFile;
editor_bbs.setData(content);
modal.find('[name="category"]').val(category);
modal.find('[name="notice"]').val(notice);
modal.find('[name="hidden"]').val(hidden);
if (notice==1) modal.find('[data-role="notice"]').addClass('active');
else modal.find('[data-role="notice"]').removeClass('active');
if (hidden==1) modal.find('[data-role="hidden"]').addClass('active');
else modal.find('[data-role="hidden"]').removeClass('active');
if (category) {
page_bbs_write_main.find('[data-role="category"]').text(category);
} else {
page_bbs_write_main.find('[data-role="category"]').text('');
}
if (tag) {
modal.find('[name="tag"]').val(tag);
page_bbs_write_main.find('[data-role="tag"]').text(tag);
} else {
modal.find('[name="tag"]').val('');
page_bbs_write_main.find('[data-role="tag"]').text('');
}
if (attachNum) {
$.post(rooturl+'/?r='+raccount+'&m=mediaset&a=getAttachFileList',{
p_module : 'bbs',
uid : uid,
theme_file : attachFileTheme,
mod : 'upload'
},function(response){
var result = $.parseJSON(response);
var photo=result.photo;
var video=result.video;
var audio=result.audio;
var file=result.file;
var zip=result.zip;
var doc=result.doc;
modal.find('[name="featured_img"]').val(featured_img); // 대표이미지 셋팅
modal.find('[data-role="attach-preview-photo"]').html(photo);
modal.find('[data-role="attach-preview-video"]').html(video)
modal.find('[data-role="attach-preview-audio"]').html(audio)
modal.find('[data-role="attach-preview-file"]').html(file)
modal.find('[data-role="attachNum"]').text(attachNum)
});
} else {
modal.find('[data-role="attachNum"]').text('');
}
});
} else {
modal.find('[data-act="submit"] .not-loading').text('등록');
}
})
.catch( error => {
console.error( error );
} );
}
});
//부가항목 셋팅
$.post(rooturl+'/?r='+raccount+'&m=bbs&a=get_writeMeta',{
bid : bid
},function(response){
var result = $.parseJSON(response);
var list=result.list;
var has_category = result.has_category;
modal.find('[data-role="bbs-meta"]').html(list)
//카테고리 불러오기
if (has_category) {
$.post(rooturl+'/?r='+raccount+'&m=bbs&a=get_categoryList',{
mod: 'write',
bid : bid
},function(response){
var result = $.parseJSON(response);
var list=result.list;
var category = page_bbs_write_main.find('[data-role="category"]').text();
page_bbs_write_category.find('.content').html(list)
if (category) {
page_bbs_write_category.find('[name="category_radio"][value="'+category+'"]').prop('checked', true);
} else {
page_bbs_write_category.find('[name="category_radio"]').prop('checked', false);
}
})
}
// 비밀글 처리
modal.find('[data-role="hidden"]').on('changed.rc.switch', function () {
if ($(this).hasClass('active')) {
modal.find('[name="hidden"]').val(1)
} else {
modal.find('[name="hidden"]').val(0)
}
})
// 공지글 처리
modal.find('[data-role="notice"]').on('changed.rc.switch', function () {
if ($(this).hasClass('active')) {
modal.find('[name="notice"]').val(1)
} else {
modal.find('[name="notice"]').val(0)
}
})
})
}, 300);
})
//글쓰기 모달이 닫힐때
modal_bbs_write.on('hidden.rc.modal', function (e) {
var submitting = false;
var modal = modal_bbs_write;
if(modal.find('[data-act="submit"]').is(":disabled")) var submitting = true;
modal.find('[name="uid"]').val(''); // uid 초기화
modal.find('[name="pcode"]').val(''); // pcode 초기화
modal.find('[data-role="attach-files"]').html(''); // 첨부요소 destroy
modal.find('.ajax-file-upload-container').remove(); // 첨부요소 destroy
if (modal.find('.ck-editor__editable').length) {
var subject = modal.find('[name="subject"]').val();
var content = editor_bbs.getData();
editor_bbs.destroy(); //에디터 제거
console.log('editor_bbs.destroy');
if (!submitting && (content || subject)) {
setTimeout(function(){
popup_bbs_cancelCheck.popup({
backdrop: 'static'
}); // 글쓰기 취소확인 팝업 호출
}, 200);
}
}
})
// 글 등록
modal_bbs_write.find('[data-act="submit"]').click(function(event){
var modal = modal_bbs_write;
var bid = modal.find('[name="bid"]').val();
var uid = modal.find('[name="uid"]').val();
var theme = modal.find('[name="theme"]').val();
var notice = modal.find('[name="notice"]').val();
var hidden = modal.find('[name="hidden"]').val();
var category = modal.find('[name="category"]').val();
var tag = modal.find('[name="tag"]').val();
var backtype = modal.find('[name="backtype"]').val();
var nlist = modal.find('[name="nlist"]').val();
var pcode = modal.find('[name="pcode"]').val();
var upfiles = modal.find('[name="upfiles"]').val('');
var _markup = localStorage.getItem('bbs-'+bid+'-listMarkup');
var markup = _markup?_markup:'media'
if (!memberid) {
var name_el = modal.find('[name="name"]');
var name = name_el.val();
var pw_el = modal.find('[name="pw"]');
var pw = pw_el.val();
}
var subject_el = modal.find('[name="subject"]');
var subject = subject_el.val();
var editorData = editor_bbs.getData();
if (!subject_el.val()) {
subject_el.focus()
setTimeout(function(){$.notify({message: '제목을 입력해 주세요.'},{type: 'default'})}, 450);
return false;
}
if (editorData == '') {
editor_bbs.editing.view.focus();
setTimeout(function(){$.notify({message: '본문을 입력해 주세요.'},{type: 'default'})}, 450);
return false;
}
if (notice && hidden) {
if (notice == 1 && hidden == 1)
{
$.notify({message: '공지글은 비밀글로 등록할 수 없습니다.'},{type: 'default'});
return false;
}
}
if (category && category == '')
{
$.notify({message: '카테고리를 선택해 주세요.'},{type: 'default'});
page_bbs_write_category.page({ start: '#page-bbs-write-main' });
return false;
}
// 대표이미지가 없을 경우, 첫번째 업로드 사진을 지정함
var featured_img_input = $('#modal-bbs-write').find('input[name="featured_img"]'); // 대표이미지 input
var featured_img_uid = featured_img_input.val();
if(!featured_img_uid){ // 대표이미지로 지정된 값이 없는 경우
var first_attach_img_li = $('#modal-bbs-write').find('[data-role="attach-preview-photo"] li:first'); // 첫번째 첨부된 이미지 리스트 li
var first_attach_img_uid = first_attach_img_li.attr('data-id');
featured_img_input.val(first_attach_img_uid);
}
// 첨부파일 uid 를 upfiles 값에 추가하기
var attachfiles=$('#modal-bbs-write').find('input[name="attachfiles[]"]').map(function(){return $(this).val()}).get();
var new_upfiles='';
if(attachfiles){
for(var i=0;i<attachfiles.length;i++) {
new_upfiles+=attachfiles[i];
}
$('#modal-bbs-write').find('input[name="upfiles"]').val(new_upfiles);
}
var upfiles = modal.find('[name="upfiles"]').val();
var featured_img = modal.find('[name="featured_img"]').val();
$(this).attr("disabled",true);
if($('[data-role="bbs-list"] [data-role="post"] [data-role="list-wrapper"]').length > 0) var list_wrapper = 1;
else var list_wrapper = 0;
setTimeout(function(){
$.post(rooturl+'/?r='+raccount+'&m=bbs&a=write',{
bid : bid,
uid : uid,
theme : theme,
name : name,
subject : subject,
content : editorData,
notice : notice,
hidden : hidden,
category : category,
tag : tag,
upfiles : upfiles,
featured_img : featured_img,
backtype : backtype,
pcode : pcode,
markup : markup,
list_wrapper: list_wrapper
},function(response){
var result = $.parseJSON(response);
var error = result.error;
var item = result.item;
var notice = result.notice;
var _uid = result.uid;
var subject = result.subject;
var content = result.content;
if (!error) {
history.back(); // 게시판 글쓰기 모달 닫기
setTimeout(function(){
if (!uid) {
$('[data-role="bbs-list"]').find('[data-role="empty"]').addClass('d-none');
$('[data-role="bbs-list"]').find('.content').animate({scrollTop : 0}, 100);
if (list_wrapper) {
if (notice==1) $('[data-role="bbs-list"] [data-role="notice"] [data-role="list-wrapper"]').prepend(item);
else $('[data-role="bbs-list"] [data-role="post"] [data-role="list-wrapper"]').prepend(item);
} else {
if (notice==1) $('[data-role="bbs-list"] [data-role="notice"]').prepend(item);
else $('[data-role="bbs-list"] [data-role="post"]').prepend(item);
}
$('[data-role="bbs-list"]').find('#item-'+_uid).addClass('animated fadeInDown').attr('tabindex','-1').focus();
} else {
// 게시물 수정일 경우
$('[data-role="bbs-view"]').find('[data-role="subject"]').text(subject);
$('[data-role="bbs-view"]').find('[data-role="article-body"]').html(content);
$('[data-role="bbs-list"]').find('#item-'+uid+' a').removeAttr('data-subject').attr('data-subject',subject);
$('[data-role="bbs-list"]').find('#item-'+uid+' [data-role="subject"]').text(subject);
$('[data-role="bbs-list"]').find('#item-'+uid).attr('tabindex','-1').focus();
$.post(rooturl+'/?r='+raccount+'&m=bbs&a=get_postData',{
bid : bid,
uid : uid,
mod : 'view'
},function(response){
var result = $.parseJSON(response);
var featured_img=result.featured_img;
var adddata=result.adddata;
var photo=result.photo;
var video=result.video;
var audio=result.audio;
var file=result.file;
var hidden=result.hidden;
$('[data-role="bbs-list"]').find('#item-'+uid+' [data-role="featured_img"]').attr('src',featured_img); //대표이미지 갱신
if (photo) { // 첨부 이미지가 있을 경우
$('[data-role="bbs-view"]').find('[data-role="attach-photo"]').removeClass('hidden').html(photo)
}
if (video) { // 첨부 비디오가 있을 경우
$('[data-role="bbs-view"]').find('[data-role="attach-video"]').removeClass('hidden').html(video)
$('[data-role="bbs-view"]').find('.mejs__overlay-button').css('margin','0') //mejs-player 플레이버튼 위치재조정
}
if (audio) { // 첨부 오디오가 있을 경우
$('[data-role="bbs-view"]').find('[data-role="attach-audio"]').removeClass('hidden').html(audio)
}
if (file) { // 첨부 기타파일이 있을 경우
$('[data-role="bbs-view"]').find('[data-role="attach-file"]').removeClass('hidden').html(file)
}
});
}
//글쓰기 모달 상태 초기화
$(this).attr('disabled', false); //글쓰기 전성버튼 상태 초기화
modal_bbs_write.find('[name="bid"]').val('');
modal_bbs_write.find('[name="subject"]').val(''); //제목 입력내용 초기화
modal_bbs_write.find('[name="featured_img"]').val(''); //대표이미지 입력내용 초기화
modal_bbs_write.find('[name="upfiles"]').val(''); //첨부파일 입력내용 초기화
modal_bbs_write.find('[name="notice"]').val(''); // 공지글 설정
modal_bbs_write.find('[name="hidden"]').val(''); // 비밀글 설정
modal_bbs_write.find('[data-role="editor-body"]').empty(); //본문내용 초기화
modal_bbs_write.find('[data-role="tap-attach"] .badge').text(''); //첨부수량 초기화
modal_bbs_write.find('[data-role="attach-preview-photo"]').html(''); //첨부사진 영역 초기화
modal_bbs_write.find('[data-role="attach-preview-video"]').html('');
modal_bbs_write.find('[data-role="attach-preview-audio"]').html('');
modal_bbs_write.find('[data-role="attach-preview-file"]').html('');
modal_bbs_write.find('[data-role="attach-files"]').html('');
modal_bbs_write.find('[data-role="bbs-meta"]').html('');
}, 600);
}
});
}, 300);
});
// 글쓰기 취소확인 처리
popup_bbs_cancelCheck.find('[data-toggle="cancelCheck"]').tap(function(event) {
event.preventDefault();
event.stopPropagation();
var value = $(this).attr('data-value');
if (value=='no') {
history.back();
setTimeout(function(){ modal_bbs_write.modal('show'); }, 10);
} else {
history.back();
modal_bbs_write.find('[name="bid"]').val('');
modal_bbs_write.find('[name="subject"]').val('') //제목 입력내용 초기화
modal_bbs_write.find('[name="featured_img"]').val('') //대표이미지 입력내용 초기화
modal_bbs_write.find('[name="hidden"]').val('') // 비밀글 설정 초기화
modal_bbs_write.find('[name="notice"]').val('') // 공지글 설정 초기화
modal_bbs_write.find('[name="category"]').val('') // 카테고리 설정 초기화
modal_bbs_write.find('[data-role="category"]').text('') // 카테고리 설정 초기화
modal_bbs_write.find('[name="tag"]').val('') // 태그 설정 초기화
modal_bbs_write.find('[data-role="tag"]').text('') // 태그 설정 초기화
modal_bbs_write.find('[name="upfiles"]').val('') //첨부파일 입력내용 초기화
modal_bbs_write.find('[data-role="editor-body"]').empty() //본문내용 초기화
modal_bbs_write.find('[data-role="attach-preview-photo"]').html(''); //첨부사진 영역 초기화
modal_bbs_write.find('[data-role="attach-preview-video"]').html('');
modal_bbs_write.find('[data-role="attach-preview-audio"]').html('');
modal_bbs_write.find('[data-role="attach-preview-file"]').html('');
modal_bbs_write.find('[data-role="attach-files"]').html('');
modal_bbs_write.find('[data-role="attachNum"]').text('');
modal_bbs_write.find('[data-role="bbs-meta"]').html('');
modal_bbs_write.find('[data-toggle="switch"]').removeClass('active');
page_bbs_write_category.find('[name="category_radio"]').prop('checked', false);
console.log('입력사항 초기화');
}
});
popup_comment_mypost.on('show.rc.popup', function (e) {
var button = $(e.relatedTarget);
var uid = button.attr('data-uid');
var type = button.attr('data-type');
var parent = button.attr('data-parent');
var notice = button.closest('[data-role="'+type+'-item"]').attr('data-notice');
var hidden = button.closest('[data-role="'+type+'-item"]').attr('data-hidden');
var popup = $(this);
popup.find('[data-role="comment"]').removeClass('d-none');
if (type=='oneline') popup.find('[data-role="comment"]').addClass('d-none');
if (notice=="true") popup.find('[data-kcact="notice"] span').text('해제')
else popup.find('[data-kcact="notice"] span').text('')
if (hidden=="true") popup.find('[data-act="edit"]').attr('data-hidden','true');
else popup.find('[data-act="edit"]').attr('data-hidden','false');
popup.find('.table-view-cell a').attr('data-uid',uid);
popup.find('.table-view-cell a').attr('data-type',type)
})
// 카테고리 항목 클릭에 글쓰기폼의 name="category" 에 값 적용하기
page_bbs_write_category.on('click','[type="radio"]',function(){
var radio_val = $(this).val()
modal_bbs_write.find('[name="category"]').val(radio_val);
modal_bbs_write.find('[data-role="category"]').text(radio_val)
});
// 태그 페이지가 닫힐때 태그폼의 내용을 추출하여 글쓰기폼의 name="tag" 에 값 적용하기
page_bbs_write_tag.on('shown.rc.page', function () {
var tag = $('#page-bbs-write-tag').find('[name="tag"]')
setTimeout(function(){ tag.focus() }, 300);
})
page_bbs_write_tag.on('hidden.rc.page', function () {
var tag_input = $('#page-bbs-write-tag').find('[name="tag"]');
var tag = tag_input.val()
tag_input.blur();
modal_bbs_write.find('[name="tag"]').val(tag);
page_bbs_write_main.find('[data-role="tag"]').text(tag);
})

View File

@@ -0,0 +1,157 @@
/**
* --------------------------------------------------------------------------
* kimsQ Rb v2.5 모바일 기본형 게시판 테마 스크립트 (rc-default): list.js
* Homepage: http://www.kimsq.com
* Licensed under RBL
* Copyright 2019 redblock inc
* --------------------------------------------------------------------------
*/
function getBbsList(bid,cat,search,page){
var _markup = localStorage.getItem('bbs-'+bid+'-listMarkup');
var markup = _markup?_markup:'media';
var markup_list=markup+'-list'; // 목록 마크업
var markup_item=markup+'-item'; // 아이템 마크업
var page = $(page);
var container = page.find('[data-role="bbs-list"]');
if (search) {
var search = search.split(";");
var keyword = search[0];
var where = search[1] ;
} else {
var keyword = '';
var where = '';
}
page.attr('data-bid',bid);
page.find('[data-role="bar-tab"]').remove();
setTimeout(function(){
$.post(rooturl+'/?r='+raccount+'&m=bbs&a=get_listData',{
bid : bid,
},function(response){
var result = $.parseJSON(response);
var error=result.error;
var theme=result.theme;
var theme_css = '/modules/bbs/themes/'+theme+'/_main.css';
var recnum=result.recnum;
var totalPage = result.TPG;
var totalNUM = result.NUM;
var sort=result.sort;
var orderby=result.orderby;
var bar_tab=result.bar_tab;
var currentPage =1; // 처음엔 무조건 1, 아래 더보기 진행되면서 +1 증가
var prevNUM = currentPage * recnum;
var moreNUM = totalNUM - prevNUM ;
if (error) {
history.back();
setTimeout(function(){ $.notify({message: error},{type: 'default'}) }, 500);
} else {
page.find('[data-role="bar-nav"]').after(bar_tab);
if (!$('link[href="'+theme_css+'"]').length)
$('<link/>', {
rel: 'stylesheet',
type: 'text/css',
href: theme_css
}).appendTo('head');
container.empty();
container.append('<div data-role="notice" class="d-none"></div><div data-role="post"></div>');
container.find('[data-role="post"]').loader({ position: 'inside' });
$.post(rooturl+'/?r='+raccount+'&m=bbs&a=get_postList',{
bid : bid,
sort: sort,
orderby: orderby,
recnum: recnum,
markup_list : markup_list,
markup_item : markup_item,
keyword : keyword,
where : where,
cat : cat,
p : 1
},function(response){
var result = $.parseJSON(response);
var error=result.error;
var list=result.list;
if (error) {
history.back();
setTimeout(function(){ $.notify({message: '다시 시도해 주세요.'},{type: 'default'}) }, 500);
} else {
var num=result.num;
var num_notice=result.num_notice;
var list_post=result.list_post;
var list_notice=result.list_notice;
// 상태 초기화
container.find('[data-role="post"]').html('');
container.find('[data-role="notice"]').html('');
container.find('[data-role="post"]').html(list_post);
container.find('[data-role="notice"]').html(list_notice);
container.find('[data-plugin="timeago"]').timeago();
container.find('[data-plugin="markjs"]').mark(keyword); // marks.js
container.find('[data-role="notice"]').removeClass('d-none');
if (cat || keyword) {
container.find('[data-role="post"] [data-role="toolbar"]').removeClass('d-none');
container.find('[data-role="notice"]').addClass('d-none');
container.find('[data-start]').attr('data-start','#page-bbs-result');
if (!num) {
container.find('[data-role="empty"] [type="button"]').removeClass('d-none');
}
}
overScrollEffect_bbs(page_bbs_list)
pullToRefresh_bbs(page_bbs_list)
//무한 스크롤
container.infinitescroll({
dataSource: function(helpers, callback){
var nextPage = parseInt(currentPage)+1;
if (totalPage>currentPage) {
$.post(rooturl+'/?r='+raccount+'&m=bbs&a=get_postList',{
bid : bid,
sort: sort,
orderby: orderby,
recnum: recnum,
markup_list : markup_list,
markup_item : markup_item,
keyword : keyword,
where : where,
cat : cat,
p : nextPage
},function(response) {
var result = $.parseJSON(response);
var error = result.error;
var list=result.list_post;
var page=result.page;
if(error) alert(result.error_comment);
callback({ content: list });
currentPage++; // 현재 페이지 +1
console.log(currentPage+'페이지 불러옴')
container.find('[data-role="list-wrapper"]').attr('data-page',page);
container.find('[data-plugin="timeago"]').timeago();
//container.find('[data-plugin="markjs"]').mark(keyword); // marks.js
});
} else {
callback({ end: true });
console.log('더이상 불러올 페이지가 없습니다.')
}
},
appendToEle : container.find('[data-role="post"] [data-role="list-wrapper"]'),
percentage : 75, // 95% 아래로 스크롤할때 다움페이지 호출
hybrid : false // true: 버튼형, false: 자동
});
}
});
}
})
}, 100);
};

View File

@@ -0,0 +1,703 @@
/**
* --------------------------------------------------------------------------
* kimsQ Rb v2.5 모바일 기본형 게시판 테마 스크립트 (rc-default): view.js
* Homepage: http://www.kimsq.com
* Licensed under RBL
* Copyright 2019 redblock inc
* --------------------------------------------------------------------------
*/
function getBbsView(settings){
var type=settings.type; //컴포넌트 타입
var mid=settings.mid; // 컴포넌트 아이디
var ctheme=settings.ctheme; // 댓글테마
var landing = settings.landing;
var page = $('[data-role="bbs-view"]')
var sheet_comment_write = $('#sheet-comment-write') // 댓글 작성 sheet
var page_bbs_photo = $('#page-bbs-photo'); // 샤진 크게보기 페이지
var page_bbs_opinion = $('#page-bbs-opinion');
var popup_linkshare = $('#popup-link-share') //링크공유 팝업
var kakao_link_btn = $('#kakao-link-btn') //카카오톡 링크공유 버튼
var popover_bbs_view = $('#popover-bbs-view') // 게시물 관리 팝오버
// 게시물보기 모달이 보여질때 : 게시물 본문영역 셋팅
$(mid).on('show.rc.'+type, function(event) {
var ele = $(event.relatedTarget) // 모달을 호출한 아이템 정의
var start = $(ele).attr('data-start')?$(ele).attr('data-start'):''; // 시작페이지
var bid = $(ele).attr('data-bid')?$(ele).attr('data-bid'):''; // 게시판 아이디
var uid = $(ele).attr('data-uid')?$(ele).attr('data-uid'):''; // 대상 PK
var subject = $(ele).attr('data-subject')?$(ele).attr('data-subject'):''; // 제목
var cat = $(ele).attr('data-cat')?$(ele).attr('data-cat'):''; // 카테고리
var url = $(ele).attr('data-url')?$(ele).attr('data-url'):''; // url
var name = $(ele).attr('data-name')?$(ele).attr('data-name'):''; // name
var mbruid = $(ele).attr('data-mbruid')?$(ele).attr('data-mbruid'):''; // 작성자 회원 고유번호
var mbrid = $(ele).attr('data-mbrid')?$(ele).attr('data-mbrid'):''; // 작성자 회원아이디
var avatar = $(ele).attr('data-avatar')?$(ele).attr('data-avatar'):''; // avatar
var comment = $(ele).attr('data-comment')?$(ele).attr('data-comment'):''; // comment
var hit = $(ele).attr('data-hit')?$(ele).attr('data-hit'):''; // hit
var likes = $(ele).attr('data-likes')?$(ele).attr('data-likes'):''; // likes
var d_regis = $(ele).attr('data-dregis')?$(ele).attr('data-dregis'):''; // d_regis
var markup = $(ele).attr('data-markup')?$(ele).attr('data-markup'):''; // 마크업
var item = ele.closest('.table-view-cell')
var move = ele.attr('data-move');
item.attr('tabindex','-1').focus(); // 모달을 호출한 아이템을 포커싱 처리함 (css로 배경색 적용)
var modal = $(this);
if (start) page.attr('data-start',start);
page.find('[name="uid"]').val(uid);
page.find('[name="bid"]').val(bid);
page.find('[data-role="cat"]').text(cat).attr('data-cat',cat);
page.find('[data-role="name"]').text(name);
page.find('[data-role="total_comment"]').text(comment);
page.find('[data-target="#page-member-profile"]').attr('data-mbruid',mbruid).attr('data-url','/@'+mbrid);
page.find('[data-toggle="sheet"][data-avatar]').attr('data-nic',name).attr('data-avatar',avatar).attr('data-mbruid',mbruid);
page.find('[data-role="avatar"]').attr('src',avatar);
page.find('[data-role="hit"]').text(hit);
page.find('[data-role="likes"]').text(likes);
page.find('[data-role="likes"]').text(likes);
page.find('[data-role="d_regis"]').text(d_regis);
page.find('.bar-nav [data-role="toolbar"]').attr('data-uid',uid);
page.find('[data-role="article"]').loader({ // 로더 출력
position: "inside"
});
if (landing) {
page.find('[data-role="hback"]').addClass('d-none');
page.find('[data-role="gohome"]').removeClass('d-none');
} else {
page.find('[data-role="hback"]').removeClass('d-none');
page.find('[data-role="gohome"]').addClass('d-none');
}
setTimeout(function(){
$.post(rooturl+'/?r='+raccount+'&m=bbs&a=get_postData',{
bid : bid,
uid : uid,
markup_file : markup,
mod : 'view'
},function(response){
modal.find('[data-role="article"]').loader("hide");
var result = $.parseJSON(response);
var _uid=result.uid;
var article=result.article;
var featured_img = result.featured_img;
var adddata=result.adddata;
var attachNum = result.attachNum;
var attachFileTheme = result.theme_attachFile;
var hidden=result.hidden;
var hidden_attach=result.hidden_attach;
var mypost=result.mypost;
var bname=result.bname;
var is_post_liked=result.is_post_liked;
var is_post_disliked=result.is_post_disliked;
var is_post_tag=result.is_post_tag;
var bbs_c_hidden=result.bbs_c_hidden; // 댓글 사용여부
var theme=result.theme;
var theme_css = '/modules/bbs/themes/'+theme+'/_main.css';
var theme_use_reply=result.theme_use_reply;
var theme_show_tag=result.theme_show_tag;
var theme_show_upfile=result.theme_show_upfile;
var theme_show_like=result.theme_show_like;
var theme_show_dislike=result.theme_show_dislike;
var theme_show_share=result.theme_show_share;
if (!_uid) {
history.back();
setTimeout(function(){
$.notify({message: '존재하지 않는 게시물 입니다.'},{type: 'default'});
$('[data-role="bbs-list"]').find('#item-'+uid).slideUp();
}, 600);
}
if (!$('link[href="'+theme_css+'"]').length)
$('<link/>', {
rel: 'stylesheet',
type: 'text/css',
href: theme_css
}).appendTo('head');
page.find('[data-role="linkShare"]').attr('data-subject',subject).attr('data-image',featured_img).attr('data-url',url);
page.find('[data-role="article"]').html(article);
page.find('[data-act="category"]').attr('data-bname',bname);
page.find('[data-act="tag"]').attr('data-bname',bname);
Iframely('[data-role="article"] oembed[url]') // oembed 미디어 변환
page.find('[data-role="linkShare"]').attr('data-url',url);
page.find('.bar-nav [data-toggle="popover"]').attr('data-url',url).attr('data-bid',bid).attr('data-uid',uid);
if (is_post_liked) {
modal.find('[data-role="btn_post_like"]').addClass('active');
page_bbs_opinion.find('[data-role="btn_post_like"]').addClass('active');
}
if (is_post_disliked) {
modal.find('[data-role="btn_post_dislike"]').addClass('active');
page_bbs_opinion.find('[data-role="btn_post_dislike"]').addClass('active')
}
if (bbs_c_hidden) {
page.find('[data-role="btn_comment"]').remove() // 좋아요 버튼 제거
}
if (theme_show_like==0) {
page.find('[data-role="btn_post_like"]').remove() // 좋아요 버튼 제거
}
if (theme_show_dislike==0) {
page.find('[data-role="btn_post_dislike"]').remove() // 싫어요 버튼 제거
}
if (theme_show_share==0) {
page.find('[data-role="linkShare"]').remove() // sns공유 버튼 제거
}
if (theme_show_tag==0 || !is_post_tag) {
page.find('[data-role="post_tags"]').remove() // 테그목록 제거
}
// 첨부파일이 있을 경우
if (attachNum) {
$.post(rooturl+'/?r='+raccount+'&m=mediaset&a=getAttachFileList',{
p_module : 'bbs',
uid : uid,
theme_file : attachFileTheme,
mod : 'view'
},function(response){
var result = $.parseJSON(response);
var photo=result.photo;
var photo_full=result.photo_full;
var video=result.video;
var audio=result.audio;
var file=result.file;
var zip=result.zip;
var doc=result.doc;
if (photo) { // 첨부 이미지가 있을 경우
page.find('[data-role="attach-photo"]').removeClass('hidden').html(photo)
i=0;
page.find('[data-role="attach-photo"] [data-toggle="page"]').each(function(i) {
$(this).attr('data-index',i);i=++i;
});
page_bbs_photo.find('.swiper-wrapper').html(photo_full)
}
if (video) { // 첨부 비디오가 있을 경우
page.find('[data-role="attach-video"]').removeClass('hidden').html(video)
}
if (audio) { // 첨부 오디오가 있을 경우
page.find('[data-role="attach-audio"]').removeClass('hidden').html(audio)
}
if (doc) { // 첨부 문서 있을 경우
page.find('[data-role="attach-file"]').removeClass('hidden').html(doc)
}
if (zip) { // 첨부 압축파일이 있을 경우
page.find('[data-role="attach-file"]').removeClass('hidden').html(zip)
}
if (file) { // 첨부 기타파일이 있을 경우
page.find('[data-role="attach-file"]').removeClass('hidden').html(file)
}
if (theme_show_upfile==0) {
page.find('[data-role="attach"]').remove() // 첨부목록 제거
}
});
}
// 댓글 출력 함수 정의
var get_Rb_Comment = function(p_module,p_table,p_uid,theme){
modal.find('[data-role="comment_box"]').Rb_comment({
moduleName : 'comment', // 댓글 모듈명 지정 (수정금지)
parent : p_module+'-'+p_uid, // rb_s_comment parent 필드에 저장되는 형태가 p_modulep_uid 형태임 참조.(- 는 저장시 제거됨)
parent_table : p_table, // 부모 uid 가 저장된 테이블 (게시판인 경우 rb_bbs_data : 댓글, 한줄의견 추가/삭제시 전체 합계 업데이트용)
theme_name : theme, // 댓글 테마
containerClass :'', // 본 엘리먼트(#commentting-container)에 추가되는 class
recnum: 5, // 출력갯수
commentPlaceHolder : '댓글을 입력해주세요.',
noMoreCommentMsg : '댓글 없음 ',
commentLength : 200, // 댓글 입력 글자 수 제한
toolbar : ['imageUpload'] // 툴바 항목
});
}
// 댓글 출력 함수 실행
var p_module = 'bbs';
var p_table = 'rb_bbs_data';
var p_uid = uid; // 게시물 고유번호 적용
var theme = ctheme;
var comment_theme_css = '/modules/comment/themes/'+ctheme+'/css/style.css';
if (!hidden && _uid) {
if (!$('link[href="'+comment_theme_css+'"]').length)
$('<link/>', {
rel: 'stylesheet',
type: 'text/css',
href: comment_theme_css
}).appendTo('head');
get_Rb_Comment(p_module,p_table,p_uid,theme);
}
//댓글영역 바로가기 일 경우,
if (move=='comment') {
setTimeout(function(){
var top = page.find('[data-role="comment-box"]').offset().top; // 타켓의 위치값
var bar_height = page.find('.bar-nav').height(); // bar-nav의 높이값
page.find('.content').animate({ scrollTop: (top-bar_height)-15 }, 100);
}, 200);
}
$('#popover-bbs-view').find('[data-role="toolbar"]').remove(); //popover 항목 초기화
if (memberid) { // 로그인 상태 일때
var item_memberid = '<li class="table-view-cell" data-toggle="postSaved" data-send="ajax" data-role="toolbar" data-history="back">저장하기</li>';
$('#popover-bbs-view').find('.table-view').prepend(item_memberid) // 수정,삭제 버튼을 추가함
}
if (mypost) { // 내글이 아니거나 관리자 일때
var items_mypost = '<li class="table-view-cell" data-toggle="postEdit" data-history="back" data-role="toolbar">수정하기</li><li class="table-view-cell" data-toggle="PostDelete" data-role="toolbar">삭제하기</li>';
$('#popover-bbs-view').find('.table-view').prepend(items_mypost) // 수정,삭제 버튼을 추가함
}
if (hidden || hidden_attach) { // 권한이 없거나 비밀글 이거나 첨부파일 권한이 없을 경우 일때
modal.find('[data-role="attach-photo"]').empty()
modal.find('[data-role="attach-video"]').empty()
modal.find('[data-role="attach-audio"]').empty()
modal.find('[data-role="attach-file"]').empty()
}
});
}, 300);
})
// 게시물보기 모달이 보여진 후에..
$(mid).on('shown.rc.'+type, function(event) {
var ele = $(event.relatedTarget) // element that triggered the modal
var uid = ele.data('uid') // 게시물 고유번호 추출
var modal = $(this);
});
//링크공유 버튼을 터치 할때
$(mid).on('tap','#btn-linkShare',function(){
if (navigator.share === undefined) { //webshare.api가 지원되지 않는 환경
popup_linkshare.popup('show')
} else {
var ele = $(this)
var sbj = ele.attr('data-subject')?ele.attr('data-subject'):'' // 버튼에서 제목 추출
var desc = ele.attr('data-desc')?ele.attr('data-desc'):'' // 버튼에서 요약설명 추출
var host = $(location).attr('origin');
var path = ele.attr('data-url')?ele.attr('data-url'):''
var link = host+path // 게시물 보기 URL
navigator.share({
title: sbj,
text: desc,
url: link,
})
.then(() => console.log('성공적으로 공유되었습니다.'))
.catch((error) => console.log('공유에러', error));
}
});
//좋아요,싫어요
$(document).on('tap','[data-toggle="opinion"]',function(){
var send = $(this).data('send')
var uid = $(this).data('uid')
var opinion = $(this).data('opinion')
var effect = $(this).data('effect')
var myid = $(this).data('myid')
var bid = $(mid).find('[name="bid"]').val()
$.post(rooturl+'/?r='+raccount+'&m=bbs&a=opinion',{
send : send,
opinion : opinion,
uid : uid,
memberid : memberid,
bid : bid
},function(response){
var result = $.parseJSON(response);
var error=result.error;
var is_post_liked=result.is_post_liked;
var is__post_disliked=result.is_post_disliked;
var likes=result.likes;
var dislikes=result.dislikes;
var msg=result.msg;
if (!error) {
if (opinion=='like') {
if (is_post_liked) {
var msg = '좋아요가 취소 되었습니다.';
$('[data-role="btn_post_like"]').removeClass('active '+effect);
}
else {
var msg = '좋아요가 추가 되었습니다.';
$('[data-role="btn_post_like"]').addClass('active '+effect);
$('[data-role="btn_post_dislike"]').removeClass('active '+effect);
}
}
if (opinion=='dislike') {
if (is_post_disliked) {
var msg = '싫어요 취소 되었습니다.';
$('[data-role="btn_post_dislike"]').removeClass('active '+effect);
}
else {
var msg = '싫어요 추가 되었습니다.';
$('[data-role="btn_post_dislike"]').addClass('active '+effect)
$('[data-role="btn_post_like"]').removeClass('active '+effect)
}
}
$('[data-role="likes_'+uid+'"]').text(likes)
$('[data-role="dislikes_'+uid+'"]').text(dislikes)
}
$.notify({message: msg},{type: 'default'});
});
});
//게시물 링크저장(스크랩)
$(document).on('tap','[data-toggle="postSaved"]',function(){
var send = $(this).data('send')
var uid = $(this).data('uid')
if(!memberid){
$('#modal-login').modal() // 비로그인 일 경우 로그인 모달 호출
return false;
}
$.post(rooturl+'/?r='+raccount+'&m=bbs&a=saved',{
send : send,
uid : uid
},function(response){
var result = $.parseJSON(response);
var error=result.error;
var is_post_saved=result.is_post_saved;
var msg=result.msg;
var msgType=result.msgType;
if (!error) {
if (is_post_saved) {
var msg = '게시물이 저장함에서 삭제되었습니다.';
var msgType = 'successs';
$('[data-role="btn_post_saved"]').removeClass('active');
}
else {
var msg = '게시물이 저장함에 추가되었습니다.';
var msgType = 'successs';
$('[data-role="btn_post_saved"]').addClass('active');
}
}
$.notify({message: msg},{type: 'success'});
});
});
//게시물보기 모달(페이지)이 닫혔을 때
$(mid).on('hidden.rc.'+type, function() {
var modal = $(this);
var uid = modal.find('[name="uid"]').val()
var list_parent = $('[data-role="bbs-list"]').find('#item-'+uid)
modal.find('.bar-nav [data-role="toolbar"]').removeAttr('data-uid')
list_parent.attr('tabindex','-1').focus(); // 모달을 호출한 아이템을 포커싱 처리함 (css로 배경색 적용)
modal.find('[name="uid"]').val('')
modal.find('[data-role="article"]').html(''); // 본문영역 내용 비우기
modal.find('[data-role="hback"]').removeClass('d-none');
modal.find('[data-role="gohome"]').addClass('d-none');
modal.find('[data-role="attach-photo"]').addClass('hidden').empty() // 사진 영역 초기화
modal.find('[data-role="attach-video"]').addClass('hidden').empty() // 비디오 영역 초기화
modal.find('[data-role="attach-audio"]').addClass('hidden').empty() // 오디오 영역 초기화
modal.find('[data-role="attach-file"]').addClass('hidden').empty() // 기타파일 영역 초기화
modal.find('[data-role="comment_box"]').html(''); // 댓글영역 내용 비우기
page_bbs_photo.find('.swiper-wrapper').html('') // 사진크게보기 영역 초기화
});
// 게시물 보기 에서 댓글이 등록된 이후에 ..
$(mid).find('[data-role="comment_box"]').on('saved.rb.comment',function(){
window.history.back(); //댓글작성 sheet 내림
var modal = $(mid)
var bid = modal.find('[name="bid"]').val()
var uid = modal.find('[name="uid"]').val()
var theme = modal.find('[name="theme"]').val()
var list_item = $('[data-role="bbs-list"]').find('#item-'+uid)
var showComment_Ele_1 = modal.find('[data-role="total_comment"]'); // 댓글 숫자 출력 element
var showComment_ListEle = list_item.find('[data-role="total_comment"]'); // 댓글 숫자 출력 element
$.post(rooturl+'/?r='+raccount+'&m=bbs&a=get_postData',{
bid : bid,
uid : uid,
theme : theme
},function(response){
var result = $.parseJSON(response);
var total_comment=result.total_comment;
// $.notify({message: '댓글이 등록 되었습니다.'},{type: 'default'});
showComment_Ele_1.text(total_comment); // 모달 상단 최종 댓글수량 합계 업데이트
showComment_ListEle.text(total_comment); // 게시물 목록 해당 항목의 최종 댓글수량 합계 업데이트
});
});
// 게시물 보기 모달에서 한줄의견이 등록된 이후에..
$(mid).find('[data-role="comment_box"]').on('saved.rb.oneline',function(){
window.history.back(); //댓글작성 sheet 내림
var modal = $(mid)
var bid = modal.find('[name="bid"]').val()
var uid = modal.find('[name="uid"]').val()
var theme = modal.find('[name="theme"]').val()
var list_item = $('[data-role="bbs-list"]').find('#item-'+uid)
var showComment_Ele_1 = modal.find('[data-role="total_comment"]'); // 댓글 숫자 출력 element
var showComment_ListEle = list_item.find('[data-role="total_comment"]'); // 댓글 숫자 출력 element
$.post(rooturl+'/?r='+raccount+'&m=bbs&a=get_postData',{
bid : bid,
uid : uid,
theme : theme
},function(response){
var result = $.parseJSON(response);
var total_comment=result.total_comment;
//$.notify({message: '한줄의견이 등록 되었습니다.'},{type: 'default'});
modal.find('[data-kcact="reload"]').click(); // 댓글 새로 불러오기
showComment_Ele_1.text(total_comment); // 최종 댓글수량 합계 업데이트
showComment_ListEle.text(total_comment); // 게시물 목록 해당 항목의 최종 댓글수량 합계 업데이트
});
});
// 댓글이 수정된 후에..
$(mid).find('[data-role="comment_box"]').on('edited.rb.comment',function(){
setTimeout(function(){
history.back()
$.notify({message: '댓글이 수정 되었습니다.'},{type: 'default'});
}, 300);
})
// 한줄의견이 수정 후에
$(mid).find('[data-role="comment_box"]').on('edited.rb.oneline',function(){
setTimeout(function(){
history.back()
$.notify({message: '답글이 수정 되었습니다.'},{type: 'default'});
}, 300);
})
//링크 공유 팝업이 열릴때
popup_linkshare.on('shown.rc.popup', function (event) {
var ele = $(event.relatedTarget)
var path = ele.attr('data-url')?ele.attr('data-url'):''
var host = $(location).attr('origin');
var title= "게시물 공유"
var sbj = ele.attr('data-subject')?ele.attr('data-subject'):'' // 버튼에서 제목 추출
var email = ele.attr('data-email')?ele.attr('data-email'):'' // 버튼에서 이메일 추출
var desc = ele.attr('data-desc')?ele.attr('data-desc'):'' // 버튼에서 요약설명 추출
var image = ele.attr('data-image')?ele.attr('data-image'):'' // 버튼에서 대표이미지 경로 추출
var popup = $(this)
var link = host+path // 게시물 보기 URL
var enc_link = encodeURIComponent(host+path) // URL 인코딩
var imageUrl = host+image // 대표이미지 URL
var enc_sbj = encodeURIComponent(sbj) // 제목 인코딩
var facebook = 'http://www.facebook.com/sharer.php?u=' + enc_link;
var twitter = 'https://twitter.com/intent/tweet?url=' + enc_link + '&text=' + sbj;
var naver = 'http://share.naver.com/web/shareView.nhn?url=' + enc_link + '&title=' + sbj;
var kakaostory = 'https://story.kakao.com/share?url=' + enc_link + '&title=' + enc_sbj;
var email = 'mailto:' + email + '?subject=링크공유-' + enc_sbj+'&body='+ enc_link;
popup.find('[data-role="title"]').text(title)
popup.find('[data-role="share"]').val(host+path)
popup.find('[data-role="share"]').focus(function(){
$(this).on("mouseup.a keyup.a", function(e){
$(this).off("mouseup.a keyup.a").select();
});
});
popup.find('[data-role="facebook"]').attr('href',facebook)
popup.find('[data-role="twitter"]').attr('href',twitter)
popup.find('[data-role="naver"]').attr('href',naver)
popup.find('[data-role="kakaostory"]').attr('href',kakaostory)
popup.find('[data-role="email"]').attr('href',email)
//카카오 링크
function sendLink() {
Kakao.Link.sendDefault({
objectType: 'feed',
content: {
title: sbj,
description: desc,
imageUrl: imageUrl,
link: {
mobileWebUrl: link,
webUrl: link
}
},
buttons: [
{
title: '바로가기',
link: {
mobileWebUrl: link,
webUrl: link
}
},
]
});
}
//카카오톡 링크공유
kakao_link_btn.click(function() {
sendLink()
});
})
page_bbs_photo.on('show.rc.page', function (e) {
var ele = $(e.relatedTarget)
var index = ele.attr('data-index');
var uid = ele.attr('data-uid');
var page = $(this);
var title = page_bbs_view.find('[data-role="title"]').text();
var subject = page_bbs_view.find('[data-role="subject"]').text();
page.find('[data-role="title"]').text(title);
page.find('[data-role="subject"]').text(subject);
var bbs_photo_swiper = new Swiper('#page-bbs-photo .swiper-container', {
zoom: true,
initialSlide: index,
spaceBetween: 30,
pagination: {
el: '#page-bbs-photo .swiper-pagination',
type: 'fraction',
},
navigation: {
nextEl: '#page-bbs-photo .swiper-button-next',
prevEl: '#page-bbs-photo .swiper-button-prev',
},
on: {
init: function () {
page_bbs_photo.find('.swiper-container').css('height','100vh');
},
},
});
})
page_bbs_photo.on('hidden.rc.page', function () {
// swiper destroy
var bbs_photo_swiper = document.querySelector('#page-bbs-photo .swiper-container').swiper
bbs_photo_swiper.destroy(false, true);
// 줌상태 초기화
setTimeout(function(){
page_bbs_photo.find('.swiper-zoom-container').removeAttr('style');
page_bbs_photo.find('.swiper-zoom-container img').removeAttr('style');
}, 500);
})
//게시물 수정
$(document).on('tap','[data-toggle="postEdit"]',function() {
var bid = $(this).attr('data-bid');
var uid = $(this).attr('data-uid');
modal_bbs_write.find('[name="bid"]').val(bid);
modal_bbs_write.find('[name="uid"]').val(uid);
setTimeout(function(){modal_bbs_write.modal()}, 50);
});
// 게시물 삭제
$(document).on('tap','[data-toggle="PostDelete"]',function() {
var uid = $(this).data('uid');
var bid = $(mid).find('[name="bid"]').val();
history.back();
setTimeout(function(){
if (confirm('정말 삭제하시겠습니까? ')){
$('.content').loader({
text: "삭제중...",
position: "overlay"
});
$.post(rooturl+'/?r='+raccount+'&m=bbs&a=delete',{
send : 'ajax',
uid : uid,
bid : bid
},function(response){
var result = $.parseJSON(response);
var error=result.error;
var num=result.num;
if (!error) {
$('.content').loader('hide');
history.back();
setTimeout(function(){
if (!num) location.reload();
else $('#item-'+uid).slideUp();
}, 700);
}
});
}
}, 10);
});
//첨부된 사진 크게보기 페이지 호출
$(document).on('click','figure.image',function(){
if (!$(this).hasClass('ck-widget')) {
var page_start = $(this).closest('.page').attr('id');
var src = $(this).find('img').attr('src')
$('#page-bbs-photo').page({ start: '#'+page_start });
$('#page-bbs-photo').find('.swiper-slide img').attr('src',src)
var swiper = new Swiper('#page-bbs-photo .swiper-container', {
zoom: true,
});
}
return false;
});
// 게시물 좋아요 목록보기
page_bbs_opinion.on('show.rc.page', function(event) {
var button = $(event.relatedTarget);
var page = $(this);
var bid = button.attr('data-bid');
var uid = button.attr('data-uid');
var url = button.attr('data-url');
var opinion = button.attr('data-opinion');
page.find('[name="uid"]').val(uid);
page.find('[name="bid"]').val(bid);
page.find('[data-toggle="opinion"]').attr('data-uid',uid);
page.find('[data-role="list"]').loader({ // 로더 출력
position: "inside"
});
setTimeout(function(){
$.post(rooturl+'/?r='+raccount+'&m=bbs&a=get_opinionList',{
uid : uid,
opinion : opinion
},function(response){
page.find('[data-role="list"]').loader("hide");
var result = $.parseJSON(response);
var _uid=result.uid;
var list=result.list;
var num=result.num;
if (num) {
page.find('[data-role="list"]').html(list);
} else {
page.find('[data-role="list"]').html('<li class="table-view-cell text-muted">좋아요가 없습니다.</li>');
}
});
}, 300);
});
page_bbs_opinion.on('hidden.rc.page', function(event) {
var page = $(this);
var uid = page.find('[name="uid"]').val()
var list_parent = $('[data-slide="feed"]').find('#item-'+uid)
list_parent.attr('tabindex','-1').focus(); // 모달을 호출한 아이템을 포커싱 처리함 (css로 배경색 적용)
});
};