Skip to content

Commit

Permalink
Merge pull request #1 from dnnsoftware/development
Browse files Browse the repository at this point in the history
Fix bug DNN-4057: copy the RegisterClientReference method from WebUtilit...
  • Loading branch information
skydnn committed Nov 18, 2013
2 parents 52721da + 7cbf57e commit b77f3d5
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#endregion

using System.Web.UI.HtmlControls;

namespace DotNetNuke.Web.Client.Providers
{
using System;
Expand Down Expand Up @@ -151,8 +154,22 @@ protected override void RegisterDependencies(HttpContextBase http, string js, st

var jsScriptBlock = new LiteralControl(js.Replace("&", "&"));
var cssStyleBlock = new LiteralControl(css.Replace("&", "&"));
page.FindControl(DnnBodyPlaceHolderName).Controls.Add(jsScriptBlock);
page.FindControl(DnnBodyPlaceHolderName).Controls.Add(cssStyleBlock);

var holderControl = page.FindControl(DnnBodyPlaceHolderName);
holderControl.Controls.Add(jsScriptBlock);
holderControl.Controls.Add(cssStyleBlock);

var form = (HtmlForm)page.FindControl("Form");
if (form != null)
{
form.Controls.Remove(holderControl);
form.Controls.AddAt(0, holderControl);
}
else
{
page.Controls.Remove(holderControl);
page.Controls.AddAt(0, holderControl);
}
}
}
}
2 changes: 1 addition & 1 deletion DNN Platform/DotNetNuke.Web/UI/WebControls/DnnFormLabel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected override void CreateChildControls()
pinLink.Attributes.Add("href", "#");
panel.Controls.Add(pinLink);

ClientAPI.RegisterClientReference(Page, ClientAPI.ClientNamespaceReferences.dnn);
JavaScript.RegisterClientReference(Page, ClientAPI.ClientNamespaceReferences.dnn);
JavaScript.RequestRegistration(CommonJs.DnnPlugins);
//ClientResourceManager.RegisterScript(this.Page, "~/Resources/Shared/Scripts/initTooltips.js");
}
Expand Down
3 changes: 2 additions & 1 deletion DNN Platform/Library/Common/Globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
using DotNetNuke.Entities.Portals;
using DotNetNuke.Entities.Tabs;
using DotNetNuke.Entities.Users;
using DotNetNuke.Framework.JavaScriptLibraries;
using DotNetNuke.Framework.Providers;
using DotNetNuke.Instrumentation;
using DotNetNuke.Security;
Expand Down Expand Up @@ -2101,7 +2102,7 @@ public static void SetFormFocus(Control control)
//JH dnn.js mod
if (ClientAPI.ClientAPIDisabled() == false)
{
ClientAPI.RegisterClientReference(control.Page, ClientAPI.ClientNamespaceReferences.dnn);
JavaScript.RegisterClientReference(control.Page, ClientAPI.ClientNamespaceReferences.dnn);
DNNClientAPI.SetInitialFocus(control.Page, control);
}
else
Expand Down
3 changes: 2 additions & 1 deletion DNN Platform/Library/Framework/CDefault.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using DotNetNuke.Entities.Controllers;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Tabs;
using DotNetNuke.Framework.JavaScriptLibraries;
using DotNetNuke.Services.GettingStarted;
using DotNetNuke.UI.Utilities;
using DotNetNuke.UI.WebControls;
Expand Down Expand Up @@ -74,7 +75,7 @@ public void ScrollToControl(Control objControl)
{
if (ClientAPI.BrowserSupportsFunctionality(ClientAPI.ClientFunctionality.Positioning))
{
ClientAPI.RegisterClientReference(this, ClientAPI.ClientNamespaceReferences.dnn_dom_positioning);
JavaScript.RegisterClientReference(this, ClientAPI.ClientNamespaceReferences.dnn_dom_positioning);
ClientAPI.RegisterClientVariable(this, "ScrollToControl", objControl.ClientID, true);
DNNClientAPI.SetScrollTop(Page);
}
Expand Down
34 changes: 33 additions & 1 deletion DNN Platform/Library/Framework/JavaScriptLibraries/JavaScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using System.Linq;
using System.Web;
using System.Web.UI;
using DotNetNuke.Application;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Host;
using DotNetNuke.Entities.Portals;
Expand Down Expand Up @@ -474,7 +475,7 @@ where item.ToString().StartsWith(LegacyPrefix)
//such as call jQuery.RegisterDnnJQueryPlugins in Control.OnInit.
if (page.Form != null)
{
ClientAPI.RegisterClientReference(page, ClientAPI.ClientNamespaceReferences.dnn);

}

//register dependency
Expand Down Expand Up @@ -555,6 +556,37 @@ public static string GetJQueryScriptReference()
return scriptsrc;
}

