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,118 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using Kreta.Resources;
namespace Kreta.Web.Helpers
{
public static class SearchPanelSideBarExtensions
{
public static SearchPanelSideBarHelper SearchPanelSideBar(this HtmlHelper helper, string formId, string gridId, string preSubmitFunction = null, string postSubmitFunction = null, Dictionary<string, object> htmlAttributes = null)
{
if (htmlAttributes == null)
{
htmlAttributes = new Dictionary<string, object>();
}
htmlAttributes.Add("id", formId);
helper.SearchPanelSideBarStart(formId, gridId, preSubmitFunction, postSubmitFunction);
helper.BeginForm(null, null, FormMethod.Get, htmlAttributes);
return new SearchPanelSideBarHelper(helper);
}
public static void SearchPanelSideBarStart(this HtmlHelper html, string formId, string gridId, string preSubmitFunction, string postSubmitFunction)
{
StringBuilder beforeContent = new StringBuilder();
beforeContent.AppendFormat("<div id=\"layout_SearchPanelContainer\" data-gridId=\"{0}\">", gridId);
beforeContent.Append("<div class=\"collapse sidebaritem in\" id=\"layout_search\" aria-expanded=\"true\">");
beforeContent.Append("<div class=\"searchPanelButton\">");
beforeContent.Append("<input style=\"width: 25%;border-top-right-radius: 0;border-bottom-right-radius: 0;background-color: #a94442;\" type=\"button\" class=\"k-button k-button-icontext\" id=\"searchPanelResetBtn\" value=\"").Append("X").Append("\" />");
beforeContent.Append("<input style=\"width: 75%;border-top-left-radius: 0;border-bottom-left-radius: 0;\" type=\"button\" class=\"k-button k-button-icontext\" id=\"searchPanelBtn\" value=\"").Append(CommonResource.Kereses).Append("\" />");
beforeContent.Append("</div>");
beforeContent.Append("<div class=\"sideSearchPanel\">");
beforeContent.Append("<script>");
beforeContent.Append("$(\"#searchPanelResetBtn\").click(function () {");
beforeContent.Append("$(\"#").Append(formId).Append("\").resetForm(").Append(formId).Append(");");
beforeContent.Append("});");
beforeContent.Append("$(\"#searchPanelBtn\").click(function () {");
beforeContent.Append("var popup = $('#popupNotification').data('kendoNotification');");
beforeContent.Append("if (popup) {");
beforeContent.Append("popup.hide();");
beforeContent.Append("}");
if (!string.IsNullOrWhiteSpace(preSubmitFunction))
{
beforeContent.AppendFormat(" if({0}){{ {0}('{1}'); }}", preSubmitFunction, formId);
}
if (!string.IsNullOrWhiteSpace(gridId))
{
beforeContent.Append("KretaGridHelper.refreshGridSearchPanel(\"").Append(gridId).Append("\",\"").Append(formId).Append("\");");
beforeContent.AppendFormat("$(\"#{0}\").removeClass(\"disabledGrid\");", gridId);
}
if (!string.IsNullOrWhiteSpace(postSubmitFunction))
{
beforeContent.AppendFormat(" if({0}){{ {0}('{1}'); }}", postSubmitFunction, formId);
}
beforeContent.Append("});");
beforeContent.Append("$(document).ready(function() {");
beforeContent.Append("document.addEventListener(\"keydown\", onKeyDown, false);");
beforeContent.Append("function onKeyDown(e) {");
beforeContent.Append("if (e.keyCode == 13) {");
beforeContent.Append("var searchbutton = $(\"#searchPanelBtn\");");
beforeContent.AppendFormat("if (searchbutton != null && searchbutton.length == 1 && $(document.activeElement).parents(\"#{0}\").length == 1) {{", formId);
beforeContent.Append("MasterLayout.searchWithEnter = true;");
beforeContent.Append("searchbutton.click();");
beforeContent.Append("}");
beforeContent.Append("}");
beforeContent.Append("}");
beforeContent.Append("});");
beforeContent.Append("var searchPanelFirstLoad = true;");
beforeContent.Append("$(document).ajaxStop(function() {");
beforeContent.Append("if (searchPanelFirstLoad) {");
beforeContent.Append("KretaGridHelper.refreshGridSearchPanel(\"").Append(gridId).Append("\",\"").Append(formId).Append("\");");
beforeContent.Append("searchPanelFirstLoad = false;");
beforeContent.Append("}");
beforeContent.Append("});");
beforeContent.Append("</script>");
html.ViewContext.Writer.Write(beforeContent.ToString());
}
public static void SearchPanelSideBarEnd(this HtmlHelper html)
{
StringBuilder endContent = new StringBuilder();
endContent.Append("</div>");
endContent.Append("</div>");
endContent.Append("</div>");
endContent.Append("</form>");
html.ViewContext.Writer.Write(endContent.ToString());
}
public class SearchPanelSideBarHelper : IDisposable
{
private readonly HtmlHelper rohtml;
public SearchPanelSideBarHelper(HtmlHelper html)
{
rohtml = html;
}
public void Dispose()
{
rohtml.SearchPanelSideBarEnd();
}
}
}
}