diff --git a/UpgradeReadme.txt b/UpgradeReadme.txt index a8688ceb4c..a24a1c7be8 100644 --- a/UpgradeReadme.txt +++ b/UpgradeReadme.txt @@ -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 \ No newline at end of file +to use the UmbracoClientPath setting + +* removed CheckBoxTree.cs [permanently!, not in legacy package] +* removed windowCloser.cs \ No newline at end of file diff --git a/components/editorControls/mediapicker/mediaChooser.cs b/components/editorControls/mediapicker/mediaChooser.cs index 955be9b247..8b12c4e4fc 100644 --- a/components/editorControls/mediapicker/mediaChooser.cs +++ b/components/editorControls/mediapicker/mediaChooser.cs @@ -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 description for mediaChooser. /// - [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); diff --git a/components/editorControls/pagepicker/pagePicker.cs b/components/editorControls/pagepicker/pagePicker.cs index a3a59f5722..d0e6bbe5ac 100644 --- a/components/editorControls/pagepicker/pagePicker.cs +++ b/components/editorControls/pagepicker/pagePicker.cs @@ -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 description for pagePicker. /// - [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); diff --git a/components/editorControls/ultraSimpleMailer/mailerConfiguratorPreValueEditor.cs b/components/editorControls/ultraSimpleMailer/__TODELETE__mailerConfiguratorPreValueEditor.cs similarity index 100% rename from components/editorControls/ultraSimpleMailer/mailerConfiguratorPreValueEditor.cs rename to components/editorControls/ultraSimpleMailer/__TODELETE__mailerConfiguratorPreValueEditor.cs diff --git a/components/editorControls/ultraSimpleMailer/mailerHelper.cs b/components/editorControls/ultraSimpleMailer/__TODELETE__mailerHelper.cs similarity index 100% rename from components/editorControls/ultraSimpleMailer/mailerHelper.cs rename to components/editorControls/ultraSimpleMailer/__TODELETE__mailerHelper.cs diff --git a/components/editorControls/ultraSimpleMailer/mailerLogic.cs b/components/editorControls/ultraSimpleMailer/__TODELETE__mailerLogic.cs similarity index 100% rename from components/editorControls/ultraSimpleMailer/mailerLogic.cs rename to components/editorControls/ultraSimpleMailer/__TODELETE__mailerLogic.cs diff --git a/components/editorControls/ultraSimpleMailer/ultraSimpleMailerDataType.cs b/components/editorControls/ultraSimpleMailer/__TODELETE__ultraSimpleMailerDataType.cs similarity index 100% rename from components/editorControls/ultraSimpleMailer/ultraSimpleMailerDataType.cs rename to components/editorControls/ultraSimpleMailer/__TODELETE__ultraSimpleMailerDataType.cs diff --git a/components/editorControls/ultraSimpleMailer/ultraSimpleMailerEditor.cs b/components/editorControls/ultraSimpleMailer/__TODELETE__ultraSimpleMailerEditor.cs similarity index 84% rename from components/editorControls/ultraSimpleMailer/ultraSimpleMailerEditor.cs rename to components/editorControls/ultraSimpleMailer/__TODELETE__ultraSimpleMailerEditor.cs index a04672304c..bccec816ec 100644 --- a/components/editorControls/ultraSimpleMailer/ultraSimpleMailerEditor.cs +++ b/components/editorControls/ultraSimpleMailer/__TODELETE__ultraSimpleMailerEditor.cs @@ -5,19 +5,24 @@ using umbraco.editorControls.wysiwyg; using umbraco.uicontrols; using System.Web.UI; + namespace umbraco.editorControls.ultraSimpleMailer { + /// /// Summary description for ultraSimpleMailerEditor. /// + + + 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", ""); Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "progressBarCss", ""); - // 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(""); if (umbraco.helper.Request(this.ClientID + "_doTest") == "" && umbraco.helper.Request(this.ClientID + "_doSend") == "") - base.Render (writer); - else + base.Render(writer); + else { writer.WriteLine("
"); - 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("

Send newsletter to test...


"); 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: " + umbraco.helper.Request(this.ClientID + "_test_rcp") + "
"); - } - else + } + else { writer.WriteLine("

Send newsletter to all...


"); mailerLogic.SendMail(mg, new cms.businesslogic.property.Property(_data.PropertyId), config[9], config[10], true); writer.WriteLine("Sent...
"); - } - } - else + } + } + else { - if (umbraco.helper.Request(this.ClientID + "_doTest") != "") + if (umbraco.helper.Request(this.ClientID + "_doTest") != "") { writer.WriteLine("

Send newsletter to test...


"); writer.WriteLine("Send test to: "); writer.WriteLine(""); } - 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("


\"Sending
\n" + - " Sending mails...\n" + - "
\n" + + + writer.WriteLine("


\"Sending
\n" + + " Sending mails...\n" + + "
\n" + "
\n"); @@ -104,7 +109,7 @@ namespace umbraco.editorControls.ultraSimpleMailer pb.ID = "ultraSimpleMailerUpgradeStatus"; pb.Width = 200; pb.RenderControl(writer); - writer.WriteLine("


\n" + + writer.WriteLine("


\n" + "
"); writer.WriteLine("

Send newsletter to all...


"); writer.WriteLine("Please confirm that you want to send this message to " + mailerLogic.GetTotalReceiptients(mg).ToString() + " recipients
"); @@ -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 - + Code - + Code - + Code - + Code - + Code diff --git a/config templates/web.config b/config templates/web.config index e09c4095d9..b286b3470b 100644 --- a/config templates/web.config +++ b/config templates/web.config @@ -32,6 +32,7 @@ + diff --git a/umbraco/businesslogic/BasePages/ClientTools.cs b/umbraco/businesslogic/BasePages/ClientTools.cs index 50a42e3b59..83faa5e584 100644 --- a/umbraco/businesslogic/BasePages/ClientTools.cs +++ b/umbraco/businesslogic/BasePages/ClientTools.cs @@ -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; } + + /// + /// Shows the dashboard for the given application + /// + /// + /// + public ClientTools ShowDashboard(string app) + { + return ChangeContentFrameUrl(GlobalSettings.Path + string.Format("/dashboard.aspx?app={0}", app)); + } /// /// 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; + } /// /// Reloads only the active node in the tree. diff --git a/umbraco/cms/businesslogic/datatype/ClientDependencyAttribute.cs b/umbraco/cms/businesslogic/datatype/ClientDependencyAttribute.cs index d9973b08ce..3436b45388 100644 --- a/umbraco/cms/businesslogic/datatype/ClientDependencyAttribute.cs +++ b/umbraco/cms/businesslogic/datatype/ClientDependencyAttribute.cs @@ -4,95 +4,95 @@ using System.Text; namespace umbraco.cms.businesslogic.datatype { - /// - /// 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 - /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] - public class ClientDependencyAttribute : Attribute - { - /// - /// Gets or sets the priority. - /// - /// The priority. - public int Priority { get; set; } + ///// + ///// 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 + ///// + //[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] + //public class ClientDependencyAttribute : Attribute + //{ + // /// + // /// Gets or sets the priority. + // /// + // /// The priority. + // public int Priority { get; set; } - /// - /// Gets or sets the file path. - /// - /// The file path. - public string FilePath { get; set; } + // /// + // /// Gets or sets the file path. + // /// + // /// The file path. + // public string FilePath { get; set; } - /// - /// Gets or sets the type of the dependency. - /// - /// The type of the dependency. - public ClientDependencyType DependencyType { get; set; } + // /// + // /// Gets or sets the type of the dependency. + // /// + // /// The type of the dependency. + // public ClientDependencyType DependencyType { get; set; } - /// - /// Gets or sets the name of an optional javascript method that should be called on load. - /// - /// The name of the method. - public string InvokeJavascriptMethodOnLoad { get; set; } + // /// + // /// Gets or sets the name of an optional javascript method that should be called on load. + // /// + // /// The name of the method. + // public string InvokeJavascriptMethodOnLoad { get; set; } - /// - /// Initializes a new instance of the class. - /// - /// The priority. - /// Type of the dependency. - /// The file path to the dependency. - public ClientDependencyAttribute(int priority, ClientDependencyType dependencyType, string filePath) - : this(priority, dependencyType, filePath, false, string.Empty) - { } + // /// + // /// Initializes a new instance of the class. + // /// + // /// The priority. + // /// Type of the dependency. + // /// The file path to the dependency. + // public ClientDependencyAttribute(int priority, ClientDependencyType dependencyType, string filePath) + // : this(priority, dependencyType, filePath, false, string.Empty) + // { } - /// - /// Initializes a new instance of the class. - /// - /// The priority. - /// Type of the dependency. - /// The file path to the dependency. - /// The name of the Javascript method to invoke when the dependency is loaded. - public ClientDependencyAttribute(int priority, ClientDependencyType dependencyType, string filePath, string invokeJavascriptMethodOnLoad) - : this(priority, dependencyType, filePath, false, invokeJavascriptMethodOnLoad) - { } + // /// + // /// Initializes a new instance of the class. + // /// + // /// The priority. + // /// Type of the dependency. + // /// The file path to the dependency. + // /// The name of the Javascript method to invoke when the dependency is loaded. + // public ClientDependencyAttribute(int priority, ClientDependencyType dependencyType, string filePath, string invokeJavascriptMethodOnLoad) + // : this(priority, dependencyType, filePath, false, invokeJavascriptMethodOnLoad) + // { } - /// - /// Initializes a new instance of the class. - /// - /// The priority. - /// Type of the dependency. - /// The file path to the dependency. - /// if set to true the current umbraco path will be prefixed to the filePath. - public ClientDependencyAttribute(int priority, ClientDependencyType dependencyType, string filePath, bool appendUmbracoPath) - : this(priority, dependencyType, filePath, appendUmbracoPath, String.Empty) - { } + // /// + // /// Initializes a new instance of the class. + // /// + // /// The priority. + // /// Type of the dependency. + // /// The file path to the dependency. + // /// if set to true the current umbraco path will be prefixed to the filePath. + // public ClientDependencyAttribute(int priority, ClientDependencyType dependencyType, string filePath, bool appendUmbracoPath) + // : this(priority, dependencyType, filePath, appendUmbracoPath, String.Empty) + // { } - /// - /// Initializes a new instance of the class. - /// - /// The priority. - /// Type of the dependency. - /// The file path to the dependency. - /// if set to true the current umbraco path will be prefixed to the filePath. - /// The name of the Javascript method to invoke when the dependency is loaded. - public ClientDependencyAttribute(int priority, ClientDependencyType dependencyType, string filePath, bool appendUmbracoPath, string invokeJavascriptMethodOnLoad) - { - if (String.IsNullOrEmpty(filePath)) - throw new ArgumentException("filePath"); + // /// + // /// Initializes a new instance of the class. + // /// + // /// The priority. + // /// Type of the dependency. + // /// The file path to the dependency. + // /// if set to true the current umbraco path will be prefixed to the filePath. + // /// The name of the Javascript method to invoke when the dependency is loaded. + // 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; + // } + //} - /// - /// The type of client file - /// - public enum ClientDependencyType - { - Javascript, Css - } + ///// + ///// The type of client file + ///// + //public enum ClientDependencyType + //{ + // Javascript, Css + //} } diff --git a/umbraco/cms/businesslogic/datatype/ClientDependencyHelper.cs b/umbraco/cms/businesslogic/datatype/ClientDependencyHelper.cs index 053bdd801b..9d0a94ebec 100644 --- a/umbraco/cms/businesslogic/datatype/ClientDependencyHelper.cs +++ b/umbraco/cms/businesslogic/datatype/ClientDependencyHelper.cs @@ -6,66 +6,66 @@ using System.Web; namespace umbraco.cms.businesslogic.datatype { - public class ClientDependencyHelper - { - /// Path to the dependency loader we need for adding control dependencies. - protected const string DependencyLoaderScriptFile = "{0}/js/UmbracoDependencyLoader.js"; + //public class ClientDependencyHelper + //{ + // /// Path to the dependency loader we need for adding control dependencies. + // protected const string DependencyLoaderScriptFile = "{0}/js/UmbracoDependencyLoader.js"; - /// - /// Adds the client dependencies to the passed page's client script manager. - /// - public static void AddClientDependencies(Control control) { - Type controlType = control.GetType(); + // /// + // /// Adds the client dependencies to the passed page's client script manager. + // /// + // public static void AddClientDependencies(Control control) { + // Type controlType = control.GetType(); - // find dependencies - List dependencies = new List(); - 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 dependencies = new List(); + // 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); + // } + // } + //} } diff --git a/umbraco/presentation.ClientDependency/BasicClientDependencyFile.cs b/umbraco/presentation.ClientDependency/BasicClientDependencyFile.cs new file mode 100644 index 0000000000..c20f87f597 --- /dev/null +++ b/umbraco/presentation.ClientDependency/BasicClientDependencyFile.cs @@ -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 + } +} diff --git a/umbraco/presentation.ClientDependency/BasicClientDependencyPath.cs b/umbraco/presentation.ClientDependency/BasicClientDependencyPath.cs new file mode 100644 index 0000000000..b52ef331ed --- /dev/null +++ b/umbraco/presentation.ClientDependency/BasicClientDependencyPath.cs @@ -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); + } + } + } +} diff --git a/umbraco/presentation.ClientDependency/ClientDependencyCollection.cs b/umbraco/presentation.ClientDependency/ClientDependencyCollection.cs new file mode 100644 index 0000000000..c4b1187483 --- /dev/null +++ b/umbraco/presentation.ClientDependency/ClientDependencyCollection.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace umbraco.presentation.ClientDependency +{ + + /// + /// Wraps a HashSet object for the client dependency file type and declares a equality operator + /// + public class ClientDependencyCollection : HashSet + { + + public ClientDependencyCollection() : base(new ClientDependencyComparer()) { } + + internal class ClientDependencyComparer : IEqualityComparer + { + #region IEqualityComparer Members + + /// + /// If the lowercased combination of the file path, dependency type and path name aliases are the same, + /// then they are the same dependency. + /// + /// + /// + /// + 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 + } + + } + + +} diff --git a/umbraco/presentation.ClientDependency/Controls/ClientDependencyLoader.cs b/umbraco/presentation.ClientDependency/Controls/ClientDependencyLoader.cs index 26665d558f..588b045a1c 100644 --- a/umbraco/presentation.ClientDependency/Controls/ClientDependencyLoader.cs +++ b/umbraco/presentation.ClientDependency/Controls/ClientDependencyLoader.cs @@ -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) + /// + /// Singleton per request instance. + /// + /// + /// If no ClientDependencyLoader control exists on the current page, an exception is thrown. + /// + 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; + } } /// - /// Dynamically registers a dependency into the loader at runtime. - /// This is similar to ScriptManager.RegisterClientScriptInclude + /// Tracks all dependencies and maintains a deduplicated list /// - /// - 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 m_Dependencies = new List(); + /// + /// Tracks all paths and maintains a deduplicated list + /// + private HashSet m_Paths = new HashSet(); /// /// 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()); + 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 m_Dependencies = new List(); + + #region Static Helper methods + + /// + /// 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. + /// + /// + /// + /// + 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 + + /// + /// Registers a file dependency with the default provider. + /// + /// + /// + public ClientDependencyLoader RegisterDependency(string filePath, ClientDependencyType type) + { + RegisterDependency(filePath, "", type); + return this; + } + /// + /// Registers a file dependency with the default provider. + /// + /// + /// + /// + public ClientDependencyLoader RegisterDependency(string filePath, string pathNameAlias, ClientDependencyType type) + { + ClientDependencyLoader.Instance.RegisterDependency(ClientDependencyInclude.DefaultPriority, false, filePath, pathNameAlias, type, ""); + return this; + } + + /// + /// Adds a path to the current loader + /// + /// + /// + public ClientDependencyLoader AddPath(string pathNameAlias, string path) + { + AddPath(new BasicClientDependencyPath() { Name = pathNameAlias, Path = path }); + return this; + } + + /// + /// Adds a path to the current loader + /// + /// + /// + public void AddPath(IClientDependencyPath path) + { + m_Paths.Add(path); + } + + /// + /// Dynamically registers a dependency into the loader at runtime. + /// This is similar to ScriptManager.RegisterClientScriptInclude. + /// Registers a file dependency with the default provider. + /// + /// + 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()); //send an empty paths collection + } + + /// + /// Registers dependencies with the specified provider. + /// + /// + /// + /// + /// + /// This is the top most overloaded method + /// + public void RegisterClientDependencies(ClientDependencyProvider provider, ClientDependencyCollection dependencies, IEnumerable 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 paths) + { + RegisterClientDependencies(ClientDependencySettings.Instance.DefaultProvider, dependencies, paths); + } + + /// + /// Registers dependencies with the default provider + /// + /// + /// + public void RegisterClientDependencies(Control control, ClientDependencyPathCollection paths) + { + RegisterClientDependencies(ClientDependencySettings.Instance.DefaultProvider, control, paths.Cast()); + } + + /// + /// Registers dependencies with the provider name specified + /// + /// + /// + /// + public void RegisterClientDependencies(string providerName, Control control, IEnumerable paths) + { + RegisterClientDependencies(ClientDependencySettings.Instance.ProviderCollection[providerName], control, paths); + } + + /// + /// Registers dependencies with the provider specified by T + /// + public void RegisterClientDependencies(Control control, List 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 paths) + { + ClientDependencyCollection dependencies = FindDependencies(control); + RegisterClientDependencies(provider, dependencies, paths); + } + + /// + /// Recursively find all dependencies of this control and it's entire child control heirarchy. + /// + /// + /// + 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; + } + } diff --git a/umbraco/presentation.ClientDependency/Controls/ClientDependencyPath.cs b/umbraco/presentation.ClientDependency/Controls/ClientDependencyPath.cs index 0c75cac3d0..b2beea61e1 100644 --- a/umbraco/presentation.ClientDependency/Controls/ClientDependencyPath.cs +++ b/umbraco/presentation.ClientDependency/Controls/ClientDependencyPath.cs @@ -12,7 +12,7 @@ namespace umbraco.presentation.ClientDependency.Controls /// Databinding support has been enabled. /// [ParseChildren(true)] - public class ClientDependencyPath + public class ClientDependencyPath : IClientDependencyPath { string _name = ""; string _path = ""; diff --git a/umbraco/presentation.ClientDependency/IClientDependencyPath.cs b/umbraco/presentation.ClientDependency/IClientDependencyPath.cs new file mode 100644 index 0000000000..e6e40ca945 --- /dev/null +++ b/umbraco/presentation.ClientDependency/IClientDependencyPath.cs @@ -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; } + } +} diff --git a/umbraco/presentation.ClientDependency/ProviderDependencyList.cs b/umbraco/presentation.ClientDependency/ProviderDependencyList.cs new file mode 100644 index 0000000000..d31ddad974 --- /dev/null +++ b/umbraco/presentation.ClientDependency/ProviderDependencyList.cs @@ -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; } + } +} diff --git a/umbraco/presentation.ClientDependency/Providers/ClientDependencyProvider.cs b/umbraco/presentation.ClientDependency/Providers/ClientDependencyProvider.cs index 7dcb3faaf8..f4af093a1f 100644 --- a/umbraco/presentation.ClientDependency/Providers/ClientDependencyProvider.cs +++ b/umbraco/presentation.ClientDependency/Providers/ClientDependencyProvider.cs @@ -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 FolderPaths { get; private set; } protected List AllDependencies { get; private set; } /// @@ -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 paths) { DependantControl = dependantControl; AllDependencies = new List(dependencies); @@ -46,19 +46,13 @@ namespace umbraco.presentation.ClientDependency.Providers UpdateFilePaths(); - //seperate the types into 2 lists for all dependencies without composite groups - List jsDependencies = AllDependencies.FindAll( - delegate(IClientDependencyFile a) - { - return a.DependencyType == ClientDependencyType.Javascript; - } - ); - List cssDependencies = AllDependencies.FindAll( - delegate(IClientDependencyFile a) - { - return a.DependencyType == ClientDependencyType.Css; - } - ); + List jsDependencies = AllDependencies + .Where(x => x.DependencyType == ClientDependencyType.Javascript) + .ToList(); + + List 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 /// protected virtual void RegisterStartupScripts(List 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); + //} } /// @@ -149,8 +143,9 @@ namespace umbraco.presentation.ClientDependency.Providers { if (!string.IsNullOrEmpty(dependency.PathNameAlias)) { - ClientDependencyPath path = FolderPaths.Find( - delegate(ClientDependencyPath p) + List paths = FolderPaths.ToList(); + IClientDependencyPath path = paths.Find( + delegate(IClientDependencyPath p) { return p.Name == dependency.PathNameAlias; } diff --git a/umbraco/presentation.ClientDependency/UmbracoDependencyLoader.js b/umbraco/presentation.ClientDependency/UmbracoDependencyLoader.js index bb4c224776..319aced209 100644 --- a/umbraco/presentation.ClientDependency/UmbracoDependencyLoader.js +++ b/umbraco/presentation.ClientDependency/UmbracoDependencyLoader.js @@ -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() { diff --git a/umbraco/presentation.ClientDependency/umbraco.presentation.ClientDependency.csproj b/umbraco/presentation.ClientDependency/umbraco.presentation.ClientDependency.csproj index 6f00a71ea6..e2dbe51025 100644 --- a/umbraco/presentation.ClientDependency/umbraco.presentation.ClientDependency.csproj +++ b/umbraco/presentation.ClientDependency/umbraco.presentation.ClientDependency.csproj @@ -51,8 +51,10 @@ + + - + @@ -62,11 +64,12 @@ + + - diff --git a/umbraco/presentation/umbraco.presentation.csproj b/umbraco/presentation/umbraco.presentation.csproj index c5371b8b1b..0106772e84 100644 --- a/umbraco/presentation/umbraco.presentation.csproj +++ b/umbraco/presentation/umbraco.presentation.csproj @@ -468,7 +468,7 @@ TreeControl.ascx - + Code diff --git a/umbraco/presentation/umbraco/LiveEditing/Controls/Communicator.cs b/umbraco/presentation/umbraco/LiveEditing/Controls/Communicator.cs index b9f4138db6..b952be14db 100644 --- a/umbraco/presentation/umbraco/LiveEditing/Controls/Communicator.cs +++ b/umbraco/presentation/umbraco/LiveEditing/Controls/Communicator.cs @@ -1,12 +1,14 @@ using System; using System.Web.UI; using System.Web.UI.WebControls; +using umbraco.presentation.ClientDependency; namespace umbraco.presentation.LiveEditing.Controls { /// /// Control that can receive messages from the client. /// + [ClientDependency(100, ClientDependencyType.Javascript, "LiveEditing/Controls/Communicator.js", "UmbracoRoot")] public class Communicator : Control { /// @@ -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)); } /// diff --git a/umbraco/presentation/umbraco/LiveEditing/Controls/LiveEditingManager.cs b/umbraco/presentation/umbraco/LiveEditing/Controls/LiveEditingManager.cs index 8b92d08780..067bebad14 100644 --- a/umbraco/presentation/umbraco/LiveEditing/Controls/LiveEditingManager.cs +++ b/umbraco/presentation/umbraco/LiveEditing/Controls/LiveEditingManager.cs @@ -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. /// - [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); + } /// /// 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 /// Unescaped title text. /// Unescaped message text. /// The icon. + [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 diff --git a/umbraco/presentation/umbraco/LiveEditing/Controls/LiveEditingToolbar.cs b/umbraco/presentation/umbraco/LiveEditing/Controls/LiveEditingToolbar.cs index fef20a9349..4b5407ff5a 100644 --- a/umbraco/presentation/umbraco/LiveEditing/Controls/LiveEditingToolbar.cs +++ b/umbraco/presentation/umbraco/LiveEditing/Controls/LiveEditingToolbar.cs @@ -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 { /// /// The default toolbar used for Live Editing. /// - [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 diff --git a/umbraco/presentation/umbraco/LiveEditing/Modules/CreateModule/CreateModule.cs b/umbraco/presentation/umbraco/LiveEditing/Modules/CreateModule/CreateModule.cs index cf424d9fbf..49bef0a383 100644 --- a/umbraco/presentation/umbraco/LiveEditing/Modules/CreateModule/CreateModule.cs +++ b/umbraco/presentation/umbraco/LiveEditing/Modules/CreateModule/CreateModule.cs @@ -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("
")); - ScriptManager.RegisterClientScriptInclude(this, GetType(), CreateModuleScriptFile, String.Format(CreateModuleScriptFile, GlobalSettings.Path)); + //ScriptManager.RegisterClientScriptInclude(this, GetType(), CreateModuleScriptFile, String.Format(CreateModuleScriptFile, GlobalSettings.Path)); } private void FillAllowedDoctypes() diff --git a/umbraco/presentation/umbraco/LiveEditing/Modules/DeleteModule/DeleteModule.cs b/umbraco/presentation/umbraco/LiveEditing/Modules/DeleteModule/DeleteModule.cs index 92c88986ef..2e5eb644c7 100644 --- a/umbraco/presentation/umbraco/LiveEditing/Modules/DeleteModule/DeleteModule.cs +++ b/umbraco/presentation/umbraco/LiveEditing/Modules/DeleteModule/DeleteModule.cs @@ -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("
")); - ScriptManager.RegisterClientScriptInclude(this, GetType(), DeleteModuleScriptFile, String.Format(DeleteModuleScriptFile, GlobalSettings.Path)); + //ScriptManager.RegisterClientScriptInclude(this, GetType(), DeleteModuleScriptFile, String.Format(DeleteModuleScriptFile, GlobalSettings.Path)); } diff --git a/umbraco/presentation/umbraco/LiveEditing/Modules/ItemEditing/ItemEditor.cs b/umbraco/presentation/umbraco/LiveEditing/Modules/ItemEditing/ItemEditor.cs index c5a01e4d4d..d0504cc6c3 100644 --- a/umbraco/presentation/umbraco/LiveEditing/Modules/ItemEditing/ItemEditor.cs +++ b/umbraco/presentation/umbraco/LiveEditing/Modules/ItemEditing/ItemEditor.cs @@ -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 { /// /// Control that wraps the editor control to edit a field in Live Editing mode. /// - [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(); } /// @@ -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; } /// @@ -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(Page.Master)) item.Renderer = LiveEditingItemRenderer.Instance; - - m_Manager.MessageReceived += Manager_MessageReceived; - m_Manager.LiveEditingContext.Updates.UpdateAdded += Updates_UpdateAdded; - } - - /// - /// Raises the event. - /// - /// The instance containing the event data. - 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); diff --git a/umbraco/presentation/umbraco/LiveEditing/Modules/MacroModule/MacroModule.cs b/umbraco/presentation/umbraco/LiveEditing/Modules/MacroModule/MacroModule.cs index a0c8eb8e0f..f0fa426e63 100644 --- a/umbraco/presentation/umbraco/LiveEditing/Modules/MacroModule/MacroModule.cs +++ b/umbraco/presentation/umbraco/LiveEditing/Modules/MacroModule/MacroModule.cs @@ -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("")); - ScriptManager.RegisterClientScriptInclude(this, GetType(), MacroModuleScriptFile, String.Format(MacroModuleScriptFile, GlobalSettings.Path)); + //ScriptManager.RegisterClientScriptInclude(this, GetType(), MacroModuleScriptFile, String.Format(MacroModuleScriptFile, GlobalSettings.Path)); } diff --git a/umbraco/presentation/umbraco/LiveEditing/Modules/UnpublishModule/UnpublishModule.cs b/umbraco/presentation/umbraco/LiveEditing/Modules/UnpublishModule/UnpublishModule.cs index 820cd356a4..df653cb09d 100644 --- a/umbraco/presentation/umbraco/LiveEditing/Modules/UnpublishModule/UnpublishModule.cs +++ b/umbraco/presentation/umbraco/LiveEditing/Modules/UnpublishModule/UnpublishModule.cs @@ -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("")); - ScriptManager.RegisterClientScriptInclude(this, GetType(), UnpublishModuleScriptFile, String.Format(UnpublishModuleScriptFile, GlobalSettings.Path)); + //ScriptManager.RegisterClientScriptInclude(this, GetType(), UnpublishModuleScriptFile, String.Format(UnpublishModuleScriptFile, GlobalSettings.Path)); } diff --git a/umbraco/presentation/umbraco/controls/ContentControl.cs b/umbraco/presentation/umbraco/controls/ContentControl.cs index 38ae832849..3130661648 100644 --- a/umbraco/presentation/umbraco/controls/ContentControl.cs +++ b/umbraco/presentation/umbraco/controls/ContentControl.cs @@ -56,6 +56,18 @@ namespace umbraco.controls { } + /// + /// Constructor to set default properties. + /// + /// + /// + /// + /// + /// 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. + /// 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("
There were errors - data has not been saved!
")); } + /// + /// Create and setup all of the controls child controls. + /// + 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("
There were errors - data has not been saved!
")); + } + + /// + /// Initializes the control and ensures child controls are setup + /// + /// protected override void OnInit(EventArgs e) { base.OnInit(e); + + EnsureChildControls(); + // Add extras for the property tabpage. . ContentControlLoadEventArgs contentcontrolEvent = new ContentControlLoadEventArgs(); FireBeforeContentControlLoad(contentcontrolEvent); diff --git a/umbraco/presentation/umbraco/controls/windowCloser.cs b/umbraco/presentation/umbraco/controls/__TODELETE__windowCloser.cs similarity index 100% rename from umbraco/presentation/umbraco/controls/windowCloser.cs rename to umbraco/presentation/umbraco/controls/__TODELETE__windowCloser.cs diff --git a/umbraco/presentation/umbraco/dialogs/moveOrCopy.aspx b/umbraco/presentation/umbraco/dialogs/moveOrCopy.aspx index c77f318847..3cc5b03261 100644 --- a/umbraco/presentation/umbraco/dialogs/moveOrCopy.aspx +++ b/umbraco/presentation/umbraco/dialogs/moveOrCopy.aspx @@ -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()} diff --git a/umbraco/presentation/umbraco/dialogs/moveOrCopy.aspx.cs b/umbraco/presentation/umbraco/dialogs/moveOrCopy.aspx.cs index 289e4ee69c..0ead334d8c 100644 --- a/umbraco/presentation/umbraco/dialogs/moveOrCopy.aspx.cs +++ b/umbraco/presentation/umbraco/dialogs/moveOrCopy.aspx.cs @@ -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()) + "

" + ui.Text("closeThisWindow") + ""; 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); } } } diff --git a/umbraco/presentation/umbraco/umbraco.aspx b/umbraco/presentation/umbraco/umbraco.aspx index 4cfa480b65..770459a814 100644 --- a/umbraco/presentation/umbraco/umbraco.aspx +++ b/umbraco/presentation/umbraco/umbraco.aspx @@ -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 != '') { diff --git a/umbraco/presentation/umbraco_client/Application/UmbracoApplicationActions.js b/umbraco/presentation/umbraco_client/Application/UmbracoApplicationActions.js index b0c9c9c5ba..157f68fecc 100644 --- a/umbraco/presentation/umbraco_client/Application/UmbracoApplicationActions.js +++ b/umbraco/presentation/umbraco_client/Application/UmbracoApplicationActions.js @@ -18,7 +18,7 @@ Umbraco.Application.Actions = function() { _utils: Umbraco.Utils, //alias to Umbraco Utils _dialogWindow: null, /// A reference to a dialog window to open, any action that doesn't open in an overlay, opens in a dialog - _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() { diff --git a/umbraco/presentation/umbraco_client/Application/UmbracoClientManager.js b/umbraco/presentation/umbraco_client/Application/UmbracoClientManager.js index 2254800b47..b6008ce168 100644 --- a/umbraco/presentation/umbraco_client/Application/UmbracoClientManager.js +++ b/umbraco/presentation/umbraco_client/Application/UmbracoClientManager.js @@ -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. ///

+ return { - _debug: true, + _debug: false, _mainTree: null, + _rootPath: "/umbraco", //this is the default + + + setUmbracoPath: function(strPath) { + /// + /// sets the Umbraco root path folder + /// + _rootPath = strPath; + }, mainWindow: function() { /// @@ -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. /// - + if (this._mainTree == null) { - if (this.mainWindow().jQuery(".umbTree").UmbracoTreeAPI() == null) { + if (this.mainWindow().jQuery(".umbTree").UmbracoTreeAPI() == null) { this._mainTree = $("
").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; } }, diff --git a/umbraco/presentation/umbraco_client/Tree/NodeDefinition.js b/umbraco/presentation/umbraco_client/Tree/NodeDefinition.js index 021fc4510c..a14e5b25bb 100644 --- a/umbraco/presentation/umbraco_client/Tree/NodeDefinition.js +++ b/umbraco/presentation/umbraco_client/Tree/NodeDefinition.js @@ -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) { /// diff --git a/umbraco/presentation/umbraco_client/Tree/UmbracoTree.js b/umbraco/presentation/umbraco_client/Tree/UmbracoTree.js index e1b5bdfa13..b8da612598 100644 --- a/umbraco/presentation/umbraco_client/Tree/UmbracoTree.js +++ b/umbraco/presentation/umbraco_client/Tree/UmbracoTree.js @@ -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 diff --git a/umbraco/presentation/umbraco_client/Tree/UmbracoTree.min.js b/umbraco/presentation/umbraco_client/Tree/UmbracoTree.min.js index 9b34b6b14d..a8a3df5b49 100644 --- a/umbraco/presentation/umbraco_client/Tree/UmbracoTree.min.js +++ b/umbraco/presentation/umbraco_client/Tree/UmbracoTree.min.js @@ -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) {