125 lines
4.1 KiB
C#
125 lines
4.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Web.Mvc;
|
|
using Kendo.Mvc.UI;
|
|
using Kendo.Mvc.UI.Fluent;
|
|
using Kreta.Framework;
|
|
using Kreta.Resources;
|
|
using Kreta.Web.Helpers.Modal;
|
|
|
|
namespace Kreta.Web.Helpers
|
|
{
|
|
public static class ButtonExtensions
|
|
{
|
|
private const string ObsoleteButtonExtensions = "Ne használd, a text-es KretaButton metódust használd helyette!";
|
|
|
|
[Obsolete(ObsoleteButtonExtensions)]
|
|
public static ButtonBuilder KretaButton(
|
|
this HtmlHelper helper,
|
|
string name,
|
|
int content,
|
|
bool enabled = true,
|
|
string spriteCssClass = null,
|
|
string icon = null,
|
|
string imageUrl = null,
|
|
IDictionary<string, object> htmlAttributes = null,
|
|
string clickEventName = null)
|
|
{
|
|
var type = "button";
|
|
var text = StringResourcesUtil.GetString(content);
|
|
var button = helper.KretaButton(name, text, type, enabled, spriteCssClass, icon, imageUrl, htmlAttributes, clickEventName);
|
|
return button;
|
|
}
|
|
|
|
[Obsolete(ObsoleteButtonExtensions)]
|
|
public static ButtonBuilder KretaButton(
|
|
this HtmlHelper helper,
|
|
string name,
|
|
int content,
|
|
string type = "button",
|
|
bool enabled = true,
|
|
string spriteCssClass = null,
|
|
string icon = null,
|
|
string imageUrl = null,
|
|
IDictionary<string, object> htmlAttributes = null,
|
|
string clickEventName = null)
|
|
{
|
|
var text = StringResourcesUtil.GetString(content);
|
|
var button = helper.KretaButton(name, text, type, enabled, spriteCssClass, icon, imageUrl, htmlAttributes, clickEventName);
|
|
return button;
|
|
}
|
|
|
|
public static ButtonBuilder KretaButton(this HtmlHelper helper, ModalButtonModel modalButtonModel, string type = "button")
|
|
{
|
|
var button = helper.KretaButton(
|
|
modalButtonModel.Name,
|
|
modalButtonModel.Text,
|
|
type,
|
|
modalButtonModel.Enabled,
|
|
modalButtonModel.SpriteCssClass,
|
|
modalButtonModel.Icon,
|
|
modalButtonModel.ImageUrl,
|
|
null,
|
|
modalButtonModel.EventName);
|
|
return button;
|
|
}
|
|
|
|
public static ButtonBuilder KretaButton(
|
|
this HtmlHelper helper,
|
|
string name,
|
|
string text,
|
|
string type = "button",
|
|
bool enabled = true,
|
|
string spriteCssClass = null,
|
|
string icon = null,
|
|
string imageUrl = null,
|
|
IDictionary<string, object> htmlAttributes = null,
|
|
string clickEventName = null)
|
|
{
|
|
var button = helper.Kendo().Button()
|
|
.Name(name)
|
|
.Content(text)
|
|
.Enable(enabled)
|
|
.SpriteCssClass(spriteCssClass)
|
|
.Icon(icon)
|
|
.ImageUrl(imageUrl);
|
|
|
|
if (htmlAttributes == null)
|
|
{
|
|
htmlAttributes = new Dictionary<string, object>();
|
|
}
|
|
|
|
htmlAttributes.Add("type", type);
|
|
button.HtmlAttributes(htmlAttributes);
|
|
|
|
if (clickEventName != null)
|
|
{
|
|
button.Events(x => x.Click(clickEventName));
|
|
}
|
|
|
|
return button;
|
|
}
|
|
|
|
public static ButtonBuilder KretaSaveButton(
|
|
this HtmlHelper helper,
|
|
string name,
|
|
string clickEventName = null)
|
|
{
|
|
var button = helper.Kendo().Button()
|
|
.Name(name)
|
|
.Content(CommonResource.Mentes);
|
|
|
|
var htmlAttributes = new Dictionary<string, object> { { "style", "background-color:#54a5d1" } };
|
|
htmlAttributes.Add("type", "button");
|
|
button.HtmlAttributes(htmlAttributes);
|
|
|
|
if (clickEventName != null)
|
|
{
|
|
button.Events(x => x.Click(clickEventName));
|
|
}
|
|
|
|
return button;
|
|
}
|
|
|
|
}
|
|
}
|