diff --git a/Gruntfile.js b/Gruntfile.js index eada99fb9..c98f6a5cd 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -60,6 +60,9 @@ module.exports = function(grunt) { 'modules/editor/skins/xpresseditor/js/xpresseditor.min.js': ['modules/editor/skins/xpresseditor/js/xpresseditor.js'], 'modules/editor/skins/xpresseditor/js/xe_textarea.min.js': ['modules/editor/skins/xpresseditor/js/xe_textarea.js'], 'modules/editor/tpl/js/editor_common.min.js': ['modules/editor/tpl/js/editor_common.js'], + 'modules/editor/tpl/js/swfupload.min.js': ['modules/editor/tpl/js/swfupload.js'], + 'modules/editor/tpl/js/uploader.min.js': ['modules/editor/tpl/js/uploader.js'], + 'modules/editor/tpl/js/editor.min.js': ['modules/editor/tpl/js/editor.js'], // module/admin 'modules/admin/tpl/js/admin.min.js': ['modules/admin/tpl/js/admin.js'], 'modules/admin/tpl/js/config.min.js': ['modules/admin/tpl/js/config.js'], diff --git a/modules/editor/tpl/js/editor.js b/modules/editor/tpl/js/editor.js index 592a7165b..c16146354 100755 --- a/modules/editor/tpl/js/editor.js +++ b/modules/editor/tpl/js/editor.js @@ -14,52 +14,52 @@ // editor_sequence값에 해당하는 textarea object를 return function editorGetTextArea(editor_sequence) { - return jQuery('#editor_textarea_' + editor_sequence)[0]; + return jQuery('#editor_textarea_' + editor_sequence)[0]; } function editorGetPreviewArea(editor_sequence) { - return jQuery( '#editor_preview_' + editor_sequence )[0]; + return jQuery( '#editor_preview_' + editor_sequence )[0]; } // editor_sequence에 해당하는 form문 구함 function editorGetForm(editor_sequence) { - var iframe_obj = editorGetIFrame(editor_sequence); - if(!iframe_obj) return; + var iframe_obj = editorGetIFrame(editor_sequence); + if(!iframe_obj) return; - var fo_obj = iframe_obj.parentNode; - while(fo_obj.nodeName != 'FORM') { fo_obj = fo_obj.parentNode; } - if(fo_obj.nodeName == 'FORM') return fo_obj; - return; + var fo_obj = iframe_obj.parentNode; + while(fo_obj.nodeName != 'FORM') { fo_obj = fo_obj.parentNode; } + if(fo_obj.nodeName == 'FORM') return fo_obj; + return; } // 에디터의 전체 내용 return function editorGetContent_xe(editor_sequence) { - var html = ""; - if(editorMode[editor_sequence]=='html') { - var textarea_obj = editorGetTextArea(editor_sequence); - if(!textarea_obj) return ""; - html = textarea_obj.value; - } else { - var iframe_obj = editorGetIFrame(editor_sequence); - if(!iframe_obj) return ""; - html = jQuery(iframe_obj.contentWindow.document.body).html().replace(/^]*)>$/i,''); - } - return html; + var html = ""; + if(editorMode[editor_sequence]=='html') { + var textarea_obj = editorGetTextArea(editor_sequence); + if(!textarea_obj) return ""; + html = textarea_obj.value; + } else { + var iframe_obj = editorGetIFrame(editor_sequence); + if(!iframe_obj) return ""; + html = jQuery(iframe_obj.contentWindow.document.body).html().replace(/^]*)>$/i,''); + } + return html; } // 에디터 내의 선택된 부분의 NODE를 return function editorGetSelectedNode(editor_sequence) { - var iframe_obj = editorGetIFrame(editor_sequence), w, range; + var iframe_obj = editorGetIFrame(editor_sequence), w, range; w = iframe_obj.contentWindow; - if(w.document.selection) { - range = w.document.selection.createRange(); - return jQuery('
').html(range.htmlText)[0].firstChild; - } else { - range = w.getSelection().getRangeAt(0); - return jQuery('
').append(range.cloneContents())[0].firstChild; - } + if(w.document.selection) { + range = w.document.selection.createRange(); + return jQuery('
').html(range.htmlText)[0].firstChild; + } else { + range = w.getSelection().getRangeAt(0); + return jQuery('
').append(range.cloneContents())[0].firstChild; + } } /** @@ -68,136 +68,136 @@ function editorGetSelectedNode(editor_sequence) { var _editorFontColor = new Array(); function editorStart(editor_sequence, primary_key, content_key, editor_height, font_color) { - if(typeof(font_color)=='undefined') font_color = '#000'; - _editorFontColor[editor_sequence] = font_color; + if(typeof(font_color)=='undefined') font_color = '#000'; + _editorFontColor[editor_sequence] = font_color; - // iframe obj를 찾음 - var iframe_obj = editorGetIFrame(editor_sequence); - if(!iframe_obj) return; + // iframe obj를 찾음 + var iframe_obj = editorGetIFrame(editor_sequence); + if(!iframe_obj) return; jQuery(iframe_obj).css('width', '100%').parent().css('width', '100%'); - // 현 에디터를 감싸고 있는 form문을 찾음 - var fo_obj = editorGetForm(editor_sequence); - if(!fo_obj) return; + // 현 에디터를 감싸고 있는 form문을 찾음 + var fo_obj = editorGetForm(editor_sequence); + if(!fo_obj) return; - // fo_obj에 editor_sequence 값 지정 - fo_obj.setAttribute('editor_sequence', editor_sequence); + // fo_obj에 editor_sequence 값 지정 + fo_obj.setAttribute('editor_sequence', editor_sequence); - // 모듈 연관 키 값을 세팅 - editorRelKeys[editor_sequence] = new Array(); - editorRelKeys[editor_sequence]["primary"] = fo_obj[primary_key]; - editorRelKeys[editor_sequence]["content"] = fo_obj[content_key]; - editorRelKeys[editor_sequence]["func"] = editorGetContent_xe; + // 모듈 연관 키 값을 세팅 + editorRelKeys[editor_sequence] = new Array(); + editorRelKeys[editor_sequence]["primary"] = fo_obj[primary_key]; + editorRelKeys[editor_sequence]["content"] = fo_obj[content_key]; + editorRelKeys[editor_sequence]["func"] = editorGetContent_xe; - // saved document(자동저장 문서)에 대한 확인 - if(typeof(fo_obj._saved_doc_title)!="undefined" ) { ///<< _saved_doc_title field가 없으면 자동저장 하지 않음 + // saved document(자동저장 문서)에 대한 확인 + if(typeof(fo_obj._saved_doc_title)!="undefined" ) { ///<< _saved_doc_title field가 없으면 자동저장 하지 않음 - var saved_title = fo_obj._saved_doc_title.value; - var saved_content = fo_obj._saved_doc_content.value; + var saved_title = fo_obj._saved_doc_title.value; + var saved_content = fo_obj._saved_doc_content.value; - if(saved_title || saved_content) { - // 자동저장된 문서 활용여부를 물은 후 사용하지 않는다면 자동저장된 문서 삭제 - if(confirm(fo_obj._saved_doc_message.value)) { - if(typeof(fo_obj.title)!='undefined') fo_obj.title.value = saved_title; - editorRelKeys[editor_sequence]['content'].value = saved_content; + if(saved_title || saved_content) { + // 자동저장된 문서 활용여부를 물은 후 사용하지 않는다면 자동저장된 문서 삭제 + if(confirm(fo_obj._saved_doc_message.value)) { + if(typeof(fo_obj.title)!='undefined') fo_obj.title.value = saved_title; + editorRelKeys[editor_sequence]['content'].value = saved_content; - var param = new Array(); - param['editor_sequence'] = editor_sequence; - param['primary_key'] = primary_key; - param['mid'] = current_mid; - var response_tags = new Array("error","message","editor_sequence","key","title","content","document_srl"); - exec_xml('editor',"procEditorLoadSavedDocument", param, getAutoSavedSrl, response_tags); - } else { - editorRemoveSavedDoc(); - } - } - } + var param = new Array(); + param['editor_sequence'] = editor_sequence; + param['primary_key'] = primary_key; + param['mid'] = current_mid; + var response_tags = new Array("error","message","editor_sequence","key","title","content","document_srl"); + exec_xml('editor',"procEditorLoadSavedDocument", param, getAutoSavedSrl, response_tags); + } else { + editorRemoveSavedDoc(); + } + } + } - // 대상 form의 content element에서 데이터를 구함 - var content = editorRelKeys[editor_sequence]['content'].value; + // 대상 form의 content element에서 데이터를 구함 + var content = editorRelKeys[editor_sequence]['content'].value; - // IE가 아니고 내용이 없으면
추가 (FF등에서 iframe 선택시 focus를 주기 위한 꽁수) - if(!content && !xIE4Up) content = "
"; + // IE가 아니고 내용이 없으면
추가 (FF등에서 iframe 선택시 focus를 주기 위한 꽁수) + if(!content && !xIE4Up) content = "
"; - // IE일 경우 ctrl-Enter 안내 문구를 노출 - var ieHelpObj = xGetElementById("for_ie_help_"+editor_sequence); - if(xIE4Up && ieHelpObj) { - ieHelpObj.style.display = "block"; - } + // IE일 경우 ctrl-Enter 안내 문구를 노출 + var ieHelpObj = xGetElementById("for_ie_help_"+editor_sequence); + if(xIE4Up && ieHelpObj) { + ieHelpObj.style.display = "block"; + } - // content 생성 - editor_path = editor_path.replace(/^\.\//ig, ''); - var contentHtml = ''+ - ''+ - ''+ - ''+ - ''+ - content+ - ''+ - ''; - iframe_obj.contentWindow.document.open("text/html","replace"); - iframe_obj.contentWindow.document.write(contentHtml); - iframe_obj.contentWindow.document.close(); + // content 생성 + editor_path = editor_path.replace(/^\.\//ig, ''); + var contentHtml = ''+ + ''+ + ''+ + ''+ + ''+ + content+ + ''+ + ''; + iframe_obj.contentWindow.document.open("text/html","replace"); + iframe_obj.contentWindow.document.write(contentHtml); + iframe_obj.contentWindow.document.close(); - // editorMode를 기본으로 설정 - editorMode[editor_sequence] = null; + // editorMode를 기본으로 설정 + editorMode[editor_sequence] = null; - // 에디터를 시작 시킴 - try { - iframe_obj.contentWindow.document.designMode = 'On'; - } catch(e) { - } + // 에디터를 시작 시킴 + try { + iframe_obj.contentWindow.document.designMode = 'On'; + } catch(e) { + } - try { - iframe_obj.contentWindow.document.execCommand("undo", false, null); - iframe_obj.contentWindow.document.execCommand("useCSS", false, true); - } catch (e) { - } + try { + iframe_obj.contentWindow.document.execCommand("undo", false, null); + iframe_obj.contentWindow.document.execCommand("useCSS", false, true); + } catch (e) { + } - /** - * 더블클릭이나 키눌림등의 각종 이벤트에 대해 listener 추가 - * 작성시 필요한 이벤트 체크 - * 이 이벤트의 경우 윈도우 sp1 (NT or xp sp1) 에서 iframe_obj.contentWindow.document에 대한 권한이 없기에 try 문으로 감싸서 - * 에러를 무시하도록 해야 함. - **/ + /** + * 더블클릭이나 키눌림등의 각종 이벤트에 대해 listener 추가 + * 작성시 필요한 이벤트 체크 + * 이 이벤트의 경우 윈도우 sp1 (NT or xp sp1) 에서 iframe_obj.contentWindow.document에 대한 권한이 없기에 try 문으로 감싸서 + * 에러를 무시하도록 해야 함. + **/ - // 위젯 감시를 위한 더블클릭 이벤트 걸기 - try { + // 위젯 감시를 위한 더블클릭 이벤트 걸기 + try { jQuery(iframe_obj.contentWindow.document) .unbind('dblclick.widget') .bind('dblclick.widget', editorSearchComponent); - } catch(e) { - } + } catch(e) { + } - // 에디터에서 키가 눌러질때마다 이벤트를 체크함 (enter키의 처리나 FF에서 alt-s등을 처리) - try { - if(xIE4Up) xAddEventListener(iframe_obj.contentWindow.document, 'keydown',editorKeyPress); - else xAddEventListener(iframe_obj.contentWindow.document, 'keypress',editorKeyPress); - } catch(e) { - } + // 에디터에서 키가 눌러질때마다 이벤트를 체크함 (enter키의 처리나 FF에서 alt-s등을 처리) + try { + if(xIE4Up) xAddEventListener(iframe_obj.contentWindow.document, 'keydown',editorKeyPress); + else xAddEventListener(iframe_obj.contentWindow.document, 'keypress',editorKeyPress); + } catch(e) { + } - // 자동저장 필드가 있다면 자동 저장 기능 활성화 - if(typeof(fo_obj._saved_doc_title)!="undefined" ) editorEnableAutoSave(fo_obj, editor_sequence); + // 자동저장 필드가 있다면 자동 저장 기능 활성화 + if(typeof(fo_obj._saved_doc_title)!="undefined" ) editorEnableAutoSave(fo_obj, editor_sequence); - // 좋지는 않으나;; 스타일 변형을 막기 위해 start 할때 html이면 바꿔주자 - if (xGetCookie('editor_mode') == 'html'){ - var iframe_obj = editorGetIFrame(editor_sequence); - if(xGetElementById('fileUploader_'+editor_sequence)) xGetElementById('fileUploader_'+editor_sequence).style.display='block'; - textarea_obj = editorGetTextArea(editor_sequence); - textarea_obj.value = content; - xWidth(textarea_obj, xWidth(iframe_obj.parentNode)); - xHeight(textarea_obj, xHeight(iframe_obj.parentNode)); - editorMode[editor_sequence] = 'html'; - if(xGetElementById('xeEditor_'+editor_sequence)) { - xGetElementById('xeEditor_'+editor_sequence).className = 'xeEditor html'; - xGetElementById('use_rich_'+editor_sequence).className = ''; - xGetElementById('preview_html_'+editor_sequence).className = ''; - xGetElementById('use_html_'+editor_sequence).className = 'active'; - } - } + // 좋지는 않으나;; 스타일 변형을 막기 위해 start 할때 html이면 바꿔주자 + if (xGetCookie('editor_mode') == 'html'){ + var iframe_obj = editorGetIFrame(editor_sequence); + if(xGetElementById('fileUploader_'+editor_sequence)) xGetElementById('fileUploader_'+editor_sequence).style.display='block'; + textarea_obj = editorGetTextArea(editor_sequence); + textarea_obj.value = content; + xWidth(textarea_obj, xWidth(iframe_obj.parentNode)); + xHeight(textarea_obj, xHeight(iframe_obj.parentNode)); + editorMode[editor_sequence] = 'html'; + if(xGetElementById('xeEditor_'+editor_sequence)) { + xGetElementById('xeEditor_'+editor_sequence).className = 'xeEditor html'; + xGetElementById('use_rich_'+editor_sequence).className = ''; + xGetElementById('preview_html_'+editor_sequence).className = ''; + xGetElementById('use_html_'+editor_sequence).className = 'active'; + } + } } @@ -213,211 +213,211 @@ function editorStart(editor_sequence, primary_key, content_key, editor_height, f // 입력 키에 대한 이벤트 체크 function editorKeyPress(evt) { - var e = new xEvent(evt); + var e = new xEvent(evt); - // 대상을 구함 - var obj = e.target; - var body_obj = null; - if(obj.nodeName == "BODY") body_obj = obj; - else body_obj = obj.firstChild.nextSibling; - if(!body_obj) return; + // 대상을 구함 + var obj = e.target; + var body_obj = null; + if(obj.nodeName == "BODY") body_obj = obj; + else body_obj = obj.firstChild.nextSibling; + if(!body_obj) return; - // editor_sequence는 에디터의 body에 attribute로 정의되어 있음 - var editor_sequence = body_obj.getAttribute("editor_sequence"); - if(!editor_sequence) return; + // editor_sequence는 에디터의 body에 attribute로 정의되어 있음 + var editor_sequence = body_obj.getAttribute("editor_sequence"); + if(!editor_sequence) return; - // IE에서 enter키를 눌렀을때 P 태그 대신 BR 태그 입력 - if (xIE4Up && !e.ctrlKey && !e.shiftKey && e.keyCode == 13 && !editorMode[editor_sequence]) { - var iframe_obj = editorGetIFrame(editor_sequence); - if(!iframe_obj) return; + // IE에서 enter키를 눌렀을때 P 태그 대신 BR 태그 입력 + if (xIE4Up && !e.ctrlKey && !e.shiftKey && e.keyCode == 13 && !editorMode[editor_sequence]) { + var iframe_obj = editorGetIFrame(editor_sequence); + if(!iframe_obj) return; - var contentDocument = iframe_obj.contentWindow.document; + var contentDocument = iframe_obj.contentWindow.document; - var obj = contentDocument.selection.createRange(); + var obj = contentDocument.selection.createRange(); - var pTag = obj.parentElement().tagName.toLowerCase(); + var pTag = obj.parentElement().tagName.toLowerCase(); - switch(pTag) { - case 'li' : - return; - break; - default : - obj.pasteHTML("
"); - break; - } - obj.select(); - evt.cancelBubble = true; - evt.returnValue = false; - return; - } + switch(pTag) { + case 'li' : + return; + break; + default : + obj.pasteHTML("
"); + break; + } + obj.select(); + evt.cancelBubble = true; + evt.returnValue = false; + return; + } - // ctrl-S, alt-S 클릭시 submit하기 - if( e.keyCode == 115 && (e.altKey || e.ctrlKey) ) { - // iframe 에디터를 찾음 - var iframe_obj = editorGetIFrame(editor_sequence); - if(!iframe_obj) return; + // ctrl-S, alt-S 클릭시 submit하기 + if( e.keyCode == 115 && (e.altKey || e.ctrlKey) ) { + // iframe 에디터를 찾음 + var iframe_obj = editorGetIFrame(editor_sequence); + if(!iframe_obj) return; - // 대상 form을 찾음 - var fo_obj = editorGetForm(editor_sequence); - if(!fo_obj) return; + // 대상 form을 찾음 + var fo_obj = editorGetForm(editor_sequence); + if(!fo_obj) return; - // 데이터 동기화 - editorRelKeys[editor_sequence]['content'].value = editorGetContent(editor_sequence); + // 데이터 동기화 + editorRelKeys[editor_sequence]['content'].value = editorGetContent(editor_sequence); - // form문 전송 - if(fo_obj.onsubmit) fo_obj.onsubmit(); + // form문 전송 + if(fo_obj.onsubmit) fo_obj.onsubmit(); - // 이벤트 중단 - evt.cancelBubble = true; - evt.returnValue = false; - xPreventDefault(evt); - xStopPropagation(evt); - return; - } + // 이벤트 중단 + evt.cancelBubble = true; + evt.returnValue = false; + xPreventDefault(evt); + xStopPropagation(evt); + return; + } - // ctrl-b, i, u, s 키에 대한 처리 (파이어폭스에서도 에디터 상태에서 단축키 쓰도록) - if (e.ctrlKey) { - // iframe 에디터를 찾음 - var iframe_obj = editorGetIFrame(editor_sequence); - if(!iframe_obj) return; + // ctrl-b, i, u, s 키에 대한 처리 (파이어폭스에서도 에디터 상태에서 단축키 쓰도록) + if (e.ctrlKey) { + // iframe 에디터를 찾음 + var iframe_obj = editorGetIFrame(editor_sequence); + if(!iframe_obj) return; - // html 에디터 모드일 경우 이벤트 취소 시킴 - if(editorMode[editor_sequence]) { - evt.cancelBubble = true; - evt.returnValue = false; - xPreventDefault(evt); - xStopPropagation(evt); - return; - } + // html 에디터 모드일 경우 이벤트 취소 시킴 + if(editorMode[editor_sequence]) { + evt.cancelBubble = true; + evt.returnValue = false; + xPreventDefault(evt); + xStopPropagation(evt); + return; + } - switch(e.keyCode) { - // ctrl+1~6 - case 49 : - case 50 : - case 51 : - case 52 : - case 53 : - case 54 : - editorDo('formatblock',"",e.target); - xPreventDefault(evt); - xStopPropagation(evt); - break; - // ctrl+7 - case 55 : - editorDo('formatblock',"

",e.target); - xPreventDefault(evt); - xStopPropagation(evt); - break; - // ie에서 ctrlKey + enter일 경우 P 태그 입력 - case 13 : - if(xIE4Up) { - if(e.target.parentElement.document.designMode!="On") return; - var obj = e.target.parentElement.document.selection.createRange(); - obj.pasteHTML('

'); - obj.select(); - evt.cancelBubble = true; - evt.returnValue = false; - return; - } - // bold - case 98 : - editorDo('Bold',null,e.target); - xPreventDefault(evt); - xStopPropagation(evt); - break; - // italic - case 105 : - editorDo('Italic',null,e.target); - xPreventDefault(evt); - xStopPropagation(evt); - break; - // underline - case 117 : - editorDo('Underline',null,e.target); - xPreventDefault(evt); - xStopPropagation(evt); - break; - //RemoveFormat - case 100 : - editorDo('RemoveFormat',null,e.target); - xPreventDefault(evt); - xStopPropagation(evt); - break; + switch(e.keyCode) { + // ctrl+1~6 + case 49 : + case 50 : + case 51 : + case 52 : + case 53 : + case 54 : + editorDo('formatblock',"",e.target); + xPreventDefault(evt); + xStopPropagation(evt); + break; + // ctrl+7 + case 55 : + editorDo('formatblock',"

",e.target); + xPreventDefault(evt); + xStopPropagation(evt); + break; + // ie에서 ctrlKey + enter일 경우 P 태그 입력 + case 13 : + if(xIE4Up) { + if(e.target.parentElement.document.designMode!="On") return; + var obj = e.target.parentElement.document.selection.createRange(); + obj.pasteHTML('

'); + obj.select(); + evt.cancelBubble = true; + evt.returnValue = false; + return; + } + // bold + case 98 : + editorDo('Bold',null,e.target); + xPreventDefault(evt); + xStopPropagation(evt); + break; + // italic + case 105 : + editorDo('Italic',null,e.target); + xPreventDefault(evt); + xStopPropagation(evt); + break; + // underline + case 117 : + editorDo('Underline',null,e.target); + xPreventDefault(evt); + xStopPropagation(evt); + break; + //RemoveFormat + case 100 : + editorDo('RemoveFormat',null,e.target); + xPreventDefault(evt); + xStopPropagation(evt); + break; - // strike - /* - case 83 : - case 115 : - editorDo('StrikeThrough',null,e.target); - xPreventDefault(evt); - xStopPropagation(evt); - break; - */ - } - } + // strike + /* + case 83 : + case 115 : + editorDo('StrikeThrough',null,e.target); + xPreventDefault(evt); + xStopPropagation(evt); + break; + */ + } + } } // 편집 기능 실행 function editorDo(command, value, target) { - var doc = null; + var doc = null; - // target이 object인지 editor_sequence인지에 따라 document를 구함 - if(typeof(target)=="object") { - if(xIE4Up) doc = target.parentElement.document; - else doc = target.parentNode; - } else { - var iframe_obj = editorGetIFrame(target); - doc = iframe_obj.contentWindow.document; - } + // target이 object인지 editor_sequence인지에 따라 document를 구함 + if(typeof(target)=="object") { + if(xIE4Up) doc = target.parentElement.document; + else doc = target.parentNode; + } else { + var iframe_obj = editorGetIFrame(target); + doc = iframe_obj.contentWindow.document; + } - var editor_sequence = doc.body.getAttribute('editor_sequence'); - if(editorMode[editor_sequence]) return; + var editor_sequence = doc.body.getAttribute('editor_sequence'); + if(editorMode[editor_sequence]) return; - // 포커스 - if(typeof(target)=="object") target.focus(); - else editorFocus(target); + // 포커스 + if(typeof(target)=="object") target.focus(); + else editorFocus(target); - // 실행 - doc.execCommand(command, false, value); + // 실행 + doc.execCommand(command, false, value); - // 포커스 - if(typeof(target)=="object") target.focus(); - else editorFocus(target); + // 포커스 + if(typeof(target)=="object") target.focus(); + else editorFocus(target); } // 폰트를 변경 function editorChangeFontName(obj,srl) { - var value = obj.options[obj.selectedIndex].value; - if(!value) return; - editorDo('FontName',value,srl); - obj.selectedIndex = 0; + var value = obj.options[obj.selectedIndex].value; + if(!value) return; + editorDo('FontName',value,srl); + obj.selectedIndex = 0; } function editorChangeFontSize(obj,srl) { - var value = obj.options[obj.selectedIndex].value; - if(!value) return; - editorDo('FontSize',value,srl); - obj.selectedIndex = 0; + var value = obj.options[obj.selectedIndex].value; + if(!value) return; + editorDo('FontSize',value,srl); + obj.selectedIndex = 0; } function editorUnDo(obj,srl) { - editorDo('undo','',srl); - obj.selectedIndex = 0; + editorDo('undo','',srl); + obj.selectedIndex = 0; } function editorReDo(obj,srl) { - editorDo('redo','',srl); - obj.selectedIndex = 0; + editorDo('redo','',srl); + obj.selectedIndex = 0; } function editorChangeHeader(obj,srl) { - var value = obj.options[obj.selectedIndex].value; - if(!value) return; - value = "<"+value+">"; - editorDo('formatblock',value,srl); - obj.selectedIndex = 0; + var value = obj.options[obj.selectedIndex].value; + if(!value) return; + value = "<"+value+">"; + editorDo('formatblock',value,srl); + obj.selectedIndex = 0; } /** @@ -426,100 +426,100 @@ function editorChangeHeader(obj,srl) { function editorChangeMode(mode, editor_sequence) { - if(mode == 'html' || mode ==''){ - var expire = new Date(); - expire.setTime(expire.getTime()+ (7000 * 24 * 3600000)); - xSetCookie('editor_mode', mode, expire); - } + if(mode == 'html' || mode ==''){ + var expire = new Date(); + expire.setTime(expire.getTime()+ (7000 * 24 * 3600000)); + xSetCookie('editor_mode', mode, expire); + } - var iframe_obj = editorGetIFrame(editor_sequence); - if(!iframe_obj) return; + var iframe_obj = editorGetIFrame(editor_sequence); + if(!iframe_obj) return; - var textarea_obj = editorGetTextArea(editor_sequence); - var preview_obj = editorGetPreviewArea(editor_sequence); - var contentDocument = iframe_obj.contentWindow.document; + var textarea_obj = editorGetTextArea(editor_sequence); + var preview_obj = editorGetPreviewArea(editor_sequence); + var contentDocument = iframe_obj.contentWindow.document; - var html = null; - if(editorMode[editor_sequence]=='html') { - html = textarea_obj.value; - contentDocument.body.innerHTML = textarea_obj.value; - } else if (editorMode[editor_sequence]=='preview') { + var html = null; + if(editorMode[editor_sequence]=='html') { + html = textarea_obj.value; + contentDocument.body.innerHTML = textarea_obj.value; + } else if (editorMode[editor_sequence]=='preview') { // html = xInnerHtml(preview_obj); - html = textarea_obj.value; - preview_obj.contentWindow.document.body.innerHTML = ''; + html = textarea_obj.value; + preview_obj.contentWindow.document.body.innerHTML = ''; // xAddEventListener(xGetElementById('editor_preview_'+editor_sequence), 'load', function(){setPreviewHeight(editor_sequence)}); - } else { - html = contentDocument.body.innerHTML; - textarea_obj.value = html - html = html.replace(/
/ig,"
\n"); - html = html.replace(/
\n\n/ig,"
\n"); - } + } else { + html = contentDocument.body.innerHTML; + textarea_obj.value = html + html = html.replace(/
/ig,"
\n"); + html = html.replace(/
\n\n/ig,"
\n"); + } - // html 편집 사용시 - if(mode == 'html' && textarea_obj) { - preview_obj.style.display='none'; - if(xGetElementById('fileUploader_'+editor_sequence)) xGetElementById('fileUploader_'+editor_sequence).style.display='block'; - textarea_obj.value = html; - xWidth(textarea_obj, xWidth(iframe_obj.parentNode)); - xHeight(textarea_obj, xHeight(iframe_obj.parentNode)); - editorMode[editor_sequence] = 'html'; + // html 편집 사용시 + if(mode == 'html' && textarea_obj) { + preview_obj.style.display='none'; + if(xGetElementById('fileUploader_'+editor_sequence)) xGetElementById('fileUploader_'+editor_sequence).style.display='block'; + textarea_obj.value = html; + xWidth(textarea_obj, xWidth(iframe_obj.parentNode)); + xHeight(textarea_obj, xHeight(iframe_obj.parentNode)); + editorMode[editor_sequence] = 'html'; - if(xGetElementById('xeEditor_'+editor_sequence)) { - xGetElementById('xeEditor_'+editor_sequence).className = 'xeEditor html'; - xGetElementById('use_rich_'+editor_sequence).className = ''; - xGetElementById('preview_html_'+editor_sequence).className = ''; - xGetElementById('use_html_'+editor_sequence).className = 'active'; - } - // 미리보기 - } else if(mode == 'preview' && preview_obj) { - preview_obj.style.display=''; - if(xGetElementById('fileUploader_'+editor_sequence)) xGetElementById('fileUploader_'+editor_sequence).style.display='none'; + if(xGetElementById('xeEditor_'+editor_sequence)) { + xGetElementById('xeEditor_'+editor_sequence).className = 'xeEditor html'; + xGetElementById('use_rich_'+editor_sequence).className = ''; + xGetElementById('preview_html_'+editor_sequence).className = ''; + xGetElementById('use_html_'+editor_sequence).className = 'active'; + } + // 미리보기 + } else if(mode == 'preview' && preview_obj) { + preview_obj.style.display=''; + if(xGetElementById('fileUploader_'+editor_sequence)) xGetElementById('fileUploader_'+editor_sequence).style.display='none'; - var fo_obj = xGetElementById("preview_form"); - if(!fo_obj) { - fo_obj = xCreateElement('form'); - fo_obj.id = "preview_form"; - fo_obj.method = "post"; - fo_obj.action = request_uri; - fo_obj.target = "editor_preview_"+editor_sequence; - xInnerHtml(fo_obj,''); - document.body.appendChild(fo_obj); - } - fo_obj.content.value = html; - fo_obj.submit(); + var fo_obj = xGetElementById("preview_form"); + if(!fo_obj) { + fo_obj = xCreateElement('form'); + fo_obj.id = "preview_form"; + fo_obj.method = "post"; + fo_obj.action = request_uri; + fo_obj.target = "editor_preview_"+editor_sequence; + xInnerHtml(fo_obj,''); + document.body.appendChild(fo_obj); + } + fo_obj.content.value = html; + fo_obj.submit(); - xWidth(preview_obj, xWidth(iframe_obj.parentNode)); - editorMode[editor_sequence] = 'preview'; + xWidth(preview_obj, xWidth(iframe_obj.parentNode)); + editorMode[editor_sequence] = 'preview'; - if(xGetElementById('xeEditor_'+editor_sequence)) { - xGetElementById('xeEditor_'+editor_sequence).className = 'xeEditor preview'; - xGetElementById('use_rich_'+editor_sequence).className = ''; - xGetElementById('preview_html_'+editor_sequence).className = 'active'; - if(xGetElementById('use_html_'+editor_sequence)) xGetElementById('use_html_'+editor_sequence).className = ''; - } - // 위지윅 모드 사용시 - } else { - preview_obj.style.display='none'; - if(xGetElementById('fileUploader_'+editor_sequence)) xGetElementById('fileUploader_'+editor_sequence).style.display='block'; - contentDocument.body.innerHTML = html; - editorMode[editor_sequence] = null; + if(xGetElementById('xeEditor_'+editor_sequence)) { + xGetElementById('xeEditor_'+editor_sequence).className = 'xeEditor preview'; + xGetElementById('use_rich_'+editor_sequence).className = ''; + xGetElementById('preview_html_'+editor_sequence).className = 'active'; + if(xGetElementById('use_html_'+editor_sequence)) xGetElementById('use_html_'+editor_sequence).className = ''; + } + // 위지윅 모드 사용시 + } else { + preview_obj.style.display='none'; + if(xGetElementById('fileUploader_'+editor_sequence)) xGetElementById('fileUploader_'+editor_sequence).style.display='block'; + contentDocument.body.innerHTML = html; + editorMode[editor_sequence] = null; - if(xGetElementById('xeEditor_'+editor_sequence)) { - xGetElementById('xeEditor_'+editor_sequence).className = 'xeEditor rich'; - xGetElementById('use_rich_'+editor_sequence).className = 'active'; - xGetElementById('preview_html_'+editor_sequence).className = ''; - if(xGetElementById('use_html_'+editor_sequence)) xGetElementById('use_html_'+editor_sequence).className = ''; - } - } + if(xGetElementById('xeEditor_'+editor_sequence)) { + xGetElementById('xeEditor_'+editor_sequence).className = 'xeEditor rich'; + xGetElementById('use_rich_'+editor_sequence).className = 'active'; + xGetElementById('preview_html_'+editor_sequence).className = ''; + if(xGetElementById('use_html_'+editor_sequence)) xGetElementById('use_html_'+editor_sequence).className = ''; + } + } } // Editor Info Close function closeEditorInfo(editor_sequence) { - xGetElementById('editorInfo_'+editor_sequence).style.display='none'; - var expire = new Date(); - expire.setTime(expire.getTime()+ (7000 * 24 * 3600000)); - xSetCookie('EditorInfo', '1', expire); + xGetElementById('editorInfo_'+editor_sequence).style.display='none'; + var expire = new Date(); + expire.setTime(expire.getTime()+ (7000 * 24 * 3600000)); + xSetCookie('EditorInfo', '1', expire); } @@ -528,39 +528,39 @@ function showEditorHelp(e,editor_sequence){ } function showEditorExtension(evt,editor_sequence){ - var oid = '#editorExtension_'+editor_sequence; - var e = new xEvent(evt); - if(jQuery(oid).hasClass('extension2')){ + var oid = '#editorExtension_'+editor_sequence; + var e = new xEvent(evt); + if(jQuery(oid).hasClass('extension2')){ jQuery(oid).addClass('open'); - if(e.pageX <= xWidth('editor_component_'+editor_sequence)){ + if(e.pageX <= xWidth('editor_component_'+editor_sequence)){ jQuery('#editor_component_'+editor_sequence).css('right','auto').css('left', 0); - }else{ + }else{ jQuery('#editor_component_'+editor_sequence).css('right', 0).css('left', 'auto'); - } - }else{ + } + }else{ jQuery(oid).attr('class', 'extension2'); - } + } } function showPreviewContent(editor_sequence) { - if(typeof(editor_sequence)=='undefined') return; - if(typeof(_editorFontColor[editor_sequence])=='undefined') return; - var preview_obj = editorGetPreviewArea(editor_sequence); - preview_obj.contentWindow.document.body.style.color = _editorFontColor[editor_sequence]; + if(typeof(editor_sequence)=='undefined') return; + if(typeof(_editorFontColor[editor_sequence])=='undefined') return; + var preview_obj = editorGetPreviewArea(editor_sequence); + preview_obj.contentWindow.document.body.style.color = _editorFontColor[editor_sequence]; } function setPreviewHeight(editor_sequence){ - var h = xGetElementById('editor_preview_'+editor_sequence).contentWindow.document.body.scrollHeight; - if(h < 400) h=400; - xHeight('editor_preview_'+editor_sequence,h+20); + var h = xGetElementById('editor_preview_'+editor_sequence).contentWindow.document.body.scrollHeight; + if(h < 400) h=400; + xHeight('editor_preview_'+editor_sequence,h+20); } function getAutoSavedSrl(ret_obj, response_tags, c) { - var editor_sequence = ret_obj['editor_sequence']; - var primary_key = ret_obj['key']; - var fo_obj = editorGetForm(editor_sequence); + var editor_sequence = ret_obj['editor_sequence']; + var primary_key = ret_obj['key']; + var fo_obj = editorGetForm(editor_sequence); - fo_obj[primary_key].value = ret_obj['document_srl']; - if(uploadSettingObj[editor_sequence]) editorUploadInit(uploadSettingObj[editor_sequence], true); + fo_obj[primary_key].value = ret_obj['document_srl']; + if(uploadSettingObj[editor_sequence]) editorUploadInit(uploadSettingObj[editor_sequence], true); } diff --git a/modules/editor/tpl/js/editor.min.js b/modules/editor/tpl/js/editor.min.js new file mode 100644 index 000000000..3f9999bfa --- /dev/null +++ b/modules/editor/tpl/js/editor.min.js @@ -0,0 +1 @@ +function editorGetTextArea(a){return jQuery("#editor_textarea_"+a)[0]}function editorGetPreviewArea(a){return jQuery("#editor_preview_"+a)[0]}function editorGetForm(a){var b=editorGetIFrame(a);if(b){for(var c=b.parentNode;"FORM"!=c.nodeName;)c=c.parentNode;return"FORM"==c.nodeName?c:void 0}}function editorGetContent_xe(a){var b="";if("html"==editorMode[a]){var c=editorGetTextArea(a);if(!c)return"";b=c.value}else{var d=editorGetIFrame(a);if(!d)return"";b=jQuery(d.contentWindow.document.body).html().replace(/^]*)>$/i,"")}return b}function editorGetSelectedNode(a){var b,c,d=editorGetIFrame(a);return b=d.contentWindow,b.document.selection?(c=b.document.selection.createRange(),jQuery("

").html(c.htmlText)[0].firstChild):(c=b.getSelection().getRangeAt(0),jQuery("
").append(c.cloneContents())[0].firstChild)}function editorStart(a,b,c,d,e){"undefined"==typeof e&&(e="#000"),_editorFontColor[a]=e;var f=editorGetIFrame(a);if(f){jQuery(f).css("width","100%").parent().css("width","100%");var g=editorGetForm(a);if(g){if(g.setAttribute("editor_sequence",a),editorRelKeys[a]=new Array,editorRelKeys[a].primary=g[b],editorRelKeys[a].content=g[c],editorRelKeys[a].func=editorGetContent_xe,"undefined"!=typeof g._saved_doc_title){var h=g._saved_doc_title.value,i=g._saved_doc_content.value;if(h||i)if(confirm(g._saved_doc_message.value)){"undefined"!=typeof g.title&&(g.title.value=h),editorRelKeys[a].content.value=i;var j=new Array;j.editor_sequence=a,j.primary_key=b,j.mid=current_mid;var k=new Array("error","message","editor_sequence","key","title","content","document_srl");exec_xml("editor","procEditorLoadSavedDocument",j,getAutoSavedSrl,k)}else editorRemoveSavedDoc()}var l=editorRelKeys[a].content.value;l||xIE4Up||(l="
");var m=xGetElementById("for_ie_help_"+a);xIE4Up&&m&&(m.style.display="block"),editor_path=editor_path.replace(/^\.\//gi,"");var n=''+l+"";f.contentWindow.document.open("text/html","replace"),f.contentWindow.document.write(n),f.contentWindow.document.close(),editorMode[a]=null;try{f.contentWindow.document.designMode="On"}catch(o){}try{f.contentWindow.document.execCommand("undo",!1,null),f.contentWindow.document.execCommand("useCSS",!1,!0)}catch(o){}try{jQuery(f.contentWindow.document).unbind("dblclick.widget").bind("dblclick.widget",editorSearchComponent)}catch(o){}try{xIE4Up?xAddEventListener(f.contentWindow.document,"keydown",editorKeyPress):xAddEventListener(f.contentWindow.document,"keypress",editorKeyPress)}catch(o){}if("undefined"!=typeof g._saved_doc_title&&editorEnableAutoSave(g,a),"html"==xGetCookie("editor_mode")){var f=editorGetIFrame(a);xGetElementById("fileUploader_"+a)&&(xGetElementById("fileUploader_"+a).style.display="block"),textarea_obj=editorGetTextArea(a),textarea_obj.value=l,xWidth(textarea_obj,xWidth(f.parentNode)),xHeight(textarea_obj,xHeight(f.parentNode)),editorMode[a]="html",xGetElementById("xeEditor_"+a)&&(xGetElementById("xeEditor_"+a).className="xeEditor html",xGetElementById("use_rich_"+a).className="",xGetElementById("preview_html_"+a).className="",xGetElementById("use_html_"+a).className="active")}}}}function editorKeyPress(a){var b=new xEvent(a),c=b.target,d=null;if(d="BODY"==c.nodeName?c:c.firstChild.nextSibling){var e=d.getAttribute("editor_sequence");if(e){if(xIE4Up&&!b.ctrlKey&&!b.shiftKey&&13==b.keyCode&&!editorMode[e]){var f=editorGetIFrame(e);if(!f)return;var g=f.contentWindow.document,c=g.selection.createRange(),h=c.parentElement().tagName.toLowerCase();switch(h){case"li":return;default:c.pasteHTML("
")}return c.select(),a.cancelBubble=!0,a.returnValue=!1,void 0}if(115==b.keyCode&&(b.altKey||b.ctrlKey)){var f=editorGetIFrame(e);if(!f)return;var i=editorGetForm(e);if(!i)return;return editorRelKeys[e].content.value=editorGetContent(e),i.onsubmit&&i.onsubmit(),a.cancelBubble=!0,a.returnValue=!1,xPreventDefault(a),xStopPropagation(a),void 0}if(b.ctrlKey){var f=editorGetIFrame(e);if(!f)return;if(editorMode[e])return a.cancelBubble=!0,a.returnValue=!1,xPreventDefault(a),xStopPropagation(a),void 0;switch(b.keyCode){case 49:case 50:case 51:case 52:case 53:case 54:editorDo("formatblock","",b.target),xPreventDefault(a),xStopPropagation(a);break;case 55:editorDo("formatblock","

",b.target),xPreventDefault(a),xStopPropagation(a);break;case 13:if(xIE4Up){if("On"!=b.target.parentElement.document.designMode)return;var c=b.target.parentElement.document.selection.createRange();return c.pasteHTML("

"),c.select(),a.cancelBubble=!0,a.returnValue=!1,void 0}case 98:editorDo("Bold",null,b.target),xPreventDefault(a),xStopPropagation(a);break;case 105:editorDo("Italic",null,b.target),xPreventDefault(a),xStopPropagation(a);break;case 117:editorDo("Underline",null,b.target),xPreventDefault(a),xStopPropagation(a);break;case 100:editorDo("RemoveFormat",null,b.target),xPreventDefault(a),xStopPropagation(a)}}}}}function editorDo(a,b,c){var d=null;if("object"==typeof c)d=xIE4Up?c.parentElement.document:c.parentNode;else{var e=editorGetIFrame(c);d=e.contentWindow.document}var f=d.body.getAttribute("editor_sequence");editorMode[f]||("object"==typeof c?c.focus():editorFocus(c),d.execCommand(a,!1,b),"object"==typeof c?c.focus():editorFocus(c))}function editorChangeFontName(a,b){var c=a.options[a.selectedIndex].value;c&&(editorDo("FontName",c,b),a.selectedIndex=0)}function editorChangeFontSize(a,b){var c=a.options[a.selectedIndex].value;c&&(editorDo("FontSize",c,b),a.selectedIndex=0)}function editorUnDo(a,b){editorDo("undo","",b),a.selectedIndex=0}function editorReDo(a,b){editorDo("redo","",b),a.selectedIndex=0}function editorChangeHeader(a,b){var c=a.options[a.selectedIndex].value;c&&(c="<"+c+">",editorDo("formatblock",c,b),a.selectedIndex=0)}function editorChangeMode(a,b){if("html"==a||""==a){var c=new Date;c.setTime(c.getTime()+6048e8),xSetCookie("editor_mode",a,c)}var d=editorGetIFrame(b);if(d){var e=editorGetTextArea(b),f=editorGetPreviewArea(b),g=d.contentWindow.document,h=null;if("html"==editorMode[b]?(h=e.value,g.body.innerHTML=e.value):"preview"==editorMode[b]?(h=e.value,f.contentWindow.document.body.innerHTML=""):(h=g.body.innerHTML,e.value=h,h=h.replace(/
/gi,"
\n"),h=h.replace(/
\n\n/gi,"
\n")),"html"==a&&e)f.style.display="none",xGetElementById("fileUploader_"+b)&&(xGetElementById("fileUploader_"+b).style.display="block"),e.value=h,xWidth(e,xWidth(d.parentNode)),xHeight(e,xHeight(d.parentNode)),editorMode[b]="html",xGetElementById("xeEditor_"+b)&&(xGetElementById("xeEditor_"+b).className="xeEditor html",xGetElementById("use_rich_"+b).className="",xGetElementById("preview_html_"+b).className="",xGetElementById("use_html_"+b).className="active");else if("preview"==a&&f){f.style.display="",xGetElementById("fileUploader_"+b)&&(xGetElementById("fileUploader_"+b).style.display="none");var i=xGetElementById("preview_form");i||(i=xCreateElement("form"),i.id="preview_form",i.method="post",i.action=request_uri,i.target="editor_preview_"+b,xInnerHtml(i,''),document.body.appendChild(i)),i.content.value=h,i.submit(),xWidth(f,xWidth(d.parentNode)),editorMode[b]="preview",xGetElementById("xeEditor_"+b)&&(xGetElementById("xeEditor_"+b).className="xeEditor preview",xGetElementById("use_rich_"+b).className="",xGetElementById("preview_html_"+b).className="active",xGetElementById("use_html_"+b)&&(xGetElementById("use_html_"+b).className=""))}else f.style.display="none",xGetElementById("fileUploader_"+b)&&(xGetElementById("fileUploader_"+b).style.display="block"),g.body.innerHTML=h,editorMode[b]=null,xGetElementById("xeEditor_"+b)&&(xGetElementById("xeEditor_"+b).className="xeEditor rich",xGetElementById("use_rich_"+b).className="active",xGetElementById("preview_html_"+b).className="",xGetElementById("use_html_"+b)&&(xGetElementById("use_html_"+b).className=""))}}function closeEditorInfo(a){xGetElementById("editorInfo_"+a).style.display="none";var b=new Date;b.setTime(b.getTime()+6048e8),xSetCookie("EditorInfo","1",b)}function showEditorHelp(a,b){jQuery("#helpList_"+b).toggleClass("open")}function showEditorExtension(a,b){var c="#editorExtension_"+b,d=new xEvent(a);jQuery(c).hasClass("extension2")?(jQuery(c).addClass("open"),d.pageX<=xWidth("editor_component_"+b)?jQuery("#editor_component_"+b).css("right","auto").css("left",0):jQuery("#editor_component_"+b).css("right",0).css("left","auto")):jQuery(c).attr("class","extension2")}function showPreviewContent(a){if("undefined"!=typeof a&&"undefined"!=typeof _editorFontColor[a]){var b=editorGetPreviewArea(a);b.contentWindow.document.body.style.color=_editorFontColor[a]}}function setPreviewHeight(a){var b=xGetElementById("editor_preview_"+a).contentWindow.document.body.scrollHeight;400>b&&(b=400),xHeight("editor_preview_"+a,b+20)}function getAutoSavedSrl(a){var b=a.editor_sequence,c=a.key,d=editorGetForm(b);d[c].value=a.document_srl,uploadSettingObj[b]&&editorUploadInit(uploadSettingObj[b],!0)}var _editorFontColor=new Array; \ No newline at end of file diff --git a/modules/editor/tpl/js/editor_admin.js b/modules/editor/tpl/js/editor_admin.js index a3e5fd349..c66d495a7 100644 --- a/modules/editor/tpl/js/editor_admin.js +++ b/modules/editor/tpl/js/editor_admin.js @@ -1,17 +1,17 @@ /** * @author NAVER (developers@xpressengine.com) * @version 0.1 - * @brief 에디터 관리자 페이지용 스크립트 - **/ - + * @brief 에디터 관리자 페이지용 스크립트 + **/ + function doSetupComponent(component_name) { - popopen(request_uri.setQuery('module','editor').setQuery('act','dispEditorAdminSetupComponent').setQuery('component_name',component_name), 'SetupComponent'); + popopen(request_uri.setQuery('module','editor').setQuery('act','dispEditorAdminSetupComponent').setQuery('component_name',component_name), 'SetupComponent'); } function toggleSectionCheckBox(obj, id) { - var box_list = xGetElementsByTagName('input', xGetElementById(id)); - if(typeof(box_list.length)=='undefined') return; - for(var i in box_list) { - box_list[i].checked = obj.checked; - } + var box_list = xGetElementsByTagName('input', xGetElementById(id)); + if(typeof(box_list.length)=='undefined') return; + for(var i in box_list) { + box_list[i].checked = obj.checked; + } } diff --git a/modules/editor/tpl/js/editor_common.js b/modules/editor/tpl/js/editor_common.js index 5d79974a0..f78d677e7 100644 --- a/modules/editor/tpl/js/editor_common.js +++ b/modules/editor/tpl/js/editor_common.js @@ -7,12 +7,12 @@ var editorRelKeys = new Array(); ///< 에디터와 각 모듈과의 연동을 var editorDragObj = {isDrag:false, y:0, obj:null, id:'', det:0, source_height:0} function editorGetContent(editor_sequence) { - // 입력된 내용을 받아옴 - var content = editorRelKeys[editor_sequence]["func"](editor_sequence); + // 입력된 내용을 받아옴 + var content = editorRelKeys[editor_sequence]["func"](editor_sequence); - // 첨부파일 링크시 url을 변경 - var reg_pattern = new RegExp( request_uri.replace(/\//g,'\\/')+"(files|common|modules|layouts|widgets)", 'ig' ); - return content.replace(reg_pattern, "$1"); + // 첨부파일 링크시 url을 변경 + var reg_pattern = new RegExp( request_uri.replace(/\//g,'\\/')+"(files|common|modules|layouts|widgets)", 'ig' ); + return content.replace(reg_pattern, "$1"); } // 에디터에 포커스를 줌 @@ -32,83 +32,83 @@ function editorFocus(editor_sequence) { **/ // 자동 저장 활성화 시키는 함수 (50초마다 자동저장) function editorEnableAutoSave(fo_obj, editor_sequence, callback) { - var title = fo_obj.title.value; - var content = editorRelKeys[editor_sequence]['content'].value; + var title = fo_obj.title.value; + var content = editorRelKeys[editor_sequence]['content'].value; - editorAutoSaveObj = {"fo_obj":fo_obj, "editor_sequence":editor_sequence, "title":title, "content":content, locked:false}; + editorAutoSaveObj = {"fo_obj":fo_obj, "editor_sequence":editor_sequence, "title":title, "content":content, locked:false}; clearTimeout(editorEnableAutoSave.timer); - editorEnableAutoSave.timer = setTimeout(function(){_editorAutoSave(false, callback)}, 50000); + editorEnableAutoSave.timer = setTimeout(function(){_editorAutoSave(false, callback)}, 50000); } editorEnableAutoSave.timer = null; // ajax를 이용하여 editor.procEditorSaveDoc 호출하여 자동 저장시킴 exe는 강제 코드 function _editorAutoSave(exe, callback) { - var fo_obj = editorAutoSaveObj.fo_obj; - var editor_sequence = editorAutoSaveObj.editor_sequence; + var fo_obj = editorAutoSaveObj.fo_obj; + var editor_sequence = editorAutoSaveObj.editor_sequence; - // 50초마다 동기화를 시킴 강제 실행은 제외 - if(!exe) { + // 50초마다 동기화를 시킴 강제 실행은 제외 + if(!exe) { clearTimeout(editorEnableAutoSave.timer); editorEnableAutoSave.timer = setTimeout(function(){ _editorAutoSave(exe, callback) }, 50000); } - // 현재 자동저장중이면 중지 - if(editorAutoSaveObj.locked == true) return; + // 현재 자동저장중이면 중지 + if(editorAutoSaveObj.locked == true) return; - // 대상이 없으면 자동저장 시키는 기능 자체를 중지 - if(!fo_obj || typeof(fo_obj.title)=='undefined' || !editor_sequence) return; + // 대상이 없으면 자동저장 시키는 기능 자체를 중지 + if(!fo_obj || typeof(fo_obj.title)=='undefined' || !editor_sequence) return; - // 자동저장을 위한 준비 - var title = fo_obj.title.value; + // 자동저장을 위한 준비 + var title = fo_obj.title.value; var content = ''; try{ content = editorGetContent(editor_sequence); }catch(e){ } - // 내용이 이전에 저장하였던 것과 다르면 자동 저장을 함 또는 강제 저장 설정시 자동 저장 - if(title != editorAutoSaveObj.title || content != editorAutoSaveObj.content || exe) { - var params, oDate = new Date(); + // 내용이 이전에 저장하였던 것과 다르면 자동 저장을 함 또는 강제 저장 설정시 자동 저장 + if(title != editorAutoSaveObj.title || content != editorAutoSaveObj.content || exe) { + var params, oDate = new Date(); - params = { + params = { title : title, content : content, mid : current_mid, document_srl : editorRelKeys[editor_sequence]['primary'].value }; - editorAutoSaveObj.title = title; - editorAutoSaveObj.content = content; + editorAutoSaveObj.title = title; + editorAutoSaveObj.content = content; - // 메시지 만들어서 보여줌 - jQuery("#editor_autosaved_message_"+editor_sequence).text(oDate.getHours()+':'+oDate.getMinutes()+' '+auto_saved_msg).show(300); + // 메시지 만들어서 보여줌 + jQuery("#editor_autosaved_message_"+editor_sequence).text(oDate.getHours()+':'+oDate.getMinutes()+' '+auto_saved_msg).show(300); - // 현재 자동저장중임을 설정 - editorAutoSaveObj.locked = true; + // 현재 자동저장중임을 설정 + editorAutoSaveObj.locked = true; - // 서버 호출 (서버와 교신중이라는 메세지를 보이지 않도록 함) - show_waiting_message = false; - exec_xml( + // 서버 호출 (서버와 교신중이라는 메세지를 보이지 않도록 함) + show_waiting_message = false; + exec_xml( "editor", "procEditorSaveDoc", params, function() { var arg = jQuery.extend({}, params, {auto_saved_msg:auto_saved_msg}); - + editorAutoSaveObj.locked = false; if(jQuery.isFunction(callback)) callback(arg); } ); - show_waiting_message = true; - } + show_waiting_message = true; + } } // 자동저장된 모든 메세지를 삭제하는 루틴 function editorRemoveSavedDoc() { - var param = new Array(); - param['mid'] = current_mid; - exec_xml("editor","procEditorRemoveSavedDoc", param); + var param = new Array(); + param['mid'] = current_mid; + exec_xml("editor","procEditorRemoveSavedDoc", param); } /** @@ -117,26 +117,26 @@ function editorRemoveSavedDoc() { // editor_sequence값에 해당하는 iframe의 object를 return function editorGetIFrame(editor_sequence) { - if(editorRelKeys != undefined && editorRelKeys[editor_sequence] != undefined && editorRelKeys[editor_sequence]['editor'] != undefined) + if(editorRelKeys != undefined && editorRelKeys[editor_sequence] != undefined && editorRelKeys[editor_sequence]['editor'] != undefined) return editorRelKeys[editor_sequence]['editor'].getFrame(editor_sequence); - return document.getElementById( 'editor_iframe_'+ editor_sequence ); + return document.getElementById( 'editor_iframe_'+ editor_sequence ); } function editorGetTextarea(editor_sequence) { - return document.getElementById( 'editor_textarea_'+ editor_sequence ); + return document.getElementById( 'editor_textarea_'+ editor_sequence ); } // Editor Option Button function eOptionOver(obj) { - obj.style.marginTop='-21px'; - obj.style.zIndex='99'; + obj.style.marginTop='-21px'; + obj.style.zIndex='99'; } function eOptionOut(obj) { - obj.style.marginTop='0'; - obj.style.zIndex='1'; + obj.style.marginTop='0'; + obj.style.zIndex='1'; } function eOptionClick(obj) { - obj.style.marginTop='-42px'; - obj.style.zIndex='99'; + obj.style.marginTop='-42px'; + obj.style.zIndex='99'; } /** @@ -146,201 +146,201 @@ function eOptionClick(obj) { // 에디터 상단의 컴포넌트 버튼 클릭시 action 처리 (마우스다운 이벤트 발생시마다 요청이 됨) var editorPrevSrl = null; function editorEventCheck(e) { - editorPrevNode = null; + editorPrevNode = null; - // 이벤트가 발생한 object의 ID를 구함 - var target_id = e.target.id; - if(!target_id) return; + // 이벤트가 발생한 object의 ID를 구함 + var target_id = e.target.id; + if(!target_id) return; - // editor_sequence와 component name을 구함 (id가 포맷과 다르면 return) - var info = target_id.split('_'); - if(info[0]!="component") return; - var editor_sequence = info[1]; - var component_name = target_id.replace(/^component_[0-9]+_/,''); + // editor_sequence와 component name을 구함 (id가 포맷과 다르면 return) + var info = target_id.split('_'); + if(info[0]!="component") return; + var editor_sequence = info[1]; + var component_name = target_id.replace(/^component_[0-9]+_/,''); - if(!editor_sequence || !component_name) return; - if(editorMode[editor_sequence]=='html') return; + if(!editor_sequence || !component_name) return; + if(editorMode[editor_sequence]=='html') return; - switch(component_name) { + switch(component_name) { - // 기본 기능에 대한 동작 (바로 실행) - case 'Bold' : - case 'Italic' : - case 'Underline' : - case 'StrikeThrough' : - case 'undo' : - case 'redo' : - case 'JustifyLeft' : - case 'JustifyCenter' : - case 'JustifyRight' : - case 'JustifyFull' : - case 'Indent' : - case 'Outdent' : - case 'InsertOrderedList' : - case 'InsertUnorderedList' : - case 'SaveAs' : - case 'Print' : - case 'Copy' : - case 'Cut' : - case 'Paste' : - case 'RemoveFormat' : - case 'Subscript' : - case 'Superscript' : - editorDo(component_name, '', editor_sequence); - break; + // 기본 기능에 대한 동작 (바로 실행) + case 'Bold' : + case 'Italic' : + case 'Underline' : + case 'StrikeThrough' : + case 'undo' : + case 'redo' : + case 'JustifyLeft' : + case 'JustifyCenter' : + case 'JustifyRight' : + case 'JustifyFull' : + case 'Indent' : + case 'Outdent' : + case 'InsertOrderedList' : + case 'InsertUnorderedList' : + case 'SaveAs' : + case 'Print' : + case 'Copy' : + case 'Cut' : + case 'Paste' : + case 'RemoveFormat' : + case 'Subscript' : + case 'Superscript' : + editorDo(component_name, '', editor_sequence); + break; - // 추가 컴포넌트의 경우 서버에 요청을 시도 - default : + // 추가 컴포넌트의 경우 서버에 요청을 시도 + default : openComponent(component_name, editor_sequence); return false; - } + } - return; + return; } jQuery(document).click(editorEventCheck); // 컴포넌트 팝업 열기 function openComponent(component_name, editor_sequence, manual_url) { - editorPrevSrl = editor_sequence; - if(editorMode[editor_sequence]=='html') return; + editorPrevSrl = editor_sequence; + if(editorMode[editor_sequence]=='html') return; - var popup_url = request_uri+"?module=editor&act=dispEditorPopup&editor_sequence="+editor_sequence+"&component="+component_name; - if(typeof(manual_url)!="undefined" && manual_url) popup_url += "&manual_url="+escape(manual_url); + var popup_url = request_uri+"?module=editor&act=dispEditorPopup&editor_sequence="+editor_sequence+"&component="+component_name; + if(typeof(manual_url)!="undefined" && manual_url) popup_url += "&manual_url="+escape(manual_url); - popopen(popup_url, 'editorComponent'); + popopen(popup_url, 'editorComponent'); } // 더블클릭 이벤트 발생시에 본문내에 포함된 컴포넌트를 찾는 함수 var editorPrevNode = null; function editorSearchComponent(evt) { - var e = new xEvent(evt); + var e = new xEvent(evt); - editorPrevNode = null; - var obj = e.target; + editorPrevNode = null; + var obj = e.target; - // 위젯인지 일단 체크 - if(obj.getAttribute("widget")) { - // editor_sequence을 찾음 - var tobj = obj; - while(tobj && tobj.nodeName != "BODY") { - tobj = xParent(tobj); - } - if(!tobj || tobj.nodeName != "BODY" || !tobj.getAttribute("editor_sequence")) { - editorPrevNode = null; - return; - } - var editor_sequence = tobj.getAttribute("editor_sequence"); - var widget = obj.getAttribute("widget"); - editorPrevNode = obj; + // 위젯인지 일단 체크 + if(obj.getAttribute("widget")) { + // editor_sequence을 찾음 + var tobj = obj; + while(tobj && tobj.nodeName != "BODY") { + tobj = xParent(tobj); + } + if(!tobj || tobj.nodeName != "BODY" || !tobj.getAttribute("editor_sequence")) { + editorPrevNode = null; + return; + } + var editor_sequence = tobj.getAttribute("editor_sequence"); + var widget = obj.getAttribute("widget"); + editorPrevNode = obj; - if(editorMode[editor_sequence]=='html') return; - popopen(request_uri+"?module=widget&act=dispWidgetGenerateCodeInPage&selected_widget="+widget+"&module_srl="+editor_sequence,'GenerateCodeInPage'); - return; - } + if(editorMode[editor_sequence]=='html') return; + popopen(request_uri+"?module=widget&act=dispWidgetGenerateCodeInPage&selected_widget="+widget+"&module_srl="+editor_sequence,'GenerateCodeInPage'); + return; + } - // 선택되어진 object부터 상단으로 이동하면서 editor_component attribute가 있는지 검사 - if(!obj.getAttribute("editor_component")) { - while(obj && !obj.getAttribute("editor_component")) { - if(obj.parentElement) obj = obj.parentElement; - else obj = xParent(obj); - } - } + // 선택되어진 object부터 상단으로 이동하면서 editor_component attribute가 있는지 검사 + if(!obj.getAttribute("editor_component")) { + while(obj && !obj.getAttribute("editor_component")) { + if(obj.parentElement) obj = obj.parentElement; + else obj = xParent(obj); + } + } - if(!obj) obj = e.target; + if(!obj) obj = e.target; - var editor_component = obj.getAttribute("editor_component"); + var editor_component = obj.getAttribute("editor_component"); - // editor_component를 찾지 못했을 경우에 이미지/텍스트/링크의 경우 기본 컴포넌트와 연결 - if(!editor_component) { - // 이미지일 경우 - if(obj.nodeName == "IMG" && !obj.getAttribute("widget")) { - editor_component = "image_link"; - editorPrevNode = obj; - } - } else { - editorPrevNode = obj; - } + // editor_component를 찾지 못했을 경우에 이미지/텍스트/링크의 경우 기본 컴포넌트와 연결 + if(!editor_component) { + // 이미지일 경우 + if(obj.nodeName == "IMG" && !obj.getAttribute("widget")) { + editor_component = "image_link"; + editorPrevNode = obj; + } + } else { + editorPrevNode = obj; + } - // 아무런 editor_component가 없다면 return - if(!editor_component) { - editorPrevNode = null; - return; - } + // 아무런 editor_component가 없다면 return + if(!editor_component) { + editorPrevNode = null; + return; + } - // editor_sequence을 찾음 - var tobj = obj; - while(tobj && tobj.nodeName != "BODY") { - tobj = xParent(tobj); - } - if(!tobj || tobj.nodeName != "BODY" || !tobj.getAttribute("editor_sequence")) { - editorPrevNode = null; - return; - } - var editor_sequence = tobj.getAttribute("editor_sequence"); + // editor_sequence을 찾음 + var tobj = obj; + while(tobj && tobj.nodeName != "BODY") { + tobj = xParent(tobj); + } + if(!tobj || tobj.nodeName != "BODY" || !tobj.getAttribute("editor_sequence")) { + editorPrevNode = null; + return; + } + var editor_sequence = tobj.getAttribute("editor_sequence"); - // 해당 컴포넌트를 찾아서 실행 - openComponent(editor_component, editor_sequence); + // 해당 컴포넌트를 찾아서 실행 + openComponent(editor_component, editor_sequence); } // 에디터 내의 선택된 부분의 html코드를 변경 function editorReplaceHTML(iframe_obj, html) { - // 이미지 경로 재지정 (rewrite mod) - var srcPathRegx = /src=("|\'){1}(\.\/)?(files\/attach|files\/cache|files\/faceOff|files\/member_extra_info|modules|common|widgets|widgetstyle|layouts|addons)\/([^"\']+)\.(jpg|jpeg|png|gif)("|\'){1}/g; - html = html.replace(srcPathRegx, 'src="'+request_uri+'$3/$4.$5"'); + // 이미지 경로 재지정 (rewrite mod) + var srcPathRegx = /src=("|\'){1}(\.\/)?(files\/attach|files\/cache|files\/faceOff|files\/member_extra_info|modules|common|widgets|widgetstyle|layouts|addons)\/([^"\']+)\.(jpg|jpeg|png|gif)("|\'){1}/g; + html = html.replace(srcPathRegx, 'src="'+request_uri+'$3/$4.$5"'); - // href 경로 재지정 (rewrite mod) - var hrefPathRegx = /href=("|\'){1}(\.\/)?\?([^"\']+)("|\'){1}/g; - html = html.replace(hrefPathRegx, 'href="'+request_uri+'?$3"'); + // href 경로 재지정 (rewrite mod) + var hrefPathRegx = /href=("|\'){1}(\.\/)?\?([^"\']+)("|\'){1}/g; + html = html.replace(hrefPathRegx, 'href="'+request_uri+'?$3"'); - // 에디터가 활성화 되어 있는지 확인 후 비활성화시 활성화 - var editor_sequence = iframe_obj.editor_sequence || iframe_obj.contentWindow.document.body.getAttribute("editor_sequence"); + // 에디터가 활성화 되어 있는지 확인 후 비활성화시 활성화 + var editor_sequence = iframe_obj.editor_sequence || iframe_obj.contentWindow.document.body.getAttribute("editor_sequence"); - // iframe 에디터에 포커스를 둠 + // iframe 에디터에 포커스를 둠 try { iframe_obj.contentWindow.focus(); }catch(e){}; - + if (jQuery.isFunction(iframe_obj.replaceHTML)) { iframe_obj.replaceHTML(html); } else if(xIE4Up) { - var range = iframe_obj.contentWindow.document.selection.createRange(); - if(range.pasteHTML) { - range.pasteHTML(html); - } else if(editorPrevNode) { - editorPrevNode.outerHTML = html; - } - } else { - try { - if(iframe_obj.contentWindow.getSelection().focusNode.tagName == "HTML") { - var range = iframe_obj.contentDocument.createRange(); - range.setStart(iframe_obj.contentDocument.body,0); - range.setEnd(iframe_obj.contentDocument.body,0); - range.insertNode(range.createContextualFragment(html)); - } else { - var range = iframe_obj.contentWindow.getSelection().getRangeAt(0); - range.deleteContents(); - range.insertNode(range.createContextualFragment(html)); - } - } catch(e) { - xInnerHtml(iframe_obj.contentWindow.document.body, html+xInnerHtml(iframe_obj.contentWindow.document.body)); - } - } + var range = iframe_obj.contentWindow.document.selection.createRange(); + if(range.pasteHTML) { + range.pasteHTML(html); + } else if(editorPrevNode) { + editorPrevNode.outerHTML = html; + } + } else { + try { + if(iframe_obj.contentWindow.getSelection().focusNode.tagName == "HTML") { + var range = iframe_obj.contentDocument.createRange(); + range.setStart(iframe_obj.contentDocument.body,0); + range.setEnd(iframe_obj.contentDocument.body,0); + range.insertNode(range.createContextualFragment(html)); + } else { + var range = iframe_obj.contentWindow.getSelection().getRangeAt(0); + range.deleteContents(); + range.insertNode(range.createContextualFragment(html)); + } + } catch(e) { + xInnerHtml(iframe_obj.contentWindow.document.body, html+xInnerHtml(iframe_obj.contentWindow.document.body)); + } + } } // 에디터 내의 선택된 부분의 html 코드를 return function editorGetSelectedHtml(editor_sequence) { - var iframe_obj = editorGetIFrame(editor_sequence); + var iframe_obj = editorGetIFrame(editor_sequence); if (jQuery.isFunction(iframe_obj.getSelectedHTML)) { return iframe_obj.getSelectedHTML(); - } else if(xIE4Up) { - var range = iframe_obj.contentWindow.document.selection.createRange(); - var html = range.htmlText; - return html; - } else { - var range = iframe_obj.contentWindow.getSelection().getRangeAt(0); - var dummy = xCreateElement('div'); - dummy.appendChild(range.cloneContents()); - var html = xInnerHtml(dummy); - return html; - } + } else if(xIE4Up) { + var range = iframe_obj.contentWindow.document.selection.createRange(); + var html = range.htmlText; + return html; + } else { + var range = iframe_obj.contentWindow.getSelection().getRangeAt(0); + var dummy = xCreateElement('div'); + dummy.appendChild(range.cloneContents()); + var html = xInnerHtml(dummy); + return html; + } } @@ -355,19 +355,19 @@ var eventObj = null; // event target object var targetObj = null; // elements to be resized function editorDragStart(e) { - var obj = $(e.target); + var obj = $(e.target); var id = obj.attr('id'); - if(!id || !/^editor_drag_bar_(.+)$/.test(id)) return; + if(!id || !/^editor_drag_bar_(.+)$/.test(id)) return; - dragging = true; - startY = e.pageY; - eventObj = obj; + dragging = true; + startY = e.pageY; + eventObj = obj; editorId = RegExp.$1; - var iframe_obj = $( editorGetIFrame(editorId) ); - var textarea_obj = $( editorGetTextarea(editorId) ); - var preview_obj = $('#editor_preview_'+editorId); + var iframe_obj = $( editorGetIFrame(editorId) ); + var textarea_obj = $( editorGetTextarea(editorId) ); + var preview_obj = $('#editor_preview_'+editorId); var visible_obj = iframe_obj.is(':visible')?iframe_obj:textarea_obj; startH = parseInt(visible_obj.css('height')); @@ -391,12 +391,12 @@ function editorDragStart(e) { } function editorDragMove(e) { - if(!dragging) { - $('#xeEditorMask_' + editorId).hide(); - return; - } + if(!dragging) { + $('#xeEditorMask_' + editorId).hide(); + return; + } - var diff = e.pageY - startY; + var diff = e.pageY - startY; targetObj.css('height', (startH + diff)+'px'); return false; @@ -404,7 +404,7 @@ function editorDragMove(e) { function editorDragStop(e) { $('#xeEditorMask_' + editorId).hide(); - if(!dragging) return; + if(!dragging) return; $(document).unbind('mousemove', editorDragMove); @@ -414,9 +414,9 @@ function editorDragStop(e) { fixAdminLayoutFooter( diff ); } - dragging = false; - startY = 0; - eventObj = null; + dragging = false; + startY = 0; + eventObj = null; targetObj = null; editorId = ''; diff --git a/modules/editor/tpl/js/editor_module_config.js b/modules/editor/tpl/js/editor_module_config.js index 343887d6c..b02689d27 100644 --- a/modules/editor/tpl/js/editor_module_config.js +++ b/modules/editor/tpl/js/editor_module_config.js @@ -1,13 +1,13 @@ function getEditorSkinColorList(skin_name,selected_colorset,type,testid){ - if(skin_name.length>0){ - type = type || 'document'; - var response_tags = new Array('error','message','colorset'); - exec_xml('editor','dispEditorSkinColorset',{skin:skin_name},resultGetEditorSkinColorList,response_tags,{'selected_colorset':selected_colorset,'type':type,'testid':testid}); - } + if(skin_name.length>0){ + type = type || 'document'; + var response_tags = new Array('error','message','colorset'); + exec_xml('editor','dispEditorSkinColorset',{skin:skin_name},resultGetEditorSkinColorList,response_tags,{'selected_colorset':selected_colorset,'type':type,'testid':testid}); + } } function resultGetEditorSkinColorList(ret_obj,response_tags, params) { - var selectbox = null; + var selectbox = null; jQuery(function($){ if(params.testid){ selectbox = $("#"+params.testid).next('label').children('select'); @@ -19,21 +19,21 @@ function resultGetEditorSkinColorList(ret_obj,response_tags, params) { if(params.type == 'document'){ $("select[name=sel_editor_colorset]").hide() .removeAttr('name'); - selectbox.attr('name','sel_editor_colorset'); + selectbox.attr('name','sel_editor_colorset'); }else{ $("select[name=sel_comment_editor_colorset]").hide() - .removeAttr('name'); - selectbox.attr('name','sel_comment_editor_colorset'); - } + .removeAttr('name'); + selectbox.attr('name','sel_comment_editor_colorset'); + } - if(ret_obj['error'] == 0 && ret_obj.colorset){ + if(ret_obj['error'] == 0 && ret_obj.colorset){ var it = new Array(); - var items = ret_obj['colorset']['item']; + var items = ret_obj['colorset']['item']; if(typeof(items[0]) == 'undefined'){ it[0] = items; }else{ it = items; - } + } var selectAttr = ""; for(var i=0;i'+it[i].title+''); @@ -42,7 +42,7 @@ function resultGetEditorSkinColorList(ret_obj,response_tags, params) { $options.attr('selected', 'selected'); } - selectbox.append($options); + selectbox.append($options); } selectbox.show(); }else{ diff --git a/modules/editor/tpl/js/swfupload.js b/modules/editor/tpl/js/swfupload.js index e65b19cb2..15e15fd66 100644 --- a/modules/editor/tpl/js/swfupload.js +++ b/modules/editor/tpl/js/swfupload.js @@ -97,18 +97,18 @@ SWFUpload.completeURL = function(url) { if (typeof(url) !== "string" || url.match(/^https?:\/\//i) || url.match(/^\//)) { return url; } - + var currentURL = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : ""); - + var indexSlash = window.location.pathname.lastIndexOf("/"); if (indexSlash <= 0) { path = "/"; } else { path = window.location.pathname.substr(0, indexSlash) + "/"; } - + return /*currentURL +*/ path + url; - + }; @@ -122,7 +122,7 @@ SWFUpload.prototype.initSettings = function () { this.ensureDefault = function (settingName, defaultValue) { this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName]; }; - + // Upload backend settings this.ensureDefault("upload_url", ""); this.ensureDefault("preserve_relative_urls", false); @@ -132,7 +132,7 @@ SWFUpload.prototype.initSettings = function () { this.ensureDefault("requeue_on_error", false); this.ensureDefault("http_success", []); this.ensureDefault("assume_success_timeout", 0); - + // File Settings this.ensureDefault("file_types", "*.*"); this.ensureDefault("file_types_description", "All Files"); @@ -143,7 +143,7 @@ SWFUpload.prototype.initSettings = function () { // Flash Settings this.ensureDefault("flash_url", "swfupload.swf"); this.ensureDefault("prevent_swf_caching", true); - + // Button Settings this.ensureDefault("button_image_url", ""); this.ensureDefault("button_width", 1); @@ -158,11 +158,11 @@ SWFUpload.prototype.initSettings = function () { this.ensureDefault("button_placeholder", null); this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW); this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW); - + // Debug Settings this.ensureDefault("debug", false); this.settings.debug_enabled = this.settings.debug; // Here to maintain v2 API - + // Event Handlers this.settings.return_upload_start_handler = this.returnUploadStart; this.ensureDefault("swfupload_loaded_handler", null); @@ -170,31 +170,31 @@ SWFUpload.prototype.initSettings = function () { this.ensureDefault("file_queued_handler", null); this.ensureDefault("file_queue_error_handler", null); this.ensureDefault("file_dialog_complete_handler", null); - + this.ensureDefault("upload_start_handler", null); this.ensureDefault("upload_progress_handler", null); this.ensureDefault("upload_error_handler", null); this.ensureDefault("upload_success_handler", null); this.ensureDefault("upload_complete_handler", null); - + this.ensureDefault("debug_handler", this.debugMessage); this.ensureDefault("custom_settings", {}); // Other settings this.customSettings = this.settings.custom_settings; - + // Update the flash url if needed if (!!this.settings.prevent_swf_caching) { this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime(); } - + if (!this.settings.preserve_relative_urls) { //this.settings.flash_url = SWFUpload.completeURL(this.settings.flash_url); // Don't need to do this one since flash doesn't look at it this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url); this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url); } - + delete this.ensureDefault; }; @@ -223,7 +223,7 @@ SWFUpload.prototype.loadFlash = function () { if (window[this.movieName] == undefined) { window[this.movieName] = this.getMovieElement(); } - + }; // Private: getFlashHTML generates the object tag needed to embed the flash in to the document @@ -245,7 +245,7 @@ SWFUpload.prototype.getFlashVars = function () { // Build a string from the post param object var paramString = this.buildParamString(); var httpSuccessString = this.settings.http_success.join(","); - + // Build the parameter string return ["movieName=", encodeURIComponent(this.movieName), "&uploadURL=", encodeURIComponent(this.settings.upload_url), @@ -284,14 +284,14 @@ SWFUpload.prototype.getMovieElement = function () { if (this.movieElement === null) { throw "Could not find Flash element"; } - + return this.movieElement; }; // Private: buildParamString takes the name/value pairs in the post_params setting object // and joins them up in to a string formatted "name=value&name=value" SWFUpload.prototype.buildParamString = function () { - var postParams = this.settings.post_params; + var postParams = this.settings.post_params; var paramStringPairs = []; if (typeof(postParams) === "object") { @@ -313,12 +313,12 @@ SWFUpload.prototype.destroy = function () { try { // Make sure Flash is done before we try to remove it this.cancelUpload(null, false); - + // Remove the SWFUpload DOM nodes var movieElement = null; movieElement = this.getMovieElement(); - + if (movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE // Loop through all the movie's properties and remove all function references (DOM/JS IE 6/7 memory leak workaround) for (var i in movieElement) { @@ -334,7 +334,7 @@ SWFUpload.prototype.destroy = function () { movieElement.parentNode.removeChild(movieElement); } catch (ex) {} } - + // Remove IE form fix reference window[this.movieName] = null; @@ -347,8 +347,8 @@ SWFUpload.prototype.destroy = function () { this.customSettings = null; this.eventQueue = null; this.movieName = null; - - + + return true; } catch (ex2) { return false; @@ -417,20 +417,20 @@ SWFUpload.prototype.displayDebugInfo = function () { */ // Public: (Deprecated) addSetting adds a setting value. If the value given is undefined or null then the default_value is used. SWFUpload.prototype.addSetting = function (name, value, default_value) { - if (value == undefined) { - return (this.settings[name] = default_value); - } else { - return (this.settings[name] = value); + if (value == undefined) { + return (this.settings[name] = default_value); + } else { + return (this.settings[name] = value); } }; // Public: (Deprecated) getSetting gets a setting. Returns an empty string if the setting was not found. SWFUpload.prototype.getSetting = function (name) { - if (this.settings[name] != undefined) { - return this.settings[name]; + if (this.settings[name] != undefined) { + return this.settings[name]; } - return ""; + return ""; }; @@ -440,7 +440,7 @@ SWFUpload.prototype.getSetting = function (name) { // bugs in the ExternalInterface library. SWFUpload.prototype.callFlash = function (functionName, argumentArray) { argumentArray = argumentArray || []; - + var movieElement = this.getMovieElement(); var returnValue, returnString; @@ -451,7 +451,7 @@ SWFUpload.prototype.callFlash = function (functionName, argumentArray) { } catch (ex) { throw "Call to " + functionName + " failed"; } - + // Unescape file post param values if (returnValue != undefined && typeof returnValue.post === "object") { returnValue = this.unescapeFilePostParams(returnValue); @@ -485,7 +485,7 @@ SWFUpload.prototype.selectFiles = function () { // Public: startUpload starts uploading the first file in the queue unless -// the optional parameter 'fileID' specifies the ID +// the optional parameter 'fileID' specifies the ID SWFUpload.prototype.startUpload = function (fileID) { this.callFlash("StartUpload", [fileID]); }; @@ -519,7 +519,7 @@ SWFUpload.prototype.getStats = function () { return this.callFlash("GetStats"); }; -// Public: setStats changes the SWFUpload statistics. You shouldn't need to +// Public: setStats changes the SWFUpload statistics. You shouldn't need to // change the statistics but you can. Changing the statistics does not // affect SWFUpload accept for the successful_uploads count which is used // by the upload_limit setting to determine how many files the user may upload. @@ -622,7 +622,7 @@ SWFUpload.prototype.setHTTPSuccess = function (http_status_codes) { if (typeof http_status_codes === "string") { http_status_codes = http_status_codes.replace(" ", "").split(","); } - + this.settings.http_success = http_status_codes; this.callFlash("SetHTTPSuccess", [http_status_codes]); }; @@ -644,7 +644,7 @@ SWFUpload.prototype.setButtonImageURL = function (buttonImageURL) { if (buttonImageURL == undefined) { buttonImageURL = ""; } - + this.settings.button_image_url = buttonImageURL; this.callFlash("SetButtonImageURL", [buttonImageURL]); }; @@ -653,13 +653,13 @@ SWFUpload.prototype.setButtonImageURL = function (buttonImageURL) { SWFUpload.prototype.setButtonDimensions = function (width, height) { this.settings.button_width = width; this.settings.button_height = height; - + var movie = this.getMovieElement(); if (movie != undefined) { movie.style.width = width + "px"; movie.style.height = height + "px"; } - + this.callFlash("SetButtonDimensions", [width, height]); }; // Public: setButtonText Changes the text overlaid on the button @@ -700,9 +700,9 @@ SWFUpload.prototype.setButtonCursor = function (cursor) { Flash Event Interfaces These functions are used by Flash to trigger the various events. - + All these functions a Private. - + Because the ExternalInterface library is buggy the event calls are added to a queue and the queue then executed by a setTimeout. This ensures that events are executed in a determinate order and that @@ -711,25 +711,25 @@ SWFUpload.prototype.setButtonCursor = function (cursor) { SWFUpload.prototype.queueEvent = function (handlerName, argumentArray) { // Warning: Don't call this.debug inside here or you'll create an infinite loop - + if (argumentArray == undefined) { argumentArray = []; } else if (!(argumentArray instanceof Array)) { argumentArray = [argumentArray]; } - + var self = this; if (typeof this.settings[handlerName] === "function") { // Queue the event this.eventQueue.push(function () { this.settings[handlerName].apply(this, argumentArray); }); - + // Execute the next queued event setTimeout(function () { self.executeNextEvent(); }, 0); - + } else if (this.settings[handlerName] !== null) { throw "Event handler " + handlerName + " is unknown or is not a function"; } @@ -793,7 +793,7 @@ SWFUpload.prototype.flashReady = function () { } this.cleanUp(movieElement); - + this.queueEvent("swfupload_loaded_handler"); }; @@ -814,7 +814,7 @@ SWFUpload.prototype.cleanUp = function (movieElement) { } } } catch (ex1) { - + } // Fix Flashes own cleanup code so if the SWFMovie was removed from the page @@ -825,7 +825,7 @@ SWFUpload.prototype.cleanUp = function (movieElement) { instance[name] = null; } } catch (flashEx) { - + } }; @@ -876,9 +876,9 @@ SWFUpload.prototype.returnUploadStart = function (file) { if (returnValue === undefined) { returnValue = true; } - + returnValue = !!returnValue; - + this.callFlash("ReturnUploadStart", [returnValue]); }; @@ -918,12 +918,12 @@ SWFUpload.prototype.debug = function (message) { itself to the body if necessary. The console is automatically scrolled as messages appear. - + If you are using your own debug handler or when you deploy to production and have debug disabled you can remove these functions to reduce the file size and complexity. ********************************** */ - + // Private: debugMessage is the default debug_handler. If you want to print debug messages // call the debug() function. When overriding the function your own function should // check to see if the debug setting is true before outputting debug information. diff --git a/modules/editor/tpl/js/swfupload.min.js b/modules/editor/tpl/js/swfupload.min.js new file mode 100644 index 000000000..42a0f13cf --- /dev/null +++ b/modules/editor/tpl/js/swfupload.min.js @@ -0,0 +1 @@ +var SWFUpload;void 0==SWFUpload&&(SWFUpload=function(a){this.initSWFUpload(a)}),SWFUpload.prototype.initSWFUpload=function(a){try{this.customSettings={},this.settings=a,this.eventQueue=[],this.movieName="SWFUpload_"+SWFUpload.movieCount++,this.movieElement=null,SWFUpload.instances[this.movieName]=this,this.initSettings(),this.loadFlash(),this.displayDebugInfo()}catch(b){throw delete SWFUpload.instances[this.movieName],b}},SWFUpload.instances={},SWFUpload.movieCount=0,SWFUpload.version="2.2.0 2009-03-25",SWFUpload.QUEUE_ERROR={QUEUE_LIMIT_EXCEEDED:-100,FILE_EXCEEDS_SIZE_LIMIT:-110,ZERO_BYTE_FILE:-120,INVALID_FILETYPE:-130},SWFUpload.UPLOAD_ERROR={HTTP_ERROR:-200,MISSING_UPLOAD_URL:-210,IO_ERROR:-220,SECURITY_ERROR:-230,UPLOAD_LIMIT_EXCEEDED:-240,UPLOAD_FAILED:-250,SPECIFIED_FILE_ID_NOT_FOUND:-260,FILE_VALIDATION_FAILED:-270,FILE_CANCELLED:-280,UPLOAD_STOPPED:-290},SWFUpload.FILE_STATUS={QUEUED:-1,IN_PROGRESS:-2,ERROR:-3,COMPLETE:-4,CANCELLED:-5},SWFUpload.BUTTON_ACTION={SELECT_FILE:-100,SELECT_FILES:-110,START_UPLOAD:-120},SWFUpload.CURSOR={ARROW:-1,HAND:-2},SWFUpload.WINDOW_MODE={WINDOW:"window",TRANSPARENT:"transparent",OPAQUE:"opaque"},SWFUpload.completeURL=function(a){if("string"!=typeof a||a.match(/^https?:\/\//i)||a.match(/^\//))return a;var b=(window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:""),window.location.pathname.lastIndexOf("/"));return path=0>=b?"/":window.location.pathname.substr(0,b)+"/",path+a},SWFUpload.prototype.initSettings=function(){this.ensureDefault=function(a,b){this.settings[a]=void 0==this.settings[a]?b:this.settings[a]},this.ensureDefault("upload_url",""),this.ensureDefault("preserve_relative_urls",!1),this.ensureDefault("file_post_name","Filedata"),this.ensureDefault("post_params",{}),this.ensureDefault("use_query_string",!1),this.ensureDefault("requeue_on_error",!1),this.ensureDefault("http_success",[]),this.ensureDefault("assume_success_timeout",0),this.ensureDefault("file_types","*.*"),this.ensureDefault("file_types_description","All Files"),this.ensureDefault("file_size_limit",0),this.ensureDefault("file_upload_limit",0),this.ensureDefault("file_queue_limit",0),this.ensureDefault("flash_url","swfupload.swf"),this.ensureDefault("prevent_swf_caching",!0),this.ensureDefault("button_image_url",""),this.ensureDefault("button_width",1),this.ensureDefault("button_height",1),this.ensureDefault("button_text",""),this.ensureDefault("button_text_style","color: #000000; font-size: 16pt;"),this.ensureDefault("button_text_top_padding",0),this.ensureDefault("button_text_left_padding",0),this.ensureDefault("button_action",SWFUpload.BUTTON_ACTION.SELECT_FILES),this.ensureDefault("button_disabled",!1),this.ensureDefault("button_placeholder_id",""),this.ensureDefault("button_placeholder",null),this.ensureDefault("button_cursor",SWFUpload.CURSOR.ARROW),this.ensureDefault("button_window_mode",SWFUpload.WINDOW_MODE.WINDOW),this.ensureDefault("debug",!1),this.settings.debug_enabled=this.settings.debug,this.settings.return_upload_start_handler=this.returnUploadStart,this.ensureDefault("swfupload_loaded_handler",null),this.ensureDefault("file_dialog_start_handler",null),this.ensureDefault("file_queued_handler",null),this.ensureDefault("file_queue_error_handler",null),this.ensureDefault("file_dialog_complete_handler",null),this.ensureDefault("upload_start_handler",null),this.ensureDefault("upload_progress_handler",null),this.ensureDefault("upload_error_handler",null),this.ensureDefault("upload_success_handler",null),this.ensureDefault("upload_complete_handler",null),this.ensureDefault("debug_handler",this.debugMessage),this.ensureDefault("custom_settings",{}),this.customSettings=this.settings.custom_settings,this.settings.prevent_swf_caching&&(this.settings.flash_url=this.settings.flash_url+(this.settings.flash_url.indexOf("?")<0?"?":"&")+"preventswfcaching="+(new Date).getTime()),this.settings.preserve_relative_urls||(this.settings.upload_url=SWFUpload.completeURL(this.settings.upload_url),this.settings.button_image_url=SWFUpload.completeURL(this.settings.button_image_url)),delete this.ensureDefault},SWFUpload.prototype.loadFlash=function(){var a,b;if(null!==document.getElementById(this.movieName))throw"ID "+this.movieName+" is already in use. The Flash Object could not be added";if(a=document.getElementById(this.settings.button_placeholder_id)||this.settings.button_placeholder,void 0==a)throw"Could not find the placeholder element: "+this.settings.button_placeholder_id;b=document.createElement("div"),b.innerHTML=this.getFlashHTML(),a.parentNode.replaceChild(b.firstChild,a),void 0==window[this.movieName]&&(window[this.movieName]=this.getMovieElement())},SWFUpload.prototype.getFlashHTML=function(){return['','','','','','','',""].join("")},SWFUpload.prototype.getFlashVars=function(){var a=this.buildParamString(),b=this.settings.http_success.join(",");return["movieName=",encodeURIComponent(this.movieName),"&uploadURL=",encodeURIComponent(this.settings.upload_url),"&useQueryString=",encodeURIComponent(this.settings.use_query_string),"&requeueOnError=",encodeURIComponent(this.settings.requeue_on_error),"&httpSuccess=",encodeURIComponent(b),"&assumeSuccessTimeout=",encodeURIComponent(this.settings.assume_success_timeout),"&params=",encodeURIComponent(a),"&filePostName=",encodeURIComponent(this.settings.file_post_name),"&fileTypes=",encodeURIComponent(this.settings.file_types),"&fileTypesDescription=",encodeURIComponent(this.settings.file_types_description),"&fileSizeLimit=",encodeURIComponent(this.settings.file_size_limit),"&fileUploadLimit=",encodeURIComponent(this.settings.file_upload_limit),"&fileQueueLimit=",encodeURIComponent(this.settings.file_queue_limit),"&debugEnabled=",encodeURIComponent(this.settings.debug_enabled),"&buttonImageURL=",encodeURIComponent(this.settings.button_image_url),"&buttonWidth=",encodeURIComponent(this.settings.button_width),"&buttonHeight=",encodeURIComponent(this.settings.button_height),"&buttonText=",encodeURIComponent(this.settings.button_text),"&buttonTextTopPadding=",encodeURIComponent(this.settings.button_text_top_padding),"&buttonTextLeftPadding=",encodeURIComponent(this.settings.button_text_left_padding),"&buttonTextStyle=",encodeURIComponent(this.settings.button_text_style),"&buttonAction=",encodeURIComponent(this.settings.button_action),"&buttonDisabled=",encodeURIComponent(this.settings.button_disabled),"&buttonCursor=",encodeURIComponent(this.settings.button_cursor)].join("")},SWFUpload.prototype.getMovieElement=function(){if(void 0==this.movieElement&&(this.movieElement=document.getElementById(this.movieName)),null===this.movieElement)throw"Could not find Flash element";return this.movieElement},SWFUpload.prototype.buildParamString=function(){var a=this.settings.post_params,b=[];if("object"==typeof a)for(var c in a)a.hasOwnProperty(c)&&b.push(encodeURIComponent(c.toString())+"="+encodeURIComponent(a[c].toString()));return b.join("&")},SWFUpload.prototype.destroy=function(){try{this.cancelUpload(null,!1);var a=null;if(a=this.getMovieElement(),a&&"unknown"==typeof a.CallFunction){for(var b in a)try{"function"==typeof a[b]&&(a[b]=null)}catch(c){}try{a.parentNode.removeChild(a)}catch(d){}}return window[this.movieName]=null,SWFUpload.instances[this.movieName]=null,delete SWFUpload.instances[this.movieName],this.movieElement=null,this.settings=null,this.customSettings=null,this.eventQueue=null,this.movieName=null,!0}catch(e){return!1}},SWFUpload.prototype.displayDebugInfo=function(){this.debug(["---SWFUpload Instance Info---\n","Version: ",SWFUpload.version,"\n","Movie Name: ",this.movieName,"\n","Settings:\n"," ","upload_url: ",this.settings.upload_url,"\n"," ","flash_url: ",this.settings.flash_url,"\n"," ","use_query_string: ",this.settings.use_query_string.toString(),"\n"," ","requeue_on_error: ",this.settings.requeue_on_error.toString(),"\n"," ","http_success: ",this.settings.http_success.join(", "),"\n"," ","assume_success_timeout: ",this.settings.assume_success_timeout,"\n"," ","file_post_name: ",this.settings.file_post_name,"\n"," ","post_params: ",this.settings.post_params.toString(),"\n"," ","file_types: ",this.settings.file_types,"\n"," ","file_types_description: ",this.settings.file_types_description,"\n"," ","file_size_limit: ",this.settings.file_size_limit,"\n"," ","file_upload_limit: ",this.settings.file_upload_limit,"\n"," ","file_queue_limit: ",this.settings.file_queue_limit,"\n"," ","debug: ",this.settings.debug.toString(),"\n"," ","prevent_swf_caching: ",this.settings.prevent_swf_caching.toString(),"\n"," ","button_placeholder_id: ",this.settings.button_placeholder_id.toString(),"\n"," ","button_placeholder: ",this.settings.button_placeholder?"Set":"Not Set","\n"," ","button_image_url: ",this.settings.button_image_url.toString(),"\n"," ","button_width: ",this.settings.button_width.toString(),"\n"," ","button_height: ",this.settings.button_height.toString(),"\n"," ","button_text: ",this.settings.button_text.toString(),"\n"," ","button_text_style: ",this.settings.button_text_style.toString(),"\n"," ","button_text_top_padding: ",this.settings.button_text_top_padding.toString(),"\n"," ","button_text_left_padding: ",this.settings.button_text_left_padding.toString(),"\n"," ","button_action: ",this.settings.button_action.toString(),"\n"," ","button_disabled: ",this.settings.button_disabled.toString(),"\n"," ","custom_settings: ",this.settings.custom_settings.toString(),"\n","Event Handlers:\n"," ","swfupload_loaded_handler assigned: ",("function"==typeof this.settings.swfupload_loaded_handler).toString(),"\n"," ","file_dialog_start_handler assigned: ",("function"==typeof this.settings.file_dialog_start_handler).toString(),"\n"," ","file_queued_handler assigned: ",("function"==typeof this.settings.file_queued_handler).toString(),"\n"," ","file_queue_error_handler assigned: ",("function"==typeof this.settings.file_queue_error_handler).toString(),"\n"," ","upload_start_handler assigned: ",("function"==typeof this.settings.upload_start_handler).toString(),"\n"," ","upload_progress_handler assigned: ",("function"==typeof this.settings.upload_progress_handler).toString(),"\n"," ","upload_error_handler assigned: ",("function"==typeof this.settings.upload_error_handler).toString(),"\n"," ","upload_success_handler assigned: ",("function"==typeof this.settings.upload_success_handler).toString(),"\n"," ","upload_complete_handler assigned: ",("function"==typeof this.settings.upload_complete_handler).toString(),"\n"," ","debug_handler assigned: ",("function"==typeof this.settings.debug_handler).toString(),"\n"].join(""))},SWFUpload.prototype.addSetting=function(a,b,c){return this.settings[a]=void 0==b?c:b},SWFUpload.prototype.getSetting=function(a){return void 0!=this.settings[a]?this.settings[a]:""},SWFUpload.prototype.callFlash=function(functionName,argumentArray){argumentArray=argumentArray||[];var movieElement=this.getMovieElement(),returnValue,returnString;try{returnString=movieElement.CallFunction(''+__flash__argumentsToXML(argumentArray,0)+""),returnValue=eval(returnString)}catch(ex){throw"Call to "+functionName+" failed"}return void 0!=returnValue&&"object"==typeof returnValue.post&&(returnValue=this.unescapeFilePostParams(returnValue)),returnValue},SWFUpload.prototype.selectFile=function(){this.callFlash("SelectFile")},SWFUpload.prototype.selectFiles=function(){this.callFlash("SelectFiles")},SWFUpload.prototype.startUpload=function(a){this.callFlash("StartUpload",[a])},SWFUpload.prototype.cancelUpload=function(a,b){b!==!1&&(b=!0),this.callFlash("CancelUpload",[a,b])},SWFUpload.prototype.stopUpload=function(){this.callFlash("StopUpload")},SWFUpload.prototype.getStats=function(){return this.callFlash("GetStats")},SWFUpload.prototype.setStats=function(a){this.callFlash("SetStats",[a])},SWFUpload.prototype.getFile=function(a){return"number"==typeof a?this.callFlash("GetFileByIndex",[a]):this.callFlash("GetFile",[a])},SWFUpload.prototype.addFileParam=function(a,b,c){return this.callFlash("AddFileParam",[a,b,c])},SWFUpload.prototype.removeFileParam=function(a,b){this.callFlash("RemoveFileParam",[a,b])},SWFUpload.prototype.setUploadURL=function(a){this.settings.upload_url=a.toString(),this.callFlash("SetUploadURL",[a])},SWFUpload.prototype.setPostParams=function(a){this.settings.post_params=a,this.callFlash("SetPostParams",[a])},SWFUpload.prototype.addPostParam=function(a,b){this.settings.post_params[a]=b,this.callFlash("SetPostParams",[this.settings.post_params])},SWFUpload.prototype.removePostParam=function(a){delete this.settings.post_params[a],this.callFlash("SetPostParams",[this.settings.post_params])},SWFUpload.prototype.setFileTypes=function(a,b){this.settings.file_types=a,this.settings.file_types_description=b,this.callFlash("SetFileTypes",[a,b])},SWFUpload.prototype.setFileSizeLimit=function(a){this.settings.file_size_limit=a,this.callFlash("SetFileSizeLimit",[a])},SWFUpload.prototype.setFileUploadLimit=function(a){this.settings.file_upload_limit=a,this.callFlash("SetFileUploadLimit",[a])},SWFUpload.prototype.setFileQueueLimit=function(a){this.settings.file_queue_limit=a,this.callFlash("SetFileQueueLimit",[a])},SWFUpload.prototype.setFilePostName=function(a){this.settings.file_post_name=a,this.callFlash("SetFilePostName",[a])},SWFUpload.prototype.setUseQueryString=function(a){this.settings.use_query_string=a,this.callFlash("SetUseQueryString",[a])},SWFUpload.prototype.setRequeueOnError=function(a){this.settings.requeue_on_error=a,this.callFlash("SetRequeueOnError",[a])},SWFUpload.prototype.setHTTPSuccess=function(a){"string"==typeof a&&(a=a.replace(" ","").split(",")),this.settings.http_success=a,this.callFlash("SetHTTPSuccess",[a])},SWFUpload.prototype.setAssumeSuccessTimeout=function(a){this.settings.assume_success_timeout=a,this.callFlash("SetAssumeSuccessTimeout",[a])},SWFUpload.prototype.setDebugEnabled=function(a){this.settings.debug_enabled=a,this.callFlash("SetDebugEnabled",[a])},SWFUpload.prototype.setButtonImageURL=function(a){void 0==a&&(a=""),this.settings.button_image_url=a,this.callFlash("SetButtonImageURL",[a])},SWFUpload.prototype.setButtonDimensions=function(a,b){this.settings.button_width=a,this.settings.button_height=b;var c=this.getMovieElement();void 0!=c&&(c.style.width=a+"px",c.style.height=b+"px"),this.callFlash("SetButtonDimensions",[a,b])},SWFUpload.prototype.setButtonText=function(a){this.settings.button_text=a,this.callFlash("SetButtonText",[a])},SWFUpload.prototype.setButtonTextPadding=function(a,b){this.settings.button_text_top_padding=b,this.settings.button_text_left_padding=a,this.callFlash("SetButtonTextPadding",[a,b])},SWFUpload.prototype.setButtonTextStyle=function(a){this.settings.button_text_style=a,this.callFlash("SetButtonTextStyle",[a])},SWFUpload.prototype.setButtonDisabled=function(a){this.settings.button_disabled=a,this.callFlash("SetButtonDisabled",[a])},SWFUpload.prototype.setButtonAction=function(a){this.settings.button_action=a,this.callFlash("SetButtonAction",[a])},SWFUpload.prototype.setButtonCursor=function(a){this.settings.button_cursor=a,this.callFlash("SetButtonCursor",[a])},SWFUpload.prototype.queueEvent=function(a,b){void 0==b?b=[]:b instanceof Array||(b=[b]);var c=this;if("function"==typeof this.settings[a])this.eventQueue.push(function(){this.settings[a].apply(this,b)}),setTimeout(function(){c.executeNextEvent()},0);else if(null!==this.settings[a])throw"Event handler "+a+" is unknown or is not a function"},SWFUpload.prototype.executeNextEvent=function(){var a=this.eventQueue?this.eventQueue.shift():null;"function"==typeof a&&a.apply(this)},SWFUpload.prototype.unescapeFilePostParams=function(a){var b,c=/[$]([0-9a-f]{4})/i,d={};if(void 0!=a){for(var e in a.post)if(a.post.hasOwnProperty(e)){b=e;for(var f;null!==(f=c.exec(b));)b=b.replace(f[0],String.fromCharCode(parseInt("0x"+f[1],16)));d[b]=a.post[e]}a.post=d}return a},SWFUpload.prototype.testExternalInterface=function(){try{return this.callFlash("TestExternalInterface")}catch(a){return!1}},SWFUpload.prototype.flashReady=function(){var a=this.getMovieElement();return a?(this.cleanUp(a),this.queueEvent("swfupload_loaded_handler"),void 0):(this.debug("Flash called back ready but the flash movie can't be found."),void 0)},SWFUpload.prototype.cleanUp=function(a){try{if(this.movieElement&&"unknown"==typeof a.CallFunction){this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");for(var b in a)try{"function"==typeof a[b]&&(a[b]=null)}catch(c){}}}catch(d){}window.__flash__removeCallback=function(a,b){try{a&&(a[b]=null)}catch(c){}}},SWFUpload.prototype.fileDialogStart=function(){this.queueEvent("file_dialog_start_handler")},SWFUpload.prototype.fileQueued=function(a){a=this.unescapeFilePostParams(a),this.queueEvent("file_queued_handler",a)},SWFUpload.prototype.fileQueueError=function(a,b,c){a=this.unescapeFilePostParams(a),this.queueEvent("file_queue_error_handler",[a,b,c])},SWFUpload.prototype.fileDialogComplete=function(a,b,c){this.queueEvent("file_dialog_complete_handler",[a,b,c])},SWFUpload.prototype.uploadStart=function(a){a=this.unescapeFilePostParams(a),this.queueEvent("return_upload_start_handler",a)},SWFUpload.prototype.returnUploadStart=function(a){var b;if("function"==typeof this.settings.upload_start_handler)a=this.unescapeFilePostParams(a),b=this.settings.upload_start_handler.call(this,a);else if(void 0!=this.settings.upload_start_handler)throw"upload_start_handler must be a function";void 0===b&&(b=!0),b=!!b,this.callFlash("ReturnUploadStart",[b])},SWFUpload.prototype.uploadProgress=function(a,b,c){a=this.unescapeFilePostParams(a),this.queueEvent("upload_progress_handler",[a,b,c])},SWFUpload.prototype.uploadError=function(a,b,c){a=this.unescapeFilePostParams(a),this.queueEvent("upload_error_handler",[a,b,c])},SWFUpload.prototype.uploadSuccess=function(a,b,c){a=this.unescapeFilePostParams(a),this.queueEvent("upload_success_handler",[a,b,c])},SWFUpload.prototype.uploadComplete=function(a){a=this.unescapeFilePostParams(a),this.queueEvent("upload_complete_handler",a)},SWFUpload.prototype.debug=function(a){this.queueEvent("debug_handler",a)},SWFUpload.prototype.debugMessage=function(a){if(this.settings.debug){var b,c=[];if("object"==typeof a&&"string"==typeof a.name&&"string"==typeof a.message){for(var d in a)a.hasOwnProperty(d)&&c.push(d+": "+a[d]);b=c.join("\n")||"",c=b.split("\n"),b="EXCEPTION: "+c.join("\nEXCEPTION: "),SWFUpload.Console.writeLine(b)}else SWFUpload.Console.writeLine(a)}},SWFUpload.Console={},SWFUpload.Console.writeLine=function(a){var b,c;try{b=document.getElementById("SWFUpload_Console"),b||(c=document.createElement("form"),document.getElementsByTagName("body")[0].appendChild(c),b=document.createElement("textarea"),b.id="SWFUpload_Console",b.style.fontFamily="monospace",b.setAttribute("wrap","off"),b.wrap="off",b.style.overflow="auto",b.style.width="700px",b.style.height="350px",b.style.margin="5px",c.appendChild(b)),b.value+=a+"\n",b.scrollTop=b.scrollHeight-b.clientHeight}catch(d){alert("Exception: "+d.name+" Message: "+d.message)}}; \ No newline at end of file diff --git a/modules/editor/tpl/js/uploader.js b/modules/editor/tpl/js/uploader.js index a86f52ac3..e6b69fe80 100755 --- a/modules/editor/tpl/js/uploader.js +++ b/modules/editor/tpl/js/uploader.js @@ -33,7 +33,7 @@ function init(cfg, exe) { insertedFiles : 0 }, cfg); - uploadSettingObj[seq] = cfg; + uploadSettingObj[seq] = cfg; $(function(){ start(cfg) }); } @@ -352,7 +352,7 @@ function previewFiles(event, file_srl) { if(fileinfo.direct_download != 'Y' || !match) { html = ''; } else if(match[1]) { // flash video file - html = ''; + html = ''; } else if(match[2]) { // shockwave flash file html = ''; } else if(match[3]) { // movie file @@ -392,60 +392,60 @@ function removeUploadedFile(editorSequence) { function insertUploadedFile(editorSequence) { - var settings = uploaderSettings[editorSequence]; - var fileListAreaID = settings["fileListAreaID"]; - var fileListObj = get_by_id(fileListAreaID); - if(!fileListObj) return; + var settings = uploaderSettings[editorSequence]; + var fileListAreaID = settings["fileListAreaID"]; + var fileListObj = get_by_id(fileListAreaID); + if(!fileListObj) return; - if(editorMode[editorSequence]=='preview') return; + if(editorMode[editorSequence]=='preview') return; - var text = new Array(); - for(var i=0;i"); - } + // 바로 링크 가능한 파일의 경우 (이미지, 플래쉬, 동영상 등..) + if(file.direct_download == 'Y') { + // 이미지 파일의 경우 image_link 컴포넌트 열결 + if(/\.(jpg|jpeg|png|gif)$/i.test(file.download_url)) { + if(loaded_images[file_srl]) { + var obj = loaded_images[file_srl]; + } + else { + var obj = new Image(); + obj.src = file.download_url; + } + temp_code = ''; + temp_code += "\""+file.source_filename+"\"";"); + } - // binary파일의 경우 url_link 컴포넌트 연결 - } else { - text.push(""+file.source_filename+"\n"); - } - } + } else { + // binary파일의 경우 url_link 컴포넌트 연결 + text.push(""+file.source_filename+"\n"); + } + } - // html 모드 - if(editorMode[editorSequence]=='html'){ - if(text.length>0 && get_by_id('editor_textarea_'+editorSequence)) - { - get_by_id('editor_textarea_'+editorSequence).value += text.join(''); - } + // html 모드 + if(editorMode[editorSequence]=='html'){ + if(text.length>0 && get_by_id('editor_textarea_'+editorSequence)) + { + get_by_id('editor_textarea_'+editorSequence).value += text.join(''); + } - // 위지윅 모드 - }else{ - var iframe_obj = editorGetIFrame(editorSequence); - if(!iframe_obj) return; - if(text.length>0) editorReplaceHTML(iframe_obj, text.join('')); - } + // 위지윅 모드 + }else{ + var iframe_obj = editorGetIFrame(editorSequence); + if(!iframe_obj) return; + if(text.length>0) editorReplaceHTML(iframe_obj, text.join('')); + } } diff --git a/modules/editor/tpl/js/uploader.min.js b/modules/editor/tpl/js/uploader.min.js new file mode 100644 index 000000000..9f751705a --- /dev/null +++ b/modules/editor/tpl/js/uploader.min.js @@ -0,0 +1 @@ +function previewFiles(a,b){var c,d,e,f,g,h,i=jQuery;if(!b){if(c=i(a.target).parent().andSelf().filter("select").find(">option:selected"),!c.length)return;b=c.attr("value")}b&&is_def(e=uploadedFiles[b])&&(d=i("#"+e.previewAreaID).html(" "),d.length&&(f=e.download_url||"",g=f.match(/\.(?:(flv)|(swf)|(wmv|avi|mpe?g|as[fx]|mp3)|(jpe?g|png|gif))$/i),"Y"==e.direct_download&&g?g[1]?h='':g[2]?h='':g[3]?h='':g[4]&&(h=''):h='',h&&d.html(h)))}function removeUploadedFile(a){var b=uploaderSettings[a],c=b.fileListAreaID,d=get_by_id(c);if(d&&!(d.selectedIndex<0)){for(var e=new Array,f=0;f');else e.push(''+h.source_filename+"\n")}}if("html"==editorMode[a])e.length>0&&get_by_id("editor_textarea_"+a)&&(get_by_id("editor_textarea_"+a).value+=e.join(""));else{var j=editorGetIFrame(a);if(!j)return;e.length>0&&editorReplaceHTML(j,e.join(""))}}}var uploadedFiles=[],uploaderSettings=[],loaded_images=[],swfUploadObjs=[],uploadSettingObj=[],uploadAutosaveChecker=!1;!function(a){function b(b){var d=b.editorSequence;is_def(d)&&(b=a.extend({sessionName:"PHPSESSID",allowedFileSize:2097152,allowedFileTypes:"*.*",allowedFileTypesDescription:"All Files",replaceButtonID:"swfUploadButton"+b.editorSequence,insertedFiles:0},b),uploadSettingObj[d]=b,a(function(){c(b)}))}function c(b){var c,d,g,h,i,j,k,l,m,n,o,p;i=b.editorSequence,j=b.replaceButtonID,c=a("#"+j).wrap(''),d=c.width(),g=c.height(),h=a('').insertAfter(c),k={flash_url:request_uri+"modules/editor/tpl/images/SWFUpload.swf",upload_url:request_uri.replace(/^https/i,"http")+"index.php",post_params:{mid:current_mid,act:"procFileUpload",editor_sequence:i,uploadTargetSrl:editorRelKeys[i].primary.value},http_success:[302],file_size_limit:Math.floor((parseInt(b.allowedFileSize,10)||1024)/1024),file_queue_limit:0,file_upload_limit:0,file_types:b.allowedFileTypes,file_types_description:b.allowedFileTypesDescription,custom_settings:{progressTarget:null,cancelButtonId:null},debug:!1,button_window_mode:"transparent",button_placeholder_id:h.attr("id"),button_text:null,button_image_url:request_uri+"common/img/blank.gif",button_width:d,button_height:g,button_text_style:null,button_text_left_padding:0,button_text_top_padding:0,button_cursor:-2,editorSequence:i,uploadTargetSrl:editorRelKeys[i].primary.value,fileListAreaID:b.fileListAreaID,previewAreaID:b.previewAreaID,uploaderStatusID:b.uploaderStatusID},"undefined"!=typeof enforce_ssl&&enforce_ssl&&(k.upload_url=request_uri+"index.php"),a("#"+b.fileListAreaID).click(previewFiles),l={file_queued:"FileQueued",file_queue_error:"FileQueueError",file_dialog_complete:"FileDialogComplete",upload_start:"UploadStart",upload_progress:"UploadProgress",upload_error:"UploadError",upload_success:"UploadSuccess",upload_complete:"UploadComplete",queue_complete:"QueueComplete"};for(m in l)l.hasOwnProperty(m)&&(n="on"+l[m],k[m+"_handler"]=b["on"+n]||f[n]);is_def(window.xeVid)&&(k.post_params.vid=xeVid),k.post_params[b.sessionName]=getCookie(b.sessionName),uploaderSettings[i]=k,o=new SWFUpload(k),p=a("#"+o.movieName),swfUploadObjs[i]=o.movieName,p.length&&(p.css({display:"block",cursor:"pointer",position:"absolute",left:0,top:0,width:d+"px",height:g+"px"}),(b.insertedFiles||editorRelKeys[i].primary.value)&&e(b))}function d(){return!0}function e(b){function c(){"function"==typeof _editorAutoSave&&(uploadAutosaveChecker=!0,_editorAutoSave(!0))}function d(d){var e,f,g,h,i,j,k,l,m,n,o;if(f=d.editor_sequence,g=d.files,i=d.upload_status,h=d.upload_target_srl,j=Math.floor((parseInt(d.left_size,10)||0)/1024),e=a("#"+b.fileListAreaID).empty(),h&&(editorRelKeys[f].primary.value!=h&&(editorRelKeys[f].primary.value=h,c()),editorRelKeys[f].primary.value=h,b.uploadTargetSrl=h),a("#"+b.uploaderStatusID).html(i),a("#"+b.previewAreaID).empty(),g&&g.item){for(k=g.item,a.isArray(k)||(k=[k]),l=0,m=k.length;m>l;l++)n=k[l],o=n.file_srl,uploadedFiles[o]=n,n.previewAreaID=b.previewAreaID,/\.(jpe?g|png|gif)$/i.test(n.download_url)&&(loaded_images[o]=a("").attr("src",n.download_url).get(0)),a("