private static HtmlBuilder AttachmentItem(
     this HtmlBuilder hb,
     Context context,
     string controlId   = null,
     string guid        = null,
     string css         = null,
     string fileName    = null,
     string displaySize = null,
     bool?added         = null,
     bool?deleted       = null,
     bool readOnly      = false,
     bool _using        = true)
 {
     return(_using
         ? hb.Div(
                id: guid,
                css: Css.Class("control-attachments-item ", css),
                action: () => hb
                .A(
                    attributes: new HtmlAttributes()
                    .Class("file-name")
                    .Href(Locations.ShowFile(
                              context: context,
                              guid: guid,
                              temp: added == true)),
                    action: () => hb
                    .Span(css: "ui-icon ui-icon-circle-zoomin show-file"))
                .A(
                    attributes: new HtmlAttributes()
                    .Class("file-name")
                    .Href(Locations.DownloadFile(
                              context: context,
                              guid: guid,
                              temp: added == true)),
                    action: () => hb
                    .Text(text: fileName + " (" + displaySize + ")"))
                .Div(
                    attributes: new HtmlAttributes()
                    .Class(deleted == true
                             ? "ui-icon ui-icon-trash file-delete"
                             : "ui-icon ui-icon-circle-close delete-file")
                    .DataAction("binaries/deletetemp")
                    .DataId(guid)
                    .OnClick($"$p.deleteAttachment($('#{controlId}'), $(this));"),
                    _using: !readOnly))
          : hb);
 }
Beispiel #2
0
 public HtmlBuilder Html(
     HtmlBuilder hb,
     Context context,
     SiteSettings ss,
     bool allowEditing,
     bool allowImage,
     bool mobile,
     bool readOnly    = false,
     string controlId = null,
     string css       = null,
     Action action    = null)
 {
     return(hb.Div(
                id: !controlId.IsNullOrEmpty()
             ? controlId + ".wrapper"
             : null,
                css: Css.Class("comment", css),
                action: () =>
     {
         action?.Invoke();
         hb
         .P(css: "time", action: () => hb
            .Text(text: CreatedTimeDisplayValue(context: context)))
         .HtmlUser(
             context: context,
             id: Updator ?? Creator);
         if (CanEdit(
                 context: context,
                 ss: ss,
                 allowEditing: allowEditing,
                 readOnly: readOnly))
         {
             hb.MarkDown(
                 context: context,
                 controlId: controlId,
                 text: Body,
                 allowImage: allowImage,
                 mobile: mobile);
         }
         else
         {
             hb
             .P(css: "body markup", action: () => hb
                .Text(text: Body));
         }
     }));
 }
 public static HtmlBuilder MarkUp(
     this HtmlBuilder hb,
     string controlId  = null,
     string controlCss = null,
     string text       = null,
     Dictionary <string, string> attributes = null,
     bool _using = true)
 {
     return(_using
         ? hb.Div(
                attributes: new HtmlAttributes()
                .Id(controlId)
                .Class(Css.Class("control-markup markup", controlCss)),
                action: () => hb
                .Text(text: text))
         : hb);
 }
Beispiel #4
0
 private static HtmlBuilder Control(
     this HtmlBuilder hb,
     Action controlAction,
     string controlContainerCss,
     string tagControlContainer)
 {
     return(hb.Div(
                css: "field-control",
                action: () => hb
                .Append(
                    tag: tagControlContainer,
                    id: null,
                    css: Css.Class("container-normal", controlContainerCss),
                    attributes: null,
                    action: () =>
                    controlAction())));
 }
