Ejemplo n.º 1
0
        private HtmlTag renderInlineReverse()
        {
            _htmlRoot = new HtmlTag("div").AddClass("CC_editor_root");
            if (_rootId.IsNotEmpty())
            {
                _htmlRoot.Id(_rootId);
            }
            if (_rootClasses != null && _rootClasses.Any())
            {
                _htmlRoot.AddClasses(_rootClasses);
            }
            EditorLabelExpression <VIEWMODEL> labelBuilder = new EditorLabelExpression <VIEWMODEL>(_generator, _expression);
            EditorInputExpression <VIEWMODEL> inputBuilder = new EditorInputExpression <VIEWMODEL>(_generator, _expression);

            addInternalCssClasses(labelBuilder, inputBuilder);
            hideElements(_htmlRoot, labelBuilder, inputBuilder);
            addIds(labelBuilder, inputBuilder);
            addCustomLabel(labelBuilder);
            HtmlTag label = labelBuilder.LeadingColon().ToHtmlTag();
            HtmlTag input = inputBuilder.ToHtmlTag();

            _htmlRoot.Children.Add(input);
            _htmlRoot.Children.Add(label);
            return(_htmlRoot);
        }
Ejemplo n.º 2
0
        public HtmlTag Finish()
        {
            var anchor = new HtmlTag("a")
                         .AddClass("btn")
                         .Attr("href", _actionUrl);

            if (!string.IsNullOrEmpty(_id))
            {
                anchor.Id(_id);
            }

            if (_additionalCssClasses.Count > 0)
            {
                anchor.AddClasses(_additionalCssClasses);
            }

            if (_iconClasses != null)
            {
                anchor.Add("i").AddClasses(_iconClasses);
                anchor.AppendHtml(string.Format(" {0}", _buttonText));
            }
            else
            {
                anchor.AppendHtml(_buttonText);
            }

            return(anchor);
        }
Ejemplo n.º 3
0
        public HtmlTag ToHtmlTag()
        {
            _htmlRoot = new HtmlTag("div");
            _htmlRoot.AddClass(_noClear ? "view_root_no_clear" : "view_root");

            _htmlRoot = new HtmlTag("div").AddClass("view_root");
            if (_rootId.IsNotEmpty())
            {
                _htmlRoot.Id(_rootId);
            }
            if (_rootClasses != null && _rootClasses.Any())
            {
                _htmlRoot.AddClasses(_rootClasses);
            }
            ViewLabelExpression <VIEWMODEL>   labelBuilder   = new ViewLabelExpression <VIEWMODEL>(_generator, _expression);
            ViewDisplayExpression <VIEWMODEL> displayBuilder = new ViewDisplayExpression <VIEWMODEL>(_generator, _expression);

            addInternalCssClasses(labelBuilder, displayBuilder);
            hideElements(_htmlRoot, labelBuilder, displayBuilder);
            addIds(labelBuilder, displayBuilder);
            addCustomLabel(labelBuilder);
            addCustomAttr(displayBuilder);
            handleSpecialFormats(displayBuilder);
            HtmlTag label = labelBuilder.ToHtmlTag();
            HtmlTag input = displayBuilder.ToHtmlTag();

            if (input.Text().IsEmpty() && _hideIfEmpty)
            {
                return(null);
            }
            _htmlRoot.Append(label);
            _htmlRoot.Append(input);
            return(_htmlRoot);
        }
Ejemplo n.º 4
0
        public void render_multiple_classes_with_a_single_method_call()
        {
            var tag = new HtmlTag("div").Text("text");

            tag.AddClasses("a", "b", "c");

            tag.ToString().ShouldBe("<div class=\"a b c\">text</div>");
        }