public static void RegisterClientReference(Page page, ClientAPI.ClientNamespaceReferences reference)
{
switch (reference)
{
case ClientAPI.ClientNamespaceReferences.dnn:
case ClientAPI.ClientNamespaceReferences.dnn_dom:
if (HttpContext.Current.Items.Contains(LegacyPrefix + "dnn.js"))
{
break;
}

ClientResourceManager.RegisterScript(page, ClientAPI.ScriptPath + "dnn.js", 12);
HttpContext.Current.Items.Add(LegacyPrefix + "dnn.js", true);

if (!ClientAPI.BrowserSupportsFunctionality(ClientAPI.ClientFunctionality.SingleCharDelimiters))
{
ClientAPI.RegisterClientVariable(page, "__scdoff", "1", true);
}

if (!ClientAPI.UseExternalScripts)
{
ClientAPI.RegisterEmbeddedResource(page, "dnn.scripts.js", typeof (ClientAPI));
}
break;
case ClientAPI.ClientNamespaceReferences.dnn_dom_positioning:
RegisterClientReference(page, ClientAPI.ClientNamespaceReferences.dnn);
ClientResourceManager.RegisterScript(page, ClientAPI.ScriptPath + "dnn.dom.positioning.js", 13);
break;
}
}

private static string GetJQueryMigrateScriptReference()
{
string scriptsrc = jQuery.HostedMigrateUrl;
Expand Down
2 changes: 1 addition & 1 deletion DNN Platform/Library/Framework/ServicesFrameworkImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void RegisterAjaxScript(Page page)
path = "/";
}
path = path.EndsWith("/") ? path : path + "/";
ClientAPI.RegisterClientReference(page, ClientAPI.ClientNamespaceReferences.dnn);
JavaScript.RegisterClientReference(page, ClientAPI.ClientNamespaceReferences.dnn);
ClientAPI.RegisterClientVariable(page, "sf_siteRoot", path, /*overwrite*/ true);
ClientAPI.RegisterClientVariable(page, "sf_tabId", PortalSettings.Current.ActiveTab.TabID.ToString(CultureInfo.InvariantCulture), /*overwrite*/ true);

Expand Down
2 changes: 1 addition & 1 deletion DNN Platform/Library/UI/UserControls/LabelControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ protected override void OnPreRender(EventArgs e)

private void RegisterClientDependencies()
{
ClientAPI.RegisterClientReference(this.Page, ClientAPI.ClientNamespaceReferences.dnn);
JavaScript.RegisterClientReference(this.Page, ClientAPI.ClientNamespaceReferences.dnn);
JavaScript.RequestRegistration(CommonJs.DnnPlugins);
//ClientResourceManager.RegisterScript(this.Page, "~/Resources/Shared/Scripts/initTooltips.js");
}
Expand Down
7 changes: 4 additions & 3 deletions DNN Platform/Library/UI/Utilities/ClientAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Framework.JavaScriptLibraries;
using DotNetNuke.Services.Localization;
using DotNetNuke.Services.Personalization;

Expand Down Expand Up @@ -123,7 +124,7 @@ public static void InitFileManager(Page objPage)

private static void AddBodyOnLoad(Page objPage, string scriptKey, string strJSFunction)
{
ClientAPI.RegisterClientReference(objPage, ClientAPI.ClientNamespaceReferences.dnn);
JavaScript.RegisterClientReference(objPage, ClientAPI.ClientNamespaceReferences.dnn);
objPage.ClientScript.RegisterStartupScript(objPage.GetType(), scriptKey, strJSFunction, true);
}