Beispiel #5
0
 public static HtmlBuilder Selectable(
     this HtmlBuilder hb,
     string controlId,
     string controlCss = null,
     Dictionary <string, ControlData> listItemCollection = null,
     IEnumerable <string> selectedValueCollection        = null,
     bool _using = true)
 {
     return(_using
         ? hb.Ol(id: controlId,
                 css: Css.Class("control-selectable", controlCss),
                 action: () => hb
                 .SelectableItems(
                     listItemCollection: listItemCollection,
                     selectedValueTextCollection: selectedValueCollection))
         : hb);
 }
 public static HtmlBuilder DropDown(
     this HtmlBuilder hb,
     string controlId  = null,
     string controlCss = null,
     Dictionary <string, ControlData> optionCollection = null,
     string selectedValue  = null,
     bool multiple         = false,
     bool addSelectedValue = true,
     bool insertBlank      = false,
     bool disabled         = false,
     string onChange       = null,
     bool validateRequired = false,
     string action         = null,
     string method         = null,
     Column column         = null,
     bool _using           = true)
 {
     return(_using
         ? hb.Select(
                attributes: new HtmlAttributes()
                .Id(controlId)
                .Class(Css.Class(
                           "control-dropdown" + (optionCollection.Any(o =>
                                                                      !o.Value.Css.IsNullOrEmpty() ||
                                                                      !o.Value.Style.IsNullOrEmpty())
                             ? " has-css"
                             : string.Empty),
                           controlCss))
                .Multiple(multiple)
                .Disabled(disabled)
                .OnChange(onChange)
                .DataValidateRequired(validateRequired)
                .DataAction(action)
                .DataMethod(method),
                action: () => hb
                .OptionCollection(
                    optionCollection: optionCollection,
                    selectedValue: selectedValue,
                    multiple: multiple,
                    addSelectedValue: addSelectedValue,
                    insertBlank: insertBlank,
                    column: column))
         : hb);
 }
 public static HtmlBuilder CheckBox(
     this HtmlBuilder hb,
     string controlId = null,
     string controlCss = null,
     string labelText = null,
     string labelRaw = null,
     bool _checked = false,
     bool disabled = false,
     bool alwaysSend = false,
     string dataId = null,
     string onChange = null,
     string action = null,
     string method = null,
     bool _using = true)
 {
     if (_using)
     {
         hb.Input(attributes: new HtmlAttributes()
             .Id(controlId)
             .Name(controlId)
             .Class(Css.Class("control-checkbox", controlCss))
             .Type("checkbox")
             .Disabled(disabled)
             .DataAlwaysSend(alwaysSend)
             .DataId(dataId)
             .OnChange(onChange)
             .DataAction(action)
             .DataMethod(method)
             .DataReadOnly(disabled)
             .Checked(_checked));
         if (labelRaw != null)
         {
             hb.Raw(text: labelRaw);
         }
         else if (labelText != string.Empty)
         {
             hb.Label(
                 attributes: new HtmlAttributes().For(controlId),
                 action: () => hb
                     .Text(text: labelText));
         }
     }
     return hb;
 }
 public static HtmlBuilder Basket(
     this HtmlBuilder hb,
     string controlId,
     string controlCss = null,
     Dictionary <string, ControlData> listItemCollection = null,
     IEnumerable <string> selectedValueCollection        = null,
     bool _using = true)
 {
     return(_using
         ? hb.Ol(
                attributes: new HtmlAttributes()
                .Id(controlId)
                .Class(Css.Class("control-basket", controlCss)),
                action: () => hb
                .SelectableItems(
                    listItemCollection: listItemCollection,
                    selectedValueTextCollection: selectedValueCollection,
                    basket: true))
         : hb);
 }
