Exemplo n.º 1
0
        public override string GetHTML(int deep = 0)
        {
            Childs.Clear();
            AddCSS("alert alert-" + StyleAlert.ToString("g"), true);
            if (isDismissible)
            {
                AddCSS("alert-dismissible fade show", true);
            }

            css_style = "min-height: 50px;";
            SetAttribute("role", "alert");

            if (isDismissible)
            {
                button button_close = new button(null);
                button_close.AddCSS("close");

                button_close.SetAttribute("data-dismiss", "alert");
                button_close.SetAttribute("aria-label", "Close");
                span my_span = new span()
                {
                    InnerText = "×"
                };
                my_span.SetAttribute("aria-hidden", "true");
                button_close.AddDomNode(my_span);
                Childs.Add(button_close);
            }

            Childs.Add(new text(Message));

            return(base.GetHTML(deep));
        }
        /// <summary>
        /// Сформировать модальное окно
        /// </summary>
        /// <param name="title">Заголовок модального окна</param>
        /// <param name="text_ok_button">Текст конопки Ok (если null or empty), то кнопка не выводится вовсе</param>
        /// <param name="id_ok_button">ID атрибут конопки Ok</param>
        /// <param name="text_cansel_button">Текст конопки Cancel (если null or empty), то кнопка не выводится вовсе</param>
        /// <param name="body_html">Тело модального окна</param>
        /// <param name="id_modal_dialog">ID атрибут модального окна</param>
        public static div GetModalDialog(string title, string text_ok_button, string text_cansel_button, base_dom_root body_html, string id_modal_dialog = "exampleModal", string id_ok_button = "button_try_write")
        {
            span span_close_modal_header = new span("&times;");

            span_close_modal_header.SetAttribute("aria-hidden", "true");
            //
            button button_close_modal_header = new button(null);

            button_close_modal_header.AddCSS("close");
            button_close_modal_header.SetAttribute("data-dismiss", "modal");
            button_close_modal_header.SetAttribute("aria-label", "Close");
            button_close_modal_header.AddDomNode(span_close_modal_header);
            //
            h5 h5_modal_header = new h5(title);

            h5_modal_header.AddCSS("modal-title");
            div div_modal_header = new div();

            div_modal_header.AddCSS("modal-header");
            div_modal_header.AddDomNode(h5_modal_header);
            div_modal_header.AddDomNode(button_close_modal_header);
            //
            div modal_footer = new div();

            modal_footer.AddCSS("modal-footer");
            if (!string.IsNullOrEmpty(text_cansel_button))
            {
                button button_close_modal_footer = GetButton(text_cansel_button, null, null, VisualBootstrapStylesEnum.secondary);
                button_close_modal_footer.SetAttribute("data-dismiss", "modal");
                modal_footer.AddDomNode(button_close_modal_footer);
            }

            if (!string.IsNullOrEmpty(text_ok_button))
            {
                button button_send_modal_footer = GetButton(text_ok_button, null, "#", VisualBootstrapStylesEnum.primary);
                button_send_modal_footer.Id_DOM = id_ok_button;
                modal_footer.AddDomNode(button_send_modal_footer);
            }
            //
            div modal_content = new div();

            modal_content.AddCSS("modal-content");
            modal_content.AddDomNode(div_modal_header);
            //
            div modal_body = new div();

            modal_body.AddCSS("modal-body");
            modal_body.AddDomNode(body_html);
            modal_content.AddDomNode(modal_body);
            //
            modal_content.AddDomNode(modal_footer);
            //
            div modal_dialog_document = new div();

            modal_dialog_document.AddCSS("modal-dialog");

            modal_dialog_document.CustomAttributes.Add("role", "document");
            modal_dialog_document.AddDomNode(modal_content);
            //
            div ModalDialog = new div()
            {
                Id_DOM = id_modal_dialog
            };

            ModalDialog.AddCSS("modal fade", true);
            ModalDialog.CustomAttributes.Add("tabindex", "-1");
            ModalDialog.CustomAttributes.Add("role", "dialog");
            ModalDialog.CustomAttributes.Add("aria-labelledby", id_modal_dialog);
            ModalDialog.CustomAttributes.Add("aria-hidden", "true");

            ModalDialog.AddDomNode(modal_dialog_document);
            ModalDialog.before_coment_block = "Modal dialog";
            return(ModalDialog);
        }