public HtmlContentEditor(jQueryObject textArea, HtmlContentEditorOptions opt)
            : base(textArea, opt)
        {
            IncludeCKEditor();

            string id = textArea.GetAttribute("id");

            if (id.IsTrimmedEmpty())
            {
                textArea.Attribute("id", this.uniqueName);
                id = this.uniqueName;
            }

            if (options.Cols != null)
            {
                textArea.Attribute("cols", options.Cols.Value.ToString());
            }

            if (options.Rows != null)
            {
                textArea.Attribute("rows", options.Rows.Value.ToString());
            }

            var self = this;

            this.AddValidationRule(this.uniqueName, e =>
            {
                if (e.HasClass("required"))
                {
                    var value = self.Value.TrimToNull();
                    if (value == null)
                    {
                        return(Q.Text("Validation.Required"));
                    }
                }

                return(null);
            });

            LazyLoadHelper.ExecuteOnceWhenShown(this.element, () =>
            {
                var config = GetConfig();
                CKEditor.Replace(id, config);
            });
        }
Exemple #2
0
        protected virtual string GetLanguage()
        {
            var lang = J("html").GetAttribute("lang").TrimToNull() ?? "en";

            if (CKEditor.HasLanguage(lang))
            {
                return(lang);
            }

            if (lang.IndexOf('-') >= 0)
            {
                lang = lang.Split('-')[0];
            }

            if (CKEditor.HasLanguage(lang))
            {
                return(lang);
            }

            return("en");
        }