DO NOT D,OWNLOAD. DOWNLOAD LATEST STABLE FROM RELEASE TAB

Resolves 22528,22306. ClientDependency nearly done.

[TFS Changeset #57300]
This commit is contained in:
Shandem
2009-07-28 16:22:14 +00:00
parent 9a46338123
commit f24a26b264
42 changed files with 821 additions and 388 deletions

View File

@@ -1,6 +1,7 @@
* //TODO: All removed files will be in the umbraco.Legacy project
* DataType: 'editor' removed
* DataType: 'editor' removed (editor.cs)
* removed WysiwygDataType.cs
* Many files have been removed but a zip file containing all removed files has been supplied
@@ -14,4 +15,7 @@ exists in the current context, and if it doesn't it registers the scripts?)
* Umbraco_Client folder path needs to be specified in AppSettings
* The old TinyMCE was not upgraded to use ClientDependency but it's paths have been changed
to use the UmbracoClientPath setting
to use the UmbracoClientPath setting
* removed CheckBoxTree.cs [permanently!, not in legacy package]
* removed windowCloser.cs

View File

@@ -1,16 +1,17 @@
using System;
using System.Web.UI;
using umbraco.cms.businesslogic.datatype;
using umbraco.cms.presentation.Trees;
using umbraco.presentation.ClientDependency;
namespace umbraco.editorControls
{
/// <summary>
/// Summary description for mediaChooser.
/// </summary>
[ClientDependency(1, ClientDependencyType.Css, "js/submodal/submodal.css", true)]
[ClientDependency(1, ClientDependencyType.Javascript, "js/submodal/common.js", true)]
[ClientDependency(2, ClientDependencyType.Javascript, "js/submodal/submodal.js", true, "initPopUp")]
[ClientDependency(3, ClientDependencyType.Javascript, "webservices/legacyAjaxCalls.asmx/js", true)]
[ClientDependency(100, ClientDependencyType.Css, "js/submodal/submodal.css", "UmbracoRoot")]
[ClientDependency(101, ClientDependencyType.Javascript, "js/submodal/common.js", "UmbracoRoot")]
[ClientDependency(102, ClientDependencyType.Javascript, "js/submodal/submodal.js", "UmbracoRoot", InvokeJavascriptMethodOnLoad = "initPopUp")]
[ClientDependency(103, ClientDependencyType.Javascript, "webservices/legacyAjaxCalls.asmx/js", "UmbracoRoot")]
[ValidationProperty("Value")]
public class mediaChooser : System.Web.UI.WebControls.HiddenField, interfaces.IDataEditor
{
@@ -59,9 +60,9 @@ namespace umbraco.editorControls
{
base.OnLoad(e);
umbraco.presentation.ClientDependency.Controls.ClientDependencyLoader.RegisterDependency("js/submodal/common.js", "UmbracoRoot", umbraco.presentation.ClientDependency.ClientDependencyType.Javascript);
umbraco.presentation.ClientDependency.Controls.ClientDependencyLoader.RegisterDependency("js/submodal/subModal.js", "UmbracoRoot", umbraco.presentation.ClientDependency.ClientDependencyType.Javascript);
umbraco.presentation.ClientDependency.Controls.ClientDependencyLoader.RegisterDependency("js/submodal/subModal.css", "UmbracoRoot", umbraco.presentation.ClientDependency.ClientDependencyType.Css);
//umbraco.presentation.ClientDependency.Controls.ClientDependencyLoader.RegisterDependency("js/submodal/common.js", "UmbracoRoot", umbraco.presentation.ClientDependency.ClientDependencyType.Javascript);
//umbraco.presentation.ClientDependency.Controls.ClientDependencyLoader.RegisterDependency("js/submodal/subModal.js", "UmbracoRoot", umbraco.presentation.ClientDependency.ClientDependencyType.Javascript);
//umbraco.presentation.ClientDependency.Controls.ClientDependencyLoader.RegisterDependency("js/submodal/subModal.css", "UmbracoRoot", umbraco.presentation.ClientDependency.ClientDependencyType.Css);
// We need to make sure we have a reference to the legacy ajax calls in the scriptmanager
presentation.webservices.ajaxHelpers.EnsureLegacyCalls(base.Page);

View File

@@ -1,16 +1,17 @@
using System;
using System.Web.UI;
using umbraco.cms.businesslogic.datatype;
using umbraco.cms.presentation.Trees;
using umbraco.presentation.ClientDependency;
namespace umbraco.editorControls
{
/// <summary>
/// Summary description for pagePicker.
/// </summary>
[ClientDependency(1, ClientDependencyType.Css, "js/submodal/submodal.css", true)]
[ClientDependency(1, ClientDependencyType.Javascript, "js/submodal/common.js", true)]
[ClientDependency(2, ClientDependencyType.Javascript, "js/submodal/submodal.js", true, "initPopUp")]
[ClientDependency(3, ClientDependencyType.Javascript, "webservices/legacyAjaxCalls.asmx/js", true)]
[ClientDependency(100, ClientDependencyType.Css, "js/submodal/submodal.css", "UmbracoRoot")]
[ClientDependency(101, ClientDependencyType.Javascript, "js/submodal/common.js", "UmbracoRoot")]
[ClientDependency(102, ClientDependencyType.Javascript, "js/submodal/submodal.js", "UmbracoRoot", InvokeJavascriptMethodOnLoad = "initPopUp")]
[ClientDependency(103, ClientDependencyType.Javascript, "webservices/legacyAjaxCalls.asmx/js", "UmbracoRoot")]
[ValidationProperty("Value")]
public class pagePicker : System.Web.UI.WebControls.HiddenField, interfaces.IDataEditor
{
@@ -51,10 +52,6 @@ namespace umbraco.editorControls
{
base.OnInit(e);
umbraco.presentation.ClientDependency.Controls.ClientDependencyLoader.RegisterDependency("js/submodal/common.js", "UmbracoRoot", umbraco.presentation.ClientDependency.ClientDependencyType.Javascript);
umbraco.presentation.ClientDependency.Controls.ClientDependencyLoader.RegisterDependency("js/submodal/subModal.js", "UmbracoRoot", umbraco.presentation.ClientDependency.ClientDependencyType.Javascript);
umbraco.presentation.ClientDependency.Controls.ClientDependencyLoader.RegisterDependency("js/submodal/subModal.css", "UmbracoRoot", umbraco.presentation.ClientDependency.ClientDependencyType.Css);
// We need to make sure we have a reference to the legacy ajax calls in the scriptmanager
presentation.webservices.ajaxHelpers.EnsureLegacyCalls(base.Page);

View File

@@ -5,19 +5,24 @@ using umbraco.editorControls.wysiwyg;
using umbraco.uicontrols;
using System.Web.UI;
namespace umbraco.editorControls.ultraSimpleMailer
{
/// <summary>
/// Summary description for ultraSimpleMailerEditor.
/// </summary>
public class ultraSimpleMailerEditor : umbraco.editorControls.tinyMCE3.TinyMCE, interfaces.IDataFieldWithButtons
{
umbraco.cms.businesslogic.datatype.DefaultData _data;
umbraco.cms.businesslogic.datatype.DefaultData _data;
string _configuration;
private controls.progressBar pb;
public ultraSimpleMailerEditor(umbraco.cms.businesslogic.datatype.DefaultData Data, string Configuration)
: base(Data, Configuration)
public ultraSimpleMailerEditor(umbraco.cms.businesslogic.datatype.DefaultData Data, string Configuration)
: base(Data, Configuration)
{
_configuration = Configuration;
_data = Data;
@@ -26,7 +31,7 @@ namespace umbraco.editorControls.ultraSimpleMailer
protected override void OnLoad(EventArgs e)
{
base.OnLoad (e);
base.OnLoad(e);
// init progressbar
pb = new umbraco.controls.progressBar();
@@ -38,10 +43,10 @@ namespace umbraco.editorControls.ultraSimpleMailer
Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "progressBar", "<script language='javascript' src='/umbraco_client/progressBar/javascript.js'></script>");
Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "progressBarCss", "<link href=\"/umbraco_client/progressBar/style.css\" type=\"text/css\" rel=\"stylesheet\">");
// We need to make sure we have a reference to the legacy ajax calls in the scriptmanager
presentation.webservices.ajaxHelpers.EnsureLegacyCalls(base.Page);
// We need to make sure we have a reference to the legacy ajax calls in the scriptmanager
presentation.webservices.ajaxHelpers.EnsureLegacyCalls(base.Page);
}
}
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
@@ -54,48 +59,48 @@ namespace umbraco.editorControls.ultraSimpleMailer
writer.WriteLine("<input type=\"hidden\" name=\"" + this.ClientID + "_doTest\" id=\"" + this.ClientID + "_doTest\" value=\"" + umbraco.helper.Request(this.ClientID + "_doTest") + "\" />");
if (umbraco.helper.Request(this.ClientID + "_doTest") == "" && umbraco.helper.Request(this.ClientID + "_doSend") == "")
base.Render (writer);
else
base.Render(writer);
else
{
writer.WriteLine("<div class=\"propertypane\" style=\"margin: 10px; padding: 10px; width: 100%;height: 100%;background-color: light-blue\">");
if (umbraco.helper.Request(this.ClientID + "_sendButton") != "")
if (umbraco.helper.Request(this.ClientID + "_sendButton") != "")
{
// Test mail
if (umbraco.helper.Request(this.ClientID + "_doTest") != "")
if (umbraco.helper.Request(this.ClientID + "_doTest") != "")
{
writer.WriteLine("<h3 style=\"margin-left: -1px;\">Send newsletter to test...</h3><br/>");
mailerLogic.SendTestmail(umbraco.helper.Request(this.ClientID + "_test_rcp"), new cms.businesslogic.property.Property(_data.PropertyId), config[9], config[10], true);
writer.WriteLine("Test mail sent to: <b>" + umbraco.helper.Request(this.ClientID + "_test_rcp") + "</b><br/>");
}
else
}
else
{
writer.WriteLine("<h3 style=\"margin-left: -1px;\">Send newsletter to all...</h3><br/>");
mailerLogic.SendMail(mg, new cms.businesslogic.property.Property(_data.PropertyId), config[9], config[10], true);
writer.WriteLine("Sent...<br/>");
}
}
else
}
}
else
{
if (umbraco.helper.Request(this.ClientID + "_doTest") != "")
if (umbraco.helper.Request(this.ClientID + "_doTest") != "")
{
writer.WriteLine("<h3 style=\"margin-left: -1px;\">Send newsletter to test...</h3><br/>");
writer.WriteLine("Send test to: <input type=\"text\" name=\"" + this.ClientID + "_test_rcp\" id=\"" + this.ClientID + "_test_rcp\"/>");
writer.WriteLine("<input type=\"submit\" name=\"" + this.ClientID + "_sendButton\" class=\"guiInputButton\" value=\"Send\"/>");
}
else
else
{
string strScript = " alert('The MassMailer / UltraSimplerMailer is incompatible with Umbraco 4'); umbPgStep = 1;\n umbPgIgnoreSteps = true;\n";
if (ScriptManager.GetCurrent(Page).IsInAsyncPostBack)
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), this.ClientID, strScript, true);
else
Page.ClientScript.RegisterStartupScript(this.GetType(), this.ClientID, strScript, true);
writer.WriteLine(" <div id=\"ultraSimpleMailerAnimDiv\" style=\"DISPLAY: none; TEXT-ALIGN: left\"><br /><br /><span style=\"border: #999 1px solid; PADDING: 15px; BACKGROUND: white; WIDTH: 300px; TEXT-ALIGN: center\"><img id=\"ultraSimpleMailerAnim\" height=\"42\" alt=\"Sending mails...\" src=\"images/anims/publishPages.gif\"" +
" width=\"150\" /><br />\n" +
" <span class=\"guiDialogTiny\" style=\"TEXT-ALIGN: center\">Sending mails...</span>\n" +
" <br />\n" +
writer.WriteLine(" <div id=\"ultraSimpleMailerAnimDiv\" style=\"DISPLAY: none; TEXT-ALIGN: left\"><br /><br /><span style=\"border: #999 1px solid; PADDING: 15px; BACKGROUND: white; WIDTH: 300px; TEXT-ALIGN: center\"><img id=\"ultraSimpleMailerAnim\" height=\"42\" alt=\"Sending mails...\" src=\"images/anims/publishPages.gif\"" +
" width=\"150\" /><br />\n" +
" <span class=\"guiDialogTiny\" style=\"TEXT-ALIGN: center\">Sending mails...</span>\n" +
" <br />\n" +
" <br />\n");
@@ -104,7 +109,7 @@ namespace umbraco.editorControls.ultraSimpleMailer
pb.ID = "ultraSimpleMailerUpgradeStatus";
pb.Width = 200;
pb.RenderControl(writer);
writer.WriteLine(" </span><br /><br /></div>\n" +
writer.WriteLine(" </span><br /><br /></div>\n" +
"<div id=\"ultraSimpleMailerFormDiv\">");
writer.WriteLine("<h3 style=\"margin-left: -1px;\">Send newsletter to all...</h3><br/>");
writer.WriteLine("Please confirm that you want to send this message to <b>" + mailerLogic.GetTotalReceiptients(mg).ToString() + "</b> recipients<br/>");
@@ -120,26 +125,26 @@ namespace umbraco.editorControls.ultraSimpleMailer
}
public object[] MenuIcons
{
get
{
object[] _buttons = { };
object[] _buttons = { };
ArrayList buttons = new ArrayList();
for (int i=0;i<_buttons.Length;i++)
for (int i = 0; i < _buttons.Length; i++)
buttons.Add(_buttons[i]);
// Add the two new buttons
MenuIconI menuItemSend = new MenuIconClass();
MenuIconI menuItemSend = new MenuIconClass();
menuItemSend.OnClickCommand = "ultraSimpleMailer_doSend('" + this.ClientID + "')";
menuItemSend.ImageURL = "/umbraco_client/ultraSimpleMailer/images/newsletterSend.gif";
menuItemSend.AltText = "Send newsletter to all";
menuItemSend.ID = "sendToAll";
buttons.Insert(0, menuItemSend);
MenuIconI menuItemTest = new MenuIconClass();
MenuIconI menuItemTest = new MenuIconClass();
menuItemTest.OnClickCommand = "ultraSimpleMailer_doSendTest('" + this.ClientID + "')";
menuItemTest.ImageURL = "/umbraco_client/ultraSimpleMailer/images/newsletterSendTest.gif";
menuItemTest.AltText = "Test newsletter by sending to a mail address you specify";
@@ -148,8 +153,8 @@ namespace umbraco.editorControls.ultraSimpleMailer
buttons.Insert(2, "|");
// Re-create the button array
_buttons = new object[buttons.Count];
for (int i=0;i<buttons.Count;i++)
_buttons = new object[buttons.Count];
for (int i = 0; i < buttons.Count; i++)
_buttons[i] = buttons[i];
@@ -160,3 +165,4 @@ namespace umbraco.editorControls.ultraSimpleMailer
}
}

View File

@@ -332,19 +332,19 @@
<Compile Include="ultimatepicker\ultimatePickerDataEditor.cs" />
<Compile Include="ultimatepicker\ultimatePickerDataType.cs" />
<Compile Include="ultimatepicker\ultimatePickerPrevalueEditor.cs" />
<Compile Include="ultraSimpleMailer\mailerConfiguratorPreValueEditor.cs">
<Compile Include="ultraSimpleMailer\__TODELETE__mailerConfiguratorPreValueEditor.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ultraSimpleMailer\mailerHelper.cs">
<Compile Include="ultraSimpleMailer\__TODELETE__mailerHelper.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ultraSimpleMailer\mailerLogic.cs">
<Compile Include="ultraSimpleMailer\__TODELETE__mailerLogic.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ultraSimpleMailer\ultraSimpleMailerDataType.cs">
<Compile Include="ultraSimpleMailer\__TODELETE__ultraSimpleMailerDataType.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ultraSimpleMailer\ultraSimpleMailerEditor.cs">
<Compile Include="ultraSimpleMailer\__TODELETE__ultraSimpleMailerEditor.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="uploadfield\DataTypeUploadField.cs">

View File

@@ -32,6 +32,7 @@
<add key="umbracoContentXML" value="/data/umbraco.config" />
<add key="umbracoStorageDirectory" value="/data" />
<add key="umbracoPath" value="/umbraco" />
<add key="umbracoClientPath" value="/umbraco_client" />
<add key="umbracoEnableStat" value="false" />
<add key="umbracoHideTopLevelNodeFromPath" value="true" />
<add key="umbracoEditXhtmlMode" value="true" />

View File

@@ -47,6 +47,8 @@ namespace umbraco.BasePages
}
public static string ChildNodeCreated = GetMainTree + ".childNodeCreated();";
public static string SyncTree { get { return GetMainTree + ".syncTree('{0}', {1});"; } }
public static string CopyNode { get { return GetMainTree + ".copyNode('{0}', '{1}');"; } }
public static string MoveNode { get { return GetMainTree + ".moveNode('{0}', '{1}');"; } }
public static string ReloadActionNode { get { return GetMainTree + ".reloadActionNode({0}, {1}, null);"; } }
public static string SetActiveTreeType { get { return GetMainTree + ".setActiveTreeType('{0}');"; } }
public static string CloseModalWindow { get { return GetMainWindow + ".closeModal();"; } }
@@ -110,6 +112,16 @@ namespace umbraco.BasePages
RegisterClientScript(Scripts.ChangeContentFrameUrl(url));
return this;
}
/// <summary>
/// Shows the dashboard for the given application
/// </summary>
/// <param name="app"></param>
/// <returns></returns>
public ClientTools ShowDashboard(string app)
{
return ChangeContentFrameUrl(GlobalSettings.Path + string.Format("/dashboard.aspx?app={0}", app));
}
/// <summary>
/// Reloads the children of the current action node and selects the node that didn't exist there before.
@@ -159,7 +171,19 @@ namespace umbraco.BasePages
{
RegisterClientScript(string.Format(Scripts.SyncTree, path, forceReload.ToString().ToLower()));
return this;
}
}
public ClientTools CopyNode(string currNodeId, string newParentPath)
{
RegisterClientScript(string.Format(Scripts.CopyNode, currNodeId, newParentPath));
return this;
}
public ClientTools MoveNode(string currNodeId, string newParentPath)
{
RegisterClientScript(string.Format(Scripts.MoveNode, currNodeId, newParentPath));
return this;
}
/// <summary>
/// Reloads only the active node in the tree.

View File

@@ -4,95 +4,95 @@ using System.Text;
namespace umbraco.cms.businesslogic.datatype
{
/// <summary>
/// This attribute is used for data types that uses client assets like Javascript and CSS for liveediting.
/// The Live Editing feature in umbraco will look for this attribute and preload all dependencies to the page
/// to ensure that all client events and assets gets loaded
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public class ClientDependencyAttribute : Attribute
{
/// <summary>
/// Gets or sets the priority.
/// </summary>
/// <value>The priority.</value>
public int Priority { get; set; }
///// <summary>
///// This attribute is used for data types that uses client assets like Javascript and CSS for liveediting.
///// The Live Editing feature in umbraco will look for this attribute and preload all dependencies to the page
///// to ensure that all client events and assets gets loaded
///// </summary>
//[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
//public class ClientDependencyAttribute : Attribute
//{
// /// <summary>
// /// Gets or sets the priority.
// /// </summary>
// /// <value>The priority.</value>
// public int Priority { get; set; }
/// <summary>
/// Gets or sets the file path.
/// </summary>
/// <value>The file path.</value>
public string FilePath { get; set; }
// /// <summary>
// /// Gets or sets the file path.
// /// </summary>
// /// <value>The file path.</value>
// public string FilePath { get; set; }
/// <summary>
/// Gets or sets the type of the dependency.
/// </summary>
/// <value>The type of the dependency.</value>
public ClientDependencyType DependencyType { get; set; }
// /// <summary>
// /// Gets or sets the type of the dependency.
// /// </summary>
// /// <value>The type of the dependency.</value>
// public ClientDependencyType DependencyType { get; set; }
/// <summary>
/// Gets or sets the name of an optional javascript method that should be called on load.
/// </summary>
/// <value>The name of the method.</value>
public string InvokeJavascriptMethodOnLoad { get; set; }
// /// <summary>
// /// Gets or sets the name of an optional javascript method that should be called on load.
// /// </summary>
// /// <value>The name of the method.</value>
// public string InvokeJavascriptMethodOnLoad { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="ClientDependencyAttribute"/> class.
/// </summary>
/// <param name="priority">The priority.</param>
/// <param name="dependencyType">Type of the dependency.</param>
/// <param name="filePath">The file path to the dependency.</param>
public ClientDependencyAttribute(int priority, ClientDependencyType dependencyType, string filePath)
: this(priority, dependencyType, filePath, false, string.Empty)
{ }
// /// <summary>
// /// Initializes a new instance of the <see cref="ClientDependencyAttribute"/> class.
// /// </summary>
// /// <param name="priority">The priority.</param>
// /// <param name="dependencyType">Type of the dependency.</param>
// /// <param name="filePath">The file path to the dependency.</param>
// public ClientDependencyAttribute(int priority, ClientDependencyType dependencyType, string filePath)
// : this(priority, dependencyType, filePath, false, string.Empty)
// { }
/// <summary>
/// Initializes a new instance of the <see cref="ClientDependencyAttribute"/> class.
/// </summary>
/// <param name="priority">The priority.</param>
/// <param name="dependencyType">Type of the dependency.</param>
/// <param name="filePath">The file path to the dependency.</param>
/// <param name="invokeJavascriptMethodOnLoad">The name of the Javascript method to invoke when the dependency is loaded.</param>
public ClientDependencyAttribute(int priority, ClientDependencyType dependencyType, string filePath, string invokeJavascriptMethodOnLoad)
: this(priority, dependencyType, filePath, false, invokeJavascriptMethodOnLoad)
{ }
// /// <summary>
// /// Initializes a new instance of the <see cref="ClientDependencyAttribute"/> class.
// /// </summary>
// /// <param name="priority">The priority.</param>
// /// <param name="dependencyType">Type of the dependency.</param>
// /// <param name="filePath">The file path to the dependency.</param>
// /// <param name="invokeJavascriptMethodOnLoad">The name of the Javascript method to invoke when the dependency is loaded.</param>
// public ClientDependencyAttribute(int priority, ClientDependencyType dependencyType, string filePath, string invokeJavascriptMethodOnLoad)
// : this(priority, dependencyType, filePath, false, invokeJavascriptMethodOnLoad)
// { }
/// <summary>
/// Initializes a new instance of the <see cref="ClientDependencyAttribute"/> class.
/// </summary>
/// <param name="priority">The priority.</param>
/// <param name="dependencyType">Type of the dependency.</param>
/// <param name="filePath">The file path to the dependency.</param>
/// <param name="appendUmbracoPath">if set to <c>true</c> the current umbraco path will be prefixed to the filePath.</param>
public ClientDependencyAttribute(int priority, ClientDependencyType dependencyType, string filePath, bool appendUmbracoPath)
: this(priority, dependencyType, filePath, appendUmbracoPath, String.Empty)
{ }
// /// <summary>
// /// Initializes a new instance of the <see cref="ClientDependencyAttribute"/> class.
// /// </summary>
// /// <param name="priority">The priority.</param>
// /// <param name="dependencyType">Type of the dependency.</param>
// /// <param name="filePath">The file path to the dependency.</param>
// /// <param name="appendUmbracoPath">if set to <c>true</c> the current umbraco path will be prefixed to the filePath.</param>
// public ClientDependencyAttribute(int priority, ClientDependencyType dependencyType, string filePath, bool appendUmbracoPath)
// : this(priority, dependencyType, filePath, appendUmbracoPath, String.Empty)
// { }
/// <summary>
/// Initializes a new instance of the <see cref="ClientDependencyAttribute"/> class.
/// </summary>
/// <param name="priority">The priority.</param>
/// <param name="dependencyType">Type of the dependency.</param>
/// <param name="filePath">The file path to the dependency.</param>
/// <param name="appendUmbracoPath">if set to <c>true</c> the current umbraco path will be prefixed to the filePath.</param>
/// <param name="invokeJavascriptMethodOnLoad">The name of the Javascript method to invoke when the dependency is loaded.</param>
public ClientDependencyAttribute(int priority, ClientDependencyType dependencyType, string filePath, bool appendUmbracoPath, string invokeJavascriptMethodOnLoad)
{
if (String.IsNullOrEmpty(filePath))
throw new ArgumentException("filePath");
// /// <summary>
// /// Initializes a new instance of the <see cref="ClientDependencyAttribute"/> class.
// /// </summary>
// /// <param name="priority">The priority.</param>
// /// <param name="dependencyType">Type of the dependency.</param>
// /// <param name="filePath">The file path to the dependency.</param>
// /// <param name="appendUmbracoPath">if set to <c>true</c> the current umbraco path will be prefixed to the filePath.</param>
// /// <param name="invokeJavascriptMethodOnLoad">The name of the Javascript method to invoke when the dependency is loaded.</param>
// public ClientDependencyAttribute(int priority, ClientDependencyType dependencyType, string filePath, bool appendUmbracoPath, string invokeJavascriptMethodOnLoad)
// {
// if (String.IsNullOrEmpty(filePath))
// throw new ArgumentException("filePath");
Priority = priority;
FilePath = appendUmbracoPath ? GlobalSettings.Path + "/" + filePath : filePath;
DependencyType = dependencyType;
InvokeJavascriptMethodOnLoad = invokeJavascriptMethodOnLoad ?? String.Empty;
}
}
// Priority = priority;
// FilePath = appendUmbracoPath ? GlobalSettings.Path + "/" + filePath : filePath;
// DependencyType = dependencyType;
// InvokeJavascriptMethodOnLoad = invokeJavascriptMethodOnLoad ?? String.Empty;
// }
//}
/// <summary>
/// The type of client file
/// </summary>
public enum ClientDependencyType
{
Javascript, Css
}
///// <summary>
///// The type of client file
///// </summary>
//public enum ClientDependencyType
//{
// Javascript, Css
//}
}

View File

@@ -6,66 +6,66 @@ using System.Web;
namespace umbraco.cms.businesslogic.datatype
{
public class ClientDependencyHelper
{
/// <summary>Path to the dependency loader we need for adding control dependencies.</summary>
protected const string DependencyLoaderScriptFile = "{0}/js/UmbracoDependencyLoader.js";
//public class ClientDependencyHelper
//{
// /// <summary>Path to the dependency loader we need for adding control dependencies.</summary>
// protected const string DependencyLoaderScriptFile = "{0}/js/UmbracoDependencyLoader.js";
/// <summary>
/// Adds the client dependencies to the passed page's client script manager.
/// </summary>
public static void AddClientDependencies(Control control) {
Type controlType = control.GetType();
// /// <summary>
// /// Adds the client dependencies to the passed page's client script manager.
// /// </summary>
// public static void AddClientDependencies(Control control) {
// Type controlType = control.GetType();
// find dependencies
List<ClientDependencyAttribute> dependencies = new List<ClientDependencyAttribute>();
foreach (Attribute attribute in Attribute.GetCustomAttributes(controlType))
{
if (attribute is ClientDependencyAttribute)
{
dependencies.Add((ClientDependencyAttribute)attribute);
}
}
// sort by priority
dependencies.Sort((a, b) => a.Priority.CompareTo(b.Priority));
// // find dependencies
// List<ClientDependencyAttribute> dependencies = new List<ClientDependencyAttribute>();
// foreach (Attribute attribute in Attribute.GetCustomAttributes(controlType))
// {
// if (attribute is ClientDependencyAttribute)
// {
// dependencies.Add((ClientDependencyAttribute)attribute);
// }
// }
// // sort by priority
// dependencies.Sort((a, b) => a.Priority.CompareTo(b.Priority));
if (dependencies.Count > 0)
{
// register loader script
if (!HttpContext.Current.Items.Contains(DependencyLoaderScriptFile))
{
ScriptManager.RegisterClientScriptInclude(control, controlType, "DependencyLoader",
String.Format(DependencyLoaderScriptFile, GlobalSettings.Path));
HttpContext.Current.Items[DependencyLoaderScriptFile] = true;
}
// if (dependencies.Count > 0)
// {
// // register loader script
// if (!HttpContext.Current.Items.Contains(DependencyLoaderScriptFile))
// {
// ScriptManager.RegisterClientScriptInclude(control, controlType, "DependencyLoader",
// String.Format(DependencyLoaderScriptFile, GlobalSettings.Path));
// HttpContext.Current.Items[DependencyLoaderScriptFile] = true;
// }
// create Javascript calls
StringBuilder dependencyCalls = new StringBuilder("UmbDependencyLoader");
foreach (ClientDependencyAttribute dependency in dependencies)
{
switch (dependency.DependencyType)
{
case ClientDependencyType.Css:
dependencyCalls.AppendFormat(".AddCss('{0}')", dependency.FilePath);
break;
case ClientDependencyType.Javascript:
dependencyCalls.AppendFormat(".AddJs('{0}','{1}')",
dependency.FilePath, dependency.InvokeJavascriptMethodOnLoad);
break;
}
}
dependencyCalls.Append(';');
// // create Javascript calls
// StringBuilder dependencyCalls = new StringBuilder("UmbDependencyLoader");
// foreach (ClientDependencyAttribute dependency in dependencies)
// {
// switch (dependency.DependencyType)
// {
// case ClientDependencyType.Css:
// dependencyCalls.AppendFormat(".AddCss('{0}')", dependency.FilePath);
// break;
// case ClientDependencyType.Javascript:
// dependencyCalls.AppendFormat(".AddJs('{0}','{1}')",
// dependency.FilePath, dependency.InvokeJavascriptMethodOnLoad);
// break;
// }
// }
// dependencyCalls.Append(';');
// register Javascript calls
ScriptManager.RegisterClientScriptBlock(control, controlType, new Guid().ToString(),
dependencyCalls.ToString(), true);
}
// // register Javascript calls
// ScriptManager.RegisterClientScriptBlock(control, controlType, new Guid().ToString(),
// dependencyCalls.ToString(), true);
// }
// add child dependencies
foreach (Control child in control.Controls)
{
AddClientDependencies(child);
}
}
}
// // add child dependencies
// foreach (Control child in control.Controls)
// {
// AddClientDependencies(child);
// }
// }
//}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace umbraco.presentation.ClientDependency
{
public class BasicClientDependencyFile : IClientDependencyFile
{
public BasicClientDependencyFile(ClientDependencyType type)
{
DependencyType = type;
}
#region IClientDependencyFile Members
public string FilePath { get; set; }
public ClientDependencyType DependencyType { get; private set; }
public string InvokeJavascriptMethodOnLoad { get; set; }
public int Priority { get; set; }
public string PathNameAlias { get; set; }
public bool DoNotOptimize { get; set; }
#endregion
}
}

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
namespace umbraco.presentation.ClientDependency
{
public class BasicClientDependencyPath : IClientDependencyPath
{
public string Name { get; set; }
public string Path { get; set; }
public string ResolvedPath
{
get
{
return (HttpContext.Current.CurrentHandler as Page).ResolveUrl(Path);
}
}
}
}

View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace umbraco.presentation.ClientDependency
{
/// <summary>
/// Wraps a HashSet object for the client dependency file type and declares a equality operator
/// </summary>
public class ClientDependencyCollection : HashSet<IClientDependencyFile>
{
public ClientDependencyCollection() : base(new ClientDependencyComparer()) { }
internal class ClientDependencyComparer : IEqualityComparer<IClientDependencyFile>
{
#region IEqualityComparer<IClientDependencyFile> Members
/// <summary>
/// If the lowercased combination of the file path, dependency type and path name aliases are the same,
/// then they are the same dependency.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
public bool Equals(IClientDependencyFile x, IClientDependencyFile y)
{
return (x.FilePath.ToLower().Trim() + x.DependencyType.ToString().ToLower() + x.PathNameAlias.ToLower().Trim() ==
y.FilePath.ToLower().Trim() + y.DependencyType.ToString().ToLower() + y.PathNameAlias.ToLower().Trim());
}
public int GetHashCode(IClientDependencyFile obj)
{
return (obj.FilePath.ToLower().Trim() + obj.DependencyType.ToString().ToLower() + obj.PathNameAlias.ToLower().Trim())
.GetHashCode();
}
#endregion
}
}
}

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Web;
using System.Linq;
using umbraco.presentation.ClientDependency.Providers;
using umbraco.presentation.ClientDependency.Config;
@@ -19,70 +20,48 @@ namespace umbraco.presentation.ClientDependency.Controls
Paths = new ClientDependencyPathCollection();
EmbedType = ClientDependencyEmbedType.Header;
IsDebugMode = false;
//add this object to the context and validate the context type
if (HttpContext.Current != null)
{
if (HttpContext.Current.Items.Contains(ContextKey))
throw new InvalidOperationException("Only one ClientDependencyLoader may exist on a page");
//The context needs to be a page
Page page = HttpContext.Current.Handler as Page;
if (page == null)
throw new InvalidOperationException("ClientDependencyLoader only works with Page based handlers.");
HttpContext.Current.Items[ContextKey] = this;
}
else
throw new InvalidOperationException("ClientDependencyLoader requires an HttpContext");
}
private const string ContextKey = "ClientDependencyLoader";
public static void RegisterDependency(string filePath, ClientDependencyType type)
/// <summary>
/// Singleton per request instance.
/// </summary>
/// <exception cref="NullReferenceException">
/// If no ClientDependencyLoader control exists on the current page, an exception is thrown.
/// </exception>
public static ClientDependencyLoader Instance
{
RegisterDependency(filePath, "", type);
}
public static void RegisterDependency(string filePath, string pathNameAlias, ClientDependencyType type)
{
RegisterDependency(ClientDependencyInclude.DefaultPriority, false, filePath, pathNameAlias, type, "");
get
{
if (!HttpContext.Current.Items.Contains(ContextKey))
return null;
return HttpContext.Current.Items[ContextKey] as ClientDependencyLoader;
}
}
/// <summary>
/// Dynamically registers a dependency into the loader at runtime.
/// This is similar to ScriptManager.RegisterClientScriptInclude
/// Tracks all dependencies and maintains a deduplicated list
/// </summary>
/// <param name="file"></param>
public static void RegisterDependency(int priority, bool doNotOptimize, string filePath, string pathNameAlias, ClientDependencyType type, string invokeJavascriptMethodOnLoad)
{
if (!HttpContext.Current.Items.Contains(ContextKey))
throw new NullReferenceException("No ClientDependencyLoader found in the current request");
ClientDependencyLoader loader = HttpContext.Current.Items[ContextKey] as ClientDependencyLoader;
if (loader == null)
throw new Exception("Could not find a ClientDependencyLoader in the current request");
//loader.RegisteredFiles.Add(file);
//create/add a new control to this control's collection
if (type == ClientDependencyType.Css)
{
CssInclude cssInc = new CssInclude();
cssInc.DoNotOptimize = doNotOptimize;
cssInc.Priority = priority;
cssInc.FilePath = filePath;
cssInc.PathNameAlias = pathNameAlias;
cssInc.InvokeJavascriptMethodOnLoad = invokeJavascriptMethodOnLoad;
loader.Controls.Add(cssInc);
}
else
{
JsInclude jsInc = new JsInclude();
jsInc.DoNotOptimize = doNotOptimize;
jsInc.Priority = priority;
jsInc.FilePath = filePath;
jsInc.PathNameAlias = pathNameAlias;
jsInc.InvokeJavascriptMethodOnLoad = invokeJavascriptMethodOnLoad;
loader.Controls.Add(jsInc);
}
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (HttpContext.Current.Items.Contains(ContextKey))
{
throw new Exception("Only one ClientDependencyLoader may exist on a page");
}
else
{
HttpContext.Current.Items.Add(ContextKey, this);
}
}
private List<ProviderDependencyList> m_Dependencies = new List<ProviderDependencyList>();
/// <summary>
/// Tracks all paths and maintains a deduplicated list
/// </summary>
private HashSet<IClientDependencyPath> m_Paths = new HashSet<IClientDependencyPath>();
/// <summary>
/// Need to set the container for each of the paths to support databinding.
@@ -112,27 +91,33 @@ namespace umbraco.presentation.ClientDependency.Controls
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
foreach (ClientDependencyPath path in Paths)
{
Page.Trace.Write("ClientDependency", string.Format("Path loaded: {0}", path.Path));
}
ClientDependencyProvider provider = null;
m_Paths.UnionWith(Paths.Cast<IClientDependencyPath>());
ClientDependencyProvider provider = null;
switch (EmbedType)
{
case ClientDependencyEmbedType.Header:
provider = ClientDependencySettings.Instance.ProviderCollection[PageHeaderProvider.DefaultName];
provider.IsDebugMode = IsDebugMode;
ClientDependencyHelper.RegisterClientDependencies(provider, this.Page, Paths);
provider.IsDebugMode = IsDebugMode;
RegisterClientDependencies(provider, this.Page, m_Paths);
break;
case ClientDependencyEmbedType.ClientSideRegistration:
provider = ClientDependencySettings.Instance.ProviderCollection[ClientSideRegistrationProvider.DefaultName];
provider.IsDebugMode = IsDebugMode;
ClientDependencyHelper.RegisterClientDependencies(provider, this.Page, Paths);
provider.IsDebugMode = IsDebugMode;
RegisterClientDependencies(provider, this.Page, m_Paths);
break;
}
RenderDependencies();
}
private void RenderDependencies()
{
m_Dependencies.ForEach(x =>
{
x.Provider.RegisterDependencies(this.Page, x.Dependencies, m_Paths);
});
}
[PersistenceMode(PersistenceMode.InnerProperty)]
public ClientDependencyPathCollection Paths { get; private set; }
@@ -140,7 +125,212 @@ namespace umbraco.presentation.ClientDependency.Controls
public bool IsDebugMode { get; set; }
private List<ClientDependencyAttribute> m_Dependencies = new List<ClientDependencyAttribute>();
#region Static Helper methods
/// <summary>
/// Checks if a loader already exists, if it does, it returns it, otherwise it will
/// create a new one in the control specified.
/// isNew will be true if a loader was created, otherwise false if it already existed.
/// </summary>
/// <param name="parent"></param>
/// <param name="isNew"></param>
/// <returns></returns>
public static ClientDependencyLoader TryCreate(Control parent, out bool isNew)
{
if (ClientDependencyLoader.Instance == null)
{
ClientDependencyLoader loader = new ClientDependencyLoader();
parent.Controls.Add(loader);
isNew = true;
return loader;
}
else
{
isNew = false;
return ClientDependencyLoader.Instance;
}
}
#endregion
/// <summary>
/// Registers a file dependency with the default provider.
/// </summary>
/// <param name="filePath"></param>
/// <param name="type"></param>
public ClientDependencyLoader RegisterDependency(string filePath, ClientDependencyType type)
{
RegisterDependency(filePath, "", type);
return this;
}
/// <summary>
/// Registers a file dependency with the default provider.
/// </summary>
/// <param name="filePath"></param>
/// <param name="pathNameAlias"></param>
/// <param name="type"></param>
public ClientDependencyLoader RegisterDependency(string filePath, string pathNameAlias, ClientDependencyType type)
{
ClientDependencyLoader.Instance.RegisterDependency(ClientDependencyInclude.DefaultPriority, false, filePath, pathNameAlias, type, "");
return this;
}
/// <summary>
/// Adds a path to the current loader
/// </summary>
/// <param name="pathNameAlias"></param>
/// <param name="path"></param>
public ClientDependencyLoader AddPath(string pathNameAlias, string path)
{
AddPath(new BasicClientDependencyPath() { Name = pathNameAlias, Path = path });
return this;
}
/// <summary>
/// Adds a path to the current loader
/// </summary>
/// <param name="pathNameAlias"></param>
/// <param name="path"></param>
public void AddPath(IClientDependencyPath path)
{
m_Paths.Add(path);
}
/// <summary>
/// Dynamically registers a dependency into the loader at runtime.
/// This is similar to ScriptManager.RegisterClientScriptInclude.
/// Registers a file dependency with the default provider.
/// </summary>
/// <param name="file"></param>
public void RegisterDependency(int priority, bool doNotOptimize, string filePath, string pathNameAlias, ClientDependencyType type, string invokeJavascriptMethodOnLoad)
{
BasicClientDependencyFile file = new BasicClientDependencyFile(type);
file.DoNotOptimize = doNotOptimize;
file.Priority = priority;
file.FilePath = filePath;
file.PathNameAlias = pathNameAlias;
file.InvokeJavascriptMethodOnLoad = invokeJavascriptMethodOnLoad;
RegisterClientDependencies(new ClientDependencyCollection() { file }, new List<IClientDependencyPath>()); //send an empty paths collection
}
/// <summary>
/// Registers dependencies with the specified provider.
/// </summary>
/// <param name="provider"></param>
/// <param name="dependencies"></param>
/// <param name="paths"></param>
/// <remarks>
/// This is the top most overloaded method
/// </remarks>
public void RegisterClientDependencies(ClientDependencyProvider provider, ClientDependencyCollection dependencies, IEnumerable<IClientDependencyPath> paths)
{
//find or create the ProviderDependencyList for the provider passed in
ProviderDependencyList currList = m_Dependencies
.Where(x => x.Contains(provider))
.DefaultIfEmpty(new ProviderDependencyList(provider))
.SingleOrDefault();
//add the dependencies
currList.AddDependencies(dependencies);
//add the list if it is new
if (!m_Dependencies.Contains(currList))
m_Dependencies.Add(currList);
//add the paths, ensure no dups
m_Paths.UnionWith(paths);
}
public void RegisterClientDependencies(ClientDependencyCollection dependencies, IEnumerable<IClientDependencyPath> paths)
{
RegisterClientDependencies(ClientDependencySettings.Instance.DefaultProvider, dependencies, paths);
}
/// <summary>
/// Registers dependencies with the default provider
/// </summary>
/// <param name="control"></param>
/// <param name="paths"></param>
public void RegisterClientDependencies(Control control, ClientDependencyPathCollection paths)
{
RegisterClientDependencies(ClientDependencySettings.Instance.DefaultProvider, control, paths.Cast<IClientDependencyPath>());
}
/// <summary>
/// Registers dependencies with the provider name specified
/// </summary>
/// <param name="providerName"></param>
/// <param name="control"></param>
/// <param name="paths"></param>
public void RegisterClientDependencies(string providerName, Control control, IEnumerable<IClientDependencyPath> paths)
{
RegisterClientDependencies(ClientDependencySettings.Instance.ProviderCollection[providerName], control, paths);
}
/// <summary>
/// Registers dependencies with the provider specified by T
/// </summary>
public void RegisterClientDependencies<T>(Control control, List<IClientDependencyPath> paths)
where T : ClientDependencyProvider
{
//need to find the provider with the type
ClientDependencyProvider found = null;
foreach (ClientDependencyProvider p in ClientDependencySettings.Instance.ProviderCollection)
{
if (p.GetType().Equals(typeof(T)))
{
found = p;
break;
}
}
if (found == null)
throw new ArgumentException("Could not find the ClientDependencyProvider specified by T");
RegisterClientDependencies(found, control, paths);
}
public void RegisterClientDependencies(ClientDependencyProvider provider, Control control, IEnumerable<IClientDependencyPath> paths)
{
ClientDependencyCollection dependencies = FindDependencies(control);
RegisterClientDependencies(provider, dependencies, paths);
}
/// <summary>
/// Recursively find all dependencies of this control and it's entire child control heirarchy.
/// </summary>
/// <param name="control"></param>
/// <returns></returns>
private ClientDependencyCollection FindDependencies(Control control)
{
// find dependencies
Type controlType = control.GetType();
ClientDependencyCollection dependencies = new ClientDependencyCollection();
foreach (Attribute attribute in Attribute.GetCustomAttributes(controlType))
{
if (attribute is ClientDependencyAttribute)
{
dependencies.Add((ClientDependencyAttribute)attribute);
}
}
// add child dependencies
Type iClientDependency = typeof(IClientDependencyFile);
foreach (Control child in control.Controls)
{
if (iClientDependency.IsAssignableFrom(child.GetType()))
{
IClientDependencyFile include = (IClientDependencyFile)child;
dependencies.Add(include);
}
else
{
//recurse and de-duplicate!
dependencies.UnionWith(FindDependencies(child));
}
}
return dependencies;
}
}

View File

@@ -12,7 +12,7 @@ namespace umbraco.presentation.ClientDependency.Controls
/// Databinding support has been enabled.
/// </summary>
[ParseChildren(true)]
public class ClientDependencyPath
public class ClientDependencyPath : IClientDependencyPath
{
string _name = "";
string _path = "";

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace umbraco.presentation.ClientDependency
{
public interface IClientDependencyPath
{
string Name { get; set; }
string Path { get; set; }
string ResolvedPath { get; }
}
}

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using umbraco.presentation.ClientDependency.Providers;
namespace umbraco.presentation.ClientDependency
{
internal class ProviderDependencyList
{
internal ProviderDependencyList(ClientDependencyProvider provider)
{
Provider = provider;
Dependencies = new ClientDependencyCollection();
}
internal bool Contains(ClientDependencyProvider provider)
{
return Provider.Name == provider.Name;
}
internal void AddDependencies(ClientDependencyCollection list)
{
Dependencies.UnionWith(list);
}
internal void AddDependency(IClientDependencyFile file)
{
Dependencies.Add(file);
}
internal ClientDependencyCollection Dependencies { get; private set; }
internal ClientDependencyProvider Provider { get; private set; }
}
}

View File

@@ -12,7 +12,7 @@ namespace umbraco.presentation.ClientDependency.Providers
public abstract class ClientDependencyProvider : ProviderBase
{
protected Control DependantControl { get; private set; }
protected ClientDependencyPathCollection FolderPaths { get; private set; }
protected HashSet<IClientDependencyPath> FolderPaths { get; private set; }
protected List<IClientDependencyFile> AllDependencies { get; private set; }
/// <summary>
@@ -27,7 +27,7 @@ namespace umbraco.presentation.ClientDependency.Providers
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
{
IsDebugMode = false;
IsDebugMode = true;
if (config != null && config["isDebug"] != null)
{
bool isDebug;
@@ -38,7 +38,7 @@ namespace umbraco.presentation.ClientDependency.Providers
base.Initialize(name, config);
}
public void RegisterDependencies(Control dependantControl, ClientDependencyList dependencies, ClientDependencyPathCollection paths)
public void RegisterDependencies(Control dependantControl, ClientDependencyCollection dependencies, HashSet<IClientDependencyPath> paths)
{
DependantControl = dependantControl;
AllDependencies = new List<IClientDependencyFile>(dependencies);
@@ -46,19 +46,13 @@ namespace umbraco.presentation.ClientDependency.Providers
UpdateFilePaths();
//seperate the types into 2 lists for all dependencies without composite groups
List<IClientDependencyFile> jsDependencies = AllDependencies.FindAll(
delegate(IClientDependencyFile a)
{
return a.DependencyType == ClientDependencyType.Javascript;
}
);
List<IClientDependencyFile> cssDependencies = AllDependencies.FindAll(
delegate(IClientDependencyFile a)
{
return a.DependencyType == ClientDependencyType.Css;
}
);
List<IClientDependencyFile> jsDependencies = AllDependencies
.Where(x => x.DependencyType == ClientDependencyType.Javascript)
.ToList();
List<IClientDependencyFile> cssDependencies = AllDependencies
.Where(x => x.DependencyType == ClientDependencyType.Css)
.ToList();
// sort by priority
jsDependencies.Sort((a, b) => a.Priority.CompareTo(b.Priority));
@@ -81,10 +75,10 @@ namespace umbraco.presentation.ClientDependency.Providers
/// <param name="jsDependencies"></param>
protected virtual void RegisterStartupScripts(List<IClientDependencyFile> dependencies)
{
foreach (var js in dependencies)
{
DependantControl.Page.ClientScript.RegisterStartupScript(this.GetType(), js.GetHashCode().ToString(), js.InvokeJavascriptMethodOnLoad, true);
}
//foreach (var js in dependencies)
//{
// DependantControl.Page.ClientScript.RegisterStartupScript(this.GetType(), js.GetHashCode().ToString(), js.InvokeJavascriptMethodOnLoad, true);
//}
}
/// <summary>
@@ -149,8 +143,9 @@ namespace umbraco.presentation.ClientDependency.Providers
{
if (!string.IsNullOrEmpty(dependency.PathNameAlias))
{
ClientDependencyPath path = FolderPaths.Find(
delegate(ClientDependencyPath p)
List<IClientDependencyPath> paths = FolderPaths.ToList();
IClientDependencyPath path = paths.Find(
delegate(IClientDependencyPath p)
{
return p.Name == dependency.PathNameAlias;
}

View File

@@ -114,7 +114,10 @@ Umbraco.Sys.onScriptAvailable = function(script) {
if (typeof (eval(script.callbackMethod)) == 'function') {
UmbDependencyLoader.LoadNextJs();
Sys.Debug.trace("UmbracoDependencyLoader: Executing '" + script.filePath + "' callback '" + script.callbackMethod + "'.");
eval(script.callbackMethod + "()");
var func = eval(script.callbackMethod);
alert(func);
func.call(this);
//eval(script.callbackMethod + "()");
}
else {
setTimeout(function() {

View File

@@ -51,8 +51,10 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="BasicClientDependencyFile.cs" />
<Compile Include="BasicClientDependencyPath.cs" />
<Compile Include="Controls\ClientDependencyInclude.cs" />
<Compile Include="ClientDependencyList.cs" />
<Compile Include="ClientDependencyCollection.cs" />
<Compile Include="ClientDependencyType.cs" />
<Compile Include="CompositeFileMap.cs" />
<Compile Include="CompositeFileProcessor.cs" />
@@ -62,11 +64,12 @@
<Compile Include="Controls\JsInclude.cs" />
<Compile Include="CssFileUrlFormatter.cs" />
<Compile Include="IClientDependencyFile.cs" />
<Compile Include="IClientDependencyPath.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ProviderDependencyList.cs" />
<Compile Include="Providers\ClientDependencyProvider.cs" />
<Compile Include="ClientDependencyAttribute.cs" />
<Compile Include="ClientDependencyEmbedType.cs" />
<Compile Include="ClientDependencyHelper.cs" />
<Compile Include="Controls\ClientDependencyLoader.cs" />
<Compile Include="Controls\ClientDependencyPath.cs" />
<Compile Include="Controls\ClientDependencyPathCollection.cs" />

View File

@@ -468,7 +468,7 @@
<Compile Include="umbraco\controls\TreeControl.ascx.designer.cs">
<DependentUpon>TreeControl.ascx</DependentUpon>
</Compile>
<Compile Include="umbraco\controls\windowCloser.cs">
<Compile Include="umbraco\controls\__TODELETE__windowCloser.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="umbraco\developer\Xslt\xsltVisualize.aspx.cs">

View File

@@ -1,12 +1,14 @@
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using umbraco.presentation.ClientDependency;
namespace umbraco.presentation.LiveEditing.Controls
{
/// <summary>
/// Control that can receive messages from the client.
/// </summary>
[ClientDependency(100, ClientDependencyType.Javascript, "LiveEditing/Controls/Communicator.js", "UmbracoRoot")]
public class Communicator : Control
{
/// <summary>
@@ -70,8 +72,8 @@ namespace umbraco.presentation.LiveEditing.Controls
m_SubmitButton.Click += new EventHandler(SubmitButton_Click);
m_MainPanel.ContentTemplateContainer.Controls.Add(m_SubmitButton);
ScriptManager.RegisterClientScriptInclude(this, GetType(), ScriptFile,
string.Format(ScriptFile, GlobalSettings.Path));
ScriptManager.RegisterClientScriptInclude(this, GetType(), ScriptFile,
string.Format(ScriptFile, GlobalSettings.Path));
}
/// <summary>

View File

@@ -3,7 +3,11 @@ using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using umbraco.presentation.LiveEditing.Modules.ItemEditing;
using umbraco.cms.businesslogic.datatype;
using umbraco.presentation.ClientDependency;
using umbraco.presentation.ClientDependency.Providers;
using umbraco.presentation.ClientDependency.Controls;
using umbraco.BasePages;
using System.Collections.Generic;
namespace umbraco.presentation.LiveEditing.Controls
{
@@ -12,9 +16,9 @@ namespace umbraco.presentation.LiveEditing.Controls
/// Provides public properties, events and methods for Live Editing controls.
/// Add this control to a (master) page to enable Live Editing.
/// </summary>
[ClientDependency(1, ClientDependencyType.Css, "LiveEditing/CSS/LiveEditing.css", true)]
[ClientDependency(1, ClientDependencyType.Javascript, "/umbraco_client/ui/jquery.js", false, "_jQueryNoConflict = function(){jQuery.noConflict();}")]
[ClientDependency(2, ClientDependencyType.Javascript, "js/UmbracoSpeechBubble.js", true)]
[ClientDependency(1, ClientDependencyType.Css, "LiveEditing/CSS/LiveEditing.css", "UmbracoRoot")]
[ClientDependency(1, ClientDependencyType.Javascript, "ui/jquery.js", "UmbracoClient", InvokeJavascriptMethodOnLoad = "_jQueryNoConflict = function(){jQuery.noConflict();};")]
[ClientDependency(10, ClientDependencyType.Javascript, "js/UmbracoSpeechBubble.js", "UmbracoRoot")]
public class LiveEditingManager : Control
{
@@ -90,11 +94,10 @@ namespace umbraco.presentation.LiveEditing.Controls
EnsureChildControls();
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
ClientDependencyHelper.AddClientDependencies(this);
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
}
/// <summary>
/// Called by the ASP.NET page framework to notify server controls
@@ -105,6 +108,14 @@ namespace umbraco.presentation.LiveEditing.Controls
{
base.CreateChildControls();
//we need a DependencyLoader control
bool isNew;
ClientDependencyLoader.TryCreate(this, out isNew)
.AddPath("UmbracoClient", GlobalSettings.ClientPath)
.AddPath("UmbracoRoot", GlobalSettings.Path)
.EmbedType = ClientDependencyEmbedType.ClientSideRegistration;
ClientDependencyLoader.Instance.IsDebugMode = true;
m_Communicator = new Communicator();
Controls.Add(m_Communicator);
@@ -136,11 +147,20 @@ namespace umbraco.presentation.LiveEditing.Controls
/// <param name="title">Unescaped title text.</param>
/// <param name="message">Unescaped message text.</param>
/// <param name="icon">The icon.</param>
[Obsolete("Use the ClientTools library instead: 'ShowSpeechBubble' method.")]
public virtual void DisplayUserMessage(string title, string message, string icon)
{
ScriptManager.RegisterClientScriptBlock(Page, GetType(), new Guid().ToString(),
string.Format("UmbSpeechBubble.ShowMessage('{2}','{0}','{1}');",
EscapeJavascriptString(title), EscapeJavascriptString(message), EscapeJavascriptString(icon)), true);
ClientTools cTools = new ClientTools(Page);
BasePage.speechBubbleIcon ico = BasePage.speechBubbleIcon.info;
try
{
ico = (BasePage.speechBubbleIcon)(Enum.Parse(typeof(BasePage.speechBubbleIcon), icon));
}
catch { }
cTools.ShowSpeechBubble(BasePage.speechBubbleIcon.info, title, message);
//ScriptManager.RegisterClientScriptBlock(Page, GetType(), new Guid().ToString(),
// string.Format("UmbSpeechBubble.ShowMessage('{2}','{0}','{1}');",
// EscapeJavascriptString(title), EscapeJavascriptString(message), EscapeJavascriptString(icon)), true);
}
#endregion

View File

@@ -7,19 +7,19 @@ using umbraco.presentation.LiveEditing.Modules.DeleteModule;
using umbraco.presentation.LiveEditing.Modules.ItemEditing;
//using umbraco.presentation.LiveEditing.Modules.MacroEditing;
using umbraco.presentation.LiveEditing.Modules.UnpublishModule;
using umbraco.cms.businesslogic.datatype;
using umbraco.BasePages;
using umbraco.cms.businesslogic.web;
using umbraco.BusinessLogic.Actions;
using umbraco.presentation.umbraco.controls;
using umbraco.presentation.ClientDependency;
namespace umbraco.presentation.LiveEditing.Controls
{
/// <summary>
/// The default toolbar used for Live Editing.
/// </summary>
[ClientDependency(1, ClientDependencyType.Javascript, "/umbraco_client/ui/jquery.js", false)]
[ClientDependency(2, ClientDependencyType.Javascript, "LiveEditing/Controls/LiveEditingToolbar.js", true)]
[ClientDependency(1, ClientDependencyType.Javascript, "ui/jquery.js", "UmbracoClient")]
[ClientDependency(20, ClientDependencyType.Javascript, "LiveEditing/Controls/LiveEditingToolbar.js", "UmbracoRoot")]
public class LiveEditingToolbar : Control
{
#region Protected Constants

View File

@@ -6,12 +6,13 @@ using umbraco.cms.businesslogic.web;
using umbraco.presentation.LiveEditing.Controls;
using Content = umbraco.cms.businesslogic.Content;
using umbraco.BusinessLogic.Actions;
using umbraco.presentation.ClientDependency;
namespace umbraco.presentation.LiveEditing.Modules.CreateModule
{
[ClientDependency(200, ClientDependencyType.Javascript, "LiveEditing/Modules/CreateModule/CreateModule.js", "UmbracoRoot")]
public class CreateModule : BaseModule
{
protected const string CreateModuleScriptFile = "{0}/LiveEditing/Modules/CreateModule/CreateModule.js";
//protected const string CreateModuleScriptFile = "{0}/LiveEditing/Modules/CreateModule/CreateModule.js";
protected ImageButton m_CreateButton = new ImageButton();
@@ -84,7 +85,7 @@ namespace umbraco.presentation.LiveEditing.Modules.CreateModule
m_CreateModal.Controls.Add(new LiteralControl("</div>"));
ScriptManager.RegisterClientScriptInclude(this, GetType(), CreateModuleScriptFile, String.Format(CreateModuleScriptFile, GlobalSettings.Path));
//ScriptManager.RegisterClientScriptInclude(this, GetType(), CreateModuleScriptFile, String.Format(CreateModuleScriptFile, GlobalSettings.Path));
}
private void FillAllowedDoctypes()

View File

@@ -5,12 +5,13 @@ using AjaxControlToolkit;
using umbraco.cms.businesslogic.web;
using umbraco.presentation.LiveEditing.Controls;
using umbraco.BusinessLogic.Actions;
using umbraco.presentation.ClientDependency;
namespace umbraco.presentation.LiveEditing.Modules.DeleteModule
{
[ClientDependency(200, ClientDependencyType.Javascript, "LiveEditing/Modules/DeleteModule/DeleteModule.js", "UmbracoRoot")]
public class DeleteModule : BaseModule
{
protected const string DeleteModuleScriptFile = "{0}/LiveEditing/Modules/DeleteModule/DeleteModule.js";
//protected const string DeleteModuleScriptFile = "{0}/LiveEditing/Modules/DeleteModule/DeleteModule.js";
protected ImageButton m_DeleteButton = new ImageButton();
@@ -72,7 +73,7 @@ namespace umbraco.presentation.LiveEditing.Modules.DeleteModule
m_DeleteModal.Controls.Add(new LiteralControl("</div>"));
ScriptManager.RegisterClientScriptInclude(this, GetType(), DeleteModuleScriptFile, String.Format(DeleteModuleScriptFile, GlobalSettings.Path));
//ScriptManager.RegisterClientScriptInclude(this, GetType(), DeleteModuleScriptFile, String.Format(DeleteModuleScriptFile, GlobalSettings.Path));
}

View File

@@ -5,7 +5,6 @@ using System.IO;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using umbraco.cms.businesslogic.datatype;
using umbraco.cms.businesslogic.property;
using umbraco.cms.businesslogic.propertytype;
using umbraco.cms.businesslogic.web;
@@ -13,14 +12,16 @@ using umbraco.interfaces;
using umbraco.presentation.LiveEditing.Controls;
using umbraco.presentation.LiveEditing.Updates;
using umbraco.presentation.templateControls;
using umbraco.presentation.ClientDependency;
using umbraco.presentation.ClientDependency.Controls;
using umbraco.presentation.ClientDependency.Providers;
namespace umbraco.presentation.LiveEditing.Modules.ItemEditing
{
/// <summary>
/// Control that wraps the editor control to edit a field in Live Editing mode.
/// </summary>
[ClientDependency(1, ClientDependencyType.Javascript, "/umbraco_client/ui/jquery.js", false)]
[ClientDependency(2, ClientDependencyType.Javascript, "LiveEditing/Modules/ItemEditing/ItemEditing.js", true, "initializeGlobalItemEditing")]
[ClientDependency(1, ClientDependencyType.Javascript, "ui/jquery.js", "UmbracoClient")]
[ClientDependency(21, ClientDependencyType.Javascript, "LiveEditing/Modules/ItemEditing/ItemEditing.js", "UmbracoRoot", InvokeJavascriptMethodOnLoad = "initializeGlobalItemEditing")]
public class ItemEditor : UpdatePanel
{
#region Protected Constants
@@ -104,6 +105,7 @@ namespace umbraco.presentation.LiveEditing.Modules.ItemEditing
ScriptManager.RegisterStartupScript(Page, GetType(), new Guid().ToString(),
string.Format("ItemEditing.startEdit({0});", ItemId), true);
EnsureChildControls();
}
/// <summary>
@@ -145,6 +147,9 @@ namespace umbraco.presentation.LiveEditing.Modules.ItemEditing
ID = "ItemEditor";
RenderMode = UpdatePanelRenderMode.Inline;
m_Manager.MessageReceived += Manager_MessageReceived;
m_Manager.LiveEditingContext.Updates.UpdateAdded += Updates_UpdateAdded;
}
/// <summary>
@@ -156,6 +161,7 @@ namespace umbraco.presentation.LiveEditing.Modules.ItemEditing
base.OnLoad(e);
// create editor controls if in edit modoe
//this NEVER fires because onload occurs before ItemId is set in StartEditing
if (ItemId != 0)
{
EnsureChildControls();
@@ -164,21 +170,7 @@ namespace umbraco.presentation.LiveEditing.Modules.ItemEditing
// enable editing on all items
foreach (Item item in Utility.FindControls<Item>(Page.Master))
item.Renderer = LiveEditingItemRenderer.Instance;
m_Manager.MessageReceived += Manager_MessageReceived;
m_Manager.LiveEditingContext.Updates.UpdateAdded += Updates_UpdateAdded;
}
/// <summary>
/// Raises the <see cref="E:PreRender"/> event.
/// </summary>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
// add the editor control's client dependencies (the client will ensure they're only loaded once)
ClientDependencyHelper.AddClientDependencies(this);
}
@@ -192,6 +184,9 @@ namespace umbraco.presentation.LiveEditing.Modules.ItemEditing
// Unfortunately, adding TinyMCE with the client dependencies system does not work
// due to a bug in the way TinyMCE initializes in IE.
// Therefore, TinyMCE needs to be added with a script tag.
// TODO: Same goes for the pagePicker, mediaPicker controls. This is due to
// the client dependency framework not being able to render things out
// after an async call with an UpdatePanel!
ScriptManagerProxy proxy = new ScriptManagerProxy();
proxy.Scripts.Add(new ScriptReference(TinyMCEClientScriptFile));
ContentTemplateContainer.Controls.Add(proxy);

View File

@@ -9,12 +9,13 @@ using umbraco.presentation.LiveEditing.Controls;
using umbraco.presentation.LiveEditing.Updates;
using umbraco.presentation.templateControls;
using UM = umbraco.cms.businesslogic.macro;
using umbraco.presentation.ClientDependency;
namespace umbraco.presentation.LiveEditing.Modules.MacroEditing
{
[ClientDependency(200, ClientDependencyType.Javascript, "LiveEditing/Modules/MacroModule/MacroModule.js", "UmbracoRoot")]
public class MacroModule : BaseModule
{
protected const string MacroModuleScriptFile = "{0}/LiveEditing/Modules/MacroModule/MacroModule.js";
//protected const string MacroModuleScriptFile = "{0}/LiveEditing/Modules/MacroModule/MacroModule.js";
private ImageButton m_MacroButton = new ImageButton();
@@ -108,7 +109,7 @@ namespace umbraco.presentation.LiveEditing.Modules.MacroEditing
m_MacroModal.Controls.Add(new LiteralControl("</div>"));
ScriptManager.RegisterClientScriptInclude(this, GetType(), MacroModuleScriptFile, String.Format(MacroModuleScriptFile, GlobalSettings.Path));
//ScriptManager.RegisterClientScriptInclude(this, GetType(), MacroModuleScriptFile, String.Format(MacroModuleScriptFile, GlobalSettings.Path));
}

View File

@@ -5,12 +5,13 @@ using AjaxControlToolkit;
using umbraco.cms.businesslogic.web;
using umbraco.presentation.LiveEditing.Controls;
using umbraco.BusinessLogic.Actions;
using umbraco.presentation.ClientDependency;
namespace umbraco.presentation.LiveEditing.Modules.UnpublishModule
{
[ClientDependency(200, ClientDependencyType.Javascript, "LiveEditing/Modules/UnpublishModule/UnpublishModule.js", "UmbracoRoot")]
public class UnpublishModule : BaseModule
{
protected const string UnpublishModuleScriptFile = "{0}/LiveEditing/Modules/UnpublishModule/UnpublishModule.js";
//protected const string UnpublishModuleScriptFile = "{0}/LiveEditing/Modules/UnpublishModule/UnpublishModule.js";
protected ImageButton m_UnpublishButton = new ImageButton();
@@ -84,7 +85,7 @@ namespace umbraco.presentation.LiveEditing.Modules.UnpublishModule
m_UnpublishModal.Controls.Add(new LiteralControl("</div>"));
ScriptManager.RegisterClientScriptInclude(this, GetType(), UnpublishModuleScriptFile, String.Format(UnpublishModuleScriptFile, GlobalSettings.Path));
//ScriptManager.RegisterClientScriptInclude(this, GetType(), UnpublishModuleScriptFile, String.Format(UnpublishModuleScriptFile, GlobalSettings.Path));
}

View File

@@ -56,6 +56,18 @@ namespace umbraco.controls
{
}
/// <summary>
/// Constructor to set default properties.
/// </summary>
/// <param name="c"></param>
/// <param name="CanPublish"></param>
/// <param name="Id"></param>
/// <remarks>
/// This method used to create all of the child controls too which is BAD since
/// the page hasn't started initializing yet. Control IDs were not being named
/// correctly, etc... I've moved the child control setup/creation to the CreateChildControls
/// method where they are suposed to be.
/// </remarks>
public ContentControl(Content c, publishModes CanPublish, string Id)
{
ID = Id;
@@ -64,40 +76,55 @@ namespace umbraco.controls
Width = 350;
Height = 350;
SaveAndPublish += new EventHandler(standardSaveAndPublishHandler);
Save += new EventHandler(standardSaveAndPublishHandler);
prntpage = (UmbracoEnsuredPage)Page;
foreach (ContentType.TabI t in _content.ContentType.getVirtualTabs)
{
TabPage tp = NewTabPage(t.Caption);
addSaveAndPublishButtons(ref tp);
tp.Style.Add("text-align", "center");
// Iterate through the property types and add them to the tab
foreach (PropertyType pt in t.PropertyTypes)
{
// table.Rows.Add(addControl(_content.getProperty(editPropertyType.Alias), tp));
addControlNew(_content.getProperty(pt), tp, t.Caption);
inTab.Add(pt.Id.ToString(), true);
}
}
// Add property pane
tpProp = NewTabPage(ui.Text("general", "properties", null));
addSaveAndPublishButtons(ref tpProp);
tpProp.Controls.Add(
new LiteralControl("<div id=\"errorPane_" + tpProp.ClientID +
"\" style=\"display: none; text-align: left; color: red;width: 100%; border: 1px solid red; background-color: #FCDEDE\"><div><b>There were errors - data has not been saved!</b><br/></div></div>"));
}
/// <summary>
/// Create and setup all of the controls child controls.
/// </summary>
protected override void CreateChildControls()
{
base.CreateChildControls();
SaveAndPublish += new EventHandler(standardSaveAndPublishHandler);
Save += new EventHandler(standardSaveAndPublishHandler);
prntpage = (UmbracoEnsuredPage)Page;
foreach (ContentType.TabI t in _content.ContentType.getVirtualTabs)
{
TabPage tp = NewTabPage(t.Caption);
addSaveAndPublishButtons(ref tp);
tp.Style.Add("text-align", "center");
// Iterate through the property types and add them to the tab
foreach (PropertyType pt in t.PropertyTypes)
{
// table.Rows.Add(addControl(_content.getProperty(editPropertyType.Alias), tp));
addControlNew(_content.getProperty(pt), tp, t.Caption);
inTab.Add(pt.Id.ToString(), true);
}
}
// Add property pane
tpProp = NewTabPage(ui.Text("general", "properties", null));
addSaveAndPublishButtons(ref tpProp);
tpProp.Controls.Add(
new LiteralControl("<div id=\"errorPane_" + tpProp.ClientID +
"\" style=\"display: none; text-align: left; color: red;width: 100%; border: 1px solid red; background-color: #FCDEDE\"><div><b>There were errors - data has not been saved!</b><br/></div></div>"));
}
/// <summary>
/// Initializes the control and ensures child controls are setup
/// </summary>
/// <param name="e"></param>
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
EnsureChildControls();
// Add extras for the property tabpage. .
ContentControlLoadEventArgs contentcontrolEvent = new ContentControlLoadEventArgs();
FireBeforeContentControlLoad(contentcontrolEvent);

View File

@@ -25,14 +25,7 @@
jQuery("#pageNameHolder").attr("class","success");
}
function updateTree(current, oldParent, newParent, newParentPath, copy) {
if (!copy) {
UmbClientMgr.mainTree().moveNode(current, newParentPath);
} else {
UmbClientMgr.mainTree().copyNode(current, newParentPath);
}
}
function doSubmit() {document.Form1["ok"].click()}

View File

@@ -252,7 +252,7 @@ namespace umbraco.dialogs
feedback.type = umbraco.uicontrols.Feedback.feedbacktype.success;
// refresh tree
ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "treeRefresh", String.Format("updateTree({0}, {1}, {2}, '{3}', false);", currentNode.Id, oldParent, newNode.Id, newNode.Path), true);
ClientTools.MoveNode(currentNode.Id.ToString(), newNode.Path);
}
else
@@ -261,7 +261,7 @@ namespace umbraco.dialogs
d.Copy(int.Parse(helper.Request("copyTo")), this.getUser(), RelateDocuments.Checked);
feedback.Text = ui.Text("moveOrCopy", "copyDone", nodes, base.getUser()) + "</p><p><a href='#' onclick='" + ClientTools.Scripts.CloseModalWindow + "'>" + ui.Text("closeThisWindow") + "</a>";
feedback.type = umbraco.uicontrols.Feedback.feedbacktype.success;
ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "treeRefresh", String.Format("updateTree({0}, {1}, {2}, '{3}', true);", currentNode.Id, oldParent, newNode.Id, newNode.Path), true);
ClientTools.CopyNode(currentNode.Id.ToString(), newNode.Path);
}
}
}

View File

@@ -116,6 +116,8 @@
jQuery(document).ready(function() {
//UmbClientMgr.setUmbracoPath("<%=umbraco.GlobalSettings.Path %>");
jQuery(window).load(function() { resizePage('load'); });
jQuery(window).wresize(function() { resizePage('resize'); });
@@ -127,9 +129,9 @@
// load dashboard
if (rightAction != '') {
jQuery("#right").attr("src", rightAction + ".aspx?id=" + rightActionId);
UmbClientMgr.contentFrame(rightAction + ".aspx?id=" + rightActionId);
} else {
jQuery("#right").attr("src", "dashboard.aspx?app=" + initApp);
UmbClientMgr.contentFrame("dashboard.aspx?app=" + initApp);
}
if (initApp != '') {

View File

@@ -18,7 +18,7 @@ Umbraco.Application.Actions = function() {
_utils: Umbraco.Utils, //alias to Umbraco Utils
_dialogWindow: null,
/// <field name="_dialogWindow">A reference to a dialog window to open, any action that doesn't open in an overlay, opens in a dialog</field>
_isDebug: true, //set to true to enable alert debugging
_isDebug: false, //set to true to enable alert debugging
_windowTitle: " - Umbraco CMS - ",
_currApp: "",
@@ -98,8 +98,8 @@ Umbraco.Application.Actions = function() {
if (!ignoreDashboard) {
UmbClientMgr.contentFrame('dashboard.aspx?app=' + whichApp);
}
UmbClientMgr.mainTree().rebuildTree(whichApp);
jQuery("#treeWindowLabel").html(appName);
@@ -126,7 +126,7 @@ Umbraco.Application.Actions = function() {
},
openDashboard: function(whichApp) {
UmbClientMgr.contentFrame().location.href = 'dashboard.aspx?app=' + whichApp;
UmbClientMgr.contentFrame('dashboard.aspx?app=' + whichApp);
},
actionSort: function() {

View File

@@ -11,10 +11,20 @@ Umbraco.Sys.registerNamespace("Umbraco.Application");
/// A class which ensures that all calls made to the objects that it owns are done in the context
/// of the main Umbraco application window.
/// </summary>
return {
_debug: true,
_debug: false,
_mainTree: null,
_rootPath: "/umbraco", //this is the default
setUmbracoPath: function(strPath) {
/// <summary>
/// sets the Umbraco root path folder
/// </summary>
_rootPath = strPath;
},
mainWindow: function() {
/// <summary>
@@ -28,9 +38,9 @@ Umbraco.Sys.registerNamespace("Umbraco.Application");
/// Sometimes an Umbraco page will need to be opened without being contained in the iFrame from the main window
/// so this method is will construct a false tree to be returned if this is the case as to avoid errors.
/// </summary>
if (this._mainTree == null) {
if (this.mainWindow().jQuery(".umbTree").UmbracoTreeAPI() == null) {
if (this.mainWindow().jQuery(".umbTree").UmbracoTreeAPI() == null) {
this._mainTree = $("<div id='falseTree' />").appendTo("body").hide().UmbracoTree({
uiKeys: this.uiKeys(),
jsonFullMenu: {},
@@ -79,6 +89,18 @@ Umbraco.Sys.registerNamespace("Umbraco.Application");
return this.mainWindow().right;
}
else {
//if the path doesn't start with "/" or with the root path then
//prepend the root path
if (strLocation.substr(0, 1) != "/") {
strLocation = this._rootPath + "/" + strLocation;
}
else if (strLocation.length >= this._rootPath.length
&& strLocation.substr(0, this._rootPath.length) != this._rootPath) {
strLocation = this._rootPath + "/" + strLocation;
}
this._debug("contentFrame: parsed location: " + strLocation);
this.mainWindow().right.location.href = strLocation;
}
},

View File

@@ -17,7 +17,7 @@ Umbraco.Controls.NodeDefinition = function() {
sourceUrl: null,
menu: null,
treeType: null,
_isDebug: true,
_isDebug: false,
updateDefinition: function(jsTree, jsNode, nodeId, nodeName, nodeType, sourceUrl, menu, treeType) {
/// <summary>

View File

@@ -53,7 +53,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
_app: null, //the reference to the current app
_showContext: true,
_isDialog: false,
_isDebug: true, //set to true to enable alert debugging
_isDebug: false, //set to true to enable alert debugging
_loadedApps: [], //stores the application names that have been loaded to track which JavaScript code has been inserted into the DOM
_serviceUrl: "", //a path to the tree client service url
_dataUrl: "", //a path to the tree data service url

View File

@@ -1,6 +1,6 @@
Umbraco.Sys.registerNamespace("Umbraco.Controls"); (function($) {
$.fn.UmbracoTree = function(opts) { return this.each(function() { var conf = $.extend({ jsonFullMenu: null, jsonInitNode: null, appActions: null, uiKeys: null, app: "", showContext: true, isDialog: false, treeType: "standard", umb_clientFolderRoot: "/umbraco_client" }, opts); new Umbraco.Controls.UmbracoTree().init($(this), conf); }); }; $.fn.UmbracoTreeAPI = function() { return $(this).data("UmbracoTree") == null ? null : $(this).data("UmbracoTree"); }; Umbraco.Controls.UmbracoTree = function() {
return { _actionNode: new Umbraco.Controls.NodeDefinition(), _activeTreeType: "content", _recycleBinId: -20, _umb_clientFolderRoot: "/umbraco_client", _fullMenu: null, _initNode: null, _menuActions: null, _tree: null, _uiKeys: null, _container: null, _app: null, _showContext: true, _isDialog: false, _isDebug: true, _loadedApps: [], _serviceUrl: "", _dataUrl: "", _treeType: "standard", _treeClass: "umbTree", _currenAJAXRequest: false, addEventHandler: function(fnName, fn) { $(this).bind(fnName, fn); }, removeEventHandler: function(fnName, fn) { $(this).unbind(fnName, fn); }, init: function(jItem, opts) { this._init(opts.jsonFullMenu, opts.jsonInitNode, jItem, opts.appActions, opts.uiKeys, opts.app, opts.showContext, opts.isDialog, opts.treeType, opts.serviceUrl, opts.dataUrl, opts.umb_clientFolderRoot); jItem.addClass(this._treeClass); jItem.data("UmbracoTree", this); }, rebuildTree: function(app) {
return { _actionNode: new Umbraco.Controls.NodeDefinition(), _activeTreeType: "content", _recycleBinId: -20, _umb_clientFolderRoot: "/umbraco_client", _fullMenu: null, _initNode: null, _menuActions: null, _tree: null, _uiKeys: null, _container: null, _app: null, _showContext: true, _isDialog: false, _isDebug: false, _loadedApps: [], _serviceUrl: "", _dataUrl: "", _treeType: "standard", _treeClass: "umbTree", _currenAJAXRequest: false, addEventHandler: function(fnName, fn) { $(this).bind(fnName, fn); }, removeEventHandler: function(fnName, fn) { $(this).unbind(fnName, fn); }, init: function(jItem, opts) { this._init(opts.jsonFullMenu, opts.jsonInitNode, jItem, opts.appActions, opts.uiKeys, opts.app, opts.showContext, opts.isDialog, opts.treeType, opts.serviceUrl, opts.dataUrl, opts.umb_clientFolderRoot); jItem.addClass(this._treeClass); jItem.data("UmbracoTree", this); }, rebuildTree: function(app) {
this._debug("rebuildTree"); if (this._app == null || (this._app.toLowerCase() == app.toLowerCase())) { this._debug("not rebuilding"); return; }
else { this._app = app; }
$("div").remove(".tree-default-context"); this._tree.destroy(); this._container.hide(); var _this = this; var saveData = this._container.data("tree_" + app); if (saveData != null) {