/// ----------------------------------------------------------------------------- /// <summary> /// Allows any module to have drag and drop functionality enabled /// </summary> /// <param name="objTitle">Title element that responds to the click and dragged</param> /// <param name="objContainer">Container</param> /// <param name="ModuleID">Module ID</param> /// <remarks> /// This sub also will send down information to notify the client of the panes that have been defined in the current skin. /// </remarks> /// <history> /// [Jon Henning] 8/9/2004 Created /// </history> /// ----------------------------------------------------------------------------- public static void EnableContainerDragAndDrop(Control objTitle, Control objContainer, int ModuleID) { if (ClientAPI.ClientAPIDisabled() == false && ClientAPI.BrowserSupportsFunctionality(ClientAPI.ClientFunctionality.Positioning)) { AddBodyOnloadEventHandler(objTitle.Page, "__dnn_enableDragDrop()"); ClientAPI.RegisterClientReference(objTitle.Page, ClientAPI.ClientNamespaceReferences.dnn_dom_positioning); ClientAPI.RegisterClientVariable(objTitle.Page, "__dnn_dragDrop", objContainer.ClientID + " " + objTitle.ClientID + " " + ModuleID + ";", false); string strPanes = ""; string strPaneNames = ""; var objPortalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"]; Control objCtl; foreach (string strPane in objPortalSettings.ActiveTab.Panes) { objCtl = Common.Globals.FindControlRecursive(objContainer.Parent, strPane); if (objCtl != null) { strPanes += objCtl.ClientID + ";"; } strPaneNames += strPane + ";"; } ClientAPI.RegisterClientVariable(objTitle.Page, "__dnn_Panes", strPanes, true); ClientAPI.RegisterClientVariable(objTitle.Page, "__dnn_PaneNames", strPaneNames, true); } }
/// <Summary>Adds client side body.onload event handler</Summary> /// <Param name="objPage">Current page rendering content</Param> /// <Param name="strJSFunction">Javascript function name to execute</Param> public static void AddBodyOnloadEventHandler(Page objPage, string strJSFunction) { if (strJSFunction.EndsWith(";") == false) { strJSFunction += ";"; } ClientAPI.RegisterClientReference(objPage, ClientAPI.ClientNamespaceReferences.dnn); if (ClientAPI.GetClientVariable(objPage, "__dnn_pageload").IndexOf(strJSFunction) == -1) { ClientAPI.RegisterClientVariable(objPage, "__dnn_pageload", strJSFunction, false); } }
public static void EnableMinMax(Control objButton, Control objContent, int intModuleId, bool blnDefaultMin, string strMinIconLoc, string strMaxIconLoc, MinMaxPersistanceType ePersistanceType, int intAnimationFrames, string strPersonalizationNamingCtr, string strPersonalizationKey) { if (ClientAPI.BrowserSupportsFunctionality(ClientAPI.ClientFunctionality.DHTML)) { ClientAPI.RegisterClientReference(objButton.Page, ClientAPI.ClientNamespaceReferences.dnn_dom); switch (ePersistanceType) { case MinMaxPersistanceType.None: AddAttribute(objButton, "onclick", "if (__dnn_SectionMaxMin(this, '" + objContent.ClientID + "')) return false;"); if (!String.IsNullOrEmpty(strMinIconLoc)) { AddAttribute(objButton, "max_icon", strMaxIconLoc); AddAttribute(objButton, "min_icon", strMinIconLoc); } break; case MinMaxPersistanceType.Page: AddAttribute(objButton, "onclick", "if (__dnn_SectionMaxMin(this, '" + objContent.ClientID + "')) return false;"); if (!String.IsNullOrEmpty(strMinIconLoc)) { AddAttribute(objButton, "max_icon", strMaxIconLoc); AddAttribute(objButton, "min_icon", strMinIconLoc); } break; case MinMaxPersistanceType.Cookie: if (intModuleId != -1) { AddAttribute(objButton, "onclick", "if (__dnn_ContainerMaxMin_OnClick(this, '" + objContent.ClientID + "')) return false;"); ClientAPI.RegisterClientVariable(objButton.Page, "containerid_" + objContent.ClientID, intModuleId.ToString(), true); ClientAPI.RegisterClientVariable(objButton.Page, "cookieid_" + objContent.ClientID, "_Module" + intModuleId + "_Visible", true); ClientAPI.RegisterClientVariable(objButton.Page, "min_icon_" + intModuleId, strMinIconLoc, true); ClientAPI.RegisterClientVariable(objButton.Page, "max_icon_" + intModuleId, strMaxIconLoc, true); ClientAPI.RegisterClientVariable(objButton.Page, "max_text", Localization.GetString("Maximize"), true); ClientAPI.RegisterClientVariable(objButton.Page, "min_text", Localization.GetString("Minimize"), true); if (blnDefaultMin) { ClientAPI.RegisterClientVariable(objButton.Page, "__dnn_" + intModuleId + ":defminimized", "true", true); } } break; case MinMaxPersistanceType.Personalization: //Regardless if we determine whether or not the browser supports client-side personalization //we need to store these keys to properly display or hide the content (They are needed in MinMaxContentVisible) AddAttribute(objButton, "userctr", strPersonalizationNamingCtr); AddAttribute(objButton, "userkey", strPersonalizationKey); if (EnableClientPersonalization(strPersonalizationNamingCtr, strPersonalizationKey, objButton.Page)) { AddAttribute(objButton, "onclick", "if (__dnn_SectionMaxMin(this, '" + objContent.ClientID + "')) return false;"); if (!String.IsNullOrEmpty(strMinIconLoc)) { AddAttribute(objButton, "max_icon", strMaxIconLoc); AddAttribute(objButton, "min_icon", strMinIconLoc); } } break; } } if (MinMaxContentVisibile(objButton, intModuleId, blnDefaultMin, ePersistanceType)) { if (ClientAPI.BrowserSupportsFunctionality(ClientAPI.ClientFunctionality.DHTML)) { AddStyleAttribute(objContent, "display", ""); } else { objContent.Visible = true; } if (!String.IsNullOrEmpty(strMinIconLoc)) { SetMinMaxProperties(objButton, strMinIconLoc, Localization.GetString("Minimize"), Localization.GetString("Minimize")); } } else { if (ClientAPI.BrowserSupportsFunctionality(ClientAPI.ClientFunctionality.DHTML)) { AddStyleAttribute(objContent, "display", "none"); } else { objContent.Visible = false; } if (!String.IsNullOrEmpty(strMaxIconLoc)) { SetMinMaxProperties(objButton, strMaxIconLoc, Localization.GetString("Maximize"), Localization.GetString("Maximize")); } } if (intAnimationFrames != 5) { ClientAPI.RegisterClientVariable(objButton.Page, "animf_" + objContent.ClientID, intAnimationFrames.ToString(), true); } }
private static void AddBodyOnLoad(Page objPage, string scriptKey, string strJSFunction) { ClientAPI.RegisterClientReference(objPage, ClientAPI.ClientNamespaceReferences.dnn); objPage.ClientScript.RegisterStartupScript(objPage.GetType(), scriptKey, strJSFunction, true); }
public static void EnableMinMax(Control objButton, Control objContent, int intModuleId, bool blnDefaultMin, string strMinIconLoc, string strMaxIconLoc, MinMaxPersistanceType ePersistanceType, int intAnimationFrames) { if (ClientAPI.BrowserSupportsFunctionality(ClientAPI.ClientFunctionality.DHTML)) { ClientAPI.RegisterClientReference(objButton.Page, ClientAPI.ClientNamespaceReferences.dnn_dom); switch (ePersistanceType) { case MinMaxPersistanceType.None: AddAttribute(objButton, "onclick", "if (__dnn_SectionMaxMin(this, '" + objContent.ClientID + "')) return false;"); // HACK : Modified to not error if object is null. //if (strMinIconLoc.Length > 0) if (!String.IsNullOrEmpty(strMaxIconLoc)) { AddAttribute(objButton, "max_icon", strMaxIconLoc); AddAttribute(objButton, "min_icon", strMinIconLoc); } break; case MinMaxPersistanceType.Page: AddAttribute(objButton, "onclick", "if (__dnn_SectionMaxMin(this, '" + objContent.ClientID + "')) return false;"); // HACK : Modified to not error if object is null. //if (strMinIconLoc.Length > 0) if (!String.IsNullOrEmpty(strMaxIconLoc)) { AddAttribute(objButton, "max_icon", strMaxIconLoc); AddAttribute(objButton, "min_icon", strMinIconLoc); } break; case MinMaxPersistanceType.Cookie: if (intModuleId != -1) { AddAttribute(objButton, "onclick", "if (__dnn_ContainerMaxMin_OnClick(this, '" + objContent.ClientID + "')) return false;"); AddAttribute(objButton, "containerid", intModuleId.ToString()); AddAttribute(objButton, "cookieid", "_Module" + intModuleId + "_Visible"); //needed to set cookie on the client side ClientAPI.RegisterClientVariable(objButton.Page, "min_icon_" + intModuleId, strMinIconLoc, true); ClientAPI.RegisterClientVariable(objButton.Page, "max_icon_" + intModuleId, strMaxIconLoc, true); ClientAPI.RegisterClientVariable(objButton.Page, "max_text", Localization.GetString("Maximize"), true); ClientAPI.RegisterClientVariable(objButton.Page, "min_text", Localization.GetString("Minimize"), true); if (blnDefaultMin) { ClientAPI.RegisterClientVariable(objButton.Page, "__dnn_" + intModuleId + ":defminimized", "true", true); } } break; } } if (GetMinMaxContentVisibile(objButton, intModuleId, blnDefaultMin, ePersistanceType)) { if (ClientAPI.BrowserSupportsFunctionality(ClientAPI.ClientFunctionality.DHTML)) { AddStyleAttribute(objContent, "display", ""); } else { objContent.Visible = true; } // HACK : Modified to not error if object is null. //if (strMinIconLoc.Length > 0) if (!String.IsNullOrEmpty(strMaxIconLoc)) { SetMinMaxProperties(objButton, strMinIconLoc, Localization.GetString("Minimize"), Localization.GetString("Minimize")); } } else { if (ClientAPI.BrowserSupportsFunctionality(ClientAPI.ClientFunctionality.DHTML)) { AddStyleAttribute(objContent, "display", "none"); } else { objContent.Visible = false; } // HACK : Modified to not error if object is null. //if (strMaxIconLoc.Length > 0) if (!String.IsNullOrEmpty(strMaxIconLoc)) { SetMinMaxProperties(objButton, strMaxIconLoc, Localization.GetString("Maximize"), Localization.GetString("Maximize")); } } if (intAnimationFrames != 5) { AddAttribute(objButton, "animf", intAnimationFrames.ToString()); } }