Normalize cr/lf/tab

This commit is contained in:
Stephan
2017-07-20 11:21:28 +02:00
parent fa6c147a65
commit c76403077f
2466 changed files with 26012 additions and 26010 deletions

View File

@@ -8,137 +8,137 @@ using Umbraco.Web.Composing;
namespace Umbraco.Web.UI.Controls
{
/// <summary>
/// Represents the 'insert macro' button when editing a template which includes the drop down list selector
/// </summary>
/// <remarks>
/// Though this would be nicer to do in a UserControl, unfortunatley the way that the ScrollingMenu control is designed it seems that
/// we have to insert all items via code and loading a UserControl in dynamically is equally ugly.
/// </remarks>
[ClientDependency(ClientDependencyType.Css, "splitbutton/splitbutton.css", "UmbracoClient")]
[ClientDependency(ClientDependencyType.Javascript, "splitbutton/jquery.splitbutton.js", "UmbracoClient", Priority = 100)]
[ClientDependency(ClientDependencyType.Javascript, "splitbutton/InsertMacroSplitButton.js", "UmbracoClient", Priority = 101)]
internal class InsertMacroSplitButton : UmbracoControl
{
protected LiteralControl ListContainer;
/// <summary>
/// Represents the 'insert macro' button when editing a template which includes the drop down list selector
/// </summary>
/// <remarks>
/// Though this would be nicer to do in a UserControl, unfortunatley the way that the ScrollingMenu control is designed it seems that
/// we have to insert all items via code and loading a UserControl in dynamically is equally ugly.
/// </remarks>
[ClientDependency(ClientDependencyType.Css, "splitbutton/splitbutton.css", "UmbracoClient")]
[ClientDependency(ClientDependencyType.Javascript, "splitbutton/jquery.splitbutton.js", "UmbracoClient", Priority = 100)]
[ClientDependency(ClientDependencyType.Javascript, "splitbutton/InsertMacroSplitButton.js", "UmbracoClient", Priority = 101)]
internal class InsertMacroSplitButton : UmbracoControl
{
protected LiteralControl ListContainer;
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
EnsureChildControls();
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
EnsureChildControls();
}
/// <summary>
/// The JS callback to display the dialog modal screen to customize the macro to be inserted into the editor if the
/// macro has parameters.
/// </summary>
public string ClientCallbackOpenMacroModel { get; set; }
/// <summary>
/// The JS callback to display the dialog modal screen to customize the macro to be inserted into the editor if the
/// macro has parameters.
/// </summary>
public string ClientCallbackOpenMacroModel { get; set; }
/// <summary>
/// The JS callback method which accepts an 'alias' parameter that is invoked when clicking the macro button
/// to insert a macro that has no parameters.
/// </summary>
public string ClientCallbackInsertMacroMarkup { get; set; }
/// <summary>
/// The JS callback method which accepts an 'alias' parameter that is invoked when clicking the macro button
/// to insert a macro that has no parameters.
/// </summary>
public string ClientCallbackInsertMacroMarkup { get; set; }
protected override void CreateChildControls()
{
base.CreateChildControls();
protected override void CreateChildControls()
{
base.CreateChildControls();
//var menuItemsId = ClientID + "menuitems";
//var placeHolderId = ClientID + "sbPlaceholder";
//var menuItemsId = ClientID + "menuitems";
//var placeHolderId = ClientID + "sbPlaceholder";
/*create the list, similar to this, but swap the repeater for real html:
<div id="macroMenu" style="width: 285px">
<asp:Repeater ID="rpt_macros" runat="server">
<ItemTemplate>
<div class="macro" rel="<%# DataBinder.Eval(Container, "DataItem.macroAlias")%>"
data-has-params="<%# DoesMacroHaveSettings(DataBinder.Eval(Container, "DataItem.id").ToString()) %>">
<%# DataBinder.Eval(Container, "DataItem.macroName")%>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
*/
/*create the list, similar to this, but swap the repeater for real html:
//Create the drop down menu list first (it is hidden)
var divMacroItemContainer = new TagBuilder("div");
divMacroItemContainer.Attributes.Add("style", "width: 285px;display:none;");
divMacroItemContainer.Attributes.Add("class", "sbMenu");
<div id="macroMenu" style="width: 285px">
<asp:Repeater ID="rpt_macros" runat="server">
<ItemTemplate>
<div class="macro" rel="<%# DataBinder.Eval(Container, "DataItem.macroAlias")%>"
data-has-params="<%# DoesMacroHaveSettings(DataBinder.Eval(Container, "DataItem.id").ToString()) %>">
<%# DataBinder.Eval(Container, "DataItem.macroName")%>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
*/
var macros = Services.MacroService.GetAll().OrderBy(x => x.Name);
foreach (var macro in macros)
{
var divMacro = new TagBuilder("div");
divMacro.AddCssClass("macro-item");
divMacro.Attributes.Add("rel", macro.Alias);
divMacro.Attributes.Add("data-has-params", DoesMacroHaveParameters(macro.Id).ToString().ToLower());
divMacro.SetInnerText(macro.Name);
divMacroItemContainer.InnerHtml += divMacro.ToString();
}
/*create the button itself, similar to this:
<div id="splitButtonMacro" style="display: inline; height: 23px; vertical-align: top;">
<a href="javascript:openMacroModal();" class="sbLink">
<img alt="Insert Macro" src="../images/editor/insMacroSB.png" title="Insert Macro"
style="vertical-align: top;">
</a>
</div>
*/
//Create the drop down menu list first (it is hidden)
var divMacroItemContainer = new TagBuilder("div");
divMacroItemContainer.Attributes.Add("style", "width: 285px;display:none;");
divMacroItemContainer.Attributes.Add("class", "sbMenu");
var divSplitButtonWrapper = new TagBuilder("div");
divSplitButtonWrapper.AddCssClass("sbPlaceHolder");
divSplitButtonWrapper.Attributes.Add("id", ClientID + "sbPlaceholder");
var divButton = new TagBuilder("div");
divButton.Attributes.Add("style", "display: inline; height: 23px; vertical-align: top;");
var aButton = new TagBuilder("a");
aButton.Attributes.Add("href", "#"); //will be bound with jquery
aButton.AddCssClass("sbLink");
var imgButton = new TagBuilder("img");
imgButton.Attributes.Add("alt", "Insert Macro");
imgButton.Attributes.Add("src", this.ResolveUrl(SystemDirectories.Umbraco + "/images/editor/insMacroSB.png"));
imgButton.Attributes.Add("title", "Insert Macro");
imgButton.Attributes.Add("style", "vertical-align: top;");
aButton.InnerHtml = imgButton.ToString();
divButton.InnerHtml = aButton.ToString();
divSplitButtonWrapper.InnerHtml = divButton.ToString();
var macros = Services.MacroService.GetAll().OrderBy(x => x.Name);
foreach (var macro in macros)
{
var divMacro = new TagBuilder("div");
divMacro.AddCssClass("macro-item");
divMacro.Attributes.Add("rel", macro.Alias);
divMacro.Attributes.Add("data-has-params", DoesMacroHaveParameters(macro.Id).ToString().ToLower());
divMacro.SetInnerText(macro.Name);
divMacroItemContainer.InnerHtml += divMacro.ToString();
}
ListContainer = new LiteralControl(divMacroItemContainer.ToString() + divSplitButtonWrapper.ToString());
Controls.Add(ListContainer);
/*create the button itself, similar to this:
// Page.ClientScript.RegisterStartupScript(
// typeof(InsertMacroSplitButton),
// ClientID,
// @"jQuery(document).ready(function() {
// jQuery('#" + placeHolderId + " a.sbLink').splitbutton({menu:'#" + menuItemsId + "'}); " +
// "});",
// true);
<div id="splitButtonMacro" style="display: inline; height: 23px; vertical-align: top;">
<a href="javascript:openMacroModal();" class="sbLink">
<img alt="Insert Macro" src="../images/editor/insMacroSB.png" title="Insert Macro"
style="vertical-align: top;">
</a>
</div>
Page.ClientScript.RegisterStartupScript(
typeof(InsertMacroSplitButton),
typeof(InsertMacroSplitButton).Name, //same key for all instancees, we should only render once
@"jQuery(document).ready(function() {
var splitButton = new Umbraco.Controls.InsertMacroSplitButton({
openMacroModel: " + ClientCallbackOpenMacroModel + @",
insertMacroMarkup: " + ClientCallbackInsertMacroMarkup + @"
});
splitButton.init();
});",
true);
}
*/
var divSplitButtonWrapper = new TagBuilder("div");
divSplitButtonWrapper.AddCssClass("sbPlaceHolder");
divSplitButtonWrapper.Attributes.Add("id", ClientID + "sbPlaceholder");
var divButton = new TagBuilder("div");
divButton.Attributes.Add("style", "display: inline; height: 23px; vertical-align: top;");
var aButton = new TagBuilder("a");
aButton.Attributes.Add("href", "#"); //will be bound with jquery
aButton.AddCssClass("sbLink");
var imgButton = new TagBuilder("img");
imgButton.Attributes.Add("alt", "Insert Macro");
imgButton.Attributes.Add("src", this.ResolveUrl(SystemDirectories.Umbraco + "/images/editor/insMacroSB.png"));
imgButton.Attributes.Add("title", "Insert Macro");
imgButton.Attributes.Add("style", "vertical-align: top;");
aButton.InnerHtml = imgButton.ToString();
divButton.InnerHtml = aButton.ToString();
divSplitButtonWrapper.InnerHtml = divButton.ToString();
ListContainer = new LiteralControl(divMacroItemContainer.ToString() + divSplitButtonWrapper.ToString());
Controls.Add(ListContainer);
// Page.ClientScript.RegisterStartupScript(
// typeof(InsertMacroSplitButton),
// ClientID,
// @"jQuery(document).ready(function() {
// jQuery('#" + placeHolderId + " a.sbLink').splitbutton({menu:'#" + menuItemsId + "'}); " +
// "});",
// true);
Page.ClientScript.RegisterStartupScript(
typeof(InsertMacroSplitButton),
typeof(InsertMacroSplitButton).Name, //same key for all instancees, we should only render once
@"jQuery(document).ready(function() {
var splitButton = new Umbraco.Controls.InsertMacroSplitButton({
openMacroModel: " + ClientCallbackOpenMacroModel + @",
insertMacroMarkup: " + ClientCallbackInsertMacroMarkup + @"
});
splitButton.init();
});",
true);
}
private bool DoesMacroHaveParameters(int macroId)
{
bool hasParameters;
using (var scope = Current.ScopeProvider.CreateScope())
{
private bool DoesMacroHaveParameters(int macroId)
{
bool hasParameters;
using (var scope = Current.ScopeProvider.CreateScope())
{
hasParameters = scope.Database.ExecuteScalar<int>("SELECT COUNT(*) from cmsMacroProperty where macro=@macroId", new { macroId }) > 0;
scope.Complete();
}
return hasParameters;
}
}
}
return hasParameters;
}
}
}

