Fixes 28119 - unable to use custom context menu icons (kudos to Matt Brailsford for the patch!)
[TFS Changeset #73409]
This commit is contained in:
@@ -12,6 +12,7 @@ using System.Text;
|
||||
using umbraco.cms.presentation.Trees;
|
||||
using umbraco.BasePages;
|
||||
using System.Web.Services;
|
||||
using umbraco.BusinessLogic;
|
||||
|
||||
namespace umbraco.controls.Tree
|
||||
{
|
||||
@@ -30,21 +31,29 @@ namespace umbraco.controls.Tree
|
||||
List<IAction> allActions = new List<IAction>();
|
||||
foreach (IAction a in global::umbraco.BusinessLogic.Actions.Action.GetAll())
|
||||
{
|
||||
if (!string.IsNullOrEmpty(a.Alias) && (!string.IsNullOrEmpty(a.JsFunctionName) || !string.IsNullOrEmpty(a.JsSource)))
|
||||
// NH: Added a try/catch block to this as an error in a 3rd party action can crash the whole menu initialization
|
||||
try
|
||||
{
|
||||
// if the action is using invalid javascript we need to do something about this
|
||||
if (!umbraco.BusinessLogic.Actions.Action.ValidateActionJs(a))
|
||||
if (!string.IsNullOrEmpty(a.Alias) && (!string.IsNullOrEmpty(a.JsFunctionName) || !string.IsNullOrEmpty(a.JsSource)))
|
||||
{
|
||||
// Make new Iaction
|
||||
PlaceboAction pa = new PlaceboAction(a);
|
||||
pa.JsFunctionName = "IActionProxy_" + umbraco.cms.helpers.Casing.SafeAlias(pa.Alias) + "()";
|
||||
allActions.Add(pa);
|
||||
// if the action is using invalid javascript we need to do something about this
|
||||
if (!umbraco.BusinessLogic.Actions.Action.ValidateActionJs(a))
|
||||
{
|
||||
// Make new Iaction
|
||||
PlaceboAction pa = new PlaceboAction(a);
|
||||
pa.JsFunctionName = "IActionProxy_" + umbraco.cms.helpers.Casing.SafeAlias(pa.Alias) + "()";
|
||||
allActions.Add(pa);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
allActions.Add(a);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
allActions.Add(a);
|
||||
}
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
Log.Add(LogTypes.Error, -1, "Error initializing tree action: " + ee.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,16 +13,17 @@ using umbraco.cms.presentation.Trees;
|
||||
using umbraco.BasePages;
|
||||
using System.Web.Services;
|
||||
using System.Drawing;
|
||||
using umbraco.BusinessLogic;
|
||||
|
||||
namespace umbraco.controls.Tree
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// The Umbraco tree control.
|
||||
/// <remarks>If this control doesn't exist on an UmbracoEnsuredPage it will not work.</remarks>
|
||||
/// </summary>
|
||||
public partial class TreeControl : System.Web.UI.UserControl, ITreeService
|
||||
{
|
||||
/// <summary>
|
||||
/// The Umbraco tree control.
|
||||
/// <remarks>If this control doesn't exist on an UmbracoEnsuredPage it will not work.</remarks>
|
||||
/// </summary>
|
||||
public partial class TreeControl : System.Web.UI.UserControl, ITreeService
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Set the defaults
|
||||
@@ -35,37 +36,37 @@ namespace umbraco.controls.Tree
|
||||
CssClass = "";
|
||||
ManualInitialization = false;
|
||||
}
|
||||
|
||||
protected override void OnInit(EventArgs e)
|
||||
{
|
||||
base.OnInit(e);
|
||||
EnableViewState = false;
|
||||
}
|
||||
|
||||
public enum TreeMode
|
||||
{
|
||||
Standard, Checkbox, InheritedCheckBox
|
||||
}
|
||||
protected override void OnInit(EventArgs e)
|
||||
{
|
||||
base.OnInit(e);
|
||||
EnableViewState = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If there is not application or tree specified in a query string then this is the application to load.
|
||||
/// </summary>
|
||||
private const string DEFAULT_APP = "content";
|
||||
public enum TreeMode
|
||||
{
|
||||
Standard, Checkbox, InheritedCheckBox
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If there is not application or tree specified in a query string then this is the application to load.
|
||||
/// </summary>
|
||||
private const string DEFAULT_APP = "content";
|
||||
|
||||
private List<BaseTree> m_ActiveTrees = new List<BaseTree>();
|
||||
private List<BaseTree> m_AllAppTrees = new List<BaseTree>();
|
||||
private List<TreeDefinition> m_ActiveTreeDefs = null;
|
||||
private TreeMode m_TreeType = TreeMode.Standard;
|
||||
private bool m_IsInit = false;
|
||||
private TreeService m_TreeService = new TreeService();
|
||||
|
||||
private List<BaseTree> m_ActiveTrees = new List<BaseTree>();
|
||||
private List<BaseTree> m_AllAppTrees = new List<BaseTree>();
|
||||
private List<TreeDefinition> m_ActiveTreeDefs = null;
|
||||
private TreeMode m_TreeType = TreeMode.Standard;
|
||||
private bool m_IsInit = false;
|
||||
private TreeService m_TreeService = new TreeService();
|
||||
|
||||
#region Public Properties
|
||||
|
||||
#region Style Properties
|
||||
public string CssClass { get; set; }
|
||||
public Unit Height { get; set; }
|
||||
public Unit Width { get; set; }
|
||||
public Color BackColor { get; set; }
|
||||
public Color BackColor { get; set; }
|
||||
#endregion
|
||||
|
||||
#region TreeService parameters.
|
||||
@@ -160,7 +161,7 @@ namespace umbraco.controls.Tree
|
||||
m_TreeType = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the required JavaScript as a string for the current application
|
||||
/// </summary>
|
||||
@@ -195,74 +196,74 @@ namespace umbraco.controls.Tree
|
||||
Initialize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the control and looks up the tree structures that are required to be rendered.
|
||||
/// Properties of the control (or SetTreeService) need to be set before pre render or calling
|
||||
/// GetJSONContextMenu or GetJSONNode
|
||||
/// </summary>
|
||||
protected void Initialize()
|
||||
{
|
||||
//use the query strings if the TreeParams isn't explicitly set
|
||||
if (m_TreeService == null)
|
||||
{
|
||||
m_TreeService = TreeRequestParams.FromQueryStrings().CreateTreeService();
|
||||
}
|
||||
m_TreeService.App = GetCurrentApp();
|
||||
/// <summary>
|
||||
/// Initializes the control and looks up the tree structures that are required to be rendered.
|
||||
/// Properties of the control (or SetTreeService) need to be set before pre render or calling
|
||||
/// GetJSONContextMenu or GetJSONNode
|
||||
/// </summary>
|
||||
protected void Initialize()
|
||||
{
|
||||
//use the query strings if the TreeParams isn't explicitly set
|
||||
if (m_TreeService == null)
|
||||
{
|
||||
m_TreeService = TreeRequestParams.FromQueryStrings().CreateTreeService();
|
||||
}
|
||||
m_TreeService.App = GetCurrentApp();
|
||||
|
||||
// Validate permissions
|
||||
if (!BasePages.BasePage.ValidateUserContextID(BasePages.BasePage.umbracoUserContextID))
|
||||
return;
|
||||
UmbracoEnsuredPage page = new UmbracoEnsuredPage();
|
||||
if (!page.ValidateUserApp(GetCurrentApp()))
|
||||
throw new ArgumentException("The current user doesn't have access to this application. Please contact the system administrator.");
|
||||
// Validate permissions
|
||||
if (!BasePages.BasePage.ValidateUserContextID(BasePages.BasePage.umbracoUserContextID))
|
||||
return;
|
||||
UmbracoEnsuredPage page = new UmbracoEnsuredPage();
|
||||
if (!page.ValidateUserApp(GetCurrentApp()))
|
||||
throw new ArgumentException("The current user doesn't have access to this application. Please contact the system administrator.");
|
||||
|
||||
//find all tree definitions that have the current application alias that are ACTIVE
|
||||
m_ActiveTreeDefs = TreeDefinitionCollection.Instance.FindActiveTrees(GetCurrentApp());
|
||||
//find all tree defs that exists for the current application regardless of if they are active
|
||||
List<TreeDefinition> appTreeDefs = TreeDefinitionCollection.Instance.FindTrees(GetCurrentApp());
|
||||
//find all tree definitions that have the current application alias that are ACTIVE
|
||||
m_ActiveTreeDefs = TreeDefinitionCollection.Instance.FindActiveTrees(GetCurrentApp());
|
||||
//find all tree defs that exists for the current application regardless of if they are active
|
||||
List<TreeDefinition> appTreeDefs = TreeDefinitionCollection.Instance.FindTrees(GetCurrentApp());
|
||||
|
||||
//Create the BaseTree's based on the tree definitions found
|
||||
foreach (TreeDefinition treeDef in appTreeDefs)
|
||||
{
|
||||
//create the tree and initialize it
|
||||
BaseTree bTree = treeDef.CreateInstance();
|
||||
bTree.SetTreeParameters(m_TreeService);
|
||||
//Create the BaseTree's based on the tree definitions found
|
||||
foreach (TreeDefinition treeDef in appTreeDefs)
|
||||
{
|
||||
//create the tree and initialize it
|
||||
BaseTree bTree = treeDef.CreateInstance();
|
||||
bTree.SetTreeParameters(m_TreeService);
|
||||
|
||||
//store the created tree
|
||||
m_AllAppTrees.Add(bTree);
|
||||
if (treeDef.Tree.Initialize)
|
||||
m_ActiveTrees.Add(bTree);
|
||||
}
|
||||
//store the created tree
|
||||
m_AllAppTrees.Add(bTree);
|
||||
if (treeDef.Tree.Initialize)
|
||||
m_ActiveTrees.Add(bTree);
|
||||
}
|
||||
|
||||
m_IsInit = true;
|
||||
}
|
||||
m_IsInit = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This calls the databind method to bind the data binding syntax on the front-end.
|
||||
/// <remarks>
|
||||
/// Databinding was used instead of inline tags in case the tree properties needed to be set
|
||||
/// by other classes at runtime
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
/// <remarks>
|
||||
/// This will initialize the control so all TreeService properties need to be set before hand
|
||||
/// </remarks>
|
||||
protected override void OnPreRender(EventArgs e)
|
||||
{
|
||||
base.OnPreRender(e);
|
||||
/// <summary>
|
||||
/// This calls the databind method to bind the data binding syntax on the front-end.
|
||||
/// <remarks>
|
||||
/// Databinding was used instead of inline tags in case the tree properties needed to be set
|
||||
/// by other classes at runtime
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
/// <remarks>
|
||||
/// This will initialize the control so all TreeService properties need to be set before hand
|
||||
/// </remarks>
|
||||
protected override void OnPreRender(EventArgs e)
|
||||
{
|
||||
base.OnPreRender(e);
|
||||
|
||||
if (!m_IsInit)
|
||||
Initialize();
|
||||
if (!m_IsInit)
|
||||
Initialize();
|
||||
|
||||
//Render out the JavaScript associated with all of the trees for the application
|
||||
RenderTreeJS();
|
||||
//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());
|
||||
TreeContainer.Style.Add(HtmlTextWriterStyle.Width, Width.ToString());
|
||||
if (Height != Unit.Empty)
|
||||
TreeContainer.Style.Add(HtmlTextWriterStyle.Height, Height.ToString());
|
||||
if (BackColor != Color.Empty)
|
||||
@@ -276,16 +277,16 @@ namespace umbraco.controls.Tree
|
||||
//add the default class
|
||||
TreeContainer.Attributes.Add("class", "treeContainer");
|
||||
}
|
||||
|
||||
|
||||
DataBind();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the JSON markup for the full context menu
|
||||
/// </summary>
|
||||
public string GetJSONContextMenu()
|
||||
{
|
||||
DataBind();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the JSON markup for the full context menu
|
||||
/// </summary>
|
||||
public string GetJSONContextMenu()
|
||||
{
|
||||
if (ShowContextMenu)
|
||||
{
|
||||
JTreeContextMenu menu = new JTreeContextMenu();
|
||||
@@ -295,8 +296,8 @@ namespace umbraco.controls.Tree
|
||||
{
|
||||
return "{}";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string with javascript proxy methods for IActions that are using old javascript
|
||||
@@ -307,16 +308,24 @@ namespace umbraco.controls.Tree
|
||||
StringBuilder js = new StringBuilder();
|
||||
foreach (IAction a in global::umbraco.BusinessLogic.Actions.Action.GetAll())
|
||||
{
|
||||
if (!string.IsNullOrEmpty(a.Alias) && (!string.IsNullOrEmpty(a.JsFunctionName) || !string.IsNullOrEmpty(a.JsSource)))
|
||||
// NH: Added a try/catch block to this as an error in a 3rd party action can crash the whole menu initialization
|
||||
try
|
||||
{
|
||||
// if the action is using invalid javascript we need to do something about this
|
||||
if (!umbraco.BusinessLogic.Actions.Action.ValidateActionJs(a))
|
||||
if (!string.IsNullOrEmpty(a.Alias) && (!string.IsNullOrEmpty(a.JsFunctionName) || !string.IsNullOrEmpty(a.JsSource)))
|
||||
{
|
||||
js.AppendLine("function IActionProxy_" + umbraco.cms.helpers.Casing.SafeAlias(a.Alias) + "() {");
|
||||
js.AppendLine(umbraco.BusinessLogic.Actions.Action.ConvertLegacyJs(a.JsFunctionName)); // .Replace("openModal", "UmbClientMgr.openModalWindow"));
|
||||
js.AppendLine("}");
|
||||
// if the action is using invalid javascript we need to do something about this
|
||||
if (!umbraco.BusinessLogic.Actions.Action.ValidateActionJs(a))
|
||||
{
|
||||
js.AppendLine("function IActionProxy_" + umbraco.cms.helpers.Casing.SafeAlias(a.Alias) + "() {");
|
||||
js.AppendLine(umbraco.BusinessLogic.Actions.Action.ConvertLegacyJs(a.JsFunctionName)); // .Replace("openModal", "UmbClientMgr.openModalWindow"));
|
||||
js.AppendLine("}");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
Log.Add(LogTypes.Error, -1, "Error initializing tree action: " + ee.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
if (js.Length != 0)
|
||||
@@ -327,79 +336,79 @@ namespace umbraco.controls.Tree
|
||||
return js.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the JSON markup for one node
|
||||
/// </summary>
|
||||
/// <param name="treeAlias"></param>
|
||||
/// <param name="nodeId"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// This will initialize the control so all TreeService properties need to be set before hand
|
||||
/// </remarks>
|
||||
public string GetJSONNode(string nodeId)
|
||||
{
|
||||
if (!m_IsInit)
|
||||
Initialize();
|
||||
/// <summary>
|
||||
/// Returns the JSON markup for one node
|
||||
/// </summary>
|
||||
/// <param name="treeAlias"></param>
|
||||
/// <param name="nodeId"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// This will initialize the control so all TreeService properties need to be set before hand
|
||||
/// </remarks>
|
||||
public string GetJSONNode(string nodeId)
|
||||
{
|
||||
if (!m_IsInit)
|
||||
Initialize();
|
||||
|
||||
if (string.IsNullOrEmpty(m_TreeService.TreeType))
|
||||
{
|
||||
throw new ArgumentException("The TreeType is not set on the tree service");
|
||||
}
|
||||
if (string.IsNullOrEmpty(m_TreeService.TreeType))
|
||||
{
|
||||
throw new ArgumentException("The TreeType is not set on the tree service");
|
||||
}
|
||||
|
||||
BaseTree tree = m_ActiveTrees.Find(
|
||||
delegate(BaseTree t)
|
||||
{
|
||||
return (t.TreeAlias == m_TreeService.TreeType);
|
||||
}
|
||||
);
|
||||
return tree.GetSerializedNodeData(nodeId);
|
||||
}
|
||||
BaseTree tree = m_ActiveTrees.Find(
|
||||
delegate(BaseTree t)
|
||||
{
|
||||
return (t.TreeAlias == m_TreeService.TreeType);
|
||||
}
|
||||
);
|
||||
return tree.GetSerializedNodeData(nodeId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the JSON markup for the first node in the tree
|
||||
/// </summary>
|
||||
|
||||
public string GetJSONInitNode()
|
||||
{
|
||||
if (!m_IsInit)
|
||||
Initialize();
|
||||
/// <summary>
|
||||
/// Returns the JSON markup for the first node in the tree
|
||||
/// </summary>
|
||||
|
||||
//if there is only one tree to render, we don't want to have a node to hold sub trees, we just want the
|
||||
//stand alone tree, so we'll just add a TreeType to the TreeService and ensure that the right method gets loaded in tree.aspx
|
||||
if (m_ActiveTrees.Count == 1)
|
||||
{
|
||||
m_TreeService.TreeType = m_ActiveTreeDefs[0].Tree.Alias;
|
||||
public string GetJSONInitNode()
|
||||
{
|
||||
if (!m_IsInit)
|
||||
Initialize();
|
||||
|
||||
//convert the menu to a string
|
||||
//string initActions = (TreeSvc.ShowContextMenu ? Action.ToString(m_ActiveTrees[0].RootNodeActions) : "");
|
||||
//if there is only one tree to render, we don't want to have a node to hold sub trees, we just want the
|
||||
//stand alone tree, so we'll just add a TreeType to the TreeService and ensure that the right method gets loaded in tree.aspx
|
||||
if (m_ActiveTrees.Count == 1)
|
||||
{
|
||||
m_TreeService.TreeType = m_ActiveTreeDefs[0].Tree.Alias;
|
||||
|
||||
//Since there's only 1 tree, render out the tree's RootNode properties
|
||||
XmlTree xTree = new XmlTree();
|
||||
xTree.Add(m_ActiveTrees[0].RootNode);
|
||||
return xTree.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
//convert the menu to a string
|
||||
//string initActions = (TreeSvc.ShowContextMenu ? Action.ToString(m_ActiveTrees[0].RootNodeActions) : "");
|
||||
|
||||
//If there is more than 1 tree for the application than render out a
|
||||
//container node labelled with the current application.
|
||||
XmlTree xTree = new XmlTree();
|
||||
XmlTreeNode xNode = XmlTreeNode.CreateRoot(new NullTree(GetCurrentApp()));
|
||||
xNode.Text = ui.Text("sections", GetCurrentApp(), UmbracoEnsuredPage.CurrentUser);
|
||||
xNode.Source = m_TreeService.GetServiceUrl();
|
||||
xNode.Action = ClientTools.Scripts.OpenDashboard(GetCurrentApp());
|
||||
xNode.NodeType = m_TreeService.App.ToLower();
|
||||
xNode.NodeID = "-1";
|
||||
xNode.Icon = ".sprTreeFolder";
|
||||
xTree.Add(xNode);
|
||||
return xTree.ToString();
|
||||
}
|
||||
}
|
||||
//Since there's only 1 tree, render out the tree's RootNode properties
|
||||
XmlTree xTree = new XmlTree();
|
||||
xTree.Add(m_ActiveTrees[0].RootNode);
|
||||
return xTree.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
private void RenderTreeJS()
|
||||
{
|
||||
//If there is more than 1 tree for the application than render out a
|
||||
//container node labelled with the current application.
|
||||
XmlTree xTree = new XmlTree();
|
||||
XmlTreeNode xNode = XmlTreeNode.CreateRoot(new NullTree(GetCurrentApp()));
|
||||
xNode.Text = ui.Text("sections", GetCurrentApp(), UmbracoEnsuredPage.CurrentUser);
|
||||
xNode.Source = m_TreeService.GetServiceUrl();
|
||||
xNode.Action = ClientTools.Scripts.OpenDashboard(GetCurrentApp());
|
||||
xNode.NodeType = m_TreeService.App.ToLower();
|
||||
xNode.NodeID = "-1";
|
||||
xNode.Icon = ".sprTreeFolder";
|
||||
xTree.Add(xNode);
|
||||
return xTree.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private void RenderTreeJS()
|
||||
{
|
||||
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Trees_" + GetCurrentApp(), JSCurrApp, true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// renders out the script block sources defined in any IAction
|
||||
@@ -408,34 +417,42 @@ namespace umbraco.controls.Tree
|
||||
{
|
||||
foreach (IAction a in global::umbraco.BusinessLogic.Actions.Action.GetAll())
|
||||
{
|
||||
if (!string.IsNullOrEmpty(a.Alias) && (!string.IsNullOrEmpty(a.JsSource)))
|
||||
// NH: Added a try/catch block to this as an error in a 3rd party action can crash the whole menu initialization
|
||||
try
|
||||
{
|
||||
Page.ClientScript.RegisterClientScriptBlock(a.GetType(), a.Alias, a.JsSource, true);
|
||||
//Page.ClientScript.RegisterClientScriptInclude(a.GetType(), a.Alias, a.JsSource);
|
||||
if (!string.IsNullOrEmpty(a.Alias) && (!string.IsNullOrEmpty(a.JsSource)))
|
||||
{
|
||||
Page.ClientScript.RegisterClientScriptBlock(a.GetType(), a.Alias, a.JsSource, true);
|
||||
//Page.ClientScript.RegisterClientScriptInclude(a.GetType(), a.Alias, a.JsSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
Log.Add(LogTypes.Error, -1, "Error initializing tree action: " + ee.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// find the application that the tree type is associated with.
|
||||
/// </summary>
|
||||
private string GetCurrentApp()
|
||||
{
|
||||
//if theres an treetype specified but no application
|
||||
if (string.IsNullOrEmpty(m_TreeService.App) &&
|
||||
!string.IsNullOrEmpty(m_TreeService.TreeType))
|
||||
{
|
||||
TreeDefinition treeDef = TreeDefinitionCollection.Instance.FindTree(m_TreeService.TreeType);
|
||||
if (treeDef != null)
|
||||
return treeDef.App.alias;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(m_TreeService.App))
|
||||
return m_TreeService.App;
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// find the application that the tree type is associated with.
|
||||
/// </summary>
|
||||
private string GetCurrentApp()
|
||||
{
|
||||
//if theres an treetype specified but no application
|
||||
if (string.IsNullOrEmpty(m_TreeService.App) &&
|
||||
!string.IsNullOrEmpty(m_TreeService.TreeType))
|
||||
{
|
||||
TreeDefinition treeDef = TreeDefinitionCollection.Instance.FindTree(m_TreeService.TreeType);
|
||||
if (treeDef != null)
|
||||
return treeDef.App.alias;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(m_TreeService.App))
|
||||
return m_TreeService.App;
|
||||
|
||||
//if everything is null then return the default app
|
||||
return DEFAULT_APP;
|
||||
}
|
||||
}
|
||||
//if everything is null then return the default app
|
||||
return DEFAULT_APP;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
(function($) {
|
||||
(function ($) {
|
||||
$.extend($.tree.plugins, {
|
||||
"contextmenu": {
|
||||
object: $("<ul id='jstree-contextmenu' class='tree-context' />"),
|
||||
@@ -14,25 +14,25 @@
|
||||
create: {
|
||||
label: "Create",
|
||||
icon: "create",
|
||||
visible: function(NODE, TREE_OBJ) { if (NODE.length != 1) return 0; return TREE_OBJ.check("creatable", NODE); },
|
||||
action: function(NODE, TREE_OBJ) { TREE_OBJ.create(false, TREE_OBJ.get_node(NODE[0])); },
|
||||
visible: function (NODE, TREE_OBJ) { if (NODE.length != 1) return 0; return TREE_OBJ.check("creatable", NODE); },
|
||||
action: function (NODE, TREE_OBJ) { TREE_OBJ.create(false, TREE_OBJ.get_node(NODE[0])); },
|
||||
separator_after: true
|
||||
},
|
||||
rename: {
|
||||
label: "Rename",
|
||||
icon: "rename",
|
||||
visible: function(NODE, TREE_OBJ) { if (NODE.length != 1) return false; return TREE_OBJ.check("renameable", NODE); },
|
||||
action: function(NODE, TREE_OBJ) { TREE_OBJ.rename(NODE); }
|
||||
visible: function (NODE, TREE_OBJ) { if (NODE.length != 1) return false; return TREE_OBJ.check("renameable", NODE); },
|
||||
action: function (NODE, TREE_OBJ) { TREE_OBJ.rename(NODE); }
|
||||
},
|
||||
remove: {
|
||||
label: "Delete",
|
||||
icon: "remove",
|
||||
visible: function(NODE, TREE_OBJ) { var ok = true; $.each(NODE, function() { if (TREE_OBJ.check("deletable", this) == false) ok = false; return false; }); return ok; },
|
||||
action: function(NODE, TREE_OBJ) { $.each(NODE, function() { TREE_OBJ.remove(this); }); }
|
||||
visible: function (NODE, TREE_OBJ) { var ok = true; $.each(NODE, function () { if (TREE_OBJ.check("deletable", this) == false) ok = false; return false; }); return ok; },
|
||||
action: function (NODE, TREE_OBJ) { $.each(NODE, function () { TREE_OBJ.remove(this); }); }
|
||||
}
|
||||
}
|
||||
},
|
||||
show: function(obj, t) {
|
||||
show: function (obj, t) {
|
||||
var opts = $.extend(true, {}, $.tree.plugins.contextmenu.defaults, t.settings.plugins.contextmenu);
|
||||
obj = $(obj);
|
||||
$.tree.plugins.contextmenu.object.empty();
|
||||
@@ -47,9 +47,16 @@
|
||||
else cnt++;
|
||||
if (opts.items[i].separator_before === true) str += "<li class='separator'><span> </span></li>";
|
||||
str += '<li><a href="#" rel="' + i + '" class="' + i + ' ' + (r == 0 ? 'disabled' : '') + '">';
|
||||
if (opts.items[i].icon) str += "<ins " + (opts.items[i].icon.indexOf("/") == -1 ? " class='" + opts.items[i].icon + "' " : " style='background-image:url(\"" + opts.items[i].icon + "\");' ") + "> </ins>";
|
||||
else str += "<ins> </ins>";
|
||||
str += "<span>" + opts.items[i].label + '</span></a></li>';
|
||||
|
||||
// updated from patch by Matt Brailsford (http://our.umbraco.org/forum/using/ui-questions/6225-Custom-icon-in-Context-menu#comment39514)
|
||||
str += "<ins> </ins>"; str += "<span>";
|
||||
if (opts.items[i].icon && opts.items[i].icon.indexOf("/") >= 0) {
|
||||
str += "<div class=\"menuSpr\" style=\"background:transparent url('" + opts.items[i].icon + "') center center no-repeat;\"></div><div class='menuLabel'>" + opts.items[i].label + "</div>";
|
||||
} else {
|
||||
str += opts.items[i].label;
|
||||
}
|
||||
str += '</span></a></li>';
|
||||
|
||||
if (opts.items[i].separator_after === true) str += "<li class='separator'><span> </span></li>";
|
||||
}
|
||||
var tmp = obj.children("a:visible").offset();
|
||||
@@ -64,7 +71,7 @@
|
||||
if (x + w > max_x) x = Math.max((max_x - w - 2), 0);
|
||||
$.tree.plugins.contextmenu.object.css({ "left": (x), "top": (y) }).fadeIn("fast");
|
||||
},
|
||||
hide: function() {
|
||||
hide: function () {
|
||||
if (!$.tree.plugins.contextmenu.data.t) return;
|
||||
var opts = $.extend(true, {}, $.tree.plugins.contextmenu.defaults, $.tree.plugins.contextmenu.data.t.settings.plugins.contextmenu);
|
||||
if ($.tree.plugins.contextmenu.data.r && $.tree.plugins.contextmenu.data.a) {
|
||||
@@ -73,20 +80,20 @@
|
||||
$.tree.plugins.contextmenu.data = { a: false, r: false, t: false };
|
||||
$.tree.plugins.contextmenu.object.fadeOut("fast");
|
||||
},
|
||||
exec: function(cmd) {
|
||||
exec: function (cmd) {
|
||||
if ($.tree.plugins.contextmenu.data.t == false) return;
|
||||
var opts = $.extend(true, {}, $.tree.plugins.contextmenu.defaults, $.tree.plugins.contextmenu.data.t.settings.plugins.contextmenu);
|
||||
try { opts.items[cmd].action.apply(null, [$.tree.plugins.contextmenu.data.a, $.tree.plugins.contextmenu.data.t]); } catch (e) { };
|
||||
},
|
||||
|
||||
callbacks: {
|
||||
oninit: function() {
|
||||
oninit: function () {
|
||||
if (!$.tree.plugins.contextmenu.css) {
|
||||
var css = '#jstree-contextmenu { display:none; position:absolute; z-index:2000; list-style-type:none; margin:0; padding:0; left:-2000px; top:-2000px; } .tree-context { margin:20px; padding:0; width:180px; border:1px solid #979797; padding:2px; background:#f5f5f5; list-style-type:none; }.tree-context li { height:22px; margin:0 0 0 27px; padding:0; background:#ffffff; border-left:1px solid #e0e0e0; }.tree-context li a { position:relative; display:block; height:22px; line-height:22px; margin:0 0 0 -28px; text-decoration:none; color:black; padding:0; }.tree-context li a ins { text-decoration:none; float:left; width:16px; height:16px; margin:0 0 0 0; background-color:#f0f0f0; border:1px solid #f0f0f0; border-width:3px 5px 3px 6px; line-height:16px; }.tree-context li a span { display:block; background:#f0f0f0; margin:0 0 0 29px; padding-left:5px; }.tree-context li.separator { background:#f0f0f0; height:2px; line-height:2px; font-size:1px; border:0; margin:0; padding:0; }.tree-context li.separator span { display:block; margin:0px 0 0px 27px; height:1px; border-top:1px solid #e0e0e0; border-left:1px solid #e0e0e0; line-height:1px; font-size:1px; background:white; }.tree-context li a:hover { border:1px solid #d8f0fa; height:20px; line-height:20px; }.tree-context li a:hover span { background:#e7f4f9; margin-left:28px; }.tree-context li a:hover ins { background-color:#e7f4f9; border-color:#e7f4f9; border-width:2px 5px 2px 5px; }.tree-context li a.disabled { color:gray; }.tree-context li a.disabled ins { }.tree-context li a.disabled:hover { border:0; height:22px; line-height:22px; }.tree-context li a.disabled:hover span { background:#f0f0f0; margin-left:29px; }.tree-context li a.disabled:hover ins { border-color:#f0f0f0; background-color:#f0f0f0; border-width:3px 5px 3px 6px; }';
|
||||
$.tree.plugins.contextmenu.css = this.add_sheet({ str: css });
|
||||
}
|
||||
},
|
||||
onrgtclk: function(n, t, e) {
|
||||
onrgtclk: function (n, t, e) {
|
||||
var opts = $.extend(true, {}, $.tree.plugins.contextmenu.defaults, t.settings.plugins.contextmenu);
|
||||
n = $(n);
|
||||
if (n.size() == 0) return;
|
||||
@@ -106,16 +113,16 @@
|
||||
e.stopPropagation();
|
||||
// return false; // commented out because you might want to do something in your own callback
|
||||
},
|
||||
onchange: function() { $.tree.plugins.contextmenu.hide(); },
|
||||
beforedata: function() { $.tree.plugins.contextmenu.hide(); },
|
||||
ondestroy: function() { $.tree.plugins.contextmenu.hide(); }
|
||||
onchange: function () { $.tree.plugins.contextmenu.hide(); },
|
||||
beforedata: function () { $.tree.plugins.contextmenu.hide(); },
|
||||
ondestroy: function () { $.tree.plugins.contextmenu.hide(); }
|
||||
}
|
||||
}
|
||||
});
|
||||
$(function() {
|
||||
$(function () {
|
||||
$.tree.plugins.contextmenu.object.hide().appendTo("body");
|
||||
$("a", $.tree.plugins.contextmenu.object[0])
|
||||
.live("click", function(event) {
|
||||
.live("click", function (event) {
|
||||
if (!$(this).hasClass("disabled")) {
|
||||
$.tree.plugins.contextmenu.exec.apply(null, [$(this).attr("rel")]);
|
||||
$.tree.plugins.contextmenu.hide();
|
||||
@@ -124,6 +131,6 @@
|
||||
event.preventDefault();
|
||||
return false;
|
||||
})
|
||||
$(document).bind("mousedown", function(event) { if ($(event.target).parents("#jstree-contextmenu").size() == 0) $.tree.plugins.contextmenu.hide(); });
|
||||
$(document).bind("mousedown", function (event) { if ($(event.target).parents("#jstree-contextmenu").size() == 0) $.tree.plugins.contextmenu.hide(); });
|
||||
});
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user