Ejemplo n.º 5
0
        public HtmlTag tag(string tagName, string name  = null, string id     = null, string type   = null, string @for = null, string autocomplete = null,
                           IEnumerable <string> classes = null, string action = null, string method = null,
                           string text = null, Action children = null)
        {
            var theTag = new HtmlTag(tagName);

            if (type != null)
            {
                theTag.Attr("type", type);
            }

            if (id != null)
            {
                theTag.Id(id);
            }

            if (name != null)
            {
                theTag.Attr("name", name);
            }

            if (@for != null)
            {
                theTag.Attr("for", @for);
            }

            if (classes != null)
            {
                theTag.AddClasses(classes);
            }

            if (action != null)
            {
                theTag.Attr("action", action);
            }

            if (method != null)
            {
                theTag.Attr("method", method);
            }

            if (autocomplete != null)
            {
                theTag.Attr("autocomplete", autocomplete);
            }

            if (text != null)
            {
                theTag.Text(text);
            }

            AddChildContent(theTag, children);

            return(theTag);
        }
Ejemplo n.º 6
0
        protected override void Content()
        {
            var sizeCss = _sizes.SelectMany(x => x.CssClasses()).ToArray();

            _tag.AddClasses(sizeCss);
            foreach (var c in _children)
            {
                _tag.Append(c);
            }
            append(_tag);
        }
Ejemplo n.º 7
0
        public void render_multiple_classes_from_a_sequence()
        {
            var tag = new HtmlTag("div").Text("text");
            var sequenceOfClasses = new List <string> {
                "a", "b", "c"
            };

            tag.AddClasses(sequenceOfClasses);

            tag.ToString().ShouldBe("<div class=\"a b c\">text</div>");
        }
Ejemplo n.º 8
0
 private void addInternalCssClasses(HtmlTag root, HtmlTag input)
 {
     if (_inputRootClasses != null && _inputRootClasses.Any())
     {
         root.AddClasses(_inputRootClasses);
     }
     if (_inputClasses != null && _inputClasses.Any())
     {
         input.AddClasses(_inputClasses);
     }
 }
Ejemplo n.º 9
0
        public static HtmlTag BootstrapActionLinkButton <TController>(this HtmlHelper helper,
                                                                      Expression <Action <TController> > action,
                                                                      string label) where TController : Controller
        {
            var targetUrl = helper.BuildUrlFromExpression(action);
            var tag       = new HtmlTag("a");

            tag.Attr("href", targetUrl);
            tag.AddClasses("btn", "btn-primary");
            tag.Text(label);
            return(tag);
        }
Ejemplo n.º 10
0
        public void can_get_classes_from_tag()
        {
            var tag = new HtmlTag("div");

            var classes = new[] { "class1", "class2" };

            tag.AddClasses(classes);

            var tagClasses = tag.GetClasses();

            tagClasses.ShouldHaveCount(2);
            tagClasses.Except(classes).ShouldHaveCount(0);
        }
Ejemplo n.º 11
0
        public void can_get_classes_from_tag()
        {
            HtmlTag tag = new HtmlTag("div");

            var classes = new[] {"class1", "class2"};

            tag.AddClasses(classes);

            var tagClasses = tag.GetClasses();

            tagClasses.ShouldHaveCount(2);
            tagClasses.Except(classes).ShouldHaveCount(0);
        }
Ejemplo n.º 12
0
 private void addInternalCssClasses(HtmlTag root, HtmlTag input)
 {
     if (input.GetValidationHelpers().Any())
     {
         var origional = ReflectionHelper.GetProperty(_expression).Name;
         input.GetValidationHelpers().ForEachItem(x => x.ErrorMessage = x.ErrorMessage.Replace(origional, _labelDisplay));
     }
     if (_inputRootClasses != null && _inputRootClasses.Any())
     {
         root.AddClasses(_inputRootClasses);
     }
     if (_inputClasses != null && _inputClasses.Any())
     {
         input.AddClasses(_inputClasses);
     }
 }
Ejemplo n.º 13
0
        public static HtmlTag GenerateWrappedTagFor(TagInfo tagInfo)
        {
            var    a       = TagFactory.GenerateTagFor(tagInfo).GetTag();
            var    wrapper = new HtmlTag("div");
            string res;
            var    tryGetValue = tagInfo.Attributes.TryGetValue("class", out res);

            if (tryGetValue)
            {
                wrapper.AddClasses(res);
            }

            wrapper.Append(a);

            return(wrapper);
        }
