Esempio n. 1
0
 private static void RenderNotPicked(IHtmlWriter writer)
 {
     writer.AddStyleAttribute("margin-left", "-23px");
     writer.AddStyleAttribute("margin-bottom", "100px");
     writer.AddStyleAttribute("width", "13px");
     writer.AddStyleAttribute("background-color", "#C44");
     writer.AddStyleAttribute("display", "inline-block");
     writer.RenderBeginTag("span");
     writer.RenderEndTag();
 }
Esempio n. 2
0
        protected override void RenderInputTag(IHtmlWriter writer)
        {
            writer.AddStyleAttribute("width", "150px");
            writer.AddStyleAttribute("height", "155px");
            writer.AddStyleAttribute("display", "inline-flex");
            writer.RenderBeginTag("div");

            RenderCheckbox(writer);
            RenderCheckboxPicture(writer);
            RenderNotPicked(writer);
            RenderPicked(writer);

            writer.RenderEndTag();
        }
Esempio n. 3
0
        private void AddCssStylesToRender(IHtmlWriter writer)
        {
            KnockoutBindingGroup cssStylesBindingGroup = null;

            foreach (var styleProperty in CssStyles.Properties)
            {
                if (HasValueBinding(styleProperty))
                {
                    if (cssStylesBindingGroup == null)
                    {
                        cssStylesBindingGroup = new KnockoutBindingGroup();
                    }
                    cssStylesBindingGroup.Add(styleProperty.GroupMemberName, this, styleProperty);
                }

                try
                {
                    var value = GetValue(styleProperty)?.ToString();
                    if (!string.IsNullOrEmpty(value))
                    {
                        writer.AddStyleAttribute(styleProperty.GroupMemberName, value);
                    }
                }
                catch { }
            }

            if (cssStylesBindingGroup != null)
            {
                writer.AddKnockoutDataBind("style", cssStylesBindingGroup);
            }
        }
Esempio n. 4
0
        protected override void AddAttributesToRender(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            base.AddAttributesToRender(writer, context);

            var expression = KnockoutHelper.GetValidationTargetExpression(this);

            if (expression == null)
            {
                return;
            }

            var group = new KnockoutBindingGroup();

            {
                group.Add("target", expression);
                group.Add("includeErrorsFromChildren", IncludeErrorsFromChildren.ToString().ToLower());
                group.Add("includeErrorsFromTarget", IncludeErrorsFromTarget.ToString().ToLower());
                group.Add("hideWhenValid", HideWhenValid.ToString().ToLower());
            }
            writer.AddKnockoutDataBind("dotvvm-validationSummary", group);

            if (HideWhenValid)
            {
                writer.AddStyleAttribute("display", "none");
            }
        }
Esempio n. 5
0
        protected override void AddAttributesToRender(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            base.AddAttributesToRender(writer, context);

            writer.AddKnockoutDataBind("dotvvm-pwa-offlineAlert", new KnockoutBindingGroup());
            writer.AddStyleAttribute("display", "none");
        }
Esempio n. 6
0
 /// <summary>
 /// Adds the corresponding attribute or binding for the Visible property.
 /// </summary>
 protected virtual void AddVisibleAttributeOrBinding(IHtmlWriter writer)
 {
     writer.AddKnockoutDataBind("visible", this, VisibleProperty, renderEvenInServerRenderingMode: true);
     if (GetValue(VisibleProperty) as bool? == false)
     {
         writer.AddStyleAttribute("display", "none");
     }
 }
Esempio n. 7
0
 public virtual void AddStyleAttribute(string name, string value)
 {
     if (validator.CheckStyleAttribute(name, value))
     {
         Attributes.Add(name, value);
         writer.AddStyleAttribute(name, value);
     }
 }
