This commit is contained in:
skidoodle 2024-03-13 00:33:46 +01:00
commit e124a47765
19374 changed files with 9806149 additions and 0 deletions

View file

@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.Mvc;
using Kreta.BusinessLogic.HelperClasses;
namespace Kreta.Web.Helpers
{
public static class CheckBoxListExtension
{
public static MvcHtmlString KretaCheckBoxList(this HtmlHelper helper, string id, List<SelectListItem> items, object htmlAttributes = null, bool isPostAsArray = false, string onClickEvent = null)
{
TagBuilder ultag = new TagBuilder("ul");
ultag.AddCssClass("noUlLiButton");
int cnt = 0;
foreach (SelectListItem item in items)
{
cnt++;
string generatedId = id + cnt.ToString();
StringBuilder sb = new StringBuilder();
sb.Append("<li>");
sb.AppendFormat($"<input type=\"checkbox\" name=\"{{0}}", id);
if (isPostAsArray)
{
sb.AppendFormat($"[{{0}}]", cnt);
}
sb.AppendFormat($"\" value =\"{{0}}\" id =\"{{1}}\" class=\"k-checkbox\" {{2}} ", HttpUtility.HtmlEncode(item.Value), generatedId, item.Selected ? "checked=\"checked\"" : string.Empty);
if (!string.IsNullOrWhiteSpace(onClickEvent))
{
sb.AppendFormat($" onclick=\"{{0}}\"", onClickEvent);
}
sb.Append(" />");
sb.AppendFormat("<label for= \"{0}\" class=\"k-checkbox-label\">{1}</label>", generatedId, HttpUtility.HtmlEncode(item.Text));
sb.Append("</li><br />");
// jQuerry selector name property
ultag.InnerHtml += sb.ToString();
}
return new MvcHtmlString(ultag.ToString());
}
public static MvcHtmlString KretaCheckBoxListForOpenBoardKepek(this HtmlHelper helper, string id, List<OpenBoardFileCo> items, int elementsPerColumn, bool isDisabled = false)
{
TagBuilder ultag = new TagBuilder("ul");
ultag.AddCssClass("noUlLiButton");
int cnt = 0;
foreach (var item in items)
{
cnt++;
string generatedId = id + cnt.ToString();
string contentAsBase64Encoded = "data:image/jpeg;base64," + Convert.ToBase64String(item.Content);
StringBuilder sb = new StringBuilder();
if (cnt == 1)
{
sb.Append("<div class=\"col-xs-3\">");
}
sb.Append("<li>");
sb.AppendFormat("<input type=\"checkbox\" name=\"{0}[{4}]\" value =\"{1}\" id =\"{2}\" class=\"k-checkbox\" {3} {5} />", id, HttpUtility.HtmlEncode(item.ID), generatedId, item.Lathato ? "checked=\"checked\"" : string.Empty, cnt, isDisabled ? "disabled=\"disabled\"" : string.Empty);
sb.AppendFormat("<label for= \"{0}\" class=\"k-checkbox-label-inline k-checkbox-label\"></label><label id='lblFeltoltottFajlok{4}' onclick=\"var newWindow = window.open('', '_blank'); newWindow.document.body.innerHTML = '<table><thead><tr><th><img width=60% src={1}></th></tr><tbody><tr><td align=center><a href={1} download={2}.{3} target=_blank>Kattintson ide a letöltéshez!</a></td></tr></tbody></table>'; \" onMouseOver=\"this.style.cursor = 'pointer'\">{2}</label>", generatedId, contentAsBase64Encoded, item.Nev, item.Kiterjesztes, item.ID);
sb.AppendFormat("<a title='Módosítás' href='javascript:void(0)' onclick='KepekListajaHelper.openModifyKepWindow({0})'><i style='font-size: 17px; padding-left: 3px;' class='fa fa-pencil' aria-hidden='true'></i></a>", item.ID);
sb.Append("</li><br />");
if (cnt == items.Count || cnt % elementsPerColumn == 0)
{
sb.Append("</div>");
}
if (cnt != items.Count && cnt % elementsPerColumn == 0)
{
sb.Append("<div class=\"col-xs-3\">");
}
ultag.InnerHtml += sb.ToString();
}
return new MvcHtmlString(ultag.ToString());
}
}
}