Beispiel #9
0
 public static HtmlBuilder Field(
     this HtmlBuilder hb,
     string fieldId       = null,
     string fieldCss      = null,
     Action actionLabel   = null,
     Action actionControl = null,
     Action actionOptions = null,
     bool _using          = true)
 {
     return(_using
         ? hb.Div(
                id: fieldId,
                css: Css.Class("field-normal", fieldCss), action: () =>
     {
         actionLabel();
         actionControl();
         actionOptions?.Invoke();
     })
         : hb);
 }
 public static HtmlBuilder MarkDown(
     this HtmlBuilder hb,
     string controlId      = null,
     string controlCss     = null,
     string text           = null,
     string placeholder    = null,
     bool readOnly         = false,
     bool validateRequired = false,
     Dictionary <string, string> attributes = null,
     bool preview = false,
     bool _using  = true)
 {
     if (preview)
     {
         controlId = Strings.NewGuid();
     }
     return(_using
         ? hb
            .Div(attributes: new HtmlAttributes()
                 .Id(controlId + ".viewer")
                 .Class("control-markup not-send")
                 .OnDblClick("$p.editMarkdown($(this));"))
            .Div(
                attributes: new HtmlAttributes()
                .Id(controlId + ".editor")
                .Class("ui-icon ui-icon-pencil button-edit-markdown")
                .OnClick("$p.editMarkdown($(this));"),
                _using: !readOnly)
            .TextArea(
                attributes: new HtmlAttributes()
                .Id(controlId)
                .Class(Css.Class("control-markdown upload-image", controlCss))
                .Placeholder(placeholder)
                .DataValidateRequired(validateRequired, _using: !readOnly)
                .Add(attributes),
                action: () => hb
                .Text(text: text))
            .MarkDownCommands(controlId: controlId, readOnly: readOnly)
         : hb);
 }
 public static HtmlBuilder Spinner(
     this HtmlBuilder hb,
     string controlId = null,
     string controlCss = null,
     decimal? value = 0,
     decimal min = -1,
     decimal max = -1,
     decimal step = -1,
     int width = -1,
     bool alwaysSend = false,
     bool allowBalnk = false,
     string onChange = null,
     string action = null,
     string method = null,
     bool _using = true)
 {
     return _using
         ? hb.Input(attributes: new HtmlAttributes()
             .Id(controlId)
             .Name(controlId)
             .Class(Css.Class("control-spinner", controlCss)
                 + (allowBalnk
                     ? " allow-blank"
                     : string.Empty))
             .Type("number")
             .Value(value != null
                 ? value.ToString()
                 : string.Empty)
             .DataMin(min, _using: min != -1)
             .DataMax(max, _using: max != -1)
             .DataStep(step, _using: step != -1)
             .DataWidth(width, _using: width != -1)
             .DataAlwaysSend(alwaysSend)
             .OnChange(onChange)
             .DataAction(action)
             .DataMethod(method))
         : hb;
 }
 public static HtmlBuilder SelectableWrapper(
     this HtmlBuilder hb,
     string controlId,
     string controlWrapperCss = null,
     string controlCss        = null,
     Dictionary <string, ControlData> listItemCollection = null,
     IEnumerable <string> selectedValueCollection        = null,
     string action = null,
     string method = null,
     bool _using   = true)
 {
     return(_using
         ? hb.Div(
                css: Css.Class("wrapper", controlWrapperCss),
                action: () => hb
                .Selectable(
                    controlId: controlId,
                    controlCss: Css.Class("control-selectable", controlCss),
                    listItemCollection: listItemCollection,
                    selectedValueCollection: selectedValueCollection,
                    action: action,
                    method: method))
         : hb);
 }
 public static HtmlBuilder Slider(
     this HtmlBuilder hb,
     string controlId  = null,
     string controlCss = null,
     decimal value     = 0,
     decimal min       = -1,
     decimal max       = -1,
     decimal step      = -1,
     string unit       = null,
     bool alwaysSend   = false,
     string action     = null,
     string method     = null,
     bool _using       = true)
 {
     return(_using
         ? hb
            .Div(attributes: new HtmlAttributes()
                 .Id(controlId + ",ui")
                 .Class("control-slider-ui")
                 .DataMin(min, _using: min != -1)
                 .DataMax(max, _using: max != -1)
                 .DataStep(step, _using: step != -1))
            .P(
                attributes: new HtmlAttributes()
                .Id(controlId).DataAction(action)
                .Class(Css.Class("control-slider", controlCss))
                .DataAlwaysSend(alwaysSend)
                .DataAction(action)
                .DataMethod(method),
                action: () => hb
                .Span(action: () => hb
                      .Text(value.ToString()))
                .Span(action: () => hb
                      .Text(unit)))
         : hb);
 }
        public static HtmlBuilder TextBox(
            this HtmlBuilder hb,
            HtmlTypes.TextTypes textType = HtmlTypes.TextTypes.Normal,
            string controlId             = null,
            string controlCss            = null,
            string text               = null,
            string placeholder        = null,
            string onChange           = null,
            string format             = null,
            bool timepicker           = false,
            string accept             = null,
            string dataId             = null,
            bool validateRequired     = false,
            bool validateNumber       = false,
            decimal validateMinNumber = 0,
            decimal validateMaxNumber = 0,
            bool validateDate         = false,
            bool validateEmail        = false,
            string validateEqualTo    = null,
            int validateMaxLength     = 0,
            string action             = null,
            string method             = null,
            Dictionary <string, string> attributes = null,
            bool _using = true)
        {
            if (!_using)
            {
                return(hb);
            }
            switch (textType)
            {
            case HtmlTypes.TextTypes.Normal:
                return(hb.Input(attributes: new HtmlAttributes()
                                .Id(controlId)
                                .Class(Css.Class("control-textbox", controlCss))
                                .Type("text")
                                .Value(text)
                                .Placeholder(placeholder)
                                .OnChange(onChange)
                                .DataId(dataId)
                                .DataValidateRequired(validateRequired)
                                .DataValidateNumber(validateNumber)
                                .DataValidateMinNumber(
                                    validateMinNumber, _using: validateMinNumber != validateMaxNumber)
                                .DataValidateMaxNumber(
                                    validateMaxNumber, _using: validateMinNumber != validateMaxNumber)
                                .DataValidateDate(validateDate)
                                .DataValidateEmail(validateEmail)
                                .DataValidateEqualTo(validateEqualTo)
                                .DataValidateMaxLength(validateMaxLength)
                                .DataAction(action)
                                .DataMethod(method)
                                .Add(attributes)));

            case HtmlTypes.TextTypes.DateTime:
                return(hb.Input(attributes: new HtmlAttributes()
                                .Id(controlId)
                                .Class(Css.Class("control-textbox datepicker", controlCss))
                                .Type("text")
                                .Value(text)
                                .Placeholder(placeholder)
                                .OnChange(onChange)
                                .DataId(dataId)
                                .DataFormat(format)
                                .DataTimepicker(timepicker)
                                .DataValidateRequired(validateRequired)
                                .DataValidateNumber(validateNumber)
                                .DataValidateDate(validateDate)
                                .DataValidateEmail(validateEmail)
                                .DataValidateEqualTo(validateEqualTo)
                                .DataValidateMaxLength(validateMaxLength)
                                .DataAction(action)
                                .DataMethod(method)
                                .Add(attributes)));

            case HtmlTypes.TextTypes.MultiLine:
                return(hb.TextArea(
                           attributes: new HtmlAttributes()
                           .Id(controlId)
                           .Class(Css.Class("control-textarea", controlCss))
                           .Placeholder(placeholder)
                           .OnChange(onChange)
                           .DataId(dataId)
                           .DataValidateRequired(validateRequired)
                           .DataValidateNumber(validateNumber)
                           .DataValidateDate(validateDate)
                           .DataValidateEmail(validateEmail)
                           .DataValidateEqualTo(validateEqualTo)
                           .DataValidateMaxLength(validateMaxLength)
                           .DataAction(action)
                           .DataMethod(method)
                           .Add(attributes),
                           action: () => hb
                           .Text(text: text)));

            case HtmlTypes.TextTypes.Password:
                return(hb.Input(attributes: new HtmlAttributes()
                                .Id(controlId)
                                .Class(Css.Class("control-textbox", controlCss))
                                .Type("password")
                                .Value(text)
                                .Placeholder(placeholder)
                                .OnChange(onChange)
                                .DataId(dataId)
                                .DataValidateRequired(validateRequired)
                                .DataValidateNumber(validateNumber)
                                .DataValidateDate(validateDate)
                                .DataValidateEmail(validateEmail)
                                .DataValidateEqualTo(validateEqualTo)
                                .DataValidateMaxLength(validateMaxLength)
                                .Add(attributes)));

            case HtmlTypes.TextTypes.File:
                return(hb.Input(attributes: new HtmlAttributes()
                                .Id(controlId)
                                .Class(Css.Class("control-textbox", controlCss))
                                .Type("file")
                                .Value(text)
                                .Placeholder(placeholder)
                                .OnChange(onChange)
                                .Accept(accept)
                                .DataId(dataId)
                                .DataValidateRequired(validateRequired)
                                .DataValidateNumber(validateNumber)
                                .DataValidateDate(validateDate)
                                .DataValidateEmail(validateEmail)
                                .DataValidateEqualTo(validateEqualTo)
                                .DataValidateMaxLength(validateMaxLength)
                                .DataAction(action)
                                .DataMethod(method)
                                .Add(attributes)));

            default:
                return(hb);
            }
        }
 public static HtmlBuilder MarkDown(
     this HtmlBuilder hb,
     Context context,
     string controlId = null,
     string controlCss = null,
     string text = null,
     string placeholder = null,
     bool readOnly = false,
     bool allowImage = true,
     bool allowBulkUpdate = false,
     bool mobile = false,
     bool alwaysSend = false,
     bool validateRequired = false,
     Column.ViewerSwitchingTypes viewerSwitchingTypes = Column.ViewerSwitchingTypes.Auto,
     Dictionary<string, string> attributes = null,
     bool preview = false,
     bool _using = true,
     int validateMaxLength = 0,
     string validateRegex = null,
     string validateRegexErrorMessage = null)
 {
     if (!_using) return hb;
     if (preview) controlId = Strings.NewGuid();
     if (viewerSwitchingTypes != Column.ViewerSwitchingTypes.Disabled)
     {
         hb
             .Div(attributes: new HtmlAttributes()
                 .Id(controlId + ".viewer")
                 .Class("control-markup not-send")
                .OnDblClick($"$p.editMarkdown($('#{controlId}'));"))
             .Div(
                 attributes: new HtmlAttributes()
                     .Id(controlId + ".editor")
                     .Class("ui-icon ui-icon-pencil button-edit-markdown")
                    .OnClick($"$p.editMarkdown($('#{controlId}'));"),
                _using: !readOnly);
     }
     hb
         .TextArea(
             attributes: new HtmlAttributes()
                 .Id(controlId)
                 .Name(controlId)
                 .Class(Css.Class((viewerSwitchingTypes == Column.ViewerSwitchingTypes.Disabled
                     ? "control-textarea"
                     : "control-markdown")
                         + (viewerSwitchingTypes == Column.ViewerSwitchingTypes.Manual
                             ? " manual"
                             : string.Empty)
                         + (CanUploadImage(context, readOnly, allowImage, preview)
                                 ? " upload-image"
                                 : string.Empty),
                         controlCss))
                             .Placeholder(placeholder)
                             .DataAlwaysSend(alwaysSend)
                             .DataValidateMaxLength(validateMaxLength)
                             .DataValidateRequired(validateRequired, _using: !readOnly)
                             .DataValidateRegex(validateRegex)
                             .DataValidateRegexErrorMessage(validateRegexErrorMessage)
                             .DataReadOnly(readOnly)
                             .Add(attributes),
             text: text)
         .MarkDownCommands(
             context: context,
             controlId: controlId,
             readOnly: readOnly,
             allowImage: allowImage,
             mobile: mobile,
             preview: preview);
     return hb;
 }
 public static HtmlBuilder MarkDown(
     this HtmlBuilder hb,
     Context context,
     string controlId      = null,
     string controlCss     = null,
     string text           = null,
     string placeholder    = null,
     bool readOnly         = false,
     bool allowImage       = true,
     bool allowBulkUpdate  = false,
     bool mobile           = false,
     bool alwaysSend       = false,
     bool validateRequired = false,
     Dictionary <string, string> attributes = null,
     bool preview                     = false,
     bool _using                      = true,
     int validateMaxLength            = 0,
     string validateRegex             = null,
     string validateRegexErrorMessage = null)
 {
     if (preview)
     {
         controlId = Strings.NewGuid();
     }
     return(_using
         ? hb
            .Div(attributes: new HtmlAttributes()
                 .Id(controlId + ".viewer")
                 .Class("control-markup not-send")
                 .OnDblClick("$p.editMarkdown($(this));"))
            .Div(
                attributes: new HtmlAttributes()
                .Id(controlId + ".editor")
                .Class("ui-icon ui-icon-pencil button-edit-markdown")
                .OnClick("$p.editMarkdown($(this));"),
                _using: !readOnly)
            .TextArea(
                attributes: new HtmlAttributes()
                .Id(controlId)
                .Name(controlId)
                .Class(Css.Class(
                           "control-markdown" +
                           (CanUploadImage(context, readOnly, allowImage, preview)
                                 ? " upload-image"
                                 : string.Empty),
                           controlCss))
                .Placeholder(placeholder)
                .DataAlwaysSend(alwaysSend)
                .DataValidateMaxLength(validateMaxLength)
                .DataValidateRequired(validateRequired, _using: !readOnly)
                .DataValidateRegex(validateRegex)
                .DataValidateRegexErrorMessage(validateRegexErrorMessage)
                .Add(attributes),
                text: text)
            .MarkDownCommands(
                context: context,
                controlId: controlId,
                readOnly: readOnly,
                allowImage: allowImage,
                mobile: mobile,
                preview: preview)
         : hb);
 }