Esempio n. 8
0
 private void RenderCheckbox(IHtmlWriter writer)
 {
     RenderCheckedProperty(writer);
     writer.AddAttribute("class", "icon-checkbox");
     writer.AddAttribute("type", "checkbox");
     writer.AddStyleAttribute("display", "none");
     writer.AddKnockoutDataBind("attr", BuildKnockoutBindingsInputAttributes());
     writer.RenderSelfClosingTag("input");
 }
Esempio n. 9
0
        protected override void AddAttributesToRender(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            if (!RenderOnServer)
            {
                writer.AddKnockoutDataBind("visible", $"!({ GetForeachDataBindJavascriptExpression() }).length");

                if (DataSource != null && GetIEnumerableFromDataSource(DataSource).OfType <object>().Any())
                {
                    writer.AddStyleAttribute("display", "none");
                }
            }

            base.AddAttributesToRender(writer, context);
        }
Esempio n. 10
0
        protected override void AddAttributesToRender(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            if (!RenderOnServer)
            {
                writer.AddKnockoutDataBind("visible", $"!({ GetForeachDataBindJavascriptExpression() }).length");

                if (DataSource != null && GetIEnumerableFromDataSource(DataSource).OfType<object>().Any())
                {
                    writer.AddStyleAttribute("display", "none");
                }
            }

            base.AddAttributesToRender(writer, context);
        }
Esempio n. 11
0
        protected override void AddAttributesToRender(IHtmlWriter writer, RenderContext context)
        {
            if (!RenderOnServer)
            {
                writer.AddKnockoutDataBind("visible", $"({ GetForeachDataBindJavascriptExpression() }).length");
                if (numberOfRows == 0)
                {
                    writer.AddStyleAttribute("display", "none");
                }

                // with databind
                writer.AddKnockoutDataBind("with", GetDataSourceBinding());
            }

            base.AddAttributesToRender(writer, context);
        }
Esempio n. 12
0
 private void RenderPicked(IHtmlWriter writer)
 {
     writer.AddKnockoutDataBind("visible", GetValueBinding(CheckedProperty));
     writer.AddStyleAttribute("margin-left", "-13px");
     writer.AddStyleAttribute("margin-bottom", "100px");
     writer.AddStyleAttribute("width", "13px");
     writer.AddStyleAttribute("background-color", "#2E2");
     writer.AddStyleAttribute("color", "#2E2");
     writer.AddStyleAttribute("display", "inline-block");
     writer.RenderBeginTag("span");
     writer.RenderEndTag();
 }
Esempio n. 13
0
        protected override void AddAttributesToRender(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            if (!context.IsInPartialRenderingMode)
            {
                writer.AddStyleAttribute("display", "none");
            }
            writer.AddKnockoutDataBind("if", "dotvvm.isSpaReady");

            if (!string.IsNullOrEmpty(DefaultRouteName))
            {
                var route = context.Configuration.RouteTable[DefaultRouteName];
                if (route.ParameterNames.Any())
                {
                    throw new DotvvmControlException(this, $"The route '{DefaultRouteName}' specified in SpaContentPlaceHolder DefaultRouteName property cannot contain route parameters!");
                }
                writer.AddAttribute(HostingConstants.SpaContentPlaceHolderDefaultRouteDataAttributeName, route.Url);
            }
            base.AddAttributesToRender(writer, context);
        }
Esempio n. 14
0
        protected override void AddAttributesToRender(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            writer.AddStyleAttribute("display", "none");
            writer.AddAttribute("class", "dotvvm__pwa__offline-handler", true);
            var onlinePageLoadBinding = GetCommandBinding(OnlinePageLoadProperty);

            if (onlinePageLoadBinding != null)
            {
                writer.AddAttribute("onlinepageload", KnockoutHelper.GenerateClientPostBackScript(nameof(OnlinePageLoad), onlinePageLoadBinding, this), true, ";");
            }
            var offlinePageLoadBinding = GetCommandBinding(OfflinePageLoadProperty);

            if (offlinePageLoadBinding != null)
            {
                writer.AddAttribute("offlinepageload", KnockoutHelper.GenerateClientPostBackScript(nameof(OfflinePageLoad), offlinePageLoadBinding, this, new PostbackScriptOptions()), true, ";");
            }
            base.AddAttributesToRender(writer, context);

            writer.AddKnockoutDataBind("dotvvm-pwa-offlineHandler", new KnockoutBindingGroup());
        }
