Green Key

Beirholm has signed a cooperation agreement with Green Key to
promote sustainable textiles in the hospitality industry.

Error executing template "Designs/Rapido/Paragraph/ParagraphContainer.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_1656976b786f4aad855772141201ad1d.Execute() in D:\dynamicweb.net\Solutions\Dynamicweb\beirholm.cloud.dynamicweb-cms.com\files\Templates\Designs\Rapido\Paragraph\ParagraphContainer.cshtml:line 2572
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using System.Collections.Generic 3 @using System 4 @using System.Text.RegularExpressions 5 @using Dynamicweb.Core 6 @using Dynamicweb.Rapido.Blocks.Components.General 7 @using Dynamicweb.Rapido.Blocks.Components 8 9 @functions { 10 public string GenerateRgba(string color, double opacity) 11 { 12 color = color.Replace("#", ""); 13 if (color.Length == 6) { 14 return "rgba(" + Convert.ToInt32(color.Substring(0, 2), 16) + ", " + Convert.ToInt32(color.Substring(2, 2), 16) + ", " + Convert.ToInt32(color.Substring(4, 2), 16) + ", " + opacity + ");"; 15 } else { 16 return Convert.ToInt16(color).ToString(); 17 } 18 } 19 } 20 21 @* Include the required Grid builder (Contains the methods @RenderBlockList and @RenderBlock) *@ 22 @using System.Text.RegularExpressions 23 @using System.Collections.Generic 24 @using System.Reflection 25 @using System.Web 26 @using System.Web.UI.HtmlControls 27 @using Dynamicweb.Rapido.Blocks.Components 28 @using Dynamicweb.Rapido.Blocks.Components.Articles 29 @using Dynamicweb.Rapido.Blocks.Components.Documentation 30 @using Dynamicweb.Rapido.Blocks 31 32 33 @*--- START: Base block renderers ---*@ 34 35 @helper RenderBlockList(List<Block> blocks) 36 { 37 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 38 blocks = blocks.OrderBy(item => item.SortId).ToList(); 39 40 foreach (Block item in blocks) 41 { 42 if (debug) { 43 <!-- Block START: @item.Id --> 44 } 45 46 if (item.Design == null) 47 { 48 @RenderBlock(item) 49 } 50 else if (item.Design.RenderType == RenderType.None) { 51 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 52 53 <div class="@cssClass dw-mod"> 54 @RenderBlock(item) 55 </div> 56 } 57 else if (item.Design.RenderType != RenderType.Hide) 58 { 59 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 60 61 if (!item.SkipRenderBlocksList) { 62 if (item.Design.RenderType == RenderType.Row) 63 { 64 <div class="grid grid--align-content-start @cssClass dw-mod" id="Block__@item.Id"> 65 @RenderBlock(item) 66 </div> 67 } 68 69 if (item.Design.RenderType == RenderType.Column) 70 { 71 string hidePadding = item.Design.HidePadding ? "u-no-padding" : ""; 72 string size = item.Design.Size ?? "12"; 73 size = Regex.IsMatch(size, @"\d") ? "md-" + item.Design.Size : item.Design.Size; 74 75 <div class="grid__col-lg-@item.Design.Size grid__col-md-@item.Design.Size grid__col-sm-12 grid__col-xs-12 @hidePadding @cssClass dw-mod" id="Block__@item.Id"> 76 @RenderBlock(item) 77 </div> 78 } 79 80 if (item.Design.RenderType == RenderType.Table) 81 { 82 <table class="table @cssClass dw-mod" id="Block__@item.Id"> 83 @RenderBlock(item) 84 </table> 85 } 86 87 if (item.Design.RenderType == RenderType.TableRow) 88 { 89 <tr class="@cssClass dw-mod" id="Block__@item.Id"> 90 @RenderBlock(item) 91 </tr> 92 } 93 94 if (item.Design.RenderType == RenderType.TableColumn) 95 { 96 <td class="@cssClass dw-mod" id="Block__@item.Id"> 97 @RenderBlock(item) 98 </td> 99 } 100 101 if (item.Design.RenderType == RenderType.CardHeader) 102 { 103 <div class="card-header @cssClass dw-mod"> 104 @RenderBlock(item) 105 </div> 106 } 107 108 if (item.Design.RenderType == RenderType.CardBody) 109 { 110 <div class="card @cssClass dw-mod"> 111 @RenderBlock(item) 112 </div> 113 } 114 115 if (item.Design.RenderType == RenderType.CardFooter) 116 { 117 <div class="card-footer @cssClass dw-mod"> 118 @RenderBlock(item) 119 </div> 120 } 121 } 122 else 123 { 124 @RenderBlock(item) 125 } 126 } 127 128 if (debug) { 129 <!-- Block END: @item.Id --> 130 } 131 } 132 } 133 134 @helper RenderBlock(Block item) 135 { 136 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 137 138 if (item.Template != null) 139 { 140 @BlocksPage.RenderTemplate(item.Template) 141 } 142 143 if (item.Component != null) 144 { 145 string customSufix = "Custom"; 146 string methodName = item.Component.HelperName; 147 148 ComponentBase[] methodParameters = new ComponentBase[1]; 149 methodParameters[0] = item.Component; 150 Type methodType = this.GetType(); 151 152 MethodInfo customMethod = methodType.GetMethod(methodName + customSufix); 153 MethodInfo generalMethod = methodType.GetMethod(methodName); 154 155 try { 156 if (debug) { 157 <!-- Component: @methodName.Replace("Render", "") --> 158 } 159 @customMethod.Invoke(this, methodParameters).ToString(); 160 } catch { 161 try { 162 @generalMethod.Invoke(this, methodParameters).ToString(); 163 } catch(Exception ex) { 164 throw new Exception(item.Component.GetType().Name + " method '" + methodName +"' could not be invoked", ex); 165 } 166 } 167 } 168 169 if (item.BlocksList.Count > 0 && !item.SkipRenderBlocksList) 170 { 171 @RenderBlockList(item.BlocksList) 172 } 173 } 174 175 @*--- END: Base block renderers ---*@ 176 177 178 @* Include the components *@ 179 @using Dynamicweb.Rapido.Blocks.Components 180 @using Dynamicweb.Rapido.Blocks.Components.General 181 @using Dynamicweb.Rapido.Blocks 182 @using System.IO 183 184 @* Required *@ 185 @using Dynamicweb.Rapido.Blocks.Components 186 @using Dynamicweb.Rapido.Blocks.Components.General 187 @using Dynamicweb.Rapido.Blocks 188 189 190 @helper Render(ComponentBase component) 191 { 192 if (component != null) 193 { 194 @component.Render(this) 195 } 196 } 197 198 199 @* Components *@ 200 @using System.Reflection 201 @using Dynamicweb.Rapido.Blocks.Components.General 202 203 204 @* Component *@ 205 206 @helper RenderIcon(Icon settings) 207 { 208 if (settings != null) 209 { 210 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 211 212 if (settings.Name != null) 213 { 214 if (string.IsNullOrEmpty(settings.Label)) 215 { 216 <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> 217 } 218 else 219 { 220 if (settings.LabelPosition == IconLabelPosition.Before) 221 { 222 <span>@settings.Label <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i></span> 223 } 224 else 225 { 226 <span><i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> @settings.Label</span> 227 } 228 } 229 } 230 else if (!string.IsNullOrEmpty(settings.Label)) 231 { 232 @settings.Label 233 } 234 } 235 } 236 @using System.Reflection 237 @using Dynamicweb.Rapido.Blocks.Components.General 238 @using Dynamicweb.Rapido.Blocks.Components 239 @using Dynamicweb.Core 240 241 @* Component *@ 242 243 @helper RenderButton(Button settings) 244 { 245 if (settings != null && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 246 { 247 Dictionary<string, string> attributes = new Dictionary<string, string>(); 248 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 249 if (settings.Disabled) { 250 attributes.Add("disabled", "true"); 251 classList.Add("disabled"); 252 } 253 254 if (!string.IsNullOrEmpty(settings.ConfirmText) || !string.IsNullOrEmpty(settings.ConfirmTitle)) 255 { 256 settings.Id = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 257 @RenderConfirmDialog(settings); 258 settings.OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = true"; 259 } 260 261 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 262 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 263 if (!string.IsNullOrEmpty(settings.AltText)) 264 { 265 attributes.Add("title", settings.AltText); 266 } 267 else if (!string.IsNullOrEmpty(settings.Title)) 268 { 269 attributes.Add("title", settings.Title); 270 } 271 272 var onClickEvents = new List<string>(); 273 if (!string.IsNullOrEmpty(settings.OnClick)) 274 { 275 onClickEvents.Add(settings.OnClick); 276 } 277 if (!string.IsNullOrEmpty(settings.Href)) 278 { 279 onClickEvents.Add("location.href='" + settings.Href + "'"); 280 } 281 if (onClickEvents.Count > 0) 282 { 283 attributes.Add("onClick", string.Join(";", onClickEvents)); 284 } 285 286 if (settings.ButtonLayout != ButtonLayout.None) 287 { 288 classList.Add("btn"); 289 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 290 if (btnLayout == "linkclean") 291 { 292 btnLayout = "link-clean"; //fix 293 } 294 classList.Add("btn--" + btnLayout); 295 } 296 297 if (settings.Icon == null) 298 { 299 settings.Icon = new Icon(); 300 } 301 settings.Icon.Label = settings.Title; 302 303 attributes.Add("type", Enum.GetName(typeof(ButtonType), settings.ButtonType).ToLower()); 304 305 <button class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</button> 306 } 307 } 308 309 @helper RenderConfirmDialog(Button settings) 310 { 311 Modal confirmDialog = new Modal { 312 Id = settings.Id, 313 Width = ModalWidth.Sm, 314 Heading = new Heading 315 { 316 Level = 2, 317 Title = settings.ConfirmTitle 318 }, 319 BodyText = settings.ConfirmText 320 }; 321 322 confirmDialog.AddAction(new Button { Title = Translate("Cancel"), ButtonLayout = ButtonLayout.Secondary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false"}); 323 confirmDialog.AddAction(new Button { Title = Translate("OK"), ButtonLayout = ButtonLayout.Primary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false;" + settings.OnClick }); 324 325 @Render(confirmDialog) 326 } 327 @using Dynamicweb.Rapido.Blocks.Components.General 328 @using Dynamicweb.Rapido.Blocks.Components 329 @using Dynamicweb.Core 330 331 @helper RenderDashboard(Dashboard settings) 332 { 333 var widgets = settings.GetWidgets(); 334 335 if (!string.IsNullOrEmpty(settings.WidgetsBaseBackgroundColor)) 336 { 337 //set bg color for them 338 339 System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml(settings.WidgetsBaseBackgroundColor); 340 int r = Convert.ToInt16(color.R); 341 int g = Convert.ToInt16(color.G); 342 int b = Convert.ToInt16(color.B); 343 344 var count = widgets.Length; 345 var max = Math.Max(r, Math.Max(g, b)); 346 double step = 255.0 / (max * count); 347 var i = 0; 348 foreach (var widget in widgets) 349 { 350 i++; 351 352 var shade = "rgb(" + Converter.ToString(r * step * i).Replace(",", ".") + ", " + Converter.ToString(g * step * i).Replace(",", ".") + ", " + Converter.ToString(b * step * i).Replace(",", ".") + ")"; 353 widget.BackgroundColor = shade; 354 } 355 } 356 357 <div class="dashboard @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 358 @foreach (var widget in widgets) 359 { 360 <div class="dashboard__widget"> 361 @Render(widget) 362 </div> 363 } 364 </div> 365 } 366 @using Dynamicweb.Rapido.Blocks.Components.General 367 @using Dynamicweb.Rapido.Blocks.Components 368 369 @helper RenderDashboardWidgetLink(DashboardWidgetLink settings) 370 { 371 if (!string.IsNullOrEmpty(settings.Link)) 372 { 373 var backgroundStyles = ""; 374 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 375 { 376 backgroundStyles = "style=\"background-color:" + settings.BackgroundColor + "\""; 377 } 378 379 <a href="@settings.Link" class="widget widget--link @settings.CssClass dw-mod" @backgroundStyles title="@settings.Title" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 380 <div class="u-center-middle u-color-light"> 381 @if (settings.Icon != null) 382 { 383 settings.Icon.CssClass += "widget__icon"; 384 @Render(settings.Icon) 385 } 386 <div class="widget__title">@settings.Title</div> 387 </div> 388 </a> 389 } 390 } 391 @using Dynamicweb.Rapido.Blocks.Components.General 392 @using Dynamicweb.Rapido.Blocks.Components 393 394 @helper RenderDashboardWidgetCounter(DashboardWidgetCounter settings) 395 { 396 var backgroundStyles = ""; 397 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 398 { 399 backgroundStyles = "style='background-color:" + settings.BackgroundColor + "'"; 400 } 401 402 <div class="widget @settings.CssClass dw-mod" @backgroundStyles @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 403 <div class="u-center-middle u-color-light"> 404 @if (settings.Icon != null) 405 { 406 settings.Icon.CssClass += "widget__icon"; 407 @Render(settings.Icon) 408 } 409 <div class="widget__counter">@settings.Count</div> 410 <div class="widget__title">@settings.Title</div> 411 </div> 412 </div> 413 } 414 @using System.Reflection 415 @using Dynamicweb.Rapido.Blocks.Components.General 416 @using Dynamicweb.Rapido.Blocks.Components 417 @using Dynamicweb.Core 418 419 @* Component *@ 420 421 @helper RenderLink(Link settings) 422 { 423 if (settings != null && !string.IsNullOrEmpty(settings.Href) && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 424 { 425 Dictionary<string, string> attributes = new Dictionary<string, string>(); 426 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 427 if (settings.Disabled) 428 { 429 attributes.Add("disabled", "true"); 430 classList.Add("disabled"); 431 } 432 433 if (!string.IsNullOrEmpty(settings.AltText)) 434 { 435 attributes.Add("title", settings.AltText); 436 } 437 else if (!string.IsNullOrEmpty(settings.Title)) 438 { 439 attributes.Add("title", settings.Title); 440 } 441 442 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 443 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 444 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onClick", settings.OnClick); } 445 attributes.Add("href", settings.Href); 446 447 if (settings.ButtonLayout != ButtonLayout.None) 448 { 449 classList.Add("btn"); 450 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 451 if (btnLayout == "linkclean") 452 { 453 btnLayout = "link-clean"; //fix 454 } 455 classList.Add("btn--" + btnLayout); 456 } 457 458 if (settings.Icon == null) 459 { 460 settings.Icon = new Icon(); 461 } 462 settings.Icon.Label = settings.Title; 463 464 if (settings.Target == LinkTargetType.Blank && settings.Rel == LinkRelType.None) 465 { 466 settings.Rel = LinkRelType.Noopener; 467 } 468 if (settings.Target != LinkTargetType.None) 469 { 470 attributes.Add("target", "_" + Enum.GetName(typeof(LinkTargetType), settings.Target).ToLower()); 471 } 472 if (settings.Download) 473 { 474 attributes.Add("download", "true"); 475 } 476 if (settings.Rel != LinkRelType.None) 477 { 478 attributes.Add("rel", Enum.GetName(typeof(LinkRelType), settings.Rel).ToLower()); 479 } 480 481 <a class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</a> 482 } 483 } 484 @using System.Reflection 485 @using Dynamicweb.Rapido.Blocks.Components 486 @using Dynamicweb.Rapido.Blocks.Components.General 487 @using Dynamicweb.Rapido.Blocks 488 489 490 @* Component *@ 491 492 @helper RenderRating(Rating settings) 493 { 494 if (settings.Score > 0) 495 { 496 int rating = settings.Score; 497 string iconType = "fa-star"; 498 499 switch (settings.Type.ToString()) { 500 case "Stars": 501 iconType = "fa-star"; 502 break; 503 case "Hearts": 504 iconType = "fa-heart"; 505 break; 506 case "Lemons": 507 iconType = "fa-lemon"; 508 break; 509 case "Bombs": 510 iconType = "fa-bomb"; 511 break; 512 } 513 514 <div class="u-ta-right"> 515 @for (int i = 0; i < settings.OutOf; i++) 516 { 517 <i class="@(rating > i ? "fas" : "far") @iconType"></i> 518 } 519 </div> 520 } 521 } 522 @using System.Reflection 523 @using Dynamicweb.Rapido.Blocks.Components.General 524 @using Dynamicweb.Rapido.Blocks.Components 525 526 527 @* Component *@ 528 529 @helper RenderSelectFieldOption(SelectFieldOption settings) 530 { 531 Dictionary<string, string> attributes = new Dictionary<string, string>(); 532 if (settings.Checked) { attributes.Add("selected", "true"); } 533 if (settings.Disabled) { attributes.Add("disabled", "true"); } 534 if (settings.Value != null) { attributes.Add("value", settings.Value); } 535 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 536 537 <option @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Label</option> 538 } 539 @using System.Reflection 540 @using Dynamicweb.Rapido.Blocks.Components.General 541 @using Dynamicweb.Rapido.Blocks.Components 542 543 544 @* Component *@ 545 546 @helper RenderNavigation(Navigation settings) { 547 @RenderNavigation(new 548 { 549 id = settings.Id, 550 cssclass = settings.CssClass, 551 startLevel = settings.StartLevel, 552 endlevel = settings.EndLevel, 553 expandmode = settings.Expandmode, 554 sitemapmode = settings.SitemapMode, 555 template = settings.Template 556 }) 557 } 558 @using Dynamicweb.Rapido.Blocks.Components.General 559 @using Dynamicweb.Rapido.Blocks.Components 560 561 562 @* Component *@ 563 564 @helper RenderBreadcrumbNavigation(BreadcrumbNavigation settings) { 565 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 566 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 567 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 568 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 569 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 570 settings.SitemapMode = false; 571 572 @RenderNavigation(settings) 573 } 574 @using Dynamicweb.Rapido.Blocks.Components.General 575 @using Dynamicweb.Rapido.Blocks.Components 576 577 578 @* Component *@ 579 580 @helper RenderLeftNavigation(LeftNavigation settings) { 581 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 582 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 583 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 584 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 585 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 586 587 <div class="grid__cell"> 588 @RenderNavigation(settings) 589 </div> 590 } 591 @using System.Reflection 592 @using Dynamicweb.Rapido.Blocks.Components.General 593 @using Dynamicweb.Core 594 595 @* Component *@ 596 597 @helper RenderHeading(Heading settings) 598 { 599 if (settings != null && !string.IsNullOrEmpty(settings.Title)) 600 { 601 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 602 string tagName = settings.Level != 0 ? "h" + settings.Level.ToString() : "div"; 603 604 @("<" + tagName + " class=\"" + settings.CssClass + " dw-mod\" " + color + ">") 605 if (!string.IsNullOrEmpty(settings.Link)) 606 { 607 @Render(new Link { Href = settings.Link, Icon = settings.Icon, Title = settings.Title, ButtonLayout = ButtonLayout.None }) 608 } 609 else 610 { 611 if (settings.Icon == null) 612 { 613 settings.Icon = new Icon(); 614 } 615 settings.Icon.Label = settings.Title; 616 @Render(settings.Icon) 617 } 618 @("</" + tagName + ">"); 619 } 620 } 621 @using Dynamicweb.Rapido.Blocks.Components 622 @using Dynamicweb.Rapido.Blocks.Components.General 623 @using Dynamicweb.Rapido.Blocks 624 625 626 @* Component *@ 627 628 @helper RenderImage(Image settings) 629 { 630 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None) 631 { 632 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 633 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); } 634 635 if (settings.Caption != null) 636 { 637 @:<div> 638 } 639 640 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower(); 641 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower(); 642 643 <div class="image-filter image-filter--@primaryFilterClass u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)> 644 <div class="image-filter image-filter--@secondaryFilterClass dw-mod"> 645 @if (settings.Link != null) 646 { 647 <a href="@settings.Link"> 648 @RenderTheImage(settings) 649 </a> 650 } 651 else 652 { 653 @RenderTheImage(settings) 654 } 655 </div> 656 </div> 657 658 if (settings.Caption != null) 659 { 660 <span class="image-caption dw-mod">@settings.Caption</span> 661 @:</div> 662 } 663 } 664 else 665 { 666 if (settings.Caption != null) 667 { 668 @:<div> 669 } 670 if (!string.IsNullOrEmpty(settings.Link)) 671 { 672 <a href="@settings.Link"> 673 @RenderTheImage(settings) 674 </a> 675 } 676 else 677 { 678 @RenderTheImage(settings) 679 } 680 681 if (settings.Caption != null) 682 { 683 <span class="image-caption dw-mod">@settings.Caption</span> 684 @:</div> 685 } 686 } 687 } 688 689 @helper RenderTheImage(Image settings) 690 { 691 if (settings != null) 692 { 693 string placeholderImage = "/Files/Images/placeholder.gif"; 694 string imageEngine = "/Admin/Public/GetImage.ashx?"; 695 696 string imageStyle = ""; 697 698 switch (settings.Style) 699 { 700 case ImageStyle.Ball: 701 imageStyle = "grid__cell-img--ball"; 702 break; 703 } 704 705 if (settings.Style == ImageStyle.Ball || settings.Style == ImageStyle.Circle) 706 { 707 if (settings.ImageDefault != null) 708 { 709 settings.ImageDefault.Height = settings.ImageDefault.Width; 710 } 711 if (settings.ImageMedium != null) 712 { 713 settings.ImageMedium.Height = settings.ImageMedium.Width; 714 } 715 if (settings.ImageSmall != null) 716 { 717 settings.ImageSmall.Height = settings.ImageSmall.Width; 718 } 719 } 720 721 string defaultImage = imageEngine; 722 string imageSmall = ""; 723 string imageMedium = ""; 724 725 if (settings.DisableImageEngine) 726 { 727 defaultImage = settings.Path; 728 } 729 else 730 { 731 if (settings.ImageDefault != null) 732 { 733 defaultImage += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageDefault); 734 735 if (settings.Path.GetType() != typeof(string)) 736 { 737 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 738 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 739 } 740 else 741 { 742 defaultImage += settings.Path != null ? "Image=" + settings.Path : ""; 743 } 744 } 745 746 if (settings.ImageSmall != null) 747 { 748 imageSmall = "data-src-small=\"" + imageEngine; 749 imageSmall += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageSmall); 750 751 if (settings.Path.GetType() != typeof(string)) 752 { 753 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 754 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 755 } 756 else 757 { 758 imageSmall += settings.Path != null ? "Image=" + settings.Path : ""; 759 } 760 761 imageSmall += "\""; 762 } 763 764 if (settings.ImageMedium != null) 765 { 766 imageMedium = "data-src-medium=\"" + imageEngine; 767 imageMedium += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageMedium); 768 769 if (settings.Path.GetType() != typeof(string)) 770 { 771 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 772 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 773 } 774 else 775 { 776 imageMedium += settings.Path != null ? "Image=" + settings.Path : ""; 777 } 778 779 imageMedium += "\""; 780 } 781 } 782 783 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 784 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); } 785 if (!string.IsNullOrEmpty(settings.Title)) 786 { 787 optionalAttributes.Add("alt", settings.Title); 788 optionalAttributes.Add("title", settings.Title); 789 } 790 791 if (settings.DisableLazyLoad) 792 { 793 <img id="@settings.Id" class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 794 } 795 else 796 { 797 <img id="@settings.Id" class="b-lazy @imageStyle @settings.CssClass dw-mod" src="@placeholderImage" data-src="@defaultImage" @imageSmall @imageMedium @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 798 } 799 } 800 } 801 @using System.Reflection 802 @using Dynamicweb.Rapido.Blocks.Components.General 803 @using Dynamicweb.Rapido.Blocks.Components 804 805 @* Component *@ 806 807 @helper RenderFileField(FileField settings) 808 { 809 var attributes = new Dictionary<string, string>(); 810 if (string.IsNullOrEmpty(settings.Id)) 811 { 812 settings.Id = Guid.NewGuid().ToString("N"); 813 } 814 815 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 816 if (settings.Disabled) { attributes.Add("disabled", "true"); } 817 if (settings.Required) { attributes.Add("required", "true"); } 818 if (settings.Multiple) { attributes.Add("multiple", "true"); } 819 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 820 if (string.IsNullOrEmpty(settings.ChooseFileText)) 821 { 822 settings.ChooseFileText = Translate("Choose file"); 823 } 824 if (string.IsNullOrEmpty(settings.NoFilesChosenText)) 825 { 826 settings.NoFilesChosenText = Translate("No files chosen..."); 827 } 828 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 829 830 string setValueToFakeInput = "FileUpload.setValueToFakeInput(this)"; 831 attributes.Add("onchange", setValueToFakeInput + (!string.IsNullOrEmpty(settings.OnChange) ? settings.OnChange : "")); 832 833 attributes.Add("type", "file"); 834 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 835 settings.CssClass = "u-full-width " + settings.CssClass; 836 837 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 838 839 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 840 @if (!string.IsNullOrEmpty(settings.Label)) 841 { 842 <label for="@settings.Id">@settings.Label</label> 843 } 844 @if (!string.IsNullOrEmpty(settings.HelpText)) 845 { 846 <small class="form__help-text">@settings.HelpText</small> 847 } 848 849 <div class="form__field-combi file-input u-no-margin dw-mod"> 850 <input @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" /> 851 <label for="@settings.Id" class="file-input__btn btn--secondary btn dw-mod">@settings.ChooseFileText</label> 852 <label for="@settings.Id" class="@settings.CssClass file-input__fake-input js-fake-input dw-mod">@settings.NoFilesChosenText</label> 853 @if (settings.UploadButton != null) 854 { 855 settings.UploadButton.CssClass += " btn--condensed u-no-margin"; 856 @Render(settings.UploadButton) 857 } 858 </div> 859 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 860 </div> 861 } 862 @using System.Reflection 863 @using Dynamicweb.Rapido.Blocks.Components.General 864 @using Dynamicweb.Rapido.Blocks.Components 865 @using Dynamicweb.Core 866 @using System.Linq 867 868 @* Component *@ 869 870 @helper RenderDateTimeField(DateTimeField settings) 871 { 872 if (string.IsNullOrEmpty(settings.Id)) 873 { 874 settings.Id = Guid.NewGuid().ToString("N"); 875 } 876 877 var textField = new TextField { 878 Name = settings.Name, 879 Id = settings.Id, 880 Label = settings.Label, 881 HelpText = settings.HelpText, 882 Value = settings.Value, 883 Disabled = settings.Disabled, 884 Required = settings.Required, 885 ErrorMessage = settings.ErrorMessage, 886 CssClass = settings.CssClass, 887 WrapperCssClass = settings.WrapperCssClass, 888 OnChange = settings.OnChange, 889 OnClick = settings.OnClick, 890 ExtraAttributes = settings.ExtraAttributes, 891 // 892 Placeholder = settings.Placeholder 893 }; 894 895 @Render(textField) 896 897 List<string> jsAttributes = new List<string>(); 898 899 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 900 901 if (!string.IsNullOrEmpty(settings.DateFormat)) 902 { 903 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 904 } 905 if (!string.IsNullOrEmpty(settings.MinDate)) 906 { 907 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 908 } 909 if (!string.IsNullOrEmpty(settings.MaxDate)) 910 { 911 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 912 } 913 if (settings.IsInline) 914 { 915 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 916 } 917 if (settings.EnableTime) 918 { 919 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 920 } 921 if (settings.EnableWeekNumbers) 922 { 923 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 924 } 925 926 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 927 928 <script> 929 document.addEventListener("DOMContentLoaded", function () { 930 flatpickr("#@textField.Id", { 931 @string.Join(",", jsAttributes) 932 }); 933 }); 934 </script> 935 } 936 @using System.Reflection 937 @using Dynamicweb.Rapido.Blocks.Components.General 938 @using Dynamicweb.Rapido.Blocks.Components 939 940 @* Component *@ 941 942 @helper RenderTextField(TextField settings) 943 { 944 var attributes = new Dictionary<string, string>(); 945 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 946 { 947 settings.Id = Guid.NewGuid().ToString("N"); 948 } 949 950 /*base settings*/ 951 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 952 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 953 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 954 if (settings.Disabled) { attributes.Add("disabled", "true"); } 955 if (settings.Required) { attributes.Add("required", "true"); } 956 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 957 /*end*/ 958 959 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 960 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 961 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 962 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 963 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 964 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 965 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 966 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 967 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 968 settings.CssClass = "u-full-width " + settings.CssClass; 969 970 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 971 972 string noMargin = "u-no-margin"; 973 if (!settings.ReadOnly) { 974 noMargin = ""; 975 } 976 977 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 978 @if (!string.IsNullOrEmpty(settings.Label)) 979 { 980 <label for="@settings.Id">@settings.Label</label> 981 } 982 @if (!string.IsNullOrEmpty(settings.HelpText)) 983 { 984 <small class="form__help-text">@settings.HelpText</small> 985 } 986 987 @if (settings.ActionButton != null) 988 { 989 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 990 <div class="form__field-combi u-no-margin dw-mod"> 991 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 992 @Render(settings.ActionButton) 993 </div> 994 } 995 else 996 { 997 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 998 } 999 1000 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1001 </div> 1002 } 1003 @using System.Reflection 1004 @using Dynamicweb.Rapido.Blocks.Components.General 1005 @using Dynamicweb.Rapido.Blocks.Components 1006 1007 @* Component *@ 1008 1009 @helper RenderNumberField(NumberField settings) 1010 { 1011 var attributes = new Dictionary<string, string>(); 1012 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1013 { 1014 settings.Id = Guid.NewGuid().ToString("N"); 1015 } 1016 1017 /*base settings*/ 1018 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1019 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1020 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1021 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1022 if (settings.Required) { attributes.Add("required", "true"); } 1023 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1024 /*end*/ 1025 1026 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1027 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1028 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1029 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1030 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 1031 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 1032 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 1033 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 1034 attributes.Add("type", "number"); 1035 1036 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1037 1038 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1039 @if (!string.IsNullOrEmpty(settings.Label)) 1040 { 1041 <label for="@settings.Id">@settings.Label</label> 1042 } 1043 @if (!string.IsNullOrEmpty(settings.HelpText)) 1044 { 1045 <small class="form__help-text">@settings.HelpText</small> 1046 } 1047 1048 @if (settings.ActionButton != null) 1049 { 1050 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1051 <div class="form__field-combi u-no-margin dw-mod"> 1052 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1053 @Render(settings.ActionButton) 1054 </div> 1055 } 1056 else 1057 { 1058 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1059 } 1060 1061 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1062 </div> 1063 } 1064 @using System.Reflection 1065 @using Dynamicweb.Rapido.Blocks.Components.General 1066 @using Dynamicweb.Rapido.Blocks.Components 1067 1068 1069 @* Component *@ 1070 1071 @helper RenderTextareaField(TextareaField settings) 1072 { 1073 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1074 string id = settings.Id; 1075 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id)) 1076 { 1077 id = Guid.NewGuid().ToString("N"); 1078 } 1079 1080 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); } 1081 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1082 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1083 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1084 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1085 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1086 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1087 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1088 if (settings.Required) { attributes.Add("required", "true"); } 1089 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1090 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1091 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); } 1092 attributes.Add("name", settings.Name); 1093 1094 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1095 @if (!string.IsNullOrEmpty(settings.Label)) 1096 { 1097 <label for="@id">@settings.Label</label> 1098 } 1099 @if (!string.IsNullOrEmpty(settings.HelpText)) 1100 { 1101 <small class="form__help-text">@settings.HelpText</small> 1102 } 1103 1104 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 1105 1106 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1107 </div> 1108 } 1109 @using System.Reflection 1110 @using Dynamicweb.Rapido.Blocks.Components.General 1111 @using Dynamicweb.Rapido.Blocks.Components 1112 1113 1114 @* Component *@ 1115 1116 @helper RenderHiddenField(HiddenField settings) { 1117 var attributes = new Dictionary<string, string>(); 1118 attributes.Add("type", "hidden"); 1119 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1120 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1121 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1122 1123 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 1124 } 1125 @using System.Reflection 1126 @using Dynamicweb.Rapido.Blocks.Components.General 1127 @using Dynamicweb.Rapido.Blocks.Components 1128 1129 @* Component *@ 1130 1131 @helper RenderCheckboxField(CheckboxField settings) 1132 { 1133 var attributes = new Dictionary<string, string>(); 1134 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1135 { 1136 settings.Id = Guid.NewGuid().ToString("N"); 1137 } 1138 1139 /*base settings*/ 1140 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1141 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1142 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1143 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1144 if (settings.Required) { attributes.Add("required", "true"); } 1145 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1146 /*end*/ 1147 1148 attributes.Add("type", "checkbox"); 1149 if (settings.Checked) { attributes.Add("checked", "true"); } 1150 settings.CssClass = "form__control " + settings.CssClass; 1151 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1152 1153 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1154 1155 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1156 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1157 @if (!string.IsNullOrEmpty(settings.Label)) 1158 { 1159 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1160 } 1161 @if (!string.IsNullOrEmpty(settings.HelpText)) 1162 { 1163 <small class="form__help-text">@settings.HelpText</small> 1164 } 1165 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1166 </div> 1167 } 1168 @using System.Reflection 1169 @using Dynamicweb.Rapido.Blocks.Components.General 1170 @using Dynamicweb.Rapido.Blocks.Components 1171 1172 1173 @* Component *@ 1174 1175 @helper RenderCheckboxListField(CheckboxListField settings) 1176 { 1177 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1178 @if (!string.IsNullOrEmpty(settings.Label)) 1179 { 1180 <label>@settings.Label</label> 1181 } 1182 @if (!string.IsNullOrEmpty(settings.HelpText)) 1183 { 1184 <small class="form__help-text">@settings.HelpText</small> 1185 } 1186 1187 @foreach (var item in settings.Options) 1188 { 1189 if (settings.Required) 1190 { 1191 item.Required = true; 1192 } 1193 if (settings.Disabled) 1194 { 1195 item.Disabled = true; 1196 } 1197 if (!string.IsNullOrEmpty(settings.Name)) 1198 { 1199 item.Name = settings.Name; 1200 } 1201 if (!string.IsNullOrEmpty(settings.CssClass)) 1202 { 1203 item.CssClass += settings.CssClass; 1204 } 1205 1206 /* value is not supported */ 1207 1208 if (!string.IsNullOrEmpty(settings.OnClick)) 1209 { 1210 item.OnClick += settings.OnClick; 1211 } 1212 if (!string.IsNullOrEmpty(settings.OnChange)) 1213 { 1214 item.OnChange += settings.OnChange; 1215 } 1216 @Render(item) 1217 } 1218 1219 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1220 </div> 1221 } 1222 @using System.Reflection 1223 @using Dynamicweb.Rapido.Blocks.Components.General 1224 @using Dynamicweb.Rapido.Blocks.Components 1225 1226 1227 @* Component *@ 1228 1229 @helper RenderSelectField(SelectField settings) 1230 { 1231 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1232 { 1233 settings.Id = Guid.NewGuid().ToString("N"); 1234 } 1235 1236 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1237 @if (!string.IsNullOrEmpty(settings.Label)) 1238 { 1239 <label for="@settings.Id">@settings.Label</label> 1240 } 1241 @if (!string.IsNullOrEmpty(settings.HelpText)) 1242 { 1243 <small class="form__help-text">@settings.HelpText</small> 1244 } 1245 1246 @if (settings.ActionButton != null) 1247 { 1248 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1249 <div class="form__field-combi u-no-margin dw-mod"> 1250 @RenderSelectBase(settings) 1251 @Render(settings.ActionButton) 1252 </div> 1253 } 1254 else 1255 { 1256 @RenderSelectBase(settings) 1257 } 1258 1259 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1260 </div> 1261 } 1262 1263 @helper RenderSelectBase(SelectField settings) 1264 { 1265 var attributes = new Dictionary<string, string>(); 1266 1267 /*base settings*/ 1268 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1269 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1270 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1271 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1272 if (settings.Required) { attributes.Add("required", "true"); } 1273 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1274 /*end*/ 1275 1276 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1277 1278 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 1279 @if (settings.Default != null) 1280 { 1281 @Render(settings.Default) 1282 } 1283 1284 @foreach (var item in settings.Options) 1285 { 1286 if (!string.IsNullOrEmpty(settings.Value)) { 1287 item.Checked = item.Value == settings.Value; 1288 } 1289 @Render(item) 1290 } 1291 </select> 1292 } 1293 @using System.Reflection 1294 @using Dynamicweb.Rapido.Blocks.Components.General 1295 @using Dynamicweb.Rapido.Blocks.Components 1296 1297 @* Component *@ 1298 1299 @helper RenderRadioButtonField(RadioButtonField settings) 1300 { 1301 var attributes = new Dictionary<string, string>(); 1302 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1303 { 1304 settings.Id = Guid.NewGuid().ToString("N"); 1305 } 1306 1307 /*base settings*/ 1308 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1309 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1310 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1311 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1312 if (settings.Required) { attributes.Add("required", "true"); } 1313 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1314 /*end*/ 1315 1316 attributes.Add("type", "radio"); 1317 if (settings.Checked) { attributes.Add("checked", "true"); } 1318 settings.CssClass = "form__control " + settings.CssClass; 1319 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1320 1321 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1322 1323 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1324 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1325 @if (!string.IsNullOrEmpty(settings.Label)) 1326 { 1327 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1328 } 1329 @if (!string.IsNullOrEmpty(settings.HelpText)) 1330 { 1331 <small class="form__help-text">@settings.HelpText</small> 1332 } 1333 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1334 </div> 1335 } 1336 @using System.Reflection 1337 @using Dynamicweb.Rapido.Blocks.Components.General 1338 @using Dynamicweb.Rapido.Blocks.Components 1339 1340 1341 @* Component *@ 1342 1343 @helper RenderRadioButtonListField(RadioButtonListField settings) 1344 { 1345 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1346 @if (!string.IsNullOrEmpty(settings.Label)) 1347 { 1348 <label>@settings.Label</label> 1349 } 1350 @if (!string.IsNullOrEmpty(settings.HelpText)) 1351 { 1352 <small class="form__help-text">@settings.HelpText</small> 1353 } 1354 1355 @foreach (var item in settings.Options) 1356 { 1357 if (settings.Required) 1358 { 1359 item.Required = true; 1360 } 1361 if (settings.Disabled) 1362 { 1363 item.Disabled = true; 1364 } 1365 if (!string.IsNullOrEmpty(settings.Name)) 1366 { 1367 item.Name = settings.Name; 1368 } 1369 if (!string.IsNullOrEmpty(settings.Value) && settings.Value == item.Value) 1370 { 1371 item.Checked = true; 1372 } 1373 if (!string.IsNullOrEmpty(settings.OnClick)) 1374 { 1375 item.OnClick += settings.OnClick; 1376 } 1377 if (!string.IsNullOrEmpty(settings.OnChange)) 1378 { 1379 item.OnChange += settings.OnChange; 1380 } 1381 if (!string.IsNullOrEmpty(settings.CssClass)) 1382 { 1383 item.CssClass += settings.CssClass; 1384 } 1385 @Render(item) 1386 } 1387 1388 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1389 </div> 1390 } 1391 @using System.Reflection 1392 @using Dynamicweb.Rapido.Blocks.Components.General 1393 @using Dynamicweb.Rapido.Blocks.Components 1394 1395 1396 @* Component *@ 1397 1398 @helper RenderNotificationMessage(NotificationMessage settings) 1399 { 1400 if (!string.IsNullOrEmpty(settings.Message)) 1401 { 1402 var attributes = new Dictionary<string, string>(); 1403 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1404 1405 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 1406 <div class="field-@messageTypeClass @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)>@settings.Message</div> 1407 } 1408 } 1409 @using Dynamicweb.Rapido.Blocks.Components.General 1410 1411 1412 @* Component *@ 1413 1414 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 1415 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 1416 1417 <div class="@settings.CssClass dw-mod js-handlebars-root" id="@settings.Id" data-template="@settings.ScriptTemplate" data-json-feed="@settings.FeedUrl" data-init-onload="@settings.InitOnLoad.ToString()" data-preloader="@settings.Preloader" @preRender> 1418 @if (settings.SubBlocks != null) { 1419 @RenderBlockList(settings.SubBlocks) 1420 } 1421 </div> 1422 } 1423 @using System.Reflection 1424 @using Dynamicweb.Rapido.Blocks.Components.General 1425 @using Dynamicweb.Rapido.Blocks.Components 1426 @using System.Text.RegularExpressions 1427 1428 1429 @* Component *@ 1430 1431 @helper RenderSticker(Sticker settings) { 1432 if (!String.IsNullOrEmpty(settings.Title)) { 1433 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 1434 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 1435 1436 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 1437 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 1438 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 1439 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 1440 optionalAttributes.Add("style", styleTag); 1441 } 1442 1443 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 1444 } 1445 } 1446 1447 @using System.Reflection 1448 @using Dynamicweb.Rapido.Blocks.Components.General 1449 @using Dynamicweb.Rapido.Blocks.Components 1450 1451 1452 @* Component *@ 1453 1454 @helper RenderStickersCollection(StickersCollection settings) 1455 { 1456 if (settings.Stickers.Count > 0) 1457 { 1458 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 1459 1460 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1461 @foreach (Sticker sticker in settings.Stickers) 1462 { 1463 @Render(sticker) 1464 } 1465 </div> 1466 } 1467 } 1468 1469 @using Dynamicweb.Rapido.Blocks.Components.General 1470 1471 1472 @* Component *@ 1473 1474 @helper RenderForm(Form settings) { 1475 if (settings != null) 1476 { 1477 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1478 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 1479 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 1480 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 1481 var enctypes = new Dictionary<string, string> 1482 { 1483 { "multipart", "multipart/form-data" }, 1484 { "text", "text/plain" }, 1485 { "application", "application/x-www-form-urlencoded" } 1486 }; 1487 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 1488 optionalAttributes.Add("method", settings.Method.ToString()); 1489 1490 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 1491 { 1492 @settings.FormStartMarkup 1493 } 1494 else 1495 { 1496 @:<form class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1497 } 1498 1499 foreach (var field in settings.GetFields()) 1500 { 1501 @Render(field) 1502 } 1503 1504 @:</form> 1505 } 1506 } 1507 @using System.Reflection 1508 @using Dynamicweb.Rapido.Blocks.Components.General 1509 @using Dynamicweb.Rapido.Blocks.Components 1510 1511 1512 @* Component *@ 1513 1514 @helper RenderText(Text settings) 1515 { 1516 @settings.Content 1517 } 1518 @using System.Reflection 1519 @using Dynamicweb.Rapido.Blocks.Components.General 1520 @using Dynamicweb.Rapido.Blocks.Components 1521 1522 1523 @* Component *@ 1524 1525 @helper RenderContentModule(ContentModule settings) { 1526 if (!string.IsNullOrEmpty(settings.Content)) 1527 { 1528 @settings.Content 1529 } 1530 } 1531 @using System.Reflection 1532 @using Dynamicweb.Rapido.Blocks.Components.General 1533 @using Dynamicweb.Rapido.Blocks.Components 1534 1535 1536 @* Component *@ 1537 1538 @helper RenderModal(Modal settings) { 1539 if (settings != null) 1540 { 1541 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 1542 1543 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 1544 1545 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 1546 1547 <div class="modal-container"> 1548 @if (!settings.DisableDarkOverlay) 1549 { 1550 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 1551 } 1552 <div class="modal modal--@settings.Width.ToString().ToLower() modal-height--@settings.Height.ToString().ToLower()" id="@(modalId)Modal"> 1553 @if (settings.Heading != null) 1554 { 1555 if (!string.IsNullOrEmpty(settings.Heading.Title)) 1556 { 1557 <div class="modal__header"> 1558 @Render(settings.Heading) 1559 </div> 1560 } 1561 } 1562 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 1563 @if (!string.IsNullOrEmpty(settings.BodyText)) 1564 { 1565 @settings.BodyText 1566 } 1567 @if (settings.BodyTemplate != null) 1568 { 1569 @settings.BodyTemplate 1570 } 1571 @{ 1572 var actions = settings.GetActions(); 1573 } 1574 </div> 1575 @if (actions.Length > 0) 1576 { 1577 <div class="modal__footer"> 1578 @foreach (var action in actions) 1579 { 1580 action.CssClass += " u-no-margin"; 1581 @Render(action) 1582 } 1583 </div> 1584 } 1585 <label class="modal__close-btn" for="@(modalId)ModalTrigger"></label> 1586 </div> 1587 </div> 1588 } 1589 } 1590 @using Dynamicweb.Rapido.Blocks.Components.General 1591 1592 @* Component *@ 1593 1594 @helper RenderMediaListItem(MediaListItem settings) 1595 { 1596 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 1597 @if (!string.IsNullOrEmpty(settings.Label)) 1598 { 1599 if (!string.IsNullOrEmpty(settings.Link)) 1600 { 1601 @Render(new Link 1602 { 1603 Href = settings.Link, 1604 CssClass = "media-list-item__sticker dw-mod", 1605 ButtonLayout = ButtonLayout.None, 1606 Title = settings.Label, 1607 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1608 }) 1609 } 1610 else if (!string.IsNullOrEmpty(settings.OnClick)) 1611 { 1612 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 1613 <span class="u-uppercase">@settings.Label</span> 1614 </span> 1615 } 1616 else 1617 { 1618 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 1619 <span class="u-uppercase">@settings.Label</span> 1620 </span> 1621 } 1622 } 1623 <div class="media-list-item__wrap"> 1624 <div class="media-list-item__info dw-mod"> 1625 <div class="media-list-item__header dw-mod"> 1626 @if (!string.IsNullOrEmpty(settings.Title)) 1627 { 1628 if (!string.IsNullOrEmpty(settings.Link)) 1629 { 1630 @Render(new Link 1631 { 1632 Href = settings.Link, 1633 CssClass = "media-list-item__name dw-mod", 1634 ButtonLayout = ButtonLayout.None, 1635 Title = settings.Title, 1636 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1637 }) 1638 } 1639 else if (!string.IsNullOrEmpty(settings.OnClick)) 1640 { 1641 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 1642 } 1643 else 1644 { 1645 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 1646 } 1647 } 1648 1649 @if (!string.IsNullOrEmpty(settings.Status)) 1650 { 1651 <div class="media-list-item__state dw-mod">@settings.Status</div> 1652 } 1653 </div> 1654 @{ 1655 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 1656 } 1657 1658 @Render(settings.InfoTable) 1659 </div> 1660 <div class="media-list-item__actions dw-mod"> 1661 <div class="media-list-item__actions-list dw-mod"> 1662 @{ 1663 var actions = settings.GetActions(); 1664 1665 foreach (ButtonBase action in actions) 1666 { 1667 action.ButtonLayout = ButtonLayout.None; 1668 action.CssClass += " media-list-item__action link"; 1669 1670 @Render(action) 1671 } 1672 } 1673 </div> 1674 1675 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 1676 { 1677 settings.SelectButton.CssClass += " u-no-margin"; 1678 1679 <div class="media-list-item__action-button"> 1680 @Render(settings.SelectButton) 1681 </div> 1682 } 1683 </div> 1684 </div> 1685 </div> 1686 } 1687 @using Dynamicweb.Rapido.Blocks.Components.General 1688 @using Dynamicweb.Rapido.Blocks.Components 1689 1690 @helper RenderTable(Table settings) 1691 { 1692 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1693 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1694 1695 var enumToClasses = new Dictionary<TableDesign, string> 1696 { 1697 { TableDesign.Clean, "table--clean" }, 1698 { TableDesign.Bordered, "table--bordered" }, 1699 { TableDesign.Striped, "table--striped" }, 1700 { TableDesign.Hover, "table--hover" }, 1701 { TableDesign.Compact, "table--compact" }, 1702 { TableDesign.Condensed, "table--condensed" }, 1703 { TableDesign.NoTopBorder, "table--no-top-border" } 1704 }; 1705 string tableDesignClass = ""; 1706 if (settings.Design != TableDesign.None) 1707 { 1708 tableDesignClass = enumToClasses[settings.Design]; 1709 } 1710 1711 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 1712 1713 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1714 1715 <table @ComponentMethods.AddAttributes(resultAttributes)> 1716 @if (settings.Header != null) 1717 { 1718 <thead> 1719 @Render(settings.Header) 1720 </thead> 1721 } 1722 <tbody> 1723 @foreach (var row in settings.Rows) 1724 { 1725 @Render(row) 1726 } 1727 </tbody> 1728 @if (settings.Footer != null) 1729 { 1730 <tfoot> 1731 @Render(settings.Footer) 1732 </tfoot> 1733 } 1734 </table> 1735 } 1736 @using Dynamicweb.Rapido.Blocks.Components.General 1737 @using Dynamicweb.Rapido.Blocks.Components 1738 1739 @helper RenderTableRow(TableRow settings) 1740 { 1741 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1742 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1743 1744 var enumToClasses = new Dictionary<TableRowDesign, string> 1745 { 1746 { TableRowDesign.NoBorder, "table__row--no-border" }, 1747 { TableRowDesign.Border, "table__row--border" }, 1748 { TableRowDesign.TopBorder, "table__row--top-line" }, 1749 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 1750 { TableRowDesign.Solid, "table__row--solid" } 1751 }; 1752 1753 string tableRowDesignClass = ""; 1754 if (settings.Design != TableRowDesign.None) 1755 { 1756 tableRowDesignClass = enumToClasses[settings.Design]; 1757 } 1758 1759 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 1760 1761 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1762 1763 <tr @ComponentMethods.AddAttributes(resultAttributes)> 1764 @foreach (var cell in settings.Cells) 1765 { 1766 if (settings.IsHeaderRow) 1767 { 1768 cell.IsHeader = true; 1769 } 1770 @Render(cell) 1771 } 1772 </tr> 1773 } 1774 @using Dynamicweb.Rapido.Blocks.Components.General 1775 @using Dynamicweb.Rapido.Blocks.Components 1776 @using Dynamicweb.Core 1777 1778 @helper RenderTableCell(TableCell settings) 1779 { 1780 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1781 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1782 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 1783 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 1784 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 1785 1786 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1787 1788 string tagName = settings.IsHeader ? "th" : "td"; 1789 1790 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + ">") 1791 @settings.Content 1792 @("</" + tagName + ">"); 1793 } 1794 @using System.Linq 1795 @using Dynamicweb.Rapido.Blocks.Components.General 1796 1797 @* Component *@ 1798 1799 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 1800 { 1801 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 1802 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 1803 1804 if (settings.NumberOfPages > 1) 1805 { 1806 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 1807 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Page navigation"); 1808 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 1809 1810 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 1811 @if (settings.ShowPagingInfo) 1812 { 1813 <div class="pager__info dw-mod"> 1814 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 1815 </div> 1816 } 1817 <ul class="pager__list dw-mod"> 1818 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 1819 { 1820 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 1821 } 1822 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 1823 { 1824 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon }) 1825 } 1826 @if (settings.GetPages().Any()) 1827 { 1828 foreach (var page in settings.GetPages()) 1829 { 1830 @Render(page) 1831 } 1832 } 1833 else 1834 { 1835 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 1836 { 1837 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 1838 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 1839 } 1840 } 1841 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 1842 { 1843 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon }) 1844 } 1845 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 1846 { 1847 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 1848 } 1849 </ul> 1850 </div> 1851 } 1852 } 1853 1854 @helper RenderPaginationItem(PaginationItem settings) 1855 { 1856 if (settings.Icon == null) 1857 { 1858 settings.Icon = new Icon(); 1859 } 1860 1861 settings.Icon.Label = settings.Label; 1862 <li class="pager__btn dw-mod"> 1863 @if (settings.IsActive) 1864 { 1865 <span class="pager__num pager__num--current dw-mod"> 1866 @Render(settings.Icon) 1867 </span> 1868 } 1869 else 1870 { 1871 <a href="@settings.Link" class="pager__num dw-mod"> 1872 @Render(settings.Icon) 1873 </a> 1874 } 1875 </li> 1876 } 1877 1878 1879 @using Dynamicweb.Rapido.Blocks.Components.General 1880 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 1881 1882 @functions 1883 { 1884 public class CustomNumberField : FieldBase 1885 { 1886 public string Min { get; set; } 1887 public string Max { get; set; } 1888 public string Step { get; set; } 1889 public bool ReadOnly { get; set; } 1890 public string OnKeyUp { get; set; } 1891 public string OnKeyDown { get; set; } 1892 public string OnInput { get; set; } 1893 public string OnFocus { get; set; } 1894 public Button ActionButton { get; set; } 1895 } 1896 1897 public class CustomTextField : TextField 1898 { 1899 public string OnFocusOut { get; set; } 1900 } 1901 1902 public class AddToCartButtonLagersalg : AddToCartButton 1903 { 1904 public string Min { get; set; } 1905 public string Max { get; set; } 1906 public string Step { get; set; } 1907 public string Stock { get; set; } 1908 } 1909 } 1910 1911 @helper RenderCustomNumberField(CustomNumberField settings) 1912 { 1913 var attributes = new Dictionary<string, string>(); 1914 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1915 { 1916 settings.Id = Guid.NewGuid().ToString("N"); 1917 } 1918 1919 /*base settings*/ 1920 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1921 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1922 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1923 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1924 if (settings.Required) { attributes.Add("required", "true"); } 1925 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1926 /*end*/ 1927 1928 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1929 if (!string.IsNullOrEmpty(settings.OnKeyDown)) { attributes.Add("onkeydown", settings.OnKeyDown); } 1930 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1931 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1932 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1933 if (!string.IsNullOrEmpty(settings.Max)) { attributes.Add("max", settings.Max.ToString()); } 1934 if (!string.IsNullOrEmpty(settings.Min)) { attributes.Add("min", settings.Min.ToString()); } 1935 if (!string.IsNullOrEmpty(settings.Step)) { attributes.Add("step", settings.Step.ToString()); } 1936 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 1937 attributes.Add("type", "number"); 1938 1939 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1940 1941 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1942 @if (!string.IsNullOrEmpty(settings.Label)) 1943 { 1944 <label for="@settings.Id">@settings.Label</label> 1945 } 1946 @if (!string.IsNullOrEmpty(settings.HelpText)) 1947 { 1948 <small class="form__help-text">@settings.HelpText</small> 1949 } 1950 1951 @if (settings.ActionButton != null) 1952 { 1953 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1954 <div class="form__field-combi u-no-margin dw-mod"> 1955 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1956 @Render(settings.ActionButton) 1957 </div> 1958 } 1959 else 1960 { 1961 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1962 } 1963 1964 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1965 </div> 1966 } 1967 1968 1969 @helper RenderCustomTextField(CustomTextField settings) 1970 { 1971 var attributes = new Dictionary<string, string>(); 1972 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1973 { 1974 settings.Id = Guid.NewGuid().ToString("N"); 1975 } 1976 1977 /*base settings*/ 1978 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1979 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1980 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1981 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1982 if (settings.Required) { attributes.Add("required", "true"); } 1983 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1984 /*end*/ 1985 1986 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1987 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1988 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1989 if (!string.IsNullOrEmpty(settings.OnFocusOut)) { attributes.Add("onfocusout", settings.OnFocusOut); } 1990 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1991 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1992 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1993 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 1994 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 1995 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1996 settings.CssClass = "u-full-width " + settings.CssClass; 1997 1998 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1999 2000 string noMargin = "u-no-margin"; 2001 if (!settings.ReadOnly) 2002 { 2003 noMargin = ""; 2004 } 2005 2006 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 2007 @if (!string.IsNullOrEmpty(settings.Label)) 2008 { 2009 <label for="@settings.Id">@settings.Label</label> 2010 } 2011 @if (!string.IsNullOrEmpty(settings.HelpText)) 2012 { 2013 <small class="form__help-text">@settings.HelpText</small> 2014 } 2015 2016 @if (settings.ActionButton != null) 2017 { 2018 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 2019 <div class="form__field-combi u-no-margin dw-mod"> 2020 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 2021 @Render(settings.ActionButton) 2022 </div> 2023 } 2024 else 2025 { 2026 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 2027 } 2028 2029 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 2030 </div> 2031 } 2032 2033 @helper RenderAddToCartButtonLagersalg(AddToCartButtonLagersalg settings) 2034 { 2035 if (!settings.HideTitle) 2036 { 2037 if (string.IsNullOrEmpty(settings.Title)) 2038 { 2039 if (settings.BuyForPoints) 2040 { 2041 settings.Title = Translate("Buy with points"); 2042 } 2043 else 2044 { 2045 settings.Title = Translate("Add to cart"); 2046 } 2047 } 2048 } 2049 else 2050 { 2051 settings.Title = ""; 2052 } 2053 2054 if (settings.Icon == null) 2055 { 2056 settings.Icon = new Icon(); 2057 settings.Icon.LabelPosition = Dynamicweb.Rapido.Blocks.Components.General.IconLabelPosition.After; 2058 } 2059 2060 if (string.IsNullOrEmpty(settings.Icon.Name)) 2061 { 2062 settings.Icon.Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue; 2063 } 2064 2065 settings.OnClick = "Beirholm.AddToCart(event, { " + 2066 "id: '" + settings.ProductId + "'," + 2067 (!string.IsNullOrEmpty(settings.VariantId) ? "variantId: '" + settings.VariantId + "'," : "") + 2068 (!string.IsNullOrEmpty(settings.UnitId) ? "unitId: '" + settings.UnitId + "'," : "") + 2069 (settings.BuyForPoints ? "buyForPoints: true," : "") + 2070 (!string.IsNullOrEmpty(settings.ProductInfo) ? "productInfo: " + settings.ProductInfo + "," : "") + 2071 "quantity: " + (string.IsNullOrEmpty(settings.QuantitySelectorId) ? "1" : "parseFloat(document.getElementById('" + settings.QuantitySelectorId + "').value),") + 2072 "min: '" + settings.Min + "'," + 2073 "max: '" + settings.Max + "'," + 2074 "step: '" + settings.Step + "'," + 2075 "stock: '" + settings.Stock + "' });" + settings.OnClick; 2076 2077 @RenderButton(settings) 2078 } 2079 2080 @* Include the basic, re-used, paragraph initializer *@ 2081 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2082 @using Dynamicweb.Frontend 2083 @using Dynamicweb.Rapido.Blocks.Components.General 2084 @using Dynamicweb.Rapido.Blocks.Components 2085 2086 @functions { 2087 public class ContentParagraph 2088 { 2089 public string Title { get; set; } 2090 public Image Image { get; set; } 2091 public string Text { get; set; } 2092 public string Link { get; set; } 2093 public bool SetImageAsBackground { get; set; } 2094 public bool HideOuterPadding { get; set; } 2095 public string InnerPaddingCss { get; set; } 2096 public string CardCss { get; set; } 2097 public string ButtonWrapperCss { get; set; } 2098 public string Layout { get; set; } 2099 public string Module { get; set; } 2100 public Link ButtonPrimary { get; set; } 2101 public Link ButtonSecondary { get; set; } 2102 } 2103 } 2104 2105 @helper RenderParagraph(ItemViewModel item, bool renderModule = true) 2106 { 2107 if (item != null) { 2108 string layout = item.GetList("ContentPositions").SelectedValue; 2109 2110 string paragraphClasses = ""; 2111 string paragraphWidth = !String.IsNullOrEmpty(item.GetString("Width")) ? item.GetList("Width").SelectedValue : "12"; 2112 paragraphClasses += " grid__col-lg-" + paragraphWidth + " grid__col-md-" + paragraphWidth + " grid__col-sm-" + paragraphWidth; 2113 if (item.GetList("WidthMobile").SelectedValue == "hide") 2114 { 2115 paragraphClasses += " u-hidden-xs"; 2116 } 2117 else 2118 { 2119 paragraphClasses += " grid__col-xs-" + item.GetList("WidthMobile").SelectedValue; 2120 } 2121 paragraphClasses += item.GetBoolean("HidePadding") ? " paragraph-container--no-padding" : ""; 2122 paragraphClasses += layout == "middle-center" || layout == "middle-left" ? " u-middle-horizontal grid--justify-center grid--align-self-center" : ""; 2123 2124 //Alternative Design Layout 2125 var designLayout = Model.Item.GetItem("CustomSettings") != null ? Model.Item.GetItem("CustomSettings").GetString("DesignLayout") != null ? Model.Item.GetItem("CustomSettings").GetList("DesignLayout").SelectedValue : "" : ""; 2126 paragraphClasses += !String.IsNullOrEmpty(designLayout) ? designLayout : ""; 2127 2128 string title = item.GetBoolean("ShowTitle") ? item.GetString("Title") : ""; 2129 string cardClass = item.GetBoolean("ShowAsCard") ? "paragraph-card" : ""; 2130 string buttonSpacing = ""; 2131 string buttonAlignment = layout == "all-centered" || layout == "middle-center" ? "grid--justify-center" : ""; 2132 2133 string image = item.GetFile("Image") != null ? item.GetFile("Image").ToString() + "&" + item.GetFile("Image").GetFocalPointParameters() : ""; 2134 int cropMode = !String.IsNullOrEmpty(Converter.ToString(item.GetList("ImageCrop"))) ? Convert.ToInt32(item.GetList("ImageCrop").SelectedValue) : 0; 2135 ImageStyle imageStyle = item.GetList("ImageStyle").SelectedValue == "ball" ? ImageStyle.Ball : ImageStyle.None; 2136 ButtonLayout primaryButtonLayout = !String.IsNullOrEmpty(item.GetList("ButtonDesign").SelectedValue) ? (ButtonLayout)System.Enum.Parse(typeof(ButtonLayout), char.ToUpper(item.GetList("ButtonDesign").SelectedValue[0]) + item.GetList("ButtonDesign").SelectedValue.Substring(1)) : ButtonLayout.Primary; 2137 if (primaryButtonLayout == ButtonLayout.Link) 2138 { 2139 primaryButtonLayout = ButtonLayout.LinkClean; 2140 } 2141 ButtonLayout secondaryButtonLayout = !String.IsNullOrEmpty(item.GetList("SecondaryButtonDesign").SelectedValue) ? (ButtonLayout)System.Enum.Parse(typeof(ButtonLayout), char.ToUpper(item.GetList("SecondaryButtonDesign").SelectedValue[0]) + item.GetList("SecondaryButtonDesign").SelectedValue.Substring(1)) : ButtonLayout.Secondary; 2142 if (secondaryButtonLayout == ButtonLayout.Link) 2143 { 2144 secondaryButtonLayout = ButtonLayout.LinkClean; 2145 } 2146 ImageFilter primaryImageFilter = !string.IsNullOrEmpty(item.GetList("ImageFilterPrimary").SelectedValue) ? (ImageFilter) Enum.Parse(typeof(ImageFilter), item.GetList("ImageFilterPrimary").SelectedValue.Replace("-", ""), true) : ImageFilter.None; 2147 ImageFilter secondaryImageFilter = !string.IsNullOrEmpty(item.GetList("ImageFilterSecondary").SelectedValue) ? (ImageFilter) Enum.Parse(typeof(ImageFilter), item.GetList("ImageFilterSecondary").SelectedValue.Replace("-", ""), true) : ImageFilter.None; 2148 string imageFilterColorCode = item.GetString("ColorForTheFilter").StartsWith("#") && primaryImageFilter == ImageFilter.Colorize ? GenerateRgba(item.GetString("ColorForTheFilter"), 0.3) : ""; 2149 bool setImageAsBackground = item.GetList("ImageStyle").SelectedValue.ToLower() == "background" ? true : false; 2150 2151 Image paragraphImage = null; 2152 if (!String.IsNullOrEmpty(image)) 2153 { 2154 paragraphImage = new Image 2155 { 2156 Path = image, 2157 Link = item.GetString("Link"), 2158 FilterPrimary = primaryImageFilter, 2159 FilterSecondary = secondaryImageFilter, 2160 FilterColor = imageFilterColorCode, 2161 Style = imageStyle, 2162 ImageDefault = new ImageSettings 2163 { 2164 Crop = cropMode, 2165 Height = 845, 2166 Width = 1920 2167 }, 2168 ImageMedium = new ImageSettings 2169 { 2170 Crop = cropMode, 2171 Height = 450, 2172 Width = 1024 2173 }, 2174 ImageSmall = new ImageSettings 2175 { 2176 Crop = cropMode, 2177 Height = 544, 2178 Width = 640 2179 } 2180 }; 2181 } 2182 2183 ContentParagraph paragraph = new ContentParagraph 2184 { 2185 Title = title, 2186 Text = item.GetString("Text"), 2187 Image = paragraphImage, 2188 Link = item.GetString("Link"), 2189 Module = !String.IsNullOrEmpty(Model.GetModuleOutput()) && renderModule ? Model.GetModuleOutput() : "", 2190 InnerPaddingCss = item.GetList("InnerPadding") != null ? "paragraph-container__body--padding-" + item.GetList("InnerPadding").SelectedValue : "", 2191 CardCss = cardClass, 2192 HideOuterPadding = item.GetBoolean("HidePadding"), 2193 SetImageAsBackground = item.GetList("ImageStyle").SelectedValue.ToLower() == "background" ? true : false, 2194 ButtonWrapperCss = buttonSpacing + buttonAlignment, 2195 Layout = layout 2196 }; 2197 2198 if (!String.IsNullOrEmpty(item.GetString("Link"))) 2199 { 2200 paragraph.ButtonPrimary = new Link 2201 { 2202 Href = item.GetString("Link"), 2203 Title = item.GetString("LinkText"), 2204 ButtonLayout = primaryButtonLayout, 2205 CssClass = "u-no-margin" 2206 }; 2207 2208 if (!String.IsNullOrEmpty(item.GetString("SecondaryLink"))) { 2209 paragraph.ButtonPrimary.CssClass = ""; 2210 } 2211 } 2212 2213 if (!String.IsNullOrEmpty(item.GetString("SecondaryLink"))) 2214 { 2215 if (!String.IsNullOrEmpty(item.GetString("Link"))) 2216 { 2217 paragraph.ButtonPrimary.CssClass += " u-margin-right--lg"; 2218 } 2219 2220 paragraph.ButtonSecondary = new Link 2221 { 2222 Href = item.GetString("SecondaryLink"), 2223 Title = item.GetString("SecondaryLinkText"), 2224 ButtonLayout = secondaryButtonLayout 2225 }; 2226 } 2227 2228 <div class="paragraph-container @paragraphClasses dw-mod"> 2229 @if (setImageAsBackground == true && paragraphImage != null) 2230 { 2231 paragraphImage.CssClass = "background-image__cover"; 2232 2233 <div class="background-image dw-mod"> 2234 <div class="background-image__wrapper dw-mod"> 2235 @Render(paragraphImage) 2236 </div> 2237 </div> 2238 } 2239 @{ 2240 switch (layout) 2241 { 2242 case "title-top": 2243 @RenderLayoutTitleTop(paragraph) 2244 break; 2245 case "image-left": 2246 @RenderLayoutImageLeft(paragraph) 2247 break; 2248 case "image-right": 2249 @RenderLayoutImageRight(paragraph) 2250 break; 2251 case "image-centered": 2252 @RenderLayoutImageCentered(paragraph) 2253 break; 2254 case "all-centered": 2255 @RenderLayoutAllCentered(paragraph) 2256 break; 2257 case "middle-center": 2258 case "middle-left": 2259 @RenderLayoutMiddle(paragraph) 2260 break; 2261 default: 2262 @RenderLayoutImageTop(paragraph) 2263 break; 2264 } 2265 } 2266 </div> 2267 } 2268 } 2269 2270 2271 @helper RenderLayoutTitleTop(ContentParagraph settings) 2272 { 2273 <div class="grid__cell @settings.CardCss @settings.InnerPaddingCss dw-mod"> 2274 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2275 @if (!settings.SetImageAsBackground && settings.Image != null) 2276 { 2277 <div class="u-margin-bottom--lg"> 2278 @Render(settings.Image) 2279 </div> 2280 } 2281 @Render(new Text { Content = settings.Text}) 2282 @Render(new ContentModule { Content = settings.Module }) 2283 2284 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2285 { 2286 <div class="grid__cell"> 2287 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2288 @Render(settings.ButtonPrimary) 2289 @Render(settings.ButtonSecondary) 2290 </div> 2291 </div> 2292 } 2293 </div> 2294 } 2295 2296 @helper RenderLayoutImageLeft(ContentParagraph settings) 2297 { 2298 <div class="grid__cell @settings.CardCss @settings.InnerPaddingCss dw-mod"> 2299 <div class="grid grid--external-bleed"> 2300 @if (!settings.SetImageAsBackground && settings.Image != null) 2301 { 2302 <div class="grid__col-3"> 2303 @Render(settings.Image) 2304 </div> 2305 } 2306 <div class="grid__col-9 @settings.InnerPaddingCss dw-mod"> 2307 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2308 @Render(new Text { Content = settings.Text }) 2309 @Render(new ContentModule { Content = settings.Module }) 2310 2311 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2312 { 2313 <div class="grid__cell"> 2314 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2315 @Render(settings.ButtonPrimary) 2316 @Render(settings.ButtonSecondary) 2317 </div> 2318 </div> 2319 } 2320 </div> 2321 </div> 2322 </div> 2323 } 2324 2325 @helper RenderLayoutImageRight(ContentParagraph settings) 2326 { 2327 <div class="grid__cell @settings.CardCss"> 2328 <div class="grid grid--external-bleed"> 2329 <div class="grid__col-9 @settings.InnerPaddingCss dw-mod"> 2330 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2331 @Render(new Text { Content = settings.Text }) 2332 @Render(new ContentModule { Content = settings.Module }) 2333 2334 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2335 { 2336 <div class="grid__cell"> 2337 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2338 @Render(settings.ButtonPrimary) 2339 @Render(settings.ButtonSecondary) 2340 </div> 2341 </div> 2342 } 2343 </div> 2344 @if (!settings.SetImageAsBackground && settings.Image != null) 2345 { 2346 <div class="grid__col-3"> 2347 @Render(settings.Image) 2348 </div> 2349 } 2350 </div> 2351 </div> 2352 } 2353 2354 @helper RenderLayoutImageCentered(ContentParagraph settings) 2355 { 2356 <div class="grid__cell @settings.CardCss @settings.InnerPaddingCss dw-mod"> 2357 2358 <div class="u-ta-center"> 2359 @if (!settings.SetImageAsBackground && settings.Image != null) 2360 { 2361 <div class="u-margin-bottom--lg u-inline-block"> 2362 @Render(settings.Image) 2363 </div> 2364 } 2365 </div> 2366 2367 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2368 @Render(new Text { Content = settings.Text }) 2369 @Render(new ContentModule { Content = settings.Module }) 2370 2371 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2372 { 2373 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2374 @Render(settings.ButtonPrimary) 2375 @Render(settings.ButtonSecondary) 2376 </div> 2377 } 2378 </div> 2379 } 2380 2381 @helper RenderLayoutAllCentered(ContentParagraph settings) 2382 { 2383 <div class="grid__cell @settings.CardCss @settings.InnerPaddingCss dw-mod"> 2384 2385 <div class="u-ta-center"> 2386 @if (!settings.SetImageAsBackground && settings.Image != null) 2387 { 2388 <div class="u-margin-bottom--lg u-inline-block"> 2389 @Render(settings.Image) 2390 </div> 2391 } 2392 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2393 @Render(new Text { Content = settings.Text }) 2394 @Render(new ContentModule { Content = settings.Module }) 2395 </div> 2396 2397 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2398 { 2399 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2400 @Render(settings.ButtonPrimary) 2401 @Render(settings.ButtonSecondary) 2402 </div> 2403 } 2404 </div> 2405 } 2406 2407 @helper RenderLayoutMiddle(ContentParagraph settings) 2408 { 2409 <div> 2410 <div class="grid__cell @settings.CardCss @settings.InnerPaddingCss dw-mod"> 2411 2412 <div class="@(settings.Layout == "middle-center" ? "u-ta-center" : "")"> 2413 @if (!settings.SetImageAsBackground && settings.Image != null) 2414 { 2415 <div class="u-margin-bottom--lg u-inline-block"> 2416 @Render(settings.Image) 2417 </div> 2418 } 2419 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2420 @Render(new Text { Content = settings.Text }) 2421 @Render(new ContentModule { Content = settings.Module }) 2422 </div> 2423 2424 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2425 { 2426 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2427 @Render(settings.ButtonPrimary) 2428 @Render(settings.ButtonSecondary) 2429 </div> 2430 } 2431 </div> 2432 </div> 2433 } 2434 2435 @helper RenderLayoutImageTop(ContentParagraph settings) 2436 { 2437 <div class="grid__cell @settings.CardCss"> 2438 @if (!settings.SetImageAsBackground && settings.Image != null) 2439 { 2440 <div class="u-margin-bottom--lg"> 2441 @Render(settings.Image) 2442 </div> 2443 } 2444 2445 <div class="@settings.InnerPaddingCss dw-mod"> 2446 @Render(new Heading { Level = 2, Title = settings.Title, Link = settings.Link }) 2447 @Render(new Text { Content = settings.Text }) 2448 @Render(new ContentModule { Content = settings.Module }) 2449 2450 @if (settings.ButtonPrimary != null || settings.ButtonSecondary != null) 2451 { 2452 <div class="paragraph-container__button @settings.ButtonWrapperCss dw-mod"> 2453 @Render(settings.ButtonPrimary) 2454 @Render(settings.ButtonSecondary) 2455 </div> 2456 } 2457 </div> 2458 </div> 2459 } 2460 2461 2462 @{ 2463 string fontColor = !string.IsNullOrEmpty(Model.Item.GetString("FontColor")) && !Model.Item.GetString("FontColor").StartsWith("#") ? "u-" + Model.Item.GetString("FontColor").Replace(" ", "-").ToLower() : ""; 2464 string backgroundColor = !string.IsNullOrEmpty(Model.Item.GetString("BackgroundColor")) && !Model.Item.GetString("BackgroundColor").StartsWith("#") ? "u-" + Model.Item.GetString("BackgroundColor").Replace(" ", "-").ToLower() + "--bg" : ""; 2465 string colorSettings = Model.Item.GetString("FontColor").StartsWith("#") || Model.Item.GetString("BackgroundColor").StartsWith("#") ? "style=\"" : ""; 2466 string fontColorHex = Model.Item.GetString("FontColor").StartsWith("#") ? "color: " + Model.Item.GetString("FontColor") + ";" : ""; 2467 string backgroundColorHex = Model.Item.GetString("BackgroundColor").StartsWith("#") ? "background-color: " + Model.Item.GetString("BackgroundColor") + ";" : ""; 2468 colorSettings += fontColorHex; 2469 colorSettings += backgroundColorHex; 2470 colorSettings += Model.Item.GetString("FontColor").StartsWith("#") || Model.Item.GetString("BackgroundColor").StartsWith("#") ? "\"" : ""; 2471 2472 string paragraphContainerClasses = ""; 2473 string containerClasses = ""; 2474 string gridClasses = ""; 2475 2476 string spacingSize = Model.Item.GetList("Spacing") != null && Model.Item.GetList("Spacing").SelectedValue != "" ? Model.Item.GetList("Spacing").SelectedValue : "lg"; 2477 2478 switch (Model.Item.GetList("Width").SelectedValue) 2479 { 2480 case "center": 2481 containerClasses += "center-container paragraph-container "; 2482 paragraphContainerClasses += " " + fontColor + " " + backgroundColor; 2483 break; 2484 case "full": 2485 containerClasses += fontColor + " " + backgroundColor + " "; 2486 paragraphContainerClasses += "paragraph-container--full-width "; 2487 break; 2488 case "combi": 2489 paragraphContainerClasses += "paragraph-container--full-width " + fontColor + " " + backgroundColor + " "; 2490 containerClasses += "center-container paragraph-container "; 2491 break; 2492 default: 2493 paragraphContainerClasses += "center-container "; 2494 break; 2495 } 2496 2497 //Background 2498 string focalPointParameters = Model.Item.GetFile("BackgroundImage") != null ? "&" + Model.Item.GetFile("BackgroundImage").GetFocalPointParameters() : ""; 2499 2500 string containerBackgroundImageFilterColor = Model.Item.GetList("ColorForTheFilter") != null ? Model.Item.GetString("ColorForTheFilter").Replace(" ", "-").ToLower() : "none"; 2501 string containerBackgroundImageFilterPrimary = Model.Item.GetList("ImageFilterPrimary") != null ? Model.Item.GetList("ImageFilterPrimary").SelectedValue : "none"; 2502 string containerBackgroundImageFilterSecondary = Model.Item.GetList("ImageFilterSecondary") != null ? Model.Item.GetList("ImageFilterSecondary").SelectedValue : "none"; 2503 string containerBackgroundImageFilterColorCode = Model.Item.GetString("ColorForTheFilter").StartsWith("#") && containerBackgroundImageFilterPrimary == "colorize" ? "style=\"background-color: " + GenerateRgba(Model.Item.GetString("ColorForTheFilter"), 0.3) + "\"" : ""; 2504 2505 if (containerBackgroundImageFilterPrimary == "colorize" && !containerBackgroundImageFilterPrimary.StartsWith("#")) 2506 { 2507 containerBackgroundImageFilterPrimary = containerBackgroundImageFilterColor; 2508 } 2509 2510 if (Model.Item.GetFile("BackgroundImage") == null) { 2511 backgroundColor = "u-color-light--bg"; 2512 } 2513 2514 //Separation line 2515 bool hasSeparationLine = Model.Item.GetBoolean("SeperationLineAfter"); 2516 if (hasSeparationLine && Model.Item.GetList("Width").SelectedValue != "center") 2517 { 2518 paragraphContainerClasses += "multiple-paragraphs-container--seperation-line-after "; 2519 } 2520 else if (hasSeparationLine) 2521 { 2522 containerClasses += "multiple-paragraphs-container--seperation-line-after "; 2523 } 2524 2525 //Alternative Design Layout 2526 var designLayout = Model.Item.GetItem("CustomSettings") != null ? Model.Item.GetItem("CustomSettings").GetString("DesignLayout") != null ? Model.Item.GetItem("CustomSettings").GetList("DesignLayout").SelectedValue : "" : ""; 2527 paragraphContainerClasses += !String.IsNullOrEmpty(designLayout) ? designLayout : ""; 2528 2529 var paragraphHeight = Model.Item.GetList("Height").SelectedValue; 2530 //Height 2531 if (!string.IsNullOrEmpty(paragraphHeight)) 2532 { 2533 gridClasses += "paragraph-container--height-" + paragraphHeight + " " + (paragraphHeight == "screen" ? "screen-height " : ""); 2534 } 2535 2536 if (Model.Item.GetString("MakeParagraphsCenterAligned") != null && Model.Item.GetBoolean("MakeParagraphsCenterAligned")) 2537 { 2538 gridClasses += "grid--justify-center "; 2539 } 2540 2541 //Set as carousel 2542 if (Model.Item.GetBoolean("EnableCarousel")) 2543 { 2544 containerClasses.Replace(" paragraph-container ", ""); 2545 } 2546 2547 //getting video ID from youtube URL 2548 string videoCode = Model.Item.GetString("VideoURL"); 2549 Regex regex = new Regex(@".be\/(.[^?]*)"); 2550 Match match = regex.Match(videoCode); 2551 string videoId = ""; 2552 if (match.Success) 2553 { 2554 videoId = match.Groups[1].Value; 2555 } 2556 else 2557 { 2558 regex = new Regex(@"v=([^&]+)"); 2559 match = regex.Match(videoCode); 2560 if (match.Success) 2561 { 2562 videoId = match.Groups[1].Value; 2563 } 2564 } 2565 } 2566 2567 <div class="grid__col-md-12 grid__col--bleed"> 2568 <section class="multiple-paragraphs-container @paragraphContainerClasses multiple-paragraphs-container--spacing-@spacingSize dw-mod" @colorSettings> 2569 <div class="background-image image-filter image-filter--@containerBackgroundImageFilterPrimary dw-mod" @containerBackgroundImageFilterColorCode> 2570 <div class="background-image__wrapper image-filter image-filter--@containerBackgroundImageFilterSecondary dw-mod"> 2571 @if (!String.IsNullOrEmpty(Model.Item.GetString("BackgroundImage"))) { 2572 @Render(new Image { 2573 Path = Model.Item.GetFile("BackgroundImage").PathUrlEncoded + focalPointParameters, 2574 CssClass = "background-image__cover", 2575 ImageDefault = new ImageSettings { 2576 Width = 1920, 2577 Height = 845, 2578 Crop = 0, 2579 FillCanvas = true 2580 }, 2581 ImageMedium = new ImageSettings 2582 { 2583 Width = 1024, 2584 Height = 450, 2585 Crop = 0, 2586 FillCanvas = true 2587 }, 2588 ImageSmall = new ImageSettings 2589 { 2590 Width = 640, 2591 Height = 544, 2592 Crop = 0, 2593 FillCanvas = true 2594 } 2595 }) 2596 } 2597 2598 @if (!string.IsNullOrEmpty(videoId)) 2599 { 2600 <div class="video-background"> 2601 <div class="video-background__container"> 2602 <div class="js-youtube-video" data-video="@videoId" id="ytPlayer@(Model.ID)"></div> 2603 </div> 2604 </div> 2605 } 2606 </div> 2607 </div> 2608 2609 @if (!Model.Item.GetBoolean("EnableCarousel")) 2610 { 2611 <div class="@containerClasses dw-mod"> 2612 <div class="grid @gridClasses dw-mod"> 2613 @foreach (var paragraph in Model.Item.GetItems("Paragraph")) 2614 { 2615 @RenderParagraph(paragraph, false) 2616 } 2617 @if (!String.IsNullOrEmpty(Model.GetModuleOutput())) { 2618 <div class="paragraph-container grid__col-12 dw-mod"> 2619 @Render(new ContentModule { Content = Model.GetModuleOutput() }) 2620 </div> 2621 } 2622 </div> 2623 </div> 2624 } 2625 else 2626 { 2627 var slides = new List<List<Dynamicweb.Frontend.ItemViewModel>>(); 2628 int tempColumnsCount = 0; 2629 var paragraphs = Model.Item.GetItems("Paragraph"); 2630 bool hasAtLeastOneVisibleParagraph = false; 2631 if (paragraphs.Count > 0) 2632 { 2633 slides.Add(new List<Dynamicweb.Frontend.ItemViewModel>()); 2634 } 2635 2636 foreach (var paragraph in paragraphs) 2637 { 2638 int columnWidth = 0; 2639 if (Pageview.Device.ToString() == "Mobile" && paragraph.GetList("WidthMobile").SelectedValue == "hide") 2640 { 2641 continue; 2642 } 2643 hasAtLeastOneVisibleParagraph = true; 2644 if (paragraph.GetList("Width").SelectedValue != "auto") 2645 { 2646 columnWidth = Pageview.Device.ToString() != "Mobile" ? Int32.Parse(paragraph.GetList("Width").SelectedValue) : Int32.Parse(paragraph.GetList("WidthMobile").SelectedValue); 2647 } 2648 else 2649 { 2650 columnWidth = 1; 2651 } 2652 2653 if (tempColumnsCount + columnWidth > 12) 2654 { 2655 slides.Add(new List<Dynamicweb.Frontend.ItemViewModel>()); 2656 tempColumnsCount = 0; 2657 } 2658 2659 slides[slides.Count - 1].Add(paragraph); 2660 tempColumnsCount += columnWidth; 2661 } 2662 2663 if (hasAtLeastOneVisibleParagraph) 2664 { 2665 <div class="@containerClasses dw-mod"> 2666 <div class="carousel dw-mod" id="Paragraph_@(Model.ID)"> 2667 <div class="carousel__container js-carousel-slides dw-mod"> 2668 @foreach (var slide in slides) 2669 { 2670 <div class="carousel__slide dw-mod"> 2671 <div class="grid @gridClasses dw-mod"> 2672 @foreach (var paragraph in slide) 2673 { 2674 @RenderParagraph(paragraph, false) 2675 } 2676 </div> 2677 </div> 2678 } 2679 </div> 2680 </div> 2681 </div> 2682 } 2683 2684 if (slides.Count > 1) 2685 { 2686 bool enableDots = Model.Item.GetBoolean("ShowDots"); 2687 2688 <script> 2689 document.addEventListener("DOMContentLoaded", function () { 2690 new CarouselModule("#Paragraph_@(Model.ID)", { 2691 slideTime: @Model.Item.GetString("SlideTime"), 2692 dots: @(Model.Item.GetBoolean("ShowDots").ToString().ToLower()) 2693 }); 2694 }) 2695 </script> 2696 } 2697 } 2698 </section> 2699 </div> 2700

Why

More than 99% of Beirholm's CO2e emissions occur in scope 3. And of those emissions, the majority occur in the manufacturing- or the use phase of our textiles. Hence, our focus remains to reduce CO2e emissions through the further development of our climate friendly BeirTex® performance textiles. In addition, we also take a new step by activating a new partner in our Value Creation Network.

To increase the focus on sustainable performance textiles in one of our end-customer markets - the hospitality industry - we have signed a collaboration agreement with Green Key. Through this collaboration, we aim to take our climate strategy, Together to Zero, to the next level by educating the hotel industry and thereby supporting our laundry partners' efforts in bringing more sustainable textiles to the industry.