/*! * 게시판 스킨 공용 함수 — webNote / DateFlat / DateSelect * 필요: jquery, jquery-ui(달력), summernote-lite(+ko-KR) * 사이트에 같은 이름 함수가 이미 있으면(예: 사이트 common.js) 그쪽이 우선 (아래는 없을 때만 정의) */ (function( $ ) { //* 에디터 — webNote( 선택자, 높이, 안내문구 ) //? 이미지는 본문에 data:image 로 들어감 (서버 BoardSanitizeHtml 이 data:image 만 허용) if( typeof window.webNote !== 'function' ) { window.webNote = function( selector, height, placeholder ) { $( selector ).summernote({ lang : 'ko-KR', height : parseInt( height, 10 ) || 400, placeholder : placeholder || '', disableDragAndDrop : false, toolbar : [ [ 'style', [ 'style' ] ], [ 'font', [ 'bold', 'italic', 'underline', 'strikethrough', 'clear' ] ], [ 'fontsize', [ 'fontsize' ] ], [ 'color', [ 'forecolor', 'backcolor' ] ], [ 'para', [ 'ul', 'ol', 'paragraph' ] ], [ 'table', [ 'table' ] ], [ 'insert', [ 'link', 'picture', 'video' ] ], [ 'view', [ 'codeview' ] ] ], callbacks : { //! 큰 이미지 붙여넣기 방지 (기본 5MB) onImageUpload : function( files ) { var editor = $( this ); $.each( files, function( i, file ) { if( !/^image\/(png|jpe?g|gif|webp)$/i.test( file.type ) ) { alert( '이미지 파일만 넣을 수 있습니다.' ); return; } if( file.size > 5 * 1024 * 1024 ) { alert( '이미지는 5MB 이하만 넣을 수 있습니다.' ); return; } var reader = new FileReader(); reader.onload = function( e ) { editor.summernote( 'insertImage', e.target.result ); }; reader.readAsDataURL( file ); }); } } }); }; } //* 달력 — DateSelect( 선택자 ) / DateFlat( 선택자 ) : 둘 다 jquery-ui datepicker (yyyy-mm-dd) var dateKo = { dateFormat : 'yy-mm-dd', changeMonth : true, changeYear : true, showMonthAfterYear : true, yearSuffix : '년', monthNames : [ '1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월' ], monthNamesShort : [ '1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월' ], dayNames : [ '일','월','화','수','목','금','토' ], dayNamesMin : [ '일','월','화','수','목','금','토' ], prevText : '이전', nextText : '다음', closeText : '닫기', currentText : '오늘', showButtonPanel : true }; if( typeof window.DateSelect !== 'function' ) { window.DateSelect = function( selector, option ) { if( !$.fn.datepicker ) return; $( selector ).attr( 'autocomplete', 'off' ).datepicker( $.extend( {}, dateKo, option || {} ) ); }; } if( typeof window.DateFlat !== 'function' ) { window.DateFlat = function( selector, option ) { window.DateSelect( selector, option ); }; } })( jQuery );