Esempio n. 15
0
        protected override void AddAttributesToRender(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            if (!RenderOnServer)
            {
                if (RenderWrapperTag)
                {
                    writer.AddKnockoutDataBind("visible", "!" + GetBinding(DataSourceProperty).GetProperty <DataSourceLengthBinding>().Binding.CastTo <IValueBinding>().GetKnockoutBindingExpression(this));
                }
                else
                {
                    writer.WriteKnockoutDataBindComment("visible", "!" + GetBinding(DataSourceProperty).GetProperty <DataSourceLengthBinding>().Binding.CastTo <IValueBinding>().GetKnockoutBindingExpression(this));
                }

                if (DataSource != null && RenderWrapperTag && GetIEnumerableFromDataSource().OfType <object>().Any())
                {
                    writer.AddStyleAttribute("display", "none");
                }
            }

            base.AddAttributesToRender(writer, context);
        }
Esempio n. 16
0
 /// <summary>
 /// Adds the corresponding attribute or binding for the Visible property.
 /// </summary>
 protected virtual void AddVisibleAttributeOrBinding(IHtmlWriter writer)
 {
     writer.AddKnockoutDataBind("visible", this, VisibleProperty, renderEvenInServerRenderingMode: true);
     if (GetValue(VisibleProperty) as bool? == false)
     {
         writer.AddStyleAttribute("display", "none");
     }
 }
Esempio n. 17
0
        /// <summary>
        /// Adds all attributes that should be added to the control begin tag.
        /// </summary>
        protected override void AddAttributesToRender(IHtmlWriter writer, RenderContext context)
        {
            // render hard-coded HTML attributes
            foreach (var attribute in Attributes.Where(a => a.Value is string || a.Value == null))
            {
                writer.AddAttribute(attribute.Key, (string)attribute.Value, true);
            }

            // render binding HTML attributes
            var propertyValuePairs = Attributes.Where(a => a.Value is ValueBindingExpression)
                .Select(a => new KeyValuePair<string, ValueBindingExpression>(a.Key, (ValueBindingExpression)a.Value)).ToList();
            if (propertyValuePairs.Any())
            {
                writer.AddKnockoutDataBind("attr", propertyValuePairs, this, null);
            }

            // handle Visible property
            writer.AddKnockoutDataBind("visible", this, VisibleProperty, () =>
            {
                if (!Visible)
                {
                    writer.AddStyleAttribute("display", "none");
                }
            });

            // handle Text property
            writer.AddKnockoutDataBind("text", this, InnerTextProperty, () =>
            {
                // inner Text is rendered as attribute only if contains binding
                // otherwise it is rendered directly as encoded content
            });

            // hadle Id property
            AddControlIdAttribute(writer);

            base.AddAttributesToRender(writer, context);
        }
Esempio n. 18
0
        protected override void AddAttributesToRender(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            if (!context.IsInPartialRenderingMode)
            {
                writer.AddStyleAttribute("display", "none");
            }
            writer.AddKnockoutDataBind("if", "dotvvm.isSpaReady");

            if (!string.IsNullOrEmpty(DefaultRouteName))
            {
                var route = context.Configuration.RouteTable[DefaultRouteName];
                if (route.ParameterNames.Any())
                {
                    throw new DotvvmControlException(this, $"The route '{DefaultRouteName}' specified in SpaContentPlaceHolder DefaultRouteName property cannot contain route parameters!");
                }
                writer.AddAttribute(HostingConstants.SpaContentPlaceHolderDefaultRouteDataAttributeName, route.Url);
            }
            base.AddAttributesToRender(writer, context);
        }