From e884d7225bb753d8c2c3c8cdab3ae80576106ec3 Mon Sep 17 00:00:00 2001 From: Shandem Date: Mon, 21 Jun 2010 12:38:29 +0000 Subject: [PATCH] Fixes issue of not registering JSSource for IActions [TFS Changeset #70482] --- .../controls/Tree/JTreeContextMenuItem.cs | 4 ++-- .../umbraco/controls/Tree/TreeControl.ascx.cs | 20 ++++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/umbraco/presentation/umbraco/controls/Tree/JTreeContextMenuItem.cs b/umbraco/presentation/umbraco/controls/Tree/JTreeContextMenuItem.cs index 8b33f22670..d97711a6d0 100644 --- a/umbraco/presentation/umbraco/controls/Tree/JTreeContextMenuItem.cs +++ b/umbraco/presentation/umbraco/controls/Tree/JTreeContextMenuItem.cs @@ -64,8 +64,8 @@ namespace umbraco.controls.Tree //required by jsTree data.Add("visible", JSONSerializer.ToJSONObject("function() {return true;}")); - //The action handler is what is assigned to the IAction, but for flexibility, we'll call our onContextMenuSelect method which will need to return true if the function is to execute. - //TODO: Check if there is a JSSource + + //The action handler is what is assigned to the IAction, but for flexibility, we'll call our onContextMenuSelect method which will need to return true if the function is to execute. data.Add("action", JSONSerializer.ToJSONObject("function(N,T){" + a.JsFunctionName + ";}")); return data; diff --git a/umbraco/presentation/umbraco/controls/Tree/TreeControl.ascx.cs b/umbraco/presentation/umbraco/controls/Tree/TreeControl.ascx.cs index addd7b01f9..18c503f9ca 100644 --- a/umbraco/presentation/umbraco/controls/Tree/TreeControl.ascx.cs +++ b/umbraco/presentation/umbraco/controls/Tree/TreeControl.ascx.cs @@ -162,7 +162,7 @@ namespace umbraco.controls.Tree } /// - /// Returns the requires JavaScript as a string for the current application + /// Returns the required JavaScript as a string for the current application /// public string JSCurrApp { @@ -258,6 +258,8 @@ namespace umbraco.controls.Tree //Render out the JavaScript associated with all of the trees for the application RenderTreeJS(); + RenderActionJS(); + //apply the styles if (Width != Unit.Empty) TreeContainer.Style.Add( HtmlTextWriterStyle.Width, Width.ToString()); @@ -365,13 +367,25 @@ namespace umbraco.controls.Tree } } - - private void RenderTreeJS() { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Trees_" + GetCurrentApp(), JSCurrApp, true); } + /// + /// renders out the script block sources defined in any IAction + /// + private void RenderActionJS() + { + foreach (IAction a in global::umbraco.BusinessLogic.Actions.Action.GetAll()) + { + if (!string.IsNullOrEmpty(a.Alias) && (!string.IsNullOrEmpty(a.JsSource))) + { + Page.ClientScript.RegisterClientScriptInclude(a.GetType(), a.Alias, a.JsSource); + } + } + } + /// /// Return the current application alias. If neither the TreeType of Application is specified /// than return the default application. If the Application is null but there is a TreeType then