WebControl ActionControlStyle.SetUpControl(WebControl control, string defaultText)
        {
            control.CssClass =
                control.CssClass.ConcatenateWithSpace(
                    ActionComponentCssElementCreator.AllStylesClass.ClassName + " " + ActionComponentCssElementCreator.ImageStyleClass.ClassName);

            if (rolloverImageInfo != null && rolloverImageInfo.GetUrl() != imageInfo.GetUrl())
            {
                control.AddJavaScriptEventScript(
                    JavaScriptWriting.JsWritingMethods.onmouseover,
                    "$( this ).children().attr( 'src', '{0}' )".FormatWith(rolloverImageInfo.GetUrl()));
                control.AddJavaScriptEventScript(
                    JavaScriptWriting.JsWritingMethods.onmouseout,
                    "$( this ).children().attr( 'src', '{0}' )".FormatWith(imageInfo.GetUrl()));
            }

            control.AddControlsReturnThis(
                new EwfImage(
                    new ImageSetup(
                        AlternateText,
                        sizesToAvailableWidth: SizesToAvailableWidth,
                        classes: SizesToAvailableWidth ? new ElementClass("ewfBlockContainer") : ElementClassSet.Empty),
                    imageInfo).ToCollection().GetControls());

            return(null);
        }
コード例 #2
0
        void ControlTreeDataLoader.LoadData()
        {
            var url = "";

            if (destinationResourceInfo != null && !(destinationResourceInfo.AlternativeMode is DisabledResourceMode))
            {
                url = destinationResourceInfo.GetUrl();
                Attributes.Add("href", this.GetClientUrl(url));
            }

            if (isPostBackButton && url.Any())
            {
                var postBack = GetLinkPostBack(destinationResourceInfo);
                EwfPage.Instance.AddPostBack(postBack);
                PreRender += delegate { this.AddJavaScriptEventScript(JsWritingMethods.onclick, PostBackButton.GetPostBackScript(postBack)); };
            }
            if (navigatesInNewWindow)
            {
                Attributes.Add("target", "_blank");
            }
            if (popUpWindowSettings != null && url.Any())
            {
                this.AddJavaScriptEventScript(JsWritingMethods.onclick, JsWritingMethods.GetPopUpWindowScript(url, this, popUpWindowSettings) + " return false");
            }
            if (navigatesInOpeningWindow && (destinationResourceInfo == null || url.Any()))
            {
                var openingWindowNavigationScript = destinationResourceInfo != null ? "opener.document.location = '" + this.GetClientUrl(url) + "'; " : "";
                this.AddJavaScriptEventScript(JsWritingMethods.onclick, openingWindowNavigationScript + "window.close(); return false");
            }

            CssClass = CssClass.ConcatenateWithSpace("ewfClickable");
            if (destinationResourceInfo != null && destinationResourceInfo.AlternativeMode is NewContentResourceMode)
            {
                CssClass = CssClass.ConcatenateWithSpace(CssElementCreator.NewContentClass);
            }
            ActionControlStyle.SetUpControl(this, url, width, height, setWidth);

            if (destinationResourceInfo != null && destinationResourceInfo.AlternativeMode is DisabledResourceMode)
            {
                var message = (destinationResourceInfo.AlternativeMode as DisabledResourceMode).Message;
                new ToolTip(EnterpriseWebFramework.Controls.ToolTip.GetToolTipTextControl(message.Any() ? message : Translation.ThePageYouRequestedIsDisabled), this);
            }
            else if (toolTip != null || toolTipControl != null)
            {
                new ToolTip(toolTipControl ?? EnterpriseWebFramework.Controls.ToolTip.GetToolTipTextControl(toolTip), this);
            }
        }
コード例 #3
0
        void ControlTreeDataLoader.LoadData()
        {
            if (!SizesToAvailableWidth)
            {
                Attributes.Add("src", this.GetClientUrl(imageInfo.GetUrl(true, true, false)));
                Attributes.Add("alt", AlternateText ?? "");
            }
            else
            {
                Controls.Add(new EwfImage(imageInfo)
                {
                    IsAutoSizer = true, AlternateText = AlternateText
                });
            }
            CssClass = CssClass.ConcatenateWithSpace(IsAutoSizer ? "ewfAutoSizer" : CssElementCreator.CssClass);

            if (ToolTip != null || ToolTipControl != null)
            {
                new ToolTip(ToolTipControl ?? EnterpriseWebFramework.Controls.ToolTip.GetToolTipTextControl(ToolTip), this);
            }
        }
コード例 #4
0
        string ControlWithJsInitLogic.GetJsInitStatements()
        {
            var script = new StringBuilder();

            if (watermarkText.Any())
            {
                var restorationStatement = "$( '#" + textBox.ClientID + "' ).filter( function() { return this.value == ''; } ).val( '" + watermarkText + "' );";

                // The first line is for bfcache browsers; the second is for all others. See http://stackoverflow.com/q/1195440/35349.
                script.Append("$( window ).on( 'pagehide', function() { " + restorationStatement + " } );");
                script.Append(restorationStatement);
            }

            if (autoCompleteService != null)
            {
                const int delay         = 250;         // Default delay is 300 ms.
                const int minCharacters = 3;

                var autocompleteOptions = new List <Tuple <string, string> >();
                autocompleteOptions.Add(Tuple.Create("delay", delay.ToString()));
                autocompleteOptions.Add(Tuple.Create("minLength", minCharacters.ToString()));
                autocompleteOptions.Add(Tuple.Create("source", "'" + autoCompleteService.GetUrl() + "'"));

                if (autoCompleteOption != AutoCompleteOption.NoPostBack)
                {
                    var handler = "function( event, ui ) {{ $( '#{0}' ).val( ui.item.value ); {1}; }}".FormatWith(
                        textBox.ClientID,
                        PostBackButton.GetPostBackScript(postBack));
                    autocompleteOptions.Add(Tuple.Create("select", handler));
                }

                script.Append(
                    @"$( '#" + textBox.ClientID +
                    "' ).autocomplete( {{ {0} }} );".FormatWith(
                        autocompleteOptions.Select(o => "{0}: {1}".FormatWith(o.Item1, o.Item2)).GetCommaDelimitedStringFromCollection()));
            }

            return(script.ToString());
        }
コード例 #5
0
 private string getClientUrl( WebControl control, ResourceInfo imageInfo )
 {
     return control.GetClientUrl( imageInfo.GetUrl( true, true, false ) );
 }
コード例 #6
0
        internal static PostBack GetLinkPostBack(ResourceInfo destination)
        {
            var id = PostBack.GetCompositeId("ewfLink", destination.GetUrl());

            return(EwfPage.Instance.GetPostBack(id) ?? PostBack.CreateFull(id: id, actionGetter: () => new PostBackAction(destination)));
        }
コード例 #7
0
        internal void SetUpClickableControl(WebControl clickableControl)
        {
            if (resource == null && action == null && script == "")
            {
                return;
            }

            clickableControl.CssClass = clickableControl.CssClass.ConcatenateWithSpace("ewfClickable");

            if (resource != null && EwfPage.Instance.IsAutoDataUpdater)
            {
                action   = HyperlinkBehavior.GetHyperlinkPostBackAction(resource);
                resource = null;
            }

            Func <string> scriptGetter;

            if (resource != null)
            {
                scriptGetter = () => "location.href = '" + EwfPage.Instance.GetClientUrl(resource.GetUrl()) + "'; return false";
            }
            else if (action != null)
            {
                action.AddToPageIfNecessary();
                scriptGetter = () => action.GetJsStatements() + " return false";
            }
            else
            {
                scriptGetter = () => script;
            }

            // Defer script generation until after all controls have IDs.
            EwfPage.Instance.PreRender += delegate { clickableControl.AddJavaScriptEventScript(JsWritingMethods.onclick, scriptGetter()); };
        }
コード例 #8
0
        internal void SetUpClickableControl(WebControl clickableControl)
        {
            if (resource == null && postBack == null && script == "")
            {
                return;
            }

            clickableControl.CssClass = clickableControl.CssClass.ConcatenateWithSpace("ewfClickable");

            if (resource != null && EwfPage.Instance.IsAutoDataUpdater)
            {
                postBack = EwfLink.GetLinkPostBack(resource);
                resource = null;
            }

            Func <string> scriptGetter;

            if (resource != null)
            {
                scriptGetter = () => "location.href = '" + EwfPage.Instance.GetClientUrl(resource.GetUrl()) + "'; return false";
            }
            else if (postBack != null)
            {
                EwfPage.Instance.AddPostBack(postBack);
                scriptGetter = () => PostBackButton.GetPostBackScript(postBack);
            }
            else
            {
                scriptGetter = () => script;
            }

            // Defer script generation until after all controls have IDs.
            EwfPage.Instance.PreRender += delegate { clickableControl.AddJavaScriptEventScript(JsWritingMethods.onclick, scriptGetter()); };
        }
コード例 #9
0
        void ControlTreeDataLoader.LoadData()
        {
            var isTextarea = rows > 1;

            textBox    = new WebControl(isTextarea ? HtmlTextWriterTag.Textarea : HtmlTextWriterTag.Input);
            PreRender += delegate {
                if (!isTextarea)
                {
                    textBox.Attributes.Add("type", masksCharacters ? "password" : "text");
                }
                textBox.Attributes.Add("name", UniqueID);
                if (isTextarea)
                {
                    textBox.Attributes.Add("rows", rows.ToString());
                }
                if (maxLength.HasValue)
                {
                    textBox.Attributes.Add("maxlength", maxLength.Value.ToString());
                }
                if (readOnly)
                {
                    textBox.Attributes.Add("readonly", "readonly");
                }
                if (disableBrowserAutoComplete || autoCompleteService != null)
                {
                    textBox.Attributes.Add("autocomplete", "off");
                }
                if (suggestSpellCheck.HasValue)
                {
                    textBox.Attributes.Add("spellcheck", suggestSpellCheck.Value.ToString().ToLower());
                }

                var value            = formValue.GetValue(AppRequestState.Instance.EwfPageRequestState.PostBackValues);
                var valueOrWatermark = watermarkText.Any() && !value.Any() ? watermarkText : value;
                if (isTextarea)
                {
                    textBox.Controls.Add(new Literal {
                        Text = HttpUtility.HtmlEncode(GetTextareaValue(valueOrWatermark))
                    });
                }
                else if (!masksCharacters)
                {
                    textBox.Attributes.Add("value", valueOrWatermark);
                }
            };
            Controls.Add(textBox);

            if (watermarkText.Any())
            {
                textBox.AddJavaScriptEventScript(JsWritingMethods.onfocus, "if( value == '" + watermarkText + "' ) value = ''");
                textBox.AddJavaScriptEventScript(JsWritingMethods.onblur, "if( value == '' ) value = '" + watermarkText + "'");
                EwfPage.Instance.ClientScript.RegisterOnSubmitStatement(
                    GetType(),
                    UniqueID + "watermark",
                    "$( '#" + textBox.ClientID + "' ).filter( function() { return this.value == '" + watermarkText + "'; } ).val( '' )");
            }

            if (!isTextarea || autoPostBack || (autoCompleteService != null && autoCompleteOption != AutoCompleteOption.NoPostBack))
            {
                action.AddToPageIfNecessary();
            }
            if (!isTextarea)
            {
                PreRender +=
                    delegate {
                    SubmitButton.EnsureImplicitSubmissionAction(
                        this,
                        action,
                        autoPostBack || (autoCompleteService != null && autoCompleteOption == AutoCompleteOption.PostBackOnTextChangeAndItemSelect));
                }
            }
            ;

            if (autoPostBack || (autoCompleteService != null && autoCompleteOption == AutoCompleteOption.PostBackOnTextChangeAndItemSelect))
            {
                PreRender += delegate {
                    // Use setTimeout to prevent keypress and change from *both* triggering post-backs at the same time when Enter is pressed after a text change.
                    textBox.AddJavaScriptEventScript(JsWritingMethods.onchange, "setTimeout( function() { " + action.GetJsStatements() + " }, 0 )");
                }
            }
            ;

            if (ToolTip != null || ToolTipControl != null)
            {
                new ToolTip(ToolTipControl ?? EnterpriseWebFramework.Controls.ToolTip.GetToolTipTextControl(ToolTip), textBox);
            }
        }

        string ControlWithJsInitLogic.GetJsInitStatements()
        {
            var script = new StringBuilder();

            if (watermarkText.Any())
            {
                var restorationStatement = "$( '#" + textBox.ClientID + "' ).filter( function() { return this.value == ''; } ).val( '" + watermarkText + "' );";

                // The first line is for bfcache browsers; the second is for all others. See http://stackoverflow.com/q/1195440/35349.
                script.Append("$( window ).on( 'pagehide', function() { " + restorationStatement + " } );");
                script.Append(restorationStatement);
            }

            if (autoCompleteService != null)
            {
                const int delay         = 250;         // Default delay is 300 ms.
                const int minCharacters = 3;

                var autocompleteOptions = new List <Tuple <string, string> >();
                autocompleteOptions.Add(Tuple.Create("delay", delay.ToString()));
                autocompleteOptions.Add(Tuple.Create("minLength", minCharacters.ToString()));
                autocompleteOptions.Add(Tuple.Create("source", "'" + autoCompleteService.GetUrl() + "'"));

                if (autoCompleteOption != AutoCompleteOption.NoPostBack)
                {
                    var handler = "function( event, ui ) {{ $( '#{0}' ).val( ui.item.value ); {1} return false; }}".FormatWith(textBox.ClientID, action.GetJsStatements());
                    autocompleteOptions.Add(Tuple.Create("select", handler));
                }

                script.Append(
                    @"$( '#" + textBox.ClientID +
                    "' ).autocomplete( {{ {0} }} );".FormatWith(
                        autocompleteOptions.Select(o => "{0}: {1}".FormatWith(o.Item1, o.Item2)).GetCommaDelimitedStringFromCollection()));
            }

            return(script.ToString());
        }

        FormValue FormValueControl.FormValue {
            get { return(formValue); }
        }
コード例 #10
0
 private string getClientUrl(WebControl control, ResourceInfo imageInfo)
 {
     return(control.GetClientUrl(imageInfo.GetUrl(true, true, false)));
 }
コード例 #11
0
 internal static PostBack GetLinkPostBack( ResourceInfo destination )
 {
     var id = PostBack.GetCompositeId( "ewfLink", destination.GetUrl() );
     return EwfPage.Instance.GetPostBack( id ) ?? PostBack.CreateFull( id: id, actionGetter: () => new PostBackAction( destination ) );
 }