Ejemplo n.º 14
0
        public HtmlTag ToHtmlTag()
        {
            _htmlRoot = new HtmlTag("div");
            _htmlRoot.AddClass(_inLine ? "editor_label_inline" : "editor_label");
            if (_labelRootClasses != null && _labelRootClasses.Any())
            {
                _htmlRoot.AddClasses(_labelRootClasses);
            }
            if (_hide)
            {
                _htmlRoot.Hide();
            }
            HtmlTag label = _generator.LabelFor(_expression);

            if (_labelClasses != null && _labelClasses.Any())
            {
                label.AddClasses(_labelClasses);
            }
            if (_elementId.IsNotEmpty())
            {
                label.Id(_elementId);
            }
            if (_customDisplay.IsNotEmpty())
            {
                label.Text(_customDisplay);
            }

            if (_colonAfterLabel && !_LeadingColon)
            {
                label.Text(label.Text() + ":");
            }
            if (_colonAfterLabel && _LeadingColon)
            {
                label.Text(":" + label.Text());
            }
//            if (ReflectionHelper.GetProperty(_expression).HasAttribute<ValidateNonEmptyAttribute>())
//            {
//                label.Text(label.Text()+"*");
//            }
            _htmlRoot.Append(label);
            return(_htmlRoot);
        }
Ejemplo n.º 15
0
        private HtmlTag CreateLabel(string value, string modelValue)
        {
            var label = new HtmlTag("label").AddClasses("radio-item");
            var input = new HtmlTag("input").Attr("type", "radio").Name(ControlContext.Name).Value(value);

            if (value == modelValue)
            {
                input.Attr("checked", "true");
            }

            var labelText = _labels.ContainsKey(value) ? _labels[value] : value;
            var text      = new HtmlTag("span").Text(labelText);

            if (_valuesWithPause.Contains(value))
            {
                label.AddClasses("visual-pause");
            }

            return(label.Append(input).Append(text));
        }
Ejemplo n.º 16
0
//        private bool checkAuthentication()
//        {
//            _authorizationService = ObjectFactory.Container.GetInstance<IAuthorizationService>();
//            _sessionContext = ObjectFactory.Container.GetInstance<ICCSessionContext>();
//            var user = _sessionContext.GetCurrentUser();
//            return _authorizationService.IsAllowed(user, _operation);
//        }

        private HtmlTag renderStandard()
        {
            _htmlRoot = new HtmlTag("div");
            _htmlRoot.AddClass(_noClear ? "editor_root_no_clear" : "editor_root");
            if (_rootId.IsNotEmpty())
            {
                _htmlRoot.Id(_rootId);
            }
            if (_rootClasses != null && _rootClasses.Any())
            {
                _htmlRoot.AddClasses(_rootClasses);
            }
            EditorLabelExpression <VIEWMODEL>  labelBuilder = new EditorLabelExpression <VIEWMODEL>(_generator, _expression);
            IEditorInputExpression <VIEWMODEL> inputBuilder;

            if (_dropdown)
            {
                inputBuilder = new DropdownInputExpression <VIEWMODEL>(_generator, _expression, _dropdownWithItems);
            }
            else
            {
                inputBuilder = new EditorInputExpression <VIEWMODEL>(_generator, _expression);
            }
            addInternalCssClasses(labelBuilder, inputBuilder);
            hideElements(_htmlRoot, labelBuilder, inputBuilder);
            addIds(labelBuilder, inputBuilder);
            addCustomLabel(labelBuilder);
            if (_readOnly)
            {
                inputBuilder.ReadOnly();
            }
            HtmlTag input = inputBuilder.ToHtmlTag();
            HtmlTag label = labelBuilder.ToHtmlTag();

            _htmlRoot.Children.Add(label);
            _htmlRoot.Children.Add(input);
            addFlagToHtmlRoot(input.FirstChild());
            return(_htmlRoot);
        }
