Ticket #7925: 7925.patch

File 7925.patch, 3.9 KB (added by kaga, 12 years ago)
  • CKEditorControl.cs

     
    4444
    4545                #endregion
    4646
     47                #region Event Save
     48
     49                public event EventHandler<EventArgs> Save;
     50
     51                #endregion
     52
    4753                #region Private Property
    4854
    4955                private string CKEditorJSFile
     
    9096                        get
    9197                        {
    9298                                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);
    94100                                return (CKEditorConfig)ViewState["CKEditorConfig"];
    95101                        }
    96102                        set { ViewState["CKEditorConfig"] = value; }
     
    10151021                public CKEditorControl()
    10161022                {
    10171023                        base.TextMode = TextBoxMode.MultiLine;
    1018                         this.config = new CKEditorConfig(this.BasePath.StartsWith("~") ? this.ResolveUrl(this.BasePath) : this.BasePath);
    10191024                }
    10201025
    10211026                #endregion
     
    10301035                        string scriptInit = string.Empty;
    10311036                        string doPostBackScript = string.Empty;
    10321037                        if (this.AutoPostBack) doPostBackScript = string.Format(@"CKEDITOR.instances['{0}'].on('blur', function() {{if(this.checkDirty()){{javascript:setTimeout('__doPostBack(\'{0}\',\'\')',0); }}}});", this.ClientID);
    1033                        
     1038
    10341039                        // Sys.Application.add_load does not work on browsers != IE
    10351040                        // http://msdn.microsoft.com/en-us/library/bb386417.aspx
    10361041                        // Check _dev/msajax.js for an uncompressed version (available in CKEditor.Net downloaded from SVN).
     
    10521057                                foreach (string item in this.config.protectedSource)
    10531058                                        proSour += @"
    10541059ckeditor.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}}});
    10561061", this.ClientID, prepareJSON(), proSour, doPostBackScript);
    10571062                        }
    10581063                        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} }});
    10601065", this.ClientID, prepareJSON(), doPostBackScript);
    10611066
    10621067                        bool isInUpdatePanel = false;
     
    10761081                        if (isChanged) OnTextChanged(e);
    10771082                }
    10781083
     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                }
    10791095                #endregion
    10801096
    10811097                #region Private Method
     
    10851101                        return JSONSerializer.ToJavaScriptObjectNotation(this.config);
    10861102                }
    10871103
     1104                private void OnSave(object sender, EventArgs e)
     1105                {
     1106                        if (Save != null)
     1107                        {
     1108                                Save(this, EventArgs.Empty);
     1109                        }
     1110                }
     1111
    10881112                #endregion
    10891113
    10901114                #region IPostBackDataHandler
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy