diff --git a/umbraco/cms/businesslogic/datatype/ClientDependencyAttribute.cs b/umbraco/cms/businesslogic/datatype/ClientDependencyAttribute.cs new file mode 100644 index 0000000000..ff0ee1d577 --- /dev/null +++ b/umbraco/cms/businesslogic/datatype/ClientDependencyAttribute.cs @@ -0,0 +1,102 @@ +using System; +using ClientDependency.Core.Controls; + +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)] + [Obsolete("Use the new ClientDependency framework. Priority and InvokeJavascriptMethodOnLoad are ignored. Documentation here: http://clientdependency.codeplex.com/documentation")] + public class ClientDependencyAttribute : Attribute + { + /// + /// Gets or sets the priority. + /// + /// The priority. + [Obsolete("This property is ignored")] + public int Priority { 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 name of an optional javascript method that should be called on load. + /// + /// The name of the method. + [Obsolete("This property is ignored")] + 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. + /// 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. + /// 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; + + ClientDependencyLoader.Instance.RegisterDependency(FilePath, DependencyType == ClientDependencyType.Css ? ClientDependency.Core.ClientDependencyType.Css : ClientDependency.Core.ClientDependencyType.Javascript); + } + } + + /// + /// The type of client file + /// + public enum ClientDependencyType + { + Javascript, Css + } +} \ No newline at end of file diff --git a/umbraco/cms/umbraco.cms.csproj b/umbraco/cms/umbraco.cms.csproj index e231546e4e..f84888fca1 100644 --- a/umbraco/cms/umbraco.cms.csproj +++ b/umbraco/cms/umbraco.cms.csproj @@ -87,10 +87,6 @@ False ..\..\foreign dlls\ICSharpCode.SharpZipLib.dll - - False - ..\..\foreign dlls\Lucene.Net.dll - System @@ -174,6 +170,7 @@ Code + True True