first
This commit is contained in:
213
layouts/rc-starter/_js/component.js
Normal file
213
layouts/rc-starter/_js/component.js
Normal file
@@ -0,0 +1,213 @@
|
||||
var page_main = $('#page-main');
|
||||
|
||||
//사이트
|
||||
var page_site_info = $('#page-site-info');
|
||||
var page_site_page = $('#page-site-page');
|
||||
var modal_site_settings = $('#modal-site-settings'); //사이드
|
||||
|
||||
//게시판
|
||||
var page_bbs_list = $('#page-bbs-list'); // 게시판 목록
|
||||
var page_bbs_view = $('#page-bbs-view'); // 게시물 보기
|
||||
var page_bbs_write = $('#page-bbs-write'); // 게시물 작성
|
||||
var page_bbs_write_category = $('#page-bbs-write-category'); // 게시물 작성 > 카테고리 선택
|
||||
var page_bbs_write_attach = $('#page-bbs-write-attach'); // 게시물 작성 > 카테고리 선택
|
||||
var page_bbs_qnalist = $('#page-bbs-qnalist'); // 1:1 상담 게시판 목록
|
||||
var page_bbs_qnaview = $('#page-bbs-qnaview'); // 1:1 상담 게시판 보기
|
||||
var page_bbs_qnawrite = $('#page-bbs-qnawrite'); // 1:1 상담 게시판 쓰기
|
||||
|
||||
var popup_link_share = $('#popup-link-share'); //링크 공유
|
||||
var kakao_link_btn = $('#kakao-link-btn') //카카오톡 링크공유 버튼
|
||||
|
||||
$( document ).ready(function() {
|
||||
|
||||
page_site_info.on('hidden.rc.page', function (event) {
|
||||
var page = $(this);
|
||||
page.find('.content').scrollTop(0);
|
||||
});
|
||||
|
||||
// 일반 페이지 보기
|
||||
page_site_page.on('show.rc.page', function (event) {
|
||||
var button = $(event.relatedTarget);
|
||||
var id = button.attr('data-id');
|
||||
var type = button.attr('data-type');
|
||||
|
||||
page_site_page.find('[data-role="main"]').loader({ // 로더 출력
|
||||
position: "inside"
|
||||
});
|
||||
$.post(rooturl+'/?r='+raccount+'&m=site&a=get_postData',{
|
||||
id : id,
|
||||
_mtype : type
|
||||
},function(response){
|
||||
var result = $.parseJSON(response);
|
||||
var error=result.error;
|
||||
var article=result.article;
|
||||
if (error) {
|
||||
setTimeout(function(){
|
||||
history.back();
|
||||
page_site_page.find('[data-role="main"]').loader('hide');
|
||||
setTimeout(function(){ $.notify({message: error},{type: 'default'}); }, 400);
|
||||
return false
|
||||
}, 300);
|
||||
} else {
|
||||
page_site_page.find('[data-role="main"]').loader("hide");
|
||||
page_site_page.find('[data-role="main"]').html(article);
|
||||
Iframely('oembed[url]') // oembed 미디어 변환
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
page_site_page.on('hidden.rc.page', function (event) {
|
||||
page_site_page.find('[data-role="main"]').html('');
|
||||
})
|
||||
|
||||
// // 게시판 목록 가져오기
|
||||
// page_bbs_list.on('show.rc.page', function (event) {
|
||||
// var button = $(event.relatedTarget);
|
||||
// var bid = button.attr('data-id');
|
||||
// var cat= button.attr('data-category');
|
||||
// var collapse = button.attr('data-collapse');
|
||||
// page_bbs_list.find('.content').loader({
|
||||
// position: "inside"
|
||||
// });
|
||||
// getBbsList(bid,cat,page_bbs_list,collapse)
|
||||
// })
|
||||
//
|
||||
// page_bbs_list.on('hidden.rc.page', function (event) {
|
||||
// page_bbs_list.find('.bar-header-secondary').addClass('d-none');
|
||||
// })
|
||||
//
|
||||
// page_bbs_list.find('[data-role="category"]').on('change', function () {
|
||||
// var option = $(this).find(':selected');
|
||||
// var bid = option.attr('data-bid');
|
||||
// var collapse = option.attr('data-collapse');
|
||||
// var cat = option.val();
|
||||
// getBbsList(bid,cat,page_bbs_list,collapse)
|
||||
// });
|
||||
//
|
||||
// // 게시물 보기
|
||||
// page_bbs_view.on('show.rc.page', function (event) {
|
||||
// var button = $(event.relatedTarget);
|
||||
// var uid = button.attr('data-uid');
|
||||
//
|
||||
// $.post(rooturl+'/?r='+raccount+'&m=bbs&a=get_postData',{
|
||||
// uid : uid,
|
||||
// markup_file : 'view_simple'
|
||||
// },function(response){
|
||||
// var result = $.parseJSON(response);
|
||||
// var error=result.error;
|
||||
// var article=result.article;
|
||||
// var mypost = result.mypost;
|
||||
// if (error) {
|
||||
// setTimeout(function(){
|
||||
// history.back();
|
||||
// page_bbs_view.find('.content').loader('hide');
|
||||
// setTimeout(function(){ $.notify({message: error},{type: 'default'}); }, 400);
|
||||
// return false
|
||||
// }, 300);
|
||||
// } else {
|
||||
// // page_bbs_view.find('.content').loader('hide');
|
||||
// page_bbs_view.find('[data-role="main"]').html(article);
|
||||
//
|
||||
// if (!mypost) page_bbs_view.find('[data-role="toolbar"]').remove()
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// })
|
||||
|
||||
// 게시판(1:1상담) 목록 가져오기
|
||||
page_bbs_qnalist.on('show.rc.page', function (event) {
|
||||
var button = $(event.relatedTarget);
|
||||
var bid = button.attr('data-id');
|
||||
var cat= button.attr('data-category');
|
||||
var collapse = button.attr('data-collapse');
|
||||
page_bbs_qnalist.find('.content').loader({
|
||||
position: "inside"
|
||||
});
|
||||
getBbsList(bid,cat,page_bbs_qnalist,collapse)
|
||||
})
|
||||
|
||||
page_bbs_qnalist.on('hidden.rc.page', function (event) {
|
||||
page_bbs_qnalist.find('.bar-header-secondary').addClass('d-none');
|
||||
})
|
||||
|
||||
//링크 공유 팝업이 열릴때
|
||||
popup_link_share.on('shown.rc.popup', function (event) {
|
||||
var popup = $(this)
|
||||
var subject = popup.attr('data-subject');
|
||||
var review = popup.attr('data-review');
|
||||
var featured = popup.attr('data-featured');
|
||||
var link = popup.attr('data-link');
|
||||
var protocol = $(location).attr('protocol');
|
||||
var host = $(location).attr('host');
|
||||
var url = protocol+'//'+host+link;
|
||||
var featured_url = protocol+'//'+host+featured;
|
||||
var entry = popup.attr('data-entry');
|
||||
|
||||
popup.find('[data-role="youtube"]').attr('data-clipboard-text',url+'?ref=yt')
|
||||
popup.find('[data-role="instagram"]').attr('data-clipboard-text',url+'?ref=ig')
|
||||
popup.find('[data-role="facebook"]').attr('data-clipboard-text',url+'?ref=fb')
|
||||
popup.find('[data-role="band"]').attr('data-clipboard-text',url+'?ref=bd')
|
||||
popup.find('[data-role="naverblog"]').attr('data-clipboard-text',url+'?ref=nb')
|
||||
popup.find('[data-role="navercafe"]').attr('data-clipboard-text',url+'?ref=nc')
|
||||
popup.find('[data-role="kakaostory"]').attr('data-clipboard-text',url+'?ref=ks')
|
||||
popup.find('[data-role="twitter"]').attr('data-clipboard-text',url+'?ref=tt')
|
||||
popup.find('[data-role="email"]').attr('data-clipboard-text',url+'?ref=em')
|
||||
popup.find('[data-role="sms"]').attr('data-clipboard-text',url+'?ref=sm')
|
||||
popup.find('[data-role="etc"]').attr('data-clipboard-text',url)
|
||||
popup.find('[data-role="uid"]').attr('data-clipboard-text',entry)
|
||||
|
||||
//카카오톡 링크공유
|
||||
kakao_link_btn.off('click').click(function() {
|
||||
kakaoTalkSend({
|
||||
subject : subject,
|
||||
review : review,
|
||||
featured : featured_url,
|
||||
link : url,
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
popup_link_share.on('hidden.rc.popup', function (event) {
|
||||
var popup = popup_link_share;
|
||||
popup.removeAttr('data-link').removeAttr('data-subject').removeAttr('data-review').removeAttr('data-featured').removeAttr('data-entry');
|
||||
popup.find('[data-role]').removeAttr('data-clipboard-text');
|
||||
})
|
||||
|
||||
|
||||
modal_site_settings.on('shown.rc.modal', function (e) {
|
||||
var modal = $(this)
|
||||
modal.find('[name="main_post_req"]').val('');
|
||||
$.post(rooturl+'/?r='+raccount+'&m=site&a=get_sitecode',{
|
||||
},function(response,status){
|
||||
if(status=='success'){
|
||||
var result = $.parseJSON(response);
|
||||
var main_post_req=result.main_post_req;
|
||||
modal.find('[name="main_post_req"]').val(main_post_req);
|
||||
} else {
|
||||
alert(status);
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
modal_site_settings.find('[data-act="submit"]').click(function(){
|
||||
var button = $(this)
|
||||
var modal = modal_site_settings;
|
||||
var main_post_req = modal.find('[name="main_post_req"]').val();
|
||||
button.addClass('disabled');
|
||||
setTimeout(function(){
|
||||
$.post(rooturl+'/?r='+raccount+'&m=site&a=regissitecode',{
|
||||
main_post_req : main_post_req
|
||||
},function(response,status){
|
||||
if(status=='success'){
|
||||
button.removeClass('disabled');
|
||||
$.notify({message: '저장 되었습니다.'},{type: 'default'});
|
||||
} else {
|
||||
alert(status);
|
||||
}
|
||||
});
|
||||
}, 200);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
430
layouts/rc-starter/_js/main.js
Normal file
430
layouts/rc-starter/_js/main.js
Normal file
@@ -0,0 +1,430 @@
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* kimsQ Rb v2.4 모바일 시작하기 레이아웃 스크립트 (rc-starter)
|
||||
* Homepage: http://www.kimsq.com
|
||||
* Licensed under RBL
|
||||
* Copyright 2019 redblock inc
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
var bar = $('.bar')
|
||||
var drawer_left = $('#drawer-left')
|
||||
var drawer_right = $('#drawer-right')
|
||||
|
||||
var noti_sort = 'uid';
|
||||
var noti_orderby = 'desc';
|
||||
var noti_recnum = '10';
|
||||
|
||||
function moreNOTI(container,totalPage){
|
||||
var noti_currentPage =1; // 처음엔 무조건 1, 아래 더보기 진행되면서 +1 증가
|
||||
container.infinitescroll({
|
||||
dataSource: function(helpers, callback){
|
||||
var noti_nextPage = parseInt(noti_currentPage)+1;
|
||||
console.log('noti_totalpage: '+totalPage)
|
||||
console.log('noti_currentPage: '+noti_currentPage)
|
||||
console.log('noti_sort: '+noti_sort)
|
||||
$.get(rooturl+'/?r='+raccount+'&m=notification&a=get_notiList',{
|
||||
page : noti_nextPage,
|
||||
sort: noti_sort,
|
||||
orderby: noti_orderby,
|
||||
recnum: noti_recnum,
|
||||
callMod: 'unread'
|
||||
},function(response) {
|
||||
var result = $.parseJSON(response);
|
||||
var error = result.error;
|
||||
var content = result.content;
|
||||
if(error) alert(result.error_comment);
|
||||
callback({ content: content });
|
||||
noti_currentPage++; // 현재 페이지 +1
|
||||
console.log(noti_currentPage+'페이지 불러옴')
|
||||
$('[data-plugin="timeago"]').timeago();
|
||||
if (totalPage<=noti_currentPage) {
|
||||
container.infinitescroll('end')
|
||||
console.log('더이상 불러올 알림이 없습니다.')
|
||||
}
|
||||
});
|
||||
},
|
||||
appendToEle : container.find('.table-view'),
|
||||
percentage : 95, // 95% 아래로 스크롤할때 다음 페이지 호출
|
||||
hybrid : false // true: 버튼형, false: 자동
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function edgeEffect(container,pos,show) {
|
||||
var topEdge = $('#topEdge');
|
||||
var bottomEdge = $('#bottomEdge');
|
||||
var bar_nav_height = container.find('.bar-nav:not(.onscroll):not(.d-none)').height();
|
||||
var bar_standard_height = container.find('.bar-standard:not(.d-none)').height();
|
||||
var bar_header_secondary = container.find('.bar-header-secondary:not(.d-none)').height();
|
||||
var bar_tab_height = container.find('.bar-tab:not(.d-none)').height();
|
||||
var bar_footer_secondary_height = container.find('.bar-footer-secondary:not(.d-none)').height();
|
||||
var bar_footer_height = container.find('.bar-footer:not(.d-none)').height();
|
||||
var top_margin = bar_nav_height + bar_header_secondary + bar_standard_height;
|
||||
var bottom_margin = bar_tab_height + bar_footer_secondary_height + bar_footer_height;
|
||||
topEdge.css("opacity", "0");
|
||||
bottomEdge.css("opacity", "0");
|
||||
if (pos=='top' && show=='show') {
|
||||
topEdge.clearQueue();
|
||||
topEdge.css('top',top_margin?top_margin:0);
|
||||
topEdge.animate({height:'42px', opacity:'.5'}, 100);
|
||||
topEdge.animate({height:'0', opacity:'0'}, 600);
|
||||
setTimeout(function(){ topEdge.clearQueue() }, 680);
|
||||
}
|
||||
if (pos=='bottom' && show=='show') {
|
||||
bottomEdge.clearQueue();
|
||||
bottomEdge.css('bottom',bottom_margin?bottom_margin:0);
|
||||
bottomEdge.animate({height:'42px', opacity:'.5'}, 100);
|
||||
bottomEdge.animate({height:'0', opacity:'0'}, 600);
|
||||
setTimeout(function(){ bottomEdge.clearQueue() }, 680);
|
||||
}
|
||||
if (pos=='bottom' && show=='hide') {
|
||||
bottomEdge.css("opacity", "0");
|
||||
}
|
||||
}
|
||||
|
||||
function kakaoTalkSend(settings) {
|
||||
var title = settings.subject;
|
||||
var description = settings.review?settings.review:'';
|
||||
var imageUrl = settings.featured?settings.featured:'';
|
||||
var link = settings.link+'?ref=kt' // 카카오톡 파라미터 추가;
|
||||
|
||||
if (!kakao_jskey) {
|
||||
$.notify({message: '카카오 연동설정을 확인해주세요.'},{type: 'default'});
|
||||
return false
|
||||
}
|
||||
|
||||
Kakao.Link.sendDefault({
|
||||
objectType: 'feed',
|
||||
content: {
|
||||
title: title,
|
||||
description: description,
|
||||
imageUrl: imageUrl,
|
||||
link: {
|
||||
mobileWebUrl: link,
|
||||
webUrl: link
|
||||
}
|
||||
},
|
||||
buttons: [
|
||||
{
|
||||
title: '바로가기',
|
||||
link: {
|
||||
mobileWebUrl: link,
|
||||
webUrl: link
|
||||
}
|
||||
},
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
function overScrollEffect(page){
|
||||
page.find('main.content').on('touchstart',function(event){
|
||||
page_startY = event.originalEvent.changedTouches[0].pageY;
|
||||
});
|
||||
page.find('main.content').on('touchmove',function(event){
|
||||
var page_moveY = event.originalEvent.changedTouches[0].pageY;
|
||||
var page_contentY = $(this).scrollTop();
|
||||
var tab_id = $(this).attr('data-tab');
|
||||
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.find('main.content'),'bottom','show'); // 스크롤 하단 끝
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function pullToRefresh(page){
|
||||
page.find('.snap-content .content').on('touchstart',function(event){
|
||||
page_startY = event.originalEvent.changedTouches[0].pageY;
|
||||
});
|
||||
page.find('.snap-content .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) {
|
||||
$.loader({ text: '새로고침' });
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
$('[data-plugin="timeago"]').timeago(); // 상대시간 플러그인 초기화
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
|
||||
overScrollEffect(page_main.find('.snap-content'));
|
||||
// pullToRefresh(page_main);
|
||||
|
||||
$('[data-toggle="fullscreen"]').click(function() {
|
||||
toggleFullScreen()
|
||||
});
|
||||
|
||||
$('[data-open="newPost"]').click(function() {
|
||||
var url = $(this).attr('data-url');
|
||||
var start = $(this).attr('data-start');
|
||||
drawer_left.drawer('hide')
|
||||
|
||||
if (start=='#page-main') {
|
||||
setTimeout(function(){
|
||||
$('#popup-post-newPost').popup({
|
||||
title :'작업선택',
|
||||
url : 'post/write'
|
||||
}).attr('data-start',start);
|
||||
}, 350);
|
||||
} else {
|
||||
setTimeout(function(){
|
||||
$('#page-post-allpost').page({
|
||||
start : '#page-main',
|
||||
title : '최신 포스트'
|
||||
});
|
||||
setTimeout(function(){
|
||||
$('#popup-post-newPost').popup({
|
||||
title :'작업선택',
|
||||
url : 'post/write'
|
||||
}).attr('data-start',start);
|
||||
}, 350);
|
||||
}, 300);
|
||||
}
|
||||
});
|
||||
|
||||
$('[data-toggle="goMypage"]').click(function() {
|
||||
var url = $(this).attr('data-url');
|
||||
var target = $(this).attr('data-target');
|
||||
var start = $(this).attr('data-start');
|
||||
var title = $(this).attr('data-title');
|
||||
drawer_left.drawer('hide')
|
||||
setTimeout(function(){
|
||||
$(target).page({
|
||||
title :title,
|
||||
start : start,
|
||||
url : url
|
||||
});
|
||||
}, 300);
|
||||
});
|
||||
|
||||
if(navigator.userAgent.indexOf("Mac") > 0) {
|
||||
$("body").addClass("mac-os");
|
||||
}
|
||||
|
||||
putCookieAlert('site_common_result') // 로그인/로그아웃 알림 메시지 출력
|
||||
|
||||
$(document).on('tap','[data-toggle="changeModal"]', function (e) {
|
||||
var $this = $(this)
|
||||
var href = $this.attr('href')
|
||||
var type = $this.attr('data-type')
|
||||
var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, '')))
|
||||
var $start = $($this.closest('.modal'))
|
||||
if ($this.is('a')) e.preventDefault()
|
||||
$start.modal('hide').removeClass('active')
|
||||
setTimeout(function(){ $target.modal('show'); }, 100);
|
||||
});
|
||||
|
||||
//modal 로그인 - 실행
|
||||
$('#modal-login').find('form').submit( function(e){
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
var form = $(this)
|
||||
siteLogin(form)
|
||||
});
|
||||
|
||||
// modal 로그인이 닫혔을대
|
||||
$('#modal-login').on('hidden.rc.modal', function () {
|
||||
$(this).find('input').removeClass('is-invalid') // 에러흔적 초기화
|
||||
})
|
||||
|
||||
$("#modal-login").find('input').keyup(function() {
|
||||
$(this).removeClass('is-invalid') //에러 발생후 다시 입력 시도시에 에러 흔적 초기화
|
||||
});
|
||||
|
||||
// 로그아웃
|
||||
$('[data-act="logout"]').tap(function(){
|
||||
history.back(); // 팝업닫기
|
||||
$.loader({ text: "잠시만 기다리세요..." });
|
||||
getIframeForAction('');
|
||||
setTimeout(function(){
|
||||
frames.__iframe_for_action__.location.href = '/?r=home&m=site&a=logout';
|
||||
}, 300);
|
||||
});
|
||||
|
||||
// 드로어(사이드메뉴영역) 닫기
|
||||
$('body').on('tap click','[data-toggle="drawer-close"]',function(){
|
||||
drawer_left.drawer('hide')
|
||||
drawer_right.drawer('hide')
|
||||
});
|
||||
|
||||
//검색 모달이 열렸을때
|
||||
$('#modal-search').on('shown.rc.modal', function () {
|
||||
setTimeout(function() {
|
||||
$('#search-input').val('').focus();
|
||||
}, 50);
|
||||
|
||||
$('#search-input').autocomplete({
|
||||
lookup: function (query, done) {
|
||||
|
||||
$.getJSON(rooturl+"/?m=tag&a=searchtag", {q: query}, function(res){
|
||||
var sg_tag = [];
|
||||
var data_arr = res.taglist.split(',');//console.log(data.usernames);
|
||||
$.each(data_arr,function(key,tag){
|
||||
var tagData = tag.split('|');
|
||||
var keyword = tagData[0];
|
||||
var hit = tagData[1];
|
||||
sg_tag.push({"value":keyword,"data":hit});
|
||||
});
|
||||
var result = {
|
||||
suggestions: sg_tag
|
||||
};
|
||||
done(result);
|
||||
});
|
||||
},
|
||||
onSelect: function (suggestion) {
|
||||
if ($('#search-input').val().length >= 1) {
|
||||
$( "#modal-search-form" ).submit();
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
// 검색버튼과 검색어 초기화 버튼 동적 출력
|
||||
$('#search-input').on('keyup', function(event) {
|
||||
var modal = $('#modal-search')
|
||||
modal.find('[data-role="keyword-reset"]').addClass("hidden"); // 검색어 초기화 버튼 숨김
|
||||
modal.find("#drawer-search-footer").addClass('hidden') //검색풋터(검색버튼 포함) 숨김
|
||||
if ($(this).val().length >= 2) {
|
||||
modal.find('[data-role="keyword-reset"]').removeClass("hidden");
|
||||
}
|
||||
});
|
||||
|
||||
// 검색어 입력필드 초기화
|
||||
$('body').on('tap click','[data-act="keyword-reset"]',function(){
|
||||
var modal = $('#modal-search')
|
||||
modal.find("#search-input").val('').autocomplete('clear'); // 입력필드 초기화
|
||||
setTimeout(function(){
|
||||
modal.find("#search-input").focus(); // 입력필드 포커싱
|
||||
modal.find('[data-role="keyword-reset"]').addClass("hidden"); // 검색어 초기화 버튼 숨김
|
||||
}, 10);
|
||||
});
|
||||
|
||||
// 바로가기
|
||||
$(document).on('tap','[data-toggle="move"]',function(event){
|
||||
var button = $(this);
|
||||
var target = button.attr('data-target');
|
||||
var page = button.attr('data-page')?button.attr('data-page'):'body'; // 컨테이너
|
||||
var top = $(target).offset().top; // 타켓의 위치값
|
||||
var bar_height = $(page).find('.bar-nav').height(); // bar-nav의 높이값
|
||||
$(page).find('.content').animate({ scrollTop: (top-bar_height)-15 }, 300);
|
||||
});
|
||||
|
||||
// 검색모달이 닫혔을때
|
||||
$('#modal-search').on('hidden.rc.modal', function () {
|
||||
var modal = $(this)
|
||||
$('#search-input').autocomplete('clear');
|
||||
$('.autocomplete-suggestions').remove();
|
||||
modal.find('[data-role="keyword-reset"]').addClass("hidden"); // 검색어 초기화 버튼 숨김'
|
||||
})
|
||||
|
||||
//외부서비스 사용자 인증요청
|
||||
$('body').on('tap click','[data-connect]',function(){
|
||||
var provider = $(this).data('connect')
|
||||
|
||||
// /core/engine/cssjs.engine.php 참고
|
||||
if (provider=='naver') var target = connect_naver
|
||||
if (provider=='kakao') var target = connect_kakao
|
||||
if (provider=='google') var target = connect_google
|
||||
if (provider=='facebook') var target = connect_facebook
|
||||
if (provider=='instagram') var target = connect_instagram
|
||||
var referer = window.location.href // 연결후, 원래 페이지 복귀를 위해
|
||||
|
||||
$(".content").loader({
|
||||
text: "연결 중...",
|
||||
position: "overlay"
|
||||
});
|
||||
|
||||
$.post(rooturl+'/?r='+raccount+'&m=connect&a=save_referer',{
|
||||
referer : referer
|
||||
},function(response,status){
|
||||
|
||||
if(status=='success'){
|
||||
setTimeout(function() {
|
||||
$(".content").loader("hide");
|
||||
document.location = target;
|
||||
}, 500);
|
||||
}else{
|
||||
alert(status);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 페이지 이동
|
||||
$(document).on('tap','[data-href]',function(){
|
||||
var text = $(this).attr("data-text")?$(this).attr("data-text"):'이동중..';
|
||||
var url = $(this).attr("data-href");
|
||||
if ($(this).attr("data-toggle")=='drawer-close') {
|
||||
drawer_left.drawer('hide')
|
||||
drawer_right.drawer('hide')
|
||||
setTimeout(function(){
|
||||
$.loader({ text: text });
|
||||
location.href = url;
|
||||
}, 200);
|
||||
} else {
|
||||
$.loader({ text: text });
|
||||
location.href = url;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//링크복사
|
||||
var clipboard = new ClipboardJS('[data-toggle="linkCopy"]');
|
||||
$(document).on('tap','[data-toggle="linkCopy"]',function(){
|
||||
setTimeout(function(){
|
||||
$.notify({message: '링크가 복사 되었습니다.'},{type: 'default'});
|
||||
}, 300);
|
||||
});
|
||||
|
||||
$(document).on('click','[data-toggle="linkShare"]',function(){
|
||||
var ele = $(this)
|
||||
var sbj = ele.attr('data-subject'); // 버튼에서 제목 추출
|
||||
var desc = ele.attr('data-desc'); // 버튼에서 요약설명 추출
|
||||
var featured = ele.attr('data-featured');
|
||||
var link = ele.attr('data-link');
|
||||
var title = ele.attr('data-title')?ele.attr('data-title'):'링크 공유';
|
||||
var hback = ele.attr('data-hback');
|
||||
var entry = ele.attr('data-entry');
|
||||
var delay = 10;
|
||||
|
||||
if (hback) {
|
||||
history.back();
|
||||
delay = 100;
|
||||
}
|
||||
setTimeout(function(){
|
||||
if (ios_Token) { // iOS 네이티브앱 일 경우
|
||||
shareNative(sbj,link)
|
||||
} else if (navigator.share === undefined) { //webshare.api가 지원되지 않는 환경
|
||||
|
||||
popup_link_share.attr('data-link',link).attr('data-subject',sbj).attr('data-review',desc).attr('data-featured',featured).attr('data-entry',entry);
|
||||
setTimeout(function(){
|
||||
popup_link_share.popup({
|
||||
title : title
|
||||
})
|
||||
}, 300);
|
||||
|
||||
} else {
|
||||
navigator.share({
|
||||
title: sbj,
|
||||
text: desc,
|
||||
url: link,
|
||||
})
|
||||
.then(() => console.log('성공적으로 공유되었습니다.'))
|
||||
.catch((error) => console.log('공유에러', error));
|
||||
}
|
||||
}, delay);
|
||||
});
|
||||
|
||||
});
|
||||
296
layouts/rc-starter/_js/noti.js
Normal file
296
layouts/rc-starter/_js/noti.js
Normal file
@@ -0,0 +1,296 @@
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* FCM(Firebase 클라우드 메시징)을 활용한 포그라운드 알림 처리 (모바일 전용)
|
||||
* 참조코드 : https://github.com/firebase/quickstart-js/tree/master/messaging
|
||||
* Licensed under an Apache-2 license.
|
||||
* Firebase Quickstart Samples for Web https://firebase.google.com
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
firebase.initializeApp({'messagingSenderId': fcmSenderId});
|
||||
|
||||
const messaging = firebase.messaging();
|
||||
|
||||
messaging.usePublicVapidKey(fcmVAPID); //FCM 웹 푸시 인증서 키쌍(VAPID)
|
||||
|
||||
const permissionDivId = 'permission_div';
|
||||
const permissionAlertId = 'permission_alert';
|
||||
const tokenDivId = 'token_div';
|
||||
const pushSettingId = 'push_setting';
|
||||
const pushDisabledId = 'push_disabled';
|
||||
const popupNoti = $('#popup-noti');
|
||||
|
||||
if (isNewUser(memberid)) {
|
||||
console.log('새 사용자로 로그인 되었습니다.')
|
||||
deleteToken() // 기존 토큰 삭제
|
||||
window.localStorage.clear(); // 로컬 스토리지 초기화
|
||||
}
|
||||
|
||||
// 인스턴스 ID 토큰이 업데이트되면 콜백이 시작됩니다.
|
||||
messaging.onTokenRefresh(function() {
|
||||
messaging.getToken().then(function(refreshedToken) {
|
||||
console.log('토큰이 새로고침 되었습니다.'); // 새 인스턴스 ID 토큰이 아직 전송되지 않았 음을 나타냅니다.
|
||||
setTokenSentToServer(false);
|
||||
sendTokenToServer(refreshedToken); // 인스턴스 ID 토큰을 앱 서버로 전송합니다.
|
||||
resetNotiUI(); // 새로운 인스턴스 ID 토큰을 표시하고 모든 이전 메시지의 UI를 지웁니다.
|
||||
}).catch(function(err) {
|
||||
console.log('새로 변경된 토큰을 검색 할 수 없습니다. ', err);
|
||||
});
|
||||
});
|
||||
|
||||
// - 앱에 포커스가 있는 동안 메시지가 수신됩니다.
|
||||
messaging.onMessage(function(payload) {
|
||||
console.log('메시지가 도착했습니다. ', payload);
|
||||
|
||||
var result = JSON.stringify(payload, null, 2);
|
||||
var msg = JSON.parse(result);
|
||||
var title=msg.notification.title;
|
||||
var mbody=msg.notification.body;
|
||||
var icon=msg.notification.icon;
|
||||
var _mbody = mbody.replace(/(\n|\r\n)/g, '<br>');
|
||||
var noti_badge = $('[data-role="noti-status"]')
|
||||
|
||||
$.post(rooturl+'/?r='+raccount+'&m=notification&a=get_notiNum_ajax',function(response){
|
||||
var result = $.parseJSON(response);
|
||||
var noti_badge_num=result.num;
|
||||
noti_badge.text(noti_badge_num)
|
||||
});
|
||||
|
||||
$.notify({
|
||||
icon: icon,
|
||||
title: title,
|
||||
message: mbody
|
||||
}, {
|
||||
type: 'media',
|
||||
delay: 3000,
|
||||
icon_type: 'image',
|
||||
template: '<div data-notify="container" class="col-xs-11 col-sm-3 alert alert-{0}" role="alert">' +
|
||||
'<img data-notify="icon" class="img-circle pull-left">' +
|
||||
'<span data-notify="title">{1}</span>' +
|
||||
'<span data-notify="message">{2}</span>' +
|
||||
'</div>'
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
function resetNotiUI() {
|
||||
clearMessages();
|
||||
showToken('처리중...');
|
||||
setMemberId(memberid) // 로그인 사용자의 아이디를 로컬 스토리지에 저장
|
||||
|
||||
// Get Instance ID token. Initially this makes a network call, once retrieved
|
||||
// subsequent calls to getToken will return from cache. 이후의 getToken의 호출은 캐쉬로부터 돌아옵니다.
|
||||
messaging.getToken().then(function(currentToken) {
|
||||
if (currentToken) {
|
||||
sendTokenToServer(currentToken);
|
||||
updateUIForPushEnabled(currentToken);
|
||||
} else {
|
||||
|
||||
if (!isRequestPermission()) {
|
||||
setRequestPermission(false)
|
||||
}
|
||||
console.log('사용할수 있는 인스턴스 ID 토큰이 없습니다. 알림권한을 요청하십시오.');
|
||||
setTimeout(function(){
|
||||
updateUIForPushPermissionRequired(); // 알림권한요청 UI 를 보여줌.
|
||||
}, 1000);
|
||||
setTokenSentToServer(false);
|
||||
}
|
||||
}).catch(function(err) {
|
||||
console.log('알림권한이 없거나 토큰을 검색하는 중 오류가 발생했습니다. ', err);
|
||||
updateUIForPushDisabled()
|
||||
setRequestPermission(false)
|
||||
});
|
||||
}
|
||||
|
||||
function showToken(currentToken) {
|
||||
// 콘솔과 페이지에서 토큰을 보여줌
|
||||
var tokenElement = document.querySelector('.token');
|
||||
if (tokenElement) {
|
||||
tokenElement.textContent = currentToken;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Rb2에 인스턴스 ID 토큰을 보내세요.:
|
||||
// - 이 앱으로 메시지를 다시 보내세요.
|
||||
// - 주제 토큰 구독 / 탈퇴
|
||||
function sendTokenToServer(currentToken) {
|
||||
if (!isTokenSentToServer()) {
|
||||
console.log('Rb2 서버에 토큰 보내기 중 ...');
|
||||
|
||||
var agent = navigator.userAgent, match;
|
||||
var browser, version;
|
||||
|
||||
if((match = agent.match(/MSIE ([0-9]+)/)) || (match = agent.match(/Trident.*rv:([0-9]+)/))) browser = 'Internet Explorer';
|
||||
else if(match = agent.match(/Chrome\/([0-9]+)/)) browser = 'Chrome';
|
||||
else if(match = agent.match(/Firefox\/([0-9]+)/)) browser = 'Firefox';
|
||||
else if(match = agent.match(/Safari\/([0-9]+)/)) browser = 'Safari';
|
||||
else if((match = agent.match(/OPR\/([0-9]+)/)) || (match = agent.match(/Opera\/([0-9]+)/))) browser = 'Opera';
|
||||
else browser = 'Unknown';
|
||||
|
||||
if(browser !== 'Unknown') version = match[1];
|
||||
|
||||
$.post(rooturl+'/?r='+raccount+'&m=notification&a=save_token',{
|
||||
browser : browser,
|
||||
version : version,
|
||||
token : currentToken
|
||||
},function(response){
|
||||
var result = $.parseJSON(response);
|
||||
console.log('토큰이 저장되었습니다.' + currentToken)
|
||||
});
|
||||
setTokenSentToServer(true);
|
||||
} else {
|
||||
console.log('토큰이 이미 서버에 전송 되었으므로 토큰이 변경되지 않는한 재전송되지 않습니다.');
|
||||
}
|
||||
}
|
||||
|
||||
function isTokenSentToServer() {
|
||||
return window.localStorage.getItem('sentToServer') == 1;
|
||||
}
|
||||
|
||||
function setTokenSentToServer(sent) {
|
||||
window.localStorage.setItem('sentToServer', sent ? 1 : 0);
|
||||
}
|
||||
|
||||
function isRequestPermission() {
|
||||
return window.localStorage.getItem('setRequestPermission') == 1;
|
||||
}
|
||||
|
||||
function setRequestPermission(allow) {
|
||||
window.localStorage.setItem('setRequestPermission', allow ? 1 : 0);
|
||||
}
|
||||
|
||||
function isNewUser(memberid) {
|
||||
return window.localStorage.getItem('setMemberId') != memberid;
|
||||
}
|
||||
|
||||
function setMemberId(memberid) {
|
||||
window.localStorage.setItem('setMemberId', memberid ? memberid : 0);
|
||||
}
|
||||
|
||||
function showHideDiv(divId, show) {
|
||||
const div = document.querySelector('#' + divId);
|
||||
|
||||
if (div) {
|
||||
if (show) {
|
||||
div.style = 'display: visible';
|
||||
} else {
|
||||
div.style = 'display: none';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function showHideSheet(divId, show) {
|
||||
const sheet = $('#' + divId);
|
||||
if (sheet) {
|
||||
if (show) {
|
||||
sheet.sheet('show')
|
||||
} else {
|
||||
// sheet.sheet('hide')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function showHidePopup(divId, show) {
|
||||
const popup = $('#' + divId);
|
||||
if (popup) {
|
||||
if (show) {
|
||||
popup.popup('show')
|
||||
} else {
|
||||
// popup.popup('hide')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function requestPermission() {
|
||||
console.log('권한 요청 중 ...');
|
||||
messaging.requestPermission().then(function() {
|
||||
var nt_web = ''; //알림수신
|
||||
var nt_fcm = '1'; //푸시 알림수신
|
||||
console.log('알림권한이 부여 되었습니다.');
|
||||
showHideSheet(permissionAlertId, false);
|
||||
setTimeout(function(){ $.notify({message: '알림권한이 부여 되었습니다.'}); }, 500);
|
||||
resetNotiUI();
|
||||
|
||||
$.post(rooturl+'/?r='+raccount+'&m=notification&a=notice_config_user',{
|
||||
mobile : true,
|
||||
sendAjax : true,
|
||||
nt_web : nt_web,
|
||||
nt_email : nt_email,
|
||||
nt_fcm : nt_fcm
|
||||
},function(response){
|
||||
var result = $.parseJSON(response);
|
||||
var error=result.error;
|
||||
if (!error) console.log('웹알림/푸시알림 수신처리 되었습니다.')
|
||||
});
|
||||
|
||||
}).catch(function(err) {
|
||||
var nt_fcm = '';
|
||||
showHidePopup(permissionAlertId, false);
|
||||
showHideDiv(permissionDivId, false);
|
||||
showHideDiv(pushDisabledId, true);
|
||||
console.log('알림을 실행 할수있는 권한이 없습니다.', err);
|
||||
$.notify({message: '알림 권한이 차단 되었습니다.'},{type: 'danger'});
|
||||
});
|
||||
}
|
||||
|
||||
function deleteToken() {
|
||||
// 인스턴스 ID 토큰 삭제.
|
||||
// [START delete_token]
|
||||
messaging.getToken().then(function(currentToken) {
|
||||
messaging.deleteToken(currentToken).then(function() {
|
||||
console.log('토큰이 삭제 되었습니다.');
|
||||
setTokenSentToServer(false);
|
||||
// [START_EXCLUDE]
|
||||
// 토큰이 삭제되면 관련 UI를 업데이트 합니다..
|
||||
resetNotiUI();
|
||||
// [END_EXCLUDE]
|
||||
}).catch(function(err) {
|
||||
console.log('토큰을 삭제할 수 없습니다. ', err);
|
||||
});
|
||||
// [END delete_token]
|
||||
}).catch(function(err) {
|
||||
console.log('인스턴스 ID 토큰을 가져 오는 중 오류가 발생했습니다. ', err);
|
||||
});
|
||||
}
|
||||
|
||||
// 메시지 내용을 초기화 합니다.
|
||||
function clearMessages() {}
|
||||
|
||||
function updateUIForPushEnabled(currentToken) {
|
||||
$('#'+permissionAlertId).removeClass('active')
|
||||
$('.backdrop').remove()
|
||||
showHideDiv(tokenDivId, true);
|
||||
showHideDiv(pushSettingId, true);
|
||||
showHideDiv(permissionDivId, false);
|
||||
showToken(currentToken);
|
||||
}
|
||||
|
||||
function updateUIForPushDisabled() {
|
||||
showHideDiv(pushDisabledId, true);
|
||||
showHideDiv(pushSettingId, false);
|
||||
showHidePopup(permissionAlertId, false);
|
||||
}
|
||||
|
||||
function updateUIForPushPermissionRequired() {
|
||||
if (!isRequestPermission()) {
|
||||
console.log('브라우저 알림 권한요청 이력이 없음')
|
||||
if (!nt_web) {
|
||||
setTimeout(function(){ showHideSheet(permissionAlertId, true); }, 2000);
|
||||
} else {
|
||||
console.log('사용자의 모든 알림수신을 차단하였습니다.')
|
||||
}
|
||||
} else {
|
||||
console.log('브라우저 알림 권한요청 이력이 있음')
|
||||
showHideDiv(permissionDivId, true);
|
||||
}
|
||||
}
|
||||
|
||||
//알림권한 요청 sheet가 닫혔을때(나중에 설정)
|
||||
$('#permission_alert').on('hidden.rc.sheet', function () {
|
||||
setRequestPermission(true) // 요청이력을 로컬 스토리지에 저장하여 이후에 띄우지 않음
|
||||
showHideDiv(permissionDivId, true);
|
||||
})
|
||||
|
||||
resetNotiUI();
|
||||
574
layouts/rc-starter/_js/settings.js
Normal file
574
layouts/rc-starter/_js/settings.js
Normal file
@@ -0,0 +1,574 @@
|
||||
function setWidgetConfig(id,name,path,wdgvar,area) {
|
||||
var page_widget_view = $('#page-widget-view');
|
||||
|
||||
page_widget_view.find('[data-role="form"]').html('');
|
||||
|
||||
page_widget_view.page({
|
||||
start: '#page-widget-list'
|
||||
});
|
||||
|
||||
if (!wdgvar) var mod = 'add';
|
||||
else var mod = 'edit';
|
||||
|
||||
page_widget_view.find('[data-act="save"]').attr('data-mod',mod).attr('data-area',area);
|
||||
|
||||
setTimeout(function(){
|
||||
$.post(rooturl+'/?r='+raccount+'&m=site&a=get_widgetConfig',{
|
||||
name : name,
|
||||
widget : path,
|
||||
wdgvar : wdgvar,
|
||||
area : area
|
||||
},function(response,status){
|
||||
if(status=='success'){
|
||||
var result = $.parseJSON(response);
|
||||
var page=result.page;
|
||||
var widget_name=result.widget_name;
|
||||
var widget=result.widget;
|
||||
if (!page) {
|
||||
history.back()
|
||||
setTimeout(function(){ $.notify({message: '위젯설정을 확인해주세요.'},{type: 'default'});}, 400);
|
||||
resetPage()
|
||||
return false
|
||||
}
|
||||
page_widget_view.attr('data-id',id);
|
||||
page_widget_view.attr('data-name',name);
|
||||
page_widget_view.attr('data-path',path);
|
||||
page_widget_view.find('[data-role="title"]').text(widget_name);
|
||||
page_widget_view.find('[data-role="form"]').html(page);
|
||||
|
||||
} else {
|
||||
$.notify({message: '위젯설정을 확인해주세요.'},{type: 'danger'});
|
||||
return false
|
||||
}
|
||||
});
|
||||
}, 100);
|
||||
|
||||
}
|
||||
|
||||
function resetPage() {
|
||||
$('#page-widget-list [data-role="widgetConfig"]').addClass('d-none');
|
||||
$('#page-widget-list [data-role="addWidget"]').removeClass('active');
|
||||
$('#modal-widget-selector [name="widget_selector"]').prop('selectedIndex',0);
|
||||
$('#page-widget-list [data-role="widgetPage"] [data-role="item"]').removeClass('active shadow-sm')
|
||||
}
|
||||
|
||||
var page_layout_settings = $('#page-layout-settings')
|
||||
var page_widget_list = $('#page-widget-list');
|
||||
var page_widget_view = $('#page-widget-view');
|
||||
var page_widget_makebbs = $('#page-widget-makebbs');
|
||||
var page_widget_makelist = $('#page-widget-makelist');
|
||||
var modal_widget_selector = $('#modal-widget-selector');
|
||||
var sheet_layoutreset_confirm = $('#sheet-layoutreset-confirm');
|
||||
|
||||
$('#layout-settings-panels').on('show.rc.collapse', function (e) {
|
||||
var target = $(e.target)
|
||||
var cell = target.closest('.table-view-cell')
|
||||
$(this).find('[data-toggle="collapse"]').removeClass('bg-faded');
|
||||
cell.find('[data-toggle="collapse"]').addClass('bg-faded')
|
||||
})
|
||||
|
||||
page_layout_settings.find('[data-act="submit"]').click(function(){
|
||||
$(this).attr('disabled', true );
|
||||
setTimeout(function(){
|
||||
page_layout_settings.find('form').submit()
|
||||
}, 500);
|
||||
});
|
||||
|
||||
page_layout_settings.find('[name="layout_main_type"]').change(function(){
|
||||
var type = $(this).val();
|
||||
var button = page_layout_settings.find('[data-target="#page-widget-list"]').closest('.table-view');
|
||||
if (type=='widget') button.removeClass('d-none');
|
||||
else button.addClass('d-none');
|
||||
});
|
||||
|
||||
page_widget_list.find('[data-act="submit"]').click(function(){
|
||||
$(this).attr("disabled", true);
|
||||
var widgets=$(document).find('#page-widget-list input[name="widget_members[]"]').map(function(){return $(this).val()}).get();
|
||||
var new_widgets='';
|
||||
if(widgets){
|
||||
for(var i=0;i<widgets.length;i++) {
|
||||
new_widgets+=widgets[i];
|
||||
}
|
||||
page_widget_list.find('input[name="main_widgets"]').val(new_widgets);
|
||||
}
|
||||
setTimeout(function(){
|
||||
page_widget_list.find('[name="layoutMainPage"]').submit();
|
||||
resetPage(); // 상태초기화
|
||||
page_widget_list.find('[data-role="reset"]').removeClass('d-none')
|
||||
}, 500);
|
||||
});
|
||||
|
||||
page_widget_list.on('show.rc.page', function (event) {
|
||||
var page = $(this)
|
||||
|
||||
setTimeout(function(){
|
||||
$.post(rooturl+'/?r='+raccount+'&m=site&a=get_widgetPage',{
|
||||
page : 'main',
|
||||
layout : 'rc-starter'
|
||||
},function(response,status){
|
||||
if(status=='success'){
|
||||
var result = $.parseJSON(response);
|
||||
var list=result.list;
|
||||
var layoutPageVarForSite=result.layoutPageVarForSite;
|
||||
|
||||
page.find('[data-role="widgetPage"]').html(list);
|
||||
|
||||
if (layoutPageVarForSite) page.find('[data-role="reset"]').removeClass('d-none');
|
||||
else page.find('[data-role="reset"]').addClass('d-none');
|
||||
|
||||
//순서변경
|
||||
page.find('[data-plugin="sortable"] ol').sortable({
|
||||
axis: 'y',
|
||||
cancel: 'button',
|
||||
delay: 250,
|
||||
placeholder: 'ui-state-highlight'
|
||||
});
|
||||
page.find('[data-plugin="sortable"] ol').disableSelection();
|
||||
|
||||
} else {
|
||||
alert('위젯설정을 확인해주세요.')
|
||||
return false
|
||||
}
|
||||
});
|
||||
}, 200);
|
||||
|
||||
})
|
||||
|
||||
page_widget_list.on('hidden.rc.page', function (event) {
|
||||
var page = $(this)
|
||||
page.find('[data-role="widgetPage"]').html('');
|
||||
})
|
||||
|
||||
page_widget_view.on('click','[data-act="save"]',function() {
|
||||
var name = $(document).find('#page-widget-view').attr('data-name');
|
||||
var _title = $(document).find('#page-widget-view [data-role="widgetConfig"] [name="title"]').val();
|
||||
var title_placeholder = $(document).find('#page-widget-view [data-role="widgetConfig"] [name="title"]').attr('placeholder');
|
||||
var path = $(document).find('#page-widget-view').attr('data-path');
|
||||
var id = $(document).find('#page-widget-view').attr('data-id');
|
||||
var mod = $(this).attr('data-mod');
|
||||
var area = $(this).attr('data-area');
|
||||
|
||||
$(this).attr('disabled', true);
|
||||
|
||||
var title = _title?_title:title_placeholder;
|
||||
if (!title) title = name;
|
||||
|
||||
$(document).find('[data-role="widgetPage"] .card').removeClass('animated bounceIn delay-3')
|
||||
|
||||
var widget_var = id+'^'+title+'^'+path+'^';
|
||||
|
||||
$('#page-widget-view [data-role="widgetConfig"] [name]').each(function(index){
|
||||
var _name = $(this).attr('name');
|
||||
var _var = $(this).val()?$(this).val():'';
|
||||
if (_name=='title' && !_var ) _var = $(this).attr('placeholder');
|
||||
widget_var += _name+'='+_var+',';
|
||||
});
|
||||
|
||||
setTimeout(function(){
|
||||
history.back();
|
||||
resetPage();
|
||||
if (mod=='add') {
|
||||
var box = '<li class="card bg-white round-0 position-relative text-muted text-xs-center ui-sortable-handle animated fadeInUp delay-3" data-name="'+name+'" data-path="'+path+'" data-role="item" id="'+id+'">'+
|
||||
'<a data-act="remove" title="삭제" role="button" class="position-absolute btn btn-link text-muted border-0" style="right:.5rem;top:50%;margin-top: -.92rem;"><i class="fa fa-times" aria-hidden="true"></i></a>'+
|
||||
'<div data-act="move" class="position-absolute btn btn-link text-muted border-0" style="left:.5rem;top:50%;margin-top: -.92rem;"><i class="fa fa-arrows" aria-hidden="true"></i></div>'+
|
||||
'<input type="hidden" name="widget_members[]" value="['+widget_var+']">'+
|
||||
'<button type="button" class="btn btn-link btn-lg text-reset" data-act="edit">'+title+'</button>'+
|
||||
'</li>';
|
||||
|
||||
setTimeout(function(){
|
||||
$(document).find('#page-widget-list [data-role="widgetPage"][data-area="'+area+'"] ol').append(box);
|
||||
$('#page-widget-list .content').scrollTop(10000);
|
||||
}, 300);
|
||||
|
||||
} else {
|
||||
|
||||
$(document).find('#'+id+' [name="widget_members[]"]').val('['+widget_var+']');
|
||||
$(document).find('#'+id+'').addClass('animated bounceIn');
|
||||
$(document).find('#'+id+' [data-role="title"]').text(title);
|
||||
$(document).find('#'+id+' [data-act="edit"]').text(title);
|
||||
$(document).find('#page-widget-list [data-role="widgetPage"] [data-role="item"]').removeClass('active shadow-sm')
|
||||
page_widget_list.find('[data-act="submit"]').click();
|
||||
}
|
||||
|
||||
}, 200);
|
||||
|
||||
});
|
||||
|
||||
page_widget_view.on('hidden.rc.page', function (event) {
|
||||
var page = $(this)
|
||||
page.find('[data-act="save"]').attr('disabled', false);
|
||||
resetPage();
|
||||
})
|
||||
|
||||
page_widget_view.on('click','[data-act="make"]',function() {
|
||||
var button = $(this);
|
||||
var mod = button.attr('data-mod');
|
||||
if (mod=='bbs') var target = page_widget_makebbs;
|
||||
if (mod=='postlist') var target = page_widget_makelist;
|
||||
if (!mod) return false;
|
||||
target.page({ start: '#page-widget-view' });
|
||||
})
|
||||
|
||||
|
||||
page_widget_view.on('click','[data-act="code"]',function() {
|
||||
var name = page_widget_view.attr('data-name');
|
||||
var title = page_widget_view.find('[name="title"]').val();
|
||||
var path = page_widget_view.attr('data-path');
|
||||
|
||||
if (!title) title = name;
|
||||
|
||||
var widget_var = '';
|
||||
|
||||
page_widget_view.find('[data-role="widgetConfig"] [name]').each(function(index){
|
||||
var _name = $(this).attr('name');
|
||||
var _var = $(this).val()?$(this).val():'';
|
||||
widget_var += "'"+_name+"'=>'"+_var+"',";
|
||||
});
|
||||
|
||||
var code = "<?php getWidget('"+path+"',array("+widget_var+")) ?>";
|
||||
|
||||
$('#widgetCode').val(code);
|
||||
|
||||
var clipboard = new ClipboardJS('.js-clipboard');
|
||||
|
||||
clipboard.off().on('success', function (e) {
|
||||
$(e.trigger)
|
||||
$.notify({message: '클립보드 복사완료!'},{type: 'default'});
|
||||
e.clearSelection()
|
||||
})
|
||||
|
||||
clipboard.on('error', function (e) {
|
||||
var modifierKey = /Mac/i.test(navigator.userAgent) ? '\u2318' : 'Ctrl-'
|
||||
var fallbackMsg = 'Press ' + modifierKey + 'C to copy'
|
||||
|
||||
$(e.trigger)
|
||||
.attr('title', fallbackMsg)
|
||||
.attr('title', 'Copy to clipboard')
|
||||
})
|
||||
});
|
||||
|
||||
//게시판 선택시
|
||||
$(document).on('change','[data-role="widgetConfig"] [name="bid"]',function(){
|
||||
var name = $(this).find('option:selected').attr('data-name');
|
||||
var link = $(this).find('option:selected').attr('data-link');
|
||||
var id = $(this).find('option:selected').val();
|
||||
if (id) {
|
||||
page_widget_view.find('[data-role="widgetConfig"]').find('[name="title"]').val(name);
|
||||
page_widget_view.find('[data-role="widgetConfig"]').find('[name="link"]').val(link);
|
||||
} else {
|
||||
page_widget_view.find('[data-role="widgetConfig"]').find('[name="title"]').val('');
|
||||
page_widget_view.find('[data-role="widgetConfig"]').find('[name="link"]').val('');
|
||||
}
|
||||
});
|
||||
|
||||
//포스트 카테고리 선택시
|
||||
$(document).on('change','[data-role="widgetConfig"] [name="cat"]',function(){
|
||||
var category = $(this).find('option:selected').attr('data-category');
|
||||
if (category) {
|
||||
page_widget_view.find('[data-role="widgetConfig"]').find('[name="title"]').val(category);
|
||||
} else {
|
||||
page_widget_view.find('[data-role="widgetConfig"]').find('[name="title"]').val('');
|
||||
}
|
||||
});
|
||||
|
||||
page_widget_makebbs.on('show.rc.page', function (event) {
|
||||
var page = $(this)
|
||||
page.find('input').val('');
|
||||
page.find('.input-row').removeClass('active');
|
||||
|
||||
})
|
||||
|
||||
page_widget_makelist.on('show.rc.page', function (event) {
|
||||
var page = $(this)
|
||||
page.find('input').val('');
|
||||
page.find('.input-row').removeClass('active');
|
||||
})
|
||||
|
||||
page_widget_makebbs.on('click','[data-act="submit"]',function() {
|
||||
var page = page_widget_makebbs;
|
||||
var button = $(this);
|
||||
var id = page.find('[name="id"]').val();
|
||||
var name = page.find('[name="name"]').val();
|
||||
if (!id) {
|
||||
page.find('[name="id"]').focus().addClass('is-invalid');
|
||||
page.find('[name="id"]').nextAll('.invalid-tooltip').text('게시판 아이디를 입력해주세요.')
|
||||
return false
|
||||
}
|
||||
|
||||
//아이디 유용성 체크
|
||||
if (!chkIdValue(id)) {
|
||||
page.find('[name="id"]').focus().addClass('is-invalid');
|
||||
page.find('[name="id"]').nextAll('.invalid-tooltip').text('영문 또는 숫자를 사용해주세요.')
|
||||
return false
|
||||
}
|
||||
|
||||
if (!name) {
|
||||
page.find('[name="name"]').focus().addClass('is-invalid');
|
||||
page.find('[name="name"]').nextAll('.invalid-tooltip').text('게시판 이름을 입력해주세요.')
|
||||
return false
|
||||
}
|
||||
|
||||
button.attr('disabled',true);
|
||||
setTimeout(function(){
|
||||
|
||||
$.post(rooturl+'/?r='+raccount+'&m=bbs&a=makebbs',{
|
||||
id : id,
|
||||
name : name,
|
||||
m_layout : 'rc-starter/blank-drawer.php',
|
||||
send_mod : 'ajax'
|
||||
},function(response,status){
|
||||
if(status=='success'){
|
||||
var result = $.parseJSON(response);
|
||||
var error=result.error;
|
||||
|
||||
if (error=='id_exists') {
|
||||
page.find('[name="id"]').focus().addClass('is-invalid');
|
||||
page.find('[name="id"]').nextAll('.invalid-tooltip').text('이미 같은 아이디의 게시판이 존재합니다.');
|
||||
button.attr('disabled',false);
|
||||
return false
|
||||
}
|
||||
|
||||
history.back();
|
||||
page_widget_view.find('[name="bid"]').append('<option value="'+id+'" data-name="'+name+'" data-link="/b/'+id+'">ㆍ '+name+'('+id+')</option>');
|
||||
page_widget_view.find('[name="bid"]').val(id).attr('selected','selected');
|
||||
page_widget_view.find('[name="title"]').val(name);
|
||||
page_widget_view.find('[name="link"]').val('/b/'+id);
|
||||
|
||||
} else {
|
||||
button.attr('disabled',false);
|
||||
alert('다시 시도해 주세요.')
|
||||
return false
|
||||
}
|
||||
});
|
||||
|
||||
}, 500);
|
||||
})
|
||||
|
||||
page_widget_makebbs.find('input').keyup(function() {
|
||||
$(this).removeClass('is-invalid');
|
||||
page_widget_makebbs.find('.invalid-tooltip').text('')
|
||||
});
|
||||
|
||||
page_widget_makelist.find('input').keyup(function() {
|
||||
$(this).removeClass('is-invalid');
|
||||
page_widget_makelist.find('.invalid-tooltip').text('')
|
||||
});
|
||||
|
||||
page_widget_makelist.on('click','[data-act="submit"]',function() {
|
||||
var page = page_widget_makelist;
|
||||
var button = $(this);
|
||||
var name = page.find('[name="name"]').val();
|
||||
|
||||
if (!name) {
|
||||
page.find('[name="name"]').focus().addClass('is-invalid');
|
||||
page.find('[name="name"]').nextAll('.invalid-tooltip').text('리스트명을 입력해주세요.')
|
||||
return false
|
||||
}
|
||||
|
||||
button.attr('disabled',true);
|
||||
setTimeout(function(){
|
||||
|
||||
$.post(rooturl+'/?r='+raccount+'&m=post&a=regis_list',{
|
||||
display : 3,
|
||||
name : name,
|
||||
send_mod : 'ajax'
|
||||
},function(response,status){
|
||||
if(status=='success'){
|
||||
var result = $.parseJSON(response);
|
||||
var error=result.error;
|
||||
var id=result.id;
|
||||
|
||||
if (error=='name_exists') {
|
||||
page.find('[name="name"]').focus().addClass('is-invalid');
|
||||
page.find('[name="name"]').nextAll('.invalid-tooltip').text('이미 같은 이름의 리스트가 존재합니다.');
|
||||
button.attr('disabled',false);
|
||||
return false
|
||||
}
|
||||
|
||||
history.back();
|
||||
page_widget_view.find('[name="listid"]').append('<option value="'+id+'">ㆍ '+name+'</option>');
|
||||
page_widget_view.find('[name="listid"]').val(id).attr('selected','selected');
|
||||
|
||||
} else {
|
||||
button.attr('disabled',false);
|
||||
alert('다시 시도해 주세요.')
|
||||
return false
|
||||
}
|
||||
});
|
||||
|
||||
}, 500);
|
||||
})
|
||||
|
||||
page_widget_makebbs.on('hide.rc.page', function (event) {
|
||||
var page = $(this)
|
||||
page.find('input').blur();
|
||||
page.find('[data-act="submit"]').attr('disabled',false);
|
||||
page.find('input').removeClass('is-invalid');
|
||||
page.find('.invalid-tooltip').text('')
|
||||
})
|
||||
|
||||
page_widget_makelist.on('hide.rc.page', function (event) {
|
||||
var page = $(this)
|
||||
page.find('input').blur();
|
||||
page.find('[data-act="submit"]').attr('disabled',false);
|
||||
page.find('input').removeClass('is-invalid');
|
||||
page.find('.invalid-tooltip').text('')
|
||||
})
|
||||
|
||||
$(document).find('[data-role="widgetPage"]').on('tap','[data-act="remove"]',function(e){
|
||||
e.preventDefault();
|
||||
$(this).closest('.card').remove();
|
||||
// resetPage();
|
||||
});
|
||||
|
||||
$(document).find('[data-role="widgetPage"]').on('tap','[data-act="edit"]',function(e) {
|
||||
var item = $(this).closest('[data-role="item"]')
|
||||
var id = item.attr('id');
|
||||
var name = item.attr('data-name');
|
||||
var path = item.attr('data-path');
|
||||
var wdgvar = item.find('[name="widget_members[]"]').val();
|
||||
var area;
|
||||
setWidgetConfig(id,name,path,wdgvar,area)
|
||||
page_widget_list.find('[data-role="widgetPage"] [data-role="item"]').removeClass('active shadow-sm');
|
||||
page_widget_view.find('[data-role="widgetConfig"]').attr('data-id',id);
|
||||
page_widget_list.find('[data-role="addWidget"]').removeClass('active');
|
||||
item.addClass('active shadow-sm');
|
||||
});
|
||||
|
||||
modal_widget_selector.on('show.rc.modal', function (e) {
|
||||
var modal = $(this);
|
||||
var button = $(e.relatedTarget);
|
||||
var area = button.attr('data-area');
|
||||
|
||||
//상태 초기화
|
||||
modal.find('select').prop('selectedIndex',0).removeAttr('data-area');
|
||||
modal.find('[data-role="none"]').removeClass('d-none');
|
||||
modal.find('[data-role="readme"]').addClass('d-none');
|
||||
modal.find('[data-role="thumb"]').addClass('d-none');
|
||||
modal.find('.bar-tab').addClass('d-none');
|
||||
|
||||
resetPage();
|
||||
setTimeout(function(){ modal.find('[name="widget_selector"]').attr('data-area',area).trigger('focus'); }, 100);
|
||||
|
||||
})
|
||||
|
||||
modal_widget_selector.find('[name="widget_selector"]').change(function(){
|
||||
var modal = $('#modal-widget-selector');
|
||||
var path = $(this).val();
|
||||
var name = $(this).find('option:selected').text();
|
||||
var id = randomId();
|
||||
var area = $(this).attr('data-area');
|
||||
var wdgvar = '';
|
||||
var button = $('#modal-widget-selector').find('[data-act="apply"]');
|
||||
|
||||
if (path) $('#modal-widget-selector').find('.bar-tab').removeClass('d-none');
|
||||
else $('#modal-widget-selector').find('.bar-tab').addClass('d-none');
|
||||
|
||||
modal.find('[data-role="none"]').removeClass('d-none');
|
||||
modal.find('[data-role="thumb"]').addClass('d-none').removeClass('animated fadeIn');;
|
||||
modal.find('[data-role="thumb"] img').attr('src','');
|
||||
modal.find('[data-role="readme"]').html('');
|
||||
|
||||
button.attr('data-path',path);
|
||||
button.attr('data-name',name);
|
||||
button.attr('data-id',id);
|
||||
button.attr('data-area',area);
|
||||
|
||||
$.post(rooturl+'/?r='+raccount+'&m=site&a=get_widgetGuide',{
|
||||
widget : path
|
||||
},function(response,status){
|
||||
if(status=='success'){
|
||||
var result = $.parseJSON(response);
|
||||
var readme=result.readme;
|
||||
var thumb=result.thumb;
|
||||
|
||||
modal.find('[data-role="readme"]').html(readme).removeClass('d-none');
|
||||
|
||||
if (!thumb) {
|
||||
modal.find('[data-role="none"]').removeClass('d-none');
|
||||
modal.find('[data-role="thumb"]').addClass('d-none');
|
||||
} else {
|
||||
modal.find('[data-role="none"]').addClass('d-none');
|
||||
modal.find('[data-role="thumb"]').removeClass('d-none').addClass('animated fadeIn');
|
||||
modal.find('[data-role="thumb"] img').attr('src',thumb);
|
||||
}
|
||||
|
||||
} else {
|
||||
alert('위젯설정을 확인해주세요.')
|
||||
return false
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
modal_widget_selector.find('[data-act="apply"]').click(function(){
|
||||
|
||||
var button = $(this)
|
||||
var path = button.attr('data-path');
|
||||
var name = button.attr('data-name');
|
||||
var id = button.attr('data-id');
|
||||
var area = button.attr('data-area');
|
||||
var wdgvar = '';
|
||||
var modal = $('#modal-widget-selector');
|
||||
|
||||
history.back();
|
||||
|
||||
if (!path) {
|
||||
modal.find('[name="widget_selector"]').focus();
|
||||
console.log('path 정보가 없습니다.')
|
||||
$.notify({message: '다시 시도해 주세요.'},{type: 'default'});
|
||||
return false;
|
||||
}
|
||||
setTimeout(function(){
|
||||
$('#page-widget-view [data-role="form"]').html('');
|
||||
$('#page-widget-list [data-role="item"]').removeClass('active shadow-sm')
|
||||
|
||||
if (path) {
|
||||
setWidgetConfig(id,name,path,wdgvar,area)
|
||||
$('#page-widget-list [data-role="widgetPage"][data-area="'+area+'"] [data-role="addWidget"]').addClass('active');
|
||||
} else {
|
||||
$('#page-widget-view [data-role="widgetConfig"]').addClass('d-none');
|
||||
}
|
||||
}, 10);
|
||||
});
|
||||
|
||||
modal_widget_selector.on('hidden.rc.modal', function (event) {
|
||||
var modal = $(this)
|
||||
var button = modal.find('[data-act="submit"]');
|
||||
var selector = modal.find('[name="widget_selector"]');
|
||||
button.removeAttr('data-path').removeAttr('data-id').removeAttr('data-area').removeAttr('data-name');
|
||||
selector.removeAttr('data-area');
|
||||
modal.find('[name="widget_selector"]').prop('selectedIndex',0);
|
||||
modal.find('[data-role="readme"]').html('');
|
||||
modal.find('[data-role="thumb"]').attr('src','')
|
||||
|
||||
$('[data-role="addWidget"]').removeClass('active');
|
||||
})
|
||||
|
||||
sheet_layoutreset_confirm.find('[data-reset="main"]').click(function(){
|
||||
var page = page_widget_list.find('[name="page"]').val();
|
||||
var area = page_widget_list.find('[name="area"]').val();
|
||||
history.back(); //sheet 내림
|
||||
setTimeout(function(){
|
||||
page_widget_list.find('[data-role="widgetPage"]').loader({ position: 'inside' });
|
||||
$.post(rooturl+'/?r='+raccount+'&m=site&a=deletelayoutpage',{
|
||||
page : page,
|
||||
area : area
|
||||
},function(response,status){
|
||||
if(status=='success'){
|
||||
var result = $.parseJSON(response);
|
||||
var error=result.error;
|
||||
var list=result.list;
|
||||
if (!error) {
|
||||
page_widget_list.find('[data-role="widgetPage"]').html(list).addClass('animated fadeInUp delay-3');
|
||||
page_widget_list.find('[data-role="reset"]').addClass('d-none')
|
||||
}
|
||||
} else {
|
||||
alert('다시시도 해주세요.')
|
||||
return false
|
||||
}
|
||||
});
|
||||
|
||||
}, 300);
|
||||
|
||||
});
|
||||
94
layouts/rc-starter/_js/system.js
Normal file
94
layouts/rc-starter/_js/system.js
Normal file
@@ -0,0 +1,94 @@
|
||||
var page_software_loglist = $('#page-software-loglist');
|
||||
var page_software_logview = $('#page-software-logview');
|
||||
|
||||
$('.markdown-body').markdown();
|
||||
|
||||
$('#sheet-update-confirm [data-act="submit"]').click(function(){
|
||||
history.back();
|
||||
setTimeout(function(){
|
||||
$('.content').loader({ position: 'overlay',text: '잠시만 기다리세요...' });
|
||||
}, 300);
|
||||
setTimeout(function(){
|
||||
$('[name="updateForm"]').submit();
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
$('[data-act="gitinit"]').click(function(){
|
||||
$(this).attr( 'disabled', true );
|
||||
$('.content').loader({ position: 'overlay',text: '잠시만 기다리세요...' });
|
||||
setTimeout(function(){
|
||||
$.post(rooturl+'/?r='+raccount+'&m=admin&a=gitinit',{
|
||||
},function(response,status){
|
||||
if(status=='success'){
|
||||
var result = $.parseJSON(response);
|
||||
var error=result.error;
|
||||
var msg=result.msg;
|
||||
if (error) {
|
||||
$.notify({message: msg},{type: 'default'});
|
||||
$(this).attr( 'disabled', false );
|
||||
return false
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
} else {
|
||||
$.notify({message: '다시 시도해 주세요.'},{type: 'default'});
|
||||
$(this).attr( 'disabled', false );
|
||||
return false
|
||||
}
|
||||
});
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
page_software_loglist.on('show.rc.page', function(event) {
|
||||
var button = $(event.relatedTarget);
|
||||
var page = $(this);
|
||||
page.find('[data-role="list"]').loader({ position: 'inside' });
|
||||
setTimeout(function(){
|
||||
$.post(rooturl+'/?r='+raccount+'&m=admin&a=get_updateList',{
|
||||
},function(response,status){
|
||||
if(status=='success'){
|
||||
var result = $.parseJSON(response);
|
||||
var list=result.list;
|
||||
page.find('[data-role="list"]').html(list)
|
||||
} else {
|
||||
$.notify({message: '다시 시도해 주세요.'},{type: 'danger'});
|
||||
return false
|
||||
}
|
||||
});
|
||||
}, 200);
|
||||
});
|
||||
|
||||
page_software_logview.on('show.rc.page', function(event) {
|
||||
var button = $(event.relatedTarget);
|
||||
var page = $(this);
|
||||
var uid = button.attr('data-uid');
|
||||
|
||||
page.find('[data-role="list"]').loader({ position: 'inside' });
|
||||
setTimeout(function(){
|
||||
$.post(rooturl+'/?r='+raccount+'&m=admin&a=get_updateData',{
|
||||
uid : uid
|
||||
},function(response,status){
|
||||
if(status=='success'){
|
||||
var result = $.parseJSON(response);
|
||||
var version=result.version;
|
||||
var name=result.name;
|
||||
var output=result.output;
|
||||
var d_regis=result.d_regis;
|
||||
page.find('[data-role="version"]').text(version);
|
||||
page.find('[data-role="name"]').text(name);
|
||||
page.find('[data-role="output"]').val(output);
|
||||
page.find('[data-role="d_regis"]').text(d_regis);
|
||||
} else {
|
||||
$.notify({message: '다시 시도해 주세요.'},{type: 'danger'});
|
||||
return false
|
||||
}
|
||||
});
|
||||
}, 200);
|
||||
})
|
||||
|
||||
page_software_logview.on('hidden.rc.page', function(event) {
|
||||
var page = $(this);
|
||||
page.find('[data-role="version"]').html('');
|
||||
page.find('[data-role="output"]').val('');
|
||||
page.find('[data-role="d_regis"]').html('');
|
||||
})
|
||||
Reference in New Issue
Block a user