Beispiel #1
0
 public Element(HtmlBuilder builder, string elementName)
 {
     _builder = builder;
     _builder.Writer.Write("<" + elementName);
     End = delegate 
     {
         this.CloseOpeningElement();
         this._builder.Writer.Write("</" + elementName + ">");
     };
 }
Beispiel #2
0
        protected override void RenderMuxControl(Magix.UX.Builder.HtmlBuilder builder)
        {
            using (Element el = builder.CreateElement("div"))
            {
                AddAttributes(el);

                using (Element bar = builder.CreateElement("div"))
                {
                    bar.AddAttribute("id", ClientID + "_editortoolbar");
                    bar.AddAttribute("class", "wysiwyg-editor-toolbar");
                    bar.AddAttribute("style", "display:none;");

                    using (Element header = builder.CreateElement("header"))
                    {
                        using (Element ul = builder.CreateElement("ul"))
                        {
                            ul.AddAttribute("class", "commands");
                            if (HasBold)
                            {
                                using (Element li = builder.CreateElement("li"))
                                {
                                    li.AddAttribute("data-wysihtml5-command", "bold");
                                    li.AddAttribute("title", "make text bold (ctrl + b)");
                                    li.AddAttribute("class", "command");
                                }
                            }
                            if (HasItalic)
                            {
                                using (Element li = builder.CreateElement("li"))
                                {
                                    li.AddAttribute("data-wysihtml5-command", "italic");
                                    li.AddAttribute("title", "make text italic (ctrl + i)");
                                    li.AddAttribute("class", "command");
                                }
                            }
                            if (HasUnorderedList)
                            {
                                using (Element li = builder.CreateElement("li"))
                                {
                                    li.AddAttribute("data-wysihtml5-command", "insertUnorderedList");
                                    li.AddAttribute("title", "insert an unordered list");
                                    li.AddAttribute("class", "command");
                                }
                            }
                            if (HasOrderedList)
                            {
                                using (Element li = builder.CreateElement("li"))
                                {
                                    li.AddAttribute("data-wysihtml5-command", "insertOrderedList");
                                    li.AddAttribute("title", "insert an ordered list");
                                    li.AddAttribute("class", "command");
                                }
                            }
                            if (HasCreateLink)
                            {
                                using (Element li = builder.CreateElement("li"))
                                {
                                    li.AddAttribute("data-wysihtml5-command", "createLink");
                                    li.AddAttribute("title", "insert a link");
                                    li.AddAttribute("class", "command");
                                }
                            }
                            if (HasInsertImage)
                            {
                                using (Element li = builder.CreateElement("li"))
                                {
                                    li.AddAttribute("data-wysihtml5-command", "insertImage");
                                    li.AddAttribute("title", "insert an image");
                                    li.AddAttribute("class", "command");
                                }
                            }
                            if (HasH1)
                            {
                                using (Element li = builder.CreateElement("li"))
                                {
                                    li.AddAttribute("data-wysihtml5-command", "formatBlock");
                                    li.AddAttribute("data-wysihtml5-command-value", "h1");
                                    li.AddAttribute("title", "insert headline 1");
                                    li.AddAttribute("class", "command");
                                }
                            }
                            if (HasH2)
                            {
                                using (Element li = builder.CreateElement("li"))
                                {
                                    li.AddAttribute("data-wysihtml5-command", "formatBlock");
                                    li.AddAttribute("data-wysihtml5-command-value", "h2");
                                    li.AddAttribute("title", "insert headline 2");
                                    li.AddAttribute("class", "command");
                                }
                            }
                            if (HasH3)
                            {
                                using (Element li = builder.CreateElement("li"))
                                {
                                    li.AddAttribute("data-wysihtml5-command", "formatBlock");
                                    li.AddAttribute("data-wysihtml5-command-value", "h3");
                                    li.AddAttribute("title", "insert headline 3");
                                    li.AddAttribute("class", "command");
                                }
                            }
                            if (HasH4)
                            {
                                using (Element li = builder.CreateElement("li"))
                                {
                                    li.AddAttribute("data-wysihtml5-command", "formatBlock");
                                    li.AddAttribute("data-wysihtml5-command-value", "h4");
                                    li.AddAttribute("title", "insert headline 4");
                                    li.AddAttribute("class", "command");
                                }
                            }
                            if (HasH5)
                            {
                                using (Element li = builder.CreateElement("li"))
                                {
                                    li.AddAttribute("data-wysihtml5-command", "formatBlock");
                                    li.AddAttribute("data-wysihtml5-command-value", "h5");
                                    li.AddAttribute("title", "insert headline 5");
                                    li.AddAttribute("class", "command");
                                }
                            }
                            if (HasH6)
                            {
                                using (Element li = builder.CreateElement("li"))
                                {
                                    li.AddAttribute("data-wysihtml5-command", "formatBlock");
                                    li.AddAttribute("data-wysihtml5-command-value", "h6");
                                    li.AddAttribute("title", "insert headline 6");
                                    li.AddAttribute("class", "command");
                                }
                            }
                            if (HasForeColor)
                            {
                                using (Element li = builder.CreateElement("li"))
                                {
                                    li.AddAttribute("data-wysihtml5-command-group", "foreColor");
                                    li.AddAttribute("title", "color the selected text");
                                    li.AddAttribute("class", "fore-color");
                                    using (Element ul2 = builder.CreateElement("ul"))
                                    {
                                        using (Element li2 = builder.CreateElement("li"))
                                        {
                                            li2.AddAttribute("data-wysihtml5-command", "foreColor");
                                            li2.AddAttribute("data-wysihtml5-command-value", "silver");
                                        }
                                        using (Element li2 = builder.CreateElement("li"))
                                        {
                                            li2.AddAttribute("data-wysihtml5-command", "foreColor");
                                            li2.AddAttribute("data-wysihtml5-command-value", "gray");
                                        }
                                        using (Element li2 = builder.CreateElement("li"))
                                        {
                                            li2.AddAttribute("data-wysihtml5-command", "foreColor");
                                            li2.AddAttribute("data-wysihtml5-command-value", "maroon");
                                        }
                                        using (Element li2 = builder.CreateElement("li"))
                                        {
                                            li2.AddAttribute("data-wysihtml5-command", "foreColor");
                                            li2.AddAttribute("data-wysihtml5-command-value", "red");
                                        }
                                        using (Element li2 = builder.CreateElement("li"))
                                        {
                                            li2.AddAttribute("data-wysihtml5-command", "foreColor");
                                            li2.AddAttribute("data-wysihtml5-command-value", "purple");
                                        }
                                        using (Element li2 = builder.CreateElement("li"))
                                        {
                                            li2.AddAttribute("data-wysihtml5-command", "foreColor");
                                            li2.AddAttribute("data-wysihtml5-command-value", "green");
                                        }
                                        using (Element li2 = builder.CreateElement("li"))
                                        {
                                            li2.AddAttribute("data-wysihtml5-command", "foreColor");
                                            li2.AddAttribute("data-wysihtml5-command-value", "olive");
                                        }
                                        using (Element li2 = builder.CreateElement("li"))
                                        {
                                            li2.AddAttribute("data-wysihtml5-command", "foreColor");
                                            li2.AddAttribute("data-wysihtml5-command-value", "navy");
                                        }
                                        using (Element li2 = builder.CreateElement("li"))
                                        {
                                            li2.AddAttribute("data-wysihtml5-command", "foreColor");
                                            li2.AddAttribute("data-wysihtml5-command-value", "blue");
                                        }
                                    }
                                }
                            }
                            if (HasInsertSpeech)
                            {
                                using (Element li = builder.CreateElement("li"))
                                {
                                    li.AddAttribute("data-wysihtml5-command", "insertSpeech");
                                    li.AddAttribute("title", "insert speech");
                                    li.AddAttribute("class", "command");
                                }
                            }
                            if (HasChangeView)
                            {
                                using (Element li = builder.CreateElement("li"))
                                {
                                    li.AddAttribute("data-wysihtml5-action", "change_view");
                                    li.AddAttribute("title", "show html");
                                    li.AddAttribute("class", "action");
                                }
                            }
                        }
                    }
                    if (HasCreateLink)
                    {
                        using (Element cr = builder.CreateElement("div"))
                        {
                            cr.AddAttribute("data-wysihtml5-dialog", "createLink");
                            cr.AddAttribute("style", "display:none;");
                            using (Element lbl = builder.CreateElement("label"))
                            {
                                lbl.Write("link:");
                                using (Element inp = builder.CreateElement("input"))
                                {
                                    inp.AddAttribute("data-wysihtml5-dialog-field", "href");
                                    inp.AddAttribute("value", "http://");
                                }
                            }
                            using (Element anc = builder.CreateElement("a"))
                            {
                                anc.AddAttribute("data-wysihtml5-dialog-action", "save");
                                anc.Write("ok");
                            }
                            cr.Write("&nbsp;");
                            using (Element anc = builder.CreateElement("a"))
                            {
                                anc.AddAttribute("data-wysihtml5-dialog-action", "cancel");
                                anc.Write("cancel");
                            }
                        }
                    }
                    if (HasInsertImage)
                    {
                        using (Element cr = builder.CreateElement("div"))
                        {
                            cr.AddAttribute("data-wysihtml5-dialog", "insertImage");
                            cr.AddAttribute("style", "display:none;");
                            using (Element lbl = builder.CreateElement("label"))
                            {
                                lbl.Write("image:");
                                using (Element inp = builder.CreateElement("input"))
                                {
                                    inp.AddAttribute("data-wysihtml5-dialog-field", "src");
                                    inp.AddAttribute("value", "http://");
                                }
                            }
                            using (Element anc = builder.CreateElement("a"))
                            {
                                anc.AddAttribute("data-wysihtml5-dialog-action", "save");
                                anc.Write("ok");
                            }
                            cr.Write("&nbsp;");
                            using (Element anc = builder.CreateElement("a"))
                            {
                                anc.AddAttribute("data-wysihtml5-dialog-action", "cancel");
                                anc.Write("cancel");
                            }
                        }
                    }
                }

                using (Element txt = builder.CreateElement("textarea"))
                {
                    txt.AddAttribute("id", ClientID + "_text");
                    txt.AddAttribute("name", ClientID + "_text");
                    txt.AddAttribute("class", "wysiwyg-editor-textarea");
                    if (PlaceHolder != null)
                    {
                        txt.AddAttribute("placeholder", PlaceHolder);
                    }
                    txt.Write(Value);
                }
                RenderChildren(builder.Writer as System.Web.UI.HtmlTextWriter);
            }
        }