사파리에서 동작하지 않던 버그 수정

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@6086 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
taggon 2009-04-10 09:14:01 +00:00
parent b5ea8930c1
commit 4402408798
2 changed files with 182 additions and 169 deletions

View file

@ -6,7 +6,7 @@ return this;}})(jQuery);if(typeof window.xe=='undefined')window.xe={};xe.XpressC
this.commandQueue=[];this.oCommandMap={};this.oDisabledCommand={};this.aPlugins=[];this.appStatus=xe.APP_STATUS["NOT_READY"];this.registerPlugin(this);},exec:function(msg,args,oEvent){if(this.appStatus==xe.APP_STATUS["NOT_READY"]){this.commandQueue[this.commandQueue.length]={'msg':msg,'args':args,'event':oEvent};return true;}
this.exec=this._exec;this.exec(msg,args,oEvent);},delayedExec:function(msg,args,nDelay,oEvent){var fExec=jQuery.fnBind(this.exec,this,msg,args,oEvent);setTimeout(fExec,nDelay);},_exec:function(msg,args,oEvent){return(this._exec=this.oDebugger?this._execWithDebugger:this._execWithoutDebugger).call(this,msg,args,oEvent);},_execWithDebugger:function(msg,args,oEvent){this.oDebugger.log_MessageStart(msg,args);var bResult=this._doExec(msg,args,oEvent);this.oDebugger.log_MessageEnd(msg,args);return bResult;},_execWithoutDebugger:function(msg,args,oEvent){return this._doExec(msg,args,oEvent);},_doExec:function(msg,args,oEvent){var bContinue=false;if(!this.oDisabledCommand[msg]){var allArgs=[];if(args&&args.length){var iLen=args.length;for(var i=0;i<iLen;i++)allArgs[i]=args[i];}
if(oEvent)allArgs[allArgs.length]=oEvent;var bContinue=true;bContinue=this._execMsgStep("BEFORE",msg,allArgs);if(bContinue)bContinue=this._execMsgStep("ON",msg,allArgs);if(bContinue)bContinue=this._execMsgStep("AFTER",msg,allArgs);}
return bContinue;},registerPlugin:function(oPlugin){if(!oPlugin)throw("An error occured in registerPlugin(): invalid plug-in");oPlugin.nIdx=this.aPlugins.length;oPlugin.oApp=this;this.aPlugins[oPlugin.nIdx]=oPlugin;if(oPlugin.status!=xe.PLUGIN_STATUS["NOT_READY"])oPlugin.status=xe.PLUGIN_STATUS["READY"];this.exec("MSG_PLUGIN_REGISTERED",[oPlugin]);return oPlugin.nIdx;},disableCommand:function(sCommand,bDisable){this.oDisabledCommand[sCommand]=bDisable;},registerBrowserEvent:function(obj,sEvent,sCMD,aParams,nDelay){if(!obj) return;aParams=aParams||[];var func=(nDelay)?jQuery.fnBind(this.delayedExec,this,sCMD,aParams,nDelay):jQuery.fnBind(this.exec,this,sCMD,aParams);jQuery(obj).bind(sEvent,func);},run:function(){this._changeAppStatus(xe.APP_STATUS["WAITING_FOR_PLUGINS_READY"]);var iQueueLength=this.commandQueue.length;for(i=0;i<iQueueLength;i++){var curMsgAndArgs=this.commandQueue[i];this.exec(curMsgAndArgs.msg,curMsgAndArgs.args,curMsgAndArgs.event);}
return bContinue;},registerPlugin:function(oPlugin){if(!oPlugin)throw("An error occured in registerPlugin(): invalid plug-in");oPlugin.nIdx=this.aPlugins.length;oPlugin.oApp=this;this.aPlugins[oPlugin.nIdx]=oPlugin;if(oPlugin.status!=xe.PLUGIN_STATUS["NOT_READY"])oPlugin.status=xe.PLUGIN_STATUS["READY"];this.exec("MSG_PLUGIN_REGISTERED",[oPlugin]);return oPlugin.nIdx;},disableCommand:function(sCommand,bDisable){this.oDisabledCommand[sCommand]=bDisable;},registerBrowserEvent:function(obj,sEvent,sCMD,aParams,nDelay){if(!obj)return;\n\t\taParams=aParams||[];var func=(nDelay)?jQuery.fnBind(this.delayedExec,this,sCMD,aParams,nDelay):jQuery.fnBind(this.exec,this,sCMD,aParams);jQuery(obj).bind(sEvent,func);},run:function(){this._changeAppStatus(xe.APP_STATUS["WAITING_FOR_PLUGINS_READY"]);var iQueueLength=this.commandQueue.length;for(i=0;i<iQueueLength;i++){var curMsgAndArgs=this.commandQueue[i];this.exec(curMsgAndArgs.msg,curMsgAndArgs.args,curMsgAndArgs.event);}
this._waitForPluginReady();},createCommandMap:function(sMsgHandler){this.oCommandMap[sMsgHandler]=[];var nLen=this.aPlugins.length;for(var i=0;i<nLen;i++)this._doAddToCommandMap(sMsgHandler,this.aPlugins[i]);},addToCommandMap:function(sMsgHandler,oPlugin){if(!this.oCommandMap[sMsgHandler])return;this._addToCommandMap(sMsgHandler,oPlugin);},_changeAppStatus:function(appStatus){this.appStatus=appStatus;if(this.appStatus==xe.APP_STATUS["READY"])this.exec("MSG_APP_READY");},_execMsgStep:function(sMsgStep,sMsg,args){return(this._execMsgStep=this.oDebugger?this._execMsgStepWithDebugger:this._execMsgStepWithoutDebugger).call(this,sMsgStep,sMsg,args);},_execMsgStepWithDebugger:function(sMsgStep,sMsg,args){this.oDebugger.log_MessageStepStart(sMsgStep,sMsg,args);var bStatus=this._execMsgHandler("$"+sMsgStep+"_"+sMsg,args);this.oDebugger.log_MessageStepEnd(sMsgStep,sMsg,args);return bStatus;},_execMsgStepWithoutDebugger:function(sMsgStep,sMsg,args){return this._execMsgHandler("$"+sMsgStep+"_"+sMsg,args);},_execMsgHandler:function(sMsgHandler,args){if(!this.oCommandMap[sMsgHandler]){this.createCommandMap(sMsgHandler);}
var aPlugins=this.oCommandMap[sMsgHandler];var iNumOfPlugins=aPlugins.length;if(iNumOfPlugins==0)return true;var tmpStatus,bResult=true;if(sMsgHandler.match(/^\$(BEFORE|ON|AFTER)_MSG_APP_READY$/)){for(var i=0;i<iNumOfPlugins;i++){tmpStatus=this._execHandler(aPlugins[i],sMsgHandler,args);if(tmpStatus===false){bResult=false;break;}}}else{for(var i=0;i<iNumOfPlugins;i++){if(typeof aPlugins[i]["$PRECONDITION"]=="function")if(!this._execHandler(aPlugins[i],"$PRECONDITION",[sMsgHandler,args]))continue;tmpStatus=this._execHandler(aPlugins[i],sMsgHandler,args);if(tmpStatus===false){bResult=false;break;}}}
return bResult;},_execHandler:function(oPlugin,sHandler,args){return(this._execHandler=this.oDebugger?this._execHandlerWithDebugger:this._execHandlerWithoutDebugger).call(this,oPlugin,sHandler,args);},_execHandlerWithDebugger:function(oPlugin,sHandler,args){this.oDebugger.log_CallHandlerStart(oPlugin,sHandler,args);var bResult=oPlugin[sHandler].apply(oPlugin,args);this.oDebugger.log_CallHandlerEnd(oPlugin,sHandler,args);return bResult;},_execHandlerWithoutDebugger:function(oPlugin,sHandler,args){return oPlugin[sHandler].apply(oPlugin,args);},_doAddToCommandMap:function(sMsgHandler,oPlugin){if(typeof oPlugin[sMsgHandler]!="function")return;this.oCommandMap[sMsgHandler][this.oCommandMap[sMsgHandler].length]=oPlugin;},_waitForPluginReady:function(){var bAllReady=true;for(var i=0;i<this.aPlugins.length;i++){if(this.aPlugins[i].status==xe.PLUGIN_STATUS["NOT_READY"]){bAllReady=false;break;}}
@ -140,7 +140,7 @@ sIR=sContent;return sIR;},setIR:function(sIR){var sContent;if(this.oApp.applyCon
sContent=this.oApp.applyConverter("IR_TO_"+this.sMode,sIR);else
sContent=sIR;this.textarea.value=sContent;},focus:function(){this.textarea.focus();}});var TextRange=function(oEl){this._o=oEl;};TextRange.prototype.getSelection=function(){var obj=this._o;var ret=[-1,-1];if(isNaN(this._o.selectionStart)){obj.focus();var range=document.body.createTextRange();var rangeField=null;rangeField=document.selection.createRange().duplicate();range.moveToElementText(obj);rangeField.collapse(true);range.setEndPoint("EndToEnd",rangeField);ret[0]=range.text.length;rangeField=document.selection.createRange().duplicate();range.moveToElementText(obj);rangeField.collapse(false);range.setEndPoint("EndToEnd",rangeField);ret[1]=range.text.length;obj.blur();}else{ret[0]=obj.selectionStart;ret[1]=obj.selectionEnd;}
return ret;};TextRange.prototype.setSelection=function(start,end){var obj=this._o;if(typeof end=='undefined')end=start;if(obj.setSelectionRange){obj.setSelectionRange(start,end);}else if(obj.createTextRange){var range=obj.createTextRange();range.collapse(true);range.moveStart("character",start);range.moveEnd("character",end-start);range.select();obj.blur();}};TextRange.prototype.copy=function(){var r=this.getSelection();return this._o.value.substring(r[0],r[1]);};TextRange.prototype.paste=function(sStr){var obj=this._o;var sel=this.getSelection();var value=obj.value;var pre=value.substr(0,sel[0]);var post=value.substr(sel[1]);value=pre+sStr+post;obj.value=value;var n=0;if(typeof document.body.style.maxHeight=="undefined"){var a=pre.match(/\n/gi);n=(a!=null?a.length:0);}
this.setSelection(sel[0]+sStr.length-n);};TextRange.prototype.cut=function(){var r=this.copy();this.paste('');return r;};xe.XE_EditingArea_WYSIWYG=jQuery.Class({name:"XE_EditingArea_WYSIWYG",status:xe.PLUGIN_STATUS["NOT_READY"],sMode:"WYSIWYG",iframe:null,doc:null,iLastUndoRecorded:0,iMinUndoInterval:3000,_nIFrameReadyCount:50,$init:function(iframe){this.iframe=jQuery.$(iframe);this.initIframe();this.elEditingArea=iframe;},$BEFORE_MSG_APP_READY:function(){this.oEditingArea=this.doc;this.oApp.exec("REGISTER_EDITING_AREA",[this]);this.oApp.exec("ADD_APP_PROPERTY",["getWYSIWYGWindow",jQuery.fnBind(this.getWindow,this)]);this.oApp.exec("ADD_APP_PROPERTY",["getWYSIWYGDocument",jQuery.fnBind(this.getDocument,this)]);},$ON_MSG_APP_READY:function(){if(jQuery.browser.msie){jQuery(this.doc).bind('keydown',jQuery.fnBind(function(weEvent){if(this.doc.selection.type.toLowerCase()=='control'&&weEvent.key().keyCode==8){this.oApp.exec("EXECCOMMAND",['delete',false,false]);weEvent.preventDefault();weEvent.stopPropagation();}},this));jQuery(this.doc.body).bind('mousedown',jQuery.fnBind(function(weEvent){this._oIERange=null;this._bIERangeReset=true;},this));jQuery(this.doc.body).bind('beforedeactivate',jQuery.fnBind(function(weEvent){if(this._bIERangeReset)return;var tmpRange=this.getDocument().selection.createRange(0);if(tmpRange.parentElement&&tmpRange.parentElement()&&tmpRange.parentElement().tagName=="INPUT"){this._oIERange=this._oPrevIERange;}else{this._oIERange=tmpRange;}},this));jQuery(this.doc.body).bind('mouseup',jQuery.fnBind(function(weEvent){this._bIERangeReset=false;},this));}},$ON_CHANGE_EDITING_MODE:function(sMode,bNoFocus){if(sMode==this.sMode){this.iframe.style.display="block";this.oApp.exec("REFRESH_WYSIWYG",[]);this.oApp.exec("SET_EDITING_WINDOW",[this.getWindow()]);}else{this.iframe.style.display="none";}},$AFTER_CHANGE_EDITING_MODE:function(sMode,bNoFocus){this._oIERange=null;},$ON_REFRESH_WYSIWYG:function(){if(!jQuery.browser.mozilla)return;this._disableWYSIWYG();this._enableWYSIWYG();},$ON_ENABLE_WYSIWYG:function(){this._enableWYSIWYG();},$ON_DISABLE_WYSIWYG:function(){this._disableWYSIWYG();},$ON_EVENT_EDITING_AREA_KEYUP:function(oEvent){if(oEvent.keyCode==229||oEvent.keyCode==13||oEvent.altKey||oEvent.ctrlKey||(oEvent.keyCode>=33&&oEvent.keyCode<=40)||oEvent.keyCode==16)return;this._recordUndo(oEvent);},$ON_PASTE_HTML:function(sHTML,oPSelection){if(this.oApp.getEditingMode()!=this.sMode)return;var oSelection=oPSelection||this.oApp.getSelection();oSelection.pasteHTML(sHTML);if(!jQuery.browser.msie){var sTmpBookmark=oSelection.placeStringBookmark();this.oApp.getWYSIWYGDocument().body.innerHTML=this.oApp.getWYSIWYGDocument().body.innerHTML;oSelection.moveToBookmark(sTmpBookmark);oSelection.collapseToEnd();oSelection.select();oSelection.removeStringBookmark(sTmpBookmark);}
this.setSelection(sel[0]+sStr.length-n);};TextRange.prototype.cut=function(){var r=this.copy();this.paste('');return r;};xe.XE_EditingArea_WYSIWYG=jQuery.Class({name:"XE_EditingArea_WYSIWYG",status:xe.PLUGIN_STATUS["NOT_READY"],sMode:"WYSIWYG",iframe:null,doc:null,iLastUndoRecorded:0,iMinUndoInterval:3000,_nIFrameReadyCount:50,$init:function(iframe){this.iframe=jQuery.$(iframe);this.initIframe();this.elEditingArea=iframe;},$BEFORE_MSG_APP_READY:function(){this.oEditingArea=this.doc;this.oApp.exec("REGISTER_EDITING_AREA",[this]);this.oApp.exec("ADD_APP_PROPERTY",["getWYSIWYGWindow",jQuery.fnBind(this.getWindow,this)]);this.oApp.exec("ADD_APP_PROPERTY",["getWYSIWYGDocument",jQuery.fnBind(this.getDocument,this)]);},$ON_MSG_APP_READY:function(){if(jQuery.browser.msie){jQuery(this.doc).bind('keydown',jQuery.fnBind(function(weEvent){if(this.doc.selection.type.toLowerCase()=='control'&&weEvent.keyCode==8){this.oApp.exec("EXECCOMMAND",['delete',false,false]);weEvent.preventDefault();weEvent.stopPropagation();}},this));jQuery(this.doc.body).bind('mousedown',jQuery.fnBind(function(weEvent){this._oIERange=null;this._bIERangeReset=true;},this));jQuery(this.doc.body).bind('beforedeactivate',jQuery.fnBind(function(weEvent){if(this._bIERangeReset)return;var tmpRange=this.getDocument().selection.createRange(0);if(tmpRange.parentElement&&tmpRange.parentElement()&&tmpRange.parentElement().tagName=="INPUT"){this._oIERange=this._oPrevIERange;}else{this._oIERange=tmpRange;}},this));jQuery(this.doc.body).bind('mouseup',jQuery.fnBind(function(weEvent){this._bIERangeReset=false;},this));}},$ON_CHANGE_EDITING_MODE:function(sMode,bNoFocus){if(sMode==this.sMode){this.iframe.style.display="block";this.oApp.exec("REFRESH_WYSIWYG",[]);this.oApp.exec("SET_EDITING_WINDOW",[this.getWindow()]);}else{this.iframe.style.display="none";}},$AFTER_CHANGE_EDITING_MODE:function(sMode,bNoFocus){this._oIERange=null;},$ON_REFRESH_WYSIWYG:function(){if(!jQuery.browser.mozilla)return;this._disableWYSIWYG();this._enableWYSIWYG();},$ON_ENABLE_WYSIWYG:function(){this._enableWYSIWYG();},$ON_DISABLE_WYSIWYG:function(){this._disableWYSIWYG();},$ON_EVENT_EDITING_AREA_KEYUP:function(oEvent){if(oEvent.keyCode==229||oEvent.keyCode==13||oEvent.altKey||oEvent.ctrlKey||(oEvent.keyCode>=33&&oEvent.keyCode<=40)||oEvent.keyCode==16)return;this._recordUndo(oEvent);},$ON_PASTE_HTML:function(sHTML,oPSelection){if(this.oApp.getEditingMode()!=this.sMode)return;var oSelection=oPSelection||this.oApp.getSelection();oSelection.pasteHTML(sHTML);if(!jQuery.browser.msie){var sTmpBookmark=oSelection.placeStringBookmark();this.oApp.getWYSIWYGDocument().body.innerHTML=this.oApp.getWYSIWYGDocument().body.innerHTML;oSelection.moveToBookmark(sTmpBookmark);oSelection.collapseToEnd();oSelection.select();oSelection.removeStringBookmark(sTmpBookmark);}
this.oApp.exec("RECORD_UNDO_ACTION",["INSERT HTML"]);},$AFTER_MSG_EDITING_AREA_RESIZE_ENDED:function(FnMouseDown,FnMouseMove,FnMouseUp){this.oApp.exec("REFRESH_WYSIWYG",[]);},$ON_RESTORE_IE_SELECTION:function(){if(this._oIERange){this._oIERange.select();this._oPrevIERange=this._oIERange;this._oIERange=null;}},initIframe:function(){try{this.doc=this.iframe.contentWindow.document;if(this.doc==null||this.doc.location.href=='about:blank'){throw new Error('Access denied');}
this._enableWYSIWYG();this.status=xe.PLUGIN_STATUS["READY"];}catch(e){if(this._nIFrameReadyCount-->0){setTimeout(jQuery.fnBind(this.initIframe,this),100);}else{throw("iframe for WYSIWYG editing mode can't be initialized. Please check if the iframe document exists and is also accessable(cross-domain issues). ");}}},getIR:function(){var sContent=this.doc.body.innerHTML;var sIR;if(this.oApp.applyConverter)
sIR=this.oApp.applyConverter(this.sMode+"_TO_IR",sContent);else
@ -246,4 +246,4 @@ stack.push({tag:m2,state:state});}else{var tags=[],t='';if(!stack.length)return'
if(t.state!='deleted')tags.push('</'+t.tag+'>');}while(stack.length&&t.tag!=m2);return tags.join('');}
return'<'+m1+m2+(m3?' '+m3:'')+'>';});if(stack.length){var t='';do{t=stack.pop();if(t.state!='deleted')sContent+='</'+t.tag+'>';}while(stack.length);}
return sContent;},IR_TO:function(sContent){return sContent;}});})(jQuery);xe.XE_Extension=jQuery.Class({name:"XE_Extension",seq:'',$init:function(elAppContainer,editor_sequence){this.seq=editor_sequence;this._assignHTMLObjects(elAppContainer);},_assignHTMLObjects:function(elAppContainer){this.elDropdownLayer=jQuery('DIV.xpress_xeditor_extension_layer',elAppContainer).get(0);},_removeAttrs:function(sContent){sContent=sContent.replace(/<img([^>]*?) xe_handled\s*=\s*".+?"([^>]*?)>/i,'<img$1 $2>');return sContent;},_addEvent:function(){if(this.oApp.getEditingMode()!='WYSIWYG')return;var doc=this.oApp.getWYSIWYGDocument();var seq=this.seq;var fn=function(){var img=jQuery(this);var comp=img.attr('editor_component');if(comp&&jQuery.isFunction(openComponent)){editorPrevNode=img.get(0);openComponent(comp,seq);}};jQuery('img[editor_component]',doc).each(function(){var img=jQuery(this);if(!img.attr('xe_handled')){img.attr('xe_handled','yes').dblclick(fn);}});},$ON_MSG_APP_READY:function(){this.oApp.exec('REGISTER_UI_EVENT',['extension','click','TOGGLE_EXTENSION_LAYER']);this.oApp.addConverter("WYSIWYG_TO_IR",this._removeAttrs);},$ON_TOGGLE_EXTENSION_LAYER:function(){this.oApp.exec('TOGGLE_TOOLBAR_ACTIVE_LAYER',[this.elDropdownLayer]);},$ON_CHANGE_EDITING_MODE:function(mode){this._addEvent();},$ON_PASTE_HTML:function(){this._addEvent();},$ON_LOAD_IR_FIELD:function(){this._addEvent();},$ON_SET_IR:function(){this._addEvent();}});xe.XE_AutoSave=jQuery.Class({name:"XE_AutoSave",form:null,textarea:null,$init:function(oIRTextarea,elAppContainer){this.form=oIRTextarea.form;this.textarea=oIRTextarea;this._assignHTMLObjects(elAppContainer);},_assignHTMLObjects:function(elAppContainer){this.welMessageBox=jQuery('autosave_message');},$ON_MSG_APP_READY:function(){var elTitle=jQuery(this.form._saved_doc_title);var elContent=jQuery(this.form._saved_doc_content);var title=jQuery.trim(elTitle.val());var content=jQuery.trim(elContent.val());if(title||content){if(confirm(this.form._saved_doc_message.value)){jQuery(this.form.title).val(title);this.oApp.setIR(content);}else{editorRemoveSavedDoc();}}
editorEnableAutoSave(this.form,jQuery(this.form).attr("editor_sequence"));this.oApp.exec('REGISTER_HOTKEY',['ctrl+shift+s','AUTO_SAVE']);},$ON_AUTO_SAVE:function(){_editorAutoSave();}});xe.XE_FormatWithSelectUI=jQuery.Class({name:"XE_FormatWithSelectUI",$init:function(elAppContainer){this._assignHTMLObjects(elAppContainer);},_assignHTMLObjects:function(elAppContainer){this.elFormatSelect=jQuery("SELECT.xpress_xeditor_ui_format_select",elAppContainer).get(0);},$ON_MSG_APP_READY:function(){this.oApp.registerBrowserEvent(this.elFormatSelect,"change","SET_FORMAT_FROM_SELECT_UI");this.elFormatSelect.selectedIndex=0;},$ON_MSG_STYLE_CHANGED:function(sAttributeName,sAttributeValue){var blockName=this.oApp.getWYSIWYGDocument().queryCommandValue("FormatBlock");this.elFormatSelect.value=blockName.toLowerCase();if(this.elFormatSelect.selectedIndex<0)this.elFormatSelect.selectedIndex=0;},$ON_SET_FORMAT_FROM_SELECT_UI:function(){var sFormat=this.elFormatSelect.value;if(!sFormat)return;this.oApp.exec("EXECCOMMAND",["FormatBlock",false,sFormat]);this.oApp.exec("CHECK_STYLE_CHANGE",[]);}});
editorEnableAutoSave(this.form,jQuery(this.form).attr("editor_sequence"));this.oApp.exec('REGISTER_HOTKEY',['ctrl+shift+s','AUTO_SAVE']);},$ON_AUTO_SAVE:function(){_editorAutoSave();}});xe.XE_FormatWithSelectUI=jQuery.Class({name:"XE_FormatWithSelectUI",$init:function(elAppContainer){this._assignHTMLObjects(elAppContainer);},_assignHTMLObjects:function(elAppContainer){this.elFormatSelect=jQuery("SELECT.xpress_xeditor_ui_format_select",elAppContainer).get(0);},$ON_MSG_APP_READY:function(){this.oApp.registerBrowserEvent(this.elFormatSelect,"change","SET_FORMAT_FROM_SELECT_UI");this.elFormatSelect.selectedIndex=0;},$ON_MSG_STYLE_CHANGED:function(sAttributeName,sAttributeValue){var blockName=this.oApp.getWYSIWYGDocument().queryCommandValue("FormatBlock");if(!blockName)return(this.elFormatSelect.selectedIndex=0);this.elFormatSelect.value=blockName.toLowerCase();if(this.elFormatSelect.selectedIndex<0)this.elFormatSelect.selectedIndex=0;},$ON_SET_FORMAT_FROM_SELECT_UI:function(){var sFormat=this.elFormatSelect.value;if(!sFormat)return;this.oApp.exec("EXECCOMMAND",["FormatBlock",false,sFormat]);this.oApp.exec("CHECK_STYLE_CHANGE",[]);}});

View file

@ -1,166 +1,179 @@
if (!window.xe) xe = {};
xe.Editors = [];
function editorStart_xe(editor_sequence, primary_key, content_key, editor_height) {
var textarea = jQuery("#xpress-editor-"+editor_sequence);
var iframe = jQuery('<iframe id="editor_iframe_'+editor_sequence+'"frameborder="0" src="'+editor_path+'/blank.html" scrolling="yes" style="z-index:1;width:100%;height:'+editor_height+'px">');
var htmlsrc = jQuery('<textarea rows="10" cols="20" class="input_syntax" style="display:none"></textarea>');
var form = textarea.get(0).form;
form.setAttribute('editor_sequence', editor_sequence);
var saved_content = '';
if(jQuery("input[name=content]",form).size()>0){
saved_content=jQuery("input[name=content]",form).val().replace(/src=\"files\/attach/g,'src="'+request_uri+'files/attach');
jQuery("#xpress-editor-"+editor_sequence).val(saved_content);
}
/*
// remove procFilter
if(form.comment_srl){
form.onsubmit=function(){
var content = editorGetContent(editor_sequence);
editorRelKeys[editor_sequence]['content'].value = content;
insert_comment(form);
return false;
};
}else{
form.onsubmit=function(){
var content = editorGetContent(editor_sequence);
editorRelKeys[editor_sequence]['content'].value = content;
insert(form);
return false;
};
}
*/
// hide textarea
textarea.hide().css('width', '99%').before(iframe).after(htmlsrc);
// create an editor
var oEditor = new xe.XpressCore();
var oWYSIWYGIFrame = iframe.get(0);
var oIRTextarea = textarea.get(0);
var oHTMLSrcTextarea = htmlsrc.get(0);
var elAppContainer = jQuery('.xpress-editor', form).get(0);
oEditor.getFrame = function(){ return oWYSIWYGIFrame;}
// Set standard API
editorRelKeys[editor_sequence] = new Array();
editorRelKeys[editor_sequence]["primary"] = form[primary_key];
editorRelKeys[editor_sequence]["content"] = form[content_key];
editorRelKeys[editor_sequence]["func"] = editorGetContentTextarea_xe;
editorRelKeys[editor_sequence]["editor"] = oEditor;
editorRelKeys[editor_sequence]["pasteHTML"] = function(text){
oEditor.exec('PASTE_HTML',[text]);
}
xe.Editors[editor_sequence] = oEditor;
// register plugins
oEditor.registerPlugin(new xe.CorePlugin(null));
oEditor.registerPlugin(new xe.StringConverterManager());
oEditor.registerPlugin(new xe.XE_EditingAreaManager("WYSIWYG", oIRTextarea, {nHeight:parseInt(editor_height), nMinHeight:205}, null, elAppContainer));
oEditor.registerPlugin(new xe.XE_EditingArea_WYSIWYG(oWYSIWYGIFrame));
oEditor.registerPlugin(new xe.XE_EditingArea_HTMLSrc(oHTMLSrcTextarea));
oEditor.registerPlugin(new xe.XE_EditingAreaVerticalResizer(elAppContainer));
oEditor.registerPlugin(new xe.Utils());
oEditor.registerPlugin(new xe.DialogLayerManager());
oEditor.registerPlugin(new xe.ActiveLayerManager());
oEditor.registerPlugin(new xe.XpressRangeManager(oWYSIWYGIFrame));
oEditor.registerPlugin(new xe.Hotkey());
oEditor.registerPlugin(new xe.XE_WYSIWYGStyler());
oEditor.registerPlugin(new xe.XE_WYSIWYGStyleGetter());
oEditor.registerPlugin(new xe.XE_Toolbar(elAppContainer));
oEditor.registerPlugin(new xe.XE_ExecCommand(oWYSIWYGIFrame));
oEditor.registerPlugin(new xe.XE_ColorPalette(elAppContainer));
oEditor.registerPlugin(new xe.XE_FontColor(elAppContainer));
oEditor.registerPlugin(new xe.XE_BGColor(elAppContainer));
oEditor.registerPlugin(new xe.XE_Quote(elAppContainer));
oEditor.registerPlugin(new xe.XE_FontNameWithSelectUI(elAppContainer));
oEditor.registerPlugin(new xe.XE_FontSizeWithSelectUI(elAppContainer));
oEditor.registerPlugin(new xe.XE_LineHeightWithSelectUI(elAppContainer));
oEditor.registerPlugin(new xe.XE_UndoRedo());
oEditor.registerPlugin(new xe.XE_Table(elAppContainer));
oEditor.registerPlugin(new xe.XE_Hyperlink(elAppContainer));
oEditor.registerPlugin(new xe.XE_EditingModeToggler(elAppContainer));
oEditor.registerPlugin(new xe.MessageManager(oMessageMap));
oEditor.registerPlugin(new xe.XE_SCharacter(elAppContainer));
oEditor.registerPlugin(new xe.XE_FindReplacePlugin(elAppContainer));
oEditor.registerPlugin(new xe.XE_XHTMLConverter);
oEditor.registerPlugin(new xe.XE_Preview(elAppContainer));
oEditor.registerPlugin(new xe.XE_GET_WYSYWYG_MODE(editor_sequence));
oEditor.registerPlugin(new xe.XE_Extension(elAppContainer, editor_sequence));
oEditor.registerPlugin(new xe.XE_FormatWithSelectUI(elAppContainer));
if (!jQuery.browser.msie && !jQuery.browser.opera) {
oEditor.registerPlugin(new xe.XE_WYSIWYGEnterKey(oWYSIWYGIFrame));
}
// 자동 저장 사용?
if (s=form._saved_doc_title) {
oEditor.registerPlugin(new xe.XE_AutoSave(oIRTextarea, elAppContainer));
}
// run
oEditor.run();
return oEditor;
}
function editorGetContentTextarea_xe(editor_sequence) {
var oEditor = xe.Editors[editor_sequence] || null;
if (!oEditor) return '';
return oEditor.getIR();
}
function editorGetIframe(srl) {
return jQuery('iframe#editor_iframe_'+srl).get(0);
}
function editorReplaceHTML(iframe_obj, text) {
var srl = parseInt(iframe_obj.id.replace(/^.*_/,''),10);
editorRelKeys[srl]["pasteHTML"](text);
}
// WYSIWYG 모드를 저장하는 확장기능
xe.XE_GET_WYSYWYG_MODE = jQuery.Class({
name : "XE_GET_WYSYWYG_MODE",
$init : function(editor_sequence) {
this.editor_sequence = editor_sequence;
},
$ON_CHANGE_EDITING_MODE : function(mode) {
editorMode[this.editor_sequence] = (mode =='HTMLSrc') ? 'html' : 'wysiwyg';
}
});
// 미리보기 확장기능
xe.XE_Preview = jQuery.Class({
name : "XE_Preview",
elPreviewButton : null,
$init : function(elAppContainer) {
this._assignHTMLObjects(elAppContainer);
},
_assignHTMLObjects : function(elAppContainer) {
this.elPreviewButton = jQuery("BUTTON.xpress_xeditor_preview_button", elAppContainer);
},
$ON_MSG_APP_READY : function() {
this.oApp.registerBrowserEvent(this.elPreviewButton.get(0), "click", "EVENT_PREVIEW", []);
},
$ON_EVENT_PREVIEW : function() {
// TODO : 버튼이 눌렸을 때의 동작 정의
}
});
if (!window.xe) xe = {};
xe.Editors = [];
function editorStart_xe(editor_sequence, primary_key, content_key, editor_height) {
var textarea = jQuery("#xpress-editor-"+editor_sequence);
var iframe = jQuery('<iframe id="editor_iframe_'+editor_sequence+'"frameborder="0" src="'+editor_path+'/blank.html" scrolling="yes" style="z-index:1;width:100%;height:'+editor_height+'px">');
var htmlsrc = jQuery('<textarea rows="10" cols="20" class="input_syntax" style="display:none"></textarea>');
var form = textarea.get(0).form;
form.setAttribute('editor_sequence', editor_sequence);
var saved_content = '';
if(jQuery("input[name=content]",form).size()>0){
saved_content=jQuery("input[name=content]",form).val().replace(/src=\"files\/attach/g,'src="'+request_uri+'files/attach'); //'
jQuery("#xpress-editor-"+editor_sequence).val(saved_content);
}
/*
// remove procFilter
if(form.comment_srl){
form.onsubmit=function(){
var content = editorGetContent(editor_sequence);
editorRelKeys[editor_sequence]['content'].value = content;
insert_comment(form);
return false;
};
}else{
form.onsubmit=function(){
var content = editorGetContent(editor_sequence);
editorRelKeys[editor_sequence]['content'].value = content;
insert(form);
return false;
};
}
*/
// hide textarea
textarea.hide().css('width', '99%').before(iframe).after(htmlsrc);
// create an editor
var oEditor = new xe.XpressCore();
var oWYSIWYGIFrame = iframe.get(0);
var oIRTextarea = textarea.get(0);
var oHTMLSrcTextarea = htmlsrc.get(0);
var elAppContainer = jQuery('.xpress-editor', form).get(0);
oEditor.getFrame = function(){ return oWYSIWYGIFrame;}
// Set standard API
editorRelKeys[editor_sequence] = new Array();
editorRelKeys[editor_sequence]["primary"] = form[primary_key];
editorRelKeys[editor_sequence]["content"] = form[content_key];
editorRelKeys[editor_sequence]["func"] = editorGetContentTextarea_xe;
editorRelKeys[editor_sequence]["editor"] = oEditor;
editorRelKeys[editor_sequence]["pasteHTML"] = function(text){
oEditor.exec('PASTE_HTML',[text]);
}
xe.Editors[editor_sequence] = oEditor;
// register plugins
oEditor.registerPlugin(new xe.CorePlugin(null));
oEditor.registerPlugin(new xe.StringConverterManager());
oEditor.registerPlugin(new xe.XE_EditingAreaManager("WYSIWYG", oIRTextarea, {nHeight:parseInt(editor_height), nMinHeight:205}, null, elAppContainer));
oEditor.registerPlugin(new xe.XE_EditingArea_HTMLSrc(oHTMLSrcTextarea));
oEditor.registerPlugin(new xe.XE_EditingAreaVerticalResizer(elAppContainer));
oEditor.registerPlugin(new xe.Utils());
oEditor.registerPlugin(new xe.DialogLayerManager());
oEditor.registerPlugin(new xe.ActiveLayerManager());
oEditor.registerPlugin(new xe.Hotkey());
oEditor.registerPlugin(new xe.XE_WYSIWYGStyler());
oEditor.registerPlugin(new xe.XE_WYSIWYGStyleGetter());
oEditor.registerPlugin(new xe.XE_Toolbar(elAppContainer));
oEditor.registerPlugin(new xe.XE_ColorPalette(elAppContainer));
oEditor.registerPlugin(new xe.XE_FontColor(elAppContainer));
oEditor.registerPlugin(new xe.XE_BGColor(elAppContainer));
oEditor.registerPlugin(new xe.XE_Quote(elAppContainer));
oEditor.registerPlugin(new xe.XE_FontNameWithSelectUI(elAppContainer));
oEditor.registerPlugin(new xe.XE_FontSizeWithSelectUI(elAppContainer));
oEditor.registerPlugin(new xe.XE_LineHeightWithSelectUI(elAppContainer));
oEditor.registerPlugin(new xe.XE_UndoRedo());
oEditor.registerPlugin(new xe.XE_Table(elAppContainer));
oEditor.registerPlugin(new xe.XE_Hyperlink(elAppContainer));
oEditor.registerPlugin(new xe.XE_EditingModeToggler(elAppContainer));
oEditor.registerPlugin(new xe.MessageManager(oMessageMap));
oEditor.registerPlugin(new xe.XE_SCharacter(elAppContainer));
oEditor.registerPlugin(new xe.XE_FindReplacePlugin(elAppContainer));
oEditor.registerPlugin(new xe.XE_XHTMLConverter);
oEditor.registerPlugin(new xe.XE_Preview(elAppContainer));
oEditor.registerPlugin(new xe.XE_GET_WYSYWYG_MODE(editor_sequence));
oEditor.registerPlugin(new xe.XE_Extension(elAppContainer, editor_sequence));
oEditor.registerPlugin(new xe.XE_FormatWithSelectUI(elAppContainer));
if (!jQuery.browser.msie && !jQuery.browser.opera) {
oEditor.registerPlugin(new xe.XE_WYSIWYGEnterKey(oWYSIWYGIFrame));
}
// 자동 저장 사용?
if (s=form._saved_doc_title) {
oEditor.registerPlugin(new xe.XE_AutoSave(oIRTextarea, elAppContainer));
}
function load_proc() {
try {
var doc = oWYSIWYGIFrame.contentWindow.document, str;
if (doc.location == 'about:blank') throw 'blank';
// get innerHTML
str = doc.body.innerHTML;
// register plugin
oEditor.registerPlugin(new xe.XE_EditingArea_WYSIWYG(oWYSIWYGIFrame));
oEditor.registerPlugin(new xe.XpressRangeManager(oWYSIWYGIFrame));
oEditor.registerPlugin(new xe.XE_ExecCommand(oWYSIWYGIFrame));
// run
oEditor.run();
} catch(e) {
setTimeout(load_proc, 0);
}
}
load_proc();
return oEditor;
}
function editorGetContentTextarea_xe(editor_sequence) {
var oEditor = xe.Editors[editor_sequence] || null;
if (!oEditor) return '';
return oEditor.getIR();
}
function editorGetIframe(srl) {
return jQuery('iframe#editor_iframe_'+srl).get(0);
}
function editorReplaceHTML(iframe_obj, text) {
var srl = parseInt(iframe_obj.id.replace(/^.*_/,''),10);
editorRelKeys[srl]["pasteHTML"](text);
}
// WYSIWYG 모드를 저장하는 확장기능
xe.XE_GET_WYSYWYG_MODE = jQuery.Class({
name : "XE_GET_WYSYWYG_MODE",
$init : function(editor_sequence) {
this.editor_sequence = editor_sequence;
},
$ON_CHANGE_EDITING_MODE : function(mode) {
editorMode[this.editor_sequence] = (mode =='HTMLSrc') ? 'html' : 'wysiwyg';
}
});
// 미리보기 확장기능
xe.XE_Preview = jQuery.Class({
name : "XE_Preview",
elPreviewButton : null,
$init : function(elAppContainer) {
this._assignHTMLObjects(elAppContainer);
},
_assignHTMLObjects : function(elAppContainer) {
this.elPreviewButton = jQuery("BUTTON.xpress_xeditor_preview_button", elAppContainer);
},
$ON_MSG_APP_READY : function() {
this.oApp.registerBrowserEvent(this.elPreviewButton.get(0), "click", "EVENT_PREVIEW", []);
},
$ON_EVENT_PREVIEW : function() {
// TODO : 버튼이 눌렸을 때의 동작 정의
}
});