/// <summary> /// Generates the ControlSpecific JavaScript. This script is safe to /// allow multiple callbacks to run simultaneously. /// </summary> private void GenerateControlSpecificJavaScript() { // Figure out the initial URL we're going to // Either it's the provided URL from the control or // we're posting back to the current page string Url = null; if (ServerUrl == null || ServerUrl == "") { Url = Context.Request.Path; } else { Url = ResolveUrl(ServerUrl); } //Uri ExistingUrl = Context.Request.Url; //// Must fix up URL into fully qualified URL for XmlHttp //if (!ServerUrl.ToLower().StartsWith("http")) // Url = ExistingUrl.Scheme + "://" + ExistingUrl.Authority + Url; string CallbackHandler = ClientCompleteHandler; if (string.IsNullOrEmpty(CallbackHandler)) { CallbackHandler = "null"; } string StartupCode = "function " + ClientID + @"_GetHoverPanel() { var hover = new HoverPanel(""#" + ClientID + @"""); hover.serverUrl = """ + Url + @"""; hover.timeout = " + Timeout.ToString() + @"; hover.completed = " + CallbackHandler + @"; hover.htmlTargetId = """ + (HtmlTargetClientId == "" ? ClientID : HtmlTargetClientId) + @"""; hover.postbackMode = """ + PostBackMode.ToString() + @"""; hover.navigateDelay = " + NavigateDelay.ToString() + @"; hover.adjustWindowPosition = " + AdjustWindowPosition.ToString().ToLower() + @"; hover.eventHandlerMode = """ + EventHandlerMode.ToString() + @"""; hover.shadowOpacity = " + ShadowOpacity.ToString(CultureInfo.InvariantCulture.NumberFormat) + @"; hover.shadowOffset = " + ShadowOffset + @"; hover.hoverOffsetRight = " + HoverOffsetRight.ToString() + @"; hover.hoverOffsetBottom = " + HoverOffsetBottom.ToString() + @"; return hover; } $( function() { window." + ClientID + " = " + ClientID + @"_GetHoverPanel(); }); "; ScriptProxy.RegisterStartupScript(this, GetType(), ClientID + "_STARTUP", StartupCode, true); }
protected override void OnPreRender(EventArgs e) { StringBuilder startupScript = new StringBuilder(2048); string DhId = DragHandleID; if (string.IsNullOrEmpty(DragHandleID)) { DragHandleID = ClientID; } Control Ctl = FindControl(DragHandleID); if (Ctl != null) { DhId = Ctl.ClientID; } startupScript.AppendLine("\t$('#" + ClientID + "')"); if (Closable && !string.IsNullOrEmpty(DragHandleID)) { string imageUrl = CloseBoxImage; if (imageUrl == "WebResource") { imageUrl = ScriptProxy.GetWebResourceUrl(this, GetType(), WebResources.CLOSE_ICON_RESOURCE); } StringBuilder closableOptions = new StringBuilder("imageUrl: '" + imageUrl + "'"); if (!string.IsNullOrEmpty(DragHandleID)) { closableOptions.Append(",handle: $('#" + DragHandleID + "')"); } if (!string.IsNullOrEmpty(ClientDialogHandler)) { closableOptions.Append(",handler: " + ClientDialogHandler); } if (FadeOnClose) { closableOptions.Append(",fadeOut: 'slow'"); } startupScript.AppendLine("\t\t.closable({ " + closableOptions + "})"); } string options = ""; if (Draggable) { // force auto stacking of windows (last dragged to top of zIndex) options = "{ stack: \"*\", opacity: 0.80, dragDelay: " + DragDelay.ToString(); if (!string.IsNullOrEmpty(DragHandleID)) { options += ",handle:'#" + DragHandleID + "'"; } if (!string.IsNullOrEmpty(Cursor)) { options += ",cursor:'" + Cursor + "'"; } options += " }"; startupScript.AppendLine("\t\t.draggable(" + options + " )"); } if (ShadowOffset != 0) { startupScript.AppendLine( "\t\t.shadow({ opacity:" + ShadowOpacity.ToString(CultureInfo.InvariantCulture.NumberFormat) + ",offset:" + ShadowOffset.ToString() + "})"); } if (Centered) { startupScript.AppendLine( "\t\t.centerInClient()"); } startupScript.Length = startupScript.Length - 2; // strip last CR/LF \r\n startupScript.AppendLine(";"); string script = "$( function() {\r\n" + startupScript + "});"; ScriptProxy.RegisterStartupScript(this, GetType(), ID + "_DragBehavior", script, true); base.OnPreRender(e); }