View File

@@ -3,7 +3,7 @@
namespace Umbraco.Web.UI.Controls
{
public class ProgressBar : System.Web.UI.WebControls.Image
{
{
public string Title { get; set; }
protected override void Render(System.Web.UI.HtmlTextWriter writer)

View File

@@ -10,10 +10,10 @@ using Umbraco.Web.Composing;
namespace Umbraco.Web.UI.Controls
{
/// <summary>
/// A control that exposes the helpful Umbraco context objects
/// </summary>
public abstract class UmbracoControl : Control
{
/// A control that exposes the helpful Umbraco context objects
/// </summary>
public abstract class UmbracoControl : Control
{
private UrlHelper _url;
protected UmbracoControl(UmbracoContext umbracoContext, ServiceContext services, CacheHelper appCache)
@@ -44,7 +44,7 @@ namespace Umbraco.Web.UI.Controls
/// </summary>
public ILogger Logger { get; }
/// <summary>
/// <summary>
/// Gets the profiling logger.
/// </summary>
public ProfilingLogger ProfilingLogger { get; }
@@ -54,15 +54,15 @@ namespace Umbraco.Web.UI.Controls
/// </summary>
public UmbracoContext UmbracoContext { get; }
/// <summary>
/// Gets the services context.
/// </summary>
protected ServiceContext Services { get; }
/// <summary>
/// Gets the services context.
/// </summary>
protected ServiceContext Services { get; }
/// <summary>
/// Gets a Url helper.
/// </summary>
/// <remarks>This URL helper is created without any route data and an empty request context.</remarks>
public UrlHelper Url => _url ?? (_url = new UrlHelper(Context.Request.RequestContext));
}
}
}
}

View File

@@ -104,4 +104,4 @@ namespace Umbraco.Web.UI.Controls
/// <remarks>This URL helper is created without any route data and an empty request context.</remarks>
public UrlHelper Url => _url ?? (_url = new UrlHelper(Context.Request.RequestContext));
}
}
}