Ejemplo n.º 17
0
        protected virtual HtmlTag AddButtonStyle(IHasButtonStyle button, HtmlTag tag)
        {
            var basicButton = "btn";
            var buttonStyle = DefaultButtonStyles[DefaultButton.Default];
            var controlBag  = button.NullableControlBag;

            if (controlBag != null && controlBag.ContainsKey(ButtonStyle.Key))
            {
                var style = controlBag[ButtonStyle.Key];

                if (style is DefaultButton)
                {
                    buttonStyle = DefaultButtonStyles[(DefaultButton)style];
                }

                if (style is BootstrapButton)
                {
                    buttonStyle = BootstrapButtonStyles[(BootstrapButton)style];
                }
            }

            return(tag.AddClasses(basicButton, buttonStyle));
        }
Ejemplo n.º 18
0
        protected override HtmlTag CreateTag()
        {
            var container = new HtmlTag("container", t => t.NoTag());

            if (string.IsNullOrWhiteSpace(_value) && !_alwaysShow)
            {
                return(container);
            }

            var dt = new HtmlTag("dt");
            var dd = new HtmlTag("dd");

            container.Append(dt).Append(dd);

            dt.Text(_labelText);
            dd.Attr("data-answer-for", _name).Text(_value);

            if (_classes != null)
            {
                dd.AddClasses(_classes);
            }

            return(container);
        }
Ejemplo n.º 19
0
        public HtmlTag ToHtmlTag()
        {
            _htmlRoot = new HtmlTag("div").AddClass("view_label");
            if (_labelRootClasses != null && _labelRootClasses.Any())
            {
                _htmlRoot.AddClasses(_labelRootClasses);
            }
            if (_hide)
            {
                _htmlRoot.Hide();
            }
            HtmlTag label = _generator.LabelFor(_expression);

            if (_labelClasses != null && _labelClasses.Any())
            {
                label.AddClasses(_labelClasses);
            }
            if (_elementId.IsNotEmpty())
            {
                label.Id(_elementId);
            }
            if (_customDisplay.IsNotEmpty())
            {
                label.Text(_customDisplay);
            }
            if (!_noColon && !_LeadingColon)
            {
                label.Text(label.Text() + ":");
            }
            if (!_noColon && _LeadingColon)
            {
                label.Text(":" + label.Text());
            }
            _htmlRoot.Append(label);
            return(_htmlRoot);
        }
Ejemplo n.º 20
0
 public virtual HtmlTag SelectStyler(Select select, HtmlTag tag)
 {
     return(tag.AddClasses("form-control"));
 }
Ejemplo n.º 21
0
 private void addToolTipAndClasses(HtmlTag span)
 {
     span.Attr("title", _toolTip);
     span.AddClasses(_divCssClasses);
 }
Ejemplo n.º 22
0
        public void render_multiple_classes_from_a_sequence()
        {
            var tag = new HtmlTag("div").Text("text");
            var sequenceOfClasses = new List<string>{"a", "b", "c"};
            tag.AddClasses(sequenceOfClasses);

            tag.ToString().ShouldEqual("<div class=\"a b c\">text</div>");
        }
Ejemplo n.º 23
0
 public virtual HtmlTag InputStyler(Input input, HtmlTag tag)
 {
     return(input.Type() != "hidden"
         ? tag.AddClasses("form-control")
         : tag);
 }
Ejemplo n.º 24
0
        public void render_multiple_classes_with_a_single_method_call()
        {
            var tag = new HtmlTag("div").Text("text");
            tag.AddClasses("a", "b", "c");

            tag.ToString().ShouldEqual("<div class=\"a b c\">text</div>");
        }
Ejemplo n.º 25
0
 public virtual HtmlTag FormStyler(IForm form, HtmlTag tag)
 {
     return(tag.AddClasses("form-horizontal"));
 }