Index.cshtml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. @{
  2. ViewBag.Title = "Index";
  3. Layout = "~/Views/Shared/_Layout.cshtml";
  4. }
  5. @model GreenTree.Nachtragsmanagement.Web.Models.Home.HomeModel
  6. <script>
  7. var openOffsetX = 10;
  8. var openOffsetY = 5;
  9. var popupStatus = {};
  10. var popupImages = {};
  11. var popupDescriptions = {};
  12. var popupWidths = {};
  13. var popupHeights = {};
  14. var popupLocations = {};
  15. var contentX = 0;
  16. var contentY = 0;
  17. @foreach (var g in Model.AvailableFunctions)
  18. {
  19. foreach (var i in g.Value)
  20. {
  21. ViewContext.Writer.WriteLine("popupImages[\"" + i.Name + "\"] = \"" + Url.Content(i.ImageUrl) + "\";");
  22. ViewContext.Writer.WriteLine("popupDescriptions[\"" + i.Name + "\"] = \"" + i.Description + "\";");
  23. }
  24. }
  25. $(document).ready(function () {
  26. $(".functionNavigationContainer").height($(window).height() - $(".globalFooter").height() - 3);
  27. $(".functionContentContainer").height($(window).height() - $(".globalFooter").height() - 3);
  28. $(".functionContentContainer").width($(window).width() - $(".functionNavigationContainer").width() - 3);
  29. contentX = $(".functionContentContainer").position().left;
  30. contentY = $(".functionContentContainer").position().top;
  31. })
  32. function showFunction(e) {
  33. if (!e) return;
  34. var controls = ASPxClientControl.GetControlCollection();
  35. var popupName = e.item.name + "-Popup";
  36. var popupElement = controls.GetByName(popupName);
  37. var popupControl = MVCxClientPopupControl.Cast(popupElement);
  38. if (popupControl.IsVisible()) return;
  39. if (popupStatus[e.item.name] && popupStatus[e.item.name] == "minimized") {
  40. popupControl.Show();
  41. } else {
  42. popupControl.RefreshContentUrl();
  43. popupControl.ShowAtPos(contentX + openOffsetX, contentX + openOffsetY);
  44. openOffsetX += 50;
  45. openOffsetY += 25;
  46. var popupPanel = $(
  47. '<div id="' + e.item.name + 'PanelItem" class="popupPanelItem" onclick=\'normalizeFunction("' + e.item.name + '")\'>' +
  48. '<img src="' + popupImages[e.item.name] + '" />' +
  49. '<span>' + popupDescriptions[e.item.name] + '</span>' +
  50. '<img src="@Url.Content("~/Content/Images/close-16.png")" onclick=\'hideFunction("' + e.item.name + '", false)\' />' +
  51. '</div>')
  52. .hide()
  53. .appendTo(".popupPanel")
  54. .fadeIn(500);
  55. }
  56. popupStatus[e.item.name] = "normalized";
  57. }
  58. function normalizeFunction(popupName) {
  59. var controls = ASPxClientControl.GetControlCollection();
  60. var popupElementName = popupName + "-Popup";
  61. var popupElement = controls.GetByName(popupElementName);
  62. var popupControl = MVCxClientPopupControl.Cast(popupElement);
  63. popupControl.Show();
  64. }
  65. function toggleMaximizeFunction(popupName) {
  66. var controls = ASPxClientControl.GetControlCollection();
  67. var popupElementName = popupName + "-Popup";
  68. var popupElement = controls.GetByName(popupElementName);
  69. var popupControl = MVCxClientPopupControl.Cast(popupElement);
  70. if (popupStatus[popupName] && popupStatus[popupName] == "minimized") {
  71. popupControl.Show();
  72. } else if (popupStatus[popupName] && popupStatus[popupName] == "normalized") {
  73. popupLocations[popupName] = popupControl.GetPosition();
  74. popupWidths[popupName] = popupControl.GetWidth();
  75. popupHeights[popupName] = popupControl.GetHeight();
  76. popupControl.ShowAtPos(contentX, contentY);
  77. popupControl.SetWidth($(".functionContentContainer").width());
  78. popupControl.SetHeight($(".functionContentContainer").height());
  79. } else if (popupStatus[popupName] && popupStatus[popupName] == "maximized") {
  80. popupControl.ShowAtPos(contentX, contentY);
  81. popupControl.SetWidth(popupWidths[popupName]);
  82. popupControl.SetHeight(popupHeights[popupName]);
  83. }
  84. }
  85. function hideFunction(popupName, minimize) {
  86. var controls = ASPxClientControl.GetControlCollection();
  87. var popupElement = controls.GetByName(popupName + "-Popup");
  88. var popupControl = MVCxClientPopupControl.Cast(popupElement);
  89. popupControl.Hide();
  90. if (minimize == true) {
  91. popupStatus[popupName] = "minimized";
  92. } else {
  93. popupStatus[popupName] = "closed";
  94. var iframe = popupControl.GetWindowContentIFrame();
  95. iframe.contentWindow.document.open();
  96. iframe.contentWindow.document.write("");
  97. iframe.contentWindow.document.close();
  98. $("#" + popupName + "PanelItem").fadeOut(500, function () {
  99. $(this).remove();
  100. });
  101. }
  102. }
  103. </script>
  104. @foreach (var g in Model.AvailableFunctions)
  105. {
  106. foreach (var i in g.Value)
  107. {
  108. Html.DevExpress().PopupControl(s =>
  109. {
  110. s.Name = i.Name + "-Popup";
  111. s.HeaderText = i.Description;
  112. s.SetHeaderTemplateContent(
  113. "<div class=\"functionHeader\">" +
  114. "<img class=\"headerIcon\" src=\"" + Url.Content(i.ImageUrl) + "\" />" +
  115. "<span class=\"headerText\">" + i.Description + "</span>" +
  116. "<img class=\"controlIcon\" src=\"" +
  117. Url.Content("~/Content/Images/close-16.png") + "\" onclick=\"hideFunction('" + i.Name + "',false);\" />" +
  118. "<img class=\"controlIcon\" src=\"" +
  119. Url.Content("~/Content/Images/maximize-16.png") + "\" onclick=\"toggleMaximizeFunction('" + i.Name + "');\" />" +
  120. "<img class=\"controlIcon\" src=\"" +
  121. Url.Content("~/Content/Images/minimize-16.png") + "\" onclick=\"hideFunction('" + i.Name + "',true);\" />" +
  122. "</div>");
  123. s.ContentUrl = Url.RouteUrl(i.RouteName);
  124. s.Modal = false;
  125. s.ShowMaximizeButton = (i.AllowMaximize.HasValue && i.AllowMaximize.Value) ? true : false;
  126. s.Width = new Unit(i.BaseWidth.Value, UnitType.Pixel);
  127. s.Height = new Unit(i.BaseHeight.Value, UnitType.Pixel);
  128. s.MinWidth = new Unit(i.MinWidth.Value, UnitType.Pixel);
  129. s.MinHeight = new Unit(i.MinHeight.Value, UnitType.Pixel);
  130. s.CloseAction = CloseAction.None;
  131. }).GetHtml();
  132. }
  133. }
  134. <div class="functionNavigationContainer">
  135. @Html.DevExpress().NavBar(s =>
  136. {
  137. s.Name = "devNavBarFunctions";
  138. s.Width = new Unit(100, UnitType.Percentage);
  139. s.ClientSideEvents.ItemClick = "function (s, e) { showFunction(e); }";
  140. s.Styles.Item.Cursor = "pointer";
  141. s.ControlStyle.Border.BorderStyle = BorderStyle.None;
  142. s.Styles.GroupHeader.Border.BorderStyle = BorderStyle.None;
  143. s.Styles.GroupHeader.CssClass += "devExBorderBottom devExBorderBottomGray devExBorderBottomSmall";
  144. s.Styles.GroupContent.Border.BorderStyle = BorderStyle.None;
  145. s.Styles.GroupContent.CssClass += "devExBorderBottom";
  146. s.Styles.Item.Border.BorderStyle = BorderStyle.None;
  147. s.Styles.Item.CssClass += "devExBorderBottom";
  148. foreach (var g in Model.AvailableFunctions)
  149. {
  150. s.Groups.Add(n1 =>
  151. {
  152. n1.Name = g.Key.Name;
  153. n1.Text = g.Key.Description;
  154. n1.ItemImagePosition = ImagePosition.Top;
  155. foreach (var i in g.Value)
  156. {
  157. n1.Items.Add(n2 =>
  158. {
  159. n2.Name = i.Name;
  160. n2.Text = i.Description;
  161. n2.Image.Url = i.ImageUrl;
  162. n2.Image.UrlHottracked = GreenTree.Nachtragsmanagement.Core.StaticHelper.AddSuffix(i.ImageUrl, "-contrast", true);
  163. });
  164. }
  165. });
  166. }
  167. }).GetHtml()
  168. </div>
  169. <div class="functionContentContainer">
  170. </div>