Ticket #7925: 7925.patch
File 7925.patch, 3.9 KB (added by , 13 years ago) |
---|
-
CKEditorControl.cs
44 44 45 45 #endregion 46 46 47 #region Event Save 48 49 public event EventHandler<EventArgs> Save; 50 51 #endregion 52 47 53 #region Private Property 48 54 49 55 private string CKEditorJSFile … … 90 96 get 91 97 { 92 98 if (ViewState["CKEditorConfig"] == null) 93 ViewState["CKEditorConfig"] = new CKEditorConfig(this.BasePath );99 ViewState["CKEditorConfig"] = new CKEditorConfig(this.BasePath.StartsWith("~") ? this.ResolveUrl(this.BasePath) : this.BasePath); 94 100 return (CKEditorConfig)ViewState["CKEditorConfig"]; 95 101 } 96 102 set { ViewState["CKEditorConfig"] = value; } … … 1015 1021 public CKEditorControl() 1016 1022 { 1017 1023 base.TextMode = TextBoxMode.MultiLine; 1018 this.config = new CKEditorConfig(this.BasePath.StartsWith("~") ? this.ResolveUrl(this.BasePath) : this.BasePath);1019 1024 } 1020 1025 1021 1026 #endregion … … 1030 1035 string scriptInit = string.Empty; 1031 1036 string doPostBackScript = string.Empty; 1032 1037 if (this.AutoPostBack) doPostBackScript = string.Format(@"CKEDITOR.instances['{0}'].on('blur', function() {{if(this.checkDirty()){{javascript:setTimeout('__doPostBack(\'{0}\',\'\')',0); }}}});", this.ClientID); 1033 1038 1034 1039 // Sys.Application.add_load does not work on browsers != IE 1035 1040 // http://msdn.microsoft.com/en-us/library/bb386417.aspx 1036 1041 // Check _dev/msajax.js for an uncompressed version (available in CKEditor.Net downloaded from SVN). … … 1052 1057 foreach (string item in this.config.protectedSource) 1053 1058 proSour += @" 1054 1059 ckeditor.config.protectedSource.push( " + item + " );"; 1055 script += string.Format(@"CKEditor_Init.push(function(){{if(typeof CKEDITOR.instances['{0}']!='undefined' || !document.getElementById('{0}')) return; var ckeditor = CKEDITOR.replace('{0}',{1});{2} {3}}});1060 script += string.Format(@"CKEditor_Init.push(function(){{if(typeof CKEDITOR.instances['{0}']!='undefined' || !document.getElementById('{0}')) return; var ckeditor = CKEDITOR.replace('{0}',{1}); if(ckeditor){{ ckeditor.on('beforeCommandExec', function(evt) {{ if (evt.data.name=='save') {{document.getElementById('{0}_Save').value = '1';}}}});}} {2} {3}}}); 1056 1061 ", this.ClientID, prepareJSON(), proSour, doPostBackScript); 1057 1062 } 1058 1063 else 1059 script += string.Format(@"CKEditor_Init.push(function(){{if(typeof CKEDITOR.instances['{0}']!='undefined' || !document.getElementById('{0}')) return; CKEDITOR.replace('{0}',{1}); {2}}});1064 script += string.Format(@"CKEditor_Init.push(function(){{if(typeof CKEDITOR.instances['{0}']!='undefined' || !document.getElementById('{0}')) return; var ckeditor = CKEDITOR.replace('{0}',{1}); if(ckeditor){{ ckeditor.on('beforeCommandExec', function(evt) {{ if (evt.data.name=='save') {{document.getElementById('{0}_Save').value = '1';}}}});}} {2} }}); 1060 1065 ", this.ClientID, prepareJSON(), doPostBackScript); 1061 1066 1062 1067 bool isInUpdatePanel = false; … … 1076 1081 if (isChanged) OnTextChanged(e); 1077 1082 } 1078 1083 1084 protected override void OnLoad(EventArgs e) 1085 { 1086 base.OnLoad(e); 1087 if (ViewState["CKEditorConfig"] != null) 1088 this.config = (CKEditorConfig)ViewState["CKEditorConfig"]; 1089 else 1090 this.config = new CKEditorConfig(this.BasePath.StartsWith("~") ? this.ResolveUrl(this.BasePath) : this.BasePath); 1091 if (this.Page.IsPostBack && this.Page.Request.Form[this.ClientID + "_Save"] == "1") 1092 OnSave(this, e); 1093 this.Page.RegisterHiddenField(this.ClientID + "_Save", "0"); 1094 } 1079 1095 #endregion 1080 1096 1081 1097 #region Private Method … … 1085 1101 return JSONSerializer.ToJavaScriptObjectNotation(this.config); 1086 1102 } 1087 1103 1104 private void OnSave(object sender, EventArgs e) 1105 { 1106 if (Save != null) 1107 { 1108 Save(this, EventArgs.Empty); 1109 } 1110 } 1111 1088 1112 #endregion 1089 1113 1090 1114 #region IPostBackDataHandler