示例#1
0
        // Web Forms compatibility. Remove when EnduraCode goal 790 is complete.
        private ElementActivationBehavior(ResourceInfo resource = null, FormAction action = null, string script = "")
        {
            if (action == null && !script.Any())
            {
                HyperlinkBehavior hyperlinkBehavior = resource;

                Classes               = hyperlinkBehavior.HasDestination() ? ActivatableClass : ElementClassSet.Empty;
                AttributeGetter       = () => hyperlinkBehavior.AttributeGetter(true);
                IncludeIdAttribute    = hyperlinkBehavior.IncludesIdAttribute(true);
                EtherealChildren      = hyperlinkBehavior.EtherealChildren;
                JsInitStatementGetter = id => hyperlinkBehavior.JsInitStatementGetter(id, true);
                IsFocusable           = hyperlinkBehavior.IsFocusable;
                PostBackAdder         = hyperlinkBehavior.PostBackAdder;
            }
            else
            {
                var buttonBehavior = action != null ? (ButtonBehavior) new FormActionBehavior(action) : new CustomButtonBehavior(() => script + ";");

                Classes               = ActivatableClass;
                AttributeGetter       = () => buttonBehavior.GetAttributes().Materialize();
                IncludeIdAttribute    = buttonBehavior.IncludesIdAttribute();
                EtherealChildren      = buttonBehavior.GetEtherealChildren();
                JsInitStatementGetter = buttonBehavior.GetJsInitStatements;
                IsFocusable           = true;
                PostBackAdder         = buttonBehavior.AddPostBack;
            }

            this.resource = resource;
            this.action   = action;
            this.script   = script;
        }
示例#2
0
 private ElementActivationBehavior(HyperlinkBehavior hyperlinkBehavior)
 {
     Classes               = hyperlinkBehavior.HasDestination() ? ActivatableClass : ElementClassSet.Empty;
     AttributeGetter       = () => hyperlinkBehavior.AttributeGetter(true);
     IncludeIdAttribute    = hyperlinkBehavior.IncludesIdAttribute(true);
     EtherealChildren      = hyperlinkBehavior.EtherealChildren;
     JsInitStatementGetter = id => hyperlinkBehavior.JsInitStatementGetter(id, true);
     IsFocusable           = hyperlinkBehavior.IsFocusable;
     PostBackAdder         = hyperlinkBehavior.PostBackAdder;
 }