Expand All @@ -148,7 +149,7 @@ public static void EnableContainerDragAndDrop(Control objTitle, Control objConta
#pragma warning disable 612,618
AddBodyOnloadEventHandler(objTitle.Page, "__dnn_enableDragDrop()");
#pragma warning restore 612,618
ClientAPI.RegisterClientReference(objTitle.Page, ClientAPI.ClientNamespaceReferences.dnn_dom_positioning);
JavaScript.RegisterClientReference(objTitle.Page, ClientAPI.ClientNamespaceReferences.dnn_dom_positioning);
ClientAPI.RegisterClientVariable(objTitle.Page, "__dnn_dragDrop", objContainer.ClientID + " " + objTitle.ClientID + " " + ModuleID + ";", false);
string strPanes = "";
string strPaneNames = "";
Expand Down Expand Up @@ -239,7 +240,7 @@ public static void EnableMinMax(Control objButton, Control objContent, int intMo
{
if (ClientAPI.BrowserSupportsFunctionality(ClientAPI.ClientFunctionality.DHTML))
{
ClientAPI.RegisterClientReference(objButton.Page, ClientAPI.ClientNamespaceReferences.dnn_dom);
JavaScript.RegisterClientReference(objButton.Page, ClientAPI.ClientNamespaceReferences.dnn_dom);
switch (ePersistanceType)
{
case MinMaxPersistanceType.None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);

ClientAPI.RegisterClientReference(Page, ClientAPI.ClientNamespaceReferences.dnn);
JavaScript.RegisterClientReference(Page, ClientAPI.ClientNamespaceReferences.dnn);
JavaScript.RequestRegistration(CommonJs.DnnPlugins);
ClientResourceManager.RegisterScript(this.Page, "~/Resources/Shared/Scripts/initTooltips.js");
}
Expand Down
3 changes: 2 additions & 1 deletion DNN Platform/Modules/DigitalAssets/FolderMappings.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using DotNetNuke.Application;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Framework.JavaScriptLibraries;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.FileSystem;
using DotNetNuke.Services.Localization;
Expand Down Expand Up @@ -90,7 +91,7 @@ protected List<FolderMappingInfo> FolderMappingsList
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
ClientAPI.RegisterClientReference(Page, ClientAPI.ClientNamespaceReferences.dnn);
JavaScript.RegisterClientReference(Page, ClientAPI.ClientNamespaceReferences.dnn);
CancelButton.NavigateUrl = Globals.NavigateURL();
NewMappingButton.Click += OnNewMappingClick;

Expand Down
3 changes: 2 additions & 1 deletion Website/DesktopModules/Admin/Tabs/Tabs.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
using DotNetNuke.Entities.Tabs;
using DotNetNuke.Entities.Users;
using DotNetNuke.Framework;
using DotNetNuke.Framework.JavaScriptLibraries;
using DotNetNuke.Instrumentation;
using DotNetNuke.Security;
using DotNetNuke.Security.Permissions;
Expand Down Expand Up @@ -242,7 +243,7 @@ protected override void OnInit(EventArgs e)

jQuery.RequestDnnPluginsRegistration();

ClientAPI.RegisterClientReference(Page, ClientAPI.ClientNamespaceReferences.dnn_dom);
JavaScript.RegisterClientReference(Page, ClientAPI.ClientNamespaceReferences.dnn_dom);
ClientAPI.RegisterClientScriptBlock(Page, "dnn.controls.js");
dgPermissions.RegisterScriptsForAjaxPanel();
}
Expand Down
3 changes: 2 additions & 1 deletion Website/admin/Skins/Search.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Host;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Framework.JavaScriptLibraries;
using DotNetNuke.Services.Localization;
using DotNetNuke.UI.Utilities;
using DotNetNuke.Web.Client.ClientResourceManagement;
Expand Down Expand Up @@ -565,7 +566,7 @@ protected override void OnPreRender(EventArgs e)
SearchType = "S";
}

ClientAPI.RegisterClientReference(this.Page, ClientAPI.ClientNamespaceReferences.dnn);
JavaScript.RegisterClientReference(this.Page, ClientAPI.ClientNamespaceReferences.dnn);
ClientResourceManager.RegisterScript(Page, "~/Resources/Search/Search.js", FileOrder.Js.DefaultPriority, "DnnFormBottomProvider");

txtSearchNew.Attributes.Add("autocomplete", "off");
Expand Down

0 comments on commit b77f3d5

Please sign in to comment.