Ticket #7283: 7283_3.patch
File 7283_3.patch, 8.7 KB (added by , 13 years ago) |
---|
-
_dev/msajax.js
4 4 */ 5 5 6 6 // The following script is used in CKEditorControl:OnPreRender 7 var CKEditor_Controls = []; 7 var CKEditor_Controls = [], 8 CKEditor_Init = []; 8 9 9 10 function CKEditor_TextBoxEncode(cID, inUpdatePanel) { 10 11 if (typeof CKEDITOR == 'undefined' || typeof CKEDITOR.instances[cID] == 'undefined') { … … 25 26 var onload = function() 26 27 { 27 28 var ids = CKEditor_Controls, 29 initFunctions = CKEditor_Init, 28 30 oldPageLoad = window.pageLoad; 29 31 30 var fixValues = function() {31 for ( i = ids.length; i--;) {32 var loadEditors = function() { 33 for (var i = ids.length; i--;) { 32 34 var e = document.getElementById(ids[i]); 33 e.value = e.value.replace(/</g, '<').replace(/>/g, '>'); 35 if (e && e.value && (e.value.indexOf('<') ==-1 || e.value.indexOf('>') ==-1)) { 36 e.value = e.value.replace(/</g, '<').replace(/>/g, '>').replace(/&/g, '&'); 37 } 34 38 } 39 if (typeof CKEDITOR != 'undefined') { 40 for (var i = 0; i < initFunctions.length; i++) { 41 initFunctions[i].call(this); 42 } 43 } 35 44 }; 36 45 37 46 window.pageLoad = function(sender, args) { 38 47 if (args.get_isPartialLoad()) { 39 fixValues();48 setTimeout(loadEditors, 0); 40 49 } 41 if (oldPageLoad && typeof oldPageLoad == 'function') 42 oldPageLoad.call(this, sender, args); 50 if (oldPageLoad && typeof oldPageLoad == 'function') { 51 oldPageLoad.call(this, sender, args); 52 } 43 53 }; 44 54 45 fixValues();55 setTimeout(loadEditors, 0); 46 56 }; 47 57 48 58 if ( window.addEventListener ) -
CKEditor.NET/CKEditorControl.cs
21 21 [ToolboxData("<{0}:CKEditorControl runat=server></{0}:CKEditorControl>")] 22 22 [ParseChildren(false)] 23 23 [Designer("CKEditor.NET.CKEditorControlDesigner")] 24 public class CKEditorControl : TextBox 24 public class CKEditorControl : TextBox, IPostBackDataHandler 25 25 { 26 26 #region Changed TextBox Property 27 27 … … 32 32 { 33 33 get 34 34 { 35 if (!string.IsNullOrEmpty(base.Text))36 base.Text = base.Text.Replace("<", "<").Replace(">", ">").Replace("&", "&");37 35 return base.Text; 38 36 } 39 37 set 40 38 { 41 if (!string.IsNullOrEmpty(value))42 value = value.Replace("<", "<").Replace(">", ">").Replace("&", "&");43 39 base.Text = value; 44 40 } 45 41 } … … 999 995 { 1000 996 this.RegisterStartupScript(this.GetType(), "CKEDITOR_BASEPATH", string.Format("window.CKEDITOR_BASEPATH = '{0}/';\n", (this.CKEditorJSFile.StartsWith("~") ? this.ResolveUrl(this.BasePath) : this.BasePath)), true); 1001 997 this.RegisterStartupScript(this.GetType(), "ckeditor", "<script src=\"" + (this.CKEditorJSFile.StartsWith("~") ? this.ResolveUrl(this.CKEditorJSFile) : this.CKEditorJSFile) + timestamp + "\" type=\"text/javascript\"></script>", false); 1002 if (HasMsAjax) 1003 { 1004 string scriptInit = string.Empty; 998 string scriptInit = string.Empty; 1005 999 1006 1007 1008 1009 scriptInit += @"var CKEditor_Controls=[];function CKEditor_TextBoxEncode(c,d){if(typeof CKEDITOR=='undefined'||typeof CKEDITOR.instances[c]=='undefined'){var e=document.getElementById(c);e.value=e.value.replace(/</g,'<').replace(/>/g,'>');}else{var f=CKEDITOR.instances[c];if(d)f.destroy();else f.updateElement();}};(function(){var c=function(){var d=CKEditor_Controls,e=window.pageLoad,f=function(){for(i=d.length;i--;){var g=document.getElementById(d[i]);g.value=g.value.replace(/</g,'<').replace(/>/g,'>');}};window.pageLoad=function(g,h){if(h.get_isPartialLoad())f();if(e&&typeof e=='function')e.call(this,g,h);};f();};if(window.addEventListener)window.addEventListener('load',c,false);else if(window.attachEvent)window.attachEvent('onload',c);})();1000 // Sys.Application.add_load does not work on browsers != IE 1001 // http://msdn.microsoft.com/en-us/library/bb386417.aspx 1002 // Check _dev/msajax.js for an uncompressed version (available in CKEditor.Net downloaded from SVN). 1003 scriptInit += @"var CKEditor_Controls=[],CKEditor_Init=[];function CKEditor_TextBoxEncode(d,e){if(typeof CKEDITOR=='undefined'||typeof CKEDITOR.instances[d]=='undefined'){var f=document.getElementById(d);f.value=f.value.replace(/</g,'<').replace(/>/g,'>');}else{var g=CKEDITOR.instances[d];if(e)g.destroy();else g.updateElement();}};(function(){var d=function(){var e=CKEditor_Controls,f=CKEditor_Init,g=window.pageLoad,h=function(){for(var i=e.length;i--;){var j=document.getElementById(e[i]);if(j&&j.value&&(j.value.indexOf('<')==-1||j.value.indexOf('>')==-1))j.value=j.value.replace(/</g,'<').replace(/>/g,'>').replace(/&/g,'&');}if(typeof CKEDITOR!='undefined')for(var i=0;i<f.length;i++)f[i].call(this);};window.pageLoad=function(i,j){if(j.get_isPartialLoad())setTimeout(h,0);if(g&&typeof g=='function')g.call(this,i,j);};setTimeout(h,0);};if(window.addEventListener)window.addEventListener('load',d,false);else if(window.attachEvent)window.attachEvent('onload',d);})(); 1010 1004 "; 1011 1012 this.RegisterStartupScript(this.GetType(), "CKEditorForNet", scriptInit, true); 1013 this.RegisterStartupScript(this.GetType(), this.ClientID + @"_addControl", string.Format(@"CKEditor_Controls.push('{0}'); 1005 this.RegisterStartupScript(this.GetType(), "CKEditorForNet", scriptInit, true); 1006 this.RegisterStartupScript(this.GetType(), this.ClientID + @"_addControl", string.Format(@"CKEditor_Controls.push('{0}'); 1014 1007 ", this.ClientID), true); 1015 }1016 1008 string script = string.Empty; 1017 1009 if (this.config.CKEditorEventHandler != null) 1018 1010 foreach (object[] item in this.config.CKEditorEventHandler) 1019 1011 { 1020 script += string.Format(@" if(typeof CKEDITOR != 'undefined') CKEDITOR.on('{0}',{1});1012 script += string.Format(@"CKEditor_Init.push(function(){{CKEDITOR.on('{0}',{1});}}); 1021 1013 ", item[0], item[1]); 1022 1014 } 1023 script += string.Format(@"if(typeof CKEDITOR != 'undefined') CKEDITOR.replace('{0}',{1}); 1015 if (this.config.protectedSource != null && this.config.protectedSource.Length > 0) 1016 { 1017 string proSour = string.Empty; 1018 foreach (string item in this.config.protectedSource) 1019 proSour += @" 1020 ckeditor.config.protectedSource.push( " + item + " );"; 1021 script += string.Format(@"CKEditor_Init.push(function(){{if(typeof CKEDITOR.instances['{0}']!='undefined') return;var ckeditor = CKEDITOR.replace('{0}',{1}); {2}}}); 1022 ", this.ClientID, prepareJSON(), proSour); 1023 } 1024 else 1025 script += string.Format(@"CKEditor_Init.push(function(){{if(typeof CKEDITOR.instances['{0}']!='undefined') return;CKEDITOR.replace('{0}',{1});}}); 1024 1026 ", this.ClientID, prepareJSON()); 1025 1027 1026 if (HasMsAjax)1027 {1028 bool isInUpdatePanel = false;1029 Control con = this.Parent;1030 if (updatePanel != null)1031 while (con != null)1028 bool isInUpdatePanel = false; 1029 Control con = this.Parent; 1030 if (updatePanel != null) 1031 while (con != null) 1032 { 1033 if (con.GetType() == updatePanel) 1032 1034 { 1033 if (con.GetType() == updatePanel) 1034 { 1035 isInUpdatePanel = true; 1036 break; 1037 } 1038 con = con.Parent; 1035 isInUpdatePanel = true; 1036 break; 1039 1037 } 1040 this.RegisterOnSubmitStatement(this.GetType(), "aspintegrator_Postback" + this.ClientID, string.Format("CKEditor_TextBoxEncode('{0}', {1}); ", this.ClientID, isInUpdatePanel ? 1 : 0)); 1041 } 1038 con = con.Parent; 1039 } 1040 this.RegisterOnSubmitStatement(this.GetType(), "aspintegrator_Postback" + this.ClientID, string.Format("CKEditor_TextBoxEncode('{0}', {1}); ", this.ClientID, isInUpdatePanel ? 1 : 0)); 1042 1041 this.RegisterStartupScript(this.GetType(), "aspintegratorInitial_" + this.ClientID, script, true); 1043 1042 } 1044 1043 … … 1052 1051 } 1053 1052 1054 1053 #endregion 1054 1055 #region IPostBackDataHandler 1056 1057 bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection) 1058 { 1059 if (this.config.htmlEncodeOutput) 1060 { 1061 string postedValue = postCollection[postDataKey]; 1062 postedValue = postedValue.Replace("<", "<").Replace(">", ">").Replace("&", "&"); 1063 if (this.Text != postedValue) 1064 { 1065 this.Text = postedValue; 1066 return true; 1067 } 1068 } 1069 return false; 1070 } 1071 1072 void IPostBackDataHandler.RaisePostDataChangedEvent() { } 1073 1074 #endregion 1055 1075 } 1056 1076 1057 1077 public class CKEditorControlDesigner : System.Web.UI.Design